- last update
over 1 year ago Custom Commands Failed - πΊπΈUnited States tim bozeman
What do y'all think about this patch? It tweaks
Drupal.editors[editor].attach
so it expects a promise and then dispatches aneditor:attached
event.I was doing a really odd work around before finding this issue.
const observer = new MutationObserver((mutationsList) => { mutationsList.forEach((mutation) => { if (mutation.attributeName === 'data-ckeditor5-id') { var waitForEditor = setInterval((ckeditor5Id, textArea) => { const editor = Drupal.CKEditor5Instances.get(ckeditor5Id); if (editor) { // Do stuff ... clearInterval(waitForEditor); observer.disconnect(); } }, 50, mutation.target.dataset.ckeditor5Id, mutation.target); } }); }); observer.observe(field, {attributes: true});
- last update
over 1 year ago Patch Failed to Apply - last update
over 1 year ago 28,526 pass - Status changed to Needs work
over 1 year ago 8:28pm 16 June 2023 The Needs Review Queue Bot β tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide β to find step-by-step guides for working with issues.
- last update
over 1 year ago Patch Failed to Apply - π«π·France nod_ Lille
should be 11.x even
+++ b/core/modules/editor/js/editor.js @@ -297,7 +297,18 @@ + const editorAttachPromise = Drupal.editors[format.editor].attach( + field, + format, + ); + editorAttachPromise.then( + (editor) => { + $(document).trigger('editor:attached', [editor]); + }, + (error) => { + console.log(`Failed to attach editor.\n${error}`); + }, + );
I'd do away with the editorAttachPromise variable and simply call .then() after the .attach().
Also it would be better to use a catch instead of the second parameter of the then method.
- Status changed to Needs review
over 1 year ago 10:54pm 16 June 2023 - last update
over 1 year ago 29,486 pass - πΊπΈUnited States tim bozeman
Wow, that was quick! Thanks for reviewing! Yes indeed, that is more concise. ππ»
- Status changed to Needs work
over 1 year ago 1:33pm 17 June 2023 - πΊπΈUnited States smustgrave
Could we add some test coverage for this new feature?
Also could some of the missing pieces of the issue summary be updated just to help the review
Thanks!.
- First commit to issue fork.
- Merge request !5478Issue #3319358 by Tim Bozeman, pooja saraah, JeffM2001: Trigger event when Text Editor is attached β (Open) created by dinazaur
- πΊπ¦Ukraine dinazaur
I just opened MR, so it is easier to manage, review, and update the code. It contains same changes as the patch in #13. I just could not apply the patch for the latest D10, so re-rolled it in MR.
- πΊπΈUnited States tim bozeman
It looks like some extra white space was added when re-rolling #13 into an MR.
- First commit to issue fork.
Removed the whitespaces mentioned in #18 and rebased the branch on 11.x
- πΊπΈUnited States nessthehero
Was able to spin up an instance using the MR and write a custom module that ties into this event. Seems to work great!
((Drupal, $) => { Drupal.behaviors.testEditorAttachment = { attach() { console.log('behavior attached'); $(document).on('editor:attached', function (event, editor) { if (typeof editor !== "undefined") { console.log('Event works!', event, editor); editor.setData('<p>Hello world!</p>'); } }); } }; })(Drupal, jQuery);
It's wishful thinking, but it'd be nice if this used native web Event Listeners rather than jQuery events, to reduce another need for jQuery in the large scheme of things, but it works as expected.
I won't mark as RTBC since this needs tests, but this is definitely something I could use in my current projects.
Would it be possible to roll this for 10.1? Is there a reason it must wait til 11?
- last update
12 months ago 29,722 pass - last update
12 months ago Patch Failed to Apply - πΊπΈUnited States jtwalters
The current patch direction does not account for editors that do not return a Promise. This results in a JS error, like that below:
Uncaught TypeError: Drupal.editors[format.editor].attach(...).then is not a function
Example: Try creating an Ace Editor text format and then switching to it, and then try switching back to a CKEditor 5 type format.
- πΊπΈUnited States jtwalters
Re-rolled for Drupal 10.2.3 with
Promise.resolve()
change per #22 - last update
10 months ago 29,722 pass - heddn Nicaragua
Can we get these changes back into the MR? Core doesn't really use a patch workflow any more.
- Status changed to Needs review
9 months ago 1:51pm 8 April 2024 - heddn Nicaragua
Fixed up MR and merged #24 back into it. I've hid all the patches.
- Status changed to Needs work
9 months ago 2:20pm 8 April 2024 - πΊπΈUnited States smustgrave
Thanks for turning to an MR.
Moving to NW for the tests and issue summary update.
- π³π±Netherlands daaan
The patch #24 does not work with 10.3.1. I have recreated the patch to ensure it is compatible with version 10.3.1.