Cursor "stuck" after inserting text from plugin

After inserting text from a plugin into the editor using something like

for (const textParagraph of textData) {
    const oParagraph = Api.CreateParagraph();
    oParagraph.AddText(textParagraph);
    oDocument.InsertContent([oParagraph], false);
}

then the cursor in the editor shows in a new line after the last inserted paragraph, but it is “stuck”. It’s not blinking, and writing anything is not possible. I need to click into the document to “activate” the cursor again, and enable typing.

Is this expected behavior? Can I somehow achieve the cursor staying “enabled” after inserting text, so that I can just continue typing into the document below the inserted text?

Hello @jakob

Check out browser console when this passage is being executed. It’d be better if you open browser console before running the plugin and then attempt inserting the text with it.

There is could be a problem with for ... of as it is relies on iterable objects, but I’m not sure what your textData object has.

By the way, what is the version of Document Server you are using?

@Constantine Sorry it was my mistake. I did some more testing and found out that a pop-up in my application was, when opened, taking focus away from the editor.

What fixed it was returning focus to the editor in the web app after closing the pop-up:

const editorIframe = document.querySelector('iframe[name="frameEditor"]');
if (editorIframe) {
    (editorIframe as HTMLIFrameElement).focus();
}

Thank you for the help though!

1 Like

Nice job. I’m glad to know that you’ve found the solution!