@lvce-editor/editor-worker 3.15.0 → 3.16.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 +81 -40
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -2431,6 +2431,9 @@ const setAdditionalFocus = async focusKey => {
|
|
|
2431
2431
|
};
|
|
2432
2432
|
|
|
2433
2433
|
const setFocus = async focusKey => {
|
|
2434
|
+
if (!focusKey) {
|
|
2435
|
+
return;
|
|
2436
|
+
}
|
|
2434
2437
|
await invoke$3('Focus.setFocus', focusKey);
|
|
2435
2438
|
};
|
|
2436
2439
|
|
|
@@ -5192,58 +5195,108 @@ const focusFind = state => {
|
|
|
5192
5195
|
return setFindWidgetFocus(state, FindWidget);
|
|
5193
5196
|
};
|
|
5194
5197
|
|
|
5198
|
+
const getWidgetState = (editor, id) => {
|
|
5199
|
+
const {
|
|
5200
|
+
widgets
|
|
5201
|
+
} = editor;
|
|
5202
|
+
for (const widget of widgets) {
|
|
5203
|
+
if (widget.id === id) {
|
|
5204
|
+
return widget.newState;
|
|
5205
|
+
}
|
|
5206
|
+
}
|
|
5207
|
+
return undefined;
|
|
5208
|
+
};
|
|
5209
|
+
|
|
5210
|
+
const getFindState = editor => {
|
|
5211
|
+
return getWidgetState(editor, Find);
|
|
5212
|
+
};
|
|
5213
|
+
|
|
5214
|
+
const isFind = widget => {
|
|
5215
|
+
return widget.id === Find;
|
|
5216
|
+
};
|
|
5195
5217
|
// TODO don't call renderer worker, set editor state
|
|
5196
5218
|
// TODO this function should be synchronous
|
|
5197
|
-
const focusIndex$1 =
|
|
5219
|
+
const focusIndex$1 = (editor, index) => {
|
|
5220
|
+
const findState = getFindState(editor);
|
|
5221
|
+
if (!findState) {
|
|
5222
|
+
return editor;
|
|
5223
|
+
}
|
|
5198
5224
|
const {
|
|
5199
5225
|
value,
|
|
5200
5226
|
matches,
|
|
5201
5227
|
matchIndex
|
|
5202
|
-
} =
|
|
5228
|
+
} = findState;
|
|
5203
5229
|
if (index === matchIndex) {
|
|
5204
|
-
return
|
|
5230
|
+
return editor;
|
|
5205
5231
|
}
|
|
5232
|
+
const {
|
|
5233
|
+
widgets
|
|
5234
|
+
} = editor;
|
|
5235
|
+
const childIndex = widgets.findIndex(isFind);
|
|
5236
|
+
const childWidget = widgets[childIndex];
|
|
5237
|
+
|
|
5206
5238
|
// TODO find next match and highlight it
|
|
5207
5239
|
const matchRowIndex = matches[index * 2];
|
|
5208
5240
|
const matchColumnIndex = matches[index * 2 + 1];
|
|
5209
|
-
// @ts-ignore
|
|
5210
5241
|
const newSelections = new Uint32Array([matchRowIndex, matchColumnIndex, matchRowIndex, matchColumnIndex + value.length]);
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
// TODO
|
|
5214
|
-
await invoke$3('Editor.setSelections', newSelections);
|
|
5215
|
-
return {
|
|
5216
|
-
...state,
|
|
5242
|
+
const newState = {
|
|
5243
|
+
...findState,
|
|
5217
5244
|
matchIndex: index
|
|
5218
5245
|
};
|
|
5246
|
+
const newWidget = {
|
|
5247
|
+
...childWidget,
|
|
5248
|
+
newState
|
|
5249
|
+
};
|
|
5250
|
+
const newWidgets = [...widgets.slice(0, childIndex), newWidget, ...widgets.slice(childIndex + 1)];
|
|
5251
|
+
return {
|
|
5252
|
+
...editor,
|
|
5253
|
+
selections: newSelections,
|
|
5254
|
+
widgets: newWidgets
|
|
5255
|
+
};
|
|
5219
5256
|
};
|
|
5220
|
-
const focusFirst$1 =
|
|
5221
|
-
|
|
5257
|
+
const focusFirst$1 = editor => {
|
|
5258
|
+
const findState = getFindState(editor);
|
|
5259
|
+
if (!findState) {
|
|
5260
|
+
return editor;
|
|
5261
|
+
}
|
|
5262
|
+
return focusIndex$1(editor, 0);
|
|
5222
5263
|
};
|
|
5223
|
-
const focusLast =
|
|
5264
|
+
const focusLast = editor => {
|
|
5265
|
+
const findState = getFindState(editor);
|
|
5266
|
+
if (!findState) {
|
|
5267
|
+
return editor;
|
|
5268
|
+
}
|
|
5224
5269
|
const {
|
|
5225
5270
|
matchCount
|
|
5226
|
-
} =
|
|
5227
|
-
return focusIndex$1(
|
|
5271
|
+
} = findState;
|
|
5272
|
+
return focusIndex$1(editor, matchCount - 1);
|
|
5228
5273
|
};
|
|
5229
|
-
const focusNext$1 =
|
|
5274
|
+
const focusNext$1 = editor => {
|
|
5275
|
+
const findState = getFindState(editor);
|
|
5276
|
+
if (!findState) {
|
|
5277
|
+
return editor;
|
|
5278
|
+
}
|
|
5230
5279
|
const {
|
|
5231
5280
|
matchIndex,
|
|
5232
5281
|
matchCount
|
|
5233
|
-
} =
|
|
5282
|
+
} = findState;
|
|
5234
5283
|
if (matchIndex === matchCount - 1) {
|
|
5235
|
-
return focusFirst$1(
|
|
5284
|
+
return focusFirst$1(editor);
|
|
5236
5285
|
}
|
|
5237
|
-
return focusIndex$1(
|
|
5286
|
+
return focusIndex$1(editor, matchIndex + 1);
|
|
5238
5287
|
};
|
|
5239
|
-
const focusPrevious$1 =
|
|
5288
|
+
const focusPrevious$1 = editor => {
|
|
5289
|
+
const findState = getFindState(editor);
|
|
5290
|
+
if (!findState) {
|
|
5291
|
+
return editor;
|
|
5292
|
+
}
|
|
5240
5293
|
const {
|
|
5241
5294
|
matchIndex
|
|
5242
|
-
} =
|
|
5295
|
+
} = findState;
|
|
5243
5296
|
if (matchIndex === 0) {
|
|
5244
|
-
return focusLast(
|
|
5297
|
+
return focusLast(editor);
|
|
5245
5298
|
}
|
|
5246
|
-
return focusIndex$1(
|
|
5299
|
+
return focusIndex$1(editor, matchIndex - 1);
|
|
5247
5300
|
};
|
|
5248
5301
|
|
|
5249
5302
|
const focusNextMatchButton = state => {
|
|
@@ -7123,18 +7176,6 @@ const closeDetails = editor => {
|
|
|
7123
7176
|
};
|
|
7124
7177
|
};
|
|
7125
7178
|
|
|
7126
|
-
const getWidgetState = (editor, id) => {
|
|
7127
|
-
const {
|
|
7128
|
-
widgets
|
|
7129
|
-
} = editor;
|
|
7130
|
-
for (const widget of widgets) {
|
|
7131
|
-
if (widget.id === id) {
|
|
7132
|
-
return widget.newState;
|
|
7133
|
-
}
|
|
7134
|
-
}
|
|
7135
|
-
return undefined;
|
|
7136
|
-
};
|
|
7137
|
-
|
|
7138
7179
|
const getCompletionState = editor => {
|
|
7139
7180
|
return getWidgetState(editor, Completion);
|
|
7140
7181
|
};
|
|
@@ -8713,12 +8754,12 @@ const wrapWidgetCommand = (widgetId, fn) => {
|
|
|
8713
8754
|
const widgetCommands = {
|
|
8714
8755
|
'ColorPicker.handleSliderPointerDown': ColorPicker$1,
|
|
8715
8756
|
'ColorPicker.handleSliderPointerMove': ColorPicker$1,
|
|
8716
|
-
'FindWidget.focusNext': Find,
|
|
8717
|
-
'FindWidget.focusPrevious': Find,
|
|
8757
|
+
// 'FindWidget.focusNext': WidgetId.Find,
|
|
8758
|
+
// 'FindWidget.focusPrevious': WidgetId.Find,
|
|
8718
8759
|
'FindWidget.close': Find,
|
|
8719
|
-
'FindWidget.focusIndex': Find,
|
|
8720
|
-
'FindWidget.focusFirst': Find,
|
|
8721
|
-
'FindWidget.focusLast': Find,
|
|
8760
|
+
// 'FindWidget.focusIndex': WidgetId.Find,
|
|
8761
|
+
// 'FindWidget.focusFirst': WidgetId.Find,
|
|
8762
|
+
// 'FindWidget.focusLast': WidgetId.Find,
|
|
8722
8763
|
'FindWidget.toggleReplace': Find,
|
|
8723
8764
|
'FindWidget.handleFocus': Find,
|
|
8724
8765
|
'FindWidget.handleBlur': Find,
|