@lvce-editor/editor-worker 18.8.0 → 18.9.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.
@@ -3042,6 +3042,37 @@ const notifyListeners = async (listenerType, method, ...params) => {
3042
3042
  await Promise.all(notifications);
3043
3043
  };
3044
3044
 
3045
+ const resize = (state, dimensions, columnWidth = state.columnWidth) => {
3046
+ const x = dimensions.x ?? state.x;
3047
+ const y = dimensions.y ?? state.y;
3048
+ const width = dimensions.width ?? state.width;
3049
+ const height = dimensions.height ?? state.height;
3050
+ const numberOfVisibleLines = Math.floor(height / state.itemHeight);
3051
+ const total = state.lines.length;
3052
+ const finalY = Math.max(total - numberOfVisibleLines, 0);
3053
+ const finalDeltaY = finalY * state.itemHeight;
3054
+ const deltaY = Math.min(state.deltaY, finalDeltaY);
3055
+ const minLineY = Math.floor(deltaY / state.itemHeight);
3056
+ const maxLineY = Math.min(minLineY + numberOfVisibleLines, total);
3057
+ const contentHeight = total * state.rowHeight;
3058
+ const scrollBarHeight = getScrollBarSize(height, contentHeight, state.minimumSliderSize);
3059
+ return {
3060
+ ...state,
3061
+ columnWidth,
3062
+ deltaY,
3063
+ finalDeltaY,
3064
+ finalY,
3065
+ height,
3066
+ maxLineY,
3067
+ minLineY,
3068
+ numberOfVisibleLines,
3069
+ scrollBarHeight,
3070
+ width,
3071
+ x,
3072
+ y
3073
+ };
3074
+ };
3075
+
3045
3076
  const splitLines = lines => {
3046
3077
  if (!lines) {
3047
3078
  return [''];
@@ -3604,26 +3635,12 @@ const hasSelection = editor => {
3604
3635
  return editor.selections && editor.selections.length > 0;
3605
3636
  };
3606
3637
  const setBounds = (editor, x, y, width, height, columnWidth) => {
3607
- const {
3608
- itemHeight
3609
- } = editor;
3610
- const numberOfVisibleLines = Math.floor(height / itemHeight);
3611
- const total = editor.lines.length;
3612
- const maxLineY = Math.min(numberOfVisibleLines, total);
3613
- const finalY = Math.max(total - numberOfVisibleLines, 0);
3614
- const finalDeltaY = finalY * itemHeight;
3615
- return {
3616
- ...editor,
3617
- columnWidth,
3618
- finalDeltaY,
3619
- finalY,
3638
+ return resize(editor, {
3620
3639
  height,
3621
- maxLineY,
3622
- numberOfVisibleLines,
3623
3640
  width,
3624
3641
  x,
3625
3642
  y
3626
- };
3643
+ }, columnWidth);
3627
3644
  };
3628
3645
  const setText$1 = (editor, text) => {
3629
3646
  const lines = splitLines(text);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "18.8.0",
3
+ "version": "18.9.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"