Find the name of a parent node/tag in EditorPage
Posted: Wed Apr 29, 2020 5:58 pm
Hello,
We are working on a function that inserts a tag, but we want to validate the parent node, to make sure it is
valid.
For AuthorPage, we got this to work:
How can we do the same thing for EditorPage?
Thank you,
Will
We are working on a function that inserts a tag, but we want to validate the parent node, to make sure it is
valid.
For AuthorPage, we got this to work:
Code: Select all
AuthorAccess authorAccess = authorPage.getAuthorAccess();
AuthorElement nodeAtCaret = (AuthorElement) authorAccess.getEditorAccess().getFullySelectedNode();
if (nodeAtCaret == null) {
try {
nodeAtCaret = (AuthorElement) authorAccess.getDocumentController().getNodeAtOffset(offset);
} catch (BadLocationException e) {
e.printStackTrace();
}
System.out.println(nodeAtCaret.getDisplayName()); // it will display the parent tag name and using this we can validate the our condition.
}
Thank you,
Will