@lvce-editor/editor-worker 4.1.0 → 4.3.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 +60 -41
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -2258,13 +2258,13 @@ const cancelSelection = editor => {
|
|
|
2258
2258
|
};
|
|
2259
2259
|
|
|
2260
2260
|
// TODO use numeric widget id
|
|
2261
|
+
const ColorPicker$2 = 'colorPicker';
|
|
2261
2262
|
const Completion = 'completion';
|
|
2262
2263
|
const CompletionDetail$1 = 'completionDetail';
|
|
2263
|
-
const ColorPicker$2 = 'colorPicker';
|
|
2264
2264
|
const Find = 'find';
|
|
2265
2265
|
const Hover = 'hover';
|
|
2266
|
+
const Rename = 'rename';
|
|
2266
2267
|
const SourceAction = 'sourceAction';
|
|
2267
|
-
const Rename$1 = 'rename';
|
|
2268
2268
|
|
|
2269
2269
|
const isCompletionWidget = widget => {
|
|
2270
2270
|
return widget.id === Completion;
|
|
@@ -2304,7 +2304,7 @@ const closeFind = editor => {
|
|
|
2304
2304
|
|
|
2305
2305
|
// TODO duplicate code
|
|
2306
2306
|
const isRenameWidget = widget => {
|
|
2307
|
-
return widget.id === Rename
|
|
2307
|
+
return widget.id === Rename;
|
|
2308
2308
|
};
|
|
2309
2309
|
const closeRename = editor => {
|
|
2310
2310
|
const {
|
|
@@ -2425,20 +2425,19 @@ const create$6 = () => {
|
|
|
2425
2425
|
};
|
|
2426
2426
|
|
|
2427
2427
|
const ColorPicker$1 = 41;
|
|
2428
|
-
const FindWidget = 16;
|
|
2429
|
-
const EditorCompletion = 9;
|
|
2430
2428
|
const CompletionDetail = 999;
|
|
2429
|
+
const EditorCompletion = 9;
|
|
2431
2430
|
const Empty = 0;
|
|
2432
|
-
const
|
|
2433
|
-
const
|
|
2434
|
-
const FocusFindWidgetReplaceButton = 46;
|
|
2435
|
-
const FocusFindWidgetReplaceAllButton = 47;
|
|
2431
|
+
const FindWidget = 16;
|
|
2432
|
+
const FocusEditorHover = 51;
|
|
2436
2433
|
const FocusFindWidgetCloseButton = 48;
|
|
2437
2434
|
const FocusFindWidgetNextMatchButton = 49;
|
|
2438
2435
|
const FocusFindWidgetPreviousMatchButton = 50;
|
|
2439
|
-
const
|
|
2436
|
+
const FocusFindWidgetReplace = 43;
|
|
2437
|
+
const FocusFindWidgetReplaceAllButton = 47;
|
|
2438
|
+
const FocusFindWidgetReplaceButton = 46;
|
|
2439
|
+
const FocusFindWidgetToggleReplace = 42;
|
|
2440
2440
|
const SourceActions = 38;
|
|
2441
|
-
const Rename = 999;
|
|
2442
2441
|
|
|
2443
2442
|
const newStateGenerator$1 = state => {
|
|
2444
2443
|
return loadContent$3(state);
|
|
@@ -5478,7 +5477,7 @@ const getRenamePosition = editor => {
|
|
|
5478
5477
|
const create$3 = () => {
|
|
5479
5478
|
const completionUid = create$7();
|
|
5480
5479
|
const renameWidget = {
|
|
5481
|
-
id: Rename
|
|
5480
|
+
id: Rename,
|
|
5482
5481
|
oldState: {
|
|
5483
5482
|
uid: completionUid,
|
|
5484
5483
|
focusedIndex: -1,
|
|
@@ -5495,7 +5494,7 @@ const create$3 = () => {
|
|
|
5495
5494
|
focusedIndex: -1,
|
|
5496
5495
|
oldValue: '',
|
|
5497
5496
|
newValue: '',
|
|
5498
|
-
focused:
|
|
5497
|
+
focused: true,
|
|
5499
5498
|
x: 0,
|
|
5500
5499
|
y: 0,
|
|
5501
5500
|
width: 0,
|
|
@@ -5536,7 +5535,7 @@ const openRename = async editor => {
|
|
|
5536
5535
|
return latestState;
|
|
5537
5536
|
};
|
|
5538
5537
|
const fullFocus = true;
|
|
5539
|
-
return addWidgetToEditor(Rename
|
|
5538
|
+
return addWidgetToEditor(Rename, undefined, editor, create$3, newStateGenerator, fullFocus);
|
|
5540
5539
|
};
|
|
5541
5540
|
|
|
5542
5541
|
const organizeImports = async editor => {
|
|
@@ -6697,35 +6696,44 @@ const showHover2 = async editor => {
|
|
|
6697
6696
|
return addWidgetToEditor(Hover, FocusEditorHover, editor, create$2, newStateGenerator);
|
|
6698
6697
|
};
|
|
6699
6698
|
|
|
6700
|
-
|
|
6701
|
-
const showSourceActions$1 = async editor => {
|
|
6702
|
-
// TODO
|
|
6703
|
-
// 1. hide hover, completions, color picker
|
|
6704
|
-
// 2. query source actions from extension host
|
|
6705
|
-
// 3. show source actions menu
|
|
6706
|
-
|
|
6707
|
-
await invoke$3('Viewlet.openWidget', EditorSourceActions);
|
|
6708
|
-
return editor;
|
|
6709
|
-
};
|
|
6710
|
-
|
|
6711
|
-
// TODO maybe ask extension host worker instead
|
|
6699
|
+
// TODO ask extension host worker instead
|
|
6712
6700
|
const getEditorSourceActions = async () => {
|
|
6713
6701
|
const sourceActions = await invoke$3('GetEditorSourceActions.getEditorSourceActions');
|
|
6714
6702
|
return sourceActions;
|
|
6715
6703
|
};
|
|
6716
6704
|
|
|
6717
|
-
const
|
|
6705
|
+
const getSourceActionWidgetPosition = editor => {
|
|
6706
|
+
const width = 300;
|
|
6707
|
+
const height = 150;
|
|
6708
|
+
const cursor = getPositionAtCursor(editor);
|
|
6709
|
+
const x = cursor.x;
|
|
6710
|
+
const y = cursor.y;
|
|
6711
|
+
return {
|
|
6712
|
+
x,
|
|
6713
|
+
y,
|
|
6714
|
+
width,
|
|
6715
|
+
height
|
|
6716
|
+
};
|
|
6717
|
+
};
|
|
6718
|
+
|
|
6719
|
+
const loadSourceActions = async (editor, state) => {
|
|
6718
6720
|
// const editor = GetEditor.getEditor(editorUid)
|
|
6719
6721
|
// TODO request source actions information from extensions
|
|
6720
6722
|
const sourceActions = await getEditorSourceActions();
|
|
6721
6723
|
// TODO avoid side effect
|
|
6724
|
+
const {
|
|
6725
|
+
x,
|
|
6726
|
+
y,
|
|
6727
|
+
width,
|
|
6728
|
+
height
|
|
6729
|
+
} = getSourceActionWidgetPosition(editor);
|
|
6722
6730
|
return {
|
|
6723
6731
|
...state,
|
|
6724
6732
|
sourceActions,
|
|
6725
|
-
x
|
|
6726
|
-
y
|
|
6727
|
-
width
|
|
6728
|
-
height
|
|
6733
|
+
x,
|
|
6734
|
+
y,
|
|
6735
|
+
width,
|
|
6736
|
+
height,
|
|
6729
6737
|
maxHeight: 150,
|
|
6730
6738
|
focusedIndex: 0
|
|
6731
6739
|
};
|
|
@@ -6760,9 +6768,8 @@ const create$1 = () => {
|
|
|
6760
6768
|
};
|
|
6761
6769
|
|
|
6762
6770
|
const showSourceActions = async editor => {
|
|
6763
|
-
const uid = editor.uid;
|
|
6764
6771
|
const newStateGenerator = state => {
|
|
6765
|
-
return loadSourceActions(
|
|
6772
|
+
return loadSourceActions(editor, state);
|
|
6766
6773
|
};
|
|
6767
6774
|
return addWidgetToEditor(SourceAction, SourceActions, editor, create$1, newStateGenerator);
|
|
6768
6775
|
};
|
|
@@ -8919,7 +8926,7 @@ const renderScrollBarX = {
|
|
|
8919
8926
|
return [/* method */'setScrollBarHorizontal', /* scrollBarX */scrollBarX, /* scrollBarWidth */scrollBarWidth, /* deltaX */newState.deltaX];
|
|
8920
8927
|
}
|
|
8921
8928
|
};
|
|
8922
|
-
const renderFocus$
|
|
8929
|
+
const renderFocus$2 = {
|
|
8923
8930
|
isEqual(oldState, newState) {
|
|
8924
8931
|
return oldState.focused === newState.focused;
|
|
8925
8932
|
},
|
|
@@ -9017,7 +9024,7 @@ const renderWidgets = {
|
|
|
9017
9024
|
},
|
|
9018
9025
|
multiple: true
|
|
9019
9026
|
};
|
|
9020
|
-
const render$d = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$
|
|
9027
|
+
const render$d = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$2, renderDecorations, renderGutterInfo, renderWidgets];
|
|
9021
9028
|
const renderEditor = async id => {
|
|
9022
9029
|
const instance = get$6(id);
|
|
9023
9030
|
if (!instance) {
|
|
@@ -9244,7 +9251,7 @@ const commandMap = {
|
|
|
9244
9251
|
'Editor.setSelections': setSelections,
|
|
9245
9252
|
'Editor.showHover': showHover,
|
|
9246
9253
|
'Editor.showHover2': showHover2,
|
|
9247
|
-
'Editor.showSourceActions': showSourceActions
|
|
9254
|
+
'Editor.showSourceActions': showSourceActions,
|
|
9248
9255
|
'Editor.showSourceActions2': showSourceActions,
|
|
9249
9256
|
'Editor.sortLinesAscending': sortLinesAscending,
|
|
9250
9257
|
'Editor.tabCompletion': tabCompletion,
|
|
@@ -9800,7 +9807,9 @@ const addWidget = (widget, id, render) => {
|
|
|
9800
9807
|
allCommands.push(['Viewlet.createFunctionalRoot', id, uid]);
|
|
9801
9808
|
allCommands.push(...commands);
|
|
9802
9809
|
allCommands.push(['Viewlet.send', uid, 'appendWidget']);
|
|
9803
|
-
const focusCommandIndex = allCommands.findIndex(command =>
|
|
9810
|
+
const focusCommandIndex = allCommands.findIndex(command => {
|
|
9811
|
+
return command[2] === 'focus' || command[0] === 'Viewlet.focusSelector';
|
|
9812
|
+
});
|
|
9804
9813
|
// TODO have separate rendering functions, e.g.
|
|
9805
9814
|
// 1. renderDom
|
|
9806
9815
|
// 2. renderAriaAnnouncement
|
|
@@ -10714,7 +10723,7 @@ const renderBounds$2 = {
|
|
|
10714
10723
|
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
10715
10724
|
}
|
|
10716
10725
|
};
|
|
10717
|
-
const renderFocus = {
|
|
10726
|
+
const renderFocus$1 = {
|
|
10718
10727
|
isEqual(oldState, newState) {
|
|
10719
10728
|
return oldState.focused === newState.focused && oldState.focus === newState.focus && oldState.focusSource === newState.focusSource;
|
|
10720
10729
|
},
|
|
@@ -10743,7 +10752,7 @@ const renderFocus = {
|
|
|
10743
10752
|
// },
|
|
10744
10753
|
// }
|
|
10745
10754
|
|
|
10746
|
-
const render$6 = [renderDetails, renderBounds$2, renderValue, renderFocus];
|
|
10755
|
+
const render$6 = [renderDetails, renderBounds$2, renderValue, renderFocus$1];
|
|
10747
10756
|
const apply = (oldState, newState) => {
|
|
10748
10757
|
// TODO avoid side effect
|
|
10749
10758
|
if (oldState.focus !== newState.focus) {
|
|
@@ -10849,7 +10858,15 @@ const renderBounds$1 = {
|
|
|
10849
10858
|
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
10850
10859
|
}
|
|
10851
10860
|
};
|
|
10852
|
-
const
|
|
10861
|
+
const renderFocus = {
|
|
10862
|
+
isEqual(oldState, newState) {
|
|
10863
|
+
return oldState.focused === newState.focused;
|
|
10864
|
+
},
|
|
10865
|
+
apply(oldState, newState) {
|
|
10866
|
+
return [/* method */'Viewlet.focusSelector', newState.uid, '.RenameInputBox'];
|
|
10867
|
+
}
|
|
10868
|
+
};
|
|
10869
|
+
const render$3 = [renderContent, renderBounds$1, renderFocus];
|
|
10853
10870
|
const renderFull = (oldState, newState) => {
|
|
10854
10871
|
return renderParts(render$3, oldState, newState);
|
|
10855
10872
|
};
|
|
@@ -10861,6 +10878,8 @@ const render$2 = widget => {
|
|
|
10861
10878
|
for (const command of commands) {
|
|
10862
10879
|
if (command[0] === 'Viewlet.setDom2') {
|
|
10863
10880
|
wrappedCommands.push(command);
|
|
10881
|
+
} else if (command[0] === 'Viewlet.focusSelector') {
|
|
10882
|
+
wrappedCommands.push(command);
|
|
10864
10883
|
} else {
|
|
10865
10884
|
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
10866
10885
|
}
|
|
@@ -10994,7 +11013,7 @@ const registerWidgets = () => {
|
|
|
10994
11013
|
set$7(CompletionDetail$1, EditorCompletionDetailWidget);
|
|
10995
11014
|
set$7(Find, EditorFindWidget);
|
|
10996
11015
|
set$7(Hover, EditorHoverWidget);
|
|
10997
|
-
set$7(Rename
|
|
11016
|
+
set$7(Rename, EditorRenameWidget);
|
|
10998
11017
|
set$7(SourceAction, EditorSourceActionWidget);
|
|
10999
11018
|
};
|
|
11000
11019
|
|