Page 1 of 1

Document Controller:: insertHtml

Posted: Thu Nov 19, 2020 11:38 pm
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?

Re: Document Controller:: insertHtml

Posted: Fri Nov 20, 2020 1:09 pm
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