@hailin-zheng/editor-core 2.2.21 → 2.2.23
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.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
|
@@ -14101,10 +14107,10 @@ class DynamicExecute {
|
|
14101
14107
|
this.depItems = undefined;
|
14102
14108
|
}
|
14103
14109
|
cacheList;
|
14104
|
-
getControlById(id) {
|
14110
|
+
getControlById(id, options) {
|
14105
14111
|
if (!this.cacheList) {
|
14106
14112
|
const ctx = new DocumentContext(this.doc, this.ss);
|
14107
|
-
this.cacheList = ctx.getDataElementModelList();
|
14113
|
+
this.cacheList = ctx.getDataElementModelList(options);
|
14108
14114
|
}
|
14109
14115
|
const f = this.cacheList.find(item => item.id === id);
|
14110
14116
|
return f;
|
@@ -14115,11 +14121,10 @@ 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
|
}
|
14122
|
-
const control = this.getControlById(id);
|
14127
|
+
const control = this.getControlById(id, { includeChildren: true });
|
14123
14128
|
return {
|
14124
14129
|
get value() {
|
14125
14130
|
if (control) {
|
@@ -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) {
|
@@ -21776,14 +21784,15 @@ class DocEditor {
|
|
21776
21784
|
* @private
|
21777
21785
|
*/
|
21778
21786
|
updateInputFont() {
|
21779
|
-
const { startControl } = this.selectionState;
|
21787
|
+
const { startControl, startOffset } = this.selectionState;
|
21780
21788
|
if (startControl instanceof TextGroupElement) {
|
21781
21789
|
this.viewOptions.currentFontSize = startControl.props.fontSize;
|
21782
21790
|
this.viewOptions.currentFontName = startControl.props.fontName;
|
21783
21791
|
}
|
21784
21792
|
else {
|
21785
|
-
|
21786
|
-
this.viewOptions.
|
21793
|
+
const inputTextProps = this.documentChange.getDefaultTextProps(startControl, startOffset);
|
21794
|
+
this.viewOptions.currentFontSize = inputTextProps.fontSize;
|
21795
|
+
this.viewOptions.currentFontName = inputTextProps.fontName;
|
21787
21796
|
}
|
21788
21797
|
}
|
21789
21798
|
hitInfoChanged(hitInfo) {
|
@@ -23005,7 +23014,7 @@ class DocEditor {
|
|
23005
23014
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
23006
23015
|
}
|
23007
23016
|
version() {
|
23008
|
-
return "2.2.
|
23017
|
+
return "2.2.23";
|
23009
23018
|
}
|
23010
23019
|
switchPageHeaderEditor() {
|
23011
23020
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|