Skip to content

Commit

Permalink
support concat webview context menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
yeweiasia committed Oct 20, 2022
1 parent bab36d2 commit a3c898d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"codearts",
"plugin"
],
"version": "0.4.1",
"version": "0.4.2",
"license": "SEE LICENSE IN LICENSE",
"description": "core plugin api of cloudide frontend and backend",
"repository": {
Expand Down
16 changes: 9 additions & 7 deletions src/browser/plugin-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,17 @@ export class PluginPage {
* Register context menu to the target dom
* @param target the dom to add context menu
* @param menu menu items
* @param concat concatenate all menu items registered
*/
public registerContextMenu(target: HTMLElement | Document, menu?: MenuItem[], isOnce?: boolean) {
target.addEventListener(
'contextmenu',
(e) => {
public registerContextMenu(target: HTMLElement | Document, menu?: MenuItem[], concat?: boolean) {
target.addEventListener('contextmenu', (e) => {
const curMenu: MenuItem[] | undefined = (e as any)['menu'];
if (concat) {
(e as any)['menu'] = curMenu || menu ? [...(curMenu || []), ...(menu || [])] : curMenu;
} else {
(e as any)['menu'] = menu;
},
{ once: !!isOnce }
);
}
});
}
}

Expand Down

0 comments on commit a3c898d

Please sign in to comment.