Page 1 of 1

Insert at carret position

Posted: Thu Mar 13, 2025 5:39 pm
by ArthurP
Hi,

we are implementing a side view to reproduce Desktop "Reusable Component view". In this view, an user can choose to insert a reference (xref @conref/@keyref) in the content. We use the insert action "ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation" to achieve this goal. It works successfully but we would like to insert at carret position. After looking at documentation (https://www.oxygenxml.com/doc/versions/ ... ments.html), it doesn't seem possible.

Do you have a suggestion or workaround to help us ?

Regards,
arthur

Re: Insert at carret position

Posted: Fri Mar 14, 2025 11:16 am
by cosminef
Hello,

To successfully insert the fragment at the caret position in the "ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation" operation, you can omit the insertLocation and insertPosition arguments.

You can test this use case, for example, in the browser console with an open document, using the following code snippet:

Code: Select all

workspace.currentEditor.getEditingSupport().getActionsManager().invokeOperation(
    "ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation",
    {
        fragment: "test"
    }
);
Best,
Cosmin

Re: Insert at carret position

Posted: Fri Mar 14, 2025 11:39 am
by ArthurP
Hello Cosmin,

Thanks, it works ! Easy solution :)

Regards