简体   繁体   English

如何禁用粘贴颜色

[英]How disable color from paste

I would like so if it's possible in the Tinymce editor to disable the color with the copy past from Word for example.如果可以在Tinymce 编辑器中禁用颜色,例如从Word中复制过去,我希望如此。

Thanks for the help.谢谢您的帮助。

If you console.log value in onEditorChange event of editor after pasting the text, you can see style="color: red;"如果在粘贴文本后在编辑器的onEditorChange事件中使用console.log值,则可以看到style="color: red;" is added in the pasted text.已添加到粘贴的文本中。

In onEditorChange you can use regex to remove color property from style, and then set the edited value.onEditorChange ,您可以使用正则表达式从样式中删除color属性,然后设置编辑后的值。

onEditorChange={(value) => {value.replace(/color(.*?);/i, "")}}

Check this example检查这个例子

Note: The code is according to tinymce react component.注:代码根据tinymce React组件。 You may need to change some code if you are not using tinymce for react如果您不使用 tinymce 进行反应,您可能需要更改一些代码

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

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