Within our CMS, our users can edit error messages for forms using TinyMCE. The problem is, some of these messages may require dynamic data, e.g. "Your chosen name 'X' is invalid"
.
To do this, we are using tokens. Using the above as an example, our user would type in "Your chosen name '{name}' is invalid"
, and it would get replaced on render.
I'm currently writing a plugin for TinyMCE to better help the user manage these tokens. They would click the icon, select a token from a predefined list, and it would get inserted into the content automatically.
The problem I have is how this token is treated within the content editor. At present, it's just text that can be edited, but what I want to do is make TinyMCE treat it as a single element so it can be removed, moved, but the actual token itself can not be edited.
I've tried using the noneditable
plugin by wrapping the token in a span with the mceNonEditable
class but this doesn't behave as expected, e.g. you can't backspace delete the token, if the token is at the end of the content you can't type after it, etc.
So to clarify, what I essentially want is for TinyMCE to treat some text like it would an image. It would be a solid block, a.k.a. treated as one character/element.
Is this possible?
Thank you.
</p></textarea> <br><br> <label class="container">Editable ("design") mode <input type="checkbox" checked onclick="toggleEditorMode(this. checked); return true;"> <span class="checkmark"></span> </label> <br> Use the checkbox to toggle between the "design" and "readonly" modes.
An end to editable discontentThe TinyMCE team continues to invest in the contentEditable approach, and with it the promise of robustness and feature completion. Our goal is a high-quality, complete and stable API on top of contentEditable . Since TinyMCE was launched, we have seen many new editor libraries emerge.
Adds CSS style editing support to TinyMCE, this will enable you to edit almost any CSS style property in a visual way. You simply need to load the "style" plugin and add the control "styleprops" to any toolbar.
After trying about 100 different work arounds, we finally found a solution which works (for our needs anyway).
We're inserting a disabled button with all the styles removed. For example,
<input type="button" class="token" value="my token" disabled="disabled" />
And then adding some code to onGetContent() to convert the input to plain text.
This solution, although not very elegant,
Edit: This is what we ended up with.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With