【问题标题】:prevent child element to be editable in mediumEditor.js防止子元素在 mediumEditor.js 中可编辑
【发布时间】:2016-12-31 15:11:49
【问题描述】:

如何防止中级编辑器编辑子元素,而父元素是可编辑的。 示例:

<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>

【问题讨论】:

    标签: medium-editor


    【解决方案1】:

    你只需要将它包裹在一个非 contenteditable 属性上。

    <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>

    【讨论】:

    • @VijayYadav 如果它解决了你的问题,你可以接受答案:)
    猜你喜欢
    • 2012-10-08
    • 2013-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-13
    • 2012-09-06
    • 1970-01-01
    • 2017-10-04
    相关资源
    最近更新 更多