@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 +21 -20
- package/index-cjs.js.map +1 -1
- package/index.js +21 -20
- package/index.js.map +1 -1
- package/med_editor/framework/document-selection.d.ts +6 -3
- package/package.json +1 -1
package/index.js
CHANGED
@@ -2770,8 +2770,8 @@ class DataElementRenderObject extends InlineGroupRenderObject {
|
|
2770
2770
|
const titleWidth = render.contentContext.measureText(caption, textProps).width;
|
2771
2771
|
const x = position.x;
|
2772
2772
|
const y = position.y - 20;
|
2773
|
-
render.contentContext.fillRect(x, y, titleWidth, 20, 'blue');
|
2774
|
-
render.contentContext.drawText(caption, textProps, x, y, titleWidth, 20);
|
2773
|
+
render.contentContext.fillRect(x, y, titleWidth + 10, 20, 'blue');
|
2774
|
+
render.contentContext.drawText(caption, textProps, x + 5, y, titleWidth, 20);
|
2775
2775
|
}
|
2776
2776
|
}
|
2777
2777
|
}
|
@@ -6618,8 +6618,8 @@ class DocumentSelection {
|
|
6618
6618
|
this.selectionState.addRange(startRange);
|
6619
6619
|
}
|
6620
6620
|
/**
|
6621
|
-
|
6622
|
-
|
6621
|
+
* 获取选区共同的祖先控件
|
6622
|
+
*/
|
6623
6623
|
static getAncestorCommonControl(startControl, endControl) {
|
6624
6624
|
const startNestParents = this.getNestParents(startControl.parent);
|
6625
6625
|
const ancestorCommonControl = this.getCommonParenet(endControl.parent, startNestParents);
|
@@ -6654,11 +6654,13 @@ class DocumentSelection {
|
|
6654
6654
|
* @private
|
6655
6655
|
*/
|
6656
6656
|
updateSelectionState() {
|
6657
|
-
if (this.
|
6657
|
+
if (!this.selectionState.rangeDirty) {
|
6658
6658
|
return false;
|
6659
6659
|
}
|
6660
6660
|
const range = this.selectionState.range;
|
6661
|
+
//转换选区
|
6661
6662
|
this.transformRange();
|
6663
|
+
this.selectionState.clear();
|
6662
6664
|
if (!range) {
|
6663
6665
|
return false;
|
6664
6666
|
}
|
@@ -6671,6 +6673,7 @@ class DocumentSelection {
|
|
6671
6673
|
this.selectionState.endControlIndex = ElementUtil.getControlIndex(range.endControl);
|
6672
6674
|
this.selectionState.ancestorCommonControl = DocumentSelection.getAncestorCommonControl(this.selectionState.startControl, this.selectionState.endControl);
|
6673
6675
|
this.selectionState.enableTrackChanges = this.getEnableTrackChanges(range.startControl);
|
6676
|
+
this.selectionState.rangeDirty = false;
|
6674
6677
|
return true;
|
6675
6678
|
}
|
6676
6679
|
/**
|
@@ -6681,17 +6684,6 @@ class DocumentSelection {
|
|
6681
6684
|
const body = ElementUtil.getParentByType(ele, DocumentBodyElement);
|
6682
6685
|
return body?.trackChanges || false;
|
6683
6686
|
}
|
6684
|
-
compareSelectionEquals() {
|
6685
|
-
const range = this.selectionState.range;
|
6686
|
-
const snap = this.snapshotSelectionState;
|
6687
|
-
if (snap && range) {
|
6688
|
-
return range.startControl === snap.startControl
|
6689
|
-
&& range.startOffset === snap.startOffset
|
6690
|
-
&& range.endControl === snap.endControl
|
6691
|
-
&& range.endOffset === snap.endOffset;
|
6692
|
-
}
|
6693
|
-
return false;
|
6694
|
-
}
|
6695
6687
|
/**
|
6696
6688
|
* 转换选区内容
|
6697
6689
|
* 处理结束选区在开始选区之前
|
@@ -6785,9 +6777,14 @@ class SelectionState {
|
|
6785
6777
|
this.selectedRange = null;
|
6786
6778
|
this.cursorPos = null;
|
6787
6779
|
}
|
6780
|
+
/**
|
6781
|
+
* 当前选区是否发生改变
|
6782
|
+
*/
|
6783
|
+
rangeDirty = false;
|
6788
6784
|
addRange(range) {
|
6789
|
-
|
6785
|
+
this.clear();
|
6790
6786
|
this.range = range;
|
6787
|
+
this.rangeDirty = true;
|
6791
6788
|
this.onChangedEvent.next();
|
6792
6789
|
}
|
6793
6790
|
resetRange(startControl, startOffset) {
|
@@ -12260,6 +12257,7 @@ class DocumentEvent {
|
|
12260
12257
|
const newParents = ElementUtil.getParentElements(focusElement);
|
12261
12258
|
const leaveParents = oldParents.filter(item => newParents.every(oldItem => item !== oldItem));
|
12262
12259
|
const enterParents = newParents.filter(item => oldParents.every(oldItem => item !== oldItem));
|
12260
|
+
let cancelEvent = false;
|
12263
12261
|
const loopInvokeEvent = (eventName, array) => {
|
12264
12262
|
for (const element of array) {
|
12265
12263
|
const mouseEvent = new LostCursorEvent(this.docCtx);
|
@@ -12268,13 +12266,16 @@ class DocumentEvent {
|
|
12268
12266
|
mouseEvent.ctx = this.docCtx;
|
12269
12267
|
element.invokeEvent(eventName, mouseEvent);
|
12270
12268
|
if (mouseEvent.isCancel) {
|
12269
|
+
cancelEvent = true;
|
12271
12270
|
break;
|
12272
12271
|
}
|
12273
12272
|
}
|
12274
12273
|
};
|
12275
12274
|
loopInvokeEvent('LostCursor', leaveParents);
|
12276
12275
|
loopInvokeEvent('GotCursor', enterParents);
|
12277
|
-
|
12276
|
+
if (!cancelEvent) {
|
12277
|
+
this.prevCursorItems = newParents;
|
12278
|
+
}
|
12278
12279
|
//dDocumentEvent.invokeEvent('GotCursor', focusElement, getCursorEvent, 'All', this.docCtx);
|
12279
12280
|
}
|
12280
12281
|
/**
|
@@ -16038,13 +16039,13 @@ class CanvasTextEditor {
|
|
16038
16039
|
this.documentPaint.refreshView(rePaint);
|
16039
16040
|
this.setScrollSize();
|
16040
16041
|
this.setCursor();
|
16041
|
-
ssChanged && this.selectionChanged.next(this.documentSelection.selectionState);
|
16042
|
+
(ssChanged || rePaint) && this.selectionChanged.next(this.documentSelection.selectionState);
|
16042
16043
|
this.docRule.refreshRule();
|
16043
16044
|
}
|
16044
16045
|
hitInfoChanged(hitInfo) {
|
16045
16046
|
this.documentSelection.setSelectionState(hitInfo);
|
16046
16047
|
this.refreshDocument();
|
16047
|
-
this.selectionChanged.next(this.documentSelection.selectionState);
|
16048
|
+
//this.selectionChanged.next(this.documentSelection.selectionState);
|
16048
16049
|
}
|
16049
16050
|
/**
|
16050
16051
|
* 设置光标
|