Removing an element, but retaining contents, from an external event

Having trouble installing Oxygen? Got a bug to report? Post it all here.
trentono
Posts: 3
Joined: Wed Oct 18, 2023 11:32 pm

Removing an element, but retaining contents, from an external event

Post by trentono »

Hi there,
We have been using javascript to invoke built-in author mode operations based on events generated from a form outside of the embedded Oxygen XML editor. For example, we have been using "SurroundWithFragmentOperation" to add a custom element tag with attributes around the current selection in the editor, based on a user's input and action in an html form. This is working really well, but we also want to implement the inverse -- allow a user to invoke an operation that removes the element tag, but retain the contents of the tag.

We've tried several of the other built-in author mode operations, but none seem to do what we need here. It seems like this would be a pretty common use-case, though, so perhaps we're missing something obvious. (We've tried DeleteElementOperation, ToggleSurroundWithElementOperation, and some combinations of DeleteElementOperation with insert operations.)

What would be the recommended way to implement this?

Thanks,
Trent
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Removing an element, but retaining contents, from an external event

Post by mihaela »

Hello,

You can use the ro.sync.ecss.extensions.commons.operations.UnwrapTagsOperation for this use-case.

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
Post Reply