@lvce-editor/menu-worker 4.17.0 → 4.18.0

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.
@@ -2472,11 +2472,6 @@ const getVisible = (items, focusedIndex, expanded, level) => {
2472
2472
  return visibleItems;
2473
2473
  };
2474
2474
 
2475
- const CONTEXT_MENU_WIDTH = 250;
2476
- const getMenuWidth = () => {
2477
- return CONTEXT_MENU_WIDTH;
2478
- };
2479
-
2480
2475
  // TODO lazyload menuEntries and use Command.execute (maybe)
2481
2476
  const CONTEXT_MENU_ITEM_HEIGHT = 26;
2482
2477
  const CONTEXT_MENU_SEPARATOR_HEIGHT = 11;
@@ -2915,9 +2910,6 @@ const getSubMenuItems = async (parentMenu, item) => {
2915
2910
  const getOpenSubMenuToLeft = parentMenu => {
2916
2911
  return parentMenu.openSubMenuToLeft === true || parentMenu.args?.[0]?.openSubMenuToLeft === true;
2917
2912
  };
2918
- const getSubMenuX = (parentMenu, openSubMenuToLeft) => {
2919
- return openSubMenuToLeft ? parentMenu.x - MENU_WIDTH : parentMenu.x + MENU_WIDTH;
2920
- };
2921
2913
  const showSubMenuAtEnter = async (level, index, enterX, enterY) => {
2922
2914
  const parentMenu = get$1(level);
2923
2915
  const item = parentMenu.items[index];
@@ -2928,6 +2920,7 @@ const showSubMenuAtEnter = async (level, index, enterX, enterY) => {
2928
2920
  set$1(getAll().slice(0, level + 1));
2929
2921
  const subMenuItems = await getSubMenuItems(parentMenu, item);
2930
2922
  const openSubMenuToLeft = getOpenSubMenuToLeft(parentMenu);
2923
+ const width = await getMenuMeasuredWidth(subMenuItems);
2931
2924
  const subMenu = addMenuInternal({
2932
2925
  args: item.args || parentMenu.args || [],
2933
2926
  enterX,
@@ -2939,10 +2932,9 @@ const showSubMenuAtEnter = async (level, index, enterX, enterY) => {
2939
2932
  openSubMenuToLeft,
2940
2933
  parentIndex: index,
2941
2934
  uid: parentMenu.uid,
2942
- x: getSubMenuX(parentMenu, openSubMenuToLeft),
2935
+ x: openSubMenuToLeft ? Math.max(0, parentMenu.x - width) : parentMenu.x + MENU_WIDTH,
2943
2936
  y: parentMenu.y + index * 25
2944
2937
  });
2945
- const width = getMenuWidth();
2946
2938
  const height = getMenuHeight(subMenuItems);
2947
2939
  const visible = getVisible(subMenu.items, -1, false, subMenu.level);
2948
2940
  const dom = getMenuVirtualDom(visible).slice(1);
@@ -3133,10 +3125,7 @@ const selectIndexRestoreFocus = async (menu, item) => {
3133
3125
  };
3134
3126
 
3135
3127
  const selectIndexSubMenu = async (menu, item, index) => {
3136
- if (menu.focusedIndex === index) {
3137
- return;
3138
- }
3139
- await showSubMenu(menu.level, menu.focusedIndex);
3128
+ await showSubMenu(menu.level, index);
3140
3129
  };
3141
3130
 
3142
3131
  const getSelectIndexFunction = flags => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/menu-worker",
3
- "version": "4.17.0",
3
+ "version": "4.18.0",
4
4
  "description": "Menu Worker",
5
5
  "repository": {
6
6
  "type": "git",