@lvce-editor/find-widget-worker 2.1.0 → 2.3.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/findWidgetWorkerMain.js +80 -47
- package/package.json +1 -1
|
@@ -988,53 +988,45 @@ const create$1 = (uid, x, y, width, height, parentUid) => {
|
|
|
988
988
|
minWidth: 400,
|
|
989
989
|
history: [],
|
|
990
990
|
inputErrorMessage: '',
|
|
991
|
-
|
|
991
|
+
searchInputHeight: 15,
|
|
992
992
|
inputLineHeight: 15,
|
|
993
|
-
inputPaddingTop:
|
|
994
|
-
inputPaddingBottom:
|
|
993
|
+
inputPaddingTop: 4,
|
|
994
|
+
inputPaddingBottom: 4,
|
|
995
|
+
inputBorderWidth: 1,
|
|
996
|
+
inputGap: 3
|
|
995
997
|
};
|
|
996
998
|
set$3(uid, state, state);
|
|
997
999
|
return state;
|
|
998
1000
|
};
|
|
999
1001
|
|
|
1000
|
-
const isEqual$
|
|
1002
|
+
const isEqual$8 = (oldState, newState) => {
|
|
1001
1003
|
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
1002
1004
|
};
|
|
1003
1005
|
|
|
1004
|
-
const isEqual$
|
|
1005
|
-
return newState.width === newState.width && oldState.height === newState.height && oldState.x === newState.x && oldState.
|
|
1006
|
+
const isEqual$7 = (oldState, newState) => {
|
|
1007
|
+
return newState.width === newState.width && oldState.height === newState.height && oldState.x === newState.x && oldState.searchInputHeight === newState.searchInputHeight;
|
|
1006
1008
|
};
|
|
1007
1009
|
|
|
1008
|
-
const isEqual$
|
|
1010
|
+
const isEqual$6 = (oldState, newState) => {
|
|
1009
1011
|
return oldState.version === newState.version;
|
|
1010
1012
|
};
|
|
1011
1013
|
|
|
1012
|
-
const isEqual$
|
|
1014
|
+
const isEqual$5 = (oldState, newState) => {
|
|
1013
1015
|
return oldState.focused === newState.focused && oldState.focus === newState.focus;
|
|
1014
1016
|
};
|
|
1015
1017
|
|
|
1016
|
-
const isEqual$
|
|
1018
|
+
const isEqual$4 = (oldState, newState) => {
|
|
1017
1019
|
return oldState.focused === newState.focused;
|
|
1018
1020
|
};
|
|
1019
1021
|
|
|
1020
|
-
const isEqual$
|
|
1022
|
+
const isEqual$3 = (oldState, newState) => {
|
|
1021
1023
|
return oldState.version === newState.version && oldState.replaceExpanded === newState.replaceExpanded && oldState.matchCount === newState.matchCount && oldState.matchIndex === newState.matchIndex && oldState.matchCase === newState.matchCase && oldState.matchWholeWord === newState.matchWholeWord && oldState.useRegularExpression === newState.useRegularExpression && oldState.preserveCase === newState.preserveCase;
|
|
1022
1024
|
};
|
|
1023
1025
|
|
|
1024
|
-
const isEqual$
|
|
1026
|
+
const isEqual$2 = (oldState, newState) => {
|
|
1025
1027
|
return oldState.version === newState.version;
|
|
1026
1028
|
};
|
|
1027
1029
|
|
|
1028
|
-
const RenderBounds = 8;
|
|
1029
|
-
const RenderCss = 10;
|
|
1030
|
-
const RenderEventListeners = 11;
|
|
1031
|
-
const RenderUid = 12;
|
|
1032
|
-
const RenderContent = 13;
|
|
1033
|
-
const RenderFocusContext = 14;
|
|
1034
|
-
const RenderFocus = 15;
|
|
1035
|
-
const RenderValue = 16;
|
|
1036
|
-
const RenderReplaceValue = 17;
|
|
1037
|
-
|
|
1038
1030
|
const CheckBox = 'checkbox';
|
|
1039
1031
|
const Group = 'group';
|
|
1040
1032
|
const None = 'none';
|
|
@@ -1088,12 +1080,26 @@ const FocusSearchWholeWord = 34;
|
|
|
1088
1080
|
const FocusToggleDetails = 1010;
|
|
1089
1081
|
const FocusToggleReplace = 1020;
|
|
1090
1082
|
|
|
1083
|
+
const isEqual$1 = (oldState, newState) => {
|
|
1084
|
+
return newState.inputSource === User || oldState.replacement === newState.replacement;
|
|
1085
|
+
};
|
|
1086
|
+
|
|
1087
|
+
const RenderBounds = 8;
|
|
1088
|
+
const RenderCss = 10;
|
|
1089
|
+
const RenderEventListeners = 11;
|
|
1090
|
+
const RenderUid = 12;
|
|
1091
|
+
const RenderContent = 13;
|
|
1092
|
+
const RenderFocusContext = 14;
|
|
1093
|
+
const RenderFocus = 15;
|
|
1094
|
+
const RenderValue = 16;
|
|
1095
|
+
const RenderReplaceValue = 17;
|
|
1096
|
+
|
|
1091
1097
|
const isEqual = (oldState, newState) => {
|
|
1092
1098
|
return newState.inputSource === User || oldState.value === newState.value;
|
|
1093
1099
|
};
|
|
1094
1100
|
|
|
1095
|
-
const modules = [isEqual$
|
|
1096
|
-
const numbers = [RenderEventListeners, RenderContent, RenderBounds, RenderUid, RenderFocusContext, RenderFocus, RenderValue, RenderCss];
|
|
1101
|
+
const modules = [isEqual$6, isEqual$3, isEqual$8, isEqual$2, isEqual$4, isEqual$5, isEqual, isEqual$1, isEqual$7];
|
|
1102
|
+
const numbers = [RenderEventListeners, RenderContent, RenderBounds, RenderUid, RenderFocusContext, RenderFocus, RenderValue, RenderReplaceValue, RenderCss];
|
|
1097
1103
|
|
|
1098
1104
|
const diff = (oldState, newState) => {
|
|
1099
1105
|
const diffResult = [];
|
|
@@ -1430,6 +1436,20 @@ const measureTextHeight = (value, lineHeight) => {
|
|
|
1430
1436
|
return lines.length * lineHeight;
|
|
1431
1437
|
};
|
|
1432
1438
|
|
|
1439
|
+
const measureInputHeight = (value, inputLineHeight, inputPaddingBottom, inputPaddingTop, inputBorderWidth, inputGap, replaceExpanded) => {
|
|
1440
|
+
const textHeight = measureTextHeight(value, inputLineHeight);
|
|
1441
|
+
const inputHeight = textHeight + inputPaddingBottom + inputPaddingTop + inputBorderWidth * 2;
|
|
1442
|
+
const replaceInputHeight = replaceExpanded ? inputHeight : 0; // TODO should be independent of input
|
|
1443
|
+
const actualGap = replaceExpanded ? inputGap : 0;
|
|
1444
|
+
// TODO use variables for margin
|
|
1445
|
+
const height = inputHeight + replaceInputHeight + 5 + actualGap;
|
|
1446
|
+
return {
|
|
1447
|
+
inputHeight,
|
|
1448
|
+
height,
|
|
1449
|
+
replaceInputHeight
|
|
1450
|
+
};
|
|
1451
|
+
};
|
|
1452
|
+
|
|
1433
1453
|
const refresh$1 = (state, value, inputSource) => {
|
|
1434
1454
|
const {
|
|
1435
1455
|
lines,
|
|
@@ -1438,7 +1458,10 @@ const refresh$1 = (state, value, inputSource) => {
|
|
|
1438
1458
|
matchWholeWord,
|
|
1439
1459
|
inputLineHeight,
|
|
1440
1460
|
inputPaddingTop,
|
|
1441
|
-
inputPaddingBottom
|
|
1461
|
+
inputPaddingBottom,
|
|
1462
|
+
replaceExpanded,
|
|
1463
|
+
inputBorderWidth,
|
|
1464
|
+
inputGap
|
|
1442
1465
|
} = state;
|
|
1443
1466
|
const options = {
|
|
1444
1467
|
matchCase,
|
|
@@ -1449,14 +1472,15 @@ const refresh$1 = (state, value, inputSource) => {
|
|
|
1449
1472
|
matches,
|
|
1450
1473
|
error
|
|
1451
1474
|
} = findMatches(lines, value, options);
|
|
1452
|
-
const
|
|
1453
|
-
|
|
1454
|
-
|
|
1475
|
+
const {
|
|
1476
|
+
inputHeight,
|
|
1477
|
+
height
|
|
1478
|
+
} = measureInputHeight(value, inputLineHeight, inputPaddingBottom, inputPaddingTop, inputBorderWidth, inputGap, replaceExpanded);
|
|
1455
1479
|
if (error) {
|
|
1456
1480
|
return {
|
|
1457
1481
|
...state,
|
|
1458
1482
|
inputErrorMessage: error,
|
|
1459
|
-
inputHeight,
|
|
1483
|
+
searchInputHeight: inputHeight,
|
|
1460
1484
|
height
|
|
1461
1485
|
};
|
|
1462
1486
|
}
|
|
@@ -1464,7 +1488,7 @@ const refresh$1 = (state, value, inputSource) => {
|
|
|
1464
1488
|
return {
|
|
1465
1489
|
...state,
|
|
1466
1490
|
inputErrorMessage: error,
|
|
1467
|
-
inputHeight,
|
|
1491
|
+
searchInputHeight: inputHeight,
|
|
1468
1492
|
inputSource,
|
|
1469
1493
|
matchCount,
|
|
1470
1494
|
matches,
|
|
@@ -1702,23 +1726,24 @@ const handleResizerPointerUp = async (state, eventX, eventY) => {
|
|
|
1702
1726
|
};
|
|
1703
1727
|
};
|
|
1704
1728
|
|
|
1705
|
-
const getFindWidgetHeight = replaceExpanded => {
|
|
1706
|
-
const collapsedHeight = 30;
|
|
1707
|
-
const expandedHeight = 60;
|
|
1708
|
-
const newHeight = replaceExpanded ? expandedHeight : collapsedHeight;
|
|
1709
|
-
return newHeight;
|
|
1710
|
-
};
|
|
1711
|
-
|
|
1712
1729
|
const toggleReplace$1 = state => {
|
|
1713
1730
|
const {
|
|
1714
|
-
replaceExpanded
|
|
1731
|
+
replaceExpanded,
|
|
1732
|
+
value,
|
|
1733
|
+
inputLineHeight,
|
|
1734
|
+
inputPaddingBottom,
|
|
1735
|
+
inputPaddingTop,
|
|
1736
|
+
inputBorderWidth,
|
|
1737
|
+
inputGap
|
|
1715
1738
|
} = state;
|
|
1716
1739
|
const newExpanded = !replaceExpanded;
|
|
1717
|
-
const
|
|
1740
|
+
const {
|
|
1741
|
+
height
|
|
1742
|
+
} = measureInputHeight(value, inputLineHeight, inputPaddingBottom, inputPaddingTop, inputBorderWidth, inputGap, newExpanded);
|
|
1718
1743
|
return {
|
|
1719
1744
|
...state,
|
|
1720
1745
|
replaceExpanded: newExpanded,
|
|
1721
|
-
height
|
|
1746
|
+
height
|
|
1722
1747
|
};
|
|
1723
1748
|
};
|
|
1724
1749
|
|
|
@@ -1991,7 +2016,12 @@ const loadContent = async (state, savedState) => {
|
|
|
1991
2016
|
editorWidth,
|
|
1992
2017
|
editorX,
|
|
1993
2018
|
editorY,
|
|
1994
|
-
inputLineHeight
|
|
2019
|
+
inputLineHeight,
|
|
2020
|
+
inputPaddingBottom,
|
|
2021
|
+
inputPaddingTop,
|
|
2022
|
+
replaceExpanded,
|
|
2023
|
+
inputBorderWidth,
|
|
2024
|
+
inputGap
|
|
1995
2025
|
} = state;
|
|
1996
2026
|
const {
|
|
1997
2027
|
replacement,
|
|
@@ -2002,8 +2032,7 @@ const loadContent = async (state, savedState) => {
|
|
|
2002
2032
|
const {
|
|
2003
2033
|
x,
|
|
2004
2034
|
y,
|
|
2005
|
-
width
|
|
2006
|
-
height
|
|
2035
|
+
width
|
|
2007
2036
|
} = getFindWidgetPosition(editorX, editorY, editorWidth);
|
|
2008
2037
|
if (lines.length === 0) {
|
|
2009
2038
|
return state;
|
|
@@ -2011,19 +2040,22 @@ const loadContent = async (state, savedState) => {
|
|
|
2011
2040
|
const actualValue = value || getSelectedText(lines, selections);
|
|
2012
2041
|
const matches = findMatchesCaseInsensitive(lines, actualValue);
|
|
2013
2042
|
const matchCount = getMatchCount(matches);
|
|
2014
|
-
const
|
|
2043
|
+
const {
|
|
2044
|
+
inputHeight,
|
|
2045
|
+
height
|
|
2046
|
+
} = measureInputHeight(value, inputLineHeight, inputPaddingBottom, inputPaddingTop, inputBorderWidth, inputGap, replaceExpanded);
|
|
2015
2047
|
return {
|
|
2016
2048
|
...state,
|
|
2017
2049
|
focus: FocusSearchInput,
|
|
2018
2050
|
focused: true,
|
|
2019
2051
|
height,
|
|
2020
|
-
inputHeight,
|
|
2021
2052
|
inputSource: Script,
|
|
2022
2053
|
lines,
|
|
2023
2054
|
matchCount,
|
|
2024
2055
|
matches,
|
|
2025
2056
|
matchIndex: 0,
|
|
2026
2057
|
replacement,
|
|
2058
|
+
searchInputHeight: inputHeight,
|
|
2027
2059
|
selections,
|
|
2028
2060
|
value: actualValue,
|
|
2029
2061
|
version: 1,
|
|
@@ -2479,7 +2511,7 @@ const renderCss = (oldState, newState) => {
|
|
|
2479
2511
|
height,
|
|
2480
2512
|
x,
|
|
2481
2513
|
y,
|
|
2482
|
-
inputHeight
|
|
2514
|
+
searchInputHeight: inputHeight
|
|
2483
2515
|
} = newState;
|
|
2484
2516
|
const css = `:root {
|
|
2485
2517
|
--FindWidgetWidth: ${width}px;
|
|
@@ -2603,7 +2635,7 @@ const renderReplaceValue = (oldState, newState) => {
|
|
|
2603
2635
|
uid,
|
|
2604
2636
|
replacement
|
|
2605
2637
|
} = newState;
|
|
2606
|
-
return [SetValueByName, uid,
|
|
2638
|
+
return [SetValueByName, uid, ReplaceValue, replacement];
|
|
2607
2639
|
};
|
|
2608
2640
|
|
|
2609
2641
|
const renderUid = (oldState, newState) => {
|
|
@@ -2727,7 +2759,8 @@ const commandMap = {
|
|
|
2727
2759
|
'FindWidget.terminate': terminate,
|
|
2728
2760
|
'FindWidget.toggleMatchCase': wrapCommand(toggleMatchCase),
|
|
2729
2761
|
'FindWidget.toggleReplace': wrapCommand(toggleReplace$1),
|
|
2730
|
-
'FindWidget.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression)
|
|
2762
|
+
'FindWidget.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
|
|
2763
|
+
'FindWidget.togglePreserveCase': wrapCommand(togglePreserveCase)
|
|
2731
2764
|
};
|
|
2732
2765
|
|
|
2733
2766
|
const listen = async () => {
|