Запретить редактирование дочернего элемента в mediumEditor.js

Как предотвратить редактирование дочернего элемента с помощью редактора среды, тогда как родительский элемент является редактируемым. Пример:

<div class="editable">
 This text should be editable<span class="no-editable"> This text should not be editable.</span>
</div>

<script>
  var editor = new MediumEditor('.editable');
</script>

1 ответ

Вам просто нужно обернуть его вокруг неконтролируемого атрибута.

<script src="https://yabwe.github.io/medium-editor/bower_components/medium-editor/dist/js/medium-editor.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://yabwe.github.io/medium-editor/bower_components/medium-editor/dist/css/medium-editor.min.css" rel="stylesheet"/>
<link href="https://yabwe.github.io/medium-editor/bower_components/medium-editor/dist/css/themes/tim.min.css" rel="stylesheet"/>

<div class="editable">
  <p>
    This text should be editable
  </p>
  <p contenteditable="false">
    This text should not be editable.
  </p>
</div>

<script>
  var editor = new MediumEditor('.editable');
</script>

Другие вопросы по тегам