Hello all,
I have been looking for a solution to allow user inserting a variable name into the editor (once submitted the value is searched into a hash-map and replaced on server side)
For this I wanted to forbid the user to edit the value (to avoid him involuntary edition).
The solution I found is to insert a span with "contenteditable='false' " attribute :
editor.exec("inserthtml", { value: " <
span
contenteditable
=
'false'
>+myValue+</
span
>" });
At a point this work well. The value cannot be changed and all the content is deleted at once.
But I face 2 issues with this solution :
1. If I put the cursor just before the snippet and I press enter, the snippet jump to the next line but the editor looses focus ( On chrome 39.0.2171.95 )
2. After that its impossible to put back the snippet on the previous line :
On chrome (39.0.2171.95) it delete the snippet when I hit backspace with the cursor before the snippet
On Firefox (33.1) it does nothing when I hit backspace.
There is a small code example : http://jsfiddle.net/7kk3vgsy/1/
Thanks