@hailin-zheng/editor-core 1.0.54 → 1.0.55

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.
package/index-cjs.js CHANGED
@@ -2779,8 +2779,8 @@ class DataElementRenderObject extends InlineGroupRenderObject {
2779
2779
  const titleWidth = render.contentContext.measureText(caption, textProps).width;
2780
2780
  const x = position.x;
2781
2781
  const y = position.y - 20;
2782
- render.contentContext.fillRect(x, y, titleWidth, 20, 'blue');
2783
- render.contentContext.drawText(caption, textProps, x, y, titleWidth, 20);
2782
+ render.contentContext.fillRect(x, y, titleWidth + 10, 20, 'blue');
2783
+ render.contentContext.drawText(caption, textProps, x + 5, y, titleWidth, 20);
2784
2784
  }
2785
2785
  }
2786
2786
  }
@@ -6627,8 +6627,8 @@ class DocumentSelection {
6627
6627
  this.selectionState.addRange(startRange);
6628
6628
  }
6629
6629
  /**
6630
- * 获取选区共同的祖先控件
6631
- */
6630
+ * 获取选区共同的祖先控件
6631
+ */
6632
6632
  static getAncestorCommonControl(startControl, endControl) {
6633
6633
  const startNestParents = this.getNestParents(startControl.parent);
6634
6634
  const ancestorCommonControl = this.getCommonParenet(endControl.parent, startNestParents);
@@ -6663,10 +6663,11 @@ class DocumentSelection {
6663
6663
  * @private
6664
6664
  */
6665
6665
  updateSelectionState() {
6666
- if (this.compareSelectionEquals()) {
6666
+ if (!this.selectionState.rangeDirty) {
6667
6667
  return false;
6668
6668
  }
6669
6669
  const range = this.selectionState.range;
6670
+ //转换选区
6670
6671
  this.transformRange();
6671
6672
  if (!range) {
6672
6673
  return false;
@@ -6680,6 +6681,7 @@ class DocumentSelection {
6680
6681
  this.selectionState.endControlIndex = ElementUtil.getControlIndex(range.endControl);
6681
6682
  this.selectionState.ancestorCommonControl = DocumentSelection.getAncestorCommonControl(this.selectionState.startControl, this.selectionState.endControl);
6682
6683
  this.selectionState.enableTrackChanges = this.getEnableTrackChanges(range.startControl);
6684
+ this.selectionState.rangeDirty = false;
6683
6685
  return true;
6684
6686
  }
6685
6687
  /**
@@ -6690,17 +6692,6 @@ class DocumentSelection {
6690
6692
  const body = ElementUtil.getParentByType(ele, DocumentBodyElement);
6691
6693
  return body?.trackChanges || false;
6692
6694
  }
6693
- compareSelectionEquals() {
6694
- const range = this.selectionState.range;
6695
- const snap = this.snapshotSelectionState;
6696
- if (snap && range) {
6697
- return range.startControl === snap.startControl
6698
- && range.startOffset === snap.startOffset
6699
- && range.endControl === snap.endControl
6700
- && range.endOffset === snap.endOffset;
6701
- }
6702
- return false;
6703
- }
6704
6695
  /**
6705
6696
  * 转换选区内容
6706
6697
  * 处理结束选区在开始选区之前
@@ -6794,9 +6785,14 @@ class SelectionState {
6794
6785
  this.selectedRange = null;
6795
6786
  this.cursorPos = null;
6796
6787
  }
6788
+ /**
6789
+ * 当前选区是否发生改变
6790
+ */
6791
+ rangeDirty = false;
6797
6792
  addRange(range) {
6798
6793
  //this.clear();
6799
6794
  this.range = range;
6795
+ this.rangeDirty = true;
6800
6796
  this.onChangedEvent.next();
6801
6797
  }
6802
6798
  resetRange(startControl, startOffset) {
@@ -12269,6 +12265,7 @@ class DocumentEvent {
12269
12265
  const newParents = ElementUtil.getParentElements(focusElement);
12270
12266
  const leaveParents = oldParents.filter(item => newParents.every(oldItem => item !== oldItem));
12271
12267
  const enterParents = newParents.filter(item => oldParents.every(oldItem => item !== oldItem));
12268
+ let cancelEvent = false;
12272
12269
  const loopInvokeEvent = (eventName, array) => {
12273
12270
  for (const element of array) {
12274
12271
  const mouseEvent = new LostCursorEvent(this.docCtx);
@@ -12277,13 +12274,16 @@ class DocumentEvent {
12277
12274
  mouseEvent.ctx = this.docCtx;
12278
12275
  element.invokeEvent(eventName, mouseEvent);
12279
12276
  if (mouseEvent.isCancel) {
12277
+ cancelEvent = true;
12280
12278
  break;
12281
12279
  }
12282
12280
  }
12283
12281
  };
12284
12282
  loopInvokeEvent('LostCursor', leaveParents);
12285
12283
  loopInvokeEvent('GotCursor', enterParents);
12286
- this.prevCursorItems = newParents;
12284
+ if (!cancelEvent) {
12285
+ this.prevCursorItems = newParents;
12286
+ }
12287
12287
  //dDocumentEvent.invokeEvent('GotCursor', focusElement, getCursorEvent, 'All', this.docCtx);
12288
12288
  }
12289
12289
  /**
@@ -16043,10 +16043,10 @@ class CanvasTextEditor {
16043
16043
  */
16044
16044
  refreshView(rePaint) {
16045
16045
  const ssChanged = this.documentSelection.updateSelectionState();
16046
+ this.setCursor();
16046
16047
  this.selectionOverlays.getSelectionTreeData();
16047
16048
  this.documentPaint.refreshView(rePaint);
16048
16049
  this.setScrollSize();
16049
- this.setCursor();
16050
16050
  ssChanged && this.selectionChanged.next(this.documentSelection.selectionState);
16051
16051
  this.docRule.refreshRule();
16052
16052
  }