Perform action from side view in Oxygen Web Author
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 98
- Joined: Tue Mar 06, 2018 2:07 pm
- Contact:
Perform action from side view in Oxygen Web Author
Hello,
I created a custom side view in OWA with following javascript.
In this side view, I try to perform an action (insert fragment) when I click on a button. But nothing append when I click on it.
"test-insert-fragment" action exist in my framework.
Thanks for your help.
I created a custom side view in OWA with following javascript.
In this side view, I try to perform an action (insert fragment) when I click on a button. But nothing append when I click on it.
"test-insert-fragment" action exist in my framework.
Thanks for your help.
Code: Select all
workspace.getViewManager().addView('cms-custom-view');
/**
* CMS View Renderer
*/
MyViewRenderer = function() {
sync.view.ViewRenderer.call(this);
};
MyViewRenderer.prototype = Object.create(sync.view.ViewRenderer.prototype);
MyViewRenderer.prototype.constructor = MyViewRenderer;
MyViewRenderer.prototype.getTitle = function() {
return 'Custom View';
};
MyViewRenderer.prototype.install = function(element) {
element.innerHTML = ' <button onclick="performAction(test-insert-fragment)">Click me</button>';
};
workspace.getViewManager().installView('cms-custom-view', new MyViewRenderer(), 'right');
function performAction(actionID) {
// Create an action
myAction = authorAccess.getEditorAccess().getActionsProvider().getAuthorExtensionActions().get(actionID);
authorAccess.getEditorAccess().getActionsProvider().invokeAction(myAction);
}
Nicolas Delobel
AmeXio
nicolas.delobel at amexiogroup.com
AmeXio
nicolas.delobel at amexiogroup.com
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Perform action from side view in Oxygen Web Author
Post by cristi_talau »
Hello,
The script that you pasted is executed inside the browser. However, the function "performAction" at the end of your script tries to use the Java API which has to be executed on the Web Author server.
What you should do is to use the JavaScript API to execute an operation. The code should look like the one below [1]:
To obtain a reference to the editor object you should implement the "editorChanged" callback of the ViewRenderer [2].
Also, we have a sample plugin that displays the list of elements that can be inserted at the caret position in a side-view. Clicking on them will insert the element. Maybe you can start from this plugin: https://github.com/oxygenxml/web-author ... ments-view .
Best,
Cristian
[1] https://www.oxygenxml.com/maven/com/oxy ... fydoc.html
[2] https://www.oxygenxml.com/maven/com/oxy ... ed__anchor
The script that you pasted is executed inside the browser. However, the function "performAction" at the end of your script tries to use the Java API which has to be executed on the Web Author server.
What you should do is to use the JavaScript API to execute an operation. The code should look like the one below [1]:
Code: Select all
if (editor.getEditingSupport().getType() === sync.api.Editor.EditorTypes.AUTHOR) {
editor.getActionsManager().invokeOperation(
'ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation',
{fragment: 'Oxygen XML Web Author'},
function() {
console.log('Done!');
});
}
Also, we have a sample plugin that displays the list of elements that can be inserted at the caret position in a side-view. Clicking on them will insert the element. Maybe you can start from this plugin: https://github.com/oxygenxml/web-author ... ments-view .
Best,
Cristian
[1] https://www.oxygenxml.com/maven/com/oxy ... fydoc.html
[2] https://www.oxygenxml.com/maven/com/oxy ... ed__anchor
-
- Posts: 98
- Joined: Tue Mar 06, 2018 2:07 pm
- Contact:
Re: Perform action from side view in Oxygen Web Author
Hello Cristian,
Thanks for you help, I start from the plugin and it works!
I have another question. My goal is to manage a library of XML fragments that I could add from a side view (e.g. prefilled list, floating image with text, predefined legal text, etc.) as it is made for Templates (https://www.oxygenxml.com/xml_web_autho ... -templates).
Do you think that is possible?
Thanks.
Thanks for you help, I start from the plugin and it works!
I have another question. My goal is to manage a library of XML fragments that I could add from a side view (e.g. prefilled list, floating image with text, predefined legal text, etc.) as it is made for Templates (https://www.oxygenxml.com/xml_web_autho ... -templates).
Do you think that is possible?
Thanks.
Nicolas Delobel
AmeXio
nicolas.delobel at amexiogroup.com
AmeXio
nicolas.delobel at amexiogroup.com
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Perform action from side view in Oxygen Web Author
Post by cristi_talau »
Hello,
Yes. It should be possible to implement this in a plugin. You can either hard-code fragments in the plugin configuration, retrieve them from a web service or even save them in a file in the CMS.
If you have questions on how to implement a specific behaviour, let us know.
Best,
Cristian
Yes. It should be possible to implement this in a plugin. You can either hard-code fragments in the plugin configuration, retrieve them from a web service or even save them in a file in the CMS.
If you have questions on how to implement a specific behaviour, let us know.
Best,
Cristian
Return to “SDK-API, Frameworks - Document Types”
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