@hailin-zheng/editor-core 2.1.21 → 2.1.22
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 +23 -9
- package/index-cjs.js.map +1 -1
- package/index.js +23 -9
- package/index.js.map +1 -1
- package/med_editor/framework/render-context.d.ts +2 -0
- package/package.json +1 -1
package/index.js
CHANGED
@@ -631,7 +631,6 @@ class CommonUtil {
|
|
631
631
|
static cloneValue(val) {
|
632
632
|
return CommonUtil.cloneDeep(val);
|
633
633
|
}
|
634
|
-
// @ts-ignore
|
635
634
|
static cloneDeep(source, visited = new WeakMap()) {
|
636
635
|
if (source === null || typeof source !== 'object') {
|
637
636
|
// 如果是基本类型或 null,则直接返回
|
@@ -4854,6 +4853,8 @@ class TextGroupRenderObject extends LeafRenderObject {
|
|
4854
4853
|
return;
|
4855
4854
|
}
|
4856
4855
|
const props = this.element.props;
|
4856
|
+
//基线位置到top的距离
|
4857
|
+
const actualFontBoundingBoxAscent = event.renderCtx.mainContext.getActualFontBoundingBoxAscent(props.getFont());
|
4857
4858
|
let { width, height } = this.rect;
|
4858
4859
|
let vertHeight = 0; //baseLine;
|
4859
4860
|
if (props.vertAlign === 'subscript') {
|
@@ -4872,10 +4873,11 @@ class TextGroupRenderObject extends LeafRenderObject {
|
|
4872
4873
|
return curr.actualSize + prev;
|
4873
4874
|
}, this.rect.x);
|
4874
4875
|
const x = arr.join(' ');
|
4875
|
-
|
4876
|
-
|
4877
|
-
|
4878
|
-
|
4876
|
+
let y = this.rect.y + vertHeight;
|
4877
|
+
//基线处理
|
4878
|
+
y += actualFontBoundingBoxAscent ?? 0;
|
4879
|
+
//行高处理
|
4880
|
+
y += (height - props.fontSize) / 2;
|
4879
4881
|
const t = {
|
4880
4882
|
sel: 'text',
|
4881
4883
|
text: text,
|
@@ -4883,8 +4885,6 @@ class TextGroupRenderObject extends LeafRenderObject {
|
|
4883
4885
|
ns: "http://www.w3.org/2000/svg",
|
4884
4886
|
attrs: {
|
4885
4887
|
//"transform": `translate(0,${(height - props.fontSize) / 2})`,
|
4886
|
-
"translate": { x: 0, y: (height - props.fontSize) / 2 },
|
4887
|
-
'dominant-baseline': 'hanging',
|
4888
4888
|
'font-family': this.element.props.fontName,
|
4889
4889
|
'font-size': fontSize,
|
4890
4890
|
x,
|
@@ -4892,6 +4892,9 @@ class TextGroupRenderObject extends LeafRenderObject {
|
|
4892
4892
|
}
|
4893
4893
|
},
|
4894
4894
|
};
|
4895
|
+
if (actualFontBoundingBoxAscent === undefined) {
|
4896
|
+
t.data.attrs['dominant-baseline'] = 'hanging';
|
4897
|
+
}
|
4895
4898
|
if (this.element.props.fontWeight !== 'normal') {
|
4896
4899
|
t.data.attrs['font-weight'] = this.element.props.fontWeight;
|
4897
4900
|
}
|
@@ -12839,7 +12842,18 @@ class PaintContent {
|
|
12839
12842
|
this.init();
|
12840
12843
|
}
|
12841
12844
|
init() {
|
12842
|
-
this.ctx.textBaseline = 'top';
|
12845
|
+
//this.ctx.textBaseline = 'top';
|
12846
|
+
}
|
12847
|
+
cacheFontBoundingBoxAscentMap = new Map();
|
12848
|
+
getActualFontBoundingBoxAscent(font) {
|
12849
|
+
if (this.cacheFontBoundingBoxAscentMap.has(font)) {
|
12850
|
+
return this.cacheFontBoundingBoxAscentMap.get(font);
|
12851
|
+
}
|
12852
|
+
this.ctx.font = font;
|
12853
|
+
const textMetrics = this.ctx.measureText('正');
|
12854
|
+
const value = textMetrics.actualBoundingBoxAscent;
|
12855
|
+
this.cacheFontBoundingBoxAscentMap.set(font, value);
|
12856
|
+
return value;
|
12843
12857
|
}
|
12844
12858
|
setGlobalAlpha(alpha) {
|
12845
12859
|
this.ctx.globalAlpha = alpha;
|
@@ -27806,7 +27820,7 @@ class DocEditor {
|
|
27806
27820
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
27807
27821
|
}
|
27808
27822
|
version() {
|
27809
|
-
return "2.1.
|
27823
|
+
return "2.1.22";
|
27810
27824
|
}
|
27811
27825
|
switchPageHeaderEditor() {
|
27812
27826
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|