我正在使用CKEditor 5(平衡编辑器),并尝试获取选定的文本。我该怎么做呢?
我尝试了以下代码,但得到的结果为空:
editor.model.change( writer => {
var selection = editor.model.document.selection;
console.log(selection.getSelectedElement());
} );谢谢你的帮助。
发布于 2019-03-08 23:35:58
我想,对于文本元素,selection.getSelectedElement()会返回null。当figure对象被选中时,它返回一个element对象。您可以使用
selection.getFirstPosition().parent 或
Array.from(selection.getSelectedBlocks())https://stackoverflow.com/questions/54788353
复制相似问题