@lvce-editor/editor-worker 19.29.15 → 19.29.16
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 +68 -51
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -67,7 +67,7 @@ const String$1 = 4;
|
|
|
67
67
|
const Boolean$1 = 5;
|
|
68
68
|
const Function$1 = 6;
|
|
69
69
|
const Null = 7;
|
|
70
|
-
const Unknown$
|
|
70
|
+
const Unknown$3 = 8;
|
|
71
71
|
const getType = value => {
|
|
72
72
|
switch (typeof value) {
|
|
73
73
|
case 'number':
|
|
@@ -87,7 +87,7 @@ const getType = value => {
|
|
|
87
87
|
case 'boolean':
|
|
88
88
|
return Boolean$1;
|
|
89
89
|
default:
|
|
90
|
-
return Unknown$
|
|
90
|
+
return Unknown$3;
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
const object = value => {
|
|
@@ -2090,6 +2090,7 @@ const InsertLineBreak = 'insertLineBreak';
|
|
|
2090
2090
|
const LineComment = 'lineComment';
|
|
2091
2091
|
const Rename = 'rename';
|
|
2092
2092
|
const ToggleBlockComment$1 = 'toggleBlockComment';
|
|
2093
|
+
const Unknown$2 = 'unknown';
|
|
2093
2094
|
|
|
2094
2095
|
const map$1 = Object.create(null);
|
|
2095
2096
|
const set$7 = (id, widget) => {
|
|
@@ -12604,59 +12605,75 @@ const loadContent = async (state, savedState) => {
|
|
|
12604
12605
|
return newEditor5;
|
|
12605
12606
|
};
|
|
12606
12607
|
|
|
12607
|
-
|
|
12608
|
-
|
|
12609
|
-
|
|
12608
|
+
const getSelectedLineRange = (selections, primarySelectionIndex) => {
|
|
12609
|
+
const [startRowIndex,, selectionEndRowIndex, endColumnIndex] = getSelectionPairs(selections, primarySelectionIndex);
|
|
12610
|
+
const endRowIndex = startRowIndex < selectionEndRowIndex && endColumnIndex === 0 ? selectionEndRowIndex - 1 : selectionEndRowIndex;
|
|
12611
|
+
return {
|
|
12612
|
+
endRowIndex,
|
|
12613
|
+
startRowIndex
|
|
12614
|
+
};
|
|
12615
|
+
};
|
|
12616
|
+
const movePositionDown = (lines, rowIndex, columnIndex) => {
|
|
12617
|
+
const newRowIndex = rowIndex + 1;
|
|
12618
|
+
if (newRowIndex < lines.length) {
|
|
12619
|
+
return [newRowIndex, columnIndex];
|
|
12620
|
+
}
|
|
12621
|
+
const lastRowIndex = lines.length - 1;
|
|
12622
|
+
return [lastRowIndex, lines[rowIndex - 1].length];
|
|
12623
|
+
};
|
|
12624
|
+
const getSelectionChanges = (lines, selections, primarySelectionIndex, direction) => {
|
|
12625
|
+
const startRowIndex = selections[primarySelectionIndex];
|
|
12626
|
+
const startColumnIndex = selections[primarySelectionIndex + 1];
|
|
12627
|
+
const endRowIndex = selections[primarySelectionIndex + 2];
|
|
12628
|
+
const endColumnIndex = selections[primarySelectionIndex + 3];
|
|
12629
|
+
if (direction < 0) {
|
|
12630
|
+
return new Uint32Array([startRowIndex - 1, startColumnIndex, endRowIndex - 1, endColumnIndex]);
|
|
12631
|
+
}
|
|
12632
|
+
const [newStartRowIndex, newStartColumnIndex] = movePositionDown(lines, startRowIndex, startColumnIndex);
|
|
12633
|
+
const [newEndRowIndex, newEndColumnIndex] = movePositionDown(lines, endRowIndex, endColumnIndex);
|
|
12634
|
+
return new Uint32Array([newStartRowIndex, newStartColumnIndex, newEndRowIndex, newEndColumnIndex]);
|
|
12635
|
+
};
|
|
12636
|
+
const moveLines = (editor, direction) => {
|
|
12637
|
+
const {
|
|
12638
|
+
lines,
|
|
12639
|
+
primarySelectionIndex = 0,
|
|
12640
|
+
selections
|
|
12641
|
+
} = editor;
|
|
12642
|
+
const {
|
|
12643
|
+
endRowIndex,
|
|
12644
|
+
startRowIndex
|
|
12645
|
+
} = getSelectedLineRange(selections, primarySelectionIndex);
|
|
12646
|
+
const lastRowIndex = lines.length - 1;
|
|
12647
|
+
if (direction < 0 && startRowIndex === 0 || direction > 0 && endRowIndex === lastRowIndex) {
|
|
12648
|
+
return editor;
|
|
12649
|
+
}
|
|
12650
|
+
const editStartRowIndex = direction < 0 ? startRowIndex - 1 : startRowIndex;
|
|
12651
|
+
const editEndRowIndex = direction < 0 ? endRowIndex : endRowIndex + 1;
|
|
12652
|
+
const selectedLines = lines.slice(startRowIndex, endRowIndex + 1);
|
|
12653
|
+
const inserted = direction < 0 ? [...selectedLines, lines[startRowIndex - 1]] : [lines[endRowIndex + 1], ...selectedLines];
|
|
12654
|
+
const changes = [{
|
|
12655
|
+
deleted: lines.slice(editStartRowIndex, editEndRowIndex + 1),
|
|
12656
|
+
end: {
|
|
12657
|
+
columnIndex: lines[editEndRowIndex].length,
|
|
12658
|
+
rowIndex: editEndRowIndex
|
|
12659
|
+
},
|
|
12660
|
+
inserted,
|
|
12661
|
+
origin: Unknown$2,
|
|
12662
|
+
start: {
|
|
12663
|
+
columnIndex: 0,
|
|
12664
|
+
rowIndex: editStartRowIndex
|
|
12665
|
+
}
|
|
12666
|
+
}];
|
|
12667
|
+
const selectionChanges = getSelectionChanges(lines, selections, primarySelectionIndex, direction);
|
|
12668
|
+
return scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
|
|
12669
|
+
};
|
|
12670
|
+
|
|
12610
12671
|
const moveLineDown = editor => {
|
|
12611
|
-
|
|
12612
|
-
// if (rowIndex === editor.lines.length - 1) {
|
|
12613
|
-
// return
|
|
12614
|
-
// }
|
|
12615
|
-
// const documentEdits = [
|
|
12616
|
-
// {
|
|
12617
|
-
// type: /* splice */ 2,
|
|
12618
|
-
// rowIndex: rowIndex,
|
|
12619
|
-
// count: 2,
|
|
12620
|
-
// newLines: [TextDocument.getLine(editor.textDocument, rowIndex + 1), TextDocument.getLine(editor.textDocument, rowIndex)],
|
|
12621
|
-
// },
|
|
12622
|
-
// ]
|
|
12623
|
-
// // @ts-ignore
|
|
12624
|
-
// const cursorEdits = Editor.moveCursors(editor, (editor, cursor) => {
|
|
12625
|
-
// return {
|
|
12626
|
-
// rowIndex: cursor.rowIndex + 1,
|
|
12627
|
-
// columnIndex: cursor.columnIndex,
|
|
12628
|
-
// }
|
|
12629
|
-
// })
|
|
12630
|
-
// @ts-ignore
|
|
12631
|
-
// Editor.scheduleDocumentAndCursors(editor, documentEdits, cursorEdits)
|
|
12632
|
-
return editor;
|
|
12672
|
+
return moveLines(editor, 1);
|
|
12633
12673
|
};
|
|
12634
12674
|
|
|
12635
|
-
// TODO handle multiple cursors
|
|
12636
12675
|
const moveLineUp = editor => {
|
|
12637
|
-
|
|
12638
|
-
// if (rowIndex === 0) {
|
|
12639
|
-
// return
|
|
12640
|
-
// }
|
|
12641
|
-
// const documentEdits = [
|
|
12642
|
-
// {
|
|
12643
|
-
// type: /* splice */ 2,
|
|
12644
|
-
// rowIndex: rowIndex - 1,
|
|
12645
|
-
// count: 2,
|
|
12646
|
-
// newLines: [TextDocument.getLine(editor.textDocument, rowIndex), TextDocument.getLine(editor.textDocument, rowIndex - 1)],
|
|
12647
|
-
// },
|
|
12648
|
-
// ]
|
|
12649
|
-
// // @ts-ignore
|
|
12650
|
-
// const cursorEdits = Editor.moveCursors(editor, (editor, cursor) => {
|
|
12651
|
-
// return {
|
|
12652
|
-
// // TODO handle bottom 0
|
|
12653
|
-
// rowIndex: cursor.rowIndex - 1,
|
|
12654
|
-
// columnIndex: cursor.columnIndex,
|
|
12655
|
-
// }
|
|
12656
|
-
// })
|
|
12657
|
-
// // @ts-ignore
|
|
12658
|
-
// Editor.scheduleDocumentAndCursors(editor, documentEdits, cursorEdits)
|
|
12659
|
-
return editor;
|
|
12676
|
+
return moveLines(editor, -1);
|
|
12660
12677
|
};
|
|
12661
12678
|
|
|
12662
12679
|
/**
|