[英]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.