@lvce-editor/find-widget-worker 1.17.0 → 1.18.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.
@@ -982,7 +982,7 @@ const create$1 = (uid, x, y, width, height, parentUid) => {
982
982
  inputSource: 0,
983
983
  preserveCase: false,
984
984
  resizerPointerDown: false,
985
- minWidth: 300
985
+ minWidth: 400
986
986
  };
987
987
  set$3(uid, state, state);
988
988
  return state;
@@ -1679,13 +1679,38 @@ const getSelections = async editorUid => {
1679
1679
  return selections;
1680
1680
  };
1681
1681
 
1682
- const loadContent = async state => {
1682
+ const getSavedValue = savedState => {
1683
+ if (savedState && savedState.value) {
1684
+ return savedState.value;
1685
+ }
1686
+ return '';
1687
+ };
1688
+ const getSavedReplacement = savedState => {
1689
+ if (savedState && savedState.replacement) {
1690
+ return savedState.replacement;
1691
+ }
1692
+ return '';
1693
+ };
1694
+ const restoreState = savedState => {
1695
+ const value = getSavedValue(savedState);
1696
+ const replacement = getSavedReplacement(savedState);
1697
+ return {
1698
+ value,
1699
+ replacement
1700
+ };
1701
+ };
1702
+
1703
+ const loadContent = async (state, savedState) => {
1683
1704
  const {
1684
1705
  editorUid,
1685
1706
  editorWidth,
1686
1707
  editorX,
1687
1708
  editorY
1688
1709
  } = state;
1710
+ const {
1711
+ replacement,
1712
+ value
1713
+ } = restoreState(savedState);
1689
1714
  const lines = await getLines(editorUid);
1690
1715
  const selections = await getSelections(editorUid);
1691
1716
  const {
@@ -1697,24 +1722,25 @@ const loadContent = async state => {
1697
1722
  if (lines.length === 0) {
1698
1723
  return state;
1699
1724
  }
1700
- const value = getSelectedText(lines, selections);
1701
- const matches = findMatchesCaseInsensitive(lines, value);
1725
+ const actualValue = value || getSelectedText(lines, selections);
1726
+ const matches = findMatchesCaseInsensitive(lines, actualValue);
1702
1727
  const matchCount = getMatchCount(matches);
1703
1728
  return {
1704
1729
  ...state,
1705
- value,
1730
+ focused: true,
1731
+ height,
1732
+ inputSource: Script,
1733
+ lines,
1734
+ matchCount,
1706
1735
  matches,
1707
1736
  matchIndex: 0,
1708
- matchCount,
1737
+ replacement,
1738
+ selections,
1739
+ value: actualValue,
1709
1740
  version: 1,
1710
- x,
1711
- y,
1712
1741
  width,
1713
- height,
1714
- lines,
1715
- selections,
1716
- focused: true,
1717
- inputSource: Script
1742
+ x,
1743
+ y
1718
1744
  };
1719
1745
  };
1720
1746
 
@@ -2290,10 +2316,22 @@ const resize = async (state, dimensions) => {
2290
2316
 
2291
2317
  const saveState = state => {
2292
2318
  const {
2293
- width
2319
+ width,
2320
+ value,
2321
+ replacement,
2322
+ matchCase,
2323
+ matchWholeWord,
2324
+ useRegularExpression,
2325
+ replaceExpanded
2294
2326
  } = state;
2295
2327
  return {
2296
- width
2328
+ width,
2329
+ value,
2330
+ replacement,
2331
+ matchCase,
2332
+ matchWholeWord,
2333
+ useRegularExpression,
2334
+ replaceExpanded
2297
2335
  };
2298
2336
  };
2299
2337
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/find-widget-worker",
3
- "version": "1.17.0",
3
+ "version": "1.18.0",
4
4
  "description": "Web Worker for the find widget in Lvce Editor",
5
5
  "repository": {
6
6
  "type": "git",