Page 1 of 1

Is there a way pickup highlighted words?

Posted: Sun Apr 07, 2019 2:10 pm
by wbrisett
I'm putting together a set of toolbar shortcuts. I want to be able to do this:

Sample text:
"All look your best," Peter warned them; "first impressions are awfully important."

If I highlight the word 'impressions', I want to see this:

"All look your best," Peter warned them; "first <term keyref="impressions">impressions</term> are awfully important."

I have a custom framework where I've used the wrap element, but it's getting the attribute set that I can't seem to figure out. I'm sure I'm just overlooking something simple. But I don't see anything in the documentation either.

Re: Is there a way pickup highlighted words?

Posted: Mon Apr 08, 2019 7:59 am
by Radu
Hi Wayne,

What do you mean by "I've used the wrap element"? Can you give me some sample code about how you attempt to do this in the custom framework?
For example if I used the AuthorDocumentController API from the Java code I would do something like:

Code: Select all


if(authorAccess.getEditorAccess().hasSelection()){
AuthorDocumentFragment frag = authorAccess.getDocumentController().createNewDocumentFragmentInContext("<term keyref='impressions'/>", authorAccess.getEditorAccess().getCaretOffset());
authorAccess.getDocumentController().surroundInFragment(frag, authorAccess.getEditorAccess().getSelectionStart(), authorAccess.getEditorAccess().getSelectionEnd() - 1);
}
https://www.oxygenxml.com/InstData/Edit ... oller.html

Regards,
Radu

Re: Is there a way pickup highlighted words?

Posted: Mon Apr 08, 2019 10:46 am
by wbrisett
In the Document Type Association panel, I've added an extension of the DITA framework, in that I've created an action for a custom toolbar item.

I've added the operation of :

ToggleSurroundWithElementOperation

In the Argument Value, it has:

Name: Element
Type: Fragment

It's in this value dialog I was hoping there was something I could do that would enable me to to not only place the <term keyref=""></term>, but actually pickup the word highlighted and place it in the attribute string. Is that possible, or do I need a different approach?

Re: Is there a way pickup highlighted words?

Posted: Mon Apr 08, 2019 10:51 am
by wbrisett
Here is where I am doing things Radu:
https://www.oxygenxml.com/doc/versions/ ... ialog.html

Re: Is there a way pickup highlighted words?

Posted: Mon Apr 08, 2019 11:06 am
by Radu
Hi,

You can use the ${selection} editor variable in the value you set for the "element" parameter of the operation like:

Code: Select all

<term  keyref="${selection}"/>
Regards,
Radu

Re: Is there a way pickup highlighted words?

Posted: Mon Apr 08, 2019 11:59 am
by wbrisett
I was close... I had $1, but that wasn't working. Thanks Radu!