Problem/Motivation
core/modules/editor/js/editor.admin.js provides the following public JS APIs:
Drupal.editorConfigurationDrupal.EditorFeatureHTMLRuleDrupal.EditorFeatureDrupal.FilterStatusDrupal.FilterHTMLRuleDrupal.filterConfigurationDrupal.behaviors.initializeFilterConfiguration
Plus the things integrating with the above:
Drupal.filterConfiguration.liveSettingParsers.filter_html.getRules()Drupal.behaviors.filterFilterHtmlUpdatingDrupal.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
addedFeature→ 0 resultsremovedFeature→ 0 resultsmodifiedFeature→ 0 results- Text Filters reacting to Text Editors
-
drupalEditorFeatureAdded→ 1 result:linkitdrupalEditorFeatureRemoved→ 1 result:linkitdrupalEditorFeatureModified→ 0 results
Conclusion: only one.
Conclusion: not a single text editor besides core's CKEditor 4 supported this.
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
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
Comment #14
alisonIs 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...
Comment #16
wim leersSee #2710427-81: Broken "Allowed Tags" updating: after all values for an attribute are allowed, it should not be overridden to allow only certain attribute values for a very detailed write-up for a proposed course of action.
Comment #17
wim leersPer @catch in #2710427-83: Broken "Allowed Tags" updating: after all values for an attribute are allowed, it should not be overridden to allow only certain attribute values.
Comment #19
wim leersDrupal 11 is getting close, so … let's finally get this done 🙈
Comment #21
wim leersCR created: https://www.drupal.org/node/3422372
Followed the guidelines in https://www.drupal.org/node/3082634 to deprecate JS APIs.
Comment #22
smustgrave commentedRan the javascript tests 3 times and they still fail so believe they are legit to the change.
Comment #23
wim leers@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.
Indeed. There is no way AFAICT.
But there is one thing we can do, which I'd like to get @lauriii's thoughts on:
editor.admin.jsis loaded automatically forFilterFormatEditFormthanks toeditor_form_filter_format_form_alter()doingeditor/drupal.editor.adminasset 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...(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.
Comment #24
lauriiiLooks like
core/modules/filter/filter.filter_html.admin.jshas dependency on it, but it's not declaring it's dependencies correctly... 😅Comment #25
wim leersThat's because I should've deleted that too 😅
Comment #26
wim leersNote that this now blocks #3239012, see #3239012-35: [11.x] Remove the CKEditor 4 upgrade path.
Comment #27
wim leersComment #28
smustgrave commentedSeems to have a failing Filter javascript test.
Comment #29
wim leersComment #30
wim leersAh, 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 👍
Comment #31
smustgrave commentedI 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!
Comment #32
catchThis links back to here instead of linking to the issue. Not really a commit blocker but nice not to have circles.
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.
Comment #33
wim leers#32: see #17 — I repurposed this issue 😅 Clarified that 👍
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
Editorplugins 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 thefilter_htmlformat 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 👍Comment #36
catchThanks 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!
Comment #37
spokjeAm 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?
Comment #38
wim leersThanks! 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 🌅 😄
Comment #39
wim leersCR published.
Comment #40
catchSince 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.
Comment #41
wim leersSame!
Especially for this one, where removal will be trivial 👍 (Delete a few lines in
editor.libraries.yml, delete two*.jsfiles, done!)Comment #42
spokjeAh, 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 :)