@flexem/fc-gui 3.0.0-alpha.143 → 3.0.0-alpha.145
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 +19 -10
- 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.js +15 -7
- package/elements/view-operation/view-operation.element.js +3 -2
- package/package.json +1 -1
|
@@ -35836,7 +35836,7 @@ class text_element_TextElementModal {
|
|
|
35836
35836
|
const minFontSize = 12;
|
|
35837
35837
|
lineHeight = parseInt(font.fontSize, 10) + 5;
|
|
35838
35838
|
fontString += font.fontSize + '/' + lineHeight.toString() + 'px ' + font.fontFamily;
|
|
35839
|
-
textDiv.style.cssText = `color: ${font.color};word-break: break-all;font: ${fontString};`;
|
|
35839
|
+
textDiv.style.cssText = `color: ${font.color};word-break: break-all;font: ${fontString};text-align: ${textAlign};`;
|
|
35840
35840
|
if (font.isUnderline) {
|
|
35841
35841
|
textDiv.style.textDecoration = 'underline';
|
|
35842
35842
|
}
|
|
@@ -39306,8 +39306,6 @@ class text_state_element_TextStateElement {
|
|
|
39306
39306
|
return;
|
|
39307
39307
|
}
|
|
39308
39308
|
const textElement = this.getforeignObjectElement();
|
|
39309
|
-
// 清空旧内容
|
|
39310
|
-
textElement.textContent = '';
|
|
39311
39309
|
// 设置 text-anchor 和 dominant-baseline
|
|
39312
39310
|
textElement.setAttribute('text-anchor', 'middle');
|
|
39313
39311
|
textElement.setAttribute('dominant-baseline', 'middle');
|
|
@@ -39320,9 +39318,15 @@ class text_state_element_TextStateElement {
|
|
|
39320
39318
|
const totalHeight = lines.length * lineHeight;
|
|
39321
39319
|
// 调整文本整体垂直居中(通过 dy)
|
|
39322
39320
|
const startY = (this.height / 2) - (totalHeight / 2) + (lineHeight / 2);
|
|
39323
|
-
//
|
|
39321
|
+
// 复用已有 tspan,不足则新建,多余则隐藏——避免删除 touch 目标节点导致 touchend 丢失
|
|
39322
|
+
const existingTspans = Array.from(textElement.children);
|
|
39324
39323
|
for (let i = 0; i < lines.length; i++) {
|
|
39325
|
-
|
|
39324
|
+
let tspan = existingTspans[i];
|
|
39325
|
+
if (!tspan) {
|
|
39326
|
+
tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');
|
|
39327
|
+
textElement.appendChild(tspan);
|
|
39328
|
+
}
|
|
39329
|
+
tspan.setAttribute('display', 'inline');
|
|
39326
39330
|
tspan.setAttribute('x', (this.width / 2).toString());
|
|
39327
39331
|
tspan.setAttribute('y', startY + i * lineHeight + 'px');
|
|
39328
39332
|
tspan.textContent = lines[i].replace(/ /g, '\u00A0');
|
|
@@ -39334,7 +39338,10 @@ class text_state_element_TextStateElement {
|
|
|
39334
39338
|
tspan.setAttribute('text-decoration', font.isUnderline ? 'underline' : 'none');
|
|
39335
39339
|
tspan.setAttribute('text-anchor', 'middle');
|
|
39336
39340
|
tspan.setAttribute('dominant-baseline', 'middle');
|
|
39337
|
-
|
|
39341
|
+
}
|
|
39342
|
+
// 隐藏多余的 tspan(不删除)
|
|
39343
|
+
for (let i = lines.length; i < existingTspans.length; i++) {
|
|
39344
|
+
existingTspans[i].setAttribute('display', 'none');
|
|
39338
39345
|
}
|
|
39339
39346
|
this.doFaultFlicker(textElement, stateId);
|
|
39340
39347
|
}
|
|
@@ -39377,12 +39384,13 @@ class text_state_element_TextStateElement {
|
|
|
39377
39384
|
this.textElement.setAttribute('pointer-events', 'auto'); // 确保能接收事件
|
|
39378
39385
|
this._element.appendChild(this.textElement);
|
|
39379
39386
|
}
|
|
39387
|
+
this.textElement.setAttribute('display', 'block');
|
|
39380
39388
|
return this.textElement;
|
|
39381
39389
|
}
|
|
39382
39390
|
removeForeignObjectlement() {
|
|
39383
39391
|
if (this.textElement) {
|
|
39384
|
-
this.
|
|
39385
|
-
|
|
39392
|
+
this.textElement.setAttribute('display', 'none');
|
|
39393
|
+
this.textElement.textContent = '';
|
|
39386
39394
|
}
|
|
39387
39395
|
}
|
|
39388
39396
|
doFaultFlicker(textElement, stateId) {
|
|
@@ -40543,10 +40551,11 @@ class view_operation_element_ViewOperationElement extends conditional_enable_ele
|
|
|
40543
40551
|
initElement() {
|
|
40544
40552
|
const width = this.model.size.width;
|
|
40545
40553
|
const height = this.model.size.height;
|
|
40554
|
+
// 在 initGraph 之前移除模板原有的 SVG <text>(改用 foreignObject 渲染,支持换行居中)
|
|
40555
|
+
// 必须在 initGraph 前执行,否则会误删图形状态内部后续添加的文字节点
|
|
40556
|
+
this.$element.find('text').remove();
|
|
40546
40557
|
this.initGraph(width, height);
|
|
40547
40558
|
this.rootElement.append('rect').attr('id', 'StateFrame').attr('width', width).attr('height', height).attr('fill', 'transparent');
|
|
40548
|
-
// 移除模板中原有的 SVG <text> 元素,改用 TextElementModal(foreignObject)渲染,支持换行
|
|
40549
|
-
this.$element.find('text').last().remove();
|
|
40550
40559
|
const font = Object.assign(Object.assign({}, this.model.label.font), { fontFamily: this.model.label.font.fontFamily || 'msyh' });
|
|
40551
40560
|
this.textElementModal = new text_element_TextElementModal(this.getDisplayText(), font, width, height);
|
|
40552
40561
|
this.$element.append(this.textElementModal.Element);
|