@lvce-editor/editor-worker 18.16.0 → 18.18.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.
@@ -4093,7 +4093,7 @@ const isEqual$1 = (oldState, newState) => {
4093
4093
  };
4094
4094
 
4095
4095
  const isEqual = (oldState, newState) => {
4096
- return oldState.lines === newState.lines && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.selections === newState.selections;
4096
+ return oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.highlightedLine === newState.highlightedLine && oldState.lineNumbers === newState.lineNumbers && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.deltaY === newState.deltaY && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.scrollBarWidth === newState.scrollBarWidth && oldState.selectionInfos === newState.selectionInfos;
4097
4097
  };
4098
4098
 
4099
4099
  const RenderFocus = 6;
@@ -6351,8 +6351,8 @@ const handlePointerCaptureLost = editor => {
6351
6351
  return editor;
6352
6352
  };
6353
6353
 
6354
- const handlePointerDown$1 = state => {
6355
- return state;
6354
+ const handlePointerDown$1 = (state, button, altKey, ctrlKey, x, y, detail) => {
6355
+ return handleMouseDown(state, button, altKey, ctrlKey, x, y, detail);
6356
6356
  };
6357
6357
 
6358
6358
  const moveRectangleSelection = (editor, position) => {
@@ -6532,7 +6532,7 @@ const moveSelectionPx = async (editor, x, y) => {
6532
6532
  return editorMoveSelection(editor, position);
6533
6533
  };
6534
6534
 
6535
- const handlePointerMove = (editor, x, y, altKey) => {
6535
+ const handlePointerMove = async (editor, x, y, altKey) => {
6536
6536
  if (altKey) {
6537
6537
  return moveRectangleSelectionPx(editor, x, y);
6538
6538
  }
@@ -6540,6 +6540,7 @@ const handlePointerMove = (editor, x, y, altKey) => {
6540
6540
  };
6541
6541
 
6542
6542
  const handlePointerUp = editor => {
6543
+ clearEditor();
6543
6544
  return editor;
6544
6545
  };
6545
6546
 
@@ -6774,6 +6775,13 @@ const handleTouchMove = (editor, touchEvent) => {
6774
6775
  setDeltaYFixedValue(editor, offsetY);
6775
6776
  };
6776
6777
 
6778
+ // Keep wheel handling as a dedicated command entry point and delegate
6779
+ // the actual scroll state update to the shared setDelta logic.
6780
+ // @ts-ignore
6781
+ const handleWheel$2 = (editor, deltaMode, eventDeltaX, eventDeltaY) => {
6782
+ return setDelta(editor, deltaMode, eventDeltaX, eventDeltaY);
6783
+ };
6784
+
6777
6785
  // @ts-ignore
6778
6786
  const getChanges$2 = selections => {
6779
6787
  const changes = [];
@@ -11399,10 +11407,37 @@ const diffTree = (oldNodes, newNodes) => {
11399
11407
  return removeTrailingNavigationPatches(patches);
11400
11408
  };
11401
11409
 
11410
+ const getEditorInputVirtualDom = () => {
11411
+ return [{
11412
+ ariaAutoComplete: 'list',
11413
+ ariaMultiLine: 'true',
11414
+ ariaRoleDescription: 'editor',
11415
+ autocapitalize: 'off',
11416
+ autocomplete: 'off',
11417
+ autocorrect: 'off',
11418
+ childCount: 0,
11419
+ className: 'EditorInput',
11420
+ name: 'editor',
11421
+ onBeforeInput: HandleBeforeInput,
11422
+ onBlur: HandleBlur,
11423
+ onCompositionEnd: HandleCompositionEnd,
11424
+ onCompositionStart: HandleCompositionStart,
11425
+ onCompositionUpdate: HandleCompositionUpdate,
11426
+ onCut: HandleCut,
11427
+ onFocus: HandleFocus,
11428
+ onPaste: HandlePaste,
11429
+ role: 'textbox',
11430
+ spellcheck: false,
11431
+ type: TextArea,
11432
+ wrap: 'off'
11433
+ }];
11434
+ };
11435
+
11402
11436
  const getCursorsVirtualDom = cursors => {
11403
11437
  const dom = [];
11404
11438
  for (const translate of cursors) {
11405
11439
  dom.push({
11440
+ childCount: 0,
11406
11441
  className: EditorCursor,
11407
11442
  translate,
11408
11443
  type: Div
@@ -11411,6 +11446,15 @@ const getCursorsVirtualDom = cursors => {
11411
11446
  return dom;
11412
11447
  };
11413
11448
 
11449
+ const getEditorCursorsVirtualDom = cursorInfos => {
11450
+ const cursorsDom = getCursorsVirtualDom([...cursorInfos]);
11451
+ return [{
11452
+ childCount: cursorInfos.length,
11453
+ className: 'LayerCursor',
11454
+ type: Div
11455
+ }, ...cursorsDom];
11456
+ };
11457
+
11414
11458
  // TODO use numeric value
11415
11459
  const Error$1 = 'error';
11416
11460
  const Warning = 'warning';
@@ -11455,19 +11499,16 @@ const getDiagnosticsVirtualDom = diagnostics => {
11455
11499
  return dom;
11456
11500
  };
11457
11501
 
11458
- const getGutterInfoVirtualDom = gutterInfo => {
11502
+ const getEditorDiagnosticsVirtualDom = diagnostics => {
11503
+ const diagnosticsDom = getDiagnosticsVirtualDom([...diagnostics]);
11459
11504
  return [{
11460
- childCount: 1,
11461
- className: 'LineNumber',
11462
- type: Span
11463
- }, text(gutterInfo)];
11464
- };
11465
- const getEditorGutterVirtualDom = gutterInfos => {
11466
- const dom = gutterInfos.flatMap(getGutterInfoVirtualDom);
11467
- return dom;
11505
+ childCount: diagnostics.length,
11506
+ className: 'LayerDiagnostics',
11507
+ type: Div
11508
+ }, ...diagnosticsDom];
11468
11509
  };
11469
11510
 
11470
- const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1) => {
11511
+ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1) => {
11471
11512
  const dom = [];
11472
11513
  for (let i = 0; i < textInfos.length; i++) {
11473
11514
  const textInfo = textInfos[i];
@@ -11495,7 +11536,65 @@ const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, hig
11495
11536
  return dom;
11496
11537
  };
11497
11538
 
11498
- const getScrollBarVirtualDom = () => {
11539
+ const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1) => {
11540
+ const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine);
11541
+ return [{
11542
+ childCount: textInfos.length,
11543
+ className: 'EditorRows',
11544
+ onMouseDown: HandleMouseDown,
11545
+ onPointerDown: HandlePointerDown,
11546
+ onWheel: HandleWheel,
11547
+ type: Div
11548
+ }, ...rowsDom];
11549
+ };
11550
+
11551
+ const getSelectionsVirtualDom = selections => {
11552
+ const dom = [];
11553
+ for (let i = 0; i < selections.length; i += 4) {
11554
+ const x = selections[i];
11555
+ const y = selections[i + 1];
11556
+ const width = selections[i + 2];
11557
+ const height = selections[i + 3];
11558
+ dom.push({
11559
+ childCount: 0,
11560
+ className: EditorSelection,
11561
+ height,
11562
+ left: x,
11563
+ top: y,
11564
+ type: Div,
11565
+ width
11566
+ });
11567
+ }
11568
+ return dom;
11569
+ };
11570
+
11571
+ const getEditorSelectionsVirtualDom = selectionInfos => {
11572
+ const selectionsDom = getSelectionsVirtualDom(selectionInfos);
11573
+ return [{
11574
+ childCount: selectionInfos.length / 4,
11575
+ className: 'Selections',
11576
+ type: Div
11577
+ }, ...selectionsDom];
11578
+ };
11579
+
11580
+ const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = []) => {
11581
+ return [{
11582
+ childCount: 4,
11583
+ className: 'EditorLayers',
11584
+ type: Div
11585
+ }, ...getEditorSelectionsVirtualDom(selectionInfos), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine), ...getEditorCursorsVirtualDom(cursorInfos), ...getEditorDiagnosticsVirtualDom(diagnostics)];
11586
+ };
11587
+
11588
+ const getEditorScrollBarDiagnosticsVirtualDom = scrollBarDiagnostics => {
11589
+ return [{
11590
+ childCount: scrollBarDiagnostics.length,
11591
+ className: 'EditorScrollBarDiagnostics',
11592
+ type: Div
11593
+ }, ...getDiagnosticsVirtualDom([...scrollBarDiagnostics])];
11594
+ };
11595
+
11596
+ const getScrollBarVirtualDom = (deltaY, finalDeltaY, height, scrollBarHeight) => {
11597
+ const scrollBarY = getScrollBarY(deltaY, finalDeltaY, height, scrollBarHeight);
11499
11598
  return [{
11500
11599
  childCount: 1,
11501
11600
  className: 'ScrollBar ScrollBarVertical',
@@ -11505,6 +11604,8 @@ const getScrollBarVirtualDom = () => {
11505
11604
  }, {
11506
11605
  childCount: 0,
11507
11606
  className: 'ScrollBarThumb ScrollBarThumbVertical',
11607
+ style: `height:${scrollBarHeight}px;`,
11608
+ translate: `0 ${scrollBarY}px`,
11508
11609
  type: Div
11509
11610
  }, {
11510
11611
  childCount: 1,
@@ -11518,112 +11619,84 @@ const getScrollBarVirtualDom = () => {
11518
11619
  }];
11519
11620
  };
11520
11621
 
11521
- const getSelectionsVirtualDom = selections => {
11522
- const dom = [];
11523
- for (let i = 0; i < selections.length; i += 4) {
11524
- const x = selections[i];
11525
- const y = selections[i + 1];
11526
- const width = selections[i + 2];
11527
- const height = selections[i + 3];
11528
- dom.push({
11529
- className: EditorSelection,
11530
- height,
11531
- left: x,
11532
- top: y,
11533
- type: Div,
11534
- width
11535
- });
11536
- }
11622
+ const getEditorContentVirtualDom = ({
11623
+ cursorInfos = [],
11624
+ deltaY = 0,
11625
+ diagnostics = [],
11626
+ differences,
11627
+ finalDeltaY = 0,
11628
+ height = 0,
11629
+ highlightedLine = -1,
11630
+ lineNumbers = true,
11631
+ scrollBarDiagnostics = [],
11632
+ scrollBarHeight = 0,
11633
+ selectionInfos = [],
11634
+ textInfos
11635
+ }) => {
11636
+ return [{
11637
+ childCount: 5,
11638
+ className: 'EditorContent',
11639
+ onMouseMove: HandleMouseMove,
11640
+ type: Div
11641
+ }, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom(deltaY, finalDeltaY, height, scrollBarHeight)];
11642
+ };
11643
+
11644
+ const getGutterInfoVirtualDom = gutterInfo => {
11645
+ return [{
11646
+ childCount: 1,
11647
+ className: 'LineNumber',
11648
+ type: Span
11649
+ }, text(gutterInfo)];
11650
+ };
11651
+ const getEditorGutterVirtualDom$1 = gutterInfos => {
11652
+ const dom = gutterInfos.flatMap(getGutterInfoVirtualDom);
11537
11653
  return dom;
11538
11654
  };
11539
11655
 
11656
+ const getEditorGutterVirtualDom = gutterInfos => {
11657
+ const gutterDom = getEditorGutterVirtualDom$1([...gutterInfos]);
11658
+ return [{
11659
+ childCount: gutterInfos.length,
11660
+ className: 'Gutter',
11661
+ type: Div
11662
+ }, ...gutterDom];
11663
+ };
11664
+
11540
11665
  const getEditorVirtualDom = ({
11541
11666
  cursorInfos = [],
11667
+ deltaY = 0,
11542
11668
  diagnostics = [],
11543
11669
  differences,
11670
+ finalDeltaY = 0,
11544
11671
  gutterInfos = [],
11672
+ height = 0,
11545
11673
  highlightedLine = -1,
11546
11674
  lineNumbers = true,
11547
11675
  scrollBarDiagnostics = [],
11676
+ scrollBarHeight = 0,
11548
11677
  selectionInfos = [],
11549
11678
  textInfos
11550
11679
  }) => {
11551
- const cursorInfosArray = [...cursorInfos];
11552
- const diagnosticsArray = [...diagnostics];
11553
- const gutterInfosArray = [...gutterInfos];
11554
- const scrollBarDiagnosticsArray = [...scrollBarDiagnostics];
11555
- const rowsDom = getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine);
11556
- const cursorsDom = getCursorsVirtualDom(cursorInfosArray);
11557
- const selectionsDom = getSelectionsVirtualDom(selectionInfos);
11558
- const diagnosticsDom = getDiagnosticsVirtualDom(diagnosticsArray);
11559
- const gutterDom = getEditorGutterVirtualDom(gutterInfosArray);
11560
- const scrollBarDiagnosticsDom = getDiagnosticsVirtualDom(scrollBarDiagnosticsArray);
11561
- const scrollBarDom = getScrollBarVirtualDom();
11562
11680
  return [{
11563
11681
  childCount: 2,
11564
11682
  className: 'Viewlet Editor',
11565
11683
  onContextMenu: HandleContextMenu,
11566
- onWheel: HandleWheel,
11567
11684
  role: 'code',
11568
11685
  type: Div
11569
- }, {
11570
- childCount: gutterInfosArray.length,
11571
- className: 'Gutter',
11572
- type: Div
11573
- }, ...gutterDom, {
11574
- childCount: 5,
11575
- className: 'EditorContent',
11576
- onMouseMove: HandleMouseMove,
11577
- type: Div
11578
- }, {
11579
- ariaAutoComplete: 'list',
11580
- ariaMultiLine: 'true',
11581
- ariaRoleDescription: 'editor',
11582
- autocapitalize: 'off',
11583
- autocomplete: 'off',
11584
- autocorrect: 'off',
11585
- childCount: 0,
11586
- className: 'EditorInput',
11587
- name: 'editor',
11588
- onBeforeInput: HandleBeforeInput,
11589
- onBlur: HandleBlur,
11590
- onCompositionEnd: HandleCompositionEnd,
11591
- onCompositionStart: HandleCompositionStart,
11592
- onCompositionUpdate: HandleCompositionUpdate,
11593
- onCut: HandleCut,
11594
- onFocus: HandleFocus,
11595
- onPaste: HandlePaste,
11596
- role: 'textbox',
11597
- spellcheck: false,
11598
- type: TextArea,
11599
- wrap: 'off'
11600
- }, {
11601
- childCount: 4,
11602
- className: 'EditorLayers',
11603
- type: Div
11604
- }, {
11605
- childCount: selectionsDom.length,
11606
- className: 'Selections',
11607
- type: Div
11608
- }, ...selectionsDom, {
11609
- childCount: textInfos.length,
11610
- className: 'EditorRows',
11611
- onMouseDown: HandleMouseDown,
11612
- onPointerDown: HandlePointerDown,
11613
- type: Div
11614
- }, ...rowsDom, {
11615
- childCount: cursorsDom.length,
11616
- className: 'LayerCursor',
11617
- type: Div
11618
- }, ...cursorsDom, {
11619
- childCount: diagnosticsDom.length,
11620
- className: 'LayerDiagnostics',
11621
- type: Div
11622
- }, ...diagnosticsDom, {
11623
- childCount: scrollBarDiagnosticsDom.length,
11624
- className: 'EditorScrollBarDiagnostics',
11625
- type: Div
11626
- }, ...scrollBarDiagnosticsDom, ...scrollBarDom];
11686
+ }, ...getEditorGutterVirtualDom(gutterInfos), ...getEditorContentVirtualDom({
11687
+ cursorInfos,
11688
+ deltaY,
11689
+ diagnostics,
11690
+ differences,
11691
+ finalDeltaY,
11692
+ height,
11693
+ highlightedLine,
11694
+ lineNumbers,
11695
+ scrollBarDiagnostics,
11696
+ scrollBarHeight,
11697
+ selectionInfos,
11698
+ textInfos
11699
+ })];
11627
11700
  };
11628
11701
 
11629
11702
  const getDom = state => {
@@ -11720,7 +11793,7 @@ const renderLines = {
11720
11793
  minLineY
11721
11794
  } = newState;
11722
11795
  const relativeLine = highlightedLine - minLineY;
11723
- const dom = getEditorRowsVirtualDom(textInfos, differences, true, relativeLine);
11796
+ const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, relativeLine);
11724
11797
  return [/* method */'setText', dom];
11725
11798
  },
11726
11799
  isEqual(oldState, newState) {
@@ -11811,7 +11884,7 @@ const renderGutterInfo = {
11811
11884
  gutterInfos.push(i + 1);
11812
11885
  }
11813
11886
  }
11814
- const dom = getEditorGutterVirtualDom(gutterInfos);
11887
+ const dom = getEditorGutterVirtualDom$1(gutterInfos);
11815
11888
  return ['renderGutter', dom];
11816
11889
  },
11817
11890
  isEqual(oldState, newState) {
@@ -11947,7 +12020,7 @@ const renderEventListeners = () => {
11947
12020
  params: ['handlePointerUp']
11948
12021
  }, {
11949
12022
  name: HandleWheel,
11950
- params: ['setDelta', DeltaMode, DeltaY],
12023
+ params: ['handleWheel', DeltaMode, 'event.deltaX', DeltaY],
11951
12024
  passive: true
11952
12025
  }, {
11953
12026
  name: HandleContextMenu,
@@ -12166,6 +12239,7 @@ const commandMap = {
12166
12239
  'Editor.handleTouchMove': wrapCommandOld(handleTouchMove),
12167
12240
  'Editor.handleTouchStart': wrapCommandOld(handleTouchStart),
12168
12241
  'Editor.handleTripleClick': wrapCommandOld(handleTripleClick),
12242
+ 'Editor.handleWheel': wrapCommandOld(handleWheel$2),
12169
12243
  'Editor.hotReload': hotReload,
12170
12244
  'Editor.indendLess': wrapCommandOld(indentLess),
12171
12245
  'Editor.indentMore': wrapCommandOld(indentMore),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "18.16.0",
3
+ "version": "18.18.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"