@lvce-editor/text-search-worker 5.28.0 → 5.30.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.
@@ -1232,6 +1232,7 @@ const Script$1 = 2;
1232
1232
  const Search$1 = 18;
1233
1233
  const InputContextMenu = 91;
1234
1234
 
1235
+ const Separator = 1;
1235
1236
  const None$1 = 0;
1236
1237
 
1237
1238
  const LeftClick = 0;
@@ -1756,12 +1757,14 @@ const copy$1 = async state => {
1756
1757
  const copyPath$1 = async state => {
1757
1758
  const {
1758
1759
  items,
1759
- focusedIndex
1760
+ focusedIndex,
1761
+ listFocusedIndex
1760
1762
  } = state;
1761
- if (focusedIndex === -1) {
1763
+ const actualIndex = focusedIndex === -1 ? listFocusedIndex : focusedIndex;
1764
+ if (actualIndex === -1) {
1762
1765
  return state;
1763
1766
  }
1764
- const item = items[focusedIndex];
1767
+ const item = items[actualIndex];
1765
1768
  await writeClipBoardText(item.text);
1766
1769
  return state;
1767
1770
  };
@@ -2183,6 +2186,7 @@ const ConfirmReplaceManyOccurrencesInOneFileNoValue = 'Replace {PH1} occurrences
2183
2186
  const ConfirmReplaceOneOccurrenceInOneFile = "Replace 1 occurrence across 1 file with '{PH1}'";
2184
2187
  const ConfirmReplaceOneOccurrenceInOneFileNoValue = 'Replace 1 occurrence across 1 file';
2185
2188
  const CopyPath = 'Copy Path';
2189
+ const CopyAll = 'Copy All';
2186
2190
  const Dismiss = 'Dismiss';
2187
2191
  const Cut = 'Cut';
2188
2192
  const Copy = 'Copy';
@@ -2332,6 +2336,9 @@ const theResultSetOnlyContainsASubSetOfMatches = () => {
2332
2336
  const copyPath = () => {
2333
2337
  return i18nString(CopyPath);
2334
2338
  };
2339
+ const copyAll = () => {
2340
+ return i18nString(CopyAll);
2341
+ };
2335
2342
  const refresh$1 = () => {
2336
2343
  return i18nString(Refresh$1);
2337
2344
  };
@@ -2679,6 +2686,13 @@ const getKeyBindings = () => {
2679
2686
  return [...getSearchHeaderKeyBindings(), ...getSearchResultKeyBindings()];
2680
2687
  };
2681
2688
 
2689
+ const menuEntrySeparator = {
2690
+ id: 'separator',
2691
+ label: '',
2692
+ flags: Separator,
2693
+ command: ''
2694
+ };
2695
+
2682
2696
  const getMenuEntriesInput = options => {
2683
2697
  const {
2684
2698
  inputName
@@ -2704,7 +2718,7 @@ const getMenuEntriesInput = options => {
2704
2718
  flags: None$1,
2705
2719
  command: 'Search.handleInputPaste',
2706
2720
  args: [inputName]
2707
- }, {
2721
+ }, menuEntrySeparator, {
2708
2722
  id: 'selectAll',
2709
2723
  label: selectAll(),
2710
2724
  flags: None$1,
@@ -2713,17 +2727,32 @@ const getMenuEntriesInput = options => {
2713
2727
  }];
2714
2728
  };
2715
2729
 
2716
- const getMenuEntriesList = () => {
2730
+ const getMenuEntriesList = (state, props) => {
2717
2731
  return [{
2732
+ id: 'replaceAll',
2733
+ label: replaceAll$1(),
2734
+ flags: None$1,
2735
+ command: 'Search.replaceAll'
2736
+ }, {
2718
2737
  id: 'dismiss',
2719
2738
  label: dismiss(),
2720
2739
  flags: None$1,
2721
2740
  command: 'Search.removeCurrent'
2741
+ }, {
2742
+ id: 'copy',
2743
+ label: copy(),
2744
+ flags: None$1,
2745
+ command: 'Search.copy'
2722
2746
  }, {
2723
2747
  id: 'copyPath',
2724
2748
  label: copyPath(),
2725
2749
  flags: None$1,
2726
2750
  command: 'Search.copyPath'
2751
+ }, {
2752
+ id: 'copyAll',
2753
+ label: copyAll(),
2754
+ flags: None$1,
2755
+ command: 'Search.copyAll'
2727
2756
  }];
2728
2757
  };
2729
2758
 
@@ -2916,7 +2945,8 @@ const handleUpdateFull = async (state, update) => {
2916
2945
  scrollBarHeight,
2917
2946
  searchInputErrorMessage: '',
2918
2947
  threads,
2919
- value
2948
+ value,
2949
+ collapsedPaths: []
2920
2950
  };
2921
2951
  };
2922
2952
 
@@ -3439,39 +3469,69 @@ const getNewText = (currentText, selectionStart, selectionEnd, insertedText) =>
3439
3469
  return merged;
3440
3470
  };
3441
3471
 
3442
- const isSelectionKey = (name, selections) => {
3443
- return name in selections;
3472
+ const getNewSelections = (selections, name, newValue) => {
3473
+ const old = selections[name];
3474
+ if (!old) {
3475
+ return selections;
3476
+ }
3477
+ const {
3478
+ start,
3479
+ end
3480
+ } = old;
3481
+ const newSelection = newValue.length;
3482
+ if (start === newSelection && end === newSelection) {
3483
+ return selections;
3484
+ }
3485
+ return {
3486
+ ...selections,
3487
+ [name]: {
3488
+ start: newSelection,
3489
+ end: newSelection
3490
+ }
3491
+ };
3444
3492
  };
3445
3493
  const updateValue = (state, name, newValue) => {
3494
+ const {
3495
+ selections
3496
+ } = state;
3497
+ const newSelections = getNewSelections(selections, name, newValue);
3446
3498
  switch (name) {
3447
3499
  case SearchValue:
3448
3500
  return {
3449
3501
  ...state,
3450
3502
  value: newValue,
3451
- inputSource: Script$1
3503
+ inputSource: Script$1,
3504
+ selections: newSelections
3452
3505
  };
3453
3506
  case ReplaceValue:
3454
3507
  return {
3455
3508
  ...state,
3456
3509
  replacement: newValue,
3457
- inputSource: Script$1
3510
+ inputSource: Script$1,
3511
+ selections: newSelections
3458
3512
  };
3459
3513
  case FilesToInclude:
3460
3514
  return {
3461
3515
  ...state,
3462
3516
  includeValue: newValue,
3463
- inputSource: Script$1
3517
+ inputSource: Script$1,
3518
+ selections: newSelections
3464
3519
  };
3465
3520
  case FilesToExclude:
3466
3521
  return {
3467
3522
  ...state,
3468
3523
  excludeValue: newValue,
3469
- inputSource: Script$1
3524
+ inputSource: Script$1,
3525
+ selections: newSelections
3470
3526
  };
3471
3527
  default:
3472
3528
  return state;
3473
3529
  }
3474
3530
  };
3531
+
3532
+ const isSelectionKey = (name, selections) => {
3533
+ return name in selections;
3534
+ };
3475
3535
  const handleInputPaste = async (state, name) => {
3476
3536
  const {
3477
3537
  selections
@@ -3582,10 +3642,26 @@ const handleInputFocus = (state, name) => {
3582
3642
  };
3583
3643
  };
3584
3644
 
3645
+ const handleInputSelectAll = async (state, name) => {
3646
+ // TODO
3647
+ return state;
3648
+ };
3649
+
3585
3650
  const handleInputSelectionChange = async (state, name, selectionStart, selectionEnd) => {
3586
3651
  const {
3587
3652
  selections
3588
3653
  } = state;
3654
+ const old = selections[name];
3655
+ if (!old) {
3656
+ return state;
3657
+ }
3658
+ const {
3659
+ start,
3660
+ end
3661
+ } = old;
3662
+ if (start === selectionStart && end === selectionEnd) {
3663
+ return state;
3664
+ }
3589
3665
  return {
3590
3666
  ...state,
3591
3667
  selections: {
@@ -4315,14 +4391,15 @@ const refresh = state => {
4315
4391
  };
4316
4392
 
4317
4393
  const removeCurrent = async state => {
4318
- // TODO
4319
- // 1. get focused index
4320
- // 2. if it is -1, do nothing
4321
- // 3. get search result at focused index
4322
- // 4. call removeIndex with state, searchResult, index
4323
- return {
4324
- ...state
4325
- };
4394
+ const {
4395
+ focusedIndex,
4396
+ listFocusedIndex
4397
+ } = state;
4398
+ const actualIndex = focusedIndex === -1 ? listFocusedIndex : focusedIndex;
4399
+ if (actualIndex === -1) {
4400
+ return state;
4401
+ }
4402
+ return removeIndex(state, actualIndex);
4326
4403
  };
4327
4404
 
4328
4405
  const getFocusSelector = focusKey => {
@@ -5422,6 +5499,13 @@ const replaceAllAndPrompt = async (workspacePath, items, replacement, matchCount
5422
5499
  return true;
5423
5500
  };
5424
5501
 
5502
+ const replaceAllInFile = async state => {
5503
+ // TODO replace occurrance for focused file
5504
+ return {
5505
+ ...state
5506
+ };
5507
+ };
5508
+
5425
5509
  const rerender = state => {
5426
5510
  return {
5427
5511
  ...state
@@ -5552,12 +5636,21 @@ const handleContextMenuKeyboard = async state => {
5552
5636
  return state;
5553
5637
  };
5554
5638
 
5555
- const handleContextMenuMouseAt = async (state, x, y) => {
5639
+ const handleContextMenuMouseAt = async (state, eventX, eventY) => {
5556
5640
  const {
5557
- uid
5641
+ uid,
5642
+ x,
5643
+ y,
5644
+ itemHeight,
5645
+ deltaY,
5646
+ flags,
5647
+ listItems
5558
5648
  } = state;
5649
+ const topHeight = getTopHeight(flags);
5650
+ const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight, listItems.length);
5559
5651
  await show2(uid, Search$1, x, y, {
5560
- menuId: Search$1
5652
+ menuId: Search$1,
5653
+ index
5561
5654
  });
5562
5655
  return state;
5563
5656
  };
@@ -5602,6 +5695,7 @@ const commandMap = {
5602
5695
  'TextSearch.focusPreviousPage': wrapCommand(focusPreviousPage),
5603
5696
  'TextSearch.focusRegex': wrapCommand(focusRegex),
5604
5697
  'TextSearch.focusRegexNext': wrapCommand(focusRegexNext),
5698
+ 'TextSearch.replaceAllInFile': wrapCommand(replaceAllInFile),
5605
5699
  'TextSearch.focusReplaceAll': wrapCommand(focusReplaceAll),
5606
5700
  'TextSearch.focusReplaceValue': wrapCommand(focusReplaceValue$1),
5607
5701
  'TextSearch.focusReplaceValueNext': wrapCommand(focusReplaceValueNext),
@@ -5627,6 +5721,7 @@ const commandMap = {
5627
5721
  'TextSearch.handleInputCut': wrapCommand(handleInputCut),
5628
5722
  'TextSearch.handleInputFocus': wrapCommand(handleInputFocus),
5629
5723
  'TextSearch.handleInputPaste': wrapCommand(handleInputPaste),
5724
+ 'TextSearch.handleInputSelectAll': wrapCommand(handleInputSelectAll),
5630
5725
  'TextSearch.handleInputSelectionChange': wrapCommand(handleInputSelectionChange),
5631
5726
  'TextSearch.handleListBlur': wrapCommand(handleListBlur),
5632
5727
  'TextSearch.handleListFocus': wrapCommand(handleListFocus),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "5.28.0",
3
+ "version": "5.30.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"