@lvce-editor/editor-worker 3.29.0 → 3.30.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/editorWorkerMain.js +54 -34
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -5254,6 +5254,35 @@ const handleBlur = async state => {
|
|
|
5254
5254
|
return state;
|
|
5255
5255
|
};
|
|
5256
5256
|
|
|
5257
|
+
const refresh$1 = (editor, state, value) => {
|
|
5258
|
+
const {
|
|
5259
|
+
lines
|
|
5260
|
+
} = editor;
|
|
5261
|
+
const matches = findMatchesCaseInsensitive(lines, value);
|
|
5262
|
+
const matchCount = getMatchCount(matches);
|
|
5263
|
+
return {
|
|
5264
|
+
...state,
|
|
5265
|
+
matches,
|
|
5266
|
+
matchIndex: 0,
|
|
5267
|
+
matchCount,
|
|
5268
|
+
value
|
|
5269
|
+
};
|
|
5270
|
+
};
|
|
5271
|
+
|
|
5272
|
+
const refresh = (state, value = state.value) => {
|
|
5273
|
+
// TODO get focused editor
|
|
5274
|
+
const {
|
|
5275
|
+
editorUid
|
|
5276
|
+
} = state;
|
|
5277
|
+
// highlight locations that match value
|
|
5278
|
+
const editor = getEditor(editorUid);
|
|
5279
|
+
return refresh$1(editor, state, value);
|
|
5280
|
+
};
|
|
5281
|
+
|
|
5282
|
+
const handleInput = (state, value) => {
|
|
5283
|
+
return refresh(state, value);
|
|
5284
|
+
};
|
|
5285
|
+
|
|
5257
5286
|
const handleFindWidgetFocus = (state, focusKey) => {
|
|
5258
5287
|
if (state.focus === focusKey) {
|
|
5259
5288
|
return state;
|
|
@@ -5311,29 +5340,6 @@ const loadContent$1 = editorId => {
|
|
|
5311
5340
|
editorUid: editor.uid
|
|
5312
5341
|
};
|
|
5313
5342
|
};
|
|
5314
|
-
const refresh = (state, value = state.value) => {
|
|
5315
|
-
// TODO get focused editor
|
|
5316
|
-
const {
|
|
5317
|
-
editorUid
|
|
5318
|
-
} = state;
|
|
5319
|
-
// highlight locations that match value
|
|
5320
|
-
const editor = getEditor(editorUid);
|
|
5321
|
-
const {
|
|
5322
|
-
lines
|
|
5323
|
-
} = editor;
|
|
5324
|
-
const matches = findMatchesCaseInsensitive(lines, value);
|
|
5325
|
-
const matchCount = getMatchCount(matches);
|
|
5326
|
-
return {
|
|
5327
|
-
...state,
|
|
5328
|
-
matches,
|
|
5329
|
-
matchIndex: 0,
|
|
5330
|
-
matchCount,
|
|
5331
|
-
value
|
|
5332
|
-
};
|
|
5333
|
-
};
|
|
5334
|
-
const handleInput = (state, value) => {
|
|
5335
|
-
return refresh(state, value);
|
|
5336
|
-
};
|
|
5337
5343
|
const close$1 = async state => {
|
|
5338
5344
|
// TODO
|
|
5339
5345
|
// await Viewlet.closeWidget(uid)
|
|
@@ -7887,6 +7893,26 @@ const replaceTextOccurrences = (editor, matches, oldValue, newValue) => {
|
|
|
7887
7893
|
return replaceRange(editor, ranges, [newValue], ReplaceAll$2);
|
|
7888
7894
|
};
|
|
7889
7895
|
|
|
7896
|
+
const updateWidget = (editor, widgetId, newState) => {
|
|
7897
|
+
// TODO avoid closure
|
|
7898
|
+
const isWidget = widget => {
|
|
7899
|
+
return widget.id === widgetId;
|
|
7900
|
+
};
|
|
7901
|
+
const childIndex = editor.widgets.findIndex(isWidget);
|
|
7902
|
+
// TODO scroll up/down if necessary
|
|
7903
|
+
const childWidget = editor.widgets[childIndex];
|
|
7904
|
+
const newWidget = {
|
|
7905
|
+
...childWidget,
|
|
7906
|
+
oldState: childWidget.newState,
|
|
7907
|
+
newState
|
|
7908
|
+
};
|
|
7909
|
+
const newWidgets = [...editor.widgets.slice(0, childIndex), newWidget, ...editor.widgets.slice(childIndex + 1)];
|
|
7910
|
+
return {
|
|
7911
|
+
...editor,
|
|
7912
|
+
widgets: newWidgets
|
|
7913
|
+
};
|
|
7914
|
+
};
|
|
7915
|
+
|
|
7890
7916
|
const replaceAll$1 = async editor => {
|
|
7891
7917
|
const state = getFindState(editor);
|
|
7892
7918
|
if (!state) {
|
|
@@ -7899,7 +7925,9 @@ const replaceAll$1 = async editor => {
|
|
|
7899
7925
|
} = state;
|
|
7900
7926
|
const edits = replaceTextOccurrences(editor, matches, value, replacement);
|
|
7901
7927
|
const newEditor = await applyEdit(editor, edits);
|
|
7902
|
-
|
|
7928
|
+
const newState = refresh$1(newEditor, state, value);
|
|
7929
|
+
const newestEditor = updateWidget(newEditor, Find, newState);
|
|
7930
|
+
return newestEditor;
|
|
7903
7931
|
};
|
|
7904
7932
|
|
|
7905
7933
|
const pending = Object.create(null);
|
|
@@ -8887,16 +8915,8 @@ const wrapWidgetCommand = (widgetId, fn) => {
|
|
|
8887
8915
|
// TODO scroll up/down if necessary
|
|
8888
8916
|
const childWidget = editor.widgets[childIndex];
|
|
8889
8917
|
const newState = await fn(childWidget.newState, ...args);
|
|
8890
|
-
const
|
|
8891
|
-
|
|
8892
|
-
oldState: childWidget.newState,
|
|
8893
|
-
newState
|
|
8894
|
-
};
|
|
8895
|
-
const newWidgets = [...editor.widgets.slice(0, childIndex), newWidget, ...editor.widgets.slice(childIndex + 1)];
|
|
8896
|
-
return {
|
|
8897
|
-
...editor,
|
|
8898
|
-
widgets: newWidgets
|
|
8899
|
-
};
|
|
8918
|
+
const newEditor = updateWidget(editor, widgetId, newState);
|
|
8919
|
+
return newEditor;
|
|
8900
8920
|
};
|
|
8901
8921
|
return wrapped;
|
|
8902
8922
|
};
|