@lvce-editor/editor-worker 3.14.0 → 3.15.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 +145 -142
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -3627,7 +3627,7 @@ const handleDoubleClick = (editor, modifier, x, y) => {
|
|
|
3627
3627
|
};
|
|
3628
3628
|
|
|
3629
3629
|
const WhenExpressionEditorText = 12;
|
|
3630
|
-
const handleFocus
|
|
3630
|
+
const handleFocus = editor => {
|
|
3631
3631
|
// TODO make change events functional,
|
|
3632
3632
|
// when rendering, send focus changes to renderer worker
|
|
3633
3633
|
invoke$3('Focus.setFocus', WhenExpressionEditorText);
|
|
@@ -3644,7 +3644,7 @@ const state$5 = {
|
|
|
3644
3644
|
columnIndex: 0
|
|
3645
3645
|
}
|
|
3646
3646
|
};
|
|
3647
|
-
const getPosition$
|
|
3647
|
+
const getPosition$1 = () => {
|
|
3648
3648
|
return state$5.position;
|
|
3649
3649
|
};
|
|
3650
3650
|
|
|
@@ -3964,7 +3964,7 @@ const setPosition = position => {
|
|
|
3964
3964
|
const getEditor$1 = () => {
|
|
3965
3965
|
return state$3.currentEditor;
|
|
3966
3966
|
};
|
|
3967
|
-
const getPosition
|
|
3967
|
+
const getPosition = () => {
|
|
3968
3968
|
return state$3.position;
|
|
3969
3969
|
};
|
|
3970
3970
|
const hasListener = () => {
|
|
@@ -4209,7 +4209,7 @@ const getNewSelections$5 = (anchor, position) => {
|
|
|
4209
4209
|
|
|
4210
4210
|
// @ts-ignore
|
|
4211
4211
|
const editorMoveSelection = (editor, position) => {
|
|
4212
|
-
const anchor = getPosition$
|
|
4212
|
+
const anchor = getPosition$1();
|
|
4213
4213
|
const newSelections = getNewSelections$5(anchor, position);
|
|
4214
4214
|
// TODO if selection equals previous selection -> do nothing
|
|
4215
4215
|
return scheduleSelections(editor, newSelections);
|
|
@@ -4496,7 +4496,7 @@ const getNewEditor$1 = (editor, position) => {
|
|
|
4496
4496
|
const newMinLineY = position.rowIndex;
|
|
4497
4497
|
const newMaxLineY = position.rowIndex + diff;
|
|
4498
4498
|
const newDeltaY = position.rowIndex * rowHeight;
|
|
4499
|
-
const anchor = getPosition$
|
|
4499
|
+
const anchor = getPosition$1();
|
|
4500
4500
|
const newSelections = new Uint32Array([position.rowIndex - 1, position.columnIndex, anchor.rowIndex, anchor.columnIndex]);
|
|
4501
4501
|
return {
|
|
4502
4502
|
...editor,
|
|
@@ -4511,7 +4511,7 @@ const getNewEditor$1 = (editor, position) => {
|
|
|
4511
4511
|
const newMinLineY = position.rowIndex - diff;
|
|
4512
4512
|
const newMaxLineY = position.rowIndex;
|
|
4513
4513
|
const newDeltaY = newMinLineY * rowHeight;
|
|
4514
|
-
const anchor = getPosition$
|
|
4514
|
+
const anchor = getPosition$1();
|
|
4515
4515
|
const newSelections = new Uint32Array([anchor.rowIndex, anchor.columnIndex, position.rowIndex + 1, position.columnIndex]);
|
|
4516
4516
|
return {
|
|
4517
4517
|
...editor,
|
|
@@ -4528,7 +4528,7 @@ const continueScrollingAndMovingSelection = async () => {
|
|
|
4528
4528
|
if (!editor) {
|
|
4529
4529
|
return;
|
|
4530
4530
|
}
|
|
4531
|
-
const position = getPosition
|
|
4531
|
+
const position = getPosition();
|
|
4532
4532
|
if (position.rowIndex === 0) {
|
|
4533
4533
|
return;
|
|
4534
4534
|
}
|
|
@@ -5169,22 +5169,14 @@ const findMatchesCaseInsensitive = (lines, searchString) => {
|
|
|
5169
5169
|
return findRegexMatches(lines, regex);
|
|
5170
5170
|
};
|
|
5171
5171
|
|
|
5172
|
-
const getFindWidgetHeight = replaceExpanded => {
|
|
5173
|
-
const collapsedHeight = 30;
|
|
5174
|
-
const expandedHeight = 60;
|
|
5175
|
-
const newHeight = replaceExpanded ? expandedHeight : collapsedHeight;
|
|
5176
|
-
return newHeight;
|
|
5177
|
-
};
|
|
5178
|
-
|
|
5179
5172
|
const getMatchCount = matches => {
|
|
5180
5173
|
return matches.length / 2;
|
|
5181
5174
|
};
|
|
5182
5175
|
|
|
5183
|
-
const setFindWidgetFocus =
|
|
5176
|
+
const setFindWidgetFocus = (state, focusKey) => {
|
|
5184
5177
|
if (state.focus === focusKey) {
|
|
5185
5178
|
return state;
|
|
5186
5179
|
}
|
|
5187
|
-
await setFocus(focusKey);
|
|
5188
5180
|
return {
|
|
5189
5181
|
...state,
|
|
5190
5182
|
focus: focusKey,
|
|
@@ -5192,88 +5184,15 @@ const setFindWidgetFocus = async (state, focusKey) => {
|
|
|
5192
5184
|
};
|
|
5193
5185
|
};
|
|
5194
5186
|
|
|
5195
|
-
const
|
|
5196
|
-
|
|
5197
|
-
const height = 30;
|
|
5198
|
-
const paddingTop = 10;
|
|
5199
|
-
const paddingRight = 20;
|
|
5200
|
-
const x = editor.x + editor.width - width - paddingRight;
|
|
5201
|
-
const y = editor.y + paddingTop;
|
|
5202
|
-
return {
|
|
5203
|
-
y,
|
|
5204
|
-
x,
|
|
5205
|
-
width,
|
|
5206
|
-
height
|
|
5207
|
-
};
|
|
5208
|
-
};
|
|
5209
|
-
const loadContent$1 = editorId => {
|
|
5210
|
-
const editor = getEditor(editorId);
|
|
5211
|
-
const {
|
|
5212
|
-
selections,
|
|
5213
|
-
lines
|
|
5214
|
-
} = editor;
|
|
5215
|
-
const startRowIndex = selections[0];
|
|
5216
|
-
const startColumnIndex = selections[1];
|
|
5217
|
-
const endColumnIndex = selections[3];
|
|
5218
|
-
const line = lines[startRowIndex];
|
|
5219
|
-
const value = line.slice(startColumnIndex, endColumnIndex);
|
|
5220
|
-
const matches = findMatchesCaseInsensitive(lines, value);
|
|
5221
|
-
const matchCount = getMatchCount(matches);
|
|
5222
|
-
return {
|
|
5223
|
-
value,
|
|
5224
|
-
matches,
|
|
5225
|
-
matchIndex: 0,
|
|
5226
|
-
matchCount,
|
|
5227
|
-
editorUid: editor.uid
|
|
5228
|
-
};
|
|
5229
|
-
};
|
|
5230
|
-
const refresh = (state, value = state.value) => {
|
|
5231
|
-
// TODO get focused editor
|
|
5232
|
-
const {
|
|
5233
|
-
editorUid
|
|
5234
|
-
} = state;
|
|
5235
|
-
// highlight locations that match value
|
|
5236
|
-
const editor = getEditor(editorUid);
|
|
5237
|
-
const {
|
|
5238
|
-
lines
|
|
5239
|
-
} = editor;
|
|
5240
|
-
const matches = findMatchesCaseInsensitive(lines, value);
|
|
5241
|
-
const matchCount = getMatchCount(matches);
|
|
5242
|
-
return {
|
|
5243
|
-
...state,
|
|
5244
|
-
matches,
|
|
5245
|
-
matchIndex: 0,
|
|
5246
|
-
matchCount,
|
|
5247
|
-
value
|
|
5248
|
-
};
|
|
5249
|
-
};
|
|
5250
|
-
const handleInput = (state, value) => {
|
|
5251
|
-
return refresh(state, value);
|
|
5252
|
-
};
|
|
5253
|
-
const handleFocus = async state => {
|
|
5254
|
-
if (state.focus === FindWidget) {
|
|
5255
|
-
return state;
|
|
5256
|
-
}
|
|
5257
|
-
await setFocus(FindWidget);
|
|
5258
|
-
return {
|
|
5259
|
-
...state,
|
|
5260
|
-
focus: FindWidget
|
|
5261
|
-
};
|
|
5262
|
-
};
|
|
5263
|
-
const handleBlur = async state => {
|
|
5264
|
-
await setFocus(Empty);
|
|
5265
|
-
return state;
|
|
5187
|
+
const focusCloseButton = state => {
|
|
5188
|
+
return setFindWidgetFocus(state, FocusFindWidgetCloseButton);
|
|
5266
5189
|
};
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
return {
|
|
5271
|
-
...state,
|
|
5272
|
-
replaceExpanded: !state.replaceExpanded,
|
|
5273
|
-
height: newHeight
|
|
5274
|
-
};
|
|
5190
|
+
|
|
5191
|
+
const focusFind = state => {
|
|
5192
|
+
return setFindWidgetFocus(state, FindWidget);
|
|
5275
5193
|
};
|
|
5276
5194
|
|
|
5195
|
+
// TODO don't call renderer worker, set editor state
|
|
5277
5196
|
// TODO this function should be synchronous
|
|
5278
5197
|
const focusIndex$1 = async (state, index) => {
|
|
5279
5198
|
const {
|
|
@@ -5326,6 +5245,116 @@ const focusPrevious$1 = state => {
|
|
|
5326
5245
|
}
|
|
5327
5246
|
return focusIndex$1(state, matchIndex - 1);
|
|
5328
5247
|
};
|
|
5248
|
+
|
|
5249
|
+
const focusNextMatchButton = state => {
|
|
5250
|
+
return setFindWidgetFocus(state, FocusFindWidgetNextMatchButton);
|
|
5251
|
+
};
|
|
5252
|
+
|
|
5253
|
+
const focusPreviousMatchButton = state => {
|
|
5254
|
+
return setFindWidgetFocus(state, FocusFindWidgetPreviousMatchButton);
|
|
5255
|
+
};
|
|
5256
|
+
|
|
5257
|
+
const focusReplace = state => {
|
|
5258
|
+
return setFindWidgetFocus(state, FocusFindWidgetReplace);
|
|
5259
|
+
};
|
|
5260
|
+
|
|
5261
|
+
const focusReplaceAllButton = state => {
|
|
5262
|
+
return setFindWidgetFocus(state, FocusFindWidgetReplaceAllButton);
|
|
5263
|
+
};
|
|
5264
|
+
|
|
5265
|
+
const focusReplaceButton = state => {
|
|
5266
|
+
return setFindWidgetFocus(state, FocusFindWidgetReplaceButton);
|
|
5267
|
+
};
|
|
5268
|
+
|
|
5269
|
+
const focusToggleReplaceButton = state => {
|
|
5270
|
+
return setFindWidgetFocus(state, FocusFindWidgetToggleReplace);
|
|
5271
|
+
};
|
|
5272
|
+
|
|
5273
|
+
const handleBlur = async state => {
|
|
5274
|
+
await setFocus(Empty);
|
|
5275
|
+
return state;
|
|
5276
|
+
};
|
|
5277
|
+
|
|
5278
|
+
const handleFindWidgetFocus = (state, focusKey) => {
|
|
5279
|
+
if (state.focus === focusKey) {
|
|
5280
|
+
return state;
|
|
5281
|
+
}
|
|
5282
|
+
return {
|
|
5283
|
+
...state,
|
|
5284
|
+
focus: focusKey,
|
|
5285
|
+
focusSource: User
|
|
5286
|
+
};
|
|
5287
|
+
};
|
|
5288
|
+
|
|
5289
|
+
const handleReplaceAllFocus = state => {
|
|
5290
|
+
return handleFindWidgetFocus(state, FocusFindWidgetReplaceAllButton);
|
|
5291
|
+
};
|
|
5292
|
+
|
|
5293
|
+
const handleReplaceFocus = state => {
|
|
5294
|
+
return handleFindWidgetFocus(state, FocusFindWidgetReplace);
|
|
5295
|
+
};
|
|
5296
|
+
|
|
5297
|
+
const getFindWidgetHeight = replaceExpanded => {
|
|
5298
|
+
const collapsedHeight = 30;
|
|
5299
|
+
const expandedHeight = 60;
|
|
5300
|
+
const newHeight = replaceExpanded ? expandedHeight : collapsedHeight;
|
|
5301
|
+
return newHeight;
|
|
5302
|
+
};
|
|
5303
|
+
|
|
5304
|
+
const toggleReplace = state => {
|
|
5305
|
+
const newExpanded = !state.replaceExpanded;
|
|
5306
|
+
const newHeight = getFindWidgetHeight(newExpanded);
|
|
5307
|
+
return {
|
|
5308
|
+
...state,
|
|
5309
|
+
replaceExpanded: !state.replaceExpanded,
|
|
5310
|
+
height: newHeight
|
|
5311
|
+
};
|
|
5312
|
+
};
|
|
5313
|
+
|
|
5314
|
+
const loadContent$1 = editorId => {
|
|
5315
|
+
const editor = getEditor(editorId);
|
|
5316
|
+
const {
|
|
5317
|
+
selections,
|
|
5318
|
+
lines
|
|
5319
|
+
} = editor;
|
|
5320
|
+
const startRowIndex = selections[0];
|
|
5321
|
+
const startColumnIndex = selections[1];
|
|
5322
|
+
const endColumnIndex = selections[3];
|
|
5323
|
+
const line = lines[startRowIndex];
|
|
5324
|
+
const value = line.slice(startColumnIndex, endColumnIndex);
|
|
5325
|
+
const matches = findMatchesCaseInsensitive(lines, value);
|
|
5326
|
+
const matchCount = getMatchCount(matches);
|
|
5327
|
+
return {
|
|
5328
|
+
value,
|
|
5329
|
+
matches,
|
|
5330
|
+
matchIndex: 0,
|
|
5331
|
+
matchCount,
|
|
5332
|
+
editorUid: editor.uid
|
|
5333
|
+
};
|
|
5334
|
+
};
|
|
5335
|
+
const refresh = (state, value = state.value) => {
|
|
5336
|
+
// TODO get focused editor
|
|
5337
|
+
const {
|
|
5338
|
+
editorUid
|
|
5339
|
+
} = state;
|
|
5340
|
+
// highlight locations that match value
|
|
5341
|
+
const editor = getEditor(editorUid);
|
|
5342
|
+
const {
|
|
5343
|
+
lines
|
|
5344
|
+
} = editor;
|
|
5345
|
+
const matches = findMatchesCaseInsensitive(lines, value);
|
|
5346
|
+
const matchCount = getMatchCount(matches);
|
|
5347
|
+
return {
|
|
5348
|
+
...state,
|
|
5349
|
+
matches,
|
|
5350
|
+
matchIndex: 0,
|
|
5351
|
+
matchCount,
|
|
5352
|
+
value
|
|
5353
|
+
};
|
|
5354
|
+
};
|
|
5355
|
+
const handleInput = (state, value) => {
|
|
5356
|
+
return refresh(state, value);
|
|
5357
|
+
};
|
|
5329
5358
|
const close$1 = async state => {
|
|
5330
5359
|
// TODO
|
|
5331
5360
|
// await Viewlet.closeWidget(uid)
|
|
@@ -5344,55 +5373,25 @@ const handleToggleReplaceFocus = async state => {
|
|
|
5344
5373
|
focus: FocusFindWidgetToggleReplace
|
|
5345
5374
|
};
|
|
5346
5375
|
};
|
|
5347
|
-
const handleReplaceFocus = async state => {
|
|
5348
|
-
if (state.focus === FocusFindWidgetReplace) {
|
|
5349
|
-
return state;
|
|
5350
|
-
}
|
|
5351
|
-
await setFocus(FocusFindWidgetReplace);
|
|
5352
|
-
return {
|
|
5353
|
-
...state,
|
|
5354
|
-
focus: FocusFindWidgetReplace,
|
|
5355
|
-
focusSource: User
|
|
5356
|
-
};
|
|
5357
|
-
};
|
|
5358
|
-
const focusReplace = state => {
|
|
5359
|
-
return setFindWidgetFocus(state, FocusFindWidgetReplace);
|
|
5360
|
-
};
|
|
5361
|
-
const focusFind = state => {
|
|
5362
|
-
return setFindWidgetFocus(state, FindWidget);
|
|
5363
|
-
};
|
|
5364
5376
|
const handleReplaceInput = state => {
|
|
5365
5377
|
// TODO
|
|
5366
5378
|
return state;
|
|
5367
5379
|
};
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
const
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5380
|
+
|
|
5381
|
+
const getFindWidgetPosition = editor => {
|
|
5382
|
+
const width = 300;
|
|
5383
|
+
const height = 30;
|
|
5384
|
+
const paddingTop = 10;
|
|
5385
|
+
const paddingRight = 20;
|
|
5386
|
+
const x = editor.x + editor.width - width - paddingRight;
|
|
5387
|
+
const y = editor.y + paddingTop;
|
|
5376
5388
|
return {
|
|
5377
|
-
|
|
5378
|
-
|
|
5389
|
+
y,
|
|
5390
|
+
x,
|
|
5391
|
+
width,
|
|
5392
|
+
height
|
|
5379
5393
|
};
|
|
5380
5394
|
};
|
|
5381
|
-
const focusReplaceButton = state => {
|
|
5382
|
-
return setFindWidgetFocus(state, FocusFindWidgetReplaceButton);
|
|
5383
|
-
};
|
|
5384
|
-
const focusReplaceAllButton = state => {
|
|
5385
|
-
return setFindWidgetFocus(state, FocusFindWidgetReplaceAllButton);
|
|
5386
|
-
};
|
|
5387
|
-
const focusPreviousMatchButton = state => {
|
|
5388
|
-
return setFindWidgetFocus(state, FocusFindWidgetPreviousMatchButton);
|
|
5389
|
-
};
|
|
5390
|
-
const focusNextMatchButton = state => {
|
|
5391
|
-
return setFindWidgetFocus(state, FocusFindWidgetNextMatchButton);
|
|
5392
|
-
};
|
|
5393
|
-
const focusCloseButton = state => {
|
|
5394
|
-
return setFindWidgetFocus(state, FocusFindWidgetCloseButton);
|
|
5395
|
-
};
|
|
5396
5395
|
|
|
5397
5396
|
const openFind2 = async editor => {
|
|
5398
5397
|
const newStateGenerator = async state => {
|
|
@@ -5407,7 +5406,7 @@ const openFind2 = async editor => {
|
|
|
5407
5406
|
y,
|
|
5408
5407
|
width,
|
|
5409
5408
|
height
|
|
5410
|
-
} =
|
|
5409
|
+
} = getFindWidgetPosition(editor);
|
|
5411
5410
|
const latestState = {
|
|
5412
5411
|
...state,
|
|
5413
5412
|
value,
|
|
@@ -8817,7 +8816,7 @@ const commandMap = {
|
|
|
8817
8816
|
'Editor.handleBlur': handleBlur$1,
|
|
8818
8817
|
'Editor.handleContextMenu': handleContextMenu,
|
|
8819
8818
|
'Editor.handleDoubleClick': handleDoubleClick,
|
|
8820
|
-
'Editor.handleFocus': handleFocus
|
|
8819
|
+
'Editor.handleFocus': handleFocus,
|
|
8821
8820
|
'Editor.handleMouseDown': handleMouseDown,
|
|
8822
8821
|
'Editor.handleMouseMove': handleMouseMove,
|
|
8823
8822
|
'Editor.handleMouseMoveWithAltKey': handleMouseMoveWithAltKey,
|
|
@@ -8915,9 +8914,9 @@ const commandMap = {
|
|
|
8915
8914
|
'FindWidget.focusReplace': focusReplace,
|
|
8916
8915
|
'FindWidget.focusReplaceAllButton': focusReplaceAllButton,
|
|
8917
8916
|
'FindWidget.focusReplaceButton': focusReplaceButton,
|
|
8918
|
-
'FindWidget.focusToggleReplace':
|
|
8917
|
+
'FindWidget.focusToggleReplace': focusToggleReplaceButton,
|
|
8919
8918
|
'FindWidget.handleBlur': handleBlur,
|
|
8920
|
-
'FindWidget.handleFocus':
|
|
8919
|
+
'FindWidget.handleFocus': handleFindWidgetFocus,
|
|
8921
8920
|
'FindWidget.handleInput': handleInput,
|
|
8922
8921
|
'FindWidget.handleReplaceAllFocus': handleReplaceAllFocus,
|
|
8923
8922
|
'FindWidget.handleReplaceFocus': handleReplaceFocus,
|
|
@@ -10302,6 +10301,10 @@ const renderFocus = {
|
|
|
10302
10301
|
|
|
10303
10302
|
const render$1 = [renderDetails, renderBounds, renderValue, renderFocus];
|
|
10304
10303
|
const apply = (oldState, newState) => {
|
|
10304
|
+
// TODO avoid side effect
|
|
10305
|
+
if (oldState.focus !== newState.focus) {
|
|
10306
|
+
setFocus(newState.focus);
|
|
10307
|
+
}
|
|
10305
10308
|
return renderParts(render$1, oldState, newState);
|
|
10306
10309
|
};
|
|
10307
10310
|
|
|
@@ -10329,7 +10332,7 @@ const Commands = {
|
|
|
10329
10332
|
'FindWidget.focusIndex': focusIndex$1,
|
|
10330
10333
|
'FindWidget.focusLast': focusLast,
|
|
10331
10334
|
'FindWidget.toggleReplace': toggleReplace,
|
|
10332
|
-
'FindWidget.handleFocus':
|
|
10335
|
+
'FindWidget.handleFocus': focusFind,
|
|
10333
10336
|
'FindWidget.handleBlur': handleBlur
|
|
10334
10337
|
};
|
|
10335
10338
|
|