Problem/Motivation

core/modules/editor/js/editor.admin.js provides the following public JS APIs:

  1. Drupal.editorConfiguration
  2. Drupal.EditorFeatureHTMLRule
  3. Drupal.EditorFeature
  4. Drupal.FilterStatus
  5. Drupal.FilterHTMLRule
  6. Drupal.filterConfiguration
  7. Drupal.behaviors.initializeFilterConfiguration

Plus the things integrating with the above:

  1. Drupal.filterConfiguration.liveSettingParsers.filter_html.getRules()
  2. Drupal.behaviors.filterFilterHtmlUpdating
  3. Drupal.theme.filterFilterHTMLUpdateMessage

Crucially, none of this has any test coverage, because it predates FunctionalJavascript testing infrastructure.

Its docs say:

Provides a JavaScript API to broadcast text editor configuration changes.

Filter implementations may listen to the drupalEditorFeatureAdded,
drupalEditorFeatureRemoved, and drupalEditorFeatureRemoved events on document
to automatically adjust their settings based on the editor configuration.

Mea culpa

I wrote this, in #1894644: Unidirectional editor configuration -> filter settings syncing, over 9 years ago. It was how we made the UX for configuring CKEditor 4 somewhat decent: whenever you changed the CKEditor 4 toolbar (added buttons) or changed plugin settings (e.g. configured more styles for StylesCombo), it'd automatically update the filter_html filter configuration, to keep it in sync.

