diff --git a/assets/webui/ofdgo_edit.js b/assets/webui/ofdgo_edit.js index 650ed2a..3656d93 100644 --- a/assets/webui/ofdgo_edit.js +++ b/assets/webui/ofdgo_edit.js @@ -968,16 +968,17 @@ export class CanvasEditor { width: `${item.width * change.scale * PX_PER_MM}px`, height: `${item.height * change.scale * PX_PER_MM}px`, }); if (item.contour) item.contour.svg.setAttribute("viewBox", `${item.x} ${item.y} ${item.width} ${item.height}`); - if (item.textFrame) { - const [a, b, c, d, e, f] = item.textFrame.matrix; - const box = textFrameBox(item); - for (const handle of item.node.children) { - if (handle.dataset.corner !== "w" && handle.dataset.corner !== "e") continue; - const x = box.x + (handle.dataset.corner === "e" ? box.width : 0), y = box.y + box.height / 2; - handle.style.left = `${(a * x + c * y + e - item.x) * change.scale * PX_PER_MM}px`; - handle.style.top = `${(b * x + d * y + f - item.y) * change.scale * PX_PER_MM}px`; - handle.style.cursor = a === 0 ? "var(--resize-vertical, ns-resize)" : "var(--resize-horizontal, ew-resize)"; - } + if (item.textFrame) this.placeTextHandles(item, textFrameBox(item), item, change.scale); + } + + placeTextHandles(item, box, bounds, scale = 1) { + const [a, b, c, d, e, f] = item.textFrame.matrix; + for (const handle of item.node.children) { + if (handle.dataset.corner !== "w" && handle.dataset.corner !== "e") continue; + const x = box.x + (handle.dataset.corner === "e" ? box.width : 0), y = box.y + box.height / 2; + handle.style.left = `${(a * x + c * y + e - bounds.x) * scale * PX_PER_MM}px`; + handle.style.top = `${(b * x + d * y + f - bounds.y) * scale * PX_PER_MM}px`; + handle.style.cursor = a === 0 ? "var(--resize-vertical, ns-resize)" : "var(--resize-horizontal, ew-resize)"; } } @@ -1066,7 +1067,7 @@ export class CanvasEditor { const handles = !canEditObject(item, "transform") ? [] : lineShape(item.shape) ? ["start", "end"] : item.shape || item.oriented || canEditObject(item, "stretch") ? ["nw", "n", "ne", "e", "se", "s", "sw", "w"] : item.type === "TextObject" && canEditObject(item, "reflow") && canEditObject(item, "layoutKnown") - ? ["w", "e"] : ["nw", "ne", "sw", "se"]; + ? ["nw", "ne", "sw", "se", "w", "e"] : ["nw", "ne", "sw", "se"]; for (const corner of handles) { const handle = document.createElement("span"); handle.className = `edit-handle edit-${corner}`; @@ -1303,6 +1304,7 @@ export class CanvasEditor { const bounds = transformedBox(box, frame.matrix); Object.assign(drag.item.node.style, { left: `${bounds.x * PX_PER_MM}px`, top: `${bounds.y * PX_PER_MM}px`, width: `${bounds.width * PX_PER_MM}px`, height: `${bounds.height * PX_PER_MM}px` }); + this.placeTextHandles(drag.item, box, bounds); return; } drag.box = reshapeBox({ geometry: drag.item }, to.x - from.x, 0, drag.corner, false); diff --git a/ofdgo_editor_composite_text.go b/ofdgo_editor_composite_text.go index 442e741..705b77c 100644 --- a/ofdgo_editor_composite_text.go +++ b/ofdgo_editor_composite_text.go @@ -20,7 +20,7 @@ import ( "strconv" ) -// UpdateCompositeText 修改内部文字,原文保留定位,已知段落按会话选项重排 +// UpdateCompositeText 修改内部文字,原文保留定位,已知段落按排版选项重排 // 空样式保留原字体、字号和颜色,显式改变字号时重新排版并保留首行基线 // 方向和字形映射沿用RewriteText的定位校验,不改变原文中未修改的属性 // 入参: page 页面索引, path 父复合路径, index 成员序号, value 文字, style 文字样式增量 @@ -29,7 +29,7 @@ func (e *Editor) UpdateCompositeText(page int, path ObjectPath, index int, value return e.changeCompositeText(page, path, []int{index}, &value, style, nil, nil) } -// StyleCompositeText 批量修改内部文字字体、字号或颜色,换字体保留原文字定位 +// StyleCompositeText 批量修改内部文字字体、字号或颜色,已知段落重排,原文保留定位 // 更换字体时同步字形索引,无法逐字映射时需显式重排,缺字使整批操作失败 // 入参: page 页面索引, path 父复合路径, indexes 成员序号, style 文字样式增量 // 返回: error 错误信息 @@ -129,7 +129,7 @@ func (e *Editor) updateCompositeText(node *editorCompositeNode, member Composite } object.TextObject.TextCode = text.TextCode object.TextObject.CGTransform = text.CGTransform - } else if options != nil || content != original || style.Size != 0 && style.Size != text.Size || state.layout != nil && state.layout.options.Shape && style.Font != "" && style.Font != object.TextObject.Font { + } else if options != nil || content != original || style.Size != 0 && style.Size != text.Size || state.layout != nil && style.Font != "" && style.Font != object.TextObject.Font { if style.Size != 0 { text.Size = style.Size }