@lvce-editor/text-search-worker 5.26.0 → 5.27.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 +66 -17
- package/package.json +1 -1
|
@@ -3404,9 +3404,11 @@ const handleInputContextMenu = async (state, name, button, x, y) => {
|
|
|
3404
3404
|
return state;
|
|
3405
3405
|
};
|
|
3406
3406
|
|
|
3407
|
-
const
|
|
3408
|
-
|
|
3409
|
-
|
|
3407
|
+
const writeText = async text => {
|
|
3408
|
+
await writeClipBoardText(text);
|
|
3409
|
+
};
|
|
3410
|
+
const readText = async () => {
|
|
3411
|
+
return await invoke$1('ClipBoard.readText');
|
|
3410
3412
|
};
|
|
3411
3413
|
|
|
3412
3414
|
const getNewText = (currentText, selectionStart, selectionEnd, insertedText) => {
|
|
@@ -3416,10 +3418,6 @@ const getNewText = (currentText, selectionStart, selectionEnd, insertedText) =>
|
|
|
3416
3418
|
return merged;
|
|
3417
3419
|
};
|
|
3418
3420
|
|
|
3419
|
-
const readText = async () => {
|
|
3420
|
-
return await invoke$1('ClipBoard.readText');
|
|
3421
|
-
};
|
|
3422
|
-
|
|
3423
3421
|
const isSelectionKey = (name, selections) => {
|
|
3424
3422
|
return name in selections;
|
|
3425
3423
|
};
|
|
@@ -3437,6 +3435,32 @@ const getCurrentValue = (state, name) => {
|
|
|
3437
3435
|
return '';
|
|
3438
3436
|
}
|
|
3439
3437
|
};
|
|
3438
|
+
const updateValue = (state, name, newValue) => {
|
|
3439
|
+
switch (name) {
|
|
3440
|
+
case SearchValue:
|
|
3441
|
+
return {
|
|
3442
|
+
...state,
|
|
3443
|
+
value: newValue
|
|
3444
|
+
};
|
|
3445
|
+
case ReplaceValue:
|
|
3446
|
+
return {
|
|
3447
|
+
...state,
|
|
3448
|
+
replacement: newValue
|
|
3449
|
+
};
|
|
3450
|
+
case FilesToInclude:
|
|
3451
|
+
return {
|
|
3452
|
+
...state,
|
|
3453
|
+
includeValue: newValue
|
|
3454
|
+
};
|
|
3455
|
+
case FilesToExclude:
|
|
3456
|
+
return {
|
|
3457
|
+
...state,
|
|
3458
|
+
excludeValue: newValue
|
|
3459
|
+
};
|
|
3460
|
+
default:
|
|
3461
|
+
return state;
|
|
3462
|
+
}
|
|
3463
|
+
};
|
|
3440
3464
|
const handleInputPaste = async (state, name) => {
|
|
3441
3465
|
const {
|
|
3442
3466
|
selections
|
|
@@ -3452,14 +3476,13 @@ const handleInputPaste = async (state, name) => {
|
|
|
3452
3476
|
const currentText = getCurrentValue(state, name);
|
|
3453
3477
|
const insertedText = await readText();
|
|
3454
3478
|
const newText = getNewText(currentText, start, end, insertedText);
|
|
3455
|
-
if (newText) {
|
|
3479
|
+
if (newText === currentText) {
|
|
3456
3480
|
return state;
|
|
3457
3481
|
}
|
|
3458
|
-
|
|
3459
|
-
return state;
|
|
3482
|
+
return updateValue(state, name, newText);
|
|
3460
3483
|
};
|
|
3461
3484
|
|
|
3462
|
-
const
|
|
3485
|
+
const handleInputCopy = async (state, name) => {
|
|
3463
3486
|
const {
|
|
3464
3487
|
selections
|
|
3465
3488
|
} = state;
|
|
@@ -3472,14 +3495,40 @@ const handleInputCut = async (state, name) => {
|
|
|
3472
3495
|
end
|
|
3473
3496
|
} = selection;
|
|
3474
3497
|
const currentText = getCurrentValue(state, name);
|
|
3475
|
-
const
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3498
|
+
const toCopy = currentText.slice(start, end);
|
|
3499
|
+
await writeText(toCopy);
|
|
3500
|
+
return state;
|
|
3501
|
+
};
|
|
3502
|
+
|
|
3503
|
+
const getNewTextCut = (currentText, selectionStart, selectionEnd) => {
|
|
3504
|
+
const pre = currentText.slice(0, selectionStart);
|
|
3505
|
+
const middle = currentText.slice(selectionStart, selectionEnd);
|
|
3506
|
+
const post = currentText.slice(selectionEnd);
|
|
3507
|
+
return {
|
|
3508
|
+
newText: pre + post,
|
|
3509
|
+
cutText: middle
|
|
3510
|
+
};
|
|
3511
|
+
};
|
|
3512
|
+
|
|
3513
|
+
const handleInputCut = async (state, name) => {
|
|
3514
|
+
const {
|
|
3515
|
+
selections
|
|
3516
|
+
} = state;
|
|
3517
|
+
if (!isSelectionKey(name, selections)) {
|
|
3479
3518
|
return state;
|
|
3480
3519
|
}
|
|
3481
|
-
|
|
3482
|
-
|
|
3520
|
+
const selection = selections[name];
|
|
3521
|
+
const {
|
|
3522
|
+
start,
|
|
3523
|
+
end
|
|
3524
|
+
} = selection;
|
|
3525
|
+
const currentText = getCurrentValue(state, name);
|
|
3526
|
+
const {
|
|
3527
|
+
newText,
|
|
3528
|
+
cutText
|
|
3529
|
+
} = getNewTextCut(currentText, start, end);
|
|
3530
|
+
await writeText(cutText);
|
|
3531
|
+
return updateValue(state, name, newText);
|
|
3483
3532
|
};
|
|
3484
3533
|
|
|
3485
3534
|
const getSearchFocusKey = key => {
|