@lvce-editor/editor-worker 1.12.0 → 1.14.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 +9 -45
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -3532,7 +3532,6 @@ const Alt = 2;
|
|
|
3532
3532
|
|
|
3533
3533
|
// TODO first change cursor position, then run go to definition
|
|
3534
3534
|
// cursor should appear at mousedown position immediately
|
|
3535
|
-
// @ts-ignore
|
|
3536
3535
|
const handleSingleClickWithAlt = async (editor, position) => {
|
|
3537
3536
|
const {
|
|
3538
3537
|
rowIndex,
|
|
@@ -3547,8 +3546,6 @@ const handleSingleClickWithAlt = async (editor, position) => {
|
|
|
3547
3546
|
const newEditor2 = await goToDefinition(newEditor);
|
|
3548
3547
|
return newEditor2;
|
|
3549
3548
|
};
|
|
3550
|
-
|
|
3551
|
-
// @ts-ignore
|
|
3552
3549
|
const handleSingleClickWithCtrl = async (editor, position) => {
|
|
3553
3550
|
const selections = editor.selections;
|
|
3554
3551
|
for (let i = 0; i < selections.length; i += 4) {
|
|
@@ -3572,8 +3569,6 @@ const handleSingleClickWithCtrl = async (editor, position) => {
|
|
|
3572
3569
|
newSelections[insertIndex + 3] = position.columnIndex;
|
|
3573
3570
|
return scheduleSelections(editor, newSelections);
|
|
3574
3571
|
};
|
|
3575
|
-
|
|
3576
|
-
// @ts-ignore
|
|
3577
3572
|
const handleSingleClickDefault = (editor, position) => {
|
|
3578
3573
|
setPosition$1(position);
|
|
3579
3574
|
return {
|
|
@@ -3582,8 +3577,6 @@ const handleSingleClickDefault = (editor, position) => {
|
|
|
3582
3577
|
focused: true
|
|
3583
3578
|
};
|
|
3584
3579
|
};
|
|
3585
|
-
|
|
3586
|
-
// @ts-ignore
|
|
3587
3580
|
const getFn = modifier => {
|
|
3588
3581
|
switch (modifier) {
|
|
3589
3582
|
case Alt:
|
|
@@ -3594,8 +3587,6 @@ const getFn = modifier => {
|
|
|
3594
3587
|
return handleSingleClickDefault;
|
|
3595
3588
|
}
|
|
3596
3589
|
};
|
|
3597
|
-
|
|
3598
|
-
// @ts-ignore
|
|
3599
3590
|
const handleSingleClick = async (editor, modifier, x, y) => {
|
|
3600
3591
|
object(editor);
|
|
3601
3592
|
number$1(modifier);
|
|
@@ -3647,7 +3638,6 @@ const handleTripleClick = (editor, modifier, x, y) => {
|
|
|
3647
3638
|
};
|
|
3648
3639
|
};
|
|
3649
3640
|
|
|
3650
|
-
// @ts-ignore
|
|
3651
3641
|
const handleMouseDown = (state, modifier, x, y, detail) => {
|
|
3652
3642
|
switch (detail) {
|
|
3653
3643
|
case Single:
|
|
@@ -7768,7 +7758,7 @@ const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true) =>
|
|
|
7768
7758
|
return dom;
|
|
7769
7759
|
};
|
|
7770
7760
|
|
|
7771
|
-
const getIncrementalEdits = (oldState, newState) => {
|
|
7761
|
+
const getIncrementalEdits = async (oldState, newState) => {
|
|
7772
7762
|
if (!newState.undoStack) {
|
|
7773
7763
|
return undefined;
|
|
7774
7764
|
}
|
|
@@ -7780,39 +7770,8 @@ const getIncrementalEdits = (oldState, newState) => {
|
|
|
7780
7770
|
const lines = newState.lines;
|
|
7781
7771
|
const oldLine = oldState.lines[rowIndex];
|
|
7782
7772
|
const newLine = lines[rowIndex];
|
|
7783
|
-
const
|
|
7784
|
-
|
|
7785
|
-
const initialLineState = newState.lineCache[rowIndex] || getInitialLineState(newTokenizer.initialLineState);
|
|
7786
|
-
const {
|
|
7787
|
-
tokens: oldTokens
|
|
7788
|
-
} = safeTokenizeLine(newState.languageId, oldTokenizer.tokenizeLine, oldLine, initialLineState, newTokenizer.hasArrayReturn);
|
|
7789
|
-
// @ts-ignore
|
|
7790
|
-
const {
|
|
7791
|
-
tokens: newTokens,
|
|
7792
|
-
lineState
|
|
7793
|
-
} = safeTokenizeLine(newState.languageId, newTokenizer.tokenizeLine, newLine, initialLineState, newTokenizer.hasArrayReturn);
|
|
7794
|
-
if (newTokens.length !== oldTokens.length) {
|
|
7795
|
-
return undefined;
|
|
7796
|
-
}
|
|
7797
|
-
const incrementalEdits = [];
|
|
7798
|
-
let offset = 0;
|
|
7799
|
-
const relativeRowIndex = rowIndex - newState.minLineY;
|
|
7800
|
-
for (let i = 0; i < oldTokens.length; i += 2) {
|
|
7801
|
-
const oldTokenType = oldTokens[i];
|
|
7802
|
-
const oldTokenLength = oldTokens[i + 1];
|
|
7803
|
-
const newTokenType = newTokens[i];
|
|
7804
|
-
const newTokenLength = newTokens[i + 1];
|
|
7805
|
-
if (oldTokenType === newTokenType && oldTokenLength !== newTokenLength && oldTokenLength > 0) {
|
|
7806
|
-
const columnTokenIndex = i / 2;
|
|
7807
|
-
incrementalEdits.push({
|
|
7808
|
-
rowIndex: relativeRowIndex,
|
|
7809
|
-
columnIndex: columnTokenIndex,
|
|
7810
|
-
text: newLine.slice(offset, offset + newTokenLength)
|
|
7811
|
-
});
|
|
7812
|
-
}
|
|
7813
|
-
offset += newTokenLength;
|
|
7814
|
-
}
|
|
7815
|
-
if (incrementalEdits.length === 1) {
|
|
7773
|
+
const incrementalEdits = await invoke$1('TokenizeIncremental.tokenizeIncremental', newState.uid, newState.languageId, oldLine, newLine, rowIndex, newState.minLineY);
|
|
7774
|
+
if (incrementalEdits && incrementalEdits.length === 1) {
|
|
7816
7775
|
return incrementalEdits;
|
|
7817
7776
|
}
|
|
7818
7777
|
}
|
|
@@ -7844,7 +7803,7 @@ const renderLines = {
|
|
|
7844
7803
|
return oldState.lines === newState.lines && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.deltaX === newState.deltaX && oldState.width === newState.width;
|
|
7845
7804
|
},
|
|
7846
7805
|
async apply(oldState, newState) {
|
|
7847
|
-
const incrementalEdits = getIncrementalEdits(oldState, newState);
|
|
7806
|
+
const incrementalEdits = await getIncrementalEdits(oldState, newState);
|
|
7848
7807
|
if (incrementalEdits) {
|
|
7849
7808
|
return [/* method */'setIncrementalEdits', /* incrementalEdits */incrementalEdits];
|
|
7850
7809
|
}
|
|
@@ -7898,6 +7857,11 @@ const renderFocus = {
|
|
|
7898
7857
|
return oldState.focused === newState.focused;
|
|
7899
7858
|
},
|
|
7900
7859
|
apply(oldState, newState) {
|
|
7860
|
+
// TODO avoid side effect
|
|
7861
|
+
if (newState.focused) {
|
|
7862
|
+
const FocusEditorText = 12;
|
|
7863
|
+
invoke$3('Focus.setFocus', FocusEditorText);
|
|
7864
|
+
}
|
|
7901
7865
|
return [/* method */'setFocused', newState.focused];
|
|
7902
7866
|
}
|
|
7903
7867
|
};
|