@lvce-editor/find-widget-worker 2.2.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 +55 -27
- package/package.json +1 -1
|
@@ -988,10 +988,12 @@ 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;
|
|
@@ -1002,7 +1004,7 @@ const isEqual$8 = (oldState, newState) => {
|
|
|
1002
1004
|
};
|
|
1003
1005
|
|
|
1004
1006
|
const isEqual$7 = (oldState, newState) => {
|
|
1005
|
-
return newState.width === newState.width && oldState.height === newState.height && oldState.x === newState.x && oldState.
|
|
1007
|
+
return newState.width === newState.width && oldState.height === newState.height && oldState.x === newState.x && oldState.searchInputHeight === newState.searchInputHeight;
|
|
1006
1008
|
};
|
|
1007
1009
|
|
|
1008
1010
|
const isEqual$6 = (oldState, newState) => {
|
|
@@ -1434,6 +1436,20 @@ const measureTextHeight = (value, lineHeight) => {
|
|
|
1434
1436
|
return lines.length * lineHeight;
|
|
1435
1437
|
};
|
|
1436
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
|
+
|
|
1437
1453
|
const refresh$1 = (state, value, inputSource) => {
|
|
1438
1454
|
const {
|
|
1439
1455
|
lines,
|
|
@@ -1442,7 +1458,10 @@ const refresh$1 = (state, value, inputSource) => {
|
|
|
1442
1458
|
matchWholeWord,
|
|
1443
1459
|
inputLineHeight,
|
|
1444
1460
|
inputPaddingTop,
|
|
1445
|
-
inputPaddingBottom
|
|
1461
|
+
inputPaddingBottom,
|
|
1462
|
+
replaceExpanded,
|
|
1463
|
+
inputBorderWidth,
|
|
1464
|
+
inputGap
|
|
1446
1465
|
} = state;
|
|
1447
1466
|
const options = {
|
|
1448
1467
|
matchCase,
|
|
@@ -1453,14 +1472,15 @@ const refresh$1 = (state, value, inputSource) => {
|
|
|
1453
1472
|
matches,
|
|
1454
1473
|
error
|
|
1455
1474
|
} = findMatches(lines, value, options);
|
|
1456
|
-
const
|
|
1457
|
-
|
|
1458
|
-
|
|
1475
|
+
const {
|
|
1476
|
+
inputHeight,
|
|
1477
|
+
height
|
|
1478
|
+
} = measureInputHeight(value, inputLineHeight, inputPaddingBottom, inputPaddingTop, inputBorderWidth, inputGap, replaceExpanded);
|
|
1459
1479
|
if (error) {
|
|
1460
1480
|
return {
|
|
1461
1481
|
...state,
|
|
1462
1482
|
inputErrorMessage: error,
|
|
1463
|
-
inputHeight,
|
|
1483
|
+
searchInputHeight: inputHeight,
|
|
1464
1484
|
height
|
|
1465
1485
|
};
|
|
1466
1486
|
}
|
|
@@ -1468,7 +1488,7 @@ const refresh$1 = (state, value, inputSource) => {
|
|
|
1468
1488
|
return {
|
|
1469
1489
|
...state,
|
|
1470
1490
|
inputErrorMessage: error,
|
|
1471
|
-
inputHeight,
|
|
1491
|
+
searchInputHeight: inputHeight,
|
|
1472
1492
|
inputSource,
|
|
1473
1493
|
matchCount,
|
|
1474
1494
|
matches,
|
|
@@ -1706,23 +1726,24 @@ const handleResizerPointerUp = async (state, eventX, eventY) => {
|
|
|
1706
1726
|
};
|
|
1707
1727
|
};
|
|
1708
1728
|
|
|
1709
|
-
const getFindWidgetHeight = replaceExpanded => {
|
|
1710
|
-
const collapsedHeight = 30;
|
|
1711
|
-
const expandedHeight = 60;
|
|
1712
|
-
const newHeight = replaceExpanded ? expandedHeight : collapsedHeight;
|
|
1713
|
-
return newHeight;
|
|
1714
|
-
};
|
|
1715
|
-
|
|
1716
1729
|
const toggleReplace$1 = state => {
|
|
1717
1730
|
const {
|
|
1718
|
-
replaceExpanded
|
|
1731
|
+
replaceExpanded,
|
|
1732
|
+
value,
|
|
1733
|
+
inputLineHeight,
|
|
1734
|
+
inputPaddingBottom,
|
|
1735
|
+
inputPaddingTop,
|
|
1736
|
+
inputBorderWidth,
|
|
1737
|
+
inputGap
|
|
1719
1738
|
} = state;
|
|
1720
1739
|
const newExpanded = !replaceExpanded;
|
|
1721
|
-
const
|
|
1740
|
+
const {
|
|
1741
|
+
height
|
|
1742
|
+
} = measureInputHeight(value, inputLineHeight, inputPaddingBottom, inputPaddingTop, inputBorderWidth, inputGap, newExpanded);
|
|
1722
1743
|
return {
|
|
1723
1744
|
...state,
|
|
1724
1745
|
replaceExpanded: newExpanded,
|
|
1725
|
-
height
|
|
1746
|
+
height
|
|
1726
1747
|
};
|
|
1727
1748
|
};
|
|
1728
1749
|
|
|
@@ -1995,7 +2016,12 @@ const loadContent = async (state, savedState) => {
|
|
|
1995
2016
|
editorWidth,
|
|
1996
2017
|
editorX,
|
|
1997
2018
|
editorY,
|
|
1998
|
-
inputLineHeight
|
|
2019
|
+
inputLineHeight,
|
|
2020
|
+
inputPaddingBottom,
|
|
2021
|
+
inputPaddingTop,
|
|
2022
|
+
replaceExpanded,
|
|
2023
|
+
inputBorderWidth,
|
|
2024
|
+
inputGap
|
|
1999
2025
|
} = state;
|
|
2000
2026
|
const {
|
|
2001
2027
|
replacement,
|
|
@@ -2006,8 +2032,7 @@ const loadContent = async (state, savedState) => {
|
|
|
2006
2032
|
const {
|
|
2007
2033
|
x,
|
|
2008
2034
|
y,
|
|
2009
|
-
width
|
|
2010
|
-
height
|
|
2035
|
+
width
|
|
2011
2036
|
} = getFindWidgetPosition(editorX, editorY, editorWidth);
|
|
2012
2037
|
if (lines.length === 0) {
|
|
2013
2038
|
return state;
|
|
@@ -2015,19 +2040,22 @@ const loadContent = async (state, savedState) => {
|
|
|
2015
2040
|
const actualValue = value || getSelectedText(lines, selections);
|
|
2016
2041
|
const matches = findMatchesCaseInsensitive(lines, actualValue);
|
|
2017
2042
|
const matchCount = getMatchCount(matches);
|
|
2018
|
-
const
|
|
2043
|
+
const {
|
|
2044
|
+
inputHeight,
|
|
2045
|
+
height
|
|
2046
|
+
} = measureInputHeight(value, inputLineHeight, inputPaddingBottom, inputPaddingTop, inputBorderWidth, inputGap, replaceExpanded);
|
|
2019
2047
|
return {
|
|
2020
2048
|
...state,
|
|
2021
2049
|
focus: FocusSearchInput,
|
|
2022
2050
|
focused: true,
|
|
2023
2051
|
height,
|
|
2024
|
-
inputHeight,
|
|
2025
2052
|
inputSource: Script,
|
|
2026
2053
|
lines,
|
|
2027
2054
|
matchCount,
|
|
2028
2055
|
matches,
|
|
2029
2056
|
matchIndex: 0,
|
|
2030
2057
|
replacement,
|
|
2058
|
+
searchInputHeight: inputHeight,
|
|
2031
2059
|
selections,
|
|
2032
2060
|
value: actualValue,
|
|
2033
2061
|
version: 1,
|
|
@@ -2483,7 +2511,7 @@ const renderCss = (oldState, newState) => {
|
|
|
2483
2511
|
height,
|
|
2484
2512
|
x,
|
|
2485
2513
|
y,
|
|
2486
|
-
inputHeight
|
|
2514
|
+
searchInputHeight: inputHeight
|
|
2487
2515
|
} = newState;
|
|
2488
2516
|
const css = `:root {
|
|
2489
2517
|
--FindWidgetWidth: ${width}px;
|
|
@@ -2607,7 +2635,7 @@ const renderReplaceValue = (oldState, newState) => {
|
|
|
2607
2635
|
uid,
|
|
2608
2636
|
replacement
|
|
2609
2637
|
} = newState;
|
|
2610
|
-
return [SetValueByName, uid,
|
|
2638
|
+
return [SetValueByName, uid, ReplaceValue, replacement];
|
|
2611
2639
|
};
|
|
2612
2640
|
|
|
2613
2641
|
const renderUid = (oldState, newState) => {
|