mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 08:46:55 +08:00
1 parent
057bcba868
commit
e5658de69d
2 files changed
+16
-14
No files matched your search
+13
-11
@@ -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`,
|
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.contour) item.contour.svg.setAttribute("viewBox", `${item.x} ${item.y} ${item.width} ${item.height}`);
|
||||||
if (item.textFrame) {
|
if (item.textFrame) this.placeTextHandles(item, textFrameBox(item), item, change.scale);
|
||||||
const [a, b, c, d, e, f] = item.textFrame.matrix;
|
}
|
||||||
const box = textFrameBox(item);
|
|
||||||
for (const handle of item.node.children) {
|
placeTextHandles(item, box, bounds, scale = 1) {
|
||||||
if (handle.dataset.corner !== "w" && handle.dataset.corner !== "e") continue;
|
const [a, b, c, d, e, f] = item.textFrame.matrix;
|
||||||
const x = box.x + (handle.dataset.corner === "e" ? box.width : 0), y = box.y + box.height / 2;
|
for (const handle of item.node.children) {
|
||||||
handle.style.left = `${(a * x + c * y + e - item.x) * change.scale * PX_PER_MM}px`;
|
if (handle.dataset.corner !== "w" && handle.dataset.corner !== "e") continue;
|
||||||
handle.style.top = `${(b * x + d * y + f - item.y) * change.scale * PX_PER_MM}px`;
|
const x = box.x + (handle.dataset.corner === "e" ? box.width : 0), y = box.y + box.height / 2;
|
||||||
handle.style.cursor = a === 0 ? "var(--resize-vertical, ns-resize)" : "var(--resize-horizontal, ew-resize)";
|
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"]
|
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.shape || item.oriented || canEditObject(item, "stretch") ? ["nw", "n", "ne", "e", "se", "s", "sw", "w"]
|
||||||
: item.type === "TextObject" && canEditObject(item, "reflow") && canEditObject(item, "layoutKnown")
|
: 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) {
|
for (const corner of handles) {
|
||||||
const handle = document.createElement("span");
|
const handle = document.createElement("span");
|
||||||
handle.className = `edit-handle edit-${corner}`;
|
handle.className = `edit-handle edit-${corner}`;
|
||||||
@@ -1303,6 +1304,7 @@ export class CanvasEditor {
|
|||||||
const bounds = transformedBox(box, frame.matrix);
|
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`,
|
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` });
|
width: `${bounds.width * PX_PER_MM}px`, height: `${bounds.height * PX_PER_MM}px` });
|
||||||
|
this.placeTextHandles(drag.item, box, bounds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
drag.box = reshapeBox({ geometry: drag.item }, to.x - from.x, 0, drag.corner, false);
|
drag.box = reshapeBox({ geometry: drag.item }, to.x - from.x, 0, drag.corner, false);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UpdateCompositeText 修改内部文字,原文保留定位,已知段落按会话选项重排
|
// UpdateCompositeText 修改内部文字,原文保留定位,已知段落按排版选项重排
|
||||||
// 空样式保留原字体、字号和颜色,显式改变字号时重新排版并保留首行基线
|
// 空样式保留原字体、字号和颜色,显式改变字号时重新排版并保留首行基线
|
||||||
// 方向和字形映射沿用RewriteText的定位校验,不改变原文中未修改的属性
|
// 方向和字形映射沿用RewriteText的定位校验,不改变原文中未修改的属性
|
||||||
// 入参: page 页面索引, path 父复合路径, index 成员序号, value 文字, style 文字样式增量
|
// 入参: 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)
|
return e.changeCompositeText(page, path, []int{index}, &value, style, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StyleCompositeText 批量修改内部文字字体、字号或颜色,换字体保留原文字定位
|
// StyleCompositeText 批量修改内部文字字体、字号或颜色,已知段落重排,原文保留定位
|
||||||
// 更换字体时同步字形索引,无法逐字映射时需显式重排,缺字使整批操作失败
|
// 更换字体时同步字形索引,无法逐字映射时需显式重排,缺字使整批操作失败
|
||||||
// 入参: page 页面索引, path 父复合路径, indexes 成员序号, style 文字样式增量
|
// 入参: page 页面索引, path 父复合路径, indexes 成员序号, style 文字样式增量
|
||||||
// 返回: error 错误信息
|
// 返回: error 错误信息
|
||||||
@@ -129,7 +129,7 @@ func (e *Editor) updateCompositeText(node *editorCompositeNode, member Composite
|
|||||||
}
|
}
|
||||||
object.TextObject.TextCode = text.TextCode
|
object.TextObject.TextCode = text.TextCode
|
||||||
object.TextObject.CGTransform = text.CGTransform
|
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 {
|
if style.Size != 0 {
|
||||||
text.Size = style.Size
|
text.Size = style.Size
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user