Non editable elements don't work as soon as they are replaced by new non editable elements (even when identical)
See original GitHub issueWhat is the current behavior? Describe the bug
- Enable the
noneditable
plugin - Enter the following HTML through the “source code” modal:
<div id="non-editable-bug" class="mceNonEditable">Non editable bug</div>
- TinyMCE shouldn’t allow to edit the “Non editable bug” text; which is expected
- Now replace the entire
<div>
with the exact same contents using the following code:tinymce.activeEditor.dom.setOuterHTML(tinymce.activeEditor.dom.select('#non-editable-bug'), '<div id="non-editable-bug" class="mceNonEditable">Non editable bug</div>')
- Note that it now allows the “Non editable bug” text to be edited, which means the
<div>
is no longer non editable
What is the expected behavior?
The “Non editable bug” text given in the above steps shouldn’t be allowed to edit after replacement since the mceNonEditable
class is still present.
Which versions of TinyMCE, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE?
The issue is observed on TinyMCE v5.2.1
on Edge. Didn’t check it on other browsers and for previous versions. But I’m happy to do so if required.
Additional notes
The issue doesn’t occur and it works as expected when the entire container element having the mceNonEditable
class is not replaced but only the contents inside are replaced. That is:
tinymce.activeEditor.dom.setHTML(tinymce.activeEditor.dom.select('#non-editable-bug'), 'Non editable bug')
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
tinymce noneditable contents not working properly
I am using tinyMCE editor, i need to make some contents radonly (nonEditable). As per its documentation, if i use class "mceNonEditable" with...
Read more >Should non editable text have the default cursor on hover?
Using the default arrow cursor over text will suggest to many users that the text isn't even selectable, let alone editable!
Read more >How to make read-only content in your DMS
The best solution though, is to restrict who can edit your work. But what about being able to set certain areas of your...
Read more >How to make a non-editable column field?
If the model is configured with editable = false for the field, the data could not be modified in the grid (or any...
Read more >Allow changes to parts of a protected document
Use Restrict Editing to protect parts that can or can't be changed, ... You can mark a document as read-only and still allow...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I made this fiddle to try to reproduce the bug. I can reproduce it on Tiny 5.2.1, but by the looks of things it’s something we fixed with the 5.3 release. Have a play with the fiddle on the latest stable release (which is 5.7 at the moment), and if you can find a way to reproduce the bug still then let us know.
Thank you so much for providing the solution so quickly, @ashfordneil. It’s working properly on the fiddle you provided. I need to check if it works in our app though. I’ll revert accordingly when I get the chance.
BTW, if anyone from the future is wondering how to make it work in the versions before 5.3, you can add the
contenteditable="false"
attribute manually to the element you’re trying to insert. As such:And yes, if you’re adding the
contenteditable
attribute manually, then you don’t need to add themceNonEditable
class.