Document Controller:: insertHtml

Posts: 63
Joined: Thu Oct 29, 2020 12:01 am

Document Controller:: insertHtml

Post by manojdcoder » Thu Nov 19, 2020 11:38 pm

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?

Posts: 341
Joined: Thu Sep 04, 2014 4:22 pm

Re: Document Controller:: insertHtml

Post by cristi_talau » Fri Nov 20, 2020 1:09 pm


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

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] ... esult.html
[2] ... eOperation
[3] ... paste.html

Post Reply