[英]CKEditor5 getSelectedElement()
我正在使用CKEditor 5(气球编辑器)并尝试获取选定的文本。 我该怎么做?
我尝试下面的代码,并得到NULL:
editor.model.change( writer => {
var selection = editor.model.document.selection;
console.log(selection.getSelectedElement());
} );
感谢帮助。
我猜, selection.getSelectedElement()
对于文本元素返回null
。 当选择图形对象时,它将返回一个元素对象。 您可以使用
selection.getFirstPosition().parent
要么
Array.from(selection.getSelectedBlocks())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.