@lvce-editor/editor-worker 4.4.0 → 4.5.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 +71 -53
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1739,6 +1739,22 @@ const HoverExecute = 'ExtensionHostHover.execute';
|
|
|
1739
1739
|
const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompletionProvider';
|
|
1740
1740
|
const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
|
|
1741
1741
|
|
|
1742
|
+
const ColorPicker$2 = 41;
|
|
1743
|
+
const CompletionDetail$1 = 999;
|
|
1744
|
+
const EditorCompletion = 9;
|
|
1745
|
+
const Empty = 0;
|
|
1746
|
+
const FindWidget = 16;
|
|
1747
|
+
const FocusEditorHover = 51;
|
|
1748
|
+
const FocusEditorRename = 11;
|
|
1749
|
+
const FocusFindWidgetCloseButton = 48;
|
|
1750
|
+
const FocusFindWidgetNextMatchButton = 49;
|
|
1751
|
+
const FocusFindWidgetPreviousMatchButton = 50;
|
|
1752
|
+
const FocusFindWidgetReplace = 43;
|
|
1753
|
+
const FocusFindWidgetReplaceAllButton = 47;
|
|
1754
|
+
const FocusFindWidgetReplaceButton = 46;
|
|
1755
|
+
const FocusFindWidgetToggleReplace = 42;
|
|
1756
|
+
const SourceActions = 38;
|
|
1757
|
+
|
|
1742
1758
|
const measureCharacterWidth = (fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
1743
1759
|
return measureTextWidth('a', fontWeight, fontSize, fontFamily, letterSpacing, false, 0);
|
|
1744
1760
|
};
|
|
@@ -1852,7 +1868,8 @@ const createEditor = async ({
|
|
|
1852
1868
|
charWidth,
|
|
1853
1869
|
uid: id,
|
|
1854
1870
|
id,
|
|
1855
|
-
widgets: []
|
|
1871
|
+
widgets: [],
|
|
1872
|
+
focusKey: Empty
|
|
1856
1873
|
};
|
|
1857
1874
|
// TODO avoid creating intermediate editors here
|
|
1858
1875
|
const newEditor1 = setBounds(editor, x, y, width, height, 9);
|
|
@@ -1930,14 +1947,13 @@ const applyEdit = async (editor, changes) => {
|
|
|
1930
1947
|
};
|
|
1931
1948
|
|
|
1932
1949
|
const handleBlur$2 = editor => {
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
// TODO save on blur
|
|
1937
|
-
// Command.execute(/* Main.save */ 89)
|
|
1950
|
+
if (editor.focusKey !== Empty) {
|
|
1951
|
+
return editor;
|
|
1952
|
+
}
|
|
1938
1953
|
const newEditor = {
|
|
1939
1954
|
...editor,
|
|
1940
|
-
focused: false
|
|
1955
|
+
focused: false,
|
|
1956
|
+
focusKey: Empty
|
|
1941
1957
|
};
|
|
1942
1958
|
return newEditor;
|
|
1943
1959
|
};
|
|
@@ -2258,9 +2274,9 @@ const cancelSelection = editor => {
|
|
|
2258
2274
|
};
|
|
2259
2275
|
|
|
2260
2276
|
// TODO use numeric widget id
|
|
2261
|
-
const ColorPicker$
|
|
2277
|
+
const ColorPicker$1 = 'colorPicker';
|
|
2262
2278
|
const Completion = 'completion';
|
|
2263
|
-
const CompletionDetail
|
|
2279
|
+
const CompletionDetail = 'completionDetail';
|
|
2264
2280
|
const Find = 'find';
|
|
2265
2281
|
const Hover = 'hover';
|
|
2266
2282
|
const Rename = 'rename';
|
|
@@ -2317,6 +2333,7 @@ const closeRename = editor => {
|
|
|
2317
2333
|
const newWidgets = [...widgets.slice(0, renameWidgetIndex), ...widgets.slice(renameWidgetIndex + 1)];
|
|
2318
2334
|
return {
|
|
2319
2335
|
...editor,
|
|
2336
|
+
focused: true,
|
|
2320
2337
|
widgets: newWidgets
|
|
2321
2338
|
};
|
|
2322
2339
|
};
|
|
@@ -2383,9 +2400,12 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
|
|
|
2383
2400
|
} else {
|
|
2384
2401
|
await setAdditionalFocus(focusKey);
|
|
2385
2402
|
}
|
|
2403
|
+
const newFocus = fullFocus ? false : true;
|
|
2386
2404
|
const newEditor = {
|
|
2387
2405
|
...editor,
|
|
2388
|
-
widgets: newWidgets
|
|
2406
|
+
widgets: newWidgets,
|
|
2407
|
+
focusKey,
|
|
2408
|
+
focused: newFocus
|
|
2389
2409
|
};
|
|
2390
2410
|
return newEditor;
|
|
2391
2411
|
};
|
|
@@ -2397,7 +2417,7 @@ const create$7 = () => {
|
|
|
2397
2417
|
const create$6 = () => {
|
|
2398
2418
|
const completionUid = create$7();
|
|
2399
2419
|
const widget = {
|
|
2400
|
-
id: ColorPicker$
|
|
2420
|
+
id: ColorPicker$1,
|
|
2401
2421
|
oldState: {
|
|
2402
2422
|
color: '',
|
|
2403
2423
|
offsetX: 0,
|
|
@@ -2424,27 +2444,11 @@ const create$6 = () => {
|
|
|
2424
2444
|
return widget;
|
|
2425
2445
|
};
|
|
2426
2446
|
|
|
2427
|
-
const ColorPicker$1 = 41;
|
|
2428
|
-
const CompletionDetail = 999;
|
|
2429
|
-
const EditorCompletion = 9;
|
|
2430
|
-
const Empty = 0;
|
|
2431
|
-
const FindWidget = 16;
|
|
2432
|
-
const FocusEditorHover = 51;
|
|
2433
|
-
const FocusEditorRename = 11;
|
|
2434
|
-
const FocusFindWidgetCloseButton = 48;
|
|
2435
|
-
const FocusFindWidgetNextMatchButton = 49;
|
|
2436
|
-
const FocusFindWidgetPreviousMatchButton = 50;
|
|
2437
|
-
const FocusFindWidgetReplace = 43;
|
|
2438
|
-
const FocusFindWidgetReplaceAllButton = 47;
|
|
2439
|
-
const FocusFindWidgetReplaceButton = 46;
|
|
2440
|
-
const FocusFindWidgetToggleReplace = 42;
|
|
2441
|
-
const SourceActions = 38;
|
|
2442
|
-
|
|
2443
2447
|
const newStateGenerator$1 = state => {
|
|
2444
2448
|
return loadContent$3(state);
|
|
2445
2449
|
};
|
|
2446
2450
|
const openColorPicker = async editor => {
|
|
2447
|
-
return addWidgetToEditor(ColorPicker$
|
|
2451
|
+
return addWidgetToEditor(ColorPicker$1, ColorPicker$2, editor, create$6, newStateGenerator$1);
|
|
2448
2452
|
};
|
|
2449
2453
|
|
|
2450
2454
|
const state$6 = {
|
|
@@ -5181,7 +5185,7 @@ const isFind = widget => {
|
|
|
5181
5185
|
};
|
|
5182
5186
|
// TODO don't call renderer worker, set editor state
|
|
5183
5187
|
// TODO this function should be synchronous
|
|
5184
|
-
const focusIndex$
|
|
5188
|
+
const focusIndex$2 = (editor, index) => {
|
|
5185
5189
|
const findState = getFindState(editor);
|
|
5186
5190
|
if (!findState) {
|
|
5187
5191
|
return editor;
|
|
@@ -5224,7 +5228,7 @@ const focusFirst$1 = editor => {
|
|
|
5224
5228
|
if (!findState) {
|
|
5225
5229
|
return editor;
|
|
5226
5230
|
}
|
|
5227
|
-
return focusIndex$
|
|
5231
|
+
return focusIndex$2(editor, 0);
|
|
5228
5232
|
};
|
|
5229
5233
|
const focusLast = editor => {
|
|
5230
5234
|
const findState = getFindState(editor);
|
|
@@ -5234,9 +5238,9 @@ const focusLast = editor => {
|
|
|
5234
5238
|
const {
|
|
5235
5239
|
matchCount
|
|
5236
5240
|
} = findState;
|
|
5237
|
-
return focusIndex$
|
|
5241
|
+
return focusIndex$2(editor, matchCount - 1);
|
|
5238
5242
|
};
|
|
5239
|
-
const focusNext$
|
|
5243
|
+
const focusNext$2 = editor => {
|
|
5240
5244
|
const findState = getFindState(editor);
|
|
5241
5245
|
if (!findState) {
|
|
5242
5246
|
return editor;
|
|
@@ -5248,7 +5252,7 @@ const focusNext$1 = editor => {
|
|
|
5248
5252
|
if (matchIndex === matchCount - 1) {
|
|
5249
5253
|
return focusFirst$1(editor);
|
|
5250
5254
|
}
|
|
5251
|
-
return focusIndex$
|
|
5255
|
+
return focusIndex$2(editor, matchIndex + 1);
|
|
5252
5256
|
};
|
|
5253
5257
|
const focusPrevious$1 = editor => {
|
|
5254
5258
|
const findState = getFindState(editor);
|
|
@@ -5261,7 +5265,7 @@ const focusPrevious$1 = editor => {
|
|
|
5261
5265
|
if (matchIndex === 0) {
|
|
5262
5266
|
return focusLast(editor);
|
|
5263
5267
|
}
|
|
5264
|
-
return focusIndex$
|
|
5268
|
+
return focusIndex$2(editor, matchIndex - 1);
|
|
5265
5269
|
};
|
|
5266
5270
|
|
|
5267
5271
|
const focusNextMatchButton = state => {
|
|
@@ -7561,7 +7565,7 @@ const editorUnindent = editor => {
|
|
|
7561
7565
|
// editor.lines //?
|
|
7562
7566
|
|
|
7563
7567
|
const isCompletionDetailWidget = widget => {
|
|
7564
|
-
return widget.id === CompletionDetail
|
|
7568
|
+
return widget.id === CompletionDetail;
|
|
7565
7569
|
};
|
|
7566
7570
|
const closeDetails = editor => {
|
|
7567
7571
|
const {
|
|
@@ -7578,7 +7582,7 @@ const closeDetails = editor => {
|
|
|
7578
7582
|
};
|
|
7579
7583
|
};
|
|
7580
7584
|
|
|
7581
|
-
const focusIndex = (state, index) => {
|
|
7585
|
+
const focusIndex$1 = (state, index) => {
|
|
7582
7586
|
const newState = {
|
|
7583
7587
|
...state,
|
|
7584
7588
|
focusedIndex: index,
|
|
@@ -7589,17 +7593,17 @@ const focusIndex = (state, index) => {
|
|
|
7589
7593
|
|
|
7590
7594
|
const focusFirst = state => {
|
|
7591
7595
|
const firstIndex = 0;
|
|
7592
|
-
return focusIndex(state, firstIndex);
|
|
7596
|
+
return focusIndex$1(state, firstIndex);
|
|
7593
7597
|
};
|
|
7594
7598
|
|
|
7595
|
-
const focusNext = state => {
|
|
7599
|
+
const focusNext$1 = state => {
|
|
7596
7600
|
const nextIndex = state.focusedIndex + 1;
|
|
7597
|
-
return focusIndex(state, nextIndex);
|
|
7601
|
+
return focusIndex$1(state, nextIndex);
|
|
7598
7602
|
};
|
|
7599
7603
|
|
|
7600
7604
|
const focusPrevious = state => {
|
|
7601
7605
|
const previousIndex = state.focusedIndex - 1;
|
|
7602
|
-
return focusIndex(state, previousIndex);
|
|
7606
|
+
return focusIndex$1(state, previousIndex);
|
|
7603
7607
|
};
|
|
7604
7608
|
|
|
7605
7609
|
// TODO optimize this function to return the minimum number
|
|
@@ -7649,7 +7653,7 @@ const handelWheel = (state, deltaMode, deltaY) => {
|
|
|
7649
7653
|
const create = () => {
|
|
7650
7654
|
const completionUid = create$7();
|
|
7651
7655
|
const completionWidget = {
|
|
7652
|
-
id: CompletionDetail
|
|
7656
|
+
id: CompletionDetail,
|
|
7653
7657
|
oldState: {
|
|
7654
7658
|
content: '',
|
|
7655
7659
|
uid: completionUid,
|
|
@@ -7700,7 +7704,7 @@ const openDetails = editor => {
|
|
|
7700
7704
|
};
|
|
7701
7705
|
return newestState;
|
|
7702
7706
|
};
|
|
7703
|
-
return addWidgetToEditor(CompletionDetail
|
|
7707
|
+
return addWidgetToEditor(CompletionDetail, CompletionDetail$1, editor, create, newStateGenerator);
|
|
7704
7708
|
};
|
|
7705
7709
|
|
|
7706
7710
|
const getEdits = async (editor, completionItem) => {
|
|
@@ -7781,7 +7785,7 @@ const selectCurrent = editor => {
|
|
|
7781
7785
|
};
|
|
7782
7786
|
|
|
7783
7787
|
const getCompletionDetailState = editor => {
|
|
7784
|
-
return getWidgetState(editor, CompletionDetail
|
|
7788
|
+
return getWidgetState(editor, CompletionDetail);
|
|
7785
7789
|
};
|
|
7786
7790
|
|
|
7787
7791
|
const toggleDetails = editor => {
|
|
@@ -8021,6 +8025,19 @@ const handleBlur = editor => {
|
|
|
8021
8025
|
return closeRename(editor);
|
|
8022
8026
|
};
|
|
8023
8027
|
|
|
8028
|
+
const focusIndex = (state, index) => {
|
|
8029
|
+
const newState = {
|
|
8030
|
+
...state,
|
|
8031
|
+
focusedIndex: index
|
|
8032
|
+
};
|
|
8033
|
+
return newState;
|
|
8034
|
+
};
|
|
8035
|
+
|
|
8036
|
+
const focusNext = state => {
|
|
8037
|
+
const nextIndex = state.focusedIndex + 1;
|
|
8038
|
+
return focusIndex(state, nextIndex);
|
|
8039
|
+
};
|
|
8040
|
+
|
|
8024
8041
|
const replaceTextOccurrences = (editor, matches, oldValue, newValue) => {
|
|
8025
8042
|
const ranges = [];
|
|
8026
8043
|
const oldValueLength = oldValue.length;
|
|
@@ -9076,8 +9093,8 @@ const wrapWidgetCommand = (widgetId, fn) => {
|
|
|
9076
9093
|
};
|
|
9077
9094
|
|
|
9078
9095
|
const widgetCommands = {
|
|
9079
|
-
'ColorPicker.handleSliderPointerDown': ColorPicker$
|
|
9080
|
-
'ColorPicker.handleSliderPointerMove': ColorPicker$
|
|
9096
|
+
'ColorPicker.handleSliderPointerDown': ColorPicker$1,
|
|
9097
|
+
'ColorPicker.handleSliderPointerMove': ColorPicker$1,
|
|
9081
9098
|
// 'FindWidget.focusNext': WidgetId.Find,
|
|
9082
9099
|
// 'FindWidget.focusPrevious': WidgetId.Find,
|
|
9083
9100
|
'FindWidget.close': Find,
|
|
@@ -9267,8 +9284,8 @@ const commandMap = {
|
|
|
9267
9284
|
'EditorCompletion.advance': advance,
|
|
9268
9285
|
'EditorCompletion.closeDetails': closeDetails,
|
|
9269
9286
|
'EditorCompletion.focusFirst': focusFirst,
|
|
9270
|
-
'EditorCompletion.focusIndex': focusIndex,
|
|
9271
|
-
'EditorCompletion.focusNext': focusNext,
|
|
9287
|
+
'EditorCompletion.focusIndex': focusIndex$1,
|
|
9288
|
+
'EditorCompletion.focusNext': focusNext$1,
|
|
9272
9289
|
'EditorCompletion.focusPrevious': focusPrevious,
|
|
9273
9290
|
'EditorCompletion.handleEditorBlur': handleEditorBlur,
|
|
9274
9291
|
'EditorCompletion.handleEditorClick': handleEditorClick,
|
|
@@ -9281,13 +9298,14 @@ const commandMap = {
|
|
|
9281
9298
|
'EditorCompletion.selectIndex': selectIndex,
|
|
9282
9299
|
'EditorCompletion.toggleDetails': toggleDetails,
|
|
9283
9300
|
'EditorRename.handleBlur': handleBlur,
|
|
9301
|
+
'EditorSourceActions.focusNext': focusNext,
|
|
9284
9302
|
'FindWidget.close': close$1,
|
|
9285
9303
|
'FindWidget.focusCloseButton': focusCloseButton,
|
|
9286
9304
|
'FindWidget.focusFind': focusFind,
|
|
9287
9305
|
'FindWidget.focusFirst': focusFirst$1,
|
|
9288
|
-
'FindWidget.focusIndex': focusIndex$
|
|
9306
|
+
'FindWidget.focusIndex': focusIndex$2,
|
|
9289
9307
|
'FindWidget.focusLast': focusLast,
|
|
9290
|
-
'FindWidget.focusNext': focusNext$
|
|
9308
|
+
'FindWidget.focusNext': focusNext$2,
|
|
9291
9309
|
'FindWidget.focusNextMatchButton': focusNextMatchButton,
|
|
9292
9310
|
'FindWidget.focusPrevious': focusPrevious$1,
|
|
9293
9311
|
'FindWidget.focusPreviousMatchButton': focusPreviousMatchButton,
|
|
@@ -10783,9 +10801,9 @@ const add$3 = widget => {
|
|
|
10783
10801
|
const remove$3 = removeWidget;
|
|
10784
10802
|
const Commands = {
|
|
10785
10803
|
'FindWidget.close': close$1,
|
|
10786
|
-
'FindWidget.focusNext': focusNext$
|
|
10804
|
+
'FindWidget.focusNext': focusNext$2,
|
|
10787
10805
|
'FindWidget.focusPrevious': focusPrevious$1,
|
|
10788
|
-
'FindWidget.focusIndex': focusIndex$
|
|
10806
|
+
'FindWidget.focusIndex': focusIndex$2,
|
|
10789
10807
|
'FindWidget.focusLast': focusLast,
|
|
10790
10808
|
'FindWidget.toggleReplace': toggleReplace,
|
|
10791
10809
|
'FindWidget.handleFocus': focusFind,
|
|
@@ -11012,9 +11030,9 @@ const EditorSourceActionWidget = {
|
|
|
11012
11030
|
};
|
|
11013
11031
|
|
|
11014
11032
|
const registerWidgets = () => {
|
|
11015
|
-
set$7(ColorPicker$
|
|
11033
|
+
set$7(ColorPicker$1, EditorColorPickerWidget);
|
|
11016
11034
|
set$7(Completion, EditorCompletionWidget);
|
|
11017
|
-
set$7(CompletionDetail
|
|
11035
|
+
set$7(CompletionDetail, EditorCompletionDetailWidget);
|
|
11018
11036
|
set$7(Find, EditorFindWidget);
|
|
11019
11037
|
set$7(Hover, EditorHoverWidget);
|
|
11020
11038
|
set$7(Rename, EditorRenameWidget);
|