@lvce-editor/editor-worker 18.21.0 → 18.23.0

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.
@@ -1623,6 +1623,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
1623
1623
  fontFamily: '',
1624
1624
  fontSize: 0,
1625
1625
  fontWeight: 0,
1626
+ handleOffset: 0,
1626
1627
  handleOffsetX: 0,
1627
1628
  height,
1628
1629
  highlightedLine: -1,
@@ -2743,6 +2744,9 @@ const getVisible$1 = async (editor, syncIncremental) => {
2743
2744
 
2744
2745
  const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
2745
2746
  const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
2747
+ if (!Number.isFinite(scrollBarOffset)) {
2748
+ return 0;
2749
+ }
2746
2750
  return scrollBarOffset;
2747
2751
  };
2748
2752
  const getScrollBarY = getScrollBarOffset;
@@ -4006,6 +4010,7 @@ const createEditor = async ({
4006
4010
  fontFamily,
4007
4011
  fontSize,
4008
4012
  fontWeight,
4013
+ handleOffset: 0,
4009
4014
  handleOffsetX: 0,
4010
4015
  height,
4011
4016
  id,
@@ -4101,7 +4106,7 @@ const createEditor = async ({
4101
4106
  };
4102
4107
 
4103
4108
  const isEqual$2 = (oldState, newState) => {
4104
- return oldState.itemHeight === newState.itemHeight;
4109
+ return oldState.rowHeight === newState.rowHeight && oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.scrollBarHeight === newState.scrollBarHeight;
4105
4110
  };
4106
4111
 
4107
4112
  const isEqual$1 = (oldState, newState) => {
@@ -6663,18 +6668,17 @@ const getNewPercent = (state, relativeY) => {
6663
6668
  // clicked at bottom
6664
6669
  return 1;
6665
6670
  };
6666
-
6667
- // @ts-ignore
6668
- const handleScrollBarMove = (state, eventY) => {
6671
+ const handleScrollBarMove = async (state, eventY) => {
6669
6672
  const {
6670
6673
  finalDeltaY,
6671
- handleOffset,
6674
+ handleOffset = 0,
6672
6675
  y
6673
6676
  } = state;
6674
6677
  const relativeY = eventY - y - handleOffset;
6675
6678
  const newPercent = getNewPercent(state, relativeY);
6676
6679
  const newDeltaY = newPercent * finalDeltaY;
6677
- return setDeltaYFixedValue$1(state, newDeltaY);
6680
+ const newState = await setDeltaYFixedValue$1(state, newDeltaY);
6681
+ return newState;
6678
6682
  };
6679
6683
  const handleScrollBarVerticalPointerMove = handleScrollBarMove;
6680
6684
 
@@ -6684,7 +6688,7 @@ const handleScrollBarVerticalPointerMove = handleScrollBarMove;
6684
6688
  // when clicked at y > editor.height - editor.scrollBarHeight/2, position scrollbar at (y - scrollbarHeight/2)
6685
6689
  // additionally, when clicked on scrollbar, scrollbar position shouldn't move
6686
6690
 
6687
- const handleScrollBarPointerDown = (state, eventY) => {
6691
+ const handleScrollBarPointerDown = async (state, eventY) => {
6688
6692
  const {
6689
6693
  deltaY,
6690
6694
  finalDeltaY,
@@ -6706,8 +6710,9 @@ const handleScrollBarPointerDown = (state, eventY) => {
6706
6710
  percent
6707
6711
  } = getNewDeltaPercent(height, scrollBarHeight, relativeY);
6708
6712
  const newDeltaY = percent * finalDeltaY;
6713
+ const newState = await setDeltaYFixedValue$1(state, newDeltaY);
6709
6714
  return {
6710
- ...setDeltaYFixedValue$1(state, newDeltaY),
6715
+ ...newState,
6711
6716
  handleOffset
6712
6717
  };
6713
6718
  };
@@ -11127,19 +11132,34 @@ const registerListener = (listenerType, rpcId) => {
11127
11132
  registerListener$1(listenerType, rpcId);
11128
11133
  };
11129
11134
 
11130
- const getCss = itemHeight => {
11131
- return `:root {
11132
- --ActivityBarItemHeight: var(--${itemHeight}px);
11135
+ const getCss = (rowHeight, scrollBarHeight, scrollBarTop) => {
11136
+ return `.Editor {
11137
+ --EditorRowHeight: ${rowHeight}px;
11138
+ --ScrollBarHeight: ${scrollBarHeight}px;
11139
+ --ScrollBarTop: ${scrollBarTop}px;
11140
+ }
11141
+ .Editor .EditorRow {
11142
+ height: var(--EditorRowHeight);
11143
+ line-height: var(--EditorRowHeight);
11144
+ }
11145
+ .Editor .ScrollBarThumbVertical {
11146
+ height: var(--ScrollBarHeight);
11147
+ translate: 0px var(--ScrollBarTop);
11133
11148
  }
11134
11149
  `;
11135
11150
  };
11136
11151
 
11137
11152
  const renderCss = (oldState, newState) => {
11138
11153
  const {
11139
- itemHeight,
11154
+ deltaY,
11155
+ finalDeltaY,
11156
+ height,
11157
+ rowHeight,
11158
+ scrollBarHeight,
11140
11159
  uid
11141
11160
  } = newState;
11142
- const css = getCss(itemHeight);
11161
+ const scrollBarTop = getScrollBarY(deltaY, finalDeltaY, height, scrollBarHeight);
11162
+ const css = getCss(rowHeight, scrollBarHeight, scrollBarTop);
11143
11163
  return [SetCss$1, uid, css];
11144
11164
  };
11145
11165
 
@@ -12035,6 +12055,7 @@ const renderEventListeners = () => {
12035
12055
  }, {
12036
12056
  name: HandleScrollBarVerticalPointerDown,
12037
12057
  params: ['handleScrollBarVerticalPointerDown', ClientY],
12058
+ preventDefault: true,
12038
12059
  trackPointerEvents: [HandleScrollBarVerticalPointerMove, HandleScrollBarVerticalPointerUp]
12039
12060
  }, {
12040
12061
  name: HandleScrollBarVerticalPointerMove,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "18.21.0",
3
+ "version": "18.23.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"