Custom Action for highlight content

Post here questions and problems related to oXygen frameworks/document types.
VincentV
Posts: 5
Joined: Fri Nov 22, 2024 9:59 am

Custom Action for highlight content

Post 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
Radu
Posts: 9431
Joined: Fri Jul 09, 2004 5:18 pm

Re: Custom Action for highlight content

Post by Radu »

Hi Vincent,
Is this question for the Oxygen desktop on premise tool or Oxygen WebAuthor in browser editor?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
VincentV
Posts: 5
Joined: Fri Nov 22, 2024 9:59 am

Re: Custom Action for highlight content

Post by VincentV »

Hi Radu,
this is for the Oxygen desktop on premise tool.
Kind regards,
Vincent
Radu
Posts: 9431
Joined: Fri Jul 09, 2004 5:18 pm

Re: Custom Action for highlight content

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
VincentV
Posts: 5
Joined: Fri Nov 22, 2024 9:59 am

Re: Custom Action for highlight content

Post 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
Post Reply