Refresh contextual menu action name
Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
-
- Posts: 98
- Joined: Tue Mar 06, 2018 2:07 pm
- Contact:
Refresh contextual menu action name
Hello,
In Oxygen web Author, I would like to add an action that takes name of current selected element in contextual menu.
Each time the contextual menu is displayed, this action's name will have the name of the current selected element.
So I use this code to get current tag name:
And I add action to the contextuel menu:
It works but just one time, because ACTIONS_LOADED is triggered only once
The action's name in contextual menu is not refreshed when the selection change.
Is there a way to achieve this behavior?
Thanks.
In Oxygen web Author, I would like to add an action that takes name of current selected element in contextual menu.
Each time the contextual menu is displayed, this action's name will have the name of the current selected element.
So I use this code to get current tag name:
Code: Select all
//display name
DisplayCurrentElementAction.prototype.getDisplayName = function () {
var oxyNode = this.editor.getSelectionManager().getSelection().getNodeAtCaret().getTagName();
return oxyNode;
};
Code: Select all
goog.events.listen(workspace, sync.api.Workspace.EventType.EDITOR_LOADED, function (e) {
var editor = e.editor;
editor.getActionsManager().registerAction('display.current.element.action', new DisplayCurrentElementAction(editor));
addToContextMenu(editor, 'display.current.element.action');
});
function addToContextMenu(editor, actionId) {
editor.listen(sync.api.Editor.EventTypes.ACTIONS_LOADED, function (e) {
var contextualItems = e.actionsConfiguration.contextualItems;
if (contextualItems) {
contextualItems.unshift({
id: actionId,
type: "action"
});
}
});
}
The action's name in contextual menu is not refreshed when the selection change.
Is there a way to achieve this behavior?
Thanks.
Nicolas Delobel
AmeXio
nicolas.delobel at amexiogroup.com
AmeXio
nicolas.delobel at amexiogroup.com
-
- Site Admin
- Posts: 95
- Joined: Thu Jun 09, 2016 2:01 pm
Re: Refresh contextual menu action name
Post by Gabriel Titerlea »
Hello,
Refreshing the displayName of actions is not possible at the moment. I registered a feature request and we'll update this forum post when we have a fix available.
Meanwhile, as a workaround, you can change the DOM of the menu-item yourself, during the isEnabled method execution. Something like this:
Best,
Gabriel
Refreshing the displayName of actions is not possible at the moment. I registered a feature request and we'll update this forum post when we have a fix available.
Meanwhile, as a workaround, you can change the DOM of the menu-item yourself, during the isEnabled method execution. Something like this:
Code: Select all
DisplayCurrentElementAction.prototype.isEnabled = function () {
var tagName = this.editor.getSelectionManager().getSelection().getNodeAtCaret().getTagName();
let menuItemNode = document.querySelector('.goog-menuitem[name="display.current.element.action"] span');
if (menuItemNode) {
menuItemNode.textContent = tagName;
}
// isEnabled logic.
return true;
}
Gabriel
-
- Posts: 98
- Joined: Tue Mar 06, 2018 2:07 pm
- Contact:
Re: Refresh contextual menu action name
Hello Gabriel,
Thanks a lot for this workaround. It works like a charm!
Regards,
Nicolas
Thanks a lot for this workaround. It works like a charm!
Regards,
Nicolas
Nicolas Delobel
AmeXio
nicolas.delobel at amexiogroup.com
AmeXio
nicolas.delobel at amexiogroup.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