@lvce-editor/editor-worker 3.24.0 → 3.26.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 +109 -74
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -422,7 +422,7 @@ const positionAt = (textDocument, offset) => {
|
|
|
422
422
|
};
|
|
423
423
|
|
|
424
424
|
// TODO this should be in a separate scrolling module
|
|
425
|
-
const setDeltaY$
|
|
425
|
+
const setDeltaY$3 = (state, value) => {
|
|
426
426
|
object(state);
|
|
427
427
|
number$1(value);
|
|
428
428
|
const {
|
|
@@ -461,6 +461,7 @@ const getSelectionPairs = (selections, i) => {
|
|
|
461
461
|
};
|
|
462
462
|
|
|
463
463
|
const EmptyString$1 = '';
|
|
464
|
+
const NewLine$4 = '\n';
|
|
464
465
|
const Space$1 = ' ';
|
|
465
466
|
const Tab = '\t';
|
|
466
467
|
const DoubleQuote$1 = '"';
|
|
@@ -824,9 +825,9 @@ const applyEdit$1 = (editor, changes) => {
|
|
|
824
825
|
|
|
825
826
|
// TODO
|
|
826
827
|
const setDeltaYFixedValue$1 = (editor, value) => {
|
|
827
|
-
return setDeltaY$
|
|
828
|
+
return setDeltaY$3(editor, value);
|
|
828
829
|
};
|
|
829
|
-
const setDeltaY$
|
|
830
|
+
const setDeltaY$2 = (editor, value) => {
|
|
830
831
|
return setDeltaYFixedValue$1(editor, editor.deltaY + value);
|
|
831
832
|
};
|
|
832
833
|
const isAutoClosingChange = change => {
|
|
@@ -1854,7 +1855,7 @@ const createEditor = async ({
|
|
|
1854
1855
|
// TODO avoid creating intermediate editors here
|
|
1855
1856
|
const newEditor1 = setBounds(editor, x, y, width, height, 9);
|
|
1856
1857
|
const newEditor2 = setText(newEditor1, content);
|
|
1857
|
-
const newEditor3 = setDeltaY$
|
|
1858
|
+
const newEditor3 = setDeltaY$3(newEditor2, 0);
|
|
1858
1859
|
const newEditor4 = {
|
|
1859
1860
|
...newEditor3,
|
|
1860
1861
|
focused: true
|
|
@@ -2281,13 +2282,31 @@ const closeCompletion = editor => {
|
|
|
2281
2282
|
};
|
|
2282
2283
|
|
|
2283
2284
|
const isMatchingWidget$1 = widget => {
|
|
2285
|
+
return widget.id === Find;
|
|
2286
|
+
};
|
|
2287
|
+
const closeFind = editor => {
|
|
2288
|
+
const {
|
|
2289
|
+
widgets
|
|
2290
|
+
} = editor;
|
|
2291
|
+
const index = widgets.findIndex(isMatchingWidget$1);
|
|
2292
|
+
if (index === -1) {
|
|
2293
|
+
return editor;
|
|
2294
|
+
}
|
|
2295
|
+
const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
|
|
2296
|
+
return {
|
|
2297
|
+
...editor,
|
|
2298
|
+
widgets: newWidgets
|
|
2299
|
+
};
|
|
2300
|
+
};
|
|
2301
|
+
|
|
2302
|
+
const isMatchingWidget = widget => {
|
|
2284
2303
|
return widget.id === SourceAction;
|
|
2285
2304
|
};
|
|
2286
2305
|
const closeSourceAction = editor => {
|
|
2287
2306
|
const {
|
|
2288
2307
|
widgets
|
|
2289
2308
|
} = editor;
|
|
2290
|
-
const index = widgets.findIndex(isMatchingWidget
|
|
2309
|
+
const index = widgets.findIndex(isMatchingWidget);
|
|
2291
2310
|
if (index === -1) {
|
|
2292
2311
|
return editor;
|
|
2293
2312
|
}
|
|
@@ -4135,8 +4154,8 @@ const handleTouchEnd = (editor, touchEvent) => {
|
|
|
4135
4154
|
};
|
|
4136
4155
|
|
|
4137
4156
|
// @ts-ignore
|
|
4138
|
-
const setDeltaY = (editor, deltaY) => {
|
|
4139
|
-
return setDeltaY$
|
|
4157
|
+
const setDeltaY$1 = (editor, deltaY) => {
|
|
4158
|
+
return setDeltaY$2(editor, deltaY);
|
|
4140
4159
|
};
|
|
4141
4160
|
|
|
4142
4161
|
// @ts-ignore
|
|
@@ -4155,11 +4174,11 @@ const setDelta = (editor, deltaMode, eventDeltaX, eventDeltaY) => {
|
|
|
4155
4174
|
deltaY
|
|
4156
4175
|
} = editor;
|
|
4157
4176
|
if (eventDeltaX === 0) {
|
|
4158
|
-
return setDeltaY(editor, eventDeltaY);
|
|
4177
|
+
return setDeltaY$1(editor, eventDeltaY);
|
|
4159
4178
|
}
|
|
4160
4179
|
const newDeltaX = clamp(deltaX + eventDeltaX, 0, Number.POSITIVE_INFINITY);
|
|
4161
4180
|
return {
|
|
4162
|
-
...setDeltaY(editor, eventDeltaY),
|
|
4181
|
+
...setDeltaY$1(editor, eventDeltaY),
|
|
4163
4182
|
deltaX: newDeltaX
|
|
4164
4183
|
};
|
|
4165
4184
|
};
|
|
@@ -4476,7 +4495,11 @@ const create$4 = () => {
|
|
|
4476
4495
|
x: 0,
|
|
4477
4496
|
y: 0,
|
|
4478
4497
|
width: 0,
|
|
4479
|
-
height: 0
|
|
4498
|
+
height: 0,
|
|
4499
|
+
deltaY: 0,
|
|
4500
|
+
finalDeltaY: 0,
|
|
4501
|
+
focused: false,
|
|
4502
|
+
headerHeight: 0
|
|
4480
4503
|
},
|
|
4481
4504
|
newState: {
|
|
4482
4505
|
items: [],
|
|
@@ -4489,7 +4512,11 @@ const create$4 = () => {
|
|
|
4489
4512
|
x: 0,
|
|
4490
4513
|
y: 0,
|
|
4491
4514
|
width: 0,
|
|
4492
|
-
height: 0
|
|
4515
|
+
height: 0,
|
|
4516
|
+
deltaY: 0,
|
|
4517
|
+
finalDeltaY: 0,
|
|
4518
|
+
headerHeight: 0,
|
|
4519
|
+
focused: false
|
|
4493
4520
|
}
|
|
4494
4521
|
};
|
|
4495
4522
|
return completionWidget;
|
|
@@ -7406,57 +7433,72 @@ const closeDetails = editor => {
|
|
|
7406
7433
|
};
|
|
7407
7434
|
};
|
|
7408
7435
|
|
|
7409
|
-
const
|
|
7410
|
-
|
|
7436
|
+
const focusIndex = (state, index) => {
|
|
7437
|
+
const newState = {
|
|
7438
|
+
...state,
|
|
7439
|
+
focusedIndex: index,
|
|
7440
|
+
focused: true
|
|
7441
|
+
};
|
|
7442
|
+
return newState;
|
|
7411
7443
|
};
|
|
7412
7444
|
|
|
7413
|
-
const
|
|
7414
|
-
|
|
7445
|
+
const focusFirst = state => {
|
|
7446
|
+
const firstIndex = 0;
|
|
7447
|
+
return focusIndex(state, firstIndex);
|
|
7415
7448
|
};
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
}
|
|
7421
|
-
const childIndex = editor.widgets.findIndex(isCompletion$1);
|
|
7422
|
-
// TODO scroll up/down if necessary
|
|
7423
|
-
const childWidget = editor.widgets[childIndex];
|
|
7424
|
-
const newWidget = {
|
|
7425
|
-
...childWidget,
|
|
7426
|
-
newState: {
|
|
7427
|
-
...child,
|
|
7428
|
-
focusedIndex: index,
|
|
7429
|
-
focused: true
|
|
7430
|
-
}
|
|
7431
|
-
};
|
|
7432
|
-
const newWidgets = [...editor.widgets.slice(0, childIndex), newWidget, ...editor.widgets.slice(childIndex + 1)];
|
|
7433
|
-
return {
|
|
7434
|
-
...editor,
|
|
7435
|
-
widgets: newWidgets
|
|
7436
|
-
};
|
|
7449
|
+
|
|
7450
|
+
const focusNext = state => {
|
|
7451
|
+
const nextIndex = state.focusedIndex + 1;
|
|
7452
|
+
return focusIndex(state, nextIndex);
|
|
7437
7453
|
};
|
|
7438
7454
|
|
|
7439
|
-
const
|
|
7440
|
-
const
|
|
7441
|
-
return focusIndex(
|
|
7455
|
+
const focusPrevious = state => {
|
|
7456
|
+
const previousIndex = state.focusedIndex - 1;
|
|
7457
|
+
return focusIndex(state, previousIndex);
|
|
7442
7458
|
};
|
|
7443
7459
|
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
const nextIndex = child.focusedIndex + 1;
|
|
7450
|
-
return focusIndex(editor, nextIndex);
|
|
7460
|
+
// TODO optimize this function to return the minimum number
|
|
7461
|
+
// of visible items needed, e.g. when not scrolled 5 items with
|
|
7462
|
+
// 20px fill 100px but when scrolled 6 items are needed
|
|
7463
|
+
const getNumberOfVisibleItems = (listHeight, itemHeight) => {
|
|
7464
|
+
return Math.ceil(listHeight / itemHeight) + 1;
|
|
7451
7465
|
};
|
|
7452
7466
|
|
|
7453
|
-
const
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7467
|
+
const setDeltaY = (state, value) => {
|
|
7468
|
+
object(state);
|
|
7469
|
+
number$1(value);
|
|
7470
|
+
const {
|
|
7471
|
+
itemHeight,
|
|
7472
|
+
finalDeltaY,
|
|
7473
|
+
deltaY,
|
|
7474
|
+
height,
|
|
7475
|
+
headerHeight
|
|
7476
|
+
} = state;
|
|
7477
|
+
const listHeight = height - headerHeight;
|
|
7478
|
+
const newDeltaY = clamp(value, 0, finalDeltaY);
|
|
7479
|
+
if (deltaY === newDeltaY) {
|
|
7480
|
+
return state;
|
|
7457
7481
|
}
|
|
7458
|
-
|
|
7459
|
-
|
|
7482
|
+
// TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
|
|
7483
|
+
const minLineY = Math.floor(newDeltaY / itemHeight);
|
|
7484
|
+
const maxLineY = minLineY + getNumberOfVisibleItems(listHeight, itemHeight);
|
|
7485
|
+
return {
|
|
7486
|
+
...state,
|
|
7487
|
+
deltaY: newDeltaY,
|
|
7488
|
+
minLineY,
|
|
7489
|
+
maxLineY
|
|
7490
|
+
};
|
|
7491
|
+
};
|
|
7492
|
+
|
|
7493
|
+
const handleWheel = (state, deltaMode, deltaY) => {
|
|
7494
|
+
number$1(deltaMode);
|
|
7495
|
+
number$1(deltaY);
|
|
7496
|
+
return setDeltaY(state, state.deltaY + deltaY);
|
|
7497
|
+
};
|
|
7498
|
+
|
|
7499
|
+
const handelWheel = (state, deltaMode, deltaY) => {
|
|
7500
|
+
const newState = handleWheel(state, deltaMode, deltaY);
|
|
7501
|
+
return newState;
|
|
7460
7502
|
};
|
|
7461
7503
|
|
|
7462
7504
|
const create = () => {
|
|
@@ -7492,6 +7534,10 @@ const getCompletionDetailBounds = (completionBounds, borderSize) => {
|
|
|
7492
7534
|
};
|
|
7493
7535
|
};
|
|
7494
7536
|
|
|
7537
|
+
const getCompletionState = editor => {
|
|
7538
|
+
return getWidgetState(editor, Completion);
|
|
7539
|
+
};
|
|
7540
|
+
|
|
7495
7541
|
const openDetails = editor => {
|
|
7496
7542
|
const child = getCompletionState(editor);
|
|
7497
7543
|
if (!child) {
|
|
@@ -7599,24 +7645,6 @@ const toggleDetails = editor => {
|
|
|
7599
7645
|
return closeDetails(editor);
|
|
7600
7646
|
};
|
|
7601
7647
|
|
|
7602
|
-
const isMatchingWidget = widget => {
|
|
7603
|
-
return widget.id === Find;
|
|
7604
|
-
};
|
|
7605
|
-
const closeFind = editor => {
|
|
7606
|
-
const {
|
|
7607
|
-
widgets
|
|
7608
|
-
} = editor;
|
|
7609
|
-
const index = widgets.findIndex(isMatchingWidget);
|
|
7610
|
-
if (index === -1) {
|
|
7611
|
-
return editor;
|
|
7612
|
-
}
|
|
7613
|
-
const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
|
|
7614
|
-
return {
|
|
7615
|
-
...editor,
|
|
7616
|
-
widgets: newWidgets
|
|
7617
|
-
};
|
|
7618
|
-
};
|
|
7619
|
-
|
|
7620
7648
|
const loadContent = async (editorUid, state, position) => {
|
|
7621
7649
|
const hoverInfo = await getEditorHoverInfo(editorUid, position);
|
|
7622
7650
|
if (!hoverInfo) {
|
|
@@ -7914,7 +7942,7 @@ const getText = editorUid => {
|
|
|
7914
7942
|
const {
|
|
7915
7943
|
lines
|
|
7916
7944
|
} = editor;
|
|
7917
|
-
return lines.join(
|
|
7945
|
+
return lines.join(NewLine$4);
|
|
7918
7946
|
};
|
|
7919
7947
|
|
|
7920
7948
|
const InsertText = 'insertText';
|
|
@@ -8871,7 +8899,13 @@ const widgetCommands = {
|
|
|
8871
8899
|
'FindWidget.focusReplaceAllButton': Find,
|
|
8872
8900
|
'FindWidget.focusNextMatchButton': Find,
|
|
8873
8901
|
'FindWidget.focusPreviousMatchButton': Find,
|
|
8874
|
-
'FindWidget.focusCloseButton': Find
|
|
8902
|
+
'FindWidget.focusCloseButton': Find,
|
|
8903
|
+
'EditorCompletion.handleWheel': Completion,
|
|
8904
|
+
// TODO
|
|
8905
|
+
// 'EditorCompletion.focusFirst': WidgetId.Completion,
|
|
8906
|
+
'EditorCompletion.focusNext': Completion
|
|
8907
|
+
// 'EditorCompletion.focusPrevious': WidgetId.Completion,
|
|
8908
|
+
// 'EditorCompletion.focusLast': WidgetId.Completion,
|
|
8875
8909
|
};
|
|
8876
8910
|
|
|
8877
8911
|
// TODO wrap commands globally, not per editor
|
|
@@ -8907,8 +8941,8 @@ const commandMap = {
|
|
|
8907
8941
|
'Editor.braceCompletion': braceCompletion,
|
|
8908
8942
|
'Editor.cancelSelection': cancelSelection,
|
|
8909
8943
|
'Editor.closeCompletion': closeCompletion,
|
|
8910
|
-
'Editor.closeSourceAction': closeSourceAction,
|
|
8911
8944
|
'Editor.closeFind': closeFind,
|
|
8945
|
+
'Editor.closeSourceAction': closeSourceAction,
|
|
8912
8946
|
'Editor.compositionEnd': compositionEnd,
|
|
8913
8947
|
'Editor.compositionStart': compositionStart,
|
|
8914
8948
|
'Editor.compositionUpdate': compositionUpdate,
|
|
@@ -9012,7 +9046,7 @@ const commandMap = {
|
|
|
9012
9046
|
'Editor.selectWordRight': selectWordRight,
|
|
9013
9047
|
'Editor.setDecorations': setDecorations,
|
|
9014
9048
|
'Editor.setDelta': setDelta,
|
|
9015
|
-
'Editor.setDeltaY': setDeltaY,
|
|
9049
|
+
'Editor.setDeltaY': setDeltaY$1,
|
|
9016
9050
|
'Editor.setLanguageId': setLanguageId,
|
|
9017
9051
|
'Editor.setSelections': setSelections,
|
|
9018
9052
|
'Editor.showHover': showHover,
|
|
@@ -9038,6 +9072,7 @@ const commandMap = {
|
|
|
9038
9072
|
'EditorCompletion.handleEditorClick': handleEditorClick,
|
|
9039
9073
|
'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$1,
|
|
9040
9074
|
'EditorCompletion.handleEditorType': handleEditorType$1,
|
|
9075
|
+
'EditorCompletion.handleWheel': handelWheel,
|
|
9041
9076
|
'EditorCompletion.loadContent': loadContent$2,
|
|
9042
9077
|
'EditorCompletion.openDetails': openDetails,
|
|
9043
9078
|
'EditorCompletion.selectCurrent': selectCurrent,
|