allow to set custom editor variable value from action

Are you missing a feature? Request its implementation here.
leukerts
Posts: 3
Joined: Tue Aug 02, 2022 2:21 pm

allow to set custom editor variable value from action

Post by leukerts »

Hi,
in order to grab certain values from one DITA topic in the editor and to insert them in another (via custom author action), it would be very helpful, if the value of a custom editor variable (already defined) could be set from within an author action.
A simple copy and paste will not do in this case, as we need to grab the id of the surrounding topic, and in addition the id of a nested topic within.
Thanks,
Sven.
Radu
Posts: 9058
Joined: Fri Jul 09, 2004 5:18 pm

Re: allow to set custom editor variable value from action

Post by Radu »

Hi Sven,

We have API to expand a string containing editor variables to the variable values:

Code: Select all

authorAccess.getUtilAccess().expandEditorVariables(pathWithEditorVariables, currentEditedURL)
Is that what you wanted?

If not, we also have Java API to add a custom editor variables resolver.
https://www.oxygenxml.com/InstData/Edit ... olver.html
so for example a custom AuthorOperation Java implementation could add its own

Code: Select all

void doOperation(AuthorAccess authorAccess, ArgumentsMap args) 
    throws IllegalArgumentException, AuthorOperationException{
    EditorVariablesResolver customResolver = null;
    authorAccess.getUtilAccess().addCustomEditorVariablesResolver(customResolver);
    //..invoke other methods here
    authorAccess.getUtilAccess().removeCustomEditorVariablesResolver(customResolver);
  }
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
leukerts
Posts: 3
Joined: Tue Aug 02, 2022 2:21 pm

Re: allow to set custom editor variable value from action

Post by leukerts »

Hi Radu,
thanks for the quick reply. Maybe I am not familiar with what a resolver does, but it sounds like it would give you the values of a custom editor variable, maybe packaged in a nice way - but not write to the variable.
What I am looking for - and not using proper terminology - is this:
I have already defined a custom editor variable xyz in the preferences dialogue.
Now, while editing one topic, I would like to read some <data> from the topic (in a custom button action), and then say xyz=<data>.
Then, in another topic, again with a custom button action, I would like to insert a fragment containing ${xyz}.
Does that describe it more clearly?
Thanks and best regards,
Sven.
Attachments
image.png
image.png (786 Bytes) Viewed 703 times
Radu
Posts: 9058
Joined: Fri Jul 09, 2004 5:18 pm

Re: allow to set custom editor variable value from action

Post by Radu »

Hi Sven,
I think the easiest way to accomplish what you want would be maybe this approach:
Now, while editing one topic, I would like to read some <data> from the topic (in a custom button action), and then say xyz=<data>.
In your custom "AuthorOperation" java implementation you could set a custom Java system property like:

Code: Select all

java.lang.System.setProperty("customProp", "someValue");
Then, in another topic, again with a custom button action, I would like to insert a fragment containing ${xyz}.
You can use in the inserted XML fragment the "${system(customProp)}" Oxygen specific editor variable which should expand to the value of the "customProp" Java system property.
https://www.oxygenxml.com/doc/versions/ ... ables.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
leukerts
Posts: 3
Joined: Tue Aug 02, 2022 2:21 pm

Re: allow to set custom editor variable value from action

Post by leukerts »

Hi Radu,
that looks great - thanks!

Best regards,
Sven.
Post Reply