Page 1 of 1

Custom Action for highlight content

Posted: Sun Mar 23, 2025 3:20 pm
by VincentV
Hello,

I'd like the highlight action to be available in the floating toolbar that appears when I select text.
Is there a predefined custom action for highlighting?

*Just for clarification, we have already set up a custom floating toolbar. The only action missing is the ability to highlight content in a desired color, as I can't find the corresponding action for it. Is this possible using the out-of-the-box author actions, or is more advanced customization necessary?

Thank you!
Vincent

Re: Custom Action for highlight content

Posted: Thu Mar 27, 2025 7:32 am
by Radu
Hi Vincent,
Is this question for the Oxygen desktop on premise tool or Oxygen WebAuthor in browser editor?
Regards,
Radu

Re: Custom Action for highlight content

Posted: Thu Mar 27, 2025 9:03 am
by VincentV
Hi Radu,
this is for the Oxygen desktop on premise tool.
Kind regards,
Vincent

Re: Custom Action for highlight content

Posted: Thu Mar 27, 2025 3:10 pm
by Radu
Hi Vincent,

The oxy_button form control that you can add from the CSS on a floating toolbar can only access DITA specific actions like Bold, Italic, etc. And the actions to add highlights with various colors are not accessible to it.
What one could do would be to create custom Java-based AuthorOperations which use our APIs to add higlights of certain colors:
https://www.oxygenxml.com/doc/versions/ ... a-api.html

an operation which inserts a highlight of a certain color over a selection would look like this:

Code: Select all

/**
   * @see ro.sync.ecss.extensions.api.AuthorOperation#doOperation(ro.sync.ecss.extensions.api.AuthorAccess, ro.sync.ecss.extensions.api.ArgumentsMap)
   */
  @Override
  public void doOperation(AuthorAccess authorAccess, ArgumentsMap args)
      throws AuthorOperationException {
    AuthorEditorAccess editorAccess = authorAccess.getEditorAccess();
    if(editorAccess.hasSelection()) {
      AuthorPersistentHighlighter persistentHighlighter = editorAccess.getPersistentHighlighter();
      LinkedHashMap<String, String> props = new LinkedHashMap<>();
      props.put("type", "oxy_content_highlight");
      props.put("color", "255,60,255");
      persistentHighlighter.addHighlight(editorAccess.getSelectionStart(), 
          editorAccess.getSelectionEnd() - 1, props);
    }
  }
and then create Author actions in your framework, one for each color, each action with an icon which matches the color and calling the custom operation to insert a highlight with that color.
Then in the CSS refer to those Author actions in the floating toolbar. So this would require some customization work.

Regards,
Radu

Re: Custom Action for highlight content

Posted: Fri Mar 28, 2025 9:46 am
by VincentV
Hello Radu,
so far, we have only used the out-of-the-box author actions to modify our framework.
However, in the future, we also plan to use your SDK. So this will definitely help us - thank you!
Kind regards,
Vincent