How to Set Ckeditor ReadOnly Mode

本文介绍CKEditor中实现编辑器内容的只读与可编辑状态切换的方法,包括使用setReadOnly()方法、配置CKEDITOR.config.readOnly选项以及通过设置<textarea>元素的disabled属性。同时展示了只读模式下的编辑器特性。

CKEditor API makes it possible to render the editor content read-only (and thus impossible for the user to edit). Some editor features that will not cause the user to modify the content will still be available, though. This includes, for example, the view of the content source code or features such as preview and editor interface maximization within the browser window.

The most crucial element of the API is the setReadOnly() method which puts the editor into the read-only state and restores it to the editable state.

When the editor goes from the editable into the read-only state, its readOnly property is being set to true (for read-only mode) or false (for editable mode). The readOnly event is also fired after each change of the readOnly property.

This is what CKEditor looks like when it is in read-only mode.

Read-Only Mode on Startup

CKEditor can be configured to open in the read-only mode on startup by setting the CKEDITOR.config.readOnly configuration option to true. For example:

config.readOnly = true;

The same can be achieved by setting the disabled attribute for the <textarea> element that CKEditor replaces.

Read-Only Mode Demo

See also the working “Read-Only Mode” sample that showcases toggling between the read-only and editable mode.

转载于:https://www.cnblogs.com/mouseleo/p/10095775.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值