Remove specified tags

Having trouble installing Oxygen? Got a bug to report? Post it all here.
shilpa
Posts: 68
Joined: Mon Jul 04, 2022 8:42 am

Remove specified tags

Post by shilpa »

Hi Team,
I have below requirement please help me on this.
Say in web author i have selected below element.
<paratext>apple<bold>some<ital>some</ital></bold>ball</paratext>
<paratext>some text</paratex>
<paratext>some text<bold>some text</bold>some</paratext>


and when i put cursor in different location, from selected element paratext should get remove and below fragment should get insert.
apple<bold>some<ital>some<ital></bold>ball some text some text<bold>some text</bold>some

Thanks & Regards
Shilpa.P
mihaela
Posts: 504
Joined: Wed May 20, 2009 2:40 pm

Re: Remove specified tags

Post by mihaela »

Hi,

The API that you can use to modify the document is ro.sync.ecss.extensions.api.AuthorDocumentController.

For your use case, you can use methods from AuthorDocumentController to:
- find all the nodes inside the selection: getNodesToSelect(int, int)
- create document fragments (from paratext nodes content for example, to be later inserted in the document): createDocumentFragment(int, int)
- delete nodes: deleteNode(AuthorNode)
- insert fragments: insertFragment(int, AuthorDocumentFragment)

These are just some examples of the methods that you can use. Please check the AuthorDocumentController documentation for more details.

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
shilpa
Posts: 68
Joined: Mon Jul 04, 2022 8:42 am

Re: Remove specified tags

Post by shilpa »

Hi Miheala,

After adding getNodesToSelect(int, int) in my code i am getting only one node(paratext)
Actually i should get 3 nodes(paratext,bold,ital)

<paratext>apple<bold>some<ital>some</ital></bold>ball</paratext>


Please let me know what is the behavior of getNodesToSelect(int, int)?

Thanks & Regards
Shilpa.P
mihaela
Posts: 504
Joined: Wed May 20, 2009 2:40 pm

Re: Remove specified tags

Post by mihaela »

Hello,

The Author nodes model is similar with the DOM model. The result of the getNodesToSelect(int, int) method is a list of first-level nodes that are included between start and end offsets.

So, regarding your sample, the method will return the parent paratext node. To find the other nodes (bold and ital) you will have to get its child nodes. The API that you can use to find the content nodes of a node is: ro.sync.ecss.extensions.api.node.AuthorParentNode.getContentNodes() (note that you must check if the node is an AuthorParentNode first).

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