Find out beginning of node and its first child element
Having trouble installing Oxygen? Got a bug to report? Post it all here.
Find out beginning of node and its first child element
Hi Team,
How to find out cursor is at the beginning of the node and also find out the is it first child of element?
Below is the example
Here say suppose my cursor is at <figure> then i should know its beginning of node and say suppose my cursor is at first <para>
then i should know its first child and last child of <figure> how to achieve this?
Example
<figure>
<para>
<paratext>Test</paratext>
<paratext>Test1</paratext>
</para>
<para>
<paratext>Test</paratext>
<paratext>Test1</paratext>
</para>
<figure>
Thanks & Regards
Shilpa.P
How to find out cursor is at the beginning of the node and also find out the is it first child of element?
Below is the example
Here say suppose my cursor is at <figure> then i should know its beginning of node and say suppose my cursor is at first <para>
then i should know its first child and last child of <figure> how to achieve this?
Example
<figure>
<para>
<paratext>Test</paratext>
<paratext>Test1</paratext>
</para>
<para>
<paratext>Test</paratext>
<paratext>Test1</paratext>
</para>
<figure>
Thanks & Regards
Shilpa.P
Re: Find out beginning of node and its first child element
Hi,
1. You can use the ro.sync.ecss.extensions.api.AuthorDocumentController.getContentInformationAtOffset(int) API to find if a specific offset corresponds to a start or an end sentinel of a node. Here is an example of the returned OffsetInformation, when the caret is placed at the beginning, in the content or at the end of a node:
To find the offset corresponding to the cursor you can use the ro.sync.ecss.extensions.api.access.AuthorEditorAccess.getCaretOffset() API.
2. From the OffsetInformation returned by the mentioned API method you can also find the node at caret (use OffsetInformation.getNodeForMarkerOffset() or OffsetInformation.getNodeForOffset(), depending on the position returned by the OffsetInformation.getPositionType() method). Then, you can find its parent using the ro.sync.ecss.extensions.api.node.AuthorNode.getParent() API and check the (start and end) offsets of each node to see if the node at caret is the first or last child in parent.
Best Regards,
Mihaela
1. You can use the ro.sync.ecss.extensions.api.AuthorDocumentController.getContentInformationAtOffset(int) API to find if a specific offset corresponds to a start or an end sentinel of a node. Here is an example of the returned OffsetInformation, when the caret is placed at the beginning, in the content or at the end of a node:
To find the offset corresponding to the cursor you can use the ro.sync.ecss.extensions.api.access.AuthorEditorAccess.getCaretOffset() API.
2. From the OffsetInformation returned by the mentioned API method you can also find the node at caret (use OffsetInformation.getNodeForMarkerOffset() or OffsetInformation.getNodeForOffset(), depending on the position returned by the OffsetInformation.getPositionType() method). Then, you can find its parent using the ro.sync.ecss.extensions.api.node.AuthorNode.getParent() API and check the (start and end) offsets of each node to see if the node at caret is the first or last child in parent.
Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service