@lvce-editor/editor-worker 19.67.0 → 19.67.2
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 +36 -5
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -7665,7 +7665,7 @@ const getCopyLineOperations = selections => {
|
|
|
7665
7665
|
}
|
|
7666
7666
|
return mergedOperations;
|
|
7667
7667
|
};
|
|
7668
|
-
const copyLineDown = editor => {
|
|
7668
|
+
const copyLineDown = async editor => {
|
|
7669
7669
|
const {
|
|
7670
7670
|
selections
|
|
7671
7671
|
} = editor;
|
|
@@ -7704,7 +7704,8 @@ const copyLineDown = editor => {
|
|
|
7704
7704
|
selectionChanges[i + 2] = selections[i + 2] + getRowOffset(selections[i + 2]);
|
|
7705
7705
|
selectionChanges[i + 3] = selections[i + 3];
|
|
7706
7706
|
}
|
|
7707
|
-
|
|
7707
|
+
const newEditor = await scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
|
|
7708
|
+
return typeof newEditor.finalDeltaY === 'number' ? scheduleSelections(newEditor, selectionChanges) : newEditor;
|
|
7708
7709
|
};
|
|
7709
7710
|
|
|
7710
7711
|
const copyLineUp = editor => {
|
|
@@ -12775,9 +12776,39 @@ const getMatchingClosingBrace = brace => {
|
|
|
12775
12776
|
};
|
|
12776
12777
|
const typeWithAutoClosingBracket = (editor, text) => {
|
|
12777
12778
|
const closingBracket = getMatchingClosingBrace(text);
|
|
12778
|
-
const
|
|
12779
|
-
const
|
|
12780
|
-
|
|
12779
|
+
const changes = editorReplaceSelections(editor, [text + closingBracket], EditorTypeWithAutoClosing);
|
|
12780
|
+
const selectionChanges = new Uint32Array(editor.selections.length);
|
|
12781
|
+
let lineDelta = 0;
|
|
12782
|
+
for (let i = 0; i < changes.length; i++) {
|
|
12783
|
+
const selectionIndex = i * 4;
|
|
12784
|
+
const change = changes[i];
|
|
12785
|
+
const isEmptySelection = change.start.rowIndex === change.end.rowIndex && change.start.columnIndex === change.end.columnIndex;
|
|
12786
|
+
const selection = editor.selections.subarray(selectionIndex, selectionIndex + 4);
|
|
12787
|
+
const isReversedSelection = selection[0] > selection[2] || selection[0] === selection[2] && selection[1] > selection[3];
|
|
12788
|
+
if (isEmptySelection) {
|
|
12789
|
+
selectionChanges[selectionIndex] = change.start.rowIndex + lineDelta;
|
|
12790
|
+
selectionChanges[selectionIndex + 1] = change.start.columnIndex + 1;
|
|
12791
|
+
selectionChanges[selectionIndex + 2] = change.start.rowIndex + lineDelta;
|
|
12792
|
+
selectionChanges[selectionIndex + 3] = change.start.columnIndex + 1;
|
|
12793
|
+
} else {
|
|
12794
|
+
change.inserted = change.deleted.length === 1 ? [text + change.deleted[0] + closingBracket] : [text + change.deleted[0], ...change.deleted.slice(1, -1), change.deleted.at(-1) + closingBracket];
|
|
12795
|
+
const start = {
|
|
12796
|
+
columnIndex: change.start.columnIndex + 1,
|
|
12797
|
+
rowIndex: change.start.rowIndex + lineDelta
|
|
12798
|
+
};
|
|
12799
|
+
const end = {
|
|
12800
|
+
columnIndex: (change.inserted.length === 1 ? change.start.columnIndex + change.inserted[0].length : change.inserted.at(-1).length) - 1,
|
|
12801
|
+
rowIndex: start.rowIndex + change.inserted.length - 1
|
|
12802
|
+
};
|
|
12803
|
+
const anchor = isReversedSelection ? end : start;
|
|
12804
|
+
const active = isReversedSelection ? start : end;
|
|
12805
|
+
selectionChanges[selectionIndex] = anchor.rowIndex;
|
|
12806
|
+
selectionChanges[selectionIndex + 1] = anchor.columnIndex;
|
|
12807
|
+
selectionChanges[selectionIndex + 2] = active.rowIndex;
|
|
12808
|
+
selectionChanges[selectionIndex + 3] = active.columnIndex;
|
|
12809
|
+
}
|
|
12810
|
+
lineDelta += change.inserted.length - change.deleted.length;
|
|
12811
|
+
}
|
|
12781
12812
|
// @ts-ignore
|
|
12782
12813
|
return scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
|
|
12783
12814
|
};
|