@lvce-editor/editor-worker 19.29.14 → 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 +71 -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) => {
|
|
@@ -12246,6 +12247,9 @@ const applyTabCompletion = (editor, result) => {
|
|
|
12246
12247
|
};
|
|
12247
12248
|
|
|
12248
12249
|
const handleTab = async editor => {
|
|
12250
|
+
if (!isEverySelectionEmpty(editor.selections)) {
|
|
12251
|
+
return indentMore(editor);
|
|
12252
|
+
}
|
|
12249
12253
|
const result = await getTabCompletion(editor);
|
|
12250
12254
|
if (!result) {
|
|
12251
12255
|
// TODO enter tab or two spaces
|
|
@@ -12601,59 +12605,75 @@ const loadContent = async (state, savedState) => {
|
|
|
12601
12605
|
return newEditor5;
|
|
12602
12606
|
};
|
|
12603
12607
|
|
|
12604
|
-
|
|
12605
|
-
|
|
12606
|
-
|
|
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
|
+
|
|
12607
12671
|
const moveLineDown = editor => {
|
|
12608
|
-
|
|
12609
|
-
// if (rowIndex === editor.lines.length - 1) {
|
|
12610
|
-
// return
|
|
12611
|
-
// }
|
|
12612
|
-
// const documentEdits = [
|
|
12613
|
-
// {
|
|
12614
|
-
// type: /* splice */ 2,
|
|
12615
|
-
// rowIndex: rowIndex,
|
|
12616
|
-
// count: 2,
|
|
12617
|
-
// newLines: [TextDocument.getLine(editor.textDocument, rowIndex + 1), TextDocument.getLine(editor.textDocument, rowIndex)],
|
|
12618
|
-
// },
|
|
12619
|
-
// ]
|
|
12620
|
-
// // @ts-ignore
|
|
12621
|
-
// const cursorEdits = Editor.moveCursors(editor, (editor, cursor) => {
|
|
12622
|
-
// return {
|
|
12623
|
-
// rowIndex: cursor.rowIndex + 1,
|
|
12624
|
-
// columnIndex: cursor.columnIndex,
|
|
12625
|
-
// }
|
|
12626
|
-
// })
|
|
12627
|
-
// @ts-ignore
|
|
12628
|
-
// Editor.scheduleDocumentAndCursors(editor, documentEdits, cursorEdits)
|
|
12629
|
-
return editor;
|
|
12672
|
+
return moveLines(editor, 1);
|
|
12630
12673
|
};
|
|
12631
12674
|
|
|
12632
|
-
// TODO handle multiple cursors
|
|
12633
12675
|
const moveLineUp = editor => {
|
|
12634
|
-
|
|
12635
|
-
// if (rowIndex === 0) {
|
|
12636
|
-
// return
|
|
12637
|
-
// }
|
|
12638
|
-
// const documentEdits = [
|
|
12639
|
-
// {
|
|
12640
|
-
// type: /* splice */ 2,
|
|
12641
|
-
// rowIndex: rowIndex - 1,
|
|
12642
|
-
// count: 2,
|
|
12643
|
-
// newLines: [TextDocument.getLine(editor.textDocument, rowIndex), TextDocument.getLine(editor.textDocument, rowIndex - 1)],
|
|
12644
|
-
// },
|
|
12645
|
-
// ]
|
|
12646
|
-
// // @ts-ignore
|
|
12647
|
-
// const cursorEdits = Editor.moveCursors(editor, (editor, cursor) => {
|
|
12648
|
-
// return {
|
|
12649
|
-
// // TODO handle bottom 0
|
|
12650
|
-
// rowIndex: cursor.rowIndex - 1,
|
|
12651
|
-
// columnIndex: cursor.columnIndex,
|
|
12652
|
-
// }
|
|
12653
|
-
// })
|
|
12654
|
-
// // @ts-ignore
|
|
12655
|
-
// Editor.scheduleDocumentAndCursors(editor, documentEdits, cursorEdits)
|
|
12656
|
-
return editor;
|
|
12676
|
+
return moveLines(editor, -1);
|
|
12657
12677
|
};
|
|
12658
12678
|
|
|
12659
12679
|
/**
|