From d48c3709cd1d161a23e11ed8b318bbb2579d4761 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Mon, 9 Oct 2017 23:41:40 +0100 Subject: [PATCH] Remove support for registerHalloPlugin --- .../customisation/page_editing_interface.rst | 16 +--------------- wagtail/wagtailadmin/rich_text.py | 10 ---------- .../wagtailadmin/js/hallo-bootstrap.js | 4 ++-- .../static_src/wagtailadmin/js/page-editor.js | 17 ++++------------- wagtail/wagtailadmin/tests/test_rich_text.py | 4 ++-- wagtail/wagtailcore/rich_text.py | 6 ------ wagtail/wagtaildocs/wagtail_hooks.py | 1 - wagtail/wagtailembeds/wagtail_hooks.py | 1 - wagtail/wagtailimages/wagtail_hooks.py | 1 - 9 files changed, 9 insertions(+), 51 deletions(-) diff --git a/docs/advanced_topics/customisation/page_editing_interface.rst b/docs/advanced_topics/customisation/page_editing_interface.rst index 6207210087..a5f622ebf7 100644 --- a/docs/advanced_topics/customisation/page_editing_interface.rst +++ b/docs/advanced_topics/customisation/page_editing_interface.rst @@ -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 `_ 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 ` hook to insert the Javascript line ``registerHalloPlugin(, );``: +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( - """ - - """ - ) - -.. note:: - - The call to ``registerHalloPlugin`` is required to ensure backwards compatibility; this requirement will be dropped in Wagtail 1.14. - .. _rich_text_image_formats: diff --git a/wagtail/wagtailadmin/rich_text.py b/wagtail/wagtailadmin/rich_text.py index c7bbfec105..d4d70e0c8e 100644 --- a/wagtail/wagtailadmin/rich_text.py +++ b/wagtail/wagtailadmin/rich_text.py @@ -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: diff --git a/wagtail/wagtailadmin/static_src/wagtailadmin/js/hallo-bootstrap.js b/wagtail/wagtailadmin/static_src/wagtailadmin/js/hallo-bootstrap.js index 018d12181a..95437398ce 100644 --- a/wagtail/wagtailadmin/static_src/wagtailadmin/js/hallo-bootstrap.js +++ b/wagtail/wagtailadmin/static_src/wagtailadmin/js/hallo-bootstrap.js @@ -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) { diff --git a/wagtail/wagtailadmin/static_src/wagtailadmin/js/page-editor.js b/wagtail/wagtailadmin/static_src/wagtailadmin/js/page-editor.js index cd1166d7d5..de74ca586c 100644 --- a/wagtail/wagtailadmin/static_src/wagtailadmin/js/page-editor.js +++ b/wagtail/wagtailadmin/static_src/wagtailadmin/js/page-editor.js @@ -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. diff --git a/wagtail/wagtailadmin/tests/test_rich_text.py b/wagtail/wagtailadmin/tests/test_rich_text.py index 8774c75088..12aed884d7 100644 --- a/wagtail/wagtailadmin/tests/test_rich_text.py +++ b/wagtail/wagtailadmin/tests/test_rich_text.py @@ -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') diff --git a/wagtail/wagtailcore/rich_text.py b/wagtail/wagtailcore/rich_text.py index 605a24d197..d606e205fd 100644 --- a/wagtail/wagtailcore/rich_text.py +++ b/wagtail/wagtailcore/rich_text.py @@ -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): diff --git a/wagtail/wagtaildocs/wagtail_hooks.py b/wagtail/wagtaildocs/wagtail_hooks.py index c84be4ca28..eab3c029b9 100644 --- a/wagtail/wagtaildocs/wagtail_hooks.py +++ b/wagtail/wagtaildocs/wagtail_hooks.py @@ -67,7 +67,6 @@ def editor_js(): """ """, urlresolvers.reverse('wagtaildocs:chooser') diff --git a/wagtail/wagtailembeds/wagtail_hooks.py b/wagtail/wagtailembeds/wagtail_hooks.py index 2e37d26655..aac316f6ac 100644 --- a/wagtail/wagtailembeds/wagtail_hooks.py +++ b/wagtail/wagtailembeds/wagtail_hooks.py @@ -23,7 +23,6 @@ def editor_js(): """ """, urlresolvers.reverse('wagtailembeds:chooser') diff --git a/wagtail/wagtailimages/wagtail_hooks.py b/wagtail/wagtailimages/wagtail_hooks.py index 2edacfe9c3..6d4a79421a 100644 --- a/wagtail/wagtailimages/wagtail_hooks.py +++ b/wagtail/wagtailimages/wagtail_hooks.py @@ -59,7 +59,6 @@ def editor_js(): """ """, urlresolvers.reverse('wagtailimages:chooser')