gpt4 book ai didi

javascript - CKEDITOR:如何以编程方式测试编辑器是否处于内联模式

转载 作者:行者123 更新时间:2023-11-28 01:44:04 25 4
gpt4 key购买 nike

有没有办法测试(通过javascript,之后CkEditor的实例都准备好)CkEditor的实例是否在 inline mode 中工作还是不?

最佳答案

使用CKEDITOR.instances.yourInstance.editable().isInline()。另请参阅official API docs .

注意#1:永远不要检查 getAttribute('contenteditable') == 'true' 因为如果您调用 yourInstance.setReadOnly()断言将会失败。可编辑元素的 contenteditable="false" 处于只读模式,但它仍然可能是内联的。

注意#2:反对 getAttribute( 'contenteditable' ) 的另一个原因:

// Since CKEditor 4.2 is possible to make inline instance out of <textarea>.
var editor = CKEDITOR.inline( 'article-body' );

editor.element.getName()
>> "textarea" // In such case, editor.element refers to <textarea>.

editor.element.getAttribute( 'contenteditable' )
>> null // Textarea (editor.element) is never contenteditable.

关于javascript - CKEDITOR:如何以编程方式测试编辑器是否处于内联模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20543237/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com