How to add data to insert/replace fragment
Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
-
- Posts: 12
- Joined: Mon Dec 12, 2022 11:19 pm
How to add data to insert/replace fragment
Hello, I am trying to enclose certain text in fragment inside the Web author. For example if the text I want to wrap is "truthness" it would replace the word "truthness" in a tag like this -
I have been playing around with Insert and Replace fragment but I think it is only taking self enclosed tags as input for fragment parameter.
Here is the code I am using that almost works except it adds data inside the tag as "reference" (<reference>reference</reference> instead of <reference>truthness</reference>)
Code: Select all
<reference referenceGuid="someguid">truthness</reference>
Code: Select all
<reference />
Here is the code I am using that almost works except it adds data inside the tag as "reference" (<reference>reference</reference> instead of <reference>truthness</reference>)
Code: Select all
var data = '<reference />';
editorGlobal.getActionsManager().invokeOperation(
'ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation',
{fragment: data},
function(e) {
console.log('Done!', e);
});
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: How to add data to insert/replace fragment
Hi,
The InsertFragmentOperation that you use will insert an empty reference element. The "reference" text that you see between the start and end tag of the inserted element is the placeholder that is displayed when the element is empty (it renders the name of the element by default).
Depending on what you want to achieve, there are multiple solutions.
For example, if you want to surround the selected content from the editor with a reference element, you can use the SurroundWithFragmentOperation.
If you want to surround specific content that is not selected, you can create and use a custom AuthorOperation that uses the ro.sync.ecss.extensions.api.AuthorDocumentController.surroundInFragment(String, int, int) API.
Best Regards,
Mihaela
The InsertFragmentOperation that you use will insert an empty reference element. The "reference" text that you see between the start and end tag of the inserted element is the placeholder that is displayed when the element is empty (it renders the name of the element by default).
Depending on what you want to achieve, there are multiple solutions.
For example, if you want to surround the selected content from the editor with a reference element, you can use the SurroundWithFragmentOperation.
If you want to surround specific content that is not selected, you can create and use a custom AuthorOperation that uses the ro.sync.ecss.extensions.api.AuthorDocumentController.surroundInFragment(String, int, int) API.
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