How we can add schemaAware as true while unwrapping element

Having trouble installing Oxygen? Got a bug to report? Post it all here.
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

How we can add schemaAware as true while unwrapping element

Post by SmitaPatil »

Hi Team.
I am using below function for unwrapping selected element or tag.
this.editor.getActionsManager().invokeOperation('ro.sync.ecss.extensions.commons.operations.UnwrapTagsOperation',{})
But, even if it document will be invalid after unwrapping in such case also its unwrapping.
Can you please tell how to add validation while calling this method?

Thanks & Regards,
Smita
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: How we can add schemaAware as true while unwrapping element

Post by Bogdan Dumitru »

Hello Smita,

Define your own AuthorOperation and use the AuthorSchemaManager API to check if the element can be unwrapped.
To define a custom AuthorOperation simply extend the interface from a plugin. See the user-name-insert-operation-plugin sample plugin that does that.
To check if the element can be unwrapped, create a fragment over the wrapped content and then use the AuthorSchemaManager.canInsertDocumentFragment method to check if the fragment is allowed at the position of the element that wraps it (parent element's start offset).

Also, there seems to be a related topic. Was the solution from that topic proven wrong or did you have difficulties applying it?
Bogdan Dumitru
http://www.oxygenxml.com
Post Reply