@lvce-editor/title-bar-worker 3.0.0 → 3.1.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.
@@ -1278,10 +1278,11 @@ const create$1 = () => {
1278
1278
  wrapCommand(fn) {
1279
1279
  const wrapped = async (uid, ...args) => {
1280
1280
  const {
1281
+ oldState,
1281
1282
  newState
1282
1283
  } = states[uid];
1283
1284
  const newerState = await fn(newState, ...args);
1284
- if (newState === newerState) {
1285
+ if (oldState === newerState || newState === newerState) {
1285
1286
  return;
1286
1287
  }
1287
1288
  const latest = states[uid];
@@ -1682,6 +1683,9 @@ const getMenuIds = () => {
1682
1683
  * @enum {string}
1683
1684
  */
1684
1685
  const UiStrings$1 = {
1686
+ AddCursorAbove: 'Add Cursor Above',
1687
+ AddNextOccurrence: 'Add Next Occurrence',
1688
+ AddPreviousOccurrence: 'Add Previous Occurrence',
1685
1689
  Copy: 'Copy',
1686
1690
  CopyLineDown: 'Copy Line Down',
1687
1691
  CopyLineUp: 'Copy Line Up',
@@ -1691,6 +1695,8 @@ const UiStrings$1 = {
1691
1695
  Paste: 'Paste',
1692
1696
  Redo: 'Redo',
1693
1697
  SelectAll: 'Select All',
1698
+ SelectAllOccurrences: 'Select All Occurrences',
1699
+ ShrinkSelection: 'Shrink Selection',
1694
1700
  ToggleBlockComment: 'Toggle Block Comment',
1695
1701
  ToggleLineComment: 'Toggle Line Comment',
1696
1702
  Undo: 'Undo'
@@ -1719,6 +1725,12 @@ const toggleBlockComment = () => {
1719
1725
  const selectAll = () => {
1720
1726
  return i18nString(UiStrings$1.SelectAll);
1721
1727
  };
1728
+ const expandSelection = () => {
1729
+ return i18nString(UiStrings$1.SelectAll);
1730
+ };
1731
+ const shrinkSelection = () => {
1732
+ return i18nString(UiStrings$1.ShrinkSelection);
1733
+ };
1722
1734
  const copyLineUp = () => {
1723
1735
  return i18nString(UiStrings$1.CopyLineUp);
1724
1736
  };
@@ -1731,6 +1743,27 @@ const moveLineUp = () => {
1731
1743
  const moveLineDown = () => {
1732
1744
  return i18nString(UiStrings$1.MoveLineDown);
1733
1745
  };
1746
+ const duplicateSelection = () => {
1747
+ return i18nString(UiStrings$1.MoveLineDown);
1748
+ };
1749
+ const addCursorAbove = () => {
1750
+ return i18nString(UiStrings$1.AddCursorAbove);
1751
+ };
1752
+ const addCursorBelow = () => {
1753
+ return i18nString(UiStrings$1.AddCursorAbove);
1754
+ };
1755
+ const addCursorsToLineEnds = () => {
1756
+ return i18nString(UiStrings$1.AddCursorAbove);
1757
+ };
1758
+ const addNextOccurrence = () => {
1759
+ return i18nString(UiStrings$1.AddNextOccurrence);
1760
+ };
1761
+ const addPreviousOccurrence = () => {
1762
+ return i18nString(UiStrings$1.AddPreviousOccurrence);
1763
+ };
1764
+ const selectAllOccurrences = () => {
1765
+ return i18nString(UiStrings$1.SelectAllOccurrences);
1766
+ };
1734
1767
 
1735
1768
  const menuEntrySeparator = {
1736
1769
  command: '',
@@ -2003,6 +2036,16 @@ const getMenuEntries$6 = () => {
2003
2036
  id: 'selectAll',
2004
2037
  label: selectAll()
2005
2038
  }, {
2039
+ command: 'Editor.expandSelection',
2040
+ flags: None,
2041
+ id: 'expandSelection',
2042
+ label: expandSelection()
2043
+ }, {
2044
+ command: 'Editor.shrinkSelection',
2045
+ flags: None,
2046
+ id: 'shrinkSelection',
2047
+ label: shrinkSelection()
2048
+ }, menuEntrySeparator, {
2006
2049
  command: 'Editor.copyLineUp',
2007
2050
  flags: None,
2008
2051
  id: 'copyLineUp',
@@ -2022,6 +2065,41 @@ const getMenuEntries$6 = () => {
2022
2065
  flags: Disabled,
2023
2066
  id: 'moveLineDown',
2024
2067
  label: moveLineDown()
2068
+ }, {
2069
+ command: 'Editor.duplicateSelection',
2070
+ flags: Disabled,
2071
+ id: 'duplicateSelection',
2072
+ label: duplicateSelection()
2073
+ }, menuEntrySeparator, {
2074
+ command: 'Editor.addCursorAbove',
2075
+ flags: Disabled,
2076
+ id: 'addCursorAbove',
2077
+ label: addCursorAbove()
2078
+ }, {
2079
+ command: 'Editor.addCursorBelow',
2080
+ flags: Disabled,
2081
+ id: 'addCursorBelow',
2082
+ label: addCursorBelow()
2083
+ }, {
2084
+ command: 'Editor.addCursorsToLineEnds',
2085
+ flags: Disabled,
2086
+ id: 'addCursorsToLineEnds',
2087
+ label: addCursorsToLineEnds()
2088
+ }, {
2089
+ command: 'Editor.addNextOccurrence',
2090
+ flags: Disabled,
2091
+ id: 'addNextOccurrence',
2092
+ label: addNextOccurrence()
2093
+ }, {
2094
+ command: 'Editor.addPreviousOccurrence',
2095
+ flags: Disabled,
2096
+ id: 'addPreviousOccurrence',
2097
+ label: addPreviousOccurrence()
2098
+ }, {
2099
+ command: 'Editor.selectAllOccurrences',
2100
+ flags: Disabled,
2101
+ id: 'selectAllOccurrences',
2102
+ label: selectAllOccurrences()
2025
2103
  }];
2026
2104
  };
2027
2105
 
@@ -2531,42 +2609,6 @@ const getMenuEntries$1 = async platform => {
2531
2609
  return fn();
2532
2610
  };
2533
2611
 
2534
- const getFn = id => {
2535
- switch (id) {
2536
- case Edit$2:
2537
- return getMenuEntries$c;
2538
- case File$3:
2539
- return getMenuEntries$b;
2540
- case Go$2:
2541
- return getMenuEntries$a;
2542
- case Help$2:
2543
- return getMenuEntries$9;
2544
- case OpenRecent$1:
2545
- return getMenuEntries$8;
2546
- case Run$2:
2547
- return getMenuEntries$7;
2548
- case Selection$2:
2549
- return getMenuEntries$6;
2550
- case Terminal$2:
2551
- return getMenuEntries$5;
2552
- case TitleBar:
2553
- return getMenuEntries$1;
2554
- case View$2:
2555
- return getMenuEntries$4;
2556
- default:
2557
- return undefined;
2558
- }
2559
- };
2560
- const getMenuEntries = async (id, ...args) => {
2561
- try {
2562
- const fn = getFn(id);
2563
- // @ts-ignore
2564
- return fn(...args);
2565
- } catch (error) {
2566
- throw new VError(error, `Failed to load menu entries for id ${id}`);
2567
- }
2568
- };
2569
-
2570
2612
  const loadContent2 = async state => {
2571
2613
  const {
2572
2614
  controlsOverlayEnabled,
@@ -2578,7 +2620,7 @@ const loadContent2 = async state => {
2578
2620
  platform,
2579
2621
  titleBarStyleCustom
2580
2622
  } = state;
2581
- const titleBarEntries = await getMenuEntries(TitleBar);
2623
+ const titleBarEntries = await getMenuEntries$1(platform);
2582
2624
  const withWidths = addWidths(titleBarEntries, labelPadding, labelFontWeight, labelFontSize, labelFontFamily, labelLetterSpacing);
2583
2625
  const buttons = getTitleBarButtons(platform, controlsOverlayEnabled, titleBarStyleCustom);
2584
2626
  const workspaceUri = await invoke('Workspace.getUri');
@@ -3402,6 +3444,42 @@ const handleKeyArrowLeftMenuOpen = async state => {
3402
3444
 
3403
3445
  const handleKeyArrowLeft = ifElse(handleKeyArrowLeftMenuOpen, handleKeyArrowLeftMenuClosed);
3404
3446
 
3447
+ const getFn = id => {
3448
+ switch (id) {
3449
+ case Edit$2:
3450
+ return getMenuEntries$c;
3451
+ case File$3:
3452
+ return getMenuEntries$b;
3453
+ case Go$2:
3454
+ return getMenuEntries$a;
3455
+ case Help$2:
3456
+ return getMenuEntries$9;
3457
+ case OpenRecent$1:
3458
+ return getMenuEntries$8;
3459
+ case Run$2:
3460
+ return getMenuEntries$7;
3461
+ case Selection$2:
3462
+ return getMenuEntries$6;
3463
+ case Terminal$2:
3464
+ return getMenuEntries$5;
3465
+ case TitleBar:
3466
+ return getMenuEntries$1;
3467
+ case View$2:
3468
+ return getMenuEntries$4;
3469
+ default:
3470
+ return undefined;
3471
+ }
3472
+ };
3473
+ const getMenuEntries = async (id, ...args) => {
3474
+ try {
3475
+ const fn = getFn(id);
3476
+ // @ts-ignore
3477
+ return fn(...args);
3478
+ } catch (error) {
3479
+ throw new VError(error, `Failed to load menu entries for id ${id}`);
3480
+ }
3481
+ };
3482
+
3405
3483
  // TODO menu should not be needed initially, only when item is selected and menu is opened
3406
3484
  const handleKeyArrowRightMenuOpen = async state => {
3407
3485
  const {
@@ -3628,6 +3706,9 @@ const handleMenuMouseOver = async (state, level, index) => {
3628
3706
  menus
3629
3707
  } = state;
3630
3708
  const menu = menus[level];
3709
+ if (!menu) {
3710
+ return state;
3711
+ }
3631
3712
  const {
3632
3713
  focusedIndex,
3633
3714
  items,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/title-bar-worker",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Title Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",