Document Controller:: insertHtml

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
manojdcoder
Posts: 67
Joined: Thu Oct 29, 2020 12:01 am

Document Controller:: insertHtml

Post by manojdcoder »

I noticed internally Oxygen uses a method named `insertHtml` that accepts HTML and converts it appropriate language element before insert it into document.

For example running the code below in a DITA document automatically inserts <image href="..."/> where as on a DocBook it inserts imageobject which seems very convenient.

Code: Select all

workspace.currentEditor.getController().insertHtml(`<img src="path" />`)
Is there a documentation that reveals the HTML equivalent for every language element?
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: Document Controller:: insertHtml

Post by cristi_talau »

Hello,

First of all, the methods that you discovered are not API. To implement the same behavior using API you should create your own AuthorOperationWithResult [1] and that calls:

Code: Select all

authorDocumentModel.getActionsSupport().handleHtmlPaste(htmlString);
Then invoke this operation from JavaScript code using sync.api.ActionsManager#invokeOperation [2].

Regarding the correspondence between HTML elements and framework elements, this mapping uses the same code as the Smart Paste feature and is configurable using an XSLT stylesheet found in the framework [3].


[1] https://www.oxygenxml.com/InstData/Edit ... esult.html
[2] https://www.oxygenxml.com/maven/com/oxy ... eOperation
[3] https://www.oxygenxml.com/doc/versions/ ... paste.html
Post Reply