Activate/desactivate alternate CSS with javascript
Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
-
- Posts: 102
- Joined: Tue Mar 06, 2018 2:07 pm
- Contact:
Activate/desactivate alternate CSS with javascript
Hello,
Does someone know if it's possible to activate/desactivate an alternate CSS defined in an framework extension script directly with javascript (for Oxygen Web Author usage) ?
Thanks for any help.
Regards,
Nicolas
Does someone know if it's possible to activate/desactivate an alternate CSS defined in an framework extension script directly with javascript (for Oxygen Web Author usage) ?
Code: Select all
<addCss path="css/my-alternate.less" position="before" alternate="true" title="+ My alternate"/>
Regards,
Nicolas
Nicolas Delobel
AmeXio
nicolas.delobel at amexiogroup.com
AmeXio
nicolas.delobel at amexiogroup.com
-
- Site Admin
- Posts: 245
- Joined: Wed Aug 30, 2023 2:33 pm
Re: Activate/desactivate alternate CSS with javascript
Hello,
Sorry for the late reply.
Regarding your question about toggling an alternate CSS added via the framework extension script, one way to influence which stylesheets are loaded is by using the URL parameter stylesheet-titles. This parameter can be set to specify which CSS styles (including alternate ones) are enabled when Web Author loads. For example:
Note that the value here is URL-encoded. When decoded (you can use an online tool or decodeURIComponent() in JavaScript), it becomes: "Basic,+ Inline insertion actions". This corresponds to selecting the "Basic" stylesheet plus the "+ Inline insertion actions" alternate stylesheet that you have enabled in Web Author. This example corresponds to opening a topic from the Samples section on the Web Author Dashboard using the default styles.
You can also set this programmatically as a loading option [1]. For example:
Here, for example, the document is loaded with the Main style "Basic" and the Additional styles "Hints" and "Full width".
Best,
Cosmin
[1] https://www.oxygenxml.com/maven/com/oxy ... tions.html
Sorry for the late reply.
Regarding your question about toggling an alternate CSS added via the framework extension script, one way to influence which stylesheets are loaded is by using the URL parameter stylesheet-titles. This parameter can be set to specify which CSS styles (including alternate ones) are enabled when Web Author loads. For example:
Code: Select all
&stylesheet-titles=Basic,%2B%20Inline%20insertion%20actions
You can also set this programmatically as a loading option [1]. For example:
Code: Select all
workspace.listen(sync.api.Workspace.EventType.BEFORE_EDITOR_LOADED, function(e) {
e.options["stylesheet-titles"] = "Basic,+ Hints,+ Full width";
});
Best,
Cosmin
[1] https://www.oxygenxml.com/maven/com/oxy ... tions.html
Cosmin Eftenie
www.oxygenxml.com
www.oxygenxml.com
-
- Posts: 102
- Joined: Tue Mar 06, 2018 2:07 pm
- Contact:
Re: Activate/desactivate alternate CSS with javascript
Thanks Cosmin for these information.
But it seems that once the editor is loaded you can't change this options with new values.
What I want to implement is a toolbar button that permit to toogle a specific alternate CSS.
I tried this, but nothing append:
Once options are changes, is there a way to execute like a refresh to take into account new values ?
Thanks a lot.
Regards,
Nicolas
But it seems that once the editor is loaded you can't change this options with new values.
What I want to implement is a toolbar button that permit to toogle a specific alternate CSS.
I tried this, but nothing append:
Code: Select all
let length = workspace.currentEditor.options["stylesheet-titles"].length;
if (length === 1) {
workspace.currentEditor.options["stylesheet-titles"] = [];
workspace.currentEditor.options["stylesheet-titles"] = ["Basic", "+ Hints"];
} else {
workspace.currentEditor.options["stylesheet-titles"] = [];
workspace.currentEditor.options["stylesheet-titles"] = ["Basic"];
}
Thanks a lot.
Regards,
Nicolas
Nicolas Delobel
AmeXio
nicolas.delobel at amexiogroup.com
AmeXio
nicolas.delobel at amexiogroup.com
-
- Site Admin
- Posts: 245
- Joined: Wed Aug 30, 2023 2:33 pm
Re: Activate/desactivate alternate CSS with javascript
Hello,
Thank you for the details.
You can implement a custom action [1] on the toolbar that triggers a custom operation. Inside this operation, you can use the following APIs from the IWebappAuthorEditorAccess interface to toggle your alternate CSS:
Best,
Cosmin
[1] https://www.oxygenxml.com/maven/com/oxy ... ction.html
Thank you for the details.
You can implement a custom action [1] on the toolbar that triggers a custom operation. Inside this operation, you can use the following APIs from the IWebappAuthorEditorAccess interface to toggle your alternate CSS:
- : to check which CSS groups are currently active. - https://www.oxygenxml.com/InstData/Edit ... psTitles()
Code: Select all
getActiveCssGroupsTitles
- : to activate the desired CSS group(s). - https://www.oxygenxml.com/InstData/Edit ... .util.Set)
Code: Select all
changeActiveCssGroups
Best,
Cosmin
[1] https://www.oxygenxml.com/maven/com/oxy ... ction.html
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)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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