Page 1 of 1

Action ToggleSurroundWithElementOperation inconsistent

Posted: Wed Feb 15, 2017 9:29 pm
by arcuous
Sorry, first post. I'll read up on conventions to make this and subsequent questions better. Thanks for your attention meanwhile.

There seems to be inconsistent behavior with ToggleSurroundWithElementOperation in the following scenario:

<element>text before {startSel}text inside{endSel} text after</element>

I've found that DocBook 4 works to surround the selected text, and remove it if the same text is selected, (with <emphasis role="bold"/>, so I'm using it as an example.

This is the behavior I'm trying to implement using my own <mh:Bold> element in a custom schema. I'm starting my framework from scratch and have it validating with my schema and catalog to include the mh:Bold and others.

As far as I can tell, my action is configured exactly as the DocBook 4 one, but with "<mh:Bold/>" as the element value. However, it behaves strangely:

<diag:Overview>Every ch{cursor}ild ...</diag:Overview>
<diag:Overview>Every <mh:Bold>ch{cursor}ild</mh:Bold> ...</diag:Overview>

That's okay, but using that selection and invoking the action again, surrounds with another one:

<diag:Overview>Every <mh:Bold><mh:Bold>ch{cursor}ild</mh:Bold></mh:Bold>

That's unexpected. I thought the action would remove the surrounding <mh:Bold/>. This also does nothing when I select the entire text in <mh:Bold/> or the <mh:Bold/> element itself. This may be due to the same behavior as the following:

<diag:Overview>Every{startSel}child{endSel} ...</diag:Overview>
... nothing. The menu bar for my framework blinks, but that's it.

FYI, DITA appears broken in a similar way that mine is, with a simple <b/>. If the cursor is inside text it will surround the current "word" only if there is no text selected; just the cursor in a word. If text is selected, it will do nothing, unless the entire element (<p/>) is selected. This seems to be a problem also.

Re: Action ToggleSurroundWithElementOperation inconsistent

Posted: Thu Feb 16, 2017 3:34 pm
by alex_jitianu
Hi,

Please make sure that your action uses the ro.sync.ecss.extensions.commons.operations.ToggleSurroundWithElementOperation operation because only this operation knows how to wrap/unwrap. I suspect that your action is currently using ro.sync.ecss.extensions.commons.operations.SurroundWithFragmentOperation which doesn't know how to unwrap. Let me know if this was indeed your situation. If not, can you send me the framework on support@oxygenxml.com to have a look at it? What Oxygen version are you using?

Best regards,
Alex

Re: Action ToggleSurroundWithElementOperation inconsistent

Posted: Thu Feb 16, 2017 7:58 pm
by arcuous
Yes, these are all the same ToggleSurroundWithElementOperation. I have since had success with a combination of SurroundWithFragmentOperation and UnwrapTagsOperation, but I'll send the framework with Toggle, because I expect that to work as described. I started with 17 and updated to 18.1 without a change in this behavior.

Meanwhile, do you see the same behavior I see with the DITA framework and bold (<b/>)? If that works for others, then I suspect my environment may be problematic.

Re: Action ToggleSurroundWithElementOperation inconsistent

Posted: Fri Feb 17, 2017 9:55 am
by alex_jitianu
Hi,

I'll have a look at the framework. I have to say that I don't reproduce the described behavior using the built-in DITA framework.

Best regards,
Alex

Re: Action ToggleSurroundWithElementOperation inconsistent

Posted: Fri Feb 17, 2017 6:08 pm
by arcuous
Radu answered with the solution (excerpt):
The proper value should actually be:

<mh:Bold xmlns:mh="http://medhomeportal.org/schemas/MedhomeCommon"/>

Oxygen will use the namespace information in the XML fragment and the toggle should start working fine for your case.
Thanks Radu!

~Ryan

Re: Action ToggleSurroundWithElementOperation inconsistent

Posted: Fri Feb 17, 2017 6:11 pm
by Radu
Hi Ryan,

No problem, thanks for updating the forum thread.

Regards,
Radu