@lvce-editor/editor-worker 19.67.1 → 19.67.3

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.
@@ -12776,9 +12776,39 @@ const getMatchingClosingBrace = brace => {
12776
12776
  };
12777
12777
  const typeWithAutoClosingBracket = (editor, text) => {
12778
12778
  const closingBracket = getMatchingClosingBrace(text);
12779
- const newText = text + closingBracket;
12780
- const changes = editorReplaceSelections(editor, [newText], EditorTypeWithAutoClosing);
12781
- const selectionChanges = new Uint32Array([changes[0].start.rowIndex, changes[0].start.columnIndex + 1, changes[0].end.rowIndex, changes[0].end.columnIndex + 1]);
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
+ }
12782
12812
  // @ts-ignore
12783
12813
  return scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
12784
12814
  };
@@ -15342,12 +15372,14 @@ const getCss = (uid, rowHeight, scrollBarHeight, scrollBarTop, scrollBarWidth, s
15342
15372
  const scrollOffset = getScrollOffset(deltaY, rowHeight);
15343
15373
  const translate = scrollOffset === 0 ? 'none' : `0px -${scrollOffset}px`;
15344
15374
  return `${editorSelector} {
15375
+ --EditorRowContain: size style;
15345
15376
  --EditorRowHeight: ${rowHeight}px;
15346
15377
  --ScrollBarHeight: ${scrollBarHeight}px;
15347
15378
  --ScrollBarTop: ${scrollBarTop}px;
15348
15379
  --ScrollBarWidth: ${scrollBarWidth}px;
15349
15380
  --ScrollBarLeft: ${scrollBarLeft}px;
15350
15381
  }
15382
+ .EditorRow { contain: var(--EditorRowContain, strict); }
15351
15383
  ${editorSelector} .SelectionTopLeft { border-top-left-radius: 3px; }
15352
15384
  ${editorSelector} .SelectionTopRight { border-top-right-radius: 3px; }
15353
15385
  ${editorSelector} .SelectionBottomRight { border-bottom-right-radius: 3px; }
@@ -15366,15 +15398,6 @@ ${editorSelector} .GutterRows {
15366
15398
  display: flex;
15367
15399
  flex-direction: column;
15368
15400
  }
15369
- ${editorSelector} .EditorRow,
15370
- ${editorSelector} .LineNumber {
15371
- flex: none;
15372
- }
15373
- ${editorSelector} .EditorRow {
15374
- contain: size style;
15375
- height: var(--EditorRowHeight);
15376
- line-height: var(--EditorRowHeight);
15377
- }
15378
15401
  ${editorSelector} .MergeConflictActions,
15379
15402
  ${editorSelector} .MergeConflictActionsGutter {
15380
15403
  box-sizing: border-box;
@@ -15415,10 +15438,6 @@ ${editorSelector} .EditorLineDecoration {
15415
15438
  margin-left: 2em;
15416
15439
  user-select: none;
15417
15440
  }
15418
- ${editorSelector} .LineNumber {
15419
- contain: content;
15420
- position: relative;
15421
- }
15422
15441
  ${editorSelector} .EditorGutterDecoration {
15423
15442
  bottom: 0;
15424
15443
  left: 0;
@@ -15958,6 +15977,7 @@ const editorContentNode = {
15958
15977
  };
15959
15978
  const getEditorContentVirtualDom = ({
15960
15979
  bracketMatchInfos = [],
15980
+ breadcrumbsEnabled = false,
15961
15981
  cursorInfos = [],
15962
15982
  diagnostics = [],
15963
15983
  differences,
@@ -15973,7 +15993,10 @@ const getEditorContentVirtualDom = ({
15973
15993
  visibleLineIndices = [],
15974
15994
  visibleViewLineIndices = []
15975
15995
  }) => {
15976
- return [editorContentNode, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices, problemsHighlightedRow, roundedSelection), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom()];
15996
+ return [{
15997
+ ...editorContentNode,
15998
+ className: breadcrumbsEnabled ? 'EditorContent EditorBreadcrumbsOffset' : 'EditorContent'
15999
+ }, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices, problemsHighlightedRow, roundedSelection), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom()];
15977
16000
  };
15978
16001
 
15979
16002
  const getGutterInfoVirtualDom = (gutterInfo, activeLineNumber) => {
@@ -16027,11 +16050,11 @@ const getEditorGutterVirtualDom$1 = (gutterInfos, activeLineNumber = -1) => {
16027
16050
  }, ...dom];
16028
16051
  };
16029
16052
 
16030
- const getEditorGutterVirtualDom = (gutterInfos, activeLineNumber = -1) => {
16053
+ const getEditorGutterVirtualDom = (gutterInfos, activeLineNumber = -1, breadcrumbsEnabled = false) => {
16031
16054
  const gutterDom = getEditorGutterVirtualDom$1([...gutterInfos], activeLineNumber);
16032
16055
  return [{
16033
16056
  childCount: gutterInfos.length === 0 ? 0 : 1,
16034
- className: 'Gutter',
16057
+ className: breadcrumbsEnabled ? 'Gutter EditorBreadcrumbsOffset' : 'Gutter',
16035
16058
  type: Div
16036
16059
  }, ...gutterDom];
16037
16060
  };
@@ -16098,14 +16121,14 @@ const textEditorErrorMessageNode = {
16098
16121
  className: 'TextEditorErrorMessage',
16099
16122
  type: Div
16100
16123
  };
16101
- const getMinimapVirtualDom = (minimapEnabled, minimapLines, minLineY) => {
16124
+ const getMinimapVirtualDom = (minimapEnabled, minimapLines, minLineY, breadcrumbsEnabled) => {
16102
16125
  if (!minimapEnabled) {
16103
16126
  return [];
16104
16127
  }
16105
16128
  return [{
16106
16129
  ariaHidden: True,
16107
16130
  childCount: 0,
16108
- className: 'EditorMinimap',
16131
+ className: breadcrumbsEnabled ? 'EditorMinimap EditorBreadcrumbsOffset' : 'EditorMinimap',
16109
16132
  'data-lineCount': minimapLines.length,
16110
16133
  'data-visibleStart': minLineY,
16111
16134
  type: Div
@@ -16161,8 +16184,8 @@ const getEditorVirtualDom = ({
16161
16184
  const showGutter = lineNumbers || breakPoints.length > 0 || lightBulbRowIndex >= 0 || gutterDecorations.length > 0;
16162
16185
  const primaryCursorRowIndex = getPrimaryCursorRowIndex(selections, primarySelectionIndex);
16163
16186
  const activeLineNumber = highlightActiveLineNumber ? primaryCursorRowIndex + 1 : -1;
16164
- const gutterDom = showGutter ? getEditorGutterVirtualDom(visibleGutterInfos, activeLineNumber) : [];
16165
- const minimapDom = getMinimapVirtualDom(minimapEnabled, minimapLines, minLineY);
16187
+ const gutterDom = showGutter ? getEditorGutterVirtualDom(visibleGutterInfos, activeLineNumber, breadcrumbsEnabled) : [];
16188
+ const minimapDom = getMinimapVirtualDom(minimapEnabled, minimapLines, minLineY, breadcrumbsEnabled);
16166
16189
  const breadcrumbsDom = breadcrumbsEnabled ? getEditorBreadcrumbsVirtualDom({
16167
16190
  breadcrumbsEnabled,
16168
16191
  documentSymbols,
@@ -16181,6 +16204,7 @@ const getEditorVirtualDom = ({
16181
16204
  type: Div
16182
16205
  }, ...breadcrumbsDom, ...gutterDom, ...getEditorContentVirtualDom({
16183
16206
  bracketMatchInfos,
16207
+ breadcrumbsEnabled,
16184
16208
  cursorInfos,
16185
16209
  diagnostics,
16186
16210
  differences,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.67.1",
3
+ "version": "19.67.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"