初始化后设置TinyMCE编辑器参数 [英] Set TinyMCE Editor Param after Initialized

查看:421
本文介绍了初始化后设置TinyMCE编辑器参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在tinyMCE初始化后将tinyMCE中的 readonly 参数设置为 true 。如果帖子已经发布,我试图用wordpress来禁用postEditor。我发现有些消息来源声称你可以打电话:

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.

推荐答案

更简单的设置方法是 tinyMCE.activeEditor.settings.readonly = true;
但这里的问题是readonly设置会影响tinymce的初始化方式。
因此,在初始化tinymce之后设置它不会产生很大的影响。

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.

你可以做些什么来阻止用户编辑你的编辑器中的内容是设置编辑器iframe主体的contenteditable属性为false:

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:

tinymce.activeEditor.getBody().setAttribute('contenteditable', false);

这篇关于初始化后设置TinyMCE编辑器参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