@lvce-editor/editor-worker 19.1.0 → 19.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 +177 -177
- package/dist/editorWorkerMain.min.js +1 -1
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1538,12 +1538,12 @@ const launchColorPickerWorker = async () => {
|
|
|
1538
1538
|
return launchWorker(name, url);
|
|
1539
1539
|
};
|
|
1540
1540
|
|
|
1541
|
-
const state$
|
|
1541
|
+
const state$e = {};
|
|
1542
1542
|
const getOrCreate$3 = () => {
|
|
1543
|
-
if (!state$
|
|
1544
|
-
state$
|
|
1543
|
+
if (!state$e.workerPromise) {
|
|
1544
|
+
state$e.workerPromise = launchColorPickerWorker();
|
|
1545
1545
|
}
|
|
1546
|
-
return state$
|
|
1546
|
+
return state$e.workerPromise;
|
|
1547
1547
|
};
|
|
1548
1548
|
const invoke$9 = async (method, ...params) => {
|
|
1549
1549
|
const worker = await getOrCreate$3();
|
|
@@ -1626,6 +1626,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1626
1626
|
fontWeight: 0,
|
|
1627
1627
|
handleOffset: 0,
|
|
1628
1628
|
handleOffsetX: 0,
|
|
1629
|
+
hasListener: false,
|
|
1629
1630
|
height,
|
|
1630
1631
|
highlightedLine: -1,
|
|
1631
1632
|
id,
|
|
@@ -1637,6 +1638,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1637
1638
|
isAutoClosingTagsEnabled: false,
|
|
1638
1639
|
isMonospaceFont: false,
|
|
1639
1640
|
isQuickSuggestionsEnabled: false,
|
|
1641
|
+
isSelecting: false,
|
|
1640
1642
|
itemHeight: 20,
|
|
1641
1643
|
languageId: '',
|
|
1642
1644
|
letterSpacing: 0,
|
|
@@ -1657,6 +1659,10 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1657
1659
|
savedSelections: [],
|
|
1658
1660
|
scrollBarHeight: 0,
|
|
1659
1661
|
scrollBarWidth: 0,
|
|
1662
|
+
selectionAutoMovePosition: {
|
|
1663
|
+
columnIndex: 0,
|
|
1664
|
+
rowIndex: 0
|
|
1665
|
+
},
|
|
1660
1666
|
selectionInfos: [],
|
|
1661
1667
|
selections: new Uint32Array(),
|
|
1662
1668
|
tabSize: 0,
|
|
@@ -1847,7 +1853,7 @@ const getInitialLineState = initialLineState => {
|
|
|
1847
1853
|
return deepCopy(initialLineState);
|
|
1848
1854
|
};
|
|
1849
1855
|
|
|
1850
|
-
const state$
|
|
1856
|
+
const state$d = {
|
|
1851
1857
|
warned: []
|
|
1852
1858
|
};
|
|
1853
1859
|
const flattenTokensArray = tokens => {
|
|
@@ -1859,10 +1865,10 @@ const flattenTokensArray = tokens => {
|
|
|
1859
1865
|
return flattened;
|
|
1860
1866
|
};
|
|
1861
1867
|
const warnDeprecatedArrayReturn = (languageId, fn) => {
|
|
1862
|
-
if (state$
|
|
1868
|
+
if (state$d.warned.includes(fn)) {
|
|
1863
1869
|
return;
|
|
1864
1870
|
}
|
|
1865
|
-
state$
|
|
1871
|
+
state$d.warned.push(fn);
|
|
1866
1872
|
console.warn(`tokenizers without hasArrayReturn=false are deprecated (language ${languageId})`);
|
|
1867
1873
|
};
|
|
1868
1874
|
const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
|
|
@@ -1923,14 +1929,14 @@ const TokenizePlainText = {
|
|
|
1923
1929
|
tokenizeLine
|
|
1924
1930
|
};
|
|
1925
1931
|
|
|
1926
|
-
const state$
|
|
1932
|
+
const state$c = {
|
|
1927
1933
|
enabled: false
|
|
1928
1934
|
};
|
|
1929
1935
|
const setEnabled$1 = value => {
|
|
1930
|
-
state$
|
|
1936
|
+
state$c.enabled = value;
|
|
1931
1937
|
};
|
|
1932
1938
|
const getEnabled$1 = () => {
|
|
1933
|
-
return state$
|
|
1939
|
+
return state$c.enabled;
|
|
1934
1940
|
};
|
|
1935
1941
|
|
|
1936
1942
|
const {
|
|
@@ -1938,25 +1944,25 @@ const {
|
|
|
1938
1944
|
set: set$6
|
|
1939
1945
|
} = SyntaxHighlightingWorker;
|
|
1940
1946
|
|
|
1941
|
-
const state$
|
|
1947
|
+
const state$b = {
|
|
1942
1948
|
pending: Object.create(null),
|
|
1943
1949
|
tokenizePaths: Object.create(null),
|
|
1944
1950
|
tokenizers: Object.create(null)
|
|
1945
1951
|
};
|
|
1946
1952
|
const has = languageId => {
|
|
1947
|
-
return Object.hasOwn(state$
|
|
1953
|
+
return Object.hasOwn(state$b.tokenizers, languageId);
|
|
1948
1954
|
};
|
|
1949
1955
|
const set$5 = (languageId, tokenizer) => {
|
|
1950
|
-
state$
|
|
1956
|
+
state$b.tokenizers[languageId] = tokenizer;
|
|
1951
1957
|
};
|
|
1952
1958
|
const get$5 = languageId => {
|
|
1953
|
-
return state$
|
|
1959
|
+
return state$b.tokenizers[languageId];
|
|
1954
1960
|
};
|
|
1955
1961
|
const setTokenizePath = (languageId, tokenizePath) => {
|
|
1956
|
-
state$
|
|
1962
|
+
state$b.tokenizePaths[languageId] = tokenizePath;
|
|
1957
1963
|
};
|
|
1958
1964
|
const getTokenizePath$1 = languageId => {
|
|
1959
|
-
return state$
|
|
1965
|
+
return state$b.tokenizePaths[languageId] || '';
|
|
1960
1966
|
};
|
|
1961
1967
|
const setTokenizePaths = languages => {
|
|
1962
1968
|
for (const language of languages) {
|
|
@@ -1966,7 +1972,7 @@ const setTokenizePaths = languages => {
|
|
|
1966
1972
|
}
|
|
1967
1973
|
};
|
|
1968
1974
|
const isPending = languageId => {
|
|
1969
|
-
return Object.hasOwn(state$
|
|
1975
|
+
return Object.hasOwn(state$b.pending, languageId);
|
|
1970
1976
|
};
|
|
1971
1977
|
|
|
1972
1978
|
const tokenMaps = Object.create(null);
|
|
@@ -2809,14 +2815,14 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
|
2809
2815
|
};
|
|
2810
2816
|
};
|
|
2811
2817
|
|
|
2812
|
-
const state$
|
|
2818
|
+
const state$a = {
|
|
2813
2819
|
enabled: false
|
|
2814
2820
|
};
|
|
2815
2821
|
const setEnabled = value => {
|
|
2816
|
-
state$
|
|
2822
|
+
state$a.enabled = value;
|
|
2817
2823
|
};
|
|
2818
2824
|
const getEnabled = () => {
|
|
2819
|
-
return state$
|
|
2825
|
+
return state$a.enabled;
|
|
2820
2826
|
};
|
|
2821
2827
|
|
|
2822
2828
|
// TODO this should be in a separate scrolling module
|
|
@@ -2996,7 +3002,7 @@ const getUrlAtOffset = (editor, offset) => {
|
|
|
2996
3002
|
|
|
2997
3003
|
const EditorChange = 1;
|
|
2998
3004
|
|
|
2999
|
-
const state$
|
|
3005
|
+
const state$9 = Object.create(null);
|
|
3000
3006
|
|
|
3001
3007
|
/**
|
|
3002
3008
|
* Register a listener for a specific event type
|
|
@@ -3006,13 +3012,13 @@ const state$a = Object.create(null);
|
|
|
3006
3012
|
const registerListener$1 = (listenerType, rpcId) => {
|
|
3007
3013
|
number(listenerType);
|
|
3008
3014
|
number(rpcId);
|
|
3009
|
-
if (!Object.hasOwn(state$
|
|
3010
|
-
state$
|
|
3015
|
+
if (!Object.hasOwn(state$9, listenerType)) {
|
|
3016
|
+
state$9[listenerType] = [];
|
|
3011
3017
|
}
|
|
3012
3018
|
|
|
3013
3019
|
// Avoid duplicate registrations
|
|
3014
|
-
if (!state$
|
|
3015
|
-
state$
|
|
3020
|
+
if (!state$9[listenerType].includes(rpcId)) {
|
|
3021
|
+
state$9[listenerType].push(rpcId);
|
|
3016
3022
|
}
|
|
3017
3023
|
};
|
|
3018
3024
|
|
|
@@ -3024,10 +3030,10 @@ const registerListener$1 = (listenerType, rpcId) => {
|
|
|
3024
3030
|
const unregisterListener$1 = (listenerType, rpcId) => {
|
|
3025
3031
|
number(listenerType);
|
|
3026
3032
|
number(rpcId);
|
|
3027
|
-
if (Object.hasOwn(state$
|
|
3028
|
-
const index = state$
|
|
3033
|
+
if (Object.hasOwn(state$9, listenerType)) {
|
|
3034
|
+
const index = state$9[listenerType].indexOf(rpcId);
|
|
3029
3035
|
if (index !== -1) {
|
|
3030
|
-
state$
|
|
3036
|
+
state$9[listenerType].splice(index, 1);
|
|
3031
3037
|
}
|
|
3032
3038
|
}
|
|
3033
3039
|
};
|
|
@@ -3039,7 +3045,7 @@ const unregisterListener$1 = (listenerType, rpcId) => {
|
|
|
3039
3045
|
*/
|
|
3040
3046
|
const getListeners = listenerType => {
|
|
3041
3047
|
number(listenerType);
|
|
3042
|
-
return state$
|
|
3048
|
+
return state$9[listenerType] || [];
|
|
3043
3049
|
};
|
|
3044
3050
|
|
|
3045
3051
|
/**
|
|
@@ -3693,9 +3699,11 @@ const emptyEditor = {
|
|
|
3693
3699
|
differences: [],
|
|
3694
3700
|
embeds: [],
|
|
3695
3701
|
focused: false,
|
|
3702
|
+
hasListener: false,
|
|
3696
3703
|
height: 0,
|
|
3697
3704
|
highlightedLine: -1,
|
|
3698
3705
|
incrementalEdits: emptyIncrementalEdits,
|
|
3706
|
+
isSelecting: false,
|
|
3699
3707
|
languageId: '',
|
|
3700
3708
|
// TODO use numeric language id?
|
|
3701
3709
|
lineCache: [],
|
|
@@ -3705,6 +3713,10 @@ const emptyEditor = {
|
|
|
3705
3713
|
minLineY: 0,
|
|
3706
3714
|
redoStack: [],
|
|
3707
3715
|
scrollBarHeight: 0,
|
|
3716
|
+
selectionAutoMovePosition: {
|
|
3717
|
+
columnIndex: 0,
|
|
3718
|
+
rowIndex: 0
|
|
3719
|
+
},
|
|
3708
3720
|
selectionInfos: [],
|
|
3709
3721
|
selections: new Uint32Array(),
|
|
3710
3722
|
textInfos: [],
|
|
@@ -4027,6 +4039,7 @@ const createEditor = async ({
|
|
|
4027
4039
|
fontWeight,
|
|
4028
4040
|
handleOffset: 0,
|
|
4029
4041
|
handleOffsetX: 0,
|
|
4042
|
+
hasListener: false,
|
|
4030
4043
|
height,
|
|
4031
4044
|
id,
|
|
4032
4045
|
incrementalEdits: emptyIncrementalEdits,
|
|
@@ -4036,6 +4049,7 @@ const createEditor = async ({
|
|
|
4036
4049
|
isAutoClosingTagsEnabled,
|
|
4037
4050
|
isMonospaceFont,
|
|
4038
4051
|
isQuickSuggestionsEnabled,
|
|
4052
|
+
isSelecting: false,
|
|
4039
4053
|
itemHeight: 20,
|
|
4040
4054
|
languageId: computedlanguageId,
|
|
4041
4055
|
letterSpacing,
|
|
@@ -4056,6 +4070,10 @@ const createEditor = async ({
|
|
|
4056
4070
|
savedSelections,
|
|
4057
4071
|
scrollBarHeight: 0,
|
|
4058
4072
|
scrollBarWidth: 0,
|
|
4073
|
+
selectionAutoMovePosition: {
|
|
4074
|
+
columnIndex: 0,
|
|
4075
|
+
rowIndex: 0
|
|
4076
|
+
},
|
|
4059
4077
|
selectionInfos: [],
|
|
4060
4078
|
selections: new Uint32Array(),
|
|
4061
4079
|
tabSize,
|
|
@@ -4521,7 +4539,7 @@ const y = (editor, rowIndex) => {
|
|
|
4521
4539
|
return offsetY;
|
|
4522
4540
|
};
|
|
4523
4541
|
|
|
4524
|
-
const state$
|
|
4542
|
+
const state$8 = {
|
|
4525
4543
|
timeout: -1
|
|
4526
4544
|
};
|
|
4527
4545
|
|
|
@@ -4552,7 +4570,7 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError
|
|
|
4552
4570
|
|
|
4553
4571
|
// TODO use wrapper timing module instead of this
|
|
4554
4572
|
// @ts-ignore
|
|
4555
|
-
state$
|
|
4573
|
+
state$8.timeout = setTimeout(handleTimeout, 3000);
|
|
4556
4574
|
}
|
|
4557
4575
|
return editor;
|
|
4558
4576
|
};
|
|
@@ -4572,8 +4590,8 @@ const showErrorMessage = async (editor, rowIndex, columnIndex, message) => {
|
|
|
4572
4590
|
|
|
4573
4591
|
// @ts-ignore
|
|
4574
4592
|
const editorHideMessage = async editor => {
|
|
4575
|
-
clearTimeout(state$
|
|
4576
|
-
state$
|
|
4593
|
+
clearTimeout(state$8.timeout);
|
|
4594
|
+
state$8.timeout = -1;
|
|
4577
4595
|
// await RendererProcess.invoke(/* Viewlet.send */ 'Viewlet.send', /* id */ editor.uid, /* method */ 'hideOverlayMessage')
|
|
4578
4596
|
return editor;
|
|
4579
4597
|
};
|
|
@@ -4689,12 +4707,12 @@ const launchRenameWorker = async () => {
|
|
|
4689
4707
|
return rpc;
|
|
4690
4708
|
};
|
|
4691
4709
|
|
|
4692
|
-
const state$
|
|
4710
|
+
const state$7 = {};
|
|
4693
4711
|
const getOrCreate$2 = () => {
|
|
4694
|
-
if (!state$
|
|
4695
|
-
state$
|
|
4712
|
+
if (!state$7.workerPromise) {
|
|
4713
|
+
state$7.workerPromise = launchRenameWorker();
|
|
4696
4714
|
}
|
|
4697
|
-
return state$
|
|
4715
|
+
return state$7.workerPromise;
|
|
4698
4716
|
};
|
|
4699
4717
|
const invoke$5 = async (method, ...params) => {
|
|
4700
4718
|
const worker = await getOrCreate$2();
|
|
@@ -4814,12 +4832,12 @@ const openColorPicker = async editor => {
|
|
|
4814
4832
|
return addWidgetToEditor(ColorPicker$1, ColorPicker, editor, create$6, newStateGenerator$6);
|
|
4815
4833
|
};
|
|
4816
4834
|
|
|
4817
|
-
const state$
|
|
4835
|
+
const state$6 = {
|
|
4818
4836
|
compositionText: '',
|
|
4819
4837
|
isComposing: false
|
|
4820
4838
|
};
|
|
4821
4839
|
const compositionStart = (editor, event) => {
|
|
4822
|
-
state$
|
|
4840
|
+
state$6.isComposing = true;
|
|
4823
4841
|
return editor;
|
|
4824
4842
|
};
|
|
4825
4843
|
const getCompositionChanges = (selections, data) => {
|
|
@@ -4829,9 +4847,9 @@ const getCompositionChanges = (selections, data) => {
|
|
|
4829
4847
|
const selectionStartColumn = selections[i + 1];
|
|
4830
4848
|
const selectionEndRow = selections[i + 2];
|
|
4831
4849
|
const selectionEndColumn = selections[i + 3];
|
|
4832
|
-
const startColumnIndex = selectionStartColumn - state$
|
|
4850
|
+
const startColumnIndex = selectionStartColumn - state$6.compositionText.length;
|
|
4833
4851
|
changes.push({
|
|
4834
|
-
deleted: [state$
|
|
4852
|
+
deleted: [state$6.compositionText],
|
|
4835
4853
|
end: {
|
|
4836
4854
|
columnIndex: selectionEndColumn,
|
|
4837
4855
|
rowIndex: selectionEndRow
|
|
@@ -4851,7 +4869,7 @@ const compositionUpdate = (editor, data) => {
|
|
|
4851
4869
|
selections
|
|
4852
4870
|
} = editor;
|
|
4853
4871
|
const changes = getCompositionChanges(selections, data);
|
|
4854
|
-
state$
|
|
4872
|
+
state$6.compositionText = data;
|
|
4855
4873
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
4856
4874
|
};
|
|
4857
4875
|
const compositionEnd = (editor, data) => {
|
|
@@ -4859,8 +4877,8 @@ const compositionEnd = (editor, data) => {
|
|
|
4859
4877
|
selections
|
|
4860
4878
|
} = editor;
|
|
4861
4879
|
const changes = getCompositionChanges(selections, data);
|
|
4862
|
-
state$
|
|
4863
|
-
state$
|
|
4880
|
+
state$6.isComposing = false;
|
|
4881
|
+
state$6.compositionText = '';
|
|
4864
4882
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
4865
4883
|
};
|
|
4866
4884
|
|
|
@@ -5960,19 +5978,19 @@ const closeWidgetsMaybe = widgets => {
|
|
|
5960
5978
|
return widgets.filter(isPersistentWidget);
|
|
5961
5979
|
};
|
|
5962
5980
|
|
|
5963
|
-
const state$
|
|
5981
|
+
const state$5 = {
|
|
5964
5982
|
position: {
|
|
5965
5983
|
columnIndex: 0,
|
|
5966
5984
|
rowIndex: 0
|
|
5967
5985
|
}
|
|
5968
5986
|
};
|
|
5969
|
-
const getPosition
|
|
5970
|
-
return state$
|
|
5987
|
+
const getPosition = () => {
|
|
5988
|
+
return state$5.position;
|
|
5971
5989
|
};
|
|
5972
5990
|
|
|
5973
5991
|
// @ts-ignore
|
|
5974
|
-
const setPosition
|
|
5975
|
-
state$
|
|
5992
|
+
const setPosition = position => {
|
|
5993
|
+
state$5.position = position;
|
|
5976
5994
|
};
|
|
5977
5995
|
|
|
5978
5996
|
const openExternal = async (url, platform) => {
|
|
@@ -6039,7 +6057,7 @@ const Alt = 2;
|
|
|
6039
6057
|
|
|
6040
6058
|
const handleSingleClickDefault = (editor, position) => {
|
|
6041
6059
|
// TODO avoid global variables, add them to editor state
|
|
6042
|
-
setPosition
|
|
6060
|
+
setPosition(position);
|
|
6043
6061
|
const widgets = closeWidgetsMaybe(editor.widgets);
|
|
6044
6062
|
return {
|
|
6045
6063
|
...editor,
|
|
@@ -6192,20 +6210,20 @@ const handleMouseDown = (state, button, altKey, ctrlKey, x, y, detail) => {
|
|
|
6192
6210
|
}
|
|
6193
6211
|
};
|
|
6194
6212
|
|
|
6195
|
-
const state$
|
|
6213
|
+
const state$4 = {
|
|
6196
6214
|
editor: undefined,
|
|
6197
6215
|
timeout: -1,
|
|
6198
6216
|
x: 0,
|
|
6199
6217
|
y: 0
|
|
6200
6218
|
};
|
|
6201
6219
|
const get$1 = () => {
|
|
6202
|
-
return state$
|
|
6220
|
+
return state$4;
|
|
6203
6221
|
};
|
|
6204
6222
|
const set$1 = (editor, timeout, x, y) => {
|
|
6205
|
-
state$
|
|
6206
|
-
state$
|
|
6207
|
-
state$
|
|
6208
|
-
state$
|
|
6223
|
+
state$4.editor = editor;
|
|
6224
|
+
state$4.timeout = timeout;
|
|
6225
|
+
state$4.x = x;
|
|
6226
|
+
state$4.y = y;
|
|
6209
6227
|
};
|
|
6210
6228
|
|
|
6211
6229
|
const showHover$1 = async (editor, position) => {
|
|
@@ -6346,59 +6364,25 @@ const editorHandleNativeSelectionChange = (editor, range) => {
|
|
|
6346
6364
|
return scheduleSelections(editor, selections);
|
|
6347
6365
|
};
|
|
6348
6366
|
|
|
6349
|
-
const state$4 = {
|
|
6350
|
-
/**
|
|
6351
|
-
* @type {any}
|
|
6352
|
-
*/
|
|
6353
|
-
currentEditor: undefined,
|
|
6354
|
-
hasListener: false,
|
|
6355
|
-
isSelecting: false,
|
|
6356
|
-
position: {
|
|
6357
|
-
columnIndex: 0,
|
|
6358
|
-
rowIndex: 0
|
|
6359
|
-
}
|
|
6360
|
-
};
|
|
6361
|
-
|
|
6362
|
-
// @ts-ignore
|
|
6363
|
-
const setEditor = editor => {
|
|
6364
|
-
state$4.currentEditor = editor;
|
|
6365
|
-
state$4.hasListener = true;
|
|
6366
|
-
};
|
|
6367
|
-
const clearEditor = () => {
|
|
6368
|
-
state$4.currentEditor = undefined;
|
|
6369
|
-
state$4.hasListener = false;
|
|
6370
|
-
state$4.isSelecting = false;
|
|
6371
|
-
};
|
|
6372
|
-
const startSelecting = () => {
|
|
6373
|
-
state$4.isSelecting = true;
|
|
6374
|
-
};
|
|
6375
|
-
const isSelecting = () => {
|
|
6376
|
-
return state$4.isSelecting;
|
|
6377
|
-
};
|
|
6378
|
-
|
|
6379
|
-
// @ts-ignore
|
|
6380
|
-
const setPosition = position => {
|
|
6381
|
-
state$4.position = position;
|
|
6382
|
-
};
|
|
6383
|
-
const getEditor$1 = () => {
|
|
6384
|
-
return state$4.currentEditor;
|
|
6385
|
-
};
|
|
6386
|
-
const getPosition = () => {
|
|
6387
|
-
return state$4.position;
|
|
6388
|
-
};
|
|
6389
|
-
const hasListener = () => {
|
|
6390
|
-
return state$4.hasListener;
|
|
6391
|
-
};
|
|
6392
|
-
|
|
6393
6367
|
// @ts-ignore
|
|
6394
6368
|
const handlePointerCaptureLost = editor => {
|
|
6395
|
-
|
|
6396
|
-
|
|
6369
|
+
return {
|
|
6370
|
+
...editor,
|
|
6371
|
+
hasListener: false,
|
|
6372
|
+
isSelecting: false,
|
|
6373
|
+
selectionAutoMovePosition: {
|
|
6374
|
+
columnIndex: 0,
|
|
6375
|
+
rowIndex: 0
|
|
6376
|
+
}
|
|
6377
|
+
};
|
|
6397
6378
|
};
|
|
6398
6379
|
|
|
6399
|
-
const handlePointerDown$1 = (state, button, altKey, ctrlKey, x, y, detail) => {
|
|
6400
|
-
|
|
6401
|
-
return
|
|
6380
|
+
const handlePointerDown$1 = async (state, button, altKey, ctrlKey, x, y, detail) => {
|
|
6381
|
+
const newState = await handleMouseDown(state, button, altKey, ctrlKey, x, y, detail);
|
|
6382
|
+
return {
|
|
6383
|
+
...newState,
|
|
6384
|
+
isSelecting: true
|
|
6385
|
+
};
|
|
6402
6386
|
};
|
|
6403
6387
|
|
|
6404
6388
|
const moveRectangleSelection = (editor, position) => {
|
|
@@ -6437,6 +6421,43 @@ const requestAnimationFrame = fn => {
|
|
|
6437
6421
|
globalThis.requestAnimationFrame(fn);
|
|
6438
6422
|
};
|
|
6439
6423
|
|
|
6424
|
+
const shouldUpdateSelectionData = (oldState, newState) => {
|
|
6425
|
+
return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.cursorWidth !== newState.cursorWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
|
|
6426
|
+
};
|
|
6427
|
+
const shouldUpdateVisibleTextData = (oldState, newState) => {
|
|
6428
|
+
if (oldState.textInfos !== newState.textInfos || oldState.differences !== newState.differences) {
|
|
6429
|
+
return false;
|
|
6430
|
+
}
|
|
6431
|
+
return oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.decorations !== newState.decorations || oldState.embeds !== newState.embeds || oldState.deltaX !== newState.deltaX || oldState.width !== newState.width || oldState.highlightedLine !== newState.highlightedLine || oldState.debugEnabled !== newState.debugEnabled;
|
|
6432
|
+
};
|
|
6433
|
+
const updateDerivedState = async (oldState, newState) => {
|
|
6434
|
+
let finalState = newState;
|
|
6435
|
+
if (shouldUpdateVisibleTextData(oldState, newState)) {
|
|
6436
|
+
const syncIncremental = getEnabled();
|
|
6437
|
+
const {
|
|
6438
|
+
differences,
|
|
6439
|
+
textInfos
|
|
6440
|
+
} = await getVisible$1(newState, syncIncremental);
|
|
6441
|
+
finalState = {
|
|
6442
|
+
...newState,
|
|
6443
|
+
differences,
|
|
6444
|
+
textInfos
|
|
6445
|
+
};
|
|
6446
|
+
}
|
|
6447
|
+
if (!shouldUpdateSelectionData(oldState, newState)) {
|
|
6448
|
+
return finalState;
|
|
6449
|
+
}
|
|
6450
|
+
const {
|
|
6451
|
+
cursorInfos,
|
|
6452
|
+
selectionInfos
|
|
6453
|
+
} = await getVisible(finalState);
|
|
6454
|
+
return {
|
|
6455
|
+
...finalState,
|
|
6456
|
+
cursorInfos,
|
|
6457
|
+
selectionInfos
|
|
6458
|
+
};
|
|
6459
|
+
};
|
|
6460
|
+
|
|
6440
6461
|
const LessThan = -1;
|
|
6441
6462
|
const Equal = 0;
|
|
6442
6463
|
const GreaterThan = 1;
|
|
@@ -6491,7 +6512,7 @@ const getNewSelections$5 = (anchor, position) => {
|
|
|
6491
6512
|
|
|
6492
6513
|
// @ts-ignore
|
|
6493
6514
|
const editorMoveSelection = (editor, position) => {
|
|
6494
|
-
const anchor = getPosition
|
|
6515
|
+
const anchor = getPosition();
|
|
6495
6516
|
const newSelections = getNewSelections$5(anchor, position);
|
|
6496
6517
|
// TODO if selection equals previous selection -> do nothing
|
|
6497
6518
|
return scheduleSelections(editor, newSelections);
|
|
@@ -6509,7 +6530,7 @@ const getNewEditor$1 = (editor, position) => {
|
|
|
6509
6530
|
const newMinLineY = position.rowIndex;
|
|
6510
6531
|
const newMaxLineY = position.rowIndex + diff;
|
|
6511
6532
|
const newDeltaY = position.rowIndex * rowHeight;
|
|
6512
|
-
const anchor = getPosition
|
|
6533
|
+
const anchor = getPosition();
|
|
6513
6534
|
const newSelections = new Uint32Array([position.rowIndex - 1, position.columnIndex, anchor.rowIndex, anchor.columnIndex]);
|
|
6514
6535
|
return {
|
|
6515
6536
|
...editor,
|
|
@@ -6524,7 +6545,7 @@ const getNewEditor$1 = (editor, position) => {
|
|
|
6524
6545
|
const newMinLineY = position.rowIndex - diff;
|
|
6525
6546
|
const newMaxLineY = position.rowIndex;
|
|
6526
6547
|
const newDeltaY = newMinLineY * rowHeight;
|
|
6527
|
-
const anchor = getPosition
|
|
6548
|
+
const anchor = getPosition();
|
|
6528
6549
|
const newSelections = new Uint32Array([anchor.rowIndex, anchor.columnIndex, position.rowIndex + 1, position.columnIndex]);
|
|
6529
6550
|
return {
|
|
6530
6551
|
...editor,
|
|
@@ -6536,12 +6557,13 @@ const getNewEditor$1 = (editor, position) => {
|
|
|
6536
6557
|
}
|
|
6537
6558
|
return editor;
|
|
6538
6559
|
};
|
|
6539
|
-
const continueScrollingAndMovingSelection = async
|
|
6540
|
-
const
|
|
6541
|
-
|
|
6560
|
+
const continueScrollingAndMovingSelection = async editorUid => {
|
|
6561
|
+
const editorState = get$7(editorUid);
|
|
6562
|
+
const editor = editorState?.newState;
|
|
6563
|
+
if (!editor || !editor.hasListener || !editor.isSelecting) {
|
|
6542
6564
|
return;
|
|
6543
6565
|
}
|
|
6544
|
-
const position =
|
|
6566
|
+
const position = editor.selectionAutoMovePosition;
|
|
6545
6567
|
if (position.rowIndex === 0) {
|
|
6546
6568
|
return;
|
|
6547
6569
|
}
|
|
@@ -6549,19 +6571,18 @@ const continueScrollingAndMovingSelection = async () => {
|
|
|
6549
6571
|
if (editor === newEditor) {
|
|
6550
6572
|
return;
|
|
6551
6573
|
}
|
|
6552
|
-
// await Viewlet.setState(ViewletModuleId.EditorText, newEditor)
|
|
6553
|
-
setEditor(newEditor);
|
|
6554
6574
|
// @ts-ignore
|
|
6555
6575
|
const delta = position.rowIndex < editor.minLineY ? -1 : 1;
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6576
|
+
const nextEditor = {
|
|
6577
|
+
...newEditor,
|
|
6578
|
+
selectionAutoMovePosition: {
|
|
6579
|
+
columnIndex: position.columnIndex,
|
|
6580
|
+
rowIndex: position.rowIndex + delta
|
|
6581
|
+
}
|
|
6582
|
+
};
|
|
6583
|
+
const newEditorWithDerivedState = await updateDerivedState(editor, nextEditor);
|
|
6584
|
+
set$8(editor.uid, editor, newEditorWithDerivedState);
|
|
6585
|
+
requestAnimationFrame(() => continueScrollingAndMovingSelection(editorUid));
|
|
6565
6586
|
};
|
|
6566
6587
|
|
|
6567
6588
|
// @ts-ignore
|
|
@@ -6570,16 +6591,20 @@ const moveSelectionPx = async (editor, x, y) => {
|
|
|
6570
6591
|
number(x);
|
|
6571
6592
|
number(y);
|
|
6572
6593
|
const position = await at(editor, x, y);
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6594
|
+
const newEditor = editorMoveSelection(editor, position);
|
|
6595
|
+
if (!editor.hasListener && (position.rowIndex < editor.minLineY || position.rowIndex > editor.maxLineY)) {
|
|
6596
|
+
requestAnimationFrame(() => continueScrollingAndMovingSelection(editor.uid));
|
|
6597
|
+
return {
|
|
6598
|
+
...newEditor,
|
|
6599
|
+
hasListener: true,
|
|
6600
|
+
selectionAutoMovePosition: position
|
|
6601
|
+
};
|
|
6577
6602
|
}
|
|
6578
|
-
return
|
|
6603
|
+
return newEditor;
|
|
6579
6604
|
};
|
|
6580
6605
|
|
|
6581
6606
|
const handlePointerMove = async (editor, x, y, altKey) => {
|
|
6582
|
-
if (!isSelecting
|
|
6607
|
+
if (!editor.isSelecting) {
|
|
6583
6608
|
return editor;
|
|
6584
6609
|
}
|
|
6585
6610
|
if (altKey) {
|
|
@@ -6589,8 +6614,15 @@ const handlePointerMove = async (editor, x, y, altKey) => {
|
|
|
6589
6614
|
};
|
|
6590
6615
|
|
|
6591
6616
|
const handlePointerUp = editor => {
|
|
6592
|
-
|
|
6593
|
-
|
|
6617
|
+
return {
|
|
6618
|
+
...editor,
|
|
6619
|
+
hasListener: false,
|
|
6620
|
+
isSelecting: false,
|
|
6621
|
+
selectionAutoMovePosition: {
|
|
6622
|
+
columnIndex: 0,
|
|
6623
|
+
rowIndex: 0
|
|
6624
|
+
}
|
|
6625
|
+
};
|
|
6594
6626
|
};
|
|
6595
6627
|
|
|
6596
6628
|
// @ts-ignore
|
|
@@ -9991,43 +10023,6 @@ const unsetAdditionalFocus = async focusKey => {
|
|
|
9991
10023
|
await invoke$b('Focus.removeAdditionalFocus', focusKey);
|
|
9992
10024
|
};
|
|
9993
10025
|
|
|
9994
|
-
const shouldUpdateSelectionData = (oldState, newState) => {
|
|
9995
|
-
return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.cursorWidth !== newState.cursorWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
|
|
9996
|
-
};
|
|
9997
|
-
const shouldUpdateVisibleTextData = (oldState, newState) => {
|
|
9998
|
-
if (oldState.textInfos !== newState.textInfos || oldState.differences !== newState.differences) {
|
|
9999
|
-
return false;
|
|
10000
|
-
}
|
|
10001
|
-
return oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.decorations !== newState.decorations || oldState.embeds !== newState.embeds || oldState.deltaX !== newState.deltaX || oldState.width !== newState.width || oldState.highlightedLine !== newState.highlightedLine || oldState.debugEnabled !== newState.debugEnabled;
|
|
10002
|
-
};
|
|
10003
|
-
const updateDerivedState = async (oldState, newState) => {
|
|
10004
|
-
let finalState = newState;
|
|
10005
|
-
if (shouldUpdateVisibleTextData(oldState, newState)) {
|
|
10006
|
-
const syncIncremental = getEnabled();
|
|
10007
|
-
const {
|
|
10008
|
-
differences,
|
|
10009
|
-
textInfos
|
|
10010
|
-
} = await getVisible$1(newState, syncIncremental);
|
|
10011
|
-
finalState = {
|
|
10012
|
-
...newState,
|
|
10013
|
-
differences,
|
|
10014
|
-
textInfos
|
|
10015
|
-
};
|
|
10016
|
-
}
|
|
10017
|
-
if (!shouldUpdateSelectionData(oldState, newState)) {
|
|
10018
|
-
return finalState;
|
|
10019
|
-
}
|
|
10020
|
-
const {
|
|
10021
|
-
cursorInfos,
|
|
10022
|
-
selectionInfos
|
|
10023
|
-
} = await getVisible(finalState);
|
|
10024
|
-
return {
|
|
10025
|
-
...finalState,
|
|
10026
|
-
cursorInfos,
|
|
10027
|
-
selectionInfos
|
|
10028
|
-
};
|
|
10029
|
-
};
|
|
10030
|
-
|
|
10031
10026
|
const FocusEditor = 12;
|
|
10032
10027
|
const FocusEditorCompletions = 9;
|
|
10033
10028
|
const FocusEditorRename = 11;
|
|
@@ -11143,7 +11138,7 @@ const renderCss = (oldState, newState) => {
|
|
|
11143
11138
|
};
|
|
11144
11139
|
|
|
11145
11140
|
const renderFocus$2 = (oldState, newState) => {
|
|
11146
|
-
const selector = '.EditorInput';
|
|
11141
|
+
const selector = '.EditorInput textarea';
|
|
11147
11142
|
return [FocusSelector, newState.uid, selector];
|
|
11148
11143
|
};
|
|
11149
11144
|
|
|
@@ -11414,6 +11409,10 @@ const diffTree = (oldNodes, newNodes) => {
|
|
|
11414
11409
|
|
|
11415
11410
|
const getEditorInputVirtualDom = () => {
|
|
11416
11411
|
return [{
|
|
11412
|
+
childCount: 1,
|
|
11413
|
+
className: 'EditorInput',
|
|
11414
|
+
type: Div
|
|
11415
|
+
}, {
|
|
11417
11416
|
ariaAutoComplete: 'list',
|
|
11418
11417
|
ariaMultiLine: 'true',
|
|
11419
11418
|
ariaRoleDescription: 'editor',
|
|
@@ -11421,7 +11420,6 @@ const getEditorInputVirtualDom = () => {
|
|
|
11421
11420
|
autocomplete: 'off',
|
|
11422
11421
|
autocorrect: 'off',
|
|
11423
11422
|
childCount: 0,
|
|
11424
|
-
className: 'EditorInput',
|
|
11425
11423
|
name: 'editor',
|
|
11426
11424
|
onBeforeInput: HandleBeforeInput,
|
|
11427
11425
|
onBlur: HandleBlur,
|
|
@@ -11679,13 +11677,14 @@ const getEditorVirtualDom = ({
|
|
|
11679
11677
|
selectionInfos = [],
|
|
11680
11678
|
textInfos
|
|
11681
11679
|
}) => {
|
|
11680
|
+
const gutterDom = lineNumbers ? getEditorGutterVirtualDom(gutterInfos) : [];
|
|
11682
11681
|
return [{
|
|
11683
|
-
childCount: 2,
|
|
11682
|
+
childCount: lineNumbers ? 2 : 1,
|
|
11684
11683
|
className: 'Viewlet Editor',
|
|
11685
11684
|
onContextMenu: HandleContextMenu,
|
|
11686
11685
|
role: 'code',
|
|
11687
11686
|
type: Div
|
|
11688
|
-
}, ...
|
|
11687
|
+
}, ...gutterDom, ...getEditorContentVirtualDom({
|
|
11689
11688
|
cursorInfos,
|
|
11690
11689
|
deltaY,
|
|
11691
11690
|
diagnostics,
|
|
@@ -11882,16 +11881,17 @@ const renderGutterInfo = {
|
|
|
11882
11881
|
maxLineY,
|
|
11883
11882
|
minLineY
|
|
11884
11883
|
} = newState;
|
|
11884
|
+
if (!lineNumbers) {
|
|
11885
|
+
return [];
|
|
11886
|
+
}
|
|
11885
11887
|
const gutterInfos = [];
|
|
11886
|
-
|
|
11887
|
-
|
|
11888
|
-
gutterInfos.push(i + 1);
|
|
11889
|
-
}
|
|
11888
|
+
for (let i = minLineY; i < maxLineY; i++) {
|
|
11889
|
+
gutterInfos.push(i + 1);
|
|
11890
11890
|
}
|
|
11891
11891
|
const dom = getEditorGutterVirtualDom$1(gutterInfos);
|
|
11892
11892
|
return ['renderGutter', dom];
|
|
11893
11893
|
},
|
|
11894
|
-
isEqual: (oldState, newState) => oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY
|
|
11894
|
+
isEqual: (oldState, newState) => oldState.lineNumbers === newState.lineNumbers && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY
|
|
11895
11895
|
};
|
|
11896
11896
|
const renderWidgets = {
|
|
11897
11897
|
apply(oldState, newState) {
|