I already knew it was not great. It was a necessary evil. The follow-up work to make it decentnever happened (that was the original purpose of this issue, but it was recoped in #17).

The reason it's all in JS is simply because for CKEditor 4, it is impossible to know which HTML tags, attributes and attribute values a particular CKEditor capability needs (requires) or (optionally) supports. So … for CKEditor 4, we had a hidden CKEditor 4 instance right in the configuration UI, to query the capabilities "live". That's how we were able to keep filter_html in sync. Imperfectly (there are many bug reports around this, for example #2649546: [upstream] Alignment/justify buttons not appearing for CKEditor, <p class="text-align-left text-align-center text-align-right text-align-justify"> not being allowed automatically), but … better than nothing.

With CKEditor 5, we do know on the server side which HTML tags/attributes/attribute values are supported. This was critical to be able to have an upgrade path at all.

Which means all that infrastructure is unused in Drupal core.

That leaves one key question: does contrib use it at all? Let's find out:

Text Editors triggering
  1. addedFeature → 0 results
  2. removedFeature → 0 results
  3. modifiedFeature → 0 results

Conclusion: not a single text editor besides core's CKEditor 4 supported this.

Text Filters reacting to Text Editors
  1. drupalEditorFeatureAdded → 1 result: linkit
  2. drupalEditorFeatureRemoved → 1 result: linkit
  3. drupalEditorFeatureModified → 0 results

Conclusion: only one.

Proposed resolution

Deprecate in 10.3.x, for removal in Drupal 11.

Remaining tasks

None.

User interface changes

None.

API changes

Deprecated everything in editor.admin.js: https://www.drupal.org/node/3422372

Data model changes

None.

Issue fork drupal-2567801

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Wim Leers created an issue. See original summary.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

alison’s picture

Is this issue outdated, or still valid?

I wandered over here by way of this comment (which, if this issue is outdated, should be updated -- I can create an issue for that, just figured I'd check here first):
https://git.drupalcode.org/project/drupal/-/blob/1438e66fbd7806ab97fae3a...

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wim leers’s picture

Title: Generalize the data structures used for unidirectional editor configuration -> filter settings syncing » Deprecate core/modules/editor/js/editor.admin.js JS APIs in Drupal 10, for removal in Drupal 11
Version: 9.5.x-dev » 10.0.x-dev
Issue summary: View changes
Issue tags: +Drupal 10 beta should-have, +JavaScript

Version: 10.0.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wim leers’s picture

Assigned: Unassigned » wim leers
Priority: Normal » Major
Issue tags: -Drupal 10 beta should-have, -JavaScript +Drupal 10, +JavaScript, +Drupal 11, +@deprecated

Drupal 11 is getting close, so … let's finally get this done 🙈

wim leers’s picture

Assigned: wim leers » Unassigned
Issue summary: View changes
Status: Active » Needs review

CR created: https://www.drupal.org/node/3422372

Followed the guidelines in https://www.drupal.org/node/3082634 to deprecate JS APIs.

smustgrave’s picture

Status: Needs review » Needs work

Ran the javascript tests 3 times and they still fail so believe they are legit to the change.

wim leers’s picture

Status: Needs work » Needs review

@smustgrave Yes, they still fail because core is still calling these APIs. And it has to, to avoid breaking BC. Which is what @lauriii indicated in his review on the MR.

it could be tricky since I'm not sure there's a good way for us to retrieve the currently registered event listeners.

Indeed. There is no way AFAICT.

But there is one thing we can do, which I'd like to get @lauriii's thoughts on:

  1. editor.admin.js is loaded automatically for FilterFormatEditForm thanks to editor_form_filter_format_form_alter() doing
        '#attached' => [
          'library' => [
            'editor/drupal.editor.admin',
          ],
        ],
    
  2. but it's already the responsibility of each text editor that uses these APIs to depend on the editor/drupal.editor.admin asset library (otherwise it's possible it be loaded too late!) — the CKEditor 4 module does that too for example: https://git.drupalcode.org/project/ckeditor/-/blob/1.0.1/ckeditor.librar...
  3. therefore the solution is fairly simple: remove the auto-loading in #1, and instead rely on asset library dependencies, which it should've been doing all along

(AFAICT the reason the auto-loading was still present: #1894644: Unidirectional editor configuration -> filter settings syncing introduced that asset library and predates strong use of dependencies, which happened a year later, in #1996238: Replace hook_library_info() by *.libraries.yml file.)

Implemented that.

lauriii’s picture

Status: Needs review » Needs work

Looks like core/modules/filter/filter.filter_html.admin.js has dependency on it, but it's not declaring it's dependencies correctly... 😅

wim leers’s picture

Issue summary: View changes
Status: Needs work » Needs review

That's because I should've deleted that too 😅

wim leers’s picture

Note that this now blocks #3239012, see #3239012-35: [11.x] Remove the CKEditor 4 upgrade path.

wim leers’s picture

Issue tags: +blocker
smustgrave’s picture

Status: Needs review » Needs work

Seems to have a failing Filter javascript test.

wim leers’s picture

Assigned: Unassigned » wim leers
wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs work » Needs review
Related issues: +#2556069: JS error with elements in "allowed HTML tags" that can't be direct descendants of a div

Ah, the sole failing test was one added (in #2556069: JS error with elements in "allowed HTML tags" that can't be direct descendants of a div) for the functionality this is deprecating and no longer executing by default. It was to avoid this functionality regressing to the same bug again, but since this JS functionality is A) deprecated, B) has not been touched in years and won't be, there is no more need for this regression test 👍

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

I don't know why but I chuckled reading "They were buggy ever since they were introduced in Drupal 8.0". Tests are showing green and deprecation links appear correct

LGTM!

catch’s picture

Status: Reviewed & tested by the community » Needs review

already knew it was not great. It was a necessary evil. The follow-up work to make it decent (#2567801: Deprecate core/modules/editor/js/editor.admin.js JS APIs in Drupal 10, for removal in Drupal 11) never happened.

This links back to here instead of linking to the issue. Not really a commit blocker but nice not to have circles.

Text Filters reacting to Text Editors
drupalEditorFeatureAdded → 1 result: linkit
drupalEditorFeatureRemoved → 1 result: linkit
drupalEditorFeatureModified → 0 results
Conclusion: only one.

Is this in linkit's CKEditor 4 integration? I checked and it's in the latest branch. If it's only for ckeditor4 integration then I think we just need a follow-up since maybe linkit can drop ckeditor4 support at this point rather than trying to update for this, if they're somehow relying on this for ckeditor5, then I thnk we would have to deprecate for removal in Drupal 12 at this point.

wim leers’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

#32: see #17 — I repurposed this issue 😅 Clarified that 👍

Is this in linkit's CKEditor 4 integration? I checked and it's in the latest branch. If it's only for ckeditor4 integration then I think we just need a follow-up since maybe linkit can drop ckeditor4 support at this point rather than trying to update for this, if they're somehow relying on this for ckeditor5, then I thnk we would have to deprecate for removal in Drupal 12 at this point.

You're >right. Yes, it's only for CKEditor 4. It can only be for CKEditor 4, because CKEditor 5 is not using any of the JS APIs that are being removed here.

Note that LinkIt 6 supports both CKEditor 4 and 5 at our request: because it makes switching from 4 to 5 a lot less painful (both Editor plugins must be available simultaneously to be able to switch without shenanigans). I don't think a follow-up is necessary; this will just mean that the automatic updating of the filter_html format will stop working if you're setting up a NEW text format+editor to use CKEditor 4. But we're only deprecating it here (in Drupal 10.3), not removing it yet. You won't be able to have CKEditor 4 on Drupal 11 at all, so it getting removed then won't break anything 👍

  • catch committed 3eab4038 on 10.3.x
    Issue #2567801 by Wim Leers, lauriii: Deprecate core/modules/editor/js/...

  • catch committed a3930399 on 11.x
    Issue #2567801 by Wim Leers, lauriii: Deprecate core/modules/editor/js/...
catch’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Thanks for confirming. linkit presumably will need to remove its own ckeditor4 support but that should probably happen in a branch that drops support for Drupal 10, so a bit further ahead than us doing so in Drupal 11.

Committed/pushed to 11.x and cherry-picked to 10.3.x, thanks!

spokje’s picture

Am a bit confused, but shouldn't the 11.x commit remove the core/modules/editor/js/editor.admin.js JS APIs?
Or is this happening in a follow-up?
Or am I just not reading this correctly?

wim leers’s picture

Thanks! Really nice to see this code removed from Drupal core, it's probably the code I got in core that I was most ashamed of, so … relieved to see it gone 🌅 😄

wim leers’s picture

CR published.

catch’s picture

Am a bit confused, but shouldn't the 11.x commit remove the core/modules/editor/js/editor.admin.js JS APIs?
Or is this happening in a follow-up?
Or am I just not reading this correctly?

Since we've only just started removing deprecated code from 11.x, I've been assuming that new deprecations for 11.x removal will get caught by 'remove deprecated code in x' module issues or a final sweep before beta. It would be fine to do 11.x removal and 10.3.x deprecation MRs on one issue, but also there aren't many things we're deprecating for 11.x removal any more, and don't want to encourage people to do separate removal MRs for issues where we end up deprecated for removal in 12.x after all.

wim leers’s picture

I've been assuming that new deprecations for 11.x removal will get caught by 'remove deprecated code in x' module issues or a final sweep before beta.

Same!

Especially for this one, where removal will be trivial 👍 (Delete a few lines in editor.libraries.yml, delete two *.js files, done!)

spokje’s picture

Since we've only just started removing deprecated code from 11.x, I've been assuming that new deprecations for 11.x removal will get caught by 'remove deprecated code in x' module issues or a final sweep before beta.

Ah, I somehow thought, as soon as a new major release branch was opened, issues with deprecations in that major should deliver two MRs for next minor and next major.

Fine by me, although I think this is optimistic and at some point (maybe not in 10.3.x, but still, at some point) we will discover a big BC-issue at the last minute when doing such a final scan.

Then again, there's always a fine balance between too many and too few rules and extra work for deprecations, so let's run with this :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.