Set Editor Type via JS Plugin
Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
-
- Posts: 6
- Joined: Wed May 15, 2024 6:16 pm
Set Editor Type via JS Plugin
Good day,
We're using Oxygen Web XML 25.1 with a host of custom frameworks and plugins, we have a single JS based plugin that handles all our primary UI needs.
We have a requirement to open Oxygen under specific editor types or "modes" based on certain custom options detected during the editor loading cycle.
Currently all our documents are opening under the Author mode as one would typically expect, however, is there a way to programmatically change the editor type from a JavaScript plugin? We can invoke Java actions if required.
I have scoured the various GitHub examples and documentation yet cannot seem to find a clear reference on this, thanks!
We're using Oxygen Web XML 25.1 with a host of custom frameworks and plugins, we have a single JS based plugin that handles all our primary UI needs.
We have a requirement to open Oxygen under specific editor types or "modes" based on certain custom options detected during the editor loading cycle.
Currently all our documents are opening under the Author mode as one would typically expect, however, is there a way to programmatically change the editor type from a JavaScript plugin? We can invoke Java actions if required.
I have scoured the various GitHub examples and documentation yet cannot seem to find a clear reference on this, thanks!
-
- Posts: 6
- Joined: Wed May 15, 2024 6:16 pm
Re: Set Editor Type via JS Plugin
For some additional context we're pulling the desired editor type/mode out of the URL passed to our editor,
The event_trigger method being our signature function that gets registered as a workspace event listener. It seems like I have access to the editor via e.editor as well, just not certain where to go past this.
Code: Select all
const loadAsXml = {
event: sync.api.Workspace.EventType.BEFORE_EDITOR_LOADED,
event_trigger: (e) => {
const options = e.options;
console.log(options.url);
//let newEditor = new sync.api.Editor();
},
};
-
- Site Admin
- Posts: 172
- Joined: Tue Mar 20, 2018 5:28 pm
Re: Set Editor Type via JS Plugin
Post by Bogdan Dumitru »
Hello,
One option is to register an sync.api.EditingSupportProvider with sync.api.EditingSupportManager.registerEditingSupportProvider that looks for a URL param in the the loading options (sync.api.Workspace.LoadingOptions) and return you custom EditingSupport implementation if it's specified.
Another option is to listen to sync.api.Workspace.EventType.EDITOR_LOADED and when editor gets loaded to invoke the action that shows the text page, somewhat like this: editor.getEditingSupport().getActionsManager().invokeAction("Author/ShowXML");
One option is to register an sync.api.EditingSupportProvider with sync.api.EditingSupportManager.registerEditingSupportProvider that looks for a URL param in the the loading options (sync.api.Workspace.LoadingOptions) and return you custom EditingSupport implementation if it's specified.
Another option is to listen to sync.api.Workspace.EventType.EDITOR_LOADED and when editor gets loaded to invoke the action that shows the text page, somewhat like this: editor.getEditingSupport().getActionsManager().invokeAction("Author/ShowXML");
Bogdan Dumitru
http://www.oxygenxml.com
http://www.oxygenxml.com
-
- Posts: 6
- Joined: Wed May 15, 2024 6:16 pm
Re: Set Editor Type via JS Plugin
Hi Bogdan,Bogdan Dumitru wrote: ↑Wed Jul 10, 2024 6:13 pm Hello,
One option is to register an sync.api.EditingSupportProvider with sync.api.EditingSupportManager.registerEditingSupportProvider that looks for a URL param in the the loading options (sync.api.Workspace.LoadingOptions) and return you custom EditingSupport implementation if it's specified.
Another option is to listen to sync.api.Workspace.EventType.EDITOR_LOADED and when editor gets loaded to invoke the action that shows the text page, somewhat like this: editor.getEditingSupport().getActionsManager().invokeAction("Author/ShowXML");
Thanks for your input, using the Author/ShowXML action worked perfectly. We may go down the route of providing our own editing support should we end up requiring more extendibility beyond this.
I'm not sure if the Oxygen team moderates or watches this forum heavily but this is a really good thing to demonstrate on the documentation site! Here's some sample code even:
on your main plugin.js
Code: Select all
workspace.listen(sync.api.Workspace.EventType.EDITOR_LOADED, (e) => {
console.log("Editor Loaded");
e.editor.getEditingSupport().getActionsManager().invokeAction("Author/ShowXML");
//see the actions manager
console.log(e.editor.getEditingSupport().getActionsManager())
});
-
- Site Admin
- Posts: 233
- Joined: Wed Aug 30, 2023 2:33 pm
Re: Set Editor Type via JS Plugin
Hello,
We are glad to hear that we have been helpful to you.
Also, thank you for the suggestion and we will take it into consideration.
Best,
Cosmin
We are glad to hear that we have been helpful to you.
Also, thank you for the suggestion and we will take it into consideration.
Best,
Cosmin
Cosmin Eftenie
www.oxygenxml.com
www.oxygenxml.com
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