Side view based on current XML content
Posted: Mon Mar 28, 2022 12:32 pm
Hello,
In my Oxygen Web Author framework, I try to build a custom side view that use current XML content.
So I get the content in a var called currentXmlDocument.
But my problem is that currentXmlDocument variable is populated after the side view installation.
How can I resolve this issue?
Thanks for help.
Regards,
Nicolas
In my Oxygen Web Author framework, I try to build a custom side view that use current XML content.
So I get the content in a var called currentXmlDocument.
But my problem is that currentXmlDocument variable is populated after the side view installation.
How can I resolve this issue?
Thanks for help.
Code: Select all
let currentXmlDocument = '';
(function () {
class TocViewRenderer extends sync.view.ViewRenderer {
constructor(editor) {
super();
this.selectionListener_ = this.updateOnSelectionChanged.bind(this);
this.open_ = false;
this.renderTimer_ = 0;
}
editorChanged(editor) {
this.actionsManager_ = editor.getActionsManager();
}
install(element) {
console.log('install Toc side view');
this.container_ = element;
console.log(currentXmlDocument); //is empty here
element.innerHTML = currentXmlDocument;
}
opened() { }
closed() { }
updateOnSelectionChanged() { }
update() { }
getTitle() {
return "Toc navigation";
}
getIcon() {
return sync.ext.Registry.extensionURL + "/static/nav-toc24.png";
}
}
workspace.getViewManager().addView("nav-toc");
workspace.getViewManager().installView("nav-toc", new TocViewRenderer(), 'left');
})();
goog.events.listen(
workspace,
sync.api.Workspace.EventType.EDITOR_LOADED,
function (e) {
let editor = e.editor;
console.log(editor.getUrl());
editor.getContent(function cb(e, content) {
currentXmlDocument = content;
console.log(currentXmlDocument);
});
}
);
Nicolas