@lvce-editor/editor-worker 19.72.8 → 19.72.10

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.
@@ -8922,7 +8922,7 @@ const getColorPickerBounds = editor => {
8922
8922
  };
8923
8923
  };
8924
8924
 
8925
- const newStateGenerator$5 = (state, parentUid) => {
8925
+ const newStateGenerator$4 = (state, parentUid) => {
8926
8926
  return loadContent$3(state, parentUid);
8927
8927
  };
8928
8928
  const openColorPicker = async editor => {
@@ -8933,7 +8933,7 @@ const openColorPicker = async editor => {
8933
8933
  } = await Promise.resolve().then(function () { return GetColorPickerRange; });
8934
8934
  const range = await getColorPickerRange(editor);
8935
8935
  const createWidget = () => create$6(bounds, range, editor.undoStack.length);
8936
- return addWidgetToEditor(ColorPicker$2, ColorPicker, editor, createWidget, newStateGenerator$5, fullFocus);
8936
+ return addWidgetToEditor(ColorPicker$2, ColorPicker, editor, createWidget, newStateGenerator$4, fullFocus);
8937
8937
  };
8938
8938
  const closeColorPicker = editor => {
8939
8939
  const {
@@ -12203,7 +12203,7 @@ const create$4 = () => {
12203
12203
  return widget;
12204
12204
  };
12205
12205
 
12206
- const newStateGenerator$4 = async state => {
12206
+ const newStateGenerator$3 = async state => {
12207
12207
  const latestState = {
12208
12208
  ...state,
12209
12209
  height: 45,
@@ -12215,7 +12215,7 @@ const newStateGenerator$4 = async state => {
12215
12215
  };
12216
12216
  const openCodeGenerator = async editor => {
12217
12217
  const fullFocus = true;
12218
- return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create$4, newStateGenerator$4, fullFocus);
12218
+ return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create$4, newStateGenerator$3, fullFocus);
12219
12219
  };
12220
12220
 
12221
12221
  const create$3 = () => {
@@ -12247,7 +12247,7 @@ const {
12247
12247
  setFactory
12248
12248
  } = createLazyRpc(CompletionWorker);
12249
12249
 
12250
- const newStateGenerator$3 = async (state, parentUid) => {
12250
+ const newStateGenerator$2 = async (state, parentUid) => {
12251
12251
  const {
12252
12252
  height,
12253
12253
  uid,
@@ -12273,7 +12273,7 @@ const newStateGenerator$3 = async (state, parentUid) => {
12273
12273
  };
12274
12274
  const openCompletion = async editor => {
12275
12275
  const fullFocus = false;
12276
- return addWidgetToEditor(Completion, EditorCompletion, editor, create$3, newStateGenerator$3, fullFocus);
12276
+ return addWidgetToEditor(Completion, EditorCompletion, editor, create$3, newStateGenerator$2, fullFocus);
12277
12277
  };
12278
12278
 
12279
12279
  const isFunctional = widgetId => {
@@ -12712,7 +12712,7 @@ const create$2 = () => {
12712
12712
  return widget;
12713
12713
  };
12714
12714
 
12715
- const loadContent$2 = async (state, parentUid) => {
12715
+ const loadContent$2 = async (state, parentUid, savedState) => {
12716
12716
  const {
12717
12717
  uid
12718
12718
  } = state;
@@ -12725,7 +12725,7 @@ const loadContent$2 = async (state, parentUid) => {
12725
12725
  } = editor;
12726
12726
  await launch();
12727
12727
  await invoke$3('FindWidget.create', uid, x, y, width, height, parentUid);
12728
- await invoke$3('FindWidget.loadContent', uid);
12728
+ await invoke$3('FindWidget.loadContent', uid, savedState);
12729
12729
  const diff = await invoke$3('FindWidget.diff2', uid);
12730
12730
  const commands = await invoke$3('FindWidget.render2', uid, diff);
12731
12731
  return {
@@ -12734,16 +12734,16 @@ const loadContent$2 = async (state, parentUid) => {
12734
12734
  };
12735
12735
  };
12736
12736
 
12737
- const newStateGenerator$2 = (state, parentUid) => {
12738
- return loadContent$2(state, parentUid);
12739
- };
12740
- const openFind2 = async editor => {
12737
+ const openFind2 = async (editor, savedState) => {
12741
12738
  const editorWithFocusedFind = focusFindInput(editor);
12742
12739
  if (editorWithFocusedFind !== editor) {
12743
12740
  return editorWithFocusedFind;
12744
12741
  }
12745
12742
  const fullFocus = true;
12746
- return addWidgetToEditor(Find, FindWidget, editor, create$2, newStateGenerator$2, fullFocus);
12743
+ const newStateGenerator = (state, parentUid) => {
12744
+ return loadContent$2(state, parentUid, savedState);
12745
+ };
12746
+ return addWidgetToEditor(Find, FindWidget, editor, create$2, newStateGenerator, fullFocus);
12747
12747
  };
12748
12748
 
12749
12749
  const openFind = async state => {
@@ -15556,6 +15556,7 @@ const getWordAtOffset = editor => {
15556
15556
  return '';
15557
15557
  };
15558
15558
 
15559
+ const applyEditCommand = wrapCommand$1(applyEdit, false, false);
15559
15560
  const getPositionAtCursor = editorUid => {
15560
15561
  const editor = getEditor$1(editorUid);
15561
15562
  return getPositionAtCursor$1(editor);
@@ -15662,10 +15663,7 @@ const closeFind2 = async editorUid => {
15662
15663
  await closeWidget2(editorUid, Find, 'FindWidget', 0);
15663
15664
  };
15664
15665
  const applyEdits2 = async (editorUid, edits, selectionChanges) => {
15665
- const editor = getEditor$1(editorUid);
15666
- const newEditor = await applyEdit(editor, edits, selectionChanges);
15667
- const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
15668
- set$a(editorUid, editor, newEditorWithDerivedState);
15666
+ await applyEditCommand(editorUid, edits, selectionChanges);
15669
15667
  };
15670
15668
  const getSourceActions = async editorUid => {
15671
15669
  const actions = await getEditorSourceActions(editorUid);
@@ -18817,6 +18815,17 @@ const renderEventListeners = () => {
18817
18815
  }];
18818
18816
  };
18819
18817
 
18818
+ const restorePersistentWidgets = async (editor, savedWidgets) => {
18819
+ if (!Array.isArray(savedWidgets)) {
18820
+ return editor;
18821
+ }
18822
+ const savedFindWidget = savedWidgets.find(widget => widget?.id === Find);
18823
+ if (!savedFindWidget) {
18824
+ return editor;
18825
+ }
18826
+ return openFind2(editor, savedFindWidget.state);
18827
+ };
18828
+
18820
18829
  const revealProblem = (editor, rowIndex, columnIndex) => {
18821
18830
  if (!Number.isSafeInteger(rowIndex) || !Number.isSafeInteger(columnIndex)) {
18822
18831
  return editor;
@@ -18845,14 +18854,31 @@ const save = async (uid, skipFormatting = false) => {
18845
18854
  }
18846
18855
  };
18847
18856
 
18848
- const saveState = (state, savedState) => {
18857
+ const saveState = async (state, savedState) => {
18849
18858
  const {
18850
18859
  explicitLanguageId,
18851
18860
  largeFile,
18852
18861
  lines,
18853
18862
  redoStack,
18854
- undoStack
18863
+ undoStack,
18864
+ widgets: stateWidgets
18855
18865
  } = state;
18866
+ const widgets = [];
18867
+ const widgetsToSave = stateWidgets || [];
18868
+ for (const widget of widgetsToSave) {
18869
+ if (!widget?.newState || !isPersistentWidget(widget.id)) {
18870
+ continue;
18871
+ }
18872
+ const descriptor = getWidgetHotReloadDescriptor(widget.id);
18873
+ if (!descriptor) {
18874
+ continue;
18875
+ }
18876
+ const widgetState = await descriptor.invoke(`${descriptor.name}.saveState`, widget.newState.uid);
18877
+ widgets.push({
18878
+ id: widget.id,
18879
+ state: widgetState
18880
+ });
18881
+ }
18856
18882
  return {
18857
18883
  ...(explicitLanguageId && {
18858
18884
  explicitLanguageId
@@ -18860,6 +18886,9 @@ const saveState = (state, savedState) => {
18860
18886
  ...(largeFile && {
18861
18887
  largeFile: true
18862
18888
  }),
18889
+ ...(widgets.length > 0 && {
18890
+ widgets
18891
+ }),
18863
18892
  ...((redoStack.length > 0 || undoStack.length > 0) && {
18864
18893
  lines,
18865
18894
  redoStack,
@@ -19118,6 +19147,7 @@ const commandMap = {
19118
19147
  'Editor.replaceRange': wrapCommand(replaceRange),
19119
19148
  'Editor.rerender': wrapCommand(rerender),
19120
19149
  'Editor.resize': wrapCommand(resize),
19150
+ 'Editor.restorePersistentWidgets': wrapCommand(restorePersistentWidgets),
19121
19151
  'Editor.revealProblem': wrapCommand(revealProblem),
19122
19152
  'Editor.save': save,
19123
19153
  'Editor.saveState': wrapGetter(saveState),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.72.8",
3
+ "version": "19.72.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"