@lvce-editor/editor-worker 19.75.2 → 19.75.4
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/diff-sdk.js +22 -11
- package/dist/editorWorkerMain.js +22 -11
- package/package.json +1 -1
package/dist/diff-sdk.js
CHANGED
|
@@ -4741,7 +4741,7 @@ const getSelectionFromChange = change => {
|
|
|
4741
4741
|
start: newPosition
|
|
4742
4742
|
};
|
|
4743
4743
|
};
|
|
4744
|
-
const setSelections$2 = (editor, selections) => {
|
|
4744
|
+
const setSelections$2 = (editor, selections, centerOffscreenSelection = false) => {
|
|
4745
4745
|
object(editor);
|
|
4746
4746
|
const {
|
|
4747
4747
|
foldingRanges = []
|
|
@@ -4767,10 +4767,12 @@ const setSelections$2 = (editor, selections) => {
|
|
|
4767
4767
|
selections: normalizedSelections
|
|
4768
4768
|
};
|
|
4769
4769
|
}
|
|
4770
|
-
const desiredStartVisualRow = visualRow < startVisualRow ? visualRow : visualRow - editor.numberOfVisibleLines + 1;
|
|
4770
|
+
const desiredStartVisualRow = centerOffscreenSelection ? visualRow - Math.floor(editor.numberOfVisibleLines / 2) : visualRow < startVisualRow ? visualRow : visualRow - editor.numberOfVisibleLines + 1;
|
|
4771
|
+
const desiredDeltaY = desiredStartVisualRow * editor.itemHeight;
|
|
4772
|
+
const deltaY = centerOffscreenSelection ? clamp(desiredDeltaY, 0, editor.finalDeltaY ?? 0) : desiredDeltaY;
|
|
4771
4773
|
return updateLayout({
|
|
4772
4774
|
...editor,
|
|
4773
|
-
deltaY
|
|
4775
|
+
deltaY,
|
|
4774
4776
|
selections: normalizedSelections
|
|
4775
4777
|
}, foldingRanges);
|
|
4776
4778
|
}
|
|
@@ -4800,7 +4802,7 @@ const setSelections$2 = (editor, selections) => {
|
|
|
4800
4802
|
lines,
|
|
4801
4803
|
scrollBarHeight
|
|
4802
4804
|
} = editor;
|
|
4803
|
-
const desiredMinLineY = rowIndex < minLineY ? rowIndex : rowIndex - numberOfVisibleLines + 1;
|
|
4805
|
+
const desiredMinLineY = centerOffscreenSelection ? rowIndex - Math.floor(numberOfVisibleLines / 2) : rowIndex < minLineY ? rowIndex : rowIndex - numberOfVisibleLines + 1;
|
|
4804
4806
|
const deltaY = clamp(desiredMinLineY * itemHeight, 0, finalDeltaY);
|
|
4805
4807
|
const newMinLineY = Math.floor(deltaY / itemHeight);
|
|
4806
4808
|
const newMaxLineY = Math.min(newMinLineY + numberOfVisibleLines, lines.length);
|
|
@@ -9785,18 +9787,20 @@ const cursorDocumentStart = editor => {
|
|
|
9785
9787
|
return scheduleSelections(editor, newSelections);
|
|
9786
9788
|
};
|
|
9787
9789
|
|
|
9788
|
-
const moveSelectionDown = (lastRow, selections, i, selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn) => {
|
|
9789
|
-
|
|
9790
|
+
const moveSelectionDown = (lastRow, lines, selections, i, selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn) => {
|
|
9791
|
+
const rowIndex = Math.min(selectionEndRow + 1, lastRow);
|
|
9792
|
+
const columnIndex = Math.min(selectionEndColumn, lines[rowIndex].length);
|
|
9793
|
+
moveRangeToPosition$1(selections, i, rowIndex, columnIndex);
|
|
9790
9794
|
};
|
|
9791
|
-
const getNewSelections$9 = (selections,
|
|
9792
|
-
return map(selections, moveSelectionDown.bind(null,
|
|
9795
|
+
const getNewSelections$9 = (selections, lines) => {
|
|
9796
|
+
return map(selections, moveSelectionDown.bind(null, Math.max(0, lines.length - 1), lines));
|
|
9793
9797
|
};
|
|
9794
9798
|
const cursorDown = editor => {
|
|
9795
9799
|
const {
|
|
9796
9800
|
lines,
|
|
9797
9801
|
selections
|
|
9798
9802
|
} = editor;
|
|
9799
|
-
const newSelections = getNewSelections$9(selections,
|
|
9803
|
+
const newSelections = getNewSelections$9(selections, lines);
|
|
9800
9804
|
return scheduleSelections(editor, newSelections);
|
|
9801
9805
|
};
|
|
9802
9806
|
|
|
@@ -12632,7 +12636,7 @@ const getFindWidgetFontSize = async () => {
|
|
|
12632
12636
|
};
|
|
12633
12637
|
const setSelections$1 = async (editorUid, selections) => {
|
|
12634
12638
|
const editor = getEditor$1(editorUid);
|
|
12635
|
-
const newEditor = setSelections$2(editor, selections);
|
|
12639
|
+
const newEditor = setSelections$2(editor, selections, true);
|
|
12636
12640
|
await updateEditor(editorUid, editor, newEditor);
|
|
12637
12641
|
};
|
|
12638
12642
|
|
|
@@ -14825,7 +14829,7 @@ const typeWithAutoClosing = async (editor, text) => {
|
|
|
14825
14829
|
switch (text) {
|
|
14826
14830
|
// case AutoClosing.ClosingAngleBracket: // TODO support auto closing when typing closing angle bracket of start tag
|
|
14827
14831
|
case Slash:
|
|
14828
|
-
if (isAutoClosingTagsEnabled) {
|
|
14832
|
+
if (isAutoClosingTagsEnabled && isClosingTagSlash(editor)) {
|
|
14829
14833
|
return typeWithAutoClosingTag(editor, text);
|
|
14830
14834
|
}
|
|
14831
14835
|
break;
|
|
@@ -14875,6 +14879,13 @@ const typeWithAutoClosing = async (editor, text) => {
|
|
|
14875
14879
|
// TODO should editor type command know about editor completion? -> no
|
|
14876
14880
|
// EditorCommandCompletion.openFromType(editor, text)
|
|
14877
14881
|
};
|
|
14882
|
+
const isClosingTagSlash = editor => {
|
|
14883
|
+
const [startRow, startColumn, endRow, endColumn] = editor.selections;
|
|
14884
|
+
if (startRow !== endRow || startColumn !== endColumn || startColumn === 0) {
|
|
14885
|
+
return false;
|
|
14886
|
+
}
|
|
14887
|
+
return editor.lines[startRow][startColumn - 1] === '<';
|
|
14888
|
+
};
|
|
14878
14889
|
|
|
14879
14890
|
const inverseChange = edit => {
|
|
14880
14891
|
const insertedLines = edit.inserted;
|
package/dist/editorWorkerMain.js
CHANGED
|
@@ -5154,7 +5154,7 @@ const getSelectionFromChange = change => {
|
|
|
5154
5154
|
start: newPosition
|
|
5155
5155
|
};
|
|
5156
5156
|
};
|
|
5157
|
-
const setSelections$2 = (editor, selections) => {
|
|
5157
|
+
const setSelections$2 = (editor, selections, centerOffscreenSelection = false) => {
|
|
5158
5158
|
object(editor);
|
|
5159
5159
|
const {
|
|
5160
5160
|
foldingRanges = []
|
|
@@ -5180,10 +5180,12 @@ const setSelections$2 = (editor, selections) => {
|
|
|
5180
5180
|
selections: normalizedSelections
|
|
5181
5181
|
};
|
|
5182
5182
|
}
|
|
5183
|
-
const desiredStartVisualRow = visualRow < startVisualRow ? visualRow : visualRow - editor.numberOfVisibleLines + 1;
|
|
5183
|
+
const desiredStartVisualRow = centerOffscreenSelection ? visualRow - Math.floor(editor.numberOfVisibleLines / 2) : visualRow < startVisualRow ? visualRow : visualRow - editor.numberOfVisibleLines + 1;
|
|
5184
|
+
const desiredDeltaY = desiredStartVisualRow * editor.itemHeight;
|
|
5185
|
+
const deltaY = centerOffscreenSelection ? clamp(desiredDeltaY, 0, editor.finalDeltaY ?? 0) : desiredDeltaY;
|
|
5184
5186
|
return updateLayout({
|
|
5185
5187
|
...editor,
|
|
5186
|
-
deltaY
|
|
5188
|
+
deltaY,
|
|
5187
5189
|
selections: normalizedSelections
|
|
5188
5190
|
}, foldingRanges);
|
|
5189
5191
|
}
|
|
@@ -5213,7 +5215,7 @@ const setSelections$2 = (editor, selections) => {
|
|
|
5213
5215
|
lines,
|
|
5214
5216
|
scrollBarHeight
|
|
5215
5217
|
} = editor;
|
|
5216
|
-
const desiredMinLineY = rowIndex < minLineY ? rowIndex : rowIndex - numberOfVisibleLines + 1;
|
|
5218
|
+
const desiredMinLineY = centerOffscreenSelection ? rowIndex - Math.floor(numberOfVisibleLines / 2) : rowIndex < minLineY ? rowIndex : rowIndex - numberOfVisibleLines + 1;
|
|
5217
5219
|
const deltaY = clamp(desiredMinLineY * itemHeight, 0, finalDeltaY);
|
|
5218
5220
|
const newMinLineY = Math.floor(deltaY / itemHeight);
|
|
5219
5221
|
const newMaxLineY = Math.min(newMinLineY + numberOfVisibleLines, lines.length);
|
|
@@ -10189,18 +10191,20 @@ const cursorDocumentStart = editor => {
|
|
|
10189
10191
|
return scheduleSelections(editor, newSelections);
|
|
10190
10192
|
};
|
|
10191
10193
|
|
|
10192
|
-
const moveSelectionDown = (lastRow, selections, i, selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn) => {
|
|
10193
|
-
|
|
10194
|
+
const moveSelectionDown = (lastRow, lines, selections, i, selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn) => {
|
|
10195
|
+
const rowIndex = Math.min(selectionEndRow + 1, lastRow);
|
|
10196
|
+
const columnIndex = Math.min(selectionEndColumn, lines[rowIndex].length);
|
|
10197
|
+
moveRangeToPosition$1(selections, i, rowIndex, columnIndex);
|
|
10194
10198
|
};
|
|
10195
|
-
const getNewSelections$9 = (selections,
|
|
10196
|
-
return map(selections, moveSelectionDown.bind(null,
|
|
10199
|
+
const getNewSelections$9 = (selections, lines) => {
|
|
10200
|
+
return map(selections, moveSelectionDown.bind(null, Math.max(0, lines.length - 1), lines));
|
|
10197
10201
|
};
|
|
10198
10202
|
const cursorDown = editor => {
|
|
10199
10203
|
const {
|
|
10200
10204
|
lines,
|
|
10201
10205
|
selections
|
|
10202
10206
|
} = editor;
|
|
10203
|
-
const newSelections = getNewSelections$9(selections,
|
|
10207
|
+
const newSelections = getNewSelections$9(selections, lines);
|
|
10204
10208
|
return scheduleSelections(editor, newSelections);
|
|
10205
10209
|
};
|
|
10206
10210
|
|
|
@@ -13036,7 +13040,7 @@ const getFindWidgetFontSize = async () => {
|
|
|
13036
13040
|
};
|
|
13037
13041
|
const setSelections$1 = async (editorUid, selections) => {
|
|
13038
13042
|
const editor = getEditor$1(editorUid);
|
|
13039
|
-
const newEditor = setSelections$2(editor, selections);
|
|
13043
|
+
const newEditor = setSelections$2(editor, selections, true);
|
|
13040
13044
|
await updateEditor(editorUid, editor, newEditor);
|
|
13041
13045
|
};
|
|
13042
13046
|
|
|
@@ -15229,7 +15233,7 @@ const typeWithAutoClosing = async (editor, text) => {
|
|
|
15229
15233
|
switch (text) {
|
|
15230
15234
|
// case AutoClosing.ClosingAngleBracket: // TODO support auto closing when typing closing angle bracket of start tag
|
|
15231
15235
|
case Slash:
|
|
15232
|
-
if (isAutoClosingTagsEnabled) {
|
|
15236
|
+
if (isAutoClosingTagsEnabled && isClosingTagSlash(editor)) {
|
|
15233
15237
|
return typeWithAutoClosingTag(editor, text);
|
|
15234
15238
|
}
|
|
15235
15239
|
break;
|
|
@@ -15279,6 +15283,13 @@ const typeWithAutoClosing = async (editor, text) => {
|
|
|
15279
15283
|
// TODO should editor type command know about editor completion? -> no
|
|
15280
15284
|
// EditorCommandCompletion.openFromType(editor, text)
|
|
15281
15285
|
};
|
|
15286
|
+
const isClosingTagSlash = editor => {
|
|
15287
|
+
const [startRow, startColumn, endRow, endColumn] = editor.selections;
|
|
15288
|
+
if (startRow !== endRow || startColumn !== endColumn || startColumn === 0) {
|
|
15289
|
+
return false;
|
|
15290
|
+
}
|
|
15291
|
+
return editor.lines[startRow][startColumn - 1] === '<';
|
|
15292
|
+
};
|
|
15282
15293
|
|
|
15283
15294
|
const inverseChange = edit => {
|
|
15284
15295
|
const insertedLines = edit.inserted;
|