Skip to content
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

feat(context-menu): new sheet experiment #1631

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apis/nucleus/src/components/Cell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,12 @@ const Cell = forwardRef(
const snapshot = await this.takeSnapshot(); // eslint-disable-line
return halo.config.snapshot.capture(snapshot);
},
async getContextMenu(menu, event, menuBuilder, features, context) {
if (state.sn?.component && typeof state.sn.component.onContextMenu === 'function') {
return state.sn.component.onContextMenu(menu, event, menuBuilder, features, context);
}
return undefined;
},
}),
[state.sn, contentRect, cellRect, layout, theme.name, appLayout]
);
Expand Down
3 changes: 3 additions & 0 deletions apis/nucleus/src/viz.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ export default function viz({ model, halo, initialError, onDestroy = async () =>
cellRef.current.setModel(newModel);
}
},
async getContextMenu(menu, event, menuBuilder, features, context) {
return cellRef.current.getContextMenu(menu, event, menuBuilder, features, context);
},
/**
* Listens to custom events from inside the visualization. See useEmitter
* @param {string} eventName Event name to listen to
Expand Down
4 changes: 2 additions & 2 deletions apis/supernova/src/creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ function createWithHooks(generator, opts, galaxy) {
setSnapshotData(layout) {
return generator.component.runSnaps(this, layout);
},
onContextMenu(menu, event, menuBuilder) {
return generator.component.runMenu(this, menu, event, menuBuilder);
onContextMenu(menu, event, menuBuilder, features, context) {
return generator.component.runMenu(this, menu, event, menuBuilder, features, context);
},
focus() {
generator.component.focus(this);
Expand Down
8 changes: 4 additions & 4 deletions apis/supernova/src/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ export function runSnaps(component, layout) {
return Promise.resolve();
}

export function runMenu(component, menu, event, menuBuilder) {
export function runMenu(component, menu, event, menuBuilder, features, context) {
try {
return Promise.all(component.__hooks.menus.map((h) => Promise.resolve(h.fn(menu, event, menuBuilder)))).then(
(menus) => menus[menus.length - 1]
);
return Promise.all(
component.__hooks.menus.map((h) => Promise.resolve(h.fn(menu, event, menuBuilder, features, context)))
).then((menus) => menus[menus.length - 1]);
} catch (e) {
console.error(e);
}
Expand Down