Answer the question
In order to leave comments, you need to log in
How to prohibit editing and deleting a specific element within the WYSIWYG editor?
There is the following structure:
<p id="editor">
Данный текст можно удалять и изменять
<span class="no-delete">нельзя ни удалить ни редактировать</span>
затем этот текст тоже можно удалять и изменять
</p>
Answer the question
In order to leave comments, you need to log in
An intermediate solution turned out to be the use of TinyMCE with the "PreventDelete" plugin.
jsFiddle
Plugin (git)
Ps when copying elements are overwritten...
...
inymce.PluginManager.add('preventdelete', function(ed, link) {
ed.on('keydown', function(evt) {
var range = tinymce.activeEditor.selection.getRng();
var content = tinymce.activeEditor.selection.getContent(); //Получаем весь выделенный контент
//Проверяем, если в контенте присутствует "mceNonEditable", то запрещать любые действия
if (content.indexOf("mceNonEditable") + 1){
return self.cancelKey(evt)
}
self.logElem(range.startContainer)
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question