@lvce-editor/find-widget-worker 3.24.0 → 3.24.1
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/findWidgetWorkerMain.js +41 -38
- package/package.json +1 -1
|
@@ -2548,20 +2548,6 @@ const handleSettingsChanged = async state => {
|
|
|
2548
2548
|
};
|
|
2549
2549
|
};
|
|
2550
2550
|
|
|
2551
|
-
const regexFlags = 'gi';
|
|
2552
|
-
const getSearchRegex = searchString => {
|
|
2553
|
-
const escaped = escapeRegExpCharacters(searchString);
|
|
2554
|
-
return new RegExp(escaped, regexFlags);
|
|
2555
|
-
};
|
|
2556
|
-
|
|
2557
|
-
const findMatchesCaseInsensitive = (lines, searchString) => {
|
|
2558
|
-
if (searchString.length === 0) {
|
|
2559
|
-
return new Uint32Array([]);
|
|
2560
|
-
}
|
|
2561
|
-
const regex = getSearchRegex(searchString);
|
|
2562
|
-
return findRegexMatches(lines, regex);
|
|
2563
|
-
};
|
|
2564
|
-
|
|
2565
2551
|
const getFindWidgetPosition = (editorX, editorY, editorWidth, width = 300) => {
|
|
2566
2552
|
const height = 30;
|
|
2567
2553
|
const paddingTop = 10;
|
|
@@ -2593,24 +2579,17 @@ const getSelections = async editorUid => {
|
|
|
2593
2579
|
return selections;
|
|
2594
2580
|
};
|
|
2595
2581
|
|
|
2596
|
-
const getSavedValue = savedState => {
|
|
2597
|
-
if (savedState && savedState.value) {
|
|
2598
|
-
return savedState.value;
|
|
2599
|
-
}
|
|
2600
|
-
return '';
|
|
2601
|
-
};
|
|
2602
|
-
const getSavedReplacement = savedState => {
|
|
2603
|
-
if (savedState && savedState.replacement) {
|
|
2604
|
-
return savedState.replacement;
|
|
2605
|
-
}
|
|
2606
|
-
return '';
|
|
2607
|
-
};
|
|
2608
2582
|
const restoreState = savedState => {
|
|
2609
|
-
const value = getSavedValue(savedState);
|
|
2610
|
-
const replacement = getSavedReplacement(savedState);
|
|
2611
2583
|
return {
|
|
2612
|
-
|
|
2613
|
-
|
|
2584
|
+
hasValue: typeof savedState?.value === 'string',
|
|
2585
|
+
matchCase: savedState?.matchCase === true,
|
|
2586
|
+
matchWholeWord: savedState?.matchWholeWord === true,
|
|
2587
|
+
preserveCase: savedState?.preserveCase === true,
|
|
2588
|
+
replaceExpanded: savedState?.replaceExpanded === true,
|
|
2589
|
+
replacement: typeof savedState?.replacement === 'string' ? savedState.replacement : '',
|
|
2590
|
+
useRegularExpression: savedState?.useRegularExpression === true,
|
|
2591
|
+
value: typeof savedState?.value === 'string' ? savedState.value : '',
|
|
2592
|
+
width: typeof savedState?.width === 'number' ? savedState.width : undefined
|
|
2614
2593
|
};
|
|
2615
2594
|
};
|
|
2616
2595
|
|
|
@@ -2624,31 +2603,48 @@ const loadContent = async (state, savedState) => {
|
|
|
2624
2603
|
inputGap,
|
|
2625
2604
|
inputLineHeight,
|
|
2626
2605
|
inputPaddingBottom,
|
|
2627
|
-
inputPaddingTop
|
|
2628
|
-
replaceExpanded
|
|
2606
|
+
inputPaddingTop
|
|
2629
2607
|
} = state;
|
|
2630
2608
|
const fontSize = await getFontSize();
|
|
2609
|
+
const restoredState = restoreState(savedState);
|
|
2631
2610
|
const {
|
|
2611
|
+
hasValue,
|
|
2612
|
+
matchCase,
|
|
2613
|
+
matchWholeWord,
|
|
2614
|
+
preserveCase,
|
|
2615
|
+
replaceExpanded,
|
|
2632
2616
|
replacement,
|
|
2633
|
-
|
|
2634
|
-
|
|
2617
|
+
useRegularExpression,
|
|
2618
|
+
value,
|
|
2619
|
+
width: savedWidth
|
|
2620
|
+
} = restoredState;
|
|
2635
2621
|
const lines = await getLines(editorUid);
|
|
2636
2622
|
const selections = await getSelections(editorUid);
|
|
2637
2623
|
const {
|
|
2638
|
-
width,
|
|
2624
|
+
width: defaultWidth,
|
|
2639
2625
|
x,
|
|
2640
2626
|
y
|
|
2641
2627
|
} = getFindWidgetPosition(editorX, editorY, editorWidth);
|
|
2642
2628
|
if (lines.length === 0) {
|
|
2643
2629
|
return state;
|
|
2644
2630
|
}
|
|
2645
|
-
const actualValue = value
|
|
2646
|
-
const
|
|
2631
|
+
const actualValue = hasValue ? value : getSelectedText(lines, selections);
|
|
2632
|
+
const {
|
|
2633
|
+
matches
|
|
2634
|
+
} = findMatches(lines, actualValue, {
|
|
2635
|
+
matchCase,
|
|
2636
|
+
matchWholeWord,
|
|
2637
|
+
useRegularExpression
|
|
2638
|
+
});
|
|
2647
2639
|
const matchCount = getMatchCount(matches);
|
|
2640
|
+
let width = defaultWidth;
|
|
2641
|
+
if (typeof savedWidth === 'number' && savedWidth > 0) {
|
|
2642
|
+
width = editorWidth > 0 ? Math.min(savedWidth, editorWidth) : savedWidth;
|
|
2643
|
+
}
|
|
2648
2644
|
const {
|
|
2649
2645
|
height,
|
|
2650
2646
|
inputHeight
|
|
2651
|
-
} = measureInputHeight(
|
|
2647
|
+
} = measureInputHeight(actualValue, inputLineHeight, inputPaddingBottom, inputPaddingTop, inputBorderWidth, inputGap, replaceExpanded, fontSize);
|
|
2652
2648
|
return {
|
|
2653
2649
|
...state,
|
|
2654
2650
|
focus: FocusSearchInput,
|
|
@@ -2657,12 +2653,17 @@ const loadContent = async (state, savedState) => {
|
|
|
2657
2653
|
height,
|
|
2658
2654
|
inputSource: Script$1,
|
|
2659
2655
|
lines,
|
|
2656
|
+
matchCase,
|
|
2660
2657
|
matchCount,
|
|
2661
2658
|
matches,
|
|
2662
2659
|
matchIndex: 0,
|
|
2660
|
+
matchWholeWord,
|
|
2661
|
+
preserveCase,
|
|
2662
|
+
replaceExpanded,
|
|
2663
2663
|
replacement,
|
|
2664
2664
|
searchInputHeight: inputHeight,
|
|
2665
2665
|
selections,
|
|
2666
|
+
useRegularExpression,
|
|
2666
2667
|
value: actualValue,
|
|
2667
2668
|
version: 1,
|
|
2668
2669
|
width,
|
|
@@ -3736,6 +3737,7 @@ const saveState = state => {
|
|
|
3736
3737
|
const {
|
|
3737
3738
|
matchCase,
|
|
3738
3739
|
matchWholeWord,
|
|
3740
|
+
preserveCase,
|
|
3739
3741
|
replaceExpanded,
|
|
3740
3742
|
replacement,
|
|
3741
3743
|
useRegularExpression,
|
|
@@ -3745,6 +3747,7 @@ const saveState = state => {
|
|
|
3745
3747
|
return {
|
|
3746
3748
|
matchCase,
|
|
3747
3749
|
matchWholeWord,
|
|
3750
|
+
preserveCase,
|
|
3748
3751
|
replaceExpanded,
|
|
3749
3752
|
replacement,
|
|
3750
3753
|
useRegularExpression,
|