初始化后设置TinyMCE编辑器参数
我试图在tinyMCE初始化后将tinyMCE中的readonly
参数设置为true
。如果帖子已经发布,我尝试将其与 WordPress 一起使用来禁用帖子编辑器。我发现一些消息来源声称您可以致电:
tinyMCE.activeEditor.execCommand(
'mceSetAttribute',
false,
{name:'readonly',value:true}
);
但我一直没有运气,也没有找到解决方案。
I am trying to set the readonly
parameter in tinyMCE to true
after tinyMCE has been initalized. I am trying to use this with wordpress to disable the postEditor if the post has already been published. I found some sources claiming that you can call:
tinyMCE.activeEditor.execCommand(
'mceSetAttribute',
false,
{name:'readonly',value:true}
);
but I have been having no luck with that and have not found a solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更简单的设置方法是tinyMCE.activeEditor.settings.readonly = true;
但这里的问题是只读设置会影响tinymce的初始化方式。
所以在tinymce初始化之后设置不会有太大的影响。
要阻止用户在编辑器中编辑内容,您可以将编辑器 iframe 正文的 contenteditable 属性设置为 false:
An easier way to set this is
tinyMCE.activeEditor.settings.readonly = true;
But the problem here is that the readonly setting affects the way tinymce gets initialized.
So setting it after tinymce is initialized won't have a big impact.
What you can do to prevent users from editing content in your editor is to set the contenteditable attribute of the editors iframe body to false: