Can we get element name where 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
Can we get element name where cursor is placed
Post by SmitaPatil »
Hi Team,
I want to know that if there is any JavaScript function which you have to know the element name where cursor is placed instead of calling java method every time to check it. I would call that JavaScript method. I have tried following one but couldn't able to get method which will return me element name instead of id.
this.editor.getSelectionManager().getSelection().getCaretPositionInformation()
If you need any more clarification please let me know.
Thanks & Regards,
Smita
I want to know that if there is any JavaScript function which you have to know the element name where cursor is placed instead of calling java method every time to check it. I would call that JavaScript method. I have tried following one but couldn't able to get method which will return me element name instead of id.
this.editor.getSelectionManager().getSelection().getCaretPositionInformation()
If you need any more clarification please let me know.
Thanks & Regards,
Smita
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Can we get element name where cursor is placed
Post by cristi_talau »
Hello,
You can obtain the selection as you mentioned:
Then use one of the methods here: https://www.oxygenxml.com/maven/com/oxy ... ction.html, for example:
Best,
Cristian
You can obtain the selection as you mentioned:
Code: Select all
var sel = this.editor.getSelectionManager().getSelection()
Code: Select all
sel.getNodeAtSelection().getTagName()
Cristian
-
- Posts: 93
- Joined: Mon Aug 08, 2022 2:32 pm
Re: Can we get element name where cursor is placed
Post by SmitaPatil »
Hi Cristian,
Thank you so much!!.
just one more question, can you please tell the method for just checking if the given element has child element with some "xyz" name.
Thanks & Regards,
Smita
Thank you so much!!.
just one more question, can you please tell the method for just checking if the given element has child element with some "xyz" name.
Thanks & Regards,
Smita
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Can we get element name where cursor is placed
Post by cristi_talau »
Hello,
The getNodeAtSelection() method returns a node which implements the DOM level 3 API. So, you ca use properties like childNodes on it.
Or do you want to check whether that node can have a child "xyz"?
Best,
Cristian
The getNodeAtSelection() method returns a node which implements the DOM level 3 API. So, you ca use properties like childNodes on it.
Or do you want to check whether that node can have a child "xyz"?
Best,
Cristian
-
- Posts: 93
- Joined: Mon Aug 08, 2022 2:32 pm
Re: Can we get element name where cursor is placed
Post by SmitaPatil »
Hi Cristian,
I want to check whether that node can have a child "xyz"?
Thanks & Regards,
Smita
I want to check whether that node can have a child "xyz"?
Thanks & Regards,
Smita
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Can we get element name where cursor is placed
Post by cristi_talau »
Hello,
There is no JS API for that. You have two options:
1. Use a hard-coded list of possible children / possible parents.
2. Use a Java API: https://www.oxygenxml.com/InstData/Edit ... reContext- .
Best,
Cristian
There is no JS API for that. You have two options:
1. Use a hard-coded list of possible children / possible parents.
2. Use a Java API: https://www.oxygenxml.com/InstData/Edit ... reContext- .
Best,
Cristian
-
- Posts: 93
- Joined: Mon Aug 08, 2022 2:32 pm
Re: Can we get element name where cursor is placed
Post by SmitaPatil »
Hi Cristian,
Thank you.
Can you tell me how we can differentiate between other elements or tag and comment tag.
just wanted to know if there any method to get to know whether element is comment or not where cursor has placed.
Thanks & Regards,
Smita
Thank you.
Can you tell me how we can differentiate between other elements or tag and comment tag.
just wanted to know if there any method to get to know whether element is comment or not where cursor has placed.
Thanks & Regards,
Smita
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Can we get element name where cursor is placed
Post by cristi_talau »
Hello,
You can use the "nodeType" property of the node: https://developer.mozilla.org/en-US/doc ... e/nodeType .
Best,
Cristian
You can use the "nodeType" property of the node: https://developer.mozilla.org/en-US/doc ... e/nodeType .
Best,
Cristian
-
- Posts: 93
- Joined: Mon Aug 08, 2022 2:32 pm
Re: Can we get element name where cursor is placed
Post by SmitaPatil »
Hi Cristian,
Thank you.
I tried unwrapping <#comment> element but its not working.
Can you please tell how we can just remove comment tag and just keep the text which is present inside comment.
Thanks & Regards,
Smita
Thank you.
I tried unwrapping <#comment> element but its not working.
Can you please tell how we can just remove comment tag and just keep the text which is present inside comment.
Thanks & Regards,
Smita
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Can we get element name where cursor is placed
Post by cristi_talau »
Hello,
If you talk about using UnwrapTagsOperation, it does not work for comments. What you can do instead is to use a custom AuthorOperation that reads the content of an XML comment, delete the XML comment node and insert the content back.
Best,
Cristian
If you talk about using UnwrapTagsOperation, it does not work for comments. What you can do instead is to use a custom AuthorOperation that reads the content of an XML comment, delete the XML comment node and insert the content back.
Best,
Cristian
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