简体   繁体   English

TinyMCE 5:禁用编辑器但允许复制文本

[英]TinyMCE 5: Disabled editor but allow to copy text

How to disable the Editor but allow the user to copy the text? 如何禁用编辑器但允许用户复制文本?

When I set disabled to true it's now possible to select and copy text. 当我将disabled设置为true ,现在可以选择和复制文本。

<Editor disabled={true} />

This is not how TinyMCE's read only mode works - in that mode the editor is truly read only and will not allow you to select the text in the editor. 这不是TinyMCE的只读模式的工作原理 - 在该模式下,编辑器是真正只读的,不允许您在编辑器中选择文本。 If you wanted different behavior you would need to suggest that to the TinyMCE developers via their GitHub Issue Tracker: 如果您想要不同的行为,您需要通过他们的GitHub问题跟踪器向TinyMCE开发人员建议:

https://github.com/tinymce/tinymce/issues https://github.com/tinymce/tinymce/issues

I've found a solution. 我找到了解决方案。

Just set the contenteditable attribute to false (you can delete the content). 只需将contenteditable属性设置为false (您可以删除内容)。

// do not use this solution!
<Editor 
  init={{
    init_instance_callback: editor => {
      editor.getBody().setAttrib('contenteditable', false);
    }
  }}
/>

UPDATE: 更新:

<Editor 
  init={{
    init_instance_callback: editor => {
      editor.setMode('readonly');
    }
  }}
/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM