-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pro 6843 context menu additional items #4819
Conversation
e112914
to
6cd08f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already a way to register additional context operations server side. The palette module can call:
self.apos.doc.addContextOperation({
action: 'reset-palette-position',
if: {
type: self.__meta.name
}
});
This will make the operation available only for palette.
So there is no need to introduce a redundant way of registering custom context operations.
However I do think you may need a patch to allow them to trigger a bus event rather than opening a modal. This is the current logic that implements the "operation" property:
const props = {
moduleName: operation.moduleName || this.moduleName,
// For backwards compatibility
doc,
...docProps(doc),
...operation.props
};
await apos.modal.execute(operation.modal, props);
This will need an update to support emitting a bus event with an object containing the props as an alternative.
(Excuse me, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving for time but please fix changelog
CHANGELOG.md
Outdated
@@ -17,6 +17,7 @@ | |||
* Adds support for supplying CSS variable names to a color field's `presetColors` array as selectable values. | |||
* Adds support for dynamic focus trap in Context menus (prop `dynamicFocus`). When set to `true`, the focusable elements are recalculated on each cycle step. | |||
* Adds option to disable `tabindex` on `AposToggle` component. A new prop `disableFocus` can be set to `false` to disable the focus on the toggle button. It's enabled by default. | |||
* Adds new prop `additionalMenuItems` to `AposDocContextMenu`. Allow to pass additional menu items that can trigger an action when clicked, or simply pass the action as the close event parameter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
PRO-6843
Summary
I need to add in palette a new item in the context menu.
This item should not open any modal but just emit an event I could listen to know user clicked on it. So I cannot use
customOperations
here.I just added the possibility to pass an array of extra items to a
AposDocContextMenu
component.This one can be used to call an action like we already do, or to emit a simple event when closing to the parent, like I do with palette.
It allows me to do this in palette:
If I pass
emitEvent
it will simply emit close with theaction
as parameter.What are the specific steps to test this change?
See above
What kind of change does this PR introduce?
Make sure the PR fulfills these requirements: