Remove support for registerHalloPlugin

pull/3923/head
Matt Westcott 2017-10-09 23:41:40 +01:00 zatwierdzone przez Matt Westcott
rodzic 119d2334ac
commit d48c3709cd
9 zmienionych plików z 9 dodań i 51 usunięć

Wyświetl plik

@ -121,7 +121,7 @@ The constructor for ``HalloPlugin`` accepts the following keyword arguments:
* ``css`` - a dictionary of CSS files to be imported for this plugin, defined in the same way as a `Django form media <https://docs.djangoproject.com/en/1.11/topics/forms/media/>`_ definition
* ``order`` - an index number (default 100) specifying the order in which plugins should be listed, which in turn determines the order buttons will appear in the toolbar
To have a feature active by default (i.e. on ``RichTextFields`` that do not define an explicit ``features`` list), add it to the ``default_features`` list on the ``features`` object, and use the :ref:`insert_editor_js <insert_editor_js>` hook to insert the Javascript line ``registerHalloPlugin(<plugin_name>, <opts>);``:
To have a feature active by default (i.e. on ``RichTextFields`` that do not define an explicit ``features`` list), add it to the ``default_features`` list on the ``features`` object:
.. code-block:: python
@ -135,20 +135,6 @@ To have a feature active by default (i.e. on ``RichTextFields`` that do not defi
)
features.default_features.append('blockquote')
@hooks.register('insert_editor_js')
def blockquote_editor_js():
return format_html(
"""
<script>
registerHalloPlugin('halloblockquote', {});
</script>
"""
)
.. note::
The call to ``registerHalloPlugin`` is required to ensure backwards compatibility; this requirement will be dropped in Wagtail 1.14.
.. _rich_text_image_formats:

Wyświetl plik

@ -93,11 +93,6 @@ class HalloRichTextArea(WidgetWithScript, widgets.Textarea):
if self.features is None:
self.features = features.get_default_features()
# RemovedInWagtail114Warning
self.use_legacy_plugin_config = True
else:
self.use_legacy_plugin_config = False
# construct a list of plugin objects, by querying the feature registry
# and keeping the non-null responses from get_editor_plugin
self.plugins = CORE_HALLO_PLUGINS + list(filter(None, [
@ -119,11 +114,6 @@ class HalloRichTextArea(WidgetWithScript, widgets.Textarea):
if self.options is not None and 'plugins' in self.options:
# explicit 'plugins' config passed in options, so use that
plugin_data = self.options['plugins']
elif self.use_legacy_plugin_config:
# RemovedInWagtail114Warning
# no feature list specified, so initialise without a plugins arg
# (so that it'll pick up the globally-defined halloPlugins list instead)
return "makeHalloRichTextEditable({0});".format(json.dumps(id_))
else:
plugin_data = OrderedDict()
for plugin in self.plugins:

Wyświetl plik

@ -32,8 +32,8 @@ function makeHalloRichTextEditable(id, plugins) {
richText.hallo({
toolbar: 'halloToolbarFixed',
toolbarCssClass: (closestObj.hasClass('full')) ? 'full' : (closestObj.hasClass('stream-field') && isRoot) ? 'stream-field' : '',
/* use the passed-in plugins arg if specified, otherwise use the global halloPlugins var */
plugins: plugins || halloPlugins
/* use the passed-in plugins arg */
plugins: plugins
}).bind('hallomodified', function(event, data) {
input.val(data.content);
if (!removeStylingPending) {

Wyświetl plik

@ -1,19 +1,10 @@
'use strict';
// registerHalloPlugin must be implemented here so it can be used by plugins
// hooked in with insert_editor_js (and hallo-bootstrap.js runs too late)
var halloPlugins = {
halloformat: {},
halloheadings: {formatBlocks: ['p', 'h2', 'h3', 'h4', 'h5']},
hallolists: {},
hallohr: {},
halloreundo: {},
hallowagtaillink: {},
hallorequireparagraphs: {}
};
var halloPlugins = {};
function registerHalloPlugin(name, opts) {
halloPlugins[name] = (opts || {});
/* Obsolete - used on Wagtail <1.12 to register plugins for the hallo.js editor.
Defined here so that third-party plugins can continue to call it to provide Wagtail <1.12
compatibility, without throwing an error on later versions. */
}
// Compare two date objects. Ignore minutes and seconds.

Wyświetl plik

@ -102,7 +102,7 @@ class TestDefaultRichText(BaseRichTextEditHandlerTestCase, WagtailTestUtils):
self.assertEqual(response.status_code, 200)
# Check that hallo (default editor by now)
self.assertContains(response, 'makeHalloRichTextEditable("id_body");')
self.assertContains(response, 'makeHalloRichTextEditable("id_body",')
# check that media for the default hallo features (but not others) is being imported
self.assertContains(response, 'wagtaildocs/js/hallo-plugins/hallo-wagtaildoclink.js')
@ -117,7 +117,7 @@ class TestDefaultRichText(BaseRichTextEditHandlerTestCase, WagtailTestUtils):
self.assertEqual(response.status_code, 200)
# Check that hallo (default editor by now)
self.assertContains(response, 'makeHalloRichTextEditable("__PREFIX__-value");')
self.assertContains(response, 'makeHalloRichTextEditable("__PREFIX__-value",')
# check that media for the default hallo features (but not others) is being imported
self.assertContains(response, 'wagtaildocs/js/hallo-plugins/hallo-wagtaildoclink.js')

Wyświetl plik

@ -227,12 +227,6 @@ class FeatureRegistry(object):
# a list of feature names that will be applied on rich text areas that do not specify
# an explicit `feature` list.
# RemovedInWagtail114Warning: Until Wagtail 1.14, features listed here MUST also
# update the legacy global halloPlugins list (typically by calling registerHalloPlugin
# within an insert_editor_js hook). This is because we special-case rich text areas
# without an explicit `feature` list, to use the legacy halloPlugins list instead of
# the one constructed using construct_plugins_list; this ensures that any user code
# that fiddles with halloPlugins will continue to work until Wagtail 1.14.
self.default_features = []
def get_default_features(self):

Wyświetl plik

@ -67,7 +67,6 @@ def editor_js():
"""
<script>
window.chooserUrls.documentChooser = '{0}';
registerHalloPlugin('hallowagtaildoclink');
</script>
""",
urlresolvers.reverse('wagtaildocs:chooser')

Wyświetl plik

@ -23,7 +23,6 @@ def editor_js():
"""
<script>
window.chooserUrls.embedsChooser = '{0}';
registerHalloPlugin('hallowagtailembeds');
</script>
""",
urlresolvers.reverse('wagtailembeds:chooser')

Wyświetl plik

@ -59,7 +59,6 @@ def editor_js():
"""
<script>
window.chooserUrls.imageChooser = '{0}';
registerHalloPlugin('hallowagtailimage');
</script>
""",
urlresolvers.reverse('wagtailimages:chooser')