@lvce-editor/text-search-worker 5.27.0 → 5.29.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.
- package/dist/textSearchWorkerMain.js +116 -28
- package/package.json +1 -1
|
@@ -1227,9 +1227,12 @@ const TargetSelectionEnd = 'event.target.selectionEnd';
|
|
|
1227
1227
|
const TargetSelectionStart = 'event.target.selectionStart';
|
|
1228
1228
|
const TargetValue = 'event.target.value';
|
|
1229
1229
|
|
|
1230
|
+
const Script$1 = 2;
|
|
1231
|
+
|
|
1230
1232
|
const Search$1 = 18;
|
|
1231
1233
|
const InputContextMenu = 91;
|
|
1232
1234
|
|
|
1235
|
+
const Separator = 1;
|
|
1233
1236
|
const None$1 = 0;
|
|
1234
1237
|
|
|
1235
1238
|
const LeftClick = 0;
|
|
@@ -1310,6 +1313,10 @@ const {
|
|
|
1310
1313
|
invokeAndTransfer,
|
|
1311
1314
|
set: set$1} = create$3(RendererWorker);
|
|
1312
1315
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1316
|
+
number(uid);
|
|
1317
|
+
number(menuId);
|
|
1318
|
+
number(x);
|
|
1319
|
+
number(y);
|
|
1313
1320
|
// @ts-ignore
|
|
1314
1321
|
await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1315
1322
|
};
|
|
@@ -1750,12 +1757,14 @@ const copy$1 = async state => {
|
|
|
1750
1757
|
const copyPath$1 = async state => {
|
|
1751
1758
|
const {
|
|
1752
1759
|
items,
|
|
1753
|
-
focusedIndex
|
|
1760
|
+
focusedIndex,
|
|
1761
|
+
listFocusedIndex
|
|
1754
1762
|
} = state;
|
|
1755
|
-
|
|
1763
|
+
const actualIndex = focusedIndex === -1 ? listFocusedIndex : focusedIndex;
|
|
1764
|
+
if (actualIndex === -1) {
|
|
1756
1765
|
return state;
|
|
1757
1766
|
}
|
|
1758
|
-
const item = items[
|
|
1767
|
+
const item = items[actualIndex];
|
|
1759
1768
|
await writeClipBoardText(item.text);
|
|
1760
1769
|
return state;
|
|
1761
1770
|
};
|
|
@@ -2177,6 +2186,7 @@ const ConfirmReplaceManyOccurrencesInOneFileNoValue = 'Replace {PH1} occurrences
|
|
|
2177
2186
|
const ConfirmReplaceOneOccurrenceInOneFile = "Replace 1 occurrence across 1 file with '{PH1}'";
|
|
2178
2187
|
const ConfirmReplaceOneOccurrenceInOneFileNoValue = 'Replace 1 occurrence across 1 file';
|
|
2179
2188
|
const CopyPath = 'Copy Path';
|
|
2189
|
+
const CopyAll = 'Copy All';
|
|
2180
2190
|
const Dismiss = 'Dismiss';
|
|
2181
2191
|
const Cut = 'Cut';
|
|
2182
2192
|
const Copy = 'Copy';
|
|
@@ -2326,6 +2336,9 @@ const theResultSetOnlyContainsASubSetOfMatches = () => {
|
|
|
2326
2336
|
const copyPath = () => {
|
|
2327
2337
|
return i18nString(CopyPath);
|
|
2328
2338
|
};
|
|
2339
|
+
const copyAll = () => {
|
|
2340
|
+
return i18nString(CopyAll);
|
|
2341
|
+
};
|
|
2329
2342
|
const refresh$1 = () => {
|
|
2330
2343
|
return i18nString(Refresh$1);
|
|
2331
2344
|
};
|
|
@@ -2673,6 +2686,13 @@ const getKeyBindings = () => {
|
|
|
2673
2686
|
return [...getSearchHeaderKeyBindings(), ...getSearchResultKeyBindings()];
|
|
2674
2687
|
};
|
|
2675
2688
|
|
|
2689
|
+
const menuEntrySeparator = {
|
|
2690
|
+
id: 'separator',
|
|
2691
|
+
label: '',
|
|
2692
|
+
flags: Separator,
|
|
2693
|
+
command: ''
|
|
2694
|
+
};
|
|
2695
|
+
|
|
2676
2696
|
const getMenuEntriesInput = options => {
|
|
2677
2697
|
const {
|
|
2678
2698
|
inputName
|
|
@@ -2698,7 +2718,7 @@ const getMenuEntriesInput = options => {
|
|
|
2698
2718
|
flags: None$1,
|
|
2699
2719
|
command: 'Search.handleInputPaste',
|
|
2700
2720
|
args: [inputName]
|
|
2701
|
-
}, {
|
|
2721
|
+
}, menuEntrySeparator, {
|
|
2702
2722
|
id: 'selectAll',
|
|
2703
2723
|
label: selectAll(),
|
|
2704
2724
|
flags: None$1,
|
|
@@ -2707,17 +2727,32 @@ const getMenuEntriesInput = options => {
|
|
|
2707
2727
|
}];
|
|
2708
2728
|
};
|
|
2709
2729
|
|
|
2710
|
-
const getMenuEntriesList = () => {
|
|
2730
|
+
const getMenuEntriesList = (state, props) => {
|
|
2711
2731
|
return [{
|
|
2732
|
+
id: 'replaceAll',
|
|
2733
|
+
label: replaceAll$1(),
|
|
2734
|
+
flags: None$1,
|
|
2735
|
+
command: 'Search.replaceAll'
|
|
2736
|
+
}, {
|
|
2712
2737
|
id: 'dismiss',
|
|
2713
2738
|
label: dismiss(),
|
|
2714
2739
|
flags: None$1,
|
|
2715
2740
|
command: 'Search.removeCurrent'
|
|
2741
|
+
}, {
|
|
2742
|
+
id: 'copy',
|
|
2743
|
+
label: copy(),
|
|
2744
|
+
flags: None$1,
|
|
2745
|
+
command: 'Search.copy'
|
|
2716
2746
|
}, {
|
|
2717
2747
|
id: 'copyPath',
|
|
2718
2748
|
label: copyPath(),
|
|
2719
2749
|
flags: None$1,
|
|
2720
2750
|
command: 'Search.copyPath'
|
|
2751
|
+
}, {
|
|
2752
|
+
id: 'copyAll',
|
|
2753
|
+
label: copyAll(),
|
|
2754
|
+
flags: None$1,
|
|
2755
|
+
command: 'Search.copyAll'
|
|
2721
2756
|
}];
|
|
2722
2757
|
};
|
|
2723
2758
|
|
|
@@ -2910,7 +2945,8 @@ const handleUpdateFull = async (state, update) => {
|
|
|
2910
2945
|
scrollBarHeight,
|
|
2911
2946
|
searchInputErrorMessage: '',
|
|
2912
2947
|
threads,
|
|
2913
|
-
value
|
|
2948
|
+
value,
|
|
2949
|
+
collapsedPaths: []
|
|
2914
2950
|
};
|
|
2915
2951
|
};
|
|
2916
2952
|
|
|
@@ -3411,16 +3447,6 @@ const readText = async () => {
|
|
|
3411
3447
|
return await invoke$1('ClipBoard.readText');
|
|
3412
3448
|
};
|
|
3413
3449
|
|
|
3414
|
-
const getNewText = (currentText, selectionStart, selectionEnd, insertedText) => {
|
|
3415
|
-
const pre = currentText.slice(0, selectionStart);
|
|
3416
|
-
const post = currentText.slice(selectionEnd);
|
|
3417
|
-
const merged = pre + insertedText + post;
|
|
3418
|
-
return merged;
|
|
3419
|
-
};
|
|
3420
|
-
|
|
3421
|
-
const isSelectionKey = (name, selections) => {
|
|
3422
|
-
return name in selections;
|
|
3423
|
-
};
|
|
3424
3450
|
const getCurrentValue = (state, name) => {
|
|
3425
3451
|
switch (name) {
|
|
3426
3452
|
case SearchValue:
|
|
@@ -3435,32 +3461,77 @@ const getCurrentValue = (state, name) => {
|
|
|
3435
3461
|
return '';
|
|
3436
3462
|
}
|
|
3437
3463
|
};
|
|
3464
|
+
|
|
3465
|
+
const getNewText = (currentText, selectionStart, selectionEnd, insertedText) => {
|
|
3466
|
+
const pre = currentText.slice(0, selectionStart);
|
|
3467
|
+
const post = currentText.slice(selectionEnd);
|
|
3468
|
+
const merged = pre + insertedText + post;
|
|
3469
|
+
return merged;
|
|
3470
|
+
};
|
|
3471
|
+
|
|
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
|
+
};
|
|
3492
|
+
};
|
|
3438
3493
|
const updateValue = (state, name, newValue) => {
|
|
3494
|
+
const {
|
|
3495
|
+
selections
|
|
3496
|
+
} = state;
|
|
3497
|
+
const newSelections = getNewSelections(selections, name, newValue);
|
|
3439
3498
|
switch (name) {
|
|
3440
3499
|
case SearchValue:
|
|
3441
3500
|
return {
|
|
3442
3501
|
...state,
|
|
3443
|
-
value: newValue
|
|
3502
|
+
value: newValue,
|
|
3503
|
+
inputSource: Script$1,
|
|
3504
|
+
selections: newSelections
|
|
3444
3505
|
};
|
|
3445
3506
|
case ReplaceValue:
|
|
3446
3507
|
return {
|
|
3447
3508
|
...state,
|
|
3448
|
-
replacement: newValue
|
|
3509
|
+
replacement: newValue,
|
|
3510
|
+
inputSource: Script$1,
|
|
3511
|
+
selections: newSelections
|
|
3449
3512
|
};
|
|
3450
3513
|
case FilesToInclude:
|
|
3451
3514
|
return {
|
|
3452
3515
|
...state,
|
|
3453
|
-
includeValue: newValue
|
|
3516
|
+
includeValue: newValue,
|
|
3517
|
+
inputSource: Script$1,
|
|
3518
|
+
selections: newSelections
|
|
3454
3519
|
};
|
|
3455
3520
|
case FilesToExclude:
|
|
3456
3521
|
return {
|
|
3457
3522
|
...state,
|
|
3458
|
-
excludeValue: newValue
|
|
3523
|
+
excludeValue: newValue,
|
|
3524
|
+
inputSource: Script$1,
|
|
3525
|
+
selections: newSelections
|
|
3459
3526
|
};
|
|
3460
3527
|
default:
|
|
3461
3528
|
return state;
|
|
3462
3529
|
}
|
|
3463
3530
|
};
|
|
3531
|
+
|
|
3532
|
+
const isSelectionKey = (name, selections) => {
|
|
3533
|
+
return name in selections;
|
|
3534
|
+
};
|
|
3464
3535
|
const handleInputPaste = async (state, name) => {
|
|
3465
3536
|
const {
|
|
3466
3537
|
selections
|
|
@@ -3476,9 +3547,6 @@ const handleInputPaste = async (state, name) => {
|
|
|
3476
3547
|
const currentText = getCurrentValue(state, name);
|
|
3477
3548
|
const insertedText = await readText();
|
|
3478
3549
|
const newText = getNewText(currentText, start, end, insertedText);
|
|
3479
|
-
if (newText === currentText) {
|
|
3480
|
-
return state;
|
|
3481
|
-
}
|
|
3482
3550
|
return updateValue(state, name, newText);
|
|
3483
3551
|
};
|
|
3484
3552
|
|
|
@@ -3578,13 +3646,24 @@ const handleInputSelectionChange = async (state, name, selectionStart, selection
|
|
|
3578
3646
|
const {
|
|
3579
3647
|
selections
|
|
3580
3648
|
} = state;
|
|
3649
|
+
const old = selections[name];
|
|
3650
|
+
if (!old) {
|
|
3651
|
+
return state;
|
|
3652
|
+
}
|
|
3653
|
+
const {
|
|
3654
|
+
start,
|
|
3655
|
+
end
|
|
3656
|
+
} = old;
|
|
3657
|
+
if (start === selectionStart && end === selectionEnd) {
|
|
3658
|
+
return state;
|
|
3659
|
+
}
|
|
3581
3660
|
return {
|
|
3582
3661
|
...state,
|
|
3583
3662
|
selections: {
|
|
3584
3663
|
...selections,
|
|
3585
3664
|
[name]: {
|
|
3586
|
-
selectionStart,
|
|
3587
|
-
selectionEnd
|
|
3665
|
+
start: selectionStart,
|
|
3666
|
+
end: selectionEnd
|
|
3588
3667
|
}
|
|
3589
3668
|
}
|
|
3590
3669
|
};
|
|
@@ -5544,12 +5623,21 @@ const handleContextMenuKeyboard = async state => {
|
|
|
5544
5623
|
return state;
|
|
5545
5624
|
};
|
|
5546
5625
|
|
|
5547
|
-
const handleContextMenuMouseAt = async (state,
|
|
5626
|
+
const handleContextMenuMouseAt = async (state, eventX, eventY) => {
|
|
5548
5627
|
const {
|
|
5549
|
-
uid
|
|
5628
|
+
uid,
|
|
5629
|
+
x,
|
|
5630
|
+
y,
|
|
5631
|
+
itemHeight,
|
|
5632
|
+
deltaY,
|
|
5633
|
+
flags,
|
|
5634
|
+
listItems
|
|
5550
5635
|
} = state;
|
|
5636
|
+
const topHeight = getTopHeight(flags);
|
|
5637
|
+
const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight, listItems.length);
|
|
5551
5638
|
await show2(uid, Search$1, x, y, {
|
|
5552
|
-
menuId: Search$1
|
|
5639
|
+
menuId: Search$1,
|
|
5640
|
+
index
|
|
5553
5641
|
});
|
|
5554
5642
|
return state;
|
|
5555
5643
|
};
|