fix(编辑能力): 修正文本框自适应与对齐
build.yaml / build (push) Successful in 45s

This commit is contained in:
xiaoqidun committed 2026-10-27 23:45:29 +08:00
1 parent d384527371
commit 7e3f2c468a
6 files changed
+59 -9

No files matched your search

+10
View File
@@ -134,6 +134,9 @@ func (e *Editor) updateRichTextFrame(page int, id string, value RichText, offset
if err := value.Validate(); err != nil {
return err
}
if width > 0 {
value.AutoWidth = false
}
if old.Type == "CompositeObject" && offset == 0 && (width == 0 || width == frame.W) && reflect.DeepEqual(normalizeRichText(current), normalizeRichText(value)) {
return nil
}
@@ -356,6 +359,9 @@ func (e *Editor) updateCompositeRichText(page int, path ObjectPath, index int, v
if err := value.Validate(); err != nil {
return err
}
if width > 0 {
value.AutoWidth = false
}
if offset == 0 && (width == 0 || width == frame.W) && reflect.DeepEqual(normalizeRichText(current), normalizeRichText(value)) {
return nil
}
@@ -460,6 +466,10 @@ func (e *Editor) prepareRichText(box Box, value RichText) (GraphicObject, richTe
if err != nil {
return GraphicObject{}, richTextMetadata{}, err
}
box.W = result.width
if value.AutoWidth && !value.Layout.Wrap {
box.H = result.bounds.Y + result.bounds.H
}
padX, padY := -min(0, result.bounds.X), -min(0, result.bounds.Y)
extent := Box{W: max(box.W, result.bounds.X+result.bounds.W) + padX, H: max(box.H, result.bounds.Y+result.bounds.H) + padY}
if !finite(extent.W) || !finite(extent.H) || extent.W <= 0 || extent.H <= 0 {