@lvce-editor/editor-worker 5.1.0 → 5.2.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 +212 -139
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -18,6 +18,11 @@ const execute$1 = (command, ...args) => {
|
|
|
18
18
|
return fn(...args);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
const codeGeneratorAccept = state => {
|
|
22
|
+
// TODO close code generator widget
|
|
23
|
+
return state;
|
|
24
|
+
};
|
|
25
|
+
|
|
21
26
|
let AssertionError$1 = class AssertionError extends Error {
|
|
22
27
|
constructor(message) {
|
|
23
28
|
super(message);
|
|
@@ -1034,6 +1039,13 @@ const set$6 = (id, oldEditor, newEditor) => {
|
|
|
1034
1039
|
};
|
|
1035
1040
|
};
|
|
1036
1041
|
|
|
1042
|
+
const CompletionExecute = 'ExtensionHostCompletion.execute';
|
|
1043
|
+
const CompletionResolveExecute = 'ExtensionHostCompletion.executeResolve';
|
|
1044
|
+
const HoverExecute = 'ExtensionHostHover.execute';
|
|
1045
|
+
const RenameExecuteRename = 'ExtensionHostRename.executeRenameProvider';
|
|
1046
|
+
const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompletionProvider';
|
|
1047
|
+
const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
|
|
1048
|
+
|
|
1037
1049
|
const Two = '2.0';
|
|
1038
1050
|
class AssertionError extends Error {
|
|
1039
1051
|
constructor(message) {
|
|
@@ -1718,13 +1730,6 @@ const {
|
|
|
1718
1730
|
invoke: invoke$2
|
|
1719
1731
|
} = createRpc(ExtensionHostWorker);
|
|
1720
1732
|
|
|
1721
|
-
const CompletionExecute = 'ExtensionHostCompletion.execute';
|
|
1722
|
-
const CompletionResolveExecute = 'ExtensionHostCompletion.executeResolve';
|
|
1723
|
-
const HoverExecute = 'ExtensionHostHover.execute';
|
|
1724
|
-
const RenameExecuteRename = 'ExtensionHostRename.executeRenameProvider';
|
|
1725
|
-
const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompletionProvider';
|
|
1726
|
-
const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
|
|
1727
|
-
|
|
1728
1733
|
const ColorPicker$2 = 41;
|
|
1729
1734
|
const CompletionDetail$1 = 999;
|
|
1730
1735
|
const EditorCompletion = 9;
|
|
@@ -1746,6 +1751,90 @@ const measureCharacterWidth = (fontWeight, fontSize, fontFamily, letterSpacing)
|
|
|
1746
1751
|
return measureTextWidth('a', fontWeight, fontSize, fontFamily, letterSpacing, false, 0);
|
|
1747
1752
|
};
|
|
1748
1753
|
|
|
1754
|
+
const OnRename = 'onRename';
|
|
1755
|
+
const OnCompletion = 'onCompletion';
|
|
1756
|
+
const OnDiagnostic = 'onDiagnostic';
|
|
1757
|
+
const OnHover = 'onHover';
|
|
1758
|
+
const OnTabCompletion = 'onTabCompletion';
|
|
1759
|
+
|
|
1760
|
+
// TODO add tests for this
|
|
1761
|
+
const activateByEvent = async event => {
|
|
1762
|
+
await invoke$3('ExtensionHostManagement.activateByEvent', event);
|
|
1763
|
+
};
|
|
1764
|
+
|
|
1765
|
+
const execute = async ({
|
|
1766
|
+
editor,
|
|
1767
|
+
args,
|
|
1768
|
+
event,
|
|
1769
|
+
method,
|
|
1770
|
+
noProviderFoundMessage,
|
|
1771
|
+
noProviderFoundResult = undefined
|
|
1772
|
+
}) => {
|
|
1773
|
+
const fullEvent = `${event}:${editor.languageId}`;
|
|
1774
|
+
await activateByEvent(fullEvent);
|
|
1775
|
+
const result = await invoke$2(method, editor.uid, ...args);
|
|
1776
|
+
return result;
|
|
1777
|
+
};
|
|
1778
|
+
|
|
1779
|
+
const combineResults$3 = results => {
|
|
1780
|
+
return results[0];
|
|
1781
|
+
};
|
|
1782
|
+
const executeDiagnosticProvider = editor => {
|
|
1783
|
+
return execute({
|
|
1784
|
+
editor,
|
|
1785
|
+
event: OnDiagnostic,
|
|
1786
|
+
method: 'ExtensionHost.executeDiagnosticProvider',
|
|
1787
|
+
args: [],
|
|
1788
|
+
noProviderFoundMessage: 'no diagnostic provider found',
|
|
1789
|
+
noProviderResult: [],
|
|
1790
|
+
combineResults: combineResults$3
|
|
1791
|
+
});
|
|
1792
|
+
};
|
|
1793
|
+
|
|
1794
|
+
const getDiagnosticType = diagnostic => {
|
|
1795
|
+
return diagnostic.type;
|
|
1796
|
+
};
|
|
1797
|
+
|
|
1798
|
+
const getVisibleDiagnostics = (editor, diagnostics) => {
|
|
1799
|
+
const visibleDiagnostics = [];
|
|
1800
|
+
for (const diagnostic of diagnostics) {
|
|
1801
|
+
visibleDiagnostics.push({
|
|
1802
|
+
x: diagnostic.columnIndex * editor.columnWidth,
|
|
1803
|
+
y: (diagnostic.rowIndex - editor.minLineY) * editor.rowHeight,
|
|
1804
|
+
width: 20,
|
|
1805
|
+
height: editor.rowHeight,
|
|
1806
|
+
type: getDiagnosticType(diagnostic)
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
return visibleDiagnostics;
|
|
1810
|
+
};
|
|
1811
|
+
|
|
1812
|
+
const updateDiagnostics = async uid => {
|
|
1813
|
+
try {
|
|
1814
|
+
// TODO handle error
|
|
1815
|
+
// TODO handle race condition
|
|
1816
|
+
const {
|
|
1817
|
+
newState
|
|
1818
|
+
} = get$6(uid);
|
|
1819
|
+
// TODO request diagnostics from extension host
|
|
1820
|
+
const diagnostics = await executeDiagnosticProvider(newState);
|
|
1821
|
+
const latest = get$6(uid);
|
|
1822
|
+
if (!latest) {
|
|
1823
|
+
return;
|
|
1824
|
+
}
|
|
1825
|
+
const decorations = getVisibleDiagnostics(latest.newState, diagnostics);
|
|
1826
|
+
const newEditor = {
|
|
1827
|
+
...latest.newState,
|
|
1828
|
+
diagnostics,
|
|
1829
|
+
decorations
|
|
1830
|
+
};
|
|
1831
|
+
set$6(uid, latest.oldState, newEditor);
|
|
1832
|
+
await invoke$3('Editor.rerender', uid);
|
|
1833
|
+
} catch (error) {
|
|
1834
|
+
console.error(`Failed to update diagnostics: ${error}`);
|
|
1835
|
+
}
|
|
1836
|
+
};
|
|
1837
|
+
|
|
1749
1838
|
const emptyEditor = {
|
|
1750
1839
|
uri: '',
|
|
1751
1840
|
languageId: '',
|
|
@@ -1796,7 +1885,8 @@ const createEditor = async ({
|
|
|
1796
1885
|
fontWeight,
|
|
1797
1886
|
fontFamily,
|
|
1798
1887
|
isMonospaceFont,
|
|
1799
|
-
uri
|
|
1888
|
+
uri,
|
|
1889
|
+
diagnosticsEnabled
|
|
1800
1890
|
}) => {
|
|
1801
1891
|
number$1(id);
|
|
1802
1892
|
string(content);
|
|
@@ -1856,7 +1946,8 @@ const createEditor = async ({
|
|
|
1856
1946
|
uid: id,
|
|
1857
1947
|
id,
|
|
1858
1948
|
widgets: [],
|
|
1859
|
-
focusKey: Empty
|
|
1949
|
+
focusKey: Empty,
|
|
1950
|
+
diagnosticsEnabled
|
|
1860
1951
|
};
|
|
1861
1952
|
// TODO avoid creating intermediate editors here
|
|
1862
1953
|
const newEditor1 = setBounds(editor, x, y, width, height, 9);
|
|
@@ -1868,6 +1959,9 @@ const createEditor = async ({
|
|
|
1868
1959
|
};
|
|
1869
1960
|
set$6(id, emptyEditor, newEditor4);
|
|
1870
1961
|
await invoke$2(TextDocumentSyncFull, uri, id, languageId, content);
|
|
1962
|
+
if (diagnosticsEnabled) {
|
|
1963
|
+
updateDiagnostics(editor.uid);
|
|
1964
|
+
}
|
|
1871
1965
|
};
|
|
1872
1966
|
|
|
1873
1967
|
// @ts-ignore
|
|
@@ -2260,6 +2354,16 @@ const cancelSelection = editor => {
|
|
|
2260
2354
|
return scheduleSelections(editor, newSelections);
|
|
2261
2355
|
};
|
|
2262
2356
|
|
|
2357
|
+
// TODO use numeric widget id
|
|
2358
|
+
const CodeGenerator = 1;
|
|
2359
|
+
const ColorPicker$1 = 2;
|
|
2360
|
+
const Completion = 3;
|
|
2361
|
+
const CompletionDetail = 4;
|
|
2362
|
+
const Find = 5;
|
|
2363
|
+
const Hover = 6;
|
|
2364
|
+
const Rename = 7;
|
|
2365
|
+
const SourceAction = 8;
|
|
2366
|
+
|
|
2263
2367
|
const getIndex = (widgets, id) => {
|
|
2264
2368
|
for (const [i, widget] of widgets.entries()) {
|
|
2265
2369
|
if (widget.id === id) {
|
|
@@ -2274,15 +2378,24 @@ const removeEditorWidget = (widgets, id) => {
|
|
|
2274
2378
|
return newWidgets;
|
|
2275
2379
|
};
|
|
2276
2380
|
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
const
|
|
2281
|
-
const
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
const
|
|
2285
|
-
|
|
2381
|
+
const isMatchingWidget$2 = widget => {
|
|
2382
|
+
return widget.id === CodeGenerator;
|
|
2383
|
+
};
|
|
2384
|
+
const closeCodeGenerator = editor => {
|
|
2385
|
+
const {
|
|
2386
|
+
widgets
|
|
2387
|
+
} = editor;
|
|
2388
|
+
const index = widgets.findIndex(isMatchingWidget$2);
|
|
2389
|
+
if (index === -1) {
|
|
2390
|
+
return editor;
|
|
2391
|
+
}
|
|
2392
|
+
const newWidgets = removeEditorWidget(widgets, CodeGenerator);
|
|
2393
|
+
return {
|
|
2394
|
+
...editor,
|
|
2395
|
+
widgets: newWidgets,
|
|
2396
|
+
focused: true
|
|
2397
|
+
};
|
|
2398
|
+
};
|
|
2286
2399
|
|
|
2287
2400
|
const isCompletionWidget = widget => {
|
|
2288
2401
|
return widget.id === Completion;
|
|
@@ -2302,14 +2415,14 @@ const closeCompletion = editor => {
|
|
|
2302
2415
|
};
|
|
2303
2416
|
};
|
|
2304
2417
|
|
|
2305
|
-
const isMatchingWidget$
|
|
2418
|
+
const isMatchingWidget$1 = widget => {
|
|
2306
2419
|
return widget.id === Find;
|
|
2307
2420
|
};
|
|
2308
2421
|
const closeFind = editor => {
|
|
2309
2422
|
const {
|
|
2310
2423
|
widgets
|
|
2311
2424
|
} = editor;
|
|
2312
|
-
const index = widgets.findIndex(isMatchingWidget$
|
|
2425
|
+
const index = widgets.findIndex(isMatchingWidget$1);
|
|
2313
2426
|
if (index === -1) {
|
|
2314
2427
|
return editor;
|
|
2315
2428
|
}
|
|
@@ -2341,14 +2454,14 @@ const closeRename = editor => {
|
|
|
2341
2454
|
};
|
|
2342
2455
|
};
|
|
2343
2456
|
|
|
2344
|
-
const isMatchingWidget
|
|
2457
|
+
const isMatchingWidget = widget => {
|
|
2345
2458
|
return widget.id === SourceAction;
|
|
2346
2459
|
};
|
|
2347
2460
|
const closeSourceAction = editor => {
|
|
2348
2461
|
const {
|
|
2349
2462
|
widgets
|
|
2350
2463
|
} = editor;
|
|
2351
|
-
const index = widgets.findIndex(isMatchingWidget
|
|
2464
|
+
const index = widgets.findIndex(isMatchingWidget);
|
|
2352
2465
|
if (index === -1) {
|
|
2353
2466
|
return editor;
|
|
2354
2467
|
}
|
|
@@ -2841,7 +2954,6 @@ const wordPartRight = (line, columnIndex) => {
|
|
|
2841
2954
|
return tryRegexArray(partialLine, ARRAY_PARTIAL_WORD_RIGHT_2);
|
|
2842
2955
|
};
|
|
2843
2956
|
|
|
2844
|
-
// @ts-ignore
|
|
2845
2957
|
const cursorCharacterLeft = editor => {
|
|
2846
2958
|
return editorCursorHorizontalLeft(editor, characterLeft);
|
|
2847
2959
|
};
|
|
@@ -3186,25 +3298,6 @@ const findAllReferences = async editor => {
|
|
|
3186
3298
|
return editor;
|
|
3187
3299
|
};
|
|
3188
3300
|
|
|
3189
|
-
// TODO add tests for this
|
|
3190
|
-
const activateByEvent = async event => {
|
|
3191
|
-
await invoke$3('ExtensionHostManagement.activateByEvent', event);
|
|
3192
|
-
};
|
|
3193
|
-
|
|
3194
|
-
const execute = async ({
|
|
3195
|
-
editor,
|
|
3196
|
-
args,
|
|
3197
|
-
event,
|
|
3198
|
-
method,
|
|
3199
|
-
noProviderFoundMessage,
|
|
3200
|
-
noProviderFoundResult = undefined
|
|
3201
|
-
}) => {
|
|
3202
|
-
const fullEvent = `${event}:${editor.languageId}`;
|
|
3203
|
-
await activateByEvent(fullEvent);
|
|
3204
|
-
const result = await invoke$2(method, editor.uid, ...args);
|
|
3205
|
-
return result;
|
|
3206
|
-
};
|
|
3207
|
-
|
|
3208
3301
|
const getFormattingEdits = async editor => {
|
|
3209
3302
|
const edits = await execute({
|
|
3210
3303
|
editor,
|
|
@@ -4521,7 +4614,54 @@ const moveSelectionPx = (editor, x, y) => {
|
|
|
4521
4614
|
return editorMoveSelection(editor, position);
|
|
4522
4615
|
};
|
|
4523
4616
|
|
|
4617
|
+
const User = 1;
|
|
4618
|
+
const Script = 2;
|
|
4619
|
+
const Unknown$1 = 0;
|
|
4620
|
+
|
|
4524
4621
|
const create$6 = () => {
|
|
4622
|
+
const completionUid = create$8();
|
|
4623
|
+
const widget = {
|
|
4624
|
+
id: CodeGenerator,
|
|
4625
|
+
oldState: {
|
|
4626
|
+
uid: completionUid,
|
|
4627
|
+
questions: [],
|
|
4628
|
+
x: 0,
|
|
4629
|
+
y: 0,
|
|
4630
|
+
width: 0,
|
|
4631
|
+
height: 0,
|
|
4632
|
+
focused: false,
|
|
4633
|
+
focusSource: Unknown$1
|
|
4634
|
+
},
|
|
4635
|
+
newState: {
|
|
4636
|
+
uid: completionUid,
|
|
4637
|
+
questions: [],
|
|
4638
|
+
x: 0,
|
|
4639
|
+
y: 0,
|
|
4640
|
+
width: 0,
|
|
4641
|
+
height: 0,
|
|
4642
|
+
focused: true,
|
|
4643
|
+
focusSource: Script
|
|
4644
|
+
}
|
|
4645
|
+
};
|
|
4646
|
+
return widget;
|
|
4647
|
+
};
|
|
4648
|
+
|
|
4649
|
+
const newStateGenerator$1 = async state => {
|
|
4650
|
+
const latestState = {
|
|
4651
|
+
...state,
|
|
4652
|
+
x: 100,
|
|
4653
|
+
y: 100,
|
|
4654
|
+
width: 150,
|
|
4655
|
+
height: 45
|
|
4656
|
+
};
|
|
4657
|
+
return latestState;
|
|
4658
|
+
};
|
|
4659
|
+
const openCodeGenerator = async editor => {
|
|
4660
|
+
const fullFocus = true;
|
|
4661
|
+
return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create$6, newStateGenerator$1, fullFocus);
|
|
4662
|
+
};
|
|
4663
|
+
|
|
4664
|
+
const create$5 = () => {
|
|
4525
4665
|
const completionUid = create$8();
|
|
4526
4666
|
const completionWidget = {
|
|
4527
4667
|
id: Completion,
|
|
@@ -4563,11 +4703,6 @@ const create$6 = () => {
|
|
|
4563
4703
|
return completionWidget;
|
|
4564
4704
|
};
|
|
4565
4705
|
|
|
4566
|
-
const OnRename = 'onRename';
|
|
4567
|
-
const OnCompletion = 'onCompletion';
|
|
4568
|
-
const OnHover = 'onHover';
|
|
4569
|
-
const OnTabCompletion = 'onTabCompletion';
|
|
4570
|
-
|
|
4571
4706
|
const combineResults$2 = results => {
|
|
4572
4707
|
return results[0] ?? [];
|
|
4573
4708
|
};
|
|
@@ -5018,7 +5153,7 @@ const openCompletion = async editor => {
|
|
|
5018
5153
|
if (hasWidget(widgets, Completion)) {
|
|
5019
5154
|
return editor;
|
|
5020
5155
|
}
|
|
5021
|
-
const completionWidget = create$
|
|
5156
|
+
const completionWidget = create$5();
|
|
5022
5157
|
const newWidgets = [...widgets, completionWidget];
|
|
5023
5158
|
const newEditor = {
|
|
5024
5159
|
...editor,
|
|
@@ -5043,11 +5178,7 @@ const openCompletion = async editor => {
|
|
|
5043
5178
|
};
|
|
5044
5179
|
};
|
|
5045
5180
|
|
|
5046
|
-
const
|
|
5047
|
-
const Script = 2;
|
|
5048
|
-
const Unknown$1 = 0;
|
|
5049
|
-
|
|
5050
|
-
const create$5 = () => {
|
|
5181
|
+
const create$4 = () => {
|
|
5051
5182
|
const uid = create$8();
|
|
5052
5183
|
const widget = {
|
|
5053
5184
|
id: Find,
|
|
@@ -5453,7 +5584,7 @@ const openFind2 = async editor => {
|
|
|
5453
5584
|
return latestState;
|
|
5454
5585
|
};
|
|
5455
5586
|
const fullFocus = true;
|
|
5456
|
-
return addWidgetToEditor(Find, FindWidget, editor, create$
|
|
5587
|
+
return addWidgetToEditor(Find, FindWidget, editor, create$4, newStateGenerator, fullFocus);
|
|
5457
5588
|
};
|
|
5458
5589
|
|
|
5459
5590
|
const openFind = async state => {
|
|
@@ -5475,7 +5606,7 @@ const getRenamePosition = editor => {
|
|
|
5475
5606
|
};
|
|
5476
5607
|
};
|
|
5477
5608
|
|
|
5478
|
-
const create$
|
|
5609
|
+
const create$3 = () => {
|
|
5479
5610
|
const completionUid = create$8();
|
|
5480
5611
|
const renameWidget = {
|
|
5481
5612
|
id: Rename,
|
|
@@ -5536,7 +5667,7 @@ const openRename = async editor => {
|
|
|
5536
5667
|
return latestState;
|
|
5537
5668
|
};
|
|
5538
5669
|
const fullFocus = true;
|
|
5539
|
-
return addWidgetToEditor(Rename, FocusEditorRename, editor, create$
|
|
5670
|
+
return addWidgetToEditor(Rename, FocusEditorRename, editor, create$3, newStateGenerator, fullFocus);
|
|
5540
5671
|
};
|
|
5541
5672
|
|
|
5542
5673
|
const getOrganizeImportEdits = async editor => {
|
|
@@ -6432,7 +6563,7 @@ const showHover = async state => {
|
|
|
6432
6563
|
return state;
|
|
6433
6564
|
};
|
|
6434
6565
|
|
|
6435
|
-
const create$
|
|
6566
|
+
const create$2 = () => {
|
|
6436
6567
|
const uid = create$8();
|
|
6437
6568
|
const widget = {
|
|
6438
6569
|
id: Hover,
|
|
@@ -6698,11 +6829,11 @@ const loadHoverContent = async state => {
|
|
|
6698
6829
|
};
|
|
6699
6830
|
};
|
|
6700
6831
|
|
|
6701
|
-
const newStateGenerator
|
|
6832
|
+
const newStateGenerator = async state => {
|
|
6702
6833
|
return loadHoverContent(state);
|
|
6703
6834
|
};
|
|
6704
6835
|
const showHover2 = async editor => {
|
|
6705
|
-
return addWidgetToEditor(Hover, FocusEditorHover, editor, create$
|
|
6836
|
+
return addWidgetToEditor(Hover, FocusEditorHover, editor, create$2, newStateGenerator);
|
|
6706
6837
|
};
|
|
6707
6838
|
|
|
6708
6839
|
// TODO ask extension host worker instead
|
|
@@ -6755,7 +6886,7 @@ const loadSourceActions = async (editor, state) => {
|
|
|
6755
6886
|
};
|
|
6756
6887
|
};
|
|
6757
6888
|
|
|
6758
|
-
const create$
|
|
6889
|
+
const create$1 = () => {
|
|
6759
6890
|
const completionUid = create$8();
|
|
6760
6891
|
const widget = {
|
|
6761
6892
|
id: SourceAction,
|
|
@@ -6787,7 +6918,7 @@ const showSourceActions = async editor => {
|
|
|
6787
6918
|
const newStateGenerator = async state => {
|
|
6788
6919
|
return loadSourceActions(editor, state);
|
|
6789
6920
|
};
|
|
6790
|
-
return addWidgetToEditor(SourceAction, SourceActions, editor, create$
|
|
6921
|
+
return addWidgetToEditor(SourceAction, SourceActions, editor, create$1, newStateGenerator);
|
|
6791
6922
|
};
|
|
6792
6923
|
|
|
6793
6924
|
const compareString = (a, b) => {
|
|
@@ -7666,7 +7797,7 @@ const handelWheel = (state, deltaMode, deltaY) => {
|
|
|
7666
7797
|
return newState;
|
|
7667
7798
|
};
|
|
7668
7799
|
|
|
7669
|
-
const create
|
|
7800
|
+
const create = () => {
|
|
7670
7801
|
const completionUid = create$8();
|
|
7671
7802
|
const completionWidget = {
|
|
7672
7803
|
id: CompletionDetail,
|
|
@@ -7720,7 +7851,7 @@ const openDetails = editor => {
|
|
|
7720
7851
|
};
|
|
7721
7852
|
return newestState;
|
|
7722
7853
|
};
|
|
7723
|
-
return addWidgetToEditor(CompletionDetail, CompletionDetail$1, editor, create
|
|
7854
|
+
return addWidgetToEditor(CompletionDetail, CompletionDetail$1, editor, create, newStateGenerator);
|
|
7724
7855
|
};
|
|
7725
7856
|
|
|
7726
7857
|
const getEdits = async (editor, completionItem) => {
|
|
@@ -7859,6 +7990,8 @@ const ColorPickerDark = 'ColorPickerDark';
|
|
|
7859
7990
|
const ColorPickerLight = 'ColorPickerLight';
|
|
7860
7991
|
const ColorPickerRectangle = 'ColorPickerRectangle';
|
|
7861
7992
|
const ColorPickerSlider = 'ColorPickerSlider';
|
|
7993
|
+
const DiagnosticError = 'DiagnosticError';
|
|
7994
|
+
const DiagnosticWarning = 'DiagnosticWarning';
|
|
7862
7995
|
const ColorPickerSliderThumb = 'ColorPickerSliderThumb';
|
|
7863
7996
|
const CompletionDetailCloseButton = 'CompletionDetailCloseButton';
|
|
7864
7997
|
const CompletionDetailContent = 'CompletionDetailContent';
|
|
@@ -8133,6 +8266,11 @@ const handleBlur = editor => {
|
|
|
8133
8266
|
return closeRename(editor);
|
|
8134
8267
|
};
|
|
8135
8268
|
|
|
8269
|
+
const rerender = editor => {
|
|
8270
|
+
// TODO avoid slow clone
|
|
8271
|
+
return structuredClone(editor);
|
|
8272
|
+
};
|
|
8273
|
+
|
|
8136
8274
|
const focusIndex = (state, index) => {
|
|
8137
8275
|
const newState = {
|
|
8138
8276
|
...state,
|
|
@@ -8344,49 +8482,6 @@ const moveLineDown = editor => {
|
|
|
8344
8482
|
return editor;
|
|
8345
8483
|
};
|
|
8346
8484
|
|
|
8347
|
-
const create = () => {
|
|
8348
|
-
const completionUid = create$8();
|
|
8349
|
-
const widget = {
|
|
8350
|
-
id: CodeGenerator,
|
|
8351
|
-
oldState: {
|
|
8352
|
-
uid: completionUid,
|
|
8353
|
-
questions: [],
|
|
8354
|
-
x: 0,
|
|
8355
|
-
y: 0,
|
|
8356
|
-
width: 0,
|
|
8357
|
-
height: 0,
|
|
8358
|
-
focused: false,
|
|
8359
|
-
focusSource: Unknown$1
|
|
8360
|
-
},
|
|
8361
|
-
newState: {
|
|
8362
|
-
uid: completionUid,
|
|
8363
|
-
questions: [],
|
|
8364
|
-
x: 0,
|
|
8365
|
-
y: 0,
|
|
8366
|
-
width: 0,
|
|
8367
|
-
height: 0,
|
|
8368
|
-
focused: true,
|
|
8369
|
-
focusSource: Script
|
|
8370
|
-
}
|
|
8371
|
-
};
|
|
8372
|
-
return widget;
|
|
8373
|
-
};
|
|
8374
|
-
|
|
8375
|
-
const newStateGenerator = async state => {
|
|
8376
|
-
const latestState = {
|
|
8377
|
-
...state,
|
|
8378
|
-
x: 100,
|
|
8379
|
-
y: 100,
|
|
8380
|
-
width: 150,
|
|
8381
|
-
height: 45
|
|
8382
|
-
};
|
|
8383
|
-
return latestState;
|
|
8384
|
-
};
|
|
8385
|
-
const openCodeGenerator = async editor => {
|
|
8386
|
-
const fullFocus = true;
|
|
8387
|
-
return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create, newStateGenerator, fullFocus);
|
|
8388
|
-
};
|
|
8389
|
-
|
|
8390
8485
|
// TODO handle multiple cursors
|
|
8391
8486
|
const moveLineUp = editor => {
|
|
8392
8487
|
// const rowIndex = editor.cursor.rowIndex
|
|
@@ -8911,20 +9006,25 @@ const getCursorsVirtualDom = cursors => {
|
|
|
8911
9006
|
return dom;
|
|
8912
9007
|
};
|
|
8913
9008
|
|
|
9009
|
+
// TODO use numeric value
|
|
8914
9010
|
const Error$1 = 'error';
|
|
8915
9011
|
const Warning = 'warning';
|
|
8916
9012
|
|
|
8917
9013
|
const getDiagnosticClassName = type => {
|
|
8918
|
-
// TODO use classnames enum
|
|
8919
9014
|
switch (type) {
|
|
8920
9015
|
case Error$1:
|
|
8921
|
-
return
|
|
9016
|
+
return DiagnosticError;
|
|
8922
9017
|
case Warning:
|
|
8923
|
-
return
|
|
9018
|
+
return DiagnosticWarning;
|
|
8924
9019
|
default:
|
|
8925
|
-
return
|
|
9020
|
+
return DiagnosticError;
|
|
8926
9021
|
}
|
|
8927
9022
|
};
|
|
9023
|
+
|
|
9024
|
+
const mergeClassNames = (...classNames) => {
|
|
9025
|
+
return classNames.filter(Boolean).join(' ');
|
|
9026
|
+
};
|
|
9027
|
+
|
|
8928
9028
|
const getDiagnosticVirtualDom = diagnostic => {
|
|
8929
9029
|
const {
|
|
8930
9030
|
x,
|
|
@@ -8936,7 +9036,7 @@ const getDiagnosticVirtualDom = diagnostic => {
|
|
|
8936
9036
|
const extraClassName = getDiagnosticClassName(type);
|
|
8937
9037
|
return [{
|
|
8938
9038
|
type: Div,
|
|
8939
|
-
className:
|
|
9039
|
+
className: mergeClassNames(Diagnostic, extraClassName),
|
|
8940
9040
|
width,
|
|
8941
9041
|
height,
|
|
8942
9042
|
top: y,
|
|
@@ -9226,25 +9326,6 @@ const renderEditor = async id => {
|
|
|
9226
9326
|
return commands;
|
|
9227
9327
|
};
|
|
9228
9328
|
|
|
9229
|
-
const isMatchingWidget = widget => {
|
|
9230
|
-
return widget.id === CodeGenerator;
|
|
9231
|
-
};
|
|
9232
|
-
const closeCodeGenerator = editor => {
|
|
9233
|
-
const {
|
|
9234
|
-
widgets
|
|
9235
|
-
} = editor;
|
|
9236
|
-
const index = widgets.findIndex(isMatchingWidget);
|
|
9237
|
-
if (index === -1) {
|
|
9238
|
-
return editor;
|
|
9239
|
-
}
|
|
9240
|
-
const newWidgets = removeEditorWidget(widgets, CodeGenerator);
|
|
9241
|
-
return {
|
|
9242
|
-
...editor,
|
|
9243
|
-
widgets: newWidgets,
|
|
9244
|
-
focused: true
|
|
9245
|
-
};
|
|
9246
|
-
};
|
|
9247
|
-
|
|
9248
9329
|
const keep = [
|
|
9249
9330
|
// 'ColorPicker.handleSliderPointerDown',
|
|
9250
9331
|
// 'ColorPicker.handleSliderPointerMove',
|
|
@@ -9323,11 +9404,6 @@ const wrapCommands = commands => {
|
|
|
9323
9404
|
}
|
|
9324
9405
|
};
|
|
9325
9406
|
|
|
9326
|
-
const codeGeneratorAccept = state => {
|
|
9327
|
-
// TODO close code generator widget
|
|
9328
|
-
return state;
|
|
9329
|
-
};
|
|
9330
|
-
|
|
9331
9407
|
const commandMap = {
|
|
9332
9408
|
'CodeGenerator.accept': codeGeneratorAccept,
|
|
9333
9409
|
'ColorPicker.handleSliderPointerDown': handleSliderPointerDown,
|
|
@@ -9430,6 +9506,7 @@ const commandMap = {
|
|
|
9430
9506
|
'Editor.pasteText': pasteText,
|
|
9431
9507
|
'Editor.render': renderEditor,
|
|
9432
9508
|
'Editor.replaceRange': replaceRange,
|
|
9509
|
+
'Editor.rerender': rerender,
|
|
9433
9510
|
'Editor.save': save,
|
|
9434
9511
|
'Editor.selectAll': selectAll,
|
|
9435
9512
|
'Editor.selectAllLeft': editorSelectAllLeft,
|
|
@@ -10034,10 +10111,6 @@ const removeWidget = widget => {
|
|
|
10034
10111
|
return [['Viewlet.send', widget.newState.uid, 'dispose']];
|
|
10035
10112
|
};
|
|
10036
10113
|
|
|
10037
|
-
const mergeClassNames = (...classNames) => {
|
|
10038
|
-
return classNames.filter(Boolean).join(' ');
|
|
10039
|
-
};
|
|
10040
|
-
|
|
10041
10114
|
const getCodeGeneratorVirtualDom = state => {
|
|
10042
10115
|
const escapeToClose$1 = escapeToClose();
|
|
10043
10116
|
const enterCode$1 = enterCode();
|