@lvce-editor/editor-worker 19.60.1 → 19.60.2

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.
@@ -1855,6 +1855,13 @@ const clamp = (num, min, max) => {
1855
1855
  return Math.min(Math.max(num, min), max);
1856
1856
  };
1857
1857
 
1858
+ const getScrollOffset = (deltaY, rowHeight) => {
1859
+ return rowHeight > 0 ? deltaY % rowHeight : 0;
1860
+ };
1861
+ const getRenderedLineCount = (height, rowHeight, deltaY) => {
1862
+ return height > 0 && rowHeight > 0 ? Math.ceil((height + getScrollOffset(deltaY, rowHeight)) / rowHeight) : 0;
1863
+ };
1864
+
1858
1865
  const toMergeConflictActionsRow = rowIndex => ~rowIndex;
1859
1866
  const isMergeConflictActionsRow = viewRow => viewRow < 0;
1860
1867
  const getMergeConflictRowIndex = viewRow => ~viewRow;
@@ -2080,10 +2087,11 @@ const updateLayout = (editor, foldingRanges) => {
2080
2087
  const viewLineIndices = hasMergeConflictRows ? getViewLineIndices(lines.length, rowIndex => isRowHidden(rowIndex, foldingRanges), mergeConflicts) : [];
2081
2088
  const visibleLineCount = hasMergeConflictRows ? viewLineIndices.length : getVisibleLineCount(lines.length, foldingRanges);
2082
2089
  const finalY = Math.max(visibleLineCount - numberOfVisibleLines, 0);
2083
- const finalDeltaY = finalY * itemHeight;
2090
+ const finalDeltaY = Math.max(visibleLineCount * itemHeight - height, 0);
2084
2091
  const deltaY = clamp(editor.deltaY, 0, finalDeltaY);
2085
2092
  const startVisualRow = Math.floor(deltaY / itemHeight);
2086
- const visibleViewLineIndices = hasMergeConflictRows ? getVisibleViewLineIndices(viewLineIndices, startVisualRow, numberOfVisibleLines) : getViewportLineIndices(lines.length, foldingRanges, startVisualRow, numberOfVisibleLines);
2093
+ const renderedLineCount = getRenderedLineCount(height, itemHeight, deltaY);
2094
+ const visibleViewLineIndices = hasMergeConflictRows ? getVisibleViewLineIndices(viewLineIndices, startVisualRow, renderedLineCount) : getViewportLineIndices(lines.length, foldingRanges, startVisualRow, renderedLineCount);
2087
2095
  const visibleLineIndices = hasMergeConflictRows ? getVisibleLineIndices(visibleViewLineIndices) : visibleViewLineIndices;
2088
2096
  const minLineY = visibleLineIndices[0] ?? 0;
2089
2097
  const maxLineY = visibleLineIndices.length === 0 ? 0 : visibleLineIndices.at(-1) + 1;
@@ -3214,7 +3222,7 @@ const getVisible$1 = async (editor, syncIncremental) => {
3214
3222
  width
3215
3223
  } = editor;
3216
3224
  const visibleLineIndices = editor.visibleLineIndices || Array.from({
3217
- length: Math.min(editor.numberOfVisibleLines, lines.length - editor.minLineY)
3225
+ length: Math.min(editor.maxLineY ?? editor.minLineY + editor.numberOfVisibleLines, lines.length) - editor.minLineY
3218
3226
  }, (_, index) => editor.minLineY + index);
3219
3227
  if (visibleLineIndices.length === 0) {
3220
3228
  return {
@@ -3272,7 +3280,6 @@ const setDeltaY$1 = async (state, value) => {
3272
3280
  finalDeltaY,
3273
3281
  height,
3274
3282
  itemHeight,
3275
- numberOfVisibleLines,
3276
3283
  scrollBarHeight
3277
3284
  } = state;
3278
3285
  const newDeltaY = clamp(value, 0, finalDeltaY);
@@ -3280,8 +3287,9 @@ const setDeltaY$1 = async (state, value) => {
3280
3287
  return state;
3281
3288
  }
3282
3289
  const startVisualRow = Math.floor(newDeltaY / itemHeight);
3290
+ const renderedLineCount = getRenderedLineCount(height, itemHeight, newDeltaY);
3283
3291
  const hasMergeConflictRows = state.viewLineIndices?.length > 0;
3284
- const visibleViewLineIndices = hasMergeConflictRows ? getVisibleViewLineIndices(state.viewLineIndices, startVisualRow, numberOfVisibleLines) : getViewportLineIndices(state.lines.length, state.foldingRanges || [], startVisualRow, numberOfVisibleLines);
3292
+ const visibleViewLineIndices = hasMergeConflictRows ? getVisibleViewLineIndices(state.viewLineIndices, startVisualRow, renderedLineCount) : getViewportLineIndices(state.lines.length, state.foldingRanges || [], startVisualRow, renderedLineCount);
3285
3293
  const visibleLineIndices = hasMergeConflictRows ? getVisibleLineIndices(visibleViewLineIndices) : visibleViewLineIndices;
3286
3294
  const minLineY = visibleLineIndices[0] ?? 0;
3287
3295
  const maxLineY = visibleLineIndices.length === 0 ? 0 : visibleLineIndices.at(-1) + 1;
@@ -3666,10 +3674,10 @@ const resize = (state, dimensions, columnWidth = state.columnWidth) => {
3666
3674
  if (!('foldingRanges' in state)) {
3667
3675
  const total = state.lines.length;
3668
3676
  const finalY = Math.max(total - numberOfVisibleLines, 0);
3669
- const finalDeltaY = finalY * state.itemHeight;
3677
+ const finalDeltaY = Math.max(total * state.itemHeight - height, 0);
3670
3678
  const deltaY = Math.min(state.deltaY, finalDeltaY);
3671
3679
  const minLineY = Math.floor(deltaY / state.itemHeight);
3672
- const maxLineY = Math.min(minLineY + numberOfVisibleLines, total);
3680
+ const maxLineY = Math.min(minLineY + getRenderedLineCount(height, state.itemHeight, deltaY), total);
3673
3681
  const contentHeight = total * state.rowHeight;
3674
3682
  const scrollBarHeight = getScrollBarSize(height, contentHeight, state.minimumSliderSize);
3675
3683
  return {
@@ -14873,8 +14881,10 @@ const renderAdditionalFocusContext$1 = (oldState, newState) => {
14873
14881
  return ['Viewlet.unsetAdditionalFocus', newState.uid, oldState.additionalFocus];
14874
14882
  };
14875
14883
 
14876
- const getCss = (uid, rowHeight, scrollBarHeight, scrollBarTop, scrollBarWidth, scrollBarLeft) => {
14884
+ const getCss = (uid, rowHeight, scrollBarHeight, scrollBarTop, scrollBarWidth, scrollBarLeft, deltaY = 0) => {
14877
14885
  const editorSelector = `.Editor[data-uid="${uid}"]`;
14886
+ const scrollOffset = getScrollOffset(deltaY, rowHeight);
14887
+ const translate = scrollOffset === 0 ? 'none' : `0px -${scrollOffset}px`;
14878
14888
  return `${editorSelector} {
14879
14889
  --EditorRowHeight: ${rowHeight}px;
14880
14890
  --ScrollBarHeight: ${scrollBarHeight}px;
@@ -14882,6 +14892,25 @@ const getCss = (uid, rowHeight, scrollBarHeight, scrollBarTop, scrollBarWidth, s
14882
14892
  --ScrollBarWidth: ${scrollBarWidth}px;
14883
14893
  --ScrollBarLeft: ${scrollBarLeft}px;
14884
14894
  }
14895
+ ${editorSelector} .EditorLayers {
14896
+ height: calc(100% + var(--EditorRowHeight));
14897
+ translate: ${translate};
14898
+ }
14899
+ ${editorSelector} .GutterRows {
14900
+ flex: none;
14901
+ width: 100%;
14902
+ translate: ${translate};
14903
+ }
14904
+ ${editorSelector} .EditorRows,
14905
+ ${editorSelector} .GutterRows {
14906
+ display: flex;
14907
+ flex-direction: column;
14908
+ }
14909
+ ${editorSelector} .EditorRow,
14910
+ ${editorSelector} .LineNumber {
14911
+ contain: size style;
14912
+ flex: none;
14913
+ }
14885
14914
  ${editorSelector} .EditorRow {
14886
14915
  height: var(--EditorRowHeight);
14887
14916
  line-height: var(--EditorRowHeight);
@@ -14889,6 +14918,7 @@ ${editorSelector} .EditorRow {
14889
14918
  ${editorSelector} .MergeConflictActions,
14890
14919
  ${editorSelector} .MergeConflictActionsGutter {
14891
14920
  box-sizing: border-box;
14921
+ flex: none;
14892
14922
  height: var(--EditorRowHeight);
14893
14923
  line-height: var(--EditorRowHeight);
14894
14924
  }
@@ -14989,7 +15019,7 @@ const renderCss$1 = (oldState, newState) => {
14989
15019
  const scrollBarTop = getScrollBarY(deltaY, finalDeltaY, height, scrollBarHeight);
14990
15020
  const scrollBarWidth = getScrollBarSize(width, longestLineWidth, minimumSliderSize);
14991
15021
  const scrollBarLeft = getScrollBarLeft(deltaX, longestLineWidth, width);
14992
- const css = getCss(uid, rowHeight, scrollBarHeight, scrollBarTop, scrollBarWidth, scrollBarLeft);
15022
+ const css = getCss(uid, rowHeight, scrollBarHeight, scrollBarTop, scrollBarWidth, scrollBarLeft, deltaY);
14993
15023
  return [SetCss$1, uid, css];
14994
15024
  };
14995
15025
 
@@ -15457,13 +15487,20 @@ const getGutterInfoVirtualDom = (gutterInfo, activeLineNumber) => {
15457
15487
  };
15458
15488
  const getEditorGutterVirtualDom$1 = (gutterInfos, activeLineNumber = -1) => {
15459
15489
  const dom = gutterInfos.flatMap(gutterInfo => getGutterInfoVirtualDom(gutterInfo, activeLineNumber));
15460
- return dom;
15490
+ if (gutterInfos.length === 0) {
15491
+ return [];
15492
+ }
15493
+ return [{
15494
+ childCount: gutterInfos.length,
15495
+ className: 'GutterRows',
15496
+ type: Div
15497
+ }, ...dom];
15461
15498
  };
15462
15499
 
15463
15500
  const getEditorGutterVirtualDom = (gutterInfos, activeLineNumber = -1) => {
15464
15501
  const gutterDom = getEditorGutterVirtualDom$1([...gutterInfos], activeLineNumber);
15465
15502
  return [{
15466
- childCount: gutterInfos.length,
15503
+ childCount: gutterInfos.length === 0 ? 0 : 1,
15467
15504
  className: 'Gutter',
15468
15505
  type: Div
15469
15506
  }, ...gutterDom];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.60.1",
3
+ "version": "19.60.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"