Is there a way pickup highlighted words?

Post here questions and problems related to oXygen frameworks/document types.
wbrisett
Posts: 19
Joined: Thu Feb 21, 2013 11:44 pm

Is there a way pickup highlighted words?

Post by wbrisett » Sun Apr 07, 2019 2:10 pm

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.

Radu
Posts: 6335
Joined: Fri Jul 09, 2004 5:18 pm

Re: Is there a way pickup highlighted words?

Post by Radu » Mon Apr 08, 2019 7:59 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

wbrisett
Posts: 19
Joined: Thu Feb 21, 2013 11:44 pm

Re: Is there a way pickup highlighted words?

Post by wbrisett » Mon Apr 08, 2019 10:46 am

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?

wbrisett
Posts: 19
Joined: Thu Feb 21, 2013 11:44 pm

Re: Is there a way pickup highlighted words?

Post by wbrisett » Mon Apr 08, 2019 10:51 am

Here is where I am doing things Radu:
https://www.oxygenxml.com/doc/versions/ ... ialog.html

Radu
Posts: 6335
Joined: Fri Jul 09, 2004 5:18 pm

Re: Is there a way pickup highlighted words?

Post by Radu » Mon Apr 08, 2019 11:06 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

wbrisett
Posts: 19
Joined: Thu Feb 21, 2013 11:44 pm

Re: Is there a way pickup highlighted words?

Post by wbrisett » Mon Apr 08, 2019 11:59 am

I was close... I had $1, but that wasn't working. Thanks Radu!

Post Reply