@lvce-editor/editor-worker 19.75.3 → 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 CHANGED
@@ -9787,18 +9787,20 @@ const cursorDocumentStart = editor => {
9787
9787
  return scheduleSelections(editor, newSelections);
9788
9788
  };
9789
9789
 
9790
- const moveSelectionDown = (lastRow, selections, i, selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn) => {
9791
- moveRangeToPosition$1(selections, i, Math.min(selectionEndRow + 1, lastRow), selectionEndColumn);
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);
9792
9794
  };
9793
- const getNewSelections$9 = (selections, lastRow) => {
9794
- return map(selections, moveSelectionDown.bind(null, lastRow));
9795
+ const getNewSelections$9 = (selections, lines) => {
9796
+ return map(selections, moveSelectionDown.bind(null, Math.max(0, lines.length - 1), lines));
9795
9797
  };
9796
9798
  const cursorDown = editor => {
9797
9799
  const {
9798
9800
  lines,
9799
9801
  selections
9800
9802
  } = editor;
9801
- const newSelections = getNewSelections$9(selections, Math.max(0, lines.length - 1));
9803
+ const newSelections = getNewSelections$9(selections, lines);
9802
9804
  return scheduleSelections(editor, newSelections);
9803
9805
  };
9804
9806
 
@@ -14827,7 +14829,7 @@ const typeWithAutoClosing = async (editor, text) => {
14827
14829
  switch (text) {
14828
14830
  // case AutoClosing.ClosingAngleBracket: // TODO support auto closing when typing closing angle bracket of start tag
14829
14831
  case Slash:
14830
- if (isAutoClosingTagsEnabled) {
14832
+ if (isAutoClosingTagsEnabled && isClosingTagSlash(editor)) {
14831
14833
  return typeWithAutoClosingTag(editor, text);
14832
14834
  }
14833
14835
  break;
@@ -14877,6 +14879,13 @@ const typeWithAutoClosing = async (editor, text) => {
14877
14879
  // TODO should editor type command know about editor completion? -> no
14878
14880
  // EditorCommandCompletion.openFromType(editor, text)
14879
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
+ };
14880
14889
 
14881
14890
  const inverseChange = edit => {
14882
14891
  const insertedLines = edit.inserted;
@@ -10191,18 +10191,20 @@ const cursorDocumentStart = editor => {
10191
10191
  return scheduleSelections(editor, newSelections);
10192
10192
  };
10193
10193
 
10194
- const moveSelectionDown = (lastRow, selections, i, selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn) => {
10195
- moveRangeToPosition$1(selections, i, Math.min(selectionEndRow + 1, lastRow), selectionEndColumn);
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);
10196
10198
  };
10197
- const getNewSelections$9 = (selections, lastRow) => {
10198
- return map(selections, moveSelectionDown.bind(null, lastRow));
10199
+ const getNewSelections$9 = (selections, lines) => {
10200
+ return map(selections, moveSelectionDown.bind(null, Math.max(0, lines.length - 1), lines));
10199
10201
  };
10200
10202
  const cursorDown = editor => {
10201
10203
  const {
10202
10204
  lines,
10203
10205
  selections
10204
10206
  } = editor;
10205
- const newSelections = getNewSelections$9(selections, Math.max(0, lines.length - 1));
10207
+ const newSelections = getNewSelections$9(selections, lines);
10206
10208
  return scheduleSelections(editor, newSelections);
10207
10209
  };
10208
10210
 
@@ -15231,7 +15233,7 @@ const typeWithAutoClosing = async (editor, text) => {
15231
15233
  switch (text) {
15232
15234
  // case AutoClosing.ClosingAngleBracket: // TODO support auto closing when typing closing angle bracket of start tag
15233
15235
  case Slash:
15234
- if (isAutoClosingTagsEnabled) {
15236
+ if (isAutoClosingTagsEnabled && isClosingTagSlash(editor)) {
15235
15237
  return typeWithAutoClosingTag(editor, text);
15236
15238
  }
15237
15239
  break;
@@ -15281,6 +15283,13 @@ const typeWithAutoClosing = async (editor, text) => {
15281
15283
  // TODO should editor type command know about editor completion? -> no
15282
15284
  // EditorCommandCompletion.openFromType(editor, text)
15283
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
+ };
15284
15293
 
15285
15294
  const inverseChange = edit => {
15286
15295
  const insertedLines = edit.inserted;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.75.3",
3
+ "version": "19.75.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"