@hailin-zheng/editor-core 1.0.54 → 1.0.57

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,11 +6663,13 @@ 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();
6672
+ this.selectionState.clear();
6671
6673
  if (!range) {
6672
6674
  return false;
6673
6675
  }
@@ -6680,6 +6682,7 @@ class DocumentSelection {
6680
6682
  this.selectionState.endControlIndex = ElementUtil.getControlIndex(range.endControl);
6681
6683
  this.selectionState.ancestorCommonControl = DocumentSelection.getAncestorCommonControl(this.selectionState.startControl, this.selectionState.endControl);
6682
6684
  this.selectionState.enableTrackChanges = this.getEnableTrackChanges(range.startControl);
6685
+ this.selectionState.rangeDirty = false;
6683
6686
  return true;
6684
6687
  }
6685
6688
  /**
@@ -6690,17 +6693,6 @@ class DocumentSelection {
6690
6693
  const body = ElementUtil.getParentByType(ele, DocumentBodyElement);
6691
6694
  return body?.trackChanges || false;
6692
6695
  }
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
6696
  /**
6705
6697
  * 转换选区内容
6706
6698
  * 处理结束选区在开始选区之前
@@ -6794,9 +6786,14 @@ class SelectionState {
6794
6786
  this.selectedRange = null;
6795
6787
  this.cursorPos = null;
6796
6788
  }
6789
+ /**
6790
+ * 当前选区是否发生改变
6791
+ */
6792
+ rangeDirty = false;
6797
6793
  addRange(range) {
6798
- //this.clear();
6794
+ this.clear();
6799
6795
  this.range = range;
6796
+ this.rangeDirty = true;
6800
6797
  this.onChangedEvent.next();
6801
6798
  }
6802
6799
  resetRange(startControl, startOffset) {
@@ -12269,6 +12266,7 @@ class DocumentEvent {
12269
12266
  const newParents = ElementUtil.getParentElements(focusElement);
12270
12267
  const leaveParents = oldParents.filter(item => newParents.every(oldItem => item !== oldItem));
12271
12268
  const enterParents = newParents.filter(item => oldParents.every(oldItem => item !== oldItem));
12269
+ let cancelEvent = false;
12272
12270
  const loopInvokeEvent = (eventName, array) => {
12273
12271
  for (const element of array) {
12274
12272
  const mouseEvent = new LostCursorEvent(this.docCtx);
@@ -12277,13 +12275,16 @@ class DocumentEvent {
12277
12275
  mouseEvent.ctx = this.docCtx;
12278
12276
  element.invokeEvent(eventName, mouseEvent);
12279
12277
  if (mouseEvent.isCancel) {
12278
+ cancelEvent = true;
12280
12279
  break;
12281
12280
  }
12282
12281
  }
12283
12282
  };
12284
12283
  loopInvokeEvent('LostCursor', leaveParents);
12285
12284
  loopInvokeEvent('GotCursor', enterParents);
12286
- this.prevCursorItems = newParents;
12285
+ if (!cancelEvent) {
12286
+ this.prevCursorItems = newParents;
12287
+ }
12287
12288
  //dDocumentEvent.invokeEvent('GotCursor', focusElement, getCursorEvent, 'All', this.docCtx);
12288
12289
  }
12289
12290
  /**
@@ -16047,13 +16048,13 @@ class CanvasTextEditor {
16047
16048
  this.documentPaint.refreshView(rePaint);
16048
16049
  this.setScrollSize();
16049
16050
  this.setCursor();
16050
- ssChanged && this.selectionChanged.next(this.documentSelection.selectionState);
16051
+ (ssChanged || rePaint) && this.selectionChanged.next(this.documentSelection.selectionState);
16051
16052
  this.docRule.refreshRule();
16052
16053
  }
16053
16054
  hitInfoChanged(hitInfo) {
16054
16055
  this.documentSelection.setSelectionState(hitInfo);
16055
16056
  this.refreshDocument();
16056
- this.selectionChanged.next(this.documentSelection.selectionState);
16057
+ //this.selectionChanged.next(this.documentSelection.selectionState);
16057
16058
  }
16058
16059
  /**
16059
16060
  * 设置光标