@lvce-editor/editor-worker 18.16.0 → 18.17.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.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
 
@@ -11399,10 +11400,37 @@ const diffTree = (oldNodes, newNodes) => {
11399
11400
  return removeTrailingNavigationPatches(patches);
11400
11401
  };
11401
11402
 
11403
+ const getEditorInputVirtualDom = () => {
11404
+ return [{
11405
+ ariaAutoComplete: 'list',
11406
+ ariaMultiLine: 'true',
11407
+ ariaRoleDescription: 'editor',
11408
+ autocapitalize: 'off',
11409
+ autocomplete: 'off',
11410
+ autocorrect: 'off',
11411
+ childCount: 0,
11412
+ className: 'EditorInput',
11413
+ name: 'editor',
11414
+ onBeforeInput: HandleBeforeInput,
11415
+ onBlur: HandleBlur,
11416
+ onCompositionEnd: HandleCompositionEnd,
11417
+ onCompositionStart: HandleCompositionStart,
11418
+ onCompositionUpdate: HandleCompositionUpdate,
11419
+ onCut: HandleCut,
11420
+ onFocus: HandleFocus,
11421
+ onPaste: HandlePaste,
11422
+ role: 'textbox',
11423
+ spellcheck: false,
11424
+ type: TextArea,
11425
+ wrap: 'off'
11426
+ }];
11427
+ };
11428
+
11402
11429
  const getCursorsVirtualDom = cursors => {
11403
11430
  const dom = [];
11404
11431
  for (const translate of cursors) {
11405
11432
  dom.push({
11433
+ childCount: 0,
11406
11434
  className: EditorCursor,
11407
11435
  translate,
11408
11436
  type: Div
@@ -11411,6 +11439,15 @@ const getCursorsVirtualDom = cursors => {
11411
11439
  return dom;
11412
11440
  };
11413
11441
 
11442
+ const getEditorCursorsVirtualDom = cursorInfos => {
11443
+ const cursorsDom = getCursorsVirtualDom([...cursorInfos]);
11444
+ return [{
11445
+ childCount: cursorInfos.length,
11446
+ className: 'LayerCursor',
11447
+ type: Div
11448
+ }, ...cursorsDom];
11449
+ };
11450
+
11414
11451
  // TODO use numeric value
11415
11452
  const Error$1 = 'error';
11416
11453
  const Warning = 'warning';
@@ -11455,19 +11492,16 @@ const getDiagnosticsVirtualDom = diagnostics => {
11455
11492
  return dom;
11456
11493
  };
11457
11494
 
11458
- const getGutterInfoVirtualDom = gutterInfo => {
11495
+ const getEditorDiagnosticsVirtualDom = diagnostics => {
11496
+ const diagnosticsDom = getDiagnosticsVirtualDom([...diagnostics]);
11459
11497
  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;
11498
+ childCount: diagnostics.length,
11499
+ className: 'LayerDiagnostics',
11500
+ type: Div
11501
+ }, ...diagnosticsDom];
11468
11502
  };
11469
11503
 
11470
- const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1) => {
11504
+ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1) => {
11471
11505
  const dom = [];
11472
11506
  for (let i = 0; i < textInfos.length; i++) {
11473
11507
  const textInfo = textInfos[i];
@@ -11495,6 +11529,62 @@ const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, hig
11495
11529
  return dom;
11496
11530
  };
11497
11531
 
11532
+ const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1) => {
11533
+ const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine);
11534
+ return [{
11535
+ childCount: textInfos.length,
11536
+ className: 'EditorRows',
11537
+ onMouseDown: HandleMouseDown,
11538
+ onPointerDown: HandlePointerDown,
11539
+ type: Div
11540
+ }, ...rowsDom];
11541
+ };
11542
+
11543
+ const getSelectionsVirtualDom = selections => {
11544
+ const dom = [];
11545
+ for (let i = 0; i < selections.length; i += 4) {
11546
+ const x = selections[i];
11547
+ const y = selections[i + 1];
11548
+ const width = selections[i + 2];
11549
+ const height = selections[i + 3];
11550
+ dom.push({
11551
+ childCount: 0,
11552
+ className: EditorSelection,
11553
+ height,
11554
+ left: x,
11555
+ top: y,
11556
+ type: Div,
11557
+ width
11558
+ });
11559
+ }
11560
+ return dom;
11561
+ };
11562
+
11563
+ const getEditorSelectionsVirtualDom = selectionInfos => {
11564
+ const selectionsDom = getSelectionsVirtualDom(selectionInfos);
11565
+ return [{
11566
+ childCount: selectionInfos.length / 4,
11567
+ className: 'Selections',
11568
+ type: Div
11569
+ }, ...selectionsDom];
11570
+ };
11571
+
11572
+ const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = []) => {
11573
+ return [{
11574
+ childCount: 4,
11575
+ className: 'EditorLayers',
11576
+ type: Div
11577
+ }, ...getEditorSelectionsVirtualDom(selectionInfos), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine), ...getEditorCursorsVirtualDom(cursorInfos), ...getEditorDiagnosticsVirtualDom(diagnostics)];
11578
+ };
11579
+
11580
+ const getEditorScrollBarDiagnosticsVirtualDom = scrollBarDiagnostics => {
11581
+ return [{
11582
+ childCount: scrollBarDiagnostics.length,
11583
+ className: 'EditorScrollBarDiagnostics',
11584
+ type: Div
11585
+ }, ...getDiagnosticsVirtualDom([...scrollBarDiagnostics])];
11586
+ };
11587
+
11498
11588
  const getScrollBarVirtualDom = () => {
11499
11589
  return [{
11500
11590
  childCount: 1,
@@ -11518,25 +11608,45 @@ const getScrollBarVirtualDom = () => {
11518
11608
  }];
11519
11609
  };
11520
11610
 
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
- }
11611
+ const getEditorContentVirtualDom = ({
11612
+ cursorInfos = [],
11613
+ diagnostics = [],
11614
+ differences,
11615
+ highlightedLine = -1,
11616
+ lineNumbers = true,
11617
+ scrollBarDiagnostics = [],
11618
+ selectionInfos = [],
11619
+ textInfos
11620
+ }) => {
11621
+ return [{
11622
+ childCount: 5,
11623
+ className: 'EditorContent',
11624
+ onMouseMove: HandleMouseMove,
11625
+ type: Div
11626
+ }, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom()];
11627
+ };
11628
+
11629
+ const getGutterInfoVirtualDom = gutterInfo => {
11630
+ return [{
11631
+ childCount: 1,
11632
+ className: 'LineNumber',
11633
+ type: Span
11634
+ }, text(gutterInfo)];
11635
+ };
11636
+ const getEditorGutterVirtualDom$1 = gutterInfos => {
11637
+ const dom = gutterInfos.flatMap(getGutterInfoVirtualDom);
11537
11638
  return dom;
11538
11639
  };
