@flexem/fc-gui 3.0.0-alpha.163 → 3.0.0-alpha.164
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/bundles/@flexem/fc-gui.umd.js +44 -14
- package/bundles/@flexem/fc-gui.umd.js.map +1 -1
- package/bundles/@flexem/fc-gui.umd.min.js +1 -1
- package/bundles/@flexem/fc-gui.umd.min.js.map +1 -1
- package/elements/shared/text/text-element.js +1 -1
- package/elements/shared/text/text-state-element.d.ts +2 -0
- package/elements/shared/text/text-state-element.js +33 -8
- package/elements/view-operation/view-operation.element.js +10 -5
- package/model/shared/text/font.d.ts +1 -1
- package/package.json +1 -1
|
@@ -35877,7 +35877,7 @@ class text_element_TextElementModal {
|
|
|
35877
35877
|
lineHeight = parseInt(font.fontSize, 10) + 5;
|
|
35878
35878
|
fontString += font.fontSize + '/' + lineHeight.toString() + 'px ' + font.fontFamily;
|
|
35879
35879
|
textDiv.style.cssText = `color: ${font.color};word-break: break-all;font: ${fontString};text-align: ${textAlign};`;
|
|
35880
|
-
if (font.isUnderline) {
|
|
35880
|
+
if (font.isUnderline && content.length > 0) {
|
|
35881
35881
|
textDiv.style.textDecoration = 'underline';
|
|
35882
35882
|
}
|
|
35883
35883
|
const spanText = document.createElement('span');
|
|
@@ -39708,10 +39708,23 @@ class text_state_element_TextStateElement {
|
|
|
39708
39708
|
return;
|
|
39709
39709
|
}
|
|
39710
39710
|
const textElement = this.getforeignObjectElement();
|
|
39711
|
-
// 设置 text-anchor 和 dominant-baseline
|
|
39712
|
-
textElement.setAttribute('text-anchor', 'middle');
|
|
39713
|
-
textElement.setAttribute('dominant-baseline', 'middle');
|
|
39714
39711
|
textElement.setAttribute('pointer-events', 'auto');
|
|
39712
|
+
// 根据 textAlign 计算 SVG text-anchor 和 x 坐标
|
|
39713
|
+
const textAlign = font.textAlign || 'center';
|
|
39714
|
+
let textAnchor;
|
|
39715
|
+
let anchorX;
|
|
39716
|
+
if (textAlign === 'left') {
|
|
39717
|
+
textAnchor = 'start';
|
|
39718
|
+
anchorX = 0;
|
|
39719
|
+
}
|
|
39720
|
+
else if (textAlign === 'right') {
|
|
39721
|
+
textAnchor = 'end';
|
|
39722
|
+
anchorX = this.width;
|
|
39723
|
+
}
|
|
39724
|
+
else {
|
|
39725
|
+
textAnchor = 'middle';
|
|
39726
|
+
anchorX = this.width / 2;
|
|
39727
|
+
}
|
|
39715
39728
|
// 拆分换行
|
|
39716
39729
|
const lines = content.split('\n');
|
|
39717
39730
|
const fontSize = parseInt(font.fontSize, 10);
|
|
@@ -39729,16 +39742,16 @@ class text_state_element_TextStateElement {
|
|
|
39729
39742
|
textElement.appendChild(tspan);
|
|
39730
39743
|
}
|
|
39731
39744
|
tspan.setAttribute('display', 'inline');
|
|
39732
|
-
tspan.setAttribute('x',
|
|
39745
|
+
tspan.setAttribute('x', anchorX.toString());
|
|
39733
39746
|
tspan.setAttribute('y', startY + i * lineHeight + 'px');
|
|
39734
|
-
tspan.textContent = lines[i].replace(/ /g, '
|
|
39747
|
+
tspan.textContent = lines[i].replace(/ /g, ' ');
|
|
39735
39748
|
tspan.setAttribute('font-size', font.fontSize);
|
|
39736
39749
|
tspan.setAttribute('fill', font.color);
|
|
39737
39750
|
tspan.setAttribute('font-family', font.fontFamily);
|
|
39738
39751
|
tspan.setAttribute('font-weight', font.isBold ? 'bold' : 'normal');
|
|
39739
39752
|
tspan.setAttribute('font-style', font.isItalic ? 'italic' : 'normal');
|
|
39740
39753
|
tspan.setAttribute('text-decoration', font.isUnderline ? 'underline' : 'none');
|
|
39741
|
-
tspan.setAttribute('text-anchor',
|
|
39754
|
+
tspan.setAttribute('text-anchor', textAnchor);
|
|
39742
39755
|
tspan.setAttribute('dominant-baseline', 'middle');
|
|
39743
39756
|
}
|
|
39744
39757
|
// 隐藏多余的 tspan(不删除)
|
|
@@ -39796,7 +39809,7 @@ class text_state_element_TextStateElement {
|
|
|
39796
39809
|
}
|
|
39797
39810
|
}
|
|
39798
39811
|
doFaultFlicker(textElement, stateId) {
|
|
39799
|
-
if (this.version > 3 && this.faultFlickers) {
|
|
39812
|
+
if (this.version != null && this.version > 3 && this.faultFlickers) {
|
|
39800
39813
|
this.clearFlickerInterval(textElement);
|
|
39801
39814
|
const faultFlicker = this.faultFlickers.find(t => t.id === stateId);
|
|
39802
39815
|
if (faultFlicker && faultFlicker.faultFlicker) {
|
|
@@ -39825,6 +39838,8 @@ class text_state_element_TextStateElement {
|
|
|
39825
39838
|
}
|
|
39826
39839
|
/**
|
|
39827
39840
|
* 获取指定状态在当前语种下的字体样式
|
|
39841
|
+
* fontStyleCultures 中保存的对象含 fontStyle 字符串但无 isBold/isItalic/fontFamily,
|
|
39842
|
+
* 此处从 fontStyle 解析这三个字段后返回
|
|
39828
39843
|
*/
|
|
39829
39844
|
getFontForState(stateId, defaultFont) {
|
|
39830
39845
|
if (!this.fontStyleCultures) {
|
|
@@ -39845,7 +39860,17 @@ class text_state_element_TextStateElement {
|
|
|
39845
39860
|
};
|
|
39846
39861
|
const targetLanguage = getTargetLanguage();
|
|
39847
39862
|
if (this.fontStyleCultures[stateKey][targetLanguage]) {
|
|
39848
|
-
|
|
39863
|
+
const culturedFont = this.fontStyleCultures[stateKey][targetLanguage];
|
|
39864
|
+
if (culturedFont.fontStyle) {
|
|
39865
|
+
const fs = culturedFont.fontStyle;
|
|
39866
|
+
const isBold = fs.indexOf('bold') !== -1;
|
|
39867
|
+
const isItalic = fs.indexOf('Italic') !== -1;
|
|
39868
|
+
const parts = fs.split(' ');
|
|
39869
|
+
const familyIndex = (isBold ? 1 : 0) + (isItalic ? 1 : 0) + 1;
|
|
39870
|
+
const fontFamily = parts.length > familyIndex ? parts[familyIndex] : null;
|
|
39871
|
+
return Object.assign(Object.assign({}, culturedFont), { isBold, isItalic, fontFamily });
|
|
39872
|
+
}
|
|
39873
|
+
return culturedFont;
|
|
39849
39874
|
}
|
|
39850
39875
|
return defaultFont;
|
|
39851
39876
|
}
|
|
@@ -41206,14 +41231,19 @@ class view_operation_element_ViewOperationElement extends conditional_enable_ele
|
|
|
41206
41231
|
const targetLanguage = getTargetLanguage();
|
|
41207
41232
|
if (this.model.fontStyleCultures && this.model.fontStyleCultures[targetLanguage]) {
|
|
41208
41233
|
const style = this.model.fontStyleCultures[targetLanguage];
|
|
41234
|
+
const fs = style.fontStyle || '';
|
|
41235
|
+
const isBold = fs.indexOf('bold') !== -1;
|
|
41236
|
+
const isItalic = fs.indexOf('Italic') !== -1;
|
|
41237
|
+
const parts = fs.split(' ');
|
|
41238
|
+
const familyIndex = (isBold ? 1 : 0) + (isItalic ? 1 : 0) + 1;
|
|
41239
|
+
const fontFamily = parts.length > familyIndex ? parts[familyIndex] : null;
|
|
41209
41240
|
return {
|
|
41210
41241
|
isUnderline: style.isUnderline,
|
|
41211
|
-
isBold
|
|
41212
|
-
isItalic
|
|
41242
|
+
isBold,
|
|
41243
|
+
isItalic,
|
|
41213
41244
|
fontSize: style.fontSize,
|
|
41214
|
-
fontFamily:
|
|
41215
|
-
color: style.color
|
|
41216
|
-
textAlign: style.textAlign
|
|
41245
|
+
fontFamily: fontFamily || 'msyh',
|
|
41246
|
+
color: style.color
|
|
41217
41247
|
};
|
|
41218
41248
|
}
|
|
41219
41249
|
return Object.assign(Object.assign({}, this.model.label.font), { fontFamily: this.model.label.font.fontFamily || 'msyh' });
|