@hailin-zheng/editor-core 2.2.22 → 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-cjs.js +88 -79
- package/index-cjs.js.map +1 -1
- package/index.js +88 -79
- package/index.js.map +1 -1
- package/med_editor/framework/util/element-util.d.ts +1 -12
- package/package.json +1 -1
package/index-cjs.js
CHANGED
@@ -12082,81 +12082,87 @@ class ElementUtil {
|
|
12082
12082
|
}
|
12083
12083
|
return true;
|
12084
12084
|
}
|
12085
|
-
|
12086
|
-
|
12087
|
-
|
12088
|
-
|
12089
|
-
|
12090
|
-
|
12091
|
-
|
12092
|
-
const lines = [];
|
12093
|
-
lines.push({
|
12094
|
-
f: {
|
12095
|
-
x: rect.x,
|
12096
|
-
y: rect.y
|
12097
|
-
},
|
12098
|
-
s: {
|
12099
|
-
x: rect.x + rect.width,
|
12100
|
-
y: rect.y
|
12101
|
-
}
|
12102
|
-
}, {
|
12103
|
-
f: {
|
12104
|
-
x: rect.x,
|
12105
|
-
y: rect.y
|
12106
|
-
},
|
12107
|
-
s: {
|
12108
|
-
x: rect.x,
|
12109
|
-
y: rect.y + rect.height
|
12110
|
-
}
|
12111
|
-
}, {
|
12112
|
-
f: {
|
12113
|
-
x: rect.x,
|
12114
|
-
y: rect.y + rect.height
|
12115
|
-
},
|
12116
|
-
s: {
|
12117
|
-
x: rect.x + rect.width,
|
12118
|
-
y: rect.y + rect.height
|
12119
|
-
}
|
12120
|
-
}, {
|
12121
|
-
f: {
|
12122
|
-
x: rect.x + rect.width,
|
12123
|
-
y: rect.y
|
12124
|
-
},
|
12125
|
-
s: {
|
12126
|
-
x: rect.x + rect.width,
|
12127
|
-
y: rect.y + rect.height
|
12128
|
-
}
|
12129
|
-
});
|
12130
|
-
const distances = lines.map(item => this.minDistance(item.f, item.s, p));
|
12131
|
-
return Math.min(...distances);
|
12132
|
-
}
|
12133
|
-
static minDistance(A, B, E) {
|
12134
|
-
const AB = { x: B.x - A.x, y: B.y - A.y };
|
12135
|
-
const BE = { x: E.x - B.x, y: E.y - B.y };
|
12136
|
-
const AE = { x: E.x - A.x, y: E.y - A.y };
|
12137
|
-
const AB_BE = (AB.x * BE.x + AB.y * BE.y);
|
12138
|
-
const AB_AE = (AB.x * AE.x + AB.y * AE.y);
|
12139
|
-
let reqAns = 0;
|
12140
|
-
if (AB_BE > 0) {
|
12141
|
-
const y = E.y - B.y;
|
12142
|
-
const x = E.x - B.x;
|
12143
|
-
reqAns = Math.sqrt(x * x + y * y);
|
12144
|
-
}
|
12145
|
-
else if (AB_AE < 0) {
|
12146
|
-
const y = E.y - A.y;
|
12147
|
-
const x = E.x - A.x;
|
12148
|
-
reqAns = Math.sqrt(x * x + y * y);
|
12149
|
-
}
|
12150
|
-
else {
|
12151
|
-
const x1 = AB.x;
|
12152
|
-
const y1 = AB.y;
|
12153
|
-
const x2 = AE.x;
|
12154
|
-
const y2 = AE.y;
|
12155
|
-
const mod = Math.sqrt(x1 * x1 + y1 * y1);
|
12156
|
-
reqAns = Math.abs(x1 * y2 - y1 * x2) / mod;
|
12157
|
-
}
|
12158
|
-
return reqAns;
|
12085
|
+
static getDistanceToRect(rect, point) {
|
12086
|
+
// 点到矩形左边的距离
|
12087
|
+
const dx = Math.max(rect.x - point.x, 0, point.x - (rect.x + rect.width));
|
12088
|
+
// 点到矩形上边的距离
|
12089
|
+
const dy = Math.max(rect.y - point.y, 0, point.y - (rect.y + rect.height));
|
12090
|
+
// 距离公式
|
12091
|
+
return Math.sqrt(dx * dx + dy * dy);
|
12159
12092
|
}
|
12093
|
+
// /**
|
12094
|
+
// * 获取一个点到一个矩形最短的距离
|
12095
|
+
// * @param rect
|
12096
|
+
// * @param p
|
12097
|
+
// * @returns
|
12098
|
+
// */
|
12099
|
+
// static getDistanceToRect(rect: Rect, p: Position) {
|
12100
|
+
// const lines: Array<{ f: PAIR, s: PAIR }> = [];
|
12101
|
+
// lines.push({
|
12102
|
+
// f: {
|
12103
|
+
// x: rect.x,
|
12104
|
+
// y: rect.y
|
12105
|
+
// },
|
12106
|
+
// s: {
|
12107
|
+
// x: rect.x + rect.width,
|
12108
|
+
// y: rect.y
|
12109
|
+
// }
|
12110
|
+
// }, {
|
12111
|
+
// f: {
|
12112
|
+
// x: rect.x,
|
12113
|
+
// y: rect.y
|
12114
|
+
// },
|
12115
|
+
// s: {
|
12116
|
+
// x: rect.x,
|
12117
|
+
// y: rect.y + rect.height
|
12118
|
+
// }
|
12119
|
+
// }, {
|
12120
|
+
// f: {
|
12121
|
+
// x: rect.x,
|
12122
|
+
// y: rect.y + rect.height
|
12123
|
+
// },
|
12124
|
+
// s: {
|
12125
|
+
// x: rect.x + rect.width,
|
12126
|
+
// y: rect.y + rect.height
|
12127
|
+
// }
|
12128
|
+
// }, {
|
12129
|
+
// f: {
|
12130
|
+
// x: rect.x + rect.width,
|
12131
|
+
// y: rect.y
|
12132
|
+
// },
|
12133
|
+
// s: {
|
12134
|
+
// x: rect.x + rect.width,
|
12135
|
+
// y: rect.y + rect.height
|
12136
|
+
// }
|
12137
|
+
// })
|
12138
|
+
// const distances = lines.map(item => this.minDistance(item.f, item.s, p))
|
12139
|
+
// return Math.min(...distances);
|
12140
|
+
// }
|
12141
|
+
// static minDistance(A: PAIR, B: PAIR, E: PAIR) {
|
12142
|
+
// const AB: PAIR = { x: B.x - A.x, y: B.y - A.y }
|
12143
|
+
// const BE: PAIR = { x: E.x - B.x, y: E.y - B.y };
|
12144
|
+
// const AE: PAIR = { x: E.x - A.x, y: E.y - A.y }
|
12145
|
+
// const AB_BE = (AB.x * BE.x + AB.y * BE.y);
|
12146
|
+
// const AB_AE = (AB.x * AE.x + AB.y * AE.y);
|
12147
|
+
// let reqAns = 0;
|
12148
|
+
// if (AB_BE > 0) {
|
12149
|
+
// const y = E.y - B.y;
|
12150
|
+
// const x = E.x - B.x;
|
12151
|
+
// reqAns = Math.sqrt(x * x + y * y);
|
12152
|
+
// } else if (AB_AE < 0) {
|
12153
|
+
// const y = E.y - A.y;
|
12154
|
+
// const x = E.x - A.x;
|
12155
|
+
// reqAns = Math.sqrt(x * x + y * y);
|
12156
|
+
// } else {
|
12157
|
+
// const x1 = AB.x;
|
12158
|
+
// const y1 = AB.y;
|
12159
|
+
// const x2 = AE.x;
|
12160
|
+
// const y2 = AE.y;
|
12161
|
+
// const mod = Math.sqrt(x1 * x1 + y1 * y1);
|
12162
|
+
// reqAns = Math.abs(x1 * y2 - y1 * x2) / mod;
|
12163
|
+
// }
|
12164
|
+
// return reqAns;
|
12165
|
+
// }
|
12160
12166
|
/**
|
12161
12167
|
* 获取父级层级渲染对象
|
12162
12168
|
* @param render
|
@@ -14144,7 +14150,6 @@ class DynamicExecute {
|
|
14144
14150
|
if (this.depItems && this.depItems.has(id)) {
|
14145
14151
|
return this.depItems.get(id);
|
14146
14152
|
}
|
14147
|
-
new DocumentContext(this.doc, this.ss);
|
14148
14153
|
if (id.startsWith('$')) {
|
14149
14154
|
id = id.slice(1);
|
14150
14155
|
}
|
@@ -17613,6 +17618,9 @@ class DocumentChange {
|
|
17613
17618
|
});
|
17614
17619
|
}
|
17615
17620
|
newInput(data) {
|
17621
|
+
if (data.data === '啊' || data.data === 'a') {
|
17622
|
+
debugger;
|
17623
|
+
}
|
17616
17624
|
const { startControl, startOffset, collapsed } = this.selectionState;
|
17617
17625
|
const enableTrackChanges = this.viewOptions.enableTrackChanges;
|
17618
17626
|
if (!collapsed) {
|
@@ -21805,14 +21813,15 @@ class DocEditor {
|
|
21805
21813
|
* @private
|
21806
21814
|
*/
|
21807
21815
|
updateInputFont() {
|
21808
|
-
const { startControl } = this.selectionState;
|
21816
|
+
const { startControl, startOffset } = this.selectionState;
|
21809
21817
|
if (startControl instanceof TextGroupElement) {
|
21810
21818
|
this.viewOptions.currentFontSize = startControl.props.fontSize;
|
21811
21819
|
this.viewOptions.currentFontName = startControl.props.fontName;
|
21812
21820
|
}
|
21813
21821
|
else {
|
21814
|
-
|
21815
|
-
this.viewOptions.
|
21822
|
+
const inputTextProps = this.documentChange.getDefaultTextProps(startControl, startOffset);
|
21823
|
+
this.viewOptions.currentFontSize = inputTextProps.fontSize;
|
21824
|
+
this.viewOptions.currentFontName = inputTextProps.fontName;
|
21816
21825
|
}
|
21817
21826
|
}
|
21818
21827
|
hitInfoChanged(hitInfo) {
|
@@ -23034,7 +23043,7 @@ class DocEditor {
|
|
23034
23043
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
23035
23044
|
}
|
23036
23045
|
version() {
|
23037
|
-
return "2.2.
|
23046
|
+
return "2.2.23";
|
23038
23047
|
}
|
23039
23048
|
switchPageHeaderEditor() {
|
23040
23049
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|