Problem/Motivation
So my project has a few custom ckeditor plugins which add some custom HTML into the editor (which all needed to be rewritten for them to work with ckeditor5). I have these working for the most part...however I am seeing an issue when placing in a custom button into the editor.
The way I have these plugins set up is if they are double clicked, a modal opens up with a form where I can edit its attributes:

So this example will place an html button into the editor with html that looks like this (when viewing the source):
<button class="align-right" data-href="/node/1" data-text="click me" data-align="align-right">click me</button>
The code when inspecting the button in the editor itself looks like this:
<button class="align-right ck-editor__editable ck-editor__nested-editable" role="textbox" contenteditable="true">click me</button>
When I double click the button in the editor it to edit its attributes again, Drupal thinks I am submitting the node add form itself. The modal does open for a split second, but disappears when the page refreshes. I have a few other custom plugins that work similar to this, but those work fine.
I'm not sure why this is happening...but I think it has something to do with the fact that the contents of the ckeditor4 are inside of an iframe, whereas ckeditor5 it is not. I can't modify the HTML in any way as buttons placed previously using ckeditor4 need to continue to work.
Proposed resolution
Make sure an html button click does not attempt to submit the node add/edit form.
| Comment | File | Size | Author |
|---|
Comments
Comment #2
tlo405 commentedComment #3
cilefen commentedThis is filed as a bug report. I suppose we would need steps to reproduce it, which I think include having your custom code. Otherwise it should be a support request. Also: Drupal 9.4.x is no longer to be released except for security bug fixes.
Comment #4
wim leersThat's not "Drupal" that thinks this — nor CKEditor 5; it's your browser.
It's the responsibility of these plugins to ensure that the default behavior is prevented (
event.preventDefault()) when interacting with the HTML you generate!Comment #5
wim leers