11539
11640
 
11641
+ const getEditorGutterVirtualDom = gutterInfos => {
11642
+ const gutterDom = getEditorGutterVirtualDom$1([...gutterInfos]);
11643
+ return [{
11644
+ childCount: gutterInfos.length,
11645
+ className: 'Gutter',
11646
+ type: Div
11647
+ }, ...gutterDom];
11648
+ };
11649
+
11540
11650
  const getEditorVirtualDom = ({
11541
11651
  cursorInfos = [],
11542
11652
  diagnostics = [],
@@ -11548,17 +11658,6 @@ const getEditorVirtualDom = ({
11548
11658
  selectionInfos = [],
11549
11659
  textInfos
11550
11660
  }) => {
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
11661
  return [{
11563
11662
  childCount: 2,
11564
11663
  className: 'Viewlet Editor',
@@ -11566,64 +11665,16 @@ const getEditorVirtualDom = ({
11566
11665
  onWheel: HandleWheel,
11567
11666
  role: 'code',
11568
11667
  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];
11668
+ }, ...getEditorGutterVirtualDom(gutterInfos), ...getEditorContentVirtualDom({
11669
+ cursorInfos,
11670
+ diagnostics,
11671
+ differences,
11672
+ highlightedLine,
11673
+ lineNumbers,
11674
+ scrollBarDiagnostics,
11675
+ selectionInfos,
11676
+ textInfos
11677
+ })];
11627
11678
  };
11628
11679
 
11629
11680
  const getDom = state => {
@@ -11720,7 +11771,7 @@ const renderLines = {
11720
11771
  minLineY
11721
11772
  } = newState;
11722
11773
  const relativeLine = highlightedLine - minLineY;
11723
- const dom = getEditorRowsVirtualDom(textInfos, differences, true, relativeLine);
11774
+ const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, relativeLine);
11724
11775
  return [/* method */'setText', dom];
11725
11776
  },
11726
11777
  isEqual(oldState, newState) {
@@ -11811,7 +11862,7 @@ const renderGutterInfo = {
11811
11862
  gutterInfos.push(i + 1);
11812
11863
  }
11813
11864
  }
11814
- const dom = getEditorGutterVirtualDom(gutterInfos);
11865
+ const dom = getEditorGutterVirtualDom$1(gutterInfos);
11815
11866
  return ['renderGutter', dom];
11816
11867
  },
11817
11868
  isEqual(oldState, newState) {
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.17.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"