@hailin-zheng/editor-core 2.2.22 → 2.2.24
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 +101 -83
- package/index-cjs.js.map +1 -1
- package/index.js +101 -83
- package/index.js.map +1 -1
- package/med_editor/doc-editor.d.ts +4 -0
- package/med_editor/framework/util/element-util.d.ts +1 -12
- package/package.json +1 -1
package/index.js
CHANGED
@@ -12053,81 +12053,87 @@ class ElementUtil {
|
|
12053
12053
|
}
|
12054
12054
|
return true;
|
12055
12055
|
}
|
12056
|
-
|
12057
|
-
|
12058
|
-
|
12059
|
-
|
12060
|
-
|
12061
|
-
|
12062
|
-
|
12063
|
-
const lines = [];
|
12064
|
-
lines.push({
|
12065
|
-
f: {
|
12066
|
-
x: rect.x,
|
12067
|
-
y: rect.y
|
12068
|
-
},
|
12069
|
-
s: {
|
12070
|
-
x: rect.x + rect.width,
|
12071
|
-
y: rect.y
|
12072
|
-
}
|
12073
|
-
}, {
|
12074
|
-
f: {
|
12075
|
-
x: rect.x,
|
12076
|
-
y: rect.y
|
12077
|
-
},
|
12078
|
-
s: {
|
12079
|
-
x: rect.x,
|
12080
|
-
y: rect.y + rect.height
|
12081
|
-
}
|
12082
|
-
}, {
|
12083
|
-
f: {
|
12084
|
-
x: rect.x,
|
12085
|
-
y: rect.y + rect.height
|
12086
|
-
},
|
12087
|
-
s: {
|
12088
|
-
x: rect.x + rect.width,
|
12089
|
-
y: rect.y + rect.height
|
12090
|
-
}
|
12091
|
-
}, {
|
12092
|
-
f: {
|
12093
|
-
x: rect.x + rect.width,
|
12094
|
-
y: rect.y
|
12095
|
-
},
|
12096
|
-
s: {
|
12097
|
-
x: rect.x + rect.width,
|
12098
|
-
y: rect.y + rect.height
|
12099
|
-
}
|
12100
|
-
});
|
12101
|
-
const distances = lines.map(item => this.minDistance(item.f, item.s, p));
|
12102
|
-
return Math.min(...distances);
|
12103
|
-
}
|
12104
|
-
static minDistance(A, B, E) {
|
12105
|
-
const AB = { x: B.x - A.x, y: B.y - A.y };
|
12106
|
-
const BE = { x: E.x - B.x, y: E.y - B.y };
|
12107
|
-
const AE = { x: E.x - A.x, y: E.y - A.y };
|
12108
|
-
const AB_BE = (AB.x * BE.x + AB.y * BE.y);
|
12109
|
-
const AB_AE = (AB.x * AE.x + AB.y * AE.y);
|
12110
|
-
let reqAns = 0;
|
12111
|
-
if (AB_BE > 0) {
|
12112
|
-
const y = E.y - B.y;
|
12113
|
-
const x = E.x - B.x;
|
12114
|
-
reqAns = Math.sqrt(x * x + y * y);
|
12115
|
-
}
|
12116
|
-
else if (AB_AE < 0) {
|
12117
|
-
const y = E.y - A.y;
|
12118
|
-
const x = E.x - A.x;
|
12119
|
-
reqAns = Math.sqrt(x * x + y * y);
|
12120
|
-
}
|
12121
|
-
else {
|
12122
|
-
const x1 = AB.x;
|
12123
|
-
const y1 = AB.y;
|
12124
|
-
const x2 = AE.x;
|
12125
|
-
const y2 = AE.y;
|
12126
|
-
const mod = Math.sqrt(x1 * x1 + y1 * y1);
|
12127
|
-
reqAns = Math.abs(x1 * y2 - y1 * x2) / mod;
|
12128
|
-
}
|
12129
|
-
return reqAns;
|
12056
|
+
static getDistanceToRect(rect, point) {
|
12057
|
+
// 点到矩形左边的距离
|
12058
|
+
const dx = Math.max(rect.x - point.x, 0, point.x - (rect.x + rect.width));
|
12059
|
+
// 点到矩形上边的距离
|
12060
|
+
const dy = Math.max(rect.y - point.y, 0, point.y - (rect.y + rect.height));
|
12061
|
+
// 距离公式
|
12062
|
+
return Math.sqrt(dx * dx + dy * dy);
|
12130
12063
|
}
|
12064
|
+
// /**
|
12065
|
+
// * 获取一个点到一个矩形最短的距离
|
12066
|
+
// * @param rect
|
12067
|
+
// * @param p
|
12068
|
+
// * @returns
|
12069
|
+
// */
|
12070
|
+
// static getDistanceToRect(rect: Rect, p: Position) {
|
12071
|
+
// const lines: Array<{ f: PAIR, s: PAIR }> = [];
|
12072
|
+
// lines.push({
|
12073
|
+
// f: {
|
12074
|
+
// x: rect.x,
|
12075
|
+
// y: rect.y
|
12076
|
+
// },
|
12077
|
+
// s: {
|
12078
|
+
// x: rect.x + rect.width,
|
12079
|
+
// y: rect.y
|
12080
|
+
// }
|
12081
|
+
// }, {
|
12082
|
+
// f: {
|
12083
|
+
// x: rect.x,
|
12084
|
+
// y: rect.y
|
12085
|
+
// },
|
12086
|
+
// s: {
|
12087
|
+
// x: rect.x,
|
12088
|
+
// y: rect.y + rect.height
|
12089
|
+
// }
|
12090
|
+
// }, {
|
12091
|
+
// f: {
|
12092
|
+
// x: rect.x,
|
12093
|
+
// y: rect.y + rect.height
|
12094
|
+
// },
|
12095
|
+
// s: {
|
12096
|
+
// x: rect.x + rect.width,
|
12097
|
+
// y: rect.y + rect.height
|
12098
|
+
// }
|
12099
|
+
// }, {
|
12100
|
+
// f: {
|
12101
|
+
// x: rect.x + rect.width,
|
12102
|
+
// y: rect.y
|
12103
|
+
// },
|
12104
|
+
// s: {
|
12105
|
+
// x: rect.x + rect.width,
|
12106
|
+
// y: rect.y + rect.height
|
12107
|
+
// }
|
12108
|
+
// })
|
12109
|
+
// const distances = lines.map(item => this.minDistance(item.f, item.s, p))
|
12110
|
+
// return Math.min(...distances);
|
12111
|
+
// }
|
12112
|
+
// static minDistance(A: PAIR, B: PAIR, E: PAIR) {
|
12113
|
+
// const AB: PAIR = { x: B.x - A.x, y: B.y - A.y }
|
12114
|
+
// const BE: PAIR = { x: E.x - B.x, y: E.y - B.y };
|
12115
|
+
// const AE: PAIR = { x: E.x - A.x, y: E.y - A.y }
|
12116
|
+
// const AB_BE = (AB.x * BE.x + AB.y * BE.y);
|
12117
|
+
// const AB_AE = (AB.x * AE.x + AB.y * AE.y);
|
12118
|
+
// let reqAns = 0;
|
12119
|
+
// if (AB_BE > 0) {
|
12120
|
+
// const y = E.y - B.y;
|
12121
|
+
// const x = E.x - B.x;
|
12122
|
+
// reqAns = Math.sqrt(x * x + y * y);
|
12123
|
+
// } else if (AB_AE < 0) {
|
12124
|
+
// const y = E.y - A.y;
|
12125
|
+
// const x = E.x - A.x;
|
12126
|
+
// reqAns = Math.sqrt(x * x + y * y);
|
12127
|
+
// } else {
|
12128
|
+
// const x1 = AB.x;
|
12129
|
+
// const y1 = AB.y;
|
12130
|
+
// const x2 = AE.x;
|
12131
|
+
// const y2 = AE.y;
|
12132
|
+
// const mod = Math.sqrt(x1 * x1 + y1 * y1);
|
12133
|
+
// reqAns = Math.abs(x1 * y2 - y1 * x2) / mod;
|
12134
|
+
// }
|
12135
|
+
// return reqAns;
|
12136
|
+
// }
|
12131
12137
|
/**
|
12132
12138
|
* 获取父级层级渲染对象
|
12133
12139
|
* @param render
|
@@ -14115,7 +14121,6 @@ class DynamicExecute {
|
|
14115
14121
|
if (this.depItems && this.depItems.has(id)) {
|
14116
14122
|
return this.depItems.get(id);
|
14117
14123
|
}
|
14118
|
-
new DocumentContext(this.doc, this.ss);
|
14119
14124
|
if (id.startsWith('$')) {
|
14120
14125
|
id = id.slice(1);
|
14121
14126
|
}
|
@@ -17584,6 +17589,9 @@ class DocumentChange {
|
|
17584
17589
|
});
|
17585
17590
|
}
|
17586
17591
|
newInput(data) {
|
17592
|
+
if (data.data === '啊' || data.data === 'a') {
|
17593
|
+
debugger;
|
17594
|
+
}
|
17587
17595
|
const { startControl, startOffset, collapsed } = this.selectionState;
|
17588
17596
|
const enableTrackChanges = this.viewOptions.enableTrackChanges;
|
17589
17597
|
if (!collapsed) {
|
@@ -21674,8 +21682,12 @@ class DocEditor {
|
|
21674
21682
|
// }
|
21675
21683
|
this.flushTask = () => {
|
21676
21684
|
//读取变更记录,可能会同步影响文档内容
|
21677
|
-
this.readDocChangeLog();
|
21685
|
+
const isChanged = this.readDocChangeLog();
|
21678
21686
|
this.refreshDocument();
|
21687
|
+
//触发文档改变
|
21688
|
+
if (isChanged) {
|
21689
|
+
this.triggerDocChange();
|
21690
|
+
}
|
21679
21691
|
this.flushTask = null;
|
21680
21692
|
//回调
|
21681
21693
|
// let cbs = [...this.docCtx.nextViewFns];
|
@@ -21776,14 +21788,15 @@ class DocEditor {
|
|
21776
21788
|
* @private
|
21777
21789
|
*/
|
21778
21790
|
updateInputFont() {
|
21779
|
-
const { startControl } = this.selectionState;
|
21791
|
+
const { startControl, startOffset } = this.selectionState;
|
21780
21792
|
if (startControl instanceof TextGroupElement) {
|
21781
21793
|
this.viewOptions.currentFontSize = startControl.props.fontSize;
|
21782
21794
|
this.viewOptions.currentFontName = startControl.props.fontName;
|
21783
21795
|
}
|
21784
21796
|
else {
|
21785
|
-
|
21786
|
-
this.viewOptions.
|
21797
|
+
const inputTextProps = this.documentChange.getDefaultTextProps(startControl, startOffset);
|
21798
|
+
this.viewOptions.currentFontSize = inputTextProps.fontSize;
|
21799
|
+
this.viewOptions.currentFontName = inputTextProps.fontName;
|
21787
21800
|
}
|
21788
21801
|
}
|
21789
21802
|
hitInfoChanged(hitInfo) {
|
@@ -23005,7 +23018,7 @@ class DocEditor {
|
|
23005
23018
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
23006
23019
|
}
|
23007
23020
|
version() {
|
23008
|
-
return "2.2.
|
23021
|
+
return "2.2.24";
|
23009
23022
|
}
|
23010
23023
|
switchPageHeaderEditor() {
|
23011
23024
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|
@@ -23085,6 +23098,10 @@ class DocEditor {
|
|
23085
23098
|
])
|
23086
23099
|
]);
|
23087
23100
|
}
|
23101
|
+
/**
|
23102
|
+
* 读取操作日志,并返回是否修改的标志
|
23103
|
+
* @returns
|
23104
|
+
*/
|
23088
23105
|
readDocChangeLog() {
|
23089
23106
|
//获取文档的变更日志
|
23090
23107
|
const ops = generatePatch(this.docCtx.document, false);
|
@@ -23123,9 +23140,10 @@ class DocEditor {
|
|
23123
23140
|
else {
|
23124
23141
|
this.docCtx.suggestions.clear();
|
23125
23142
|
}
|
23126
|
-
|
23127
|
-
|
23128
|
-
|
23143
|
+
return ops.length;
|
23144
|
+
// if (ops.length) {
|
23145
|
+
// this.triggerDocChange();
|
23146
|
+
// }
|
23129
23147
|
}
|
23130
23148
|
/**
|
23131
23149
|
* 处理候选词
|