How to find the element inside cursor is placed
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 93
- Joined: Mon Aug 08, 2022 2:32 pm
How to find the element inside cursor is placed
Post by SmitaPatil »
Hi Team,
I want to find the element name inside which user has placed cursor. Can you please if there is any existing method to get that?
Thanks,
Smita
I want to find the element name inside which user has placed cursor. Can you please if there is any existing method to get that?
Thanks,
Smita
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: How to find the element inside cursor is placed
Hello,
If you are developing a plugin or an AuthorOperation you can use the following Java API to find an element at a specific offset:
ro.sync.ecss.extensions.api.AuthorDocumentController.getNodeAtOffset(int)
The caret offset can be obtained from the AuthorEditorAccess:
authorAccess.getEditorAccess().getCaretOffset()
Then, to obtain the name of the element you can check first if the AuthorNode is an AuthorElement and get its local name with:
ro.sync.ecss.extensions.api.node.AuthorElement.getLocalName()
If this is not what you need please give us more details about your use case and the API that you use.
Best Regards,
Mihaela
If you are developing a plugin or an AuthorOperation you can use the following Java API to find an element at a specific offset:
ro.sync.ecss.extensions.api.AuthorDocumentController.getNodeAtOffset(int)
The caret offset can be obtained from the AuthorEditorAccess:
authorAccess.getEditorAccess().getCaretOffset()
Then, to obtain the name of the element you can check first if the AuthorNode is an AuthorElement and get its local name with:
ro.sync.ecss.extensions.api.node.AuthorElement.getLocalName()
If this is not what you need please give us more details about your use case and the API that you use.
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