@lvce-editor/editor-worker 19.2.0 → 19.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/README.md +144 -1
- package/dist/editorWorkerMain.js +115 -123
- 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$d = {};
|
|
1542
1542
|
const getOrCreate$3 = () => {
|
|
1543
|
-
if (!state$
|
|
1544
|
-
state$
|
|
1543
|
+
if (!state$d.workerPromise) {
|
|
1544
|
+
state$d.workerPromise = launchColorPickerWorker();
|
|
1545
1545
|
}
|
|
1546
|
-
return state$
|
|
1546
|
+
return state$d.workerPromise;
|
|
1547
1547
|
};
|
|
1548
1548
|
const invoke$9 = async (method, ...params) => {
|
|
1549
1549
|
const worker = await getOrCreate$3();
|
|
@@ -1659,6 +1659,10 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1659
1659
|
savedSelections: [],
|
|
1660
1660
|
scrollBarHeight: 0,
|
|
1661
1661
|
scrollBarWidth: 0,
|
|
1662
|
+
selectionAnchorPosition: {
|
|
1663
|
+
columnIndex: 0,
|
|
1664
|
+
rowIndex: 0
|
|
1665
|
+
},
|
|
1662
1666
|
selectionAutoMovePosition: {
|
|
1663
1667
|
columnIndex: 0,
|
|
1664
1668
|
rowIndex: 0
|
|
@@ -1853,7 +1857,7 @@ const getInitialLineState = initialLineState => {
|
|
|
1853
1857
|
return deepCopy(initialLineState);
|
|
1854
1858
|
};
|
|
1855
1859
|
|
|
1856
|
-
const state$
|
|
1860
|
+
const state$c = {
|
|
1857
1861
|
warned: []
|
|
1858
1862
|
};
|
|
1859
1863
|
const flattenTokensArray = tokens => {
|
|
@@ -1865,10 +1869,10 @@ const flattenTokensArray = tokens => {
|
|
|
1865
1869
|
return flattened;
|
|
1866
1870
|
};
|
|
1867
1871
|
const warnDeprecatedArrayReturn = (languageId, fn) => {
|
|
1868
|
-
if (state$
|
|
1872
|
+
if (state$c.warned.includes(fn)) {
|
|
1869
1873
|
return;
|
|
1870
1874
|
}
|
|
1871
|
-
state$
|
|
1875
|
+
state$c.warned.push(fn);
|
|
1872
1876
|
console.warn(`tokenizers without hasArrayReturn=false are deprecated (language ${languageId})`);
|
|
1873
1877
|
};
|
|
1874
1878
|
const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
|
|
@@ -1929,14 +1933,14 @@ const TokenizePlainText = {
|
|
|
1929
1933
|
tokenizeLine
|
|
1930
1934
|
};
|
|
1931
1935
|
|
|
1932
|
-
const state$
|
|
1936
|
+
const state$b = {
|
|
1933
1937
|
enabled: false
|
|
1934
1938
|
};
|
|
1935
1939
|
const setEnabled$1 = value => {
|
|
1936
|
-
state$
|
|
1940
|
+
state$b.enabled = value;
|
|
1937
1941
|
};
|
|
1938
1942
|
const getEnabled$1 = () => {
|
|
1939
|
-
return state$
|
|
1943
|
+
return state$b.enabled;
|
|
1940
1944
|
};
|
|
1941
1945
|
|
|
1942
1946
|
const {
|
|
@@ -1944,25 +1948,25 @@ const {
|
|
|
1944
1948
|
set: set$6
|
|
1945
1949
|
} = SyntaxHighlightingWorker;
|
|
1946
1950
|
|
|
1947
|
-
const state$
|
|
1951
|
+
const state$a = {
|
|
1948
1952
|
pending: Object.create(null),
|
|
1949
1953
|
tokenizePaths: Object.create(null),
|
|
1950
1954
|
tokenizers: Object.create(null)
|
|
1951
1955
|
};
|
|
1952
1956
|
const has = languageId => {
|
|
1953
|
-
return Object.hasOwn(state$
|
|
1957
|
+
return Object.hasOwn(state$a.tokenizers, languageId);
|
|
1954
1958
|
};
|
|
1955
1959
|
const set$5 = (languageId, tokenizer) => {
|
|
1956
|
-
state$
|
|
1960
|
+
state$a.tokenizers[languageId] = tokenizer;
|
|
1957
1961
|
};
|
|
1958
1962
|
const get$5 = languageId => {
|
|
1959
|
-
return state$
|
|
1963
|
+
return state$a.tokenizers[languageId];
|
|
1960
1964
|
};
|
|
1961
1965
|
const setTokenizePath = (languageId, tokenizePath) => {
|
|
1962
|
-
state$
|
|
1966
|
+
state$a.tokenizePaths[languageId] = tokenizePath;
|
|
1963
1967
|
};
|
|
1964
1968
|
const getTokenizePath$1 = languageId => {
|
|
1965
|
-
return state$
|
|
1969
|
+
return state$a.tokenizePaths[languageId] || '';
|
|
1966
1970
|
};
|
|
1967
1971
|
const setTokenizePaths = languages => {
|
|
1968
1972
|
for (const language of languages) {
|
|
@@ -1972,7 +1976,7 @@ const setTokenizePaths = languages => {
|
|
|
1972
1976
|
}
|
|
1973
1977
|
};
|
|
1974
1978
|
const isPending = languageId => {
|
|
1975
|
-
return Object.hasOwn(state$
|
|
1979
|
+
return Object.hasOwn(state$a.pending, languageId);
|
|
1976
1980
|
};
|
|
1977
1981
|
|
|
1978
1982
|
const tokenMaps = Object.create(null);
|
|
@@ -2815,14 +2819,14 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
|
2815
2819
|
};
|
|
2816
2820
|
};
|
|
2817
2821
|
|
|
2818
|
-
const state$
|
|
2822
|
+
const state$9 = {
|
|
2819
2823
|
enabled: false
|
|
2820
2824
|
};
|
|
2821
2825
|
const setEnabled = value => {
|
|
2822
|
-
state$
|
|
2826
|
+
state$9.enabled = value;
|
|
2823
2827
|
};
|
|
2824
2828
|
const getEnabled = () => {
|
|
2825
|
-
return state$
|
|
2829
|
+
return state$9.enabled;
|
|
2826
2830
|
};
|
|
2827
2831
|
|
|
2828
2832
|
// TODO this should be in a separate scrolling module
|
|
@@ -3002,7 +3006,7 @@ const getUrlAtOffset = (editor, offset) => {
|
|
|
3002
3006
|
|
|
3003
3007
|
const EditorChange = 1;
|
|
3004
3008
|
|
|
3005
|
-
const state$
|
|
3009
|
+
const state$8 = Object.create(null);
|
|
3006
3010
|
|
|
3007
3011
|
/**
|
|
3008
3012
|
* Register a listener for a specific event type
|
|
@@ -3012,13 +3016,13 @@ const state$9 = Object.create(null);
|
|
|
3012
3016
|
const registerListener$1 = (listenerType, rpcId) => {
|
|
3013
3017
|
number(listenerType);
|
|
3014
3018
|
number(rpcId);
|
|
3015
|
-
if (!Object.hasOwn(state$
|
|
3016
|
-
state$
|
|
3019
|
+
if (!Object.hasOwn(state$8, listenerType)) {
|
|
3020
|
+
state$8[listenerType] = [];
|
|
3017
3021
|
}
|
|
3018
3022
|
|
|
3019
3023
|
// Avoid duplicate registrations
|
|
3020
|
-
if (!state$
|
|
3021
|
-
state$
|
|
3024
|
+
if (!state$8[listenerType].includes(rpcId)) {
|
|
3025
|
+
state$8[listenerType].push(rpcId);
|
|
3022
3026
|
}
|
|
3023
3027
|
};
|
|
3024
3028
|
|
|
@@ -3030,10 +3034,10 @@ const registerListener$1 = (listenerType, rpcId) => {
|
|
|
3030
3034
|
const unregisterListener$1 = (listenerType, rpcId) => {
|
|
3031
3035
|
number(listenerType);
|
|
3032
3036
|
number(rpcId);
|
|
3033
|
-
if (Object.hasOwn(state$
|
|
3034
|
-
const index = state$
|
|
3037
|
+
if (Object.hasOwn(state$8, listenerType)) {
|
|
3038
|
+
const index = state$8[listenerType].indexOf(rpcId);
|
|
3035
3039
|
if (index !== -1) {
|
|
3036
|
-
state$
|
|
3040
|
+
state$8[listenerType].splice(index, 1);
|
|
3037
3041
|
}
|
|
3038
3042
|
}
|
|
3039
3043
|
};
|
|
@@ -3045,7 +3049,7 @@ const unregisterListener$1 = (listenerType, rpcId) => {
|
|
|
3045
3049
|
*/
|
|
3046
3050
|
const getListeners = listenerType => {
|
|
3047
3051
|
number(listenerType);
|
|
3048
|
-
return state$
|
|
3052
|
+
return state$8[listenerType] || [];
|
|
3049
3053
|
};
|
|
3050
3054
|
|
|
3051
3055
|
/**
|
|
@@ -3713,6 +3717,10 @@ const emptyEditor = {
|
|
|
3713
3717
|
minLineY: 0,
|
|
3714
3718
|
redoStack: [],
|
|
3715
3719
|
scrollBarHeight: 0,
|
|
3720
|
+
selectionAnchorPosition: {
|
|
3721
|
+
columnIndex: 0,
|
|
3722
|
+
rowIndex: 0
|
|
3723
|
+
},
|
|
3716
3724
|
selectionAutoMovePosition: {
|
|
3717
3725
|
columnIndex: 0,
|
|
3718
3726
|
rowIndex: 0
|
|
@@ -4070,6 +4078,10 @@ const createEditor = async ({
|
|
|
4070
4078
|
savedSelections,
|
|
4071
4079
|
scrollBarHeight: 0,
|
|
4072
4080
|
scrollBarWidth: 0,
|
|
4081
|
+
selectionAnchorPosition: {
|
|
4082
|
+
columnIndex: 0,
|
|
4083
|
+
rowIndex: 0
|
|
4084
|
+
},
|
|
4073
4085
|
selectionAutoMovePosition: {
|
|
4074
4086
|
columnIndex: 0,
|
|
4075
4087
|
rowIndex: 0
|
|
@@ -4140,7 +4152,7 @@ const createEditor = async ({
|
|
|
4140
4152
|
};
|
|
4141
4153
|
|
|
4142
4154
|
const isEqual$2 = (oldState, newState) => {
|
|
4143
|
-
return oldState.rowHeight === newState.rowHeight && oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.scrollBarHeight === newState.scrollBarHeight;
|
|
4155
|
+
return oldState.rowHeight === newState.rowHeight && oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.deltaX === newState.deltaX && oldState.longestLineWidth === newState.longestLineWidth && oldState.minimumSliderSize === newState.minimumSliderSize && oldState.width === newState.width && oldState.scrollBarHeight === newState.scrollBarHeight;
|
|
4144
4156
|
};
|
|
4145
4157
|
|
|
4146
4158
|
const isEqual$1 = (oldState, newState) => {
|
|
@@ -4151,7 +4163,7 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
4151
4163
|
};
|
|
4152
4164
|
|
|
4153
4165
|
const isEqual = (oldState, newState) => {
|
|
4154
|
-
return oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.highlightedLine === newState.highlightedLine && oldState.lineNumbers === newState.lineNumbers && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.
|
|
4166
|
+
return oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.highlightedLine === newState.highlightedLine && oldState.lineNumbers === newState.lineNumbers && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.selectionInfos === newState.selectionInfos;
|
|
4155
4167
|
};
|
|
4156
4168
|
|
|
4157
4169
|
const RenderFocus = 6;
|
|
@@ -4539,7 +4551,7 @@ const y = (editor, rowIndex) => {
|
|
|
4539
4551
|
return offsetY;
|
|
4540
4552
|
};
|
|
4541
4553
|
|
|
4542
|
-
const state$
|
|
4554
|
+
const state$7 = {
|
|
4543
4555
|
timeout: -1
|
|
4544
4556
|
};
|
|
4545
4557
|
|
|
@@ -4570,7 +4582,7 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError
|
|
|
4570
4582
|
|
|
4571
4583
|
// TODO use wrapper timing module instead of this
|
|
4572
4584
|
// @ts-ignore
|
|
4573
|
-
state$
|
|
4585
|
+
state$7.timeout = setTimeout(handleTimeout, 3000);
|
|
4574
4586
|
}
|
|
4575
4587
|
return editor;
|
|
4576
4588
|
};
|
|
@@ -4590,8 +4602,8 @@ const showErrorMessage = async (editor, rowIndex, columnIndex, message) => {
|
|
|
4590
4602
|
|
|
4591
4603
|
// @ts-ignore
|
|
4592
4604
|
const editorHideMessage = async editor => {
|
|
4593
|
-
clearTimeout(state$
|
|
4594
|
-
state$
|
|
4605
|
+
clearTimeout(state$7.timeout);
|
|
4606
|
+
state$7.timeout = -1;
|
|
4595
4607
|
// await RendererProcess.invoke(/* Viewlet.send */ 'Viewlet.send', /* id */ editor.uid, /* method */ 'hideOverlayMessage')
|
|
4596
4608
|
return editor;
|
|
4597
4609
|
};
|
|
@@ -4707,12 +4719,12 @@ const launchRenameWorker = async () => {
|
|
|
4707
4719
|
return rpc;
|
|
4708
4720
|
};
|
|
4709
4721
|
|
|
4710
|
-
const state$
|
|
4722
|
+
const state$6 = {};
|
|
4711
4723
|
const getOrCreate$2 = () => {
|
|
4712
|
-
if (!state$
|
|
4713
|
-
state$
|
|
4724
|
+
if (!state$6.workerPromise) {
|
|
4725
|
+
state$6.workerPromise = launchRenameWorker();
|
|
4714
4726
|
}
|
|
4715
|
-
return state$
|
|
4727
|
+
return state$6.workerPromise;
|
|
4716
4728
|
};
|
|
4717
4729
|
const invoke$5 = async (method, ...params) => {
|
|
4718
4730
|
const worker = await getOrCreate$2();
|
|
@@ -4832,12 +4844,12 @@ const openColorPicker = async editor => {
|
|
|
4832
4844
|
return addWidgetToEditor(ColorPicker$1, ColorPicker, editor, create$6, newStateGenerator$6);
|
|
4833
4845
|
};
|
|
4834
4846
|
|
|
4835
|
-
const state$
|
|
4847
|
+
const state$5 = {
|
|
4836
4848
|
compositionText: '',
|
|
4837
4849
|
isComposing: false
|
|
4838
4850
|
};
|
|
4839
4851
|
const compositionStart = (editor, event) => {
|
|
4840
|
-
state$
|
|
4852
|
+
state$5.isComposing = true;
|
|
4841
4853
|
return editor;
|
|
4842
4854
|
};
|
|
4843
4855
|
const getCompositionChanges = (selections, data) => {
|
|
@@ -4847,9 +4859,9 @@ const getCompositionChanges = (selections, data) => {
|
|
|
4847
4859
|
const selectionStartColumn = selections[i + 1];
|
|
4848
4860
|
const selectionEndRow = selections[i + 2];
|
|
4849
4861
|
const selectionEndColumn = selections[i + 3];
|
|
4850
|
-
const startColumnIndex = selectionStartColumn - state$
|
|
4862
|
+
const startColumnIndex = selectionStartColumn - state$5.compositionText.length;
|
|
4851
4863
|
changes.push({
|
|
4852
|
-
deleted: [state$
|
|
4864
|
+
deleted: [state$5.compositionText],
|
|
4853
4865
|
end: {
|
|
4854
4866
|
columnIndex: selectionEndColumn,
|
|
4855
4867
|
rowIndex: selectionEndRow
|
|
@@ -4869,7 +4881,7 @@ const compositionUpdate = (editor, data) => {
|
|
|
4869
4881
|
selections
|
|
4870
4882
|
} = editor;
|
|
4871
4883
|
const changes = getCompositionChanges(selections, data);
|
|
4872
|
-
state$
|
|
4884
|
+
state$5.compositionText = data;
|
|
4873
4885
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
4874
4886
|
};
|
|
4875
4887
|
const compositionEnd = (editor, data) => {
|
|
@@ -4877,8 +4889,8 @@ const compositionEnd = (editor, data) => {
|
|
|
4877
4889
|
selections
|
|
4878
4890
|
} = editor;
|
|
4879
4891
|
const changes = getCompositionChanges(selections, data);
|
|
4880
|
-
state$
|
|
4881
|
-
state$
|
|
4892
|
+
state$5.isComposing = false;
|
|
4893
|
+
state$5.compositionText = '';
|
|
4882
4894
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
4883
4895
|
};
|
|
4884
4896
|
|
|
@@ -5978,21 +5990,6 @@ const closeWidgetsMaybe = widgets => {
|
|
|
5978
5990
|
return widgets.filter(isPersistentWidget);
|
|
5979
5991
|
};
|
|
5980
5992
|
|
|
5981
|
-
const state$5 = {
|
|
5982
|
-
position: {
|
|
5983
|
-
columnIndex: 0,
|
|
5984
|
-
rowIndex: 0
|
|
5985
|
-
}
|
|
5986
|
-
};
|
|
5987
|
-
const getPosition = () => {
|
|
5988
|
-
return state$5.position;
|
|
5989
|
-
};
|
|
5990
|
-
|
|
5991
|
-
// @ts-ignore
|
|
5992
|
-
const setPosition = position => {
|
|
5993
|
-
state$5.position = position;
|
|
5994
|
-
};
|
|
5995
|
-
|
|
5996
5993
|
const openExternal = async (url, platform) => {
|
|
5997
5994
|
await openUrl(url, platform);
|
|
5998
5995
|
};
|
|
@@ -6056,12 +6053,11 @@ const Ctrl = 1;
|
|
|
6056
6053
|
const Alt = 2;
|
|
6057
6054
|
|
|
6058
6055
|
const handleSingleClickDefault = (editor, position) => {
|
|
6059
|
-
// TODO avoid global variables, add them to editor state
|
|
6060
|
-
setPosition(position);
|
|
6061
6056
|
const widgets = closeWidgetsMaybe(editor.widgets);
|
|
6062
6057
|
return {
|
|
6063
6058
|
...editor,
|
|
6064
6059
|
focused: true,
|
|
6060
|
+
selectionAnchorPosition: position,
|
|
6065
6061
|
selections: new Uint32Array([position.rowIndex, position.columnIndex, position.rowIndex, position.columnIndex]),
|
|
6066
6062
|
widgets
|
|
6067
6063
|
};
|
|
@@ -6150,6 +6146,16 @@ const Single = 1;
|
|
|
6150
6146
|
const Double = 2;
|
|
6151
6147
|
const Triple = 3;
|
|
6152
6148
|
|
|
6149
|
+
const getModifier = (altKey, ctrlKey) => {
|
|
6150
|
+
if (altKey) {
|
|
6151
|
+
return Alt;
|
|
6152
|
+
}
|
|
6153
|
+
if (ctrlKey) {
|
|
6154
|
+
return Ctrl;
|
|
6155
|
+
}
|
|
6156
|
+
return 0;
|
|
6157
|
+
};
|
|
6158
|
+
|
|
6153
6159
|
const handleSingleClick = async (editor, modifier, x, y) => {
|
|
6154
6160
|
object(editor);
|
|
6155
6161
|
number(modifier);
|
|
@@ -6187,27 +6193,26 @@ const handleTripleClick = (editor, modifier, x, y) => {
|
|
|
6187
6193
|
return selectLine(editor);
|
|
6188
6194
|
};
|
|
6189
6195
|
|
|
6190
|
-
const
|
|
6191
|
-
if (altKey) {
|
|
6192
|
-
return Alt;
|
|
6193
|
-
}
|
|
6194
|
-
if (ctrlKey) {
|
|
6195
|
-
return Ctrl;
|
|
6196
|
-
}
|
|
6197
|
-
return 0;
|
|
6198
|
-
};
|
|
6199
|
-
const handleMouseDown = (state, button, altKey, ctrlKey, x, y, detail) => {
|
|
6196
|
+
const handleMouseDown = async (state, button, altKey, ctrlKey, x, y, detail) => {
|
|
6200
6197
|
const modifier = getModifier(altKey, ctrlKey);
|
|
6198
|
+
let newState;
|
|
6201
6199
|
switch (detail) {
|
|
6202
6200
|
case Double:
|
|
6203
|
-
|
|
6201
|
+
newState = await handleDoubleClick(state, modifier, x, y);
|
|
6202
|
+
break;
|
|
6204
6203
|
case Single:
|
|
6205
|
-
|
|
6204
|
+
newState = await handleSingleClick(state, modifier, x, y);
|
|
6205
|
+
break;
|
|
6206
6206
|
case Triple:
|
|
6207
|
-
|
|
6207
|
+
newState = handleTripleClick(state, modifier, x, y);
|
|
6208
|
+
break;
|
|
6208
6209
|
default:
|
|
6209
6210
|
return state;
|
|
6210
6211
|
}
|
|
6212
|
+
return {
|
|
6213
|
+
...newState,
|
|
6214
|
+
isSelecting: true
|
|
6215
|
+
};
|
|
6211
6216
|
};
|
|
6212
6217
|
|
|
6213
6218
|
const state$4 = {
|
|
@@ -6378,11 +6383,7 @@ const handlePointerCaptureLost = editor => {
|
|
|
6378
6383
|
};
|
|
6379
6384
|
|
|
6380
6385
|
const handlePointerDown$1 = async (state, button, altKey, ctrlKey, x, y, detail) => {
|
|
6381
|
-
|
|
6382
|
-
return {
|
|
6383
|
-
...newState,
|
|
6384
|
-
isSelecting: true
|
|
6385
|
-
};
|
|
6386
|
+
return state;
|
|
6386
6387
|
};
|
|
6387
6388
|
|
|
6388
6389
|
const moveRectangleSelection = (editor, position) => {
|
|
@@ -6512,7 +6513,7 @@ const getNewSelections$5 = (anchor, position) => {
|
|
|
6512
6513
|
|
|
6513
6514
|
// @ts-ignore
|
|
6514
6515
|
const editorMoveSelection = (editor, position) => {
|
|
6515
|
-
const anchor =
|
|
6516
|
+
const anchor = editor.selectionAnchorPosition;
|
|
6516
6517
|
const newSelections = getNewSelections$5(anchor, position);
|
|
6517
6518
|
// TODO if selection equals previous selection -> do nothing
|
|
6518
6519
|
return scheduleSelections(editor, newSelections);
|
|
@@ -6530,7 +6531,7 @@ const getNewEditor$1 = (editor, position) => {
|
|
|
6530
6531
|
const newMinLineY = position.rowIndex;
|
|
6531
6532
|
const newMaxLineY = position.rowIndex + diff;
|
|
6532
6533
|
const newDeltaY = position.rowIndex * rowHeight;
|
|
6533
|
-
const anchor =
|
|
6534
|
+
const anchor = editor.selectionAnchorPosition;
|
|
6534
6535
|
const newSelections = new Uint32Array([position.rowIndex - 1, position.columnIndex, anchor.rowIndex, anchor.columnIndex]);
|
|
6535
6536
|
return {
|
|
6536
6537
|
...editor,
|
|
@@ -6545,7 +6546,7 @@ const getNewEditor$1 = (editor, position) => {
|
|
|
6545
6546
|
const newMinLineY = position.rowIndex - diff;
|
|
6546
6547
|
const newMaxLineY = position.rowIndex;
|
|
6547
6548
|
const newDeltaY = newMinLineY * rowHeight;
|
|
6548
|
-
const anchor =
|
|
6549
|
+
const anchor = editor.selectionAnchorPosition;
|
|
6549
6550
|
const newSelections = new Uint32Array([anchor.rowIndex, anchor.columnIndex, position.rowIndex + 1, position.columnIndex]);
|
|
6550
6551
|
return {
|
|
6551
6552
|
...editor,
|
|
@@ -11106,11 +11107,13 @@ const registerListener = (listenerType, rpcId) => {
|
|
|
11106
11107
|
registerListener$1(listenerType, rpcId);
|
|
11107
11108
|
};
|
|
11108
11109
|
|
|
11109
|
-
const getCss = (rowHeight, scrollBarHeight, scrollBarTop) => {
|
|
11110
|
+
const getCss = (rowHeight, scrollBarHeight, scrollBarTop, scrollBarWidth, scrollBarLeft) => {
|
|
11110
11111
|
return `.Editor {
|
|
11111
11112
|
--EditorRowHeight: ${rowHeight}px;
|
|
11112
11113
|
--ScrollBarHeight: ${scrollBarHeight}px;
|
|
11113
11114
|
--ScrollBarTop: ${scrollBarTop}px;
|
|
11115
|
+
--ScrollBarWidth: ${scrollBarWidth}px;
|
|
11116
|
+
--ScrollBarLeft: ${scrollBarLeft}px;
|
|
11114
11117
|
}
|
|
11115
11118
|
.Editor .EditorRow {
|
|
11116
11119
|
height: var(--EditorRowHeight);
|
|
@@ -11120,20 +11123,37 @@ const getCss = (rowHeight, scrollBarHeight, scrollBarTop) => {
|
|
|
11120
11123
|
height: var(--ScrollBarHeight);
|
|
11121
11124
|
translate: 0px var(--ScrollBarTop);
|
|
11122
11125
|
}
|
|
11126
|
+
.Editor .ScrollBarThumbHorizontal {
|
|
11127
|
+
width: var(--ScrollBarWidth);
|
|
11128
|
+
translate: var(--ScrollBarLeft) 0px;
|
|
11129
|
+
}
|
|
11123
11130
|
`;
|
|
11124
11131
|
};
|
|
11125
11132
|
|
|
11126
|
-
const
|
|
11133
|
+
const getScrollBarLeft = (deltaX, longestLineWidth, width) => {
|
|
11134
|
+
const scrollBarLeft = deltaX / longestLineWidth * width;
|
|
11135
|
+
if (!Number.isFinite(scrollBarLeft)) {
|
|
11136
|
+
return 0;
|
|
11137
|
+
}
|
|
11138
|
+
return scrollBarLeft;
|
|
11139
|
+
};
|
|
11140
|
+
const renderCss$1 = (oldState, newState) => {
|
|
11127
11141
|
const {
|
|
11142
|
+
deltaX,
|
|
11128
11143
|
deltaY,
|
|
11129
11144
|
finalDeltaY,
|
|
11130
11145
|
height,
|
|
11146
|
+
longestLineWidth,
|
|
11147
|
+
minimumSliderSize,
|
|
11131
11148
|
rowHeight,
|
|
11132
11149
|
scrollBarHeight,
|
|
11133
|
-
uid
|
|
11150
|
+
uid,
|
|
11151
|
+
width
|
|
11134
11152
|
} = newState;
|
|
11135
11153
|
const scrollBarTop = getScrollBarY(deltaY, finalDeltaY, height, scrollBarHeight);
|
|
11136
|
-
const
|
|
11154
|
+
const scrollBarWidth = getScrollBarSize(width, longestLineWidth, minimumSliderSize);
|
|
11155
|
+
const scrollBarLeft = getScrollBarLeft(deltaX, longestLineWidth, width);
|
|
11156
|
+
const css = getCss(rowHeight, scrollBarHeight, scrollBarTop, scrollBarWidth, scrollBarLeft);
|
|
11137
11157
|
return [SetCss$1, uid, css];
|
|
11138
11158
|
};
|
|
11139
11159
|
|
|
@@ -11593,8 +11613,7 @@ const getEditorScrollBarDiagnosticsVirtualDom = scrollBarDiagnostics => {
|
|
|
11593
11613
|
}, ...getDiagnosticsVirtualDom([...scrollBarDiagnostics])];
|
|
11594
11614
|
};
|
|
11595
11615
|
|
|
11596
|
-
const getScrollBarVirtualDom = (
|
|
11597
|
-
const scrollBarY = getScrollBarY(deltaY, finalDeltaY, height, scrollBarHeight);
|
|
11616
|
+
const getScrollBarVirtualDom = () => {
|
|
11598
11617
|
return [{
|
|
11599
11618
|
childCount: 1,
|
|
11600
11619
|
className: 'ScrollBar ScrollBarVertical',
|
|
@@ -11604,8 +11623,6 @@ const getScrollBarVirtualDom = (deltaY, finalDeltaY, height, scrollBarHeight) =>
|
|
|
11604
11623
|
}, {
|
|
11605
11624
|
childCount: 0,
|
|
11606
11625
|
className: 'ScrollBarThumb ScrollBarThumbVertical',
|
|
11607
|
-
style: `height:${scrollBarHeight}px;`,
|
|
11608
|
-
translate: `0 ${scrollBarY}px`,
|
|
11609
11626
|
type: Div
|
|
11610
11627
|
}, {
|
|
11611
11628
|
childCount: 1,
|
|
@@ -11621,15 +11638,11 @@ const getScrollBarVirtualDom = (deltaY, finalDeltaY, height, scrollBarHeight) =>
|
|
|
11621
11638
|
|
|
11622
11639
|
const getEditorContentVirtualDom = ({
|
|
11623
11640
|
cursorInfos = [],
|
|
11624
|
-
deltaY = 0,
|
|
11625
11641
|
diagnostics = [],
|
|
11626
11642
|
differences,
|
|
11627
|
-
finalDeltaY = 0,
|
|
11628
|
-
height = 0,
|
|
11629
11643
|
highlightedLine = -1,
|
|
11630
11644
|
lineNumbers = true,
|
|
11631
11645
|
scrollBarDiagnostics = [],
|
|
11632
|
-
scrollBarHeight = 0,
|
|
11633
11646
|
selectionInfos = [],
|
|
11634
11647
|
textInfos
|
|
11635
11648
|
}) => {
|
|
@@ -11638,7 +11651,7 @@ const getEditorContentVirtualDom = ({
|
|
|
11638
11651
|
className: 'EditorContent',
|
|
11639
11652
|
onMouseMove: HandleMouseMove,
|
|
11640
11653
|
type: Div
|
|
11641
|
-
}, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom(
|
|
11654
|
+
}, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom()];
|
|
11642
11655
|
};
|
|
11643
11656
|
|
|
11644
11657
|
const getGutterInfoVirtualDom = gutterInfo => {
|
|
@@ -11664,16 +11677,12 @@ const getEditorGutterVirtualDom = gutterInfos => {
|
|
|
11664
11677
|
|
|
11665
11678
|
const getEditorVirtualDom = ({
|
|
11666
11679
|
cursorInfos = [],
|
|
11667
|
-
deltaY = 0,
|
|
11668
11680
|
diagnostics = [],
|
|
11669
11681
|
differences,
|
|
11670
|
-
finalDeltaY = 0,
|
|
11671
11682
|
gutterInfos = [],
|
|
11672
|
-
height = 0,
|
|
11673
11683
|
highlightedLine = -1,
|
|
11674
11684
|
lineNumbers = true,
|
|
11675
11685
|
scrollBarDiagnostics = [],
|
|
11676
|
-
scrollBarHeight = 0,
|
|
11677
11686
|
selectionInfos = [],
|
|
11678
11687
|
textInfos
|
|
11679
11688
|
}) => {
|
|
@@ -11686,15 +11695,11 @@ const getEditorVirtualDom = ({
|
|
|
11686
11695
|
type: Div
|
|
11687
11696
|
}, ...gutterDom, ...getEditorContentVirtualDom({
|
|
11688
11697
|
cursorInfos,
|
|
11689
|
-
deltaY,
|
|
11690
11698
|
diagnostics,
|
|
11691
11699
|
differences,
|
|
11692
|
-
finalDeltaY,
|
|
11693
|
-
height,
|
|
11694
11700
|
highlightedLine,
|
|
11695
11701
|
lineNumbers,
|
|
11696
11702
|
scrollBarDiagnostics,
|
|
11697
|
-
scrollBarHeight,
|
|
11698
11703
|
selectionInfos,
|
|
11699
11704
|
textInfos
|
|
11700
11705
|
})];
|
|
@@ -11742,7 +11747,7 @@ const renderIncremental = (oldState, newState) => {
|
|
|
11742
11747
|
const getRenderer = diffType => {
|
|
11743
11748
|
switch (diffType) {
|
|
11744
11749
|
case RenderCss:
|
|
11745
|
-
return renderCss;
|
|
11750
|
+
return renderCss$1;
|
|
11746
11751
|
case RenderFocus:
|
|
11747
11752
|
return renderFocus$2;
|
|
11748
11753
|
case RenderFocusContext:
|
|
@@ -11833,22 +11838,9 @@ const renderSelections = {
|
|
|
11833
11838
|
},
|
|
11834
11839
|
isEqual: (oldState, newState) => oldState.cursorInfos === newState.cursorInfos && oldState.selectionInfos === newState.selectionInfos
|
|
11835
11840
|
};
|
|
11836
|
-
const
|
|
11837
|
-
apply
|
|
11838
|
-
|
|
11839
|
-
const translate = `0 ${scrollBarY}px`;
|
|
11840
|
-
const heightPx = `${newState.scrollBarHeight}px`;
|
|
11841
|
-
return [/* method */'setScrollBar', translate, heightPx];
|
|
11842
|
-
},
|
|
11843
|
-
isEqual: (oldState, newState) => oldState.deltaY === newState.deltaY && oldState.scrollBarHeight === newState.scrollBarHeight
|
|
11844
|
-
};
|
|
11845
|
-
const renderScrollBarX = {
|
|
11846
|
-
apply(oldState, newState) {
|
|
11847
|
-
const scrollBarWidth = getScrollBarSize(newState.width, newState.longestLineWidth, newState.minimumSliderSize);
|
|
11848
|
-
const scrollBarX = newState.deltaX / newState.longestLineWidth * newState.width;
|
|
11849
|
-
return [/* method */'setScrollBarHorizontal', /* scrollBarX */scrollBarX, /* scrollBarWidth */scrollBarWidth, /* deltaX */newState.deltaX];
|
|
11850
|
-
},
|
|
11851
|
-
isEqual: (oldState, newState) => oldState.longestLineWidth === newState.longestLineWidth && oldState.deltaX === newState.deltaX
|
|
11841
|
+
const renderCss = {
|
|
11842
|
+
apply: renderCss$1,
|
|
11843
|
+
isEqual: isEqual$2
|
|
11852
11844
|
};
|
|
11853
11845
|
const renderFocus$1 = {
|
|
11854
11846
|
apply: (oldState, newState) => [/* method */'setFocused', newState.focused],
|
|
@@ -11948,7 +11940,7 @@ const renderWidgets = {
|
|
|
11948
11940
|
isEqual: (oldState, newState) => oldState.widgets === newState.widgets,
|
|
11949
11941
|
multiple: true
|
|
11950
11942
|
};
|
|
11951
|
-
const render$6 = [renderLines, renderSelections,
|
|
11943
|
+
const render$6 = [renderLines, renderSelections, renderCss, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets, renderFocusContext, renderAdditionalFocusContext];
|
|
11952
11944
|
const renderEditor = async id => {
|
|
11953
11945
|
const instance = get$7(id);
|
|
11954
11946
|
if (!instance) {
|