You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello everyone, Please tell me is it possible to insert text by click by button - ex. {{text}} to current cursor position without selection text or add new block - I try create possibilty to insert template text from database to speed up fill text.
The text was updated successfully, but these errors were encountered:
constselection=window.getSelection();//get cursor position from browser api (offset and target element)if(!selection||!selection.anchorNode)return;constelement=selection.anchorNode.parentElement//anchor is textNodeif(element==null)return;constblock=editor.blocks.getBlockByElement(element)if(block==undefined)return;//check block is in editorconstoffset=selection.anchorOffset;//get cursor offset in element and store it to use after text insertconstoriginalText=selection.anchorNode.textContent;if(originalText){selection.anchorNode.textContent=originalText.slice(0,offset)+text+originalText.slice(offset);//add text at cursor position and set to node}else{selection.anchorNode.textContent=text;}block.dispatchChange();editor.caret.setToBlock(block,'default',offset+text.length);//set cursor at end of inserted text and focus element
In the table or other elements with complicated structure set cursor in element is not working, but text is inserted in selected position.
Hello everyone, Please tell me is it possible to insert text by click by button - ex. {{text}} to current cursor position without selection text or add new block - I try create possibilty to insert template text from database to speed up fill text.
The text was updated successfully, but these errors were encountered: