Ability to Set Loading Option Depending on Presence of Attribute in DITA
Posted: Tue Apr 08, 2025 10:28 pm
Hi Oxygen Support,
This question is related to my post about using xml:lang CSS selector: common-problems-f34/topic27291.html
We have DITA topics whose contents have been translated. To indicate this, we've added a new attribute to our custom DITA schema called "translated" that supports a single value of "yes". We typically set this attribute on the root <topic> element.
We would now like our SMEs to review the translated content in Web Author; however, since the translated content is not the actual source content, we want to prevent SMEs from editing the topic's contents.
To achieve this, I've attempted to use a plugin to control the loading options and set the editing mode to "review" and to set trackedChanges to "forced" if any element has the attribute "translated".
For example, here's my plugin JS code:
I noticed that the "translated" attribute is converted into "data-attr-translated" when Web Author is rendered, hence my use of "data-attr-translated".
Do you have any suggestions for how we can set the editing mode to "review" and trackChanges to "forced" if any element in the topic has the translated attribute?
Thanks!
Daniel
This question is related to my post about using xml:lang CSS selector: common-problems-f34/topic27291.html
We have DITA topics whose contents have been translated. To indicate this, we've added a new attribute to our custom DITA schema called "translated" that supports a single value of "yes". We typically set this attribute on the root <topic> element.
We would now like our SMEs to review the translated content in Web Author; however, since the translated content is not the actual source content, we want to prevent SMEs from editing the topic's contents.
To achieve this, I've attempted to use a plugin to control the loading options and set the editing mode to "review" and to set trackedChanges to "forced" if any element has the attribute "translated".
For example, here's my plugin JS code:
Code: Select all
function checkIfAttributeExists(attributeName) {
const elements = document.querySelectorAll(`[${attributeName}]`);
return elements.length > 0;
}
const attributeToCheck = "data-attr-translated";
const hasAttribute = checkIfAttributeExists(attributeToCheck);
goog.events.listen(workspace, sync.api.Workspace.EventType.BEFORE_EDITOR_LOADED, function(e) {
if (e.options.url.includes('.dita')) {
e.options['showDitaMapView'] = 'true';
if (hasAttribute) {
e.options.trackChanges = 'forced'
e.options.modes = 'review'
} else {
e.options.trackChanges = 'enabled'
}
}
});
Do you have any suggestions for how we can set the editing mode to "review" and trackChanges to "forced" if any element in the topic has the translated attribute?
Thanks!
Daniel