@lvce-editor/text-search-worker 3.3.0 → 3.4.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.
@@ -835,8 +835,6 @@ const copy = async state => {
835
835
  return state;
836
836
  };
837
837
 
838
- const ListItem = 22;
839
-
840
838
  const User = 1;
841
839
  const Script = 2;
842
840
 
@@ -885,7 +883,7 @@ const FocusSearchWholeWord = 34;
885
883
  const FocusSearchReplaceAll = 35;
886
884
  const FocusSearchPreserveCase = 36;
887
885
 
888
- const create = (uid, x, y, width, height, workspacePath, assetDir) => {
886
+ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight) => {
889
887
  const state = {
890
888
  uid,
891
889
  searchResults: [],
@@ -899,7 +897,7 @@ const create = (uid, x, y, width, height, workspacePath, assetDir) => {
899
897
  width,
900
898
  height,
901
899
  ...create$1({
902
- itemHeight: ListItem,
900
+ itemHeight: itemHeight || 22,
903
901
  minimumSliderSize: minimumSliderSize,
904
902
  headerHeight: 61 // TODO
905
903
  }),
@@ -3044,19 +3042,19 @@ const handleWheel = (state, deltaMode, deltaY) => {
3044
3042
  };
3045
3043
 
3046
3044
  const getSavedValue = savedState => {
3047
- if (savedState && savedState.value) {
3045
+ if (savedState && typeof savedState === 'object' && 'value' in savedState && typeof savedState.value === 'string') {
3048
3046
  return savedState.value;
3049
3047
  }
3050
3048
  return '';
3051
3049
  };
3052
3050
  const getSavedReplaceExpanded = savedState => {
3053
- if (savedState && 'replaceExpanded' in savedState) {
3051
+ if (savedState && typeof savedState === 'object' && 'replaceExpanded' in savedState && typeof savedState.replaceExpanded === 'boolean') {
3054
3052
  return savedState.replaceExpanded;
3055
3053
  }
3056
3054
  return false;
3057
3055
  };
3058
3056
  const getSavedCollapsedPaths = savedState => {
3059
- if (savedState && 'collapsedPaths' in savedState && Array.isArray(savedState.collapsedPaths) && savedState.collapsedPaths.every(path => typeof path === 'string')) {
3057
+ if (savedState && typeof savedState === 'object' && 'collapsedPaths' in savedState && Array.isArray(savedState.collapsedPaths) && savedState.collapsedPaths.every(path => typeof path === 'string')) {
3060
3058
  return savedState.collapsedPaths;
3061
3059
  }
3062
3060
  return [];
@@ -3064,11 +3062,26 @@ const getSavedCollapsedPaths = savedState => {
3064
3062
  const getThreads = () => {
3065
3063
  return 1;
3066
3064
  };
3067
- const loadContent = async (state, savedState) => {
3065
+ const restoreState = savedState => {
3068
3066
  const savedValue = getSavedValue(savedState);
3069
3067
  const savedReplaceExpanded = getSavedReplaceExpanded(savedState);
3070
3068
  const savedCollapsedPaths = getSavedCollapsedPaths(savedState);
3071
3069
  const threads = getThreads();
3070
+ return {
3071
+ savedCollapsedPaths,
3072
+ savedReplaceExpanded,
3073
+ savedValue,
3074
+ threads
3075
+ };
3076
+ };
3077
+
3078
+ const loadContent = async (state, savedState) => {
3079
+ const {
3080
+ savedValue,
3081
+ savedCollapsedPaths,
3082
+ savedReplaceExpanded,
3083
+ threads
3084
+ } = restoreState(savedState);
3072
3085
  if (savedValue) {
3073
3086
  return handleUpdate(state, {
3074
3087
  value: savedValue,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "Text Search Worker",
5
5
  "main": "dist/textSearchWorkerMain.js",
6
6
  "type": "module",