This is a migrated thread and some comments may be shown as answers.

Inserting non editable Value in the editor

2 Answers 224 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Nicolas
Top achievements
Rank 1
Nicolas asked on 19 Dec 2014, 10:27 AM

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

2 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 23 Dec 2014, 09:25 AM
Hello Nicolas,

I am afraid that using non-editable elements in the editor is not supported at this time. Even if these issues are fixed, there may be other problems that will pop up. In order to request this functionality, submit a feature request on UserVoice.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Nicolas
Top achievements
Rank 1
answered on 02 Mar 2015, 12:56 PM
Thank's for the answer.
I surrounded the issues by using a Input 
editor.exec("inserthtml", { value: '<input readonly="readonly"  value="' + text + '" title="' + text + '" />' })

But this solution does not provide easy auto-size functionality. 
As I will probably need this on other places I will insert a feature request.

Tags
Editor
Asked by
Nicolas
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Nicolas
Top achievements
Rank 1
Share this question
or