@lvce-editor/text-search-worker 5.25.0 → 5.26.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 +159 -16
- package/package.json +1 -1
|
@@ -1223,10 +1223,12 @@ const ClientY = 'event.clientY';
|
|
|
1223
1223
|
const DeltaMode = 'event.deltaMode';
|
|
1224
1224
|
const DeltaY = 'event.deltaY';
|
|
1225
1225
|
const TargetName = 'event.target.name';
|
|
1226
|
+
const TargetSelectionEnd = 'event.target.selectionEnd';
|
|
1227
|
+
const TargetSelectionStart = 'event.target.selectionStart';
|
|
1226
1228
|
const TargetValue = 'event.target.value';
|
|
1227
1229
|
|
|
1228
1230
|
const Search$1 = 18;
|
|
1229
|
-
const InputContextMenu
|
|
1231
|
+
const InputContextMenu = 91;
|
|
1230
1232
|
|
|
1231
1233
|
const None$1 = 0;
|
|
1232
1234
|
|
|
@@ -1848,7 +1850,25 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
1848
1850
|
limit: 20_000,
|
|
1849
1851
|
fileIconCache: {},
|
|
1850
1852
|
removeButtonWidth: 20,
|
|
1851
|
-
removeButtonRight: 0
|
|
1853
|
+
removeButtonRight: 0,
|
|
1854
|
+
selections: {
|
|
1855
|
+
SearchValue: {
|
|
1856
|
+
start: 0,
|
|
1857
|
+
end: 0
|
|
1858
|
+
},
|
|
1859
|
+
ReplaceValue: {
|
|
1860
|
+
start: 0,
|
|
1861
|
+
end: 0
|
|
1862
|
+
},
|
|
1863
|
+
FilesToExclude: {
|
|
1864
|
+
start: 0,
|
|
1865
|
+
end: 0
|
|
1866
|
+
},
|
|
1867
|
+
FilesToInclude: {
|
|
1868
|
+
start: 0,
|
|
1869
|
+
end: 0
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1852
1872
|
};
|
|
1853
1873
|
set(uid, state, state);
|
|
1854
1874
|
return state;
|
|
@@ -1861,6 +1881,7 @@ const RenderReplaceValue = 4;
|
|
|
1861
1881
|
const RenderIncludeValue = 5;
|
|
1862
1882
|
const RenderExcludeValue = 6;
|
|
1863
1883
|
const RenderFocusContext = 7;
|
|
1884
|
+
const RenderSelections = 8;
|
|
1864
1885
|
|
|
1865
1886
|
const diffType$5 = RenderExcludeValue;
|
|
1866
1887
|
const isEqual$6 = (oldState, newState) => {
|
|
@@ -2652,27 +2673,37 @@ const getKeyBindings = () => {
|
|
|
2652
2673
|
return [...getSearchHeaderKeyBindings(), ...getSearchResultKeyBindings()];
|
|
2653
2674
|
};
|
|
2654
2675
|
|
|
2655
|
-
const getMenuEntriesInput =
|
|
2676
|
+
const getMenuEntriesInput = options => {
|
|
2677
|
+
const {
|
|
2678
|
+
inputName
|
|
2679
|
+
} = options;
|
|
2680
|
+
if (!inputName) {
|
|
2681
|
+
return [];
|
|
2682
|
+
}
|
|
2656
2683
|
return [{
|
|
2657
2684
|
id: 'cut',
|
|
2658
2685
|
label: cut(),
|
|
2659
2686
|
flags: None$1,
|
|
2660
|
-
command: 'Search.
|
|
2687
|
+
command: 'Search.handleInputCut',
|
|
2688
|
+
args: [inputName]
|
|
2661
2689
|
}, {
|
|
2662
2690
|
id: 'copy',
|
|
2663
2691
|
label: copy(),
|
|
2664
2692
|
flags: None$1,
|
|
2665
|
-
command: 'Search.
|
|
2693
|
+
command: 'Search.handleInputCopy',
|
|
2694
|
+
args: [inputName]
|
|
2666
2695
|
}, {
|
|
2667
2696
|
id: 'paste',
|
|
2668
2697
|
label: paste(),
|
|
2669
2698
|
flags: None$1,
|
|
2670
|
-
command: 'Search.
|
|
2699
|
+
command: 'Search.handleInputPaste',
|
|
2700
|
+
args: [inputName]
|
|
2671
2701
|
}, {
|
|
2672
2702
|
id: 'selectAll',
|
|
2673
2703
|
label: selectAll(),
|
|
2674
2704
|
flags: None$1,
|
|
2675
|
-
command: 'Search.
|
|
2705
|
+
command: 'Search.handleInputSelectAll',
|
|
2706
|
+
args: [inputName]
|
|
2676
2707
|
}];
|
|
2677
2708
|
};
|
|
2678
2709
|
|
|
@@ -2694,13 +2725,12 @@ const getMenuEntries = (state, props) => {
|
|
|
2694
2725
|
if (props.menuId === Search$1) {
|
|
2695
2726
|
return getMenuEntriesList();
|
|
2696
2727
|
}
|
|
2697
|
-
if (props.menuId === InputContextMenu
|
|
2698
|
-
return getMenuEntriesInput();
|
|
2728
|
+
if (props.menuId === InputContextMenu) {
|
|
2729
|
+
return getMenuEntriesInput(props);
|
|
2699
2730
|
}
|
|
2700
2731
|
return [];
|
|
2701
2732
|
};
|
|
2702
2733
|
|
|
2703
|
-
const InputContextMenu = 91;
|
|
2704
2734
|
const getMenuEntryIds = () => {
|
|
2705
2735
|
return [Search$1, InputContextMenu];
|
|
2706
2736
|
};
|
|
@@ -3363,16 +3393,95 @@ const show2 = async (uid, menuId, x, y, args) => {
|
|
|
3363
3393
|
await showContextMenu2(uid, menuId, x, y, args);
|
|
3364
3394
|
};
|
|
3365
3395
|
|
|
3366
|
-
const handleInputContextMenu = async (state, button, x, y) => {
|
|
3396
|
+
const handleInputContextMenu = async (state, name, button, x, y) => {
|
|
3367
3397
|
const {
|
|
3368
3398
|
uid
|
|
3369
3399
|
} = state;
|
|
3370
|
-
await show2(uid, InputContextMenu
|
|
3371
|
-
menuId: InputContextMenu
|
|
3400
|
+
await show2(uid, InputContextMenu, x, y, {
|
|
3401
|
+
menuId: InputContextMenu,
|
|
3402
|
+
inputName: name
|
|
3372
3403
|
});
|
|
3373
3404
|
return state;
|
|
3374
3405
|
};
|
|
3375
3406
|
|
|
3407
|
+
const handleInputCopy = async (state, name) => {
|
|
3408
|
+
// TODO write selected text to clipboard
|
|
3409
|
+
return state;
|
|
3410
|
+
};
|
|
3411
|
+
|
|
3412
|
+
const getNewText = (currentText, selectionStart, selectionEnd, insertedText) => {
|
|
3413
|
+
const pre = currentText.slice(0, selectionStart);
|
|
3414
|
+
const post = currentText.slice(selectionEnd);
|
|
3415
|
+
const merged = pre + insertedText + post;
|
|
3416
|
+
return merged;
|
|
3417
|
+
};
|
|
3418
|
+
|
|
3419
|
+
const readText = async () => {
|
|
3420
|
+
return await invoke$1('ClipBoard.readText');
|
|
3421
|
+
};
|
|
3422
|
+
|
|
3423
|
+
const isSelectionKey = (name, selections) => {
|
|
3424
|
+
return name in selections;
|
|
3425
|
+
};
|
|
3426
|
+
const getCurrentValue = (state, name) => {
|
|
3427
|
+
switch (name) {
|
|
3428
|
+
case SearchValue:
|
|
3429
|
+
return state.value;
|
|
3430
|
+
case FilesToExclude:
|
|
3431
|
+
return state.excludeValue;
|
|
3432
|
+
case FilesToInclude:
|
|
3433
|
+
return state.includeValue;
|
|
3434
|
+
case ReplaceValue:
|
|
3435
|
+
return state.replacement;
|
|
3436
|
+
default:
|
|
3437
|
+
return '';
|
|
3438
|
+
}
|
|
3439
|
+
};
|
|
3440
|
+
const handleInputPaste = async (state, name) => {
|
|
3441
|
+
const {
|
|
3442
|
+
selections
|
|
3443
|
+
} = state;
|
|
3444
|
+
if (!isSelectionKey(name, selections)) {
|
|
3445
|
+
return state;
|
|
3446
|
+
}
|
|
3447
|
+
const selection = selections[name];
|
|
3448
|
+
const {
|
|
3449
|
+
start,
|
|
3450
|
+
end
|
|
3451
|
+
} = selection;
|
|
3452
|
+
const currentText = getCurrentValue(state, name);
|
|
3453
|
+
const insertedText = await readText();
|
|
3454
|
+
const newText = getNewText(currentText, start, end, insertedText);
|
|
3455
|
+
if (newText) {
|
|
3456
|
+
return state;
|
|
3457
|
+
}
|
|
3458
|
+
// TODO paste text
|
|
3459
|
+
return state;
|
|
3460
|
+
};
|
|
3461
|
+
|
|
3462
|
+
const handleInputCut = async (state, name) => {
|
|
3463
|
+
const {
|
|
3464
|
+
selections
|
|
3465
|
+
} = state;
|
|
3466
|
+
if (!isSelectionKey(name, selections)) {
|
|
3467
|
+
return state;
|
|
3468
|
+
}
|
|
3469
|
+
const selection = selections[name];
|
|
3470
|
+
const {
|
|
3471
|
+
start,
|
|
3472
|
+
end
|
|
3473
|
+
} = selection;
|
|
3474
|
+
const currentText = getCurrentValue(state, name);
|
|
3475
|
+
const insertedText = '';
|
|
3476
|
+
// TODO get cut text
|
|
3477
|
+
const newText = getNewText(currentText, start, end, insertedText);
|
|
3478
|
+
if (newText) {
|
|
3479
|
+
return state;
|
|
3480
|
+
}
|
|
3481
|
+
// TODO cut text
|
|
3482
|
+
return state;
|
|
3483
|
+
};
|
|
3484
|
+
|
|
3376
3485
|
const getSearchFocusKey = key => {
|
|
3377
3486
|
switch (key) {
|
|
3378
3487
|
case SearchValue:
|
|
@@ -3416,6 +3525,22 @@ const handleInputFocus = (state, name) => {
|
|
|
3416
3525
|
};
|
|
3417
3526
|
};
|
|
3418
3527
|
|
|
3528
|
+
const handleInputSelectionChange = async (state, name, selectionStart, selectionEnd) => {
|
|
3529
|
+
const {
|
|
3530
|
+
selections
|
|
3531
|
+
} = state;
|
|
3532
|
+
return {
|
|
3533
|
+
...state,
|
|
3534
|
+
selections: {
|
|
3535
|
+
...selections,
|
|
3536
|
+
[name]: {
|
|
3537
|
+
selectionStart,
|
|
3538
|
+
selectionEnd
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
};
|
|
3542
|
+
};
|
|
3543
|
+
|
|
3419
3544
|
const handleListBlur = state => {
|
|
3420
3545
|
return {
|
|
3421
3546
|
...state,
|
|
@@ -4341,6 +4466,7 @@ const HandleInputFocus = 17;
|
|
|
4341
4466
|
const HandleInputBlur = 18;
|
|
4342
4467
|
const HandleListPointerDown = 19;
|
|
4343
4468
|
const HandleInputContextMenu = 20;
|
|
4469
|
+
const HandleInputSelectionChange = 21;
|
|
4344
4470
|
|
|
4345
4471
|
const getSearchDetailsToggleVirtualDom = () => {
|
|
4346
4472
|
return [{
|
|
@@ -4521,6 +4647,7 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
|
|
|
4521
4647
|
onFocus: HandleInputFocus,
|
|
4522
4648
|
onBlur: HandleInputBlur,
|
|
4523
4649
|
onContextMenu: HandleInputContextMenu,
|
|
4650
|
+
onSelectionChange: HandleInputSelectionChange,
|
|
4524
4651
|
childCount: 0
|
|
4525
4652
|
}, {
|
|
4526
4653
|
type: Div,
|
|
@@ -4958,6 +5085,13 @@ const renderItems = (oldState, newState) => {
|
|
|
4958
5085
|
return [SetDom2, newState.uid, dom];
|
|
4959
5086
|
};
|
|
4960
5087
|
|
|
5088
|
+
const renderSelections = (oldState, newState) => {
|
|
5089
|
+
// const { selections, uid } = newState
|
|
5090
|
+
|
|
5091
|
+
// TODO
|
|
5092
|
+
return [];
|
|
5093
|
+
};
|
|
5094
|
+
|
|
4961
5095
|
const renderValue = (oldState, newState) => {
|
|
4962
5096
|
return [SetValueByName, SearchValue, newState.value];
|
|
4963
5097
|
};
|
|
@@ -4987,6 +5121,8 @@ const getRenderer = diffType => {
|
|
|
4987
5121
|
return renderItems;
|
|
4988
5122
|
case RenderFocusContext:
|
|
4989
5123
|
return renderFocusContext;
|
|
5124
|
+
case RenderSelections:
|
|
5125
|
+
return renderSelections;
|
|
4990
5126
|
default:
|
|
4991
5127
|
throw new Error('unknown renderer');
|
|
4992
5128
|
}
|
|
@@ -5130,8 +5266,11 @@ const renderEventListeners = () => {
|
|
|
5130
5266
|
preventDefault: true
|
|
5131
5267
|
}, {
|
|
5132
5268
|
name: HandleInputContextMenu,
|
|
5133
|
-
params: ['handleInputContextMenu', Button$1, ClientX, ClientY],
|
|
5269
|
+
params: ['handleInputContextMenu', TargetName, Button$1, ClientX, ClientY],
|
|
5134
5270
|
preventDefault: true
|
|
5271
|
+
}, {
|
|
5272
|
+
name: HandleInputSelectionChange,
|
|
5273
|
+
params: ['handleInputSelectionChange', TargetName, TargetSelectionStart, TargetSelectionEnd]
|
|
5135
5274
|
}, {
|
|
5136
5275
|
name: HandleHeaderContextMenu,
|
|
5137
5276
|
params: ['handleHeaderContextMenu'],
|
|
@@ -5403,7 +5542,6 @@ const commandMap = {
|
|
|
5403
5542
|
'TextSearch.focusPreserveCasePrevious': wrapCommand(focusPreserveCasePrevious),
|
|
5404
5543
|
'TextSearch.focusPrevious': wrapCommand(focusPrevious),
|
|
5405
5544
|
'TextSearch.focusPreviousInput': wrapCommand(focusPreviousInput),
|
|
5406
|
-
'TextSearch.handleInputContextMenu': wrapCommand(handleInputContextMenu),
|
|
5407
5545
|
'TextSearch.focusPreviousPage': wrapCommand(focusPreviousPage),
|
|
5408
5546
|
'TextSearch.focusRegex': wrapCommand(focusRegex),
|
|
5409
5547
|
'TextSearch.focusRegexNext': wrapCommand(focusRegexNext),
|
|
@@ -5413,6 +5551,7 @@ const commandMap = {
|
|
|
5413
5551
|
'TextSearch.focusReplaceValuePrevious': wrapCommand(focusReplaceValuePrevious),
|
|
5414
5552
|
'TextSearch.focusSearchValue': wrapCommand(focusSearchValue$1),
|
|
5415
5553
|
'TextSearch.focusSearchValueNext': wrapCommand(focusSearchValueNext),
|
|
5554
|
+
'TextSearch.getMenuEntries': wrapGetter(getMenuEntries),
|
|
5416
5555
|
'TextSearch.handleClickAt': wrapCommand(handleClickAt),
|
|
5417
5556
|
'TextSearch.handleContextMenu': wrapCommand(handleContextMenu),
|
|
5418
5557
|
'TextSearch.handleExcludeInput': wrapCommand(handleExcludeInput),
|
|
@@ -5426,7 +5565,12 @@ const commandMap = {
|
|
|
5426
5565
|
'TextSearch.handleInput': wrapCommand(handleInput),
|
|
5427
5566
|
'TextSearch.handleInput2': wrapCommand(handleInput2),
|
|
5428
5567
|
'TextSearch.handleInputBlur': wrapCommand(handleInputBlur),
|
|
5568
|
+
'TextSearch.handleInputContextMenu': wrapCommand(handleInputContextMenu),
|
|
5569
|
+
'TextSearch.handleInputCopy': wrapCommand(handleInputCopy),
|
|
5570
|
+
'TextSearch.handleInputCut': wrapCommand(handleInputCut),
|
|
5429
5571
|
'TextSearch.handleInputFocus': wrapCommand(handleInputFocus),
|
|
5572
|
+
'TextSearch.handleInputPaste': wrapCommand(handleInputPaste),
|
|
5573
|
+
'TextSearch.handleInputSelectionChange': wrapCommand(handleInputSelectionChange),
|
|
5430
5574
|
'TextSearch.handleListBlur': wrapCommand(handleListBlur),
|
|
5431
5575
|
'TextSearch.handleListFocus': wrapCommand(handleListFocus),
|
|
5432
5576
|
'TextSearch.handleListPointerDown': wrapCommand(handleListPointerDown),
|
|
@@ -5456,7 +5600,6 @@ const commandMap = {
|
|
|
5456
5600
|
'TextSearch.toggleUseIgnoreFiles': wrapCommand(toggleUseIgnoreFiles),
|
|
5457
5601
|
'TextSearch.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
|
|
5458
5602
|
'TextSearch.viewAsTree': wrapCommand(viewAsTree),
|
|
5459
|
-
'TextSearch.getMenuEntries': wrapGetter(getMenuEntries),
|
|
5460
5603
|
// not wrapped
|
|
5461
5604
|
'TextSearch.initialize': initialize,
|
|
5462
5605
|
'TextSearch.create': create,
|