@flexem/fc-gui 3.0.0-alpha.144 → 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.
|
@@ -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) {
|