@lvce-editor/menu-worker 4.15.0 → 4.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1411,9 +1411,9 @@ const {
1411
1411
  invokeAndTransfer,
1412
1412
  set: set$2
1413
1413
  } = create$1(RendererWorker);
1414
- const sendMessagePortToRendererProcess = async port => {
1414
+ const sendMessagePortToRendererProcess = async (port, rpcId = DebugWorker) => {
1415
1415
  const command = 'HandleMessagePort.handleMessagePort';
1416
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
1416
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, rpcId);
1417
1417
  };
1418
1418
  const sendMessagePortToTextMeasurementWorker = async port => {
1419
1419
  const command = 'TextMeasurement.handleMessagePort';
@@ -1421,7 +1421,7 @@ const sendMessagePortToTextMeasurementWorker = async port => {
1421
1421
  };
1422
1422
 
1423
1423
  const send$1 = port => {
1424
- return sendMessagePortToRendererProcess(port);
1424
+ return sendMessagePortToRendererProcess(port, 'MenuWorker');
1425
1425
  };
1426
1426
  const createRendererProcessRpc = async () => {
1427
1427
  try {
@@ -1583,7 +1583,7 @@ const getMenuHeight$1 = items => {
1583
1583
  }
1584
1584
  return height;
1585
1585
  };
1586
- const getMenuBounds = async (x, y, items) => {
1586
+ const getMenuBounds = async (x, y, items, openBelow = false) => {
1587
1587
  const menuWidth = await getMenuMeasuredWidth(items);
1588
1588
  const menuHeight = getMenuHeight$1(items);
1589
1589
  const layoutState = {
@@ -1598,7 +1598,7 @@ const getMenuBounds = async (x, y, items) => {
1598
1598
  x -= menuWidth + MENU_TARGET_GAP;
1599
1599
  x = Math.max(x, 0);
1600
1600
  }
1601
- if (y + menuHeight > windowHeight) {
1601
+ if (!openBelow && y + menuHeight > windowHeight) {
1602
1602
  y -= menuHeight;
1603
1603
  y = Math.max(y, 0);
1604
1604
  }
@@ -2549,9 +2549,9 @@ const show$2 = async (x, y, id, mouseBlocking = false, ...args) => {
2549
2549
  const dom = getMenuVirtualDom(visible).slice(1);
2550
2550
  await invoke$1(/* Menu.show */'Menu.showMenu', /* x */bounds.x, /* y */bounds.y, /* width */bounds.width, /* height */bounds.height, /* items */menu.items, /* level */menu.level, /* parentIndex */-1, /* dom */dom, /* mouseBlocking */mouseBlocking);
2551
2551
  };
2552
- const show2$2 = async (uid, menuId, x, y, mouseBlocking = false, ...args) => {
2552
+ const show2Internal = async (uid, menuId, x, y, mouseBlocking, openBelow, ...args) => {
2553
2553
  const items = await getMenuEntriesWithKeyBindings2(uid, menuId, ...args);
2554
- const bounds = await getMenuBounds(x, y, items);
2554
+ const bounds = await getMenuBounds(x, y, items, openBelow);
2555
2555
  const menu = addMenuInternal({
2556
2556
  args,
2557
2557
  focusedIndex: -1,
@@ -2566,6 +2566,12 @@ const show2$2 = async (uid, menuId, x, y, mouseBlocking = false, ...args) => {
2566
2566
  const dom = getMenuVirtualDom(visible).slice(1);
2567
2567
  await invoke$1(/* Menu.show */'Menu.showMenu', /* x */bounds.x, /* y */bounds.y, /* width */bounds.width, /* height */bounds.height, /* items */menu.items, /* level */menu.level, /* parentIndex */-1, /* dom */dom, /* mouseBlocking */mouseBlocking);
2568
2568
  };
2569
+ const show2$2 = async (uid, menuId, x, y, mouseBlocking = false, ...args) => {
2570
+ return show2Internal(uid, menuId, x, y, mouseBlocking, false, ...args);
2571
+ };
2572
+ const show2Below$2 = async (uid, menuId, x, y, mouseBlocking = false, ...args) => {
2573
+ return show2Internal(uid, menuId, x, y, mouseBlocking, true, ...args);
2574
+ };
2569
2575
 
2570
2576
  const show$1 = async (x, y, id, ...args) => {
2571
2577
  // @ts-ignore
@@ -2585,11 +2591,17 @@ const show2$1 = async (uid, menuId, x, y, ...args) => {
2585
2591
  // TODO maybe only send labels and keybindings to ui (id not needed on ui)
2586
2592
  // TODO what about separators?
2587
2593
  };
2594
+ const show2Below$1 = async (uid, menuId, x, y, ...args) => {
2595
+ // @ts-ignore
2596
+ await hide();
2597
+ await show2Below$2(uid, menuId, x, y, /* mouseBlocking */true, ...args);
2598
+ };
2588
2599
 
2589
2600
  const ContextMenuBrowser = {
2590
2601
  __proto__: null,
2591
2602
  show: show$1,
2592
- show2: show2$1
2603
+ show2: show2$1,
2604
+ show2Below: show2Below$1
2593
2605
  };
2594
2606
 
2595
2607
  const getModule = async platform => {
@@ -2611,6 +2623,15 @@ const show2 = async (uid, menuId, x, y, ...args) => {
2611
2623
  // @ts-ignore
2612
2624
  return module.show2(uid, menuId, x, y, ...args);
2613
2625
  };
2626
+ const show2Below = async (uid, menuId, x, y, ...args) => {
2627
+ number(uid);
2628
+ number(menuId);
2629
+ number(x);
2630
+ number(y);
2631
+ const module = await getModule();
2632
+ // @ts-ignore
2633
+ return module.show2Below(uid, menuId, x, y, ...args);
2634
+ };
2614
2635
 
2615
2636
  const RenderEntries = 1;
2616
2637
  const RenderFocusedIndex = 2;
@@ -3214,6 +3235,7 @@ const commandMap = {
3214
3235
  'Menu.selectItem': selectItem,
3215
3236
  'Menu.show': show,
3216
3237
  'Menu.show2': show2,
3238
+ 'Menu.show2Below': show2Below,
3217
3239
  'Menu.showSubMenu': showSubMenu
3218
3240
  };
3219
3241
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/menu-worker",
3
- "version": "4.15.0",
3
+ "version": "4.16.1",
4
4
  "description": "Menu Worker",
5
5
  "repository": {
6
6
  "type": "git",