Sửa được text nằm trong Form XObject (file Canva/Illustrator) + CI chạy test
Build Windows portable / build (push) Canceled after 0s
Build Windows portable / build (push) Canceled after 0s
File Canva gói toàn bộ nội dung trang vào 1 Form XObject nên chế độ sửa không thấy gì để sửa. Engine giờ liệt kê PHẲNG đệ quy vào form (FPDFFormObj_CountObjects/GetObject qua pdfium-render), mỗi mục có path [i,j,...] + tích ma trận form để quy toạ độ/cỡ chữ về trang; index của ObjectInfo/EditOp = vị trí trong danh sách phẳng (trang không form thì trùng index trang — tương thích ngược, UI không đổi cách gửi op). - SetText in-place/substitute + ReflowText + Delete hoạt động với run trong form; xoá trong form = set_text chuỗi rỗng (FPDFFormObj_RemoveObject chưa mở ở wrapper cho pdfium_7543), object mới vẽ ở cấp trang với matrix đã compose. - Đã xác minh trước: PDFium regenerate stream form khi con bị sửa (ProcessForm / HasDirtyStreams) — canary test round-trip kèm theo. - ObjectInfo thêm nested/expanded; UI bỏ khung form phủ trang + chặn kéo run trong form (Transform chưa hỗ trợ). - 4 test integration mới với fixture Form XObject tự dựng bằng lopdf (dev-dependency mới); CI thêm bước cargo test -p ff-engine trước build (máy dev không có Rust — CI là nơi duy nhất chạy test), cache thêm target/. Chi tiết: docs/12-phase4-summary.md (Iteration 4). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -663,6 +663,10 @@ struct ObjectInfoDto {
|
||||
index: u16,
|
||||
kind: String,
|
||||
rect: RectDto,
|
||||
/// Object nằm trong Form XObject (sửa text OK, kéo/resize chưa hỗ trợ).
|
||||
nested: bool,
|
||||
/// Form đã liệt kê con riêng — UI bỏ khung của form này.
|
||||
expanded: bool,
|
||||
text: Option<String>,
|
||||
font_name: Option<String>,
|
||||
font_family: Option<String>,
|
||||
@@ -685,6 +689,8 @@ fn edit_list_objects(path: String, page: u16, password: Option<String>) -> Resul
|
||||
index: o.index,
|
||||
kind: o.kind.as_str().to_string(),
|
||||
rect: RectDto { left: o.rect.left, bottom: o.rect.bottom, right: o.rect.right, top: o.rect.top },
|
||||
nested: o.nested,
|
||||
expanded: o.expanded,
|
||||
text: o.text,
|
||||
font_name: o.font_name,
|
||||
font_family: o.font_family,
|
||||
|
||||
+9
-1
@@ -2226,6 +2226,10 @@ function buildEditOverlay() {
|
||||
// Ảnh/form: khung theo từng object như cũ (có resize).
|
||||
state.editObjects.forEach((o) => {
|
||||
if (o.kind !== "image" && o.kind !== "form") return;
|
||||
// Form đã liệt kê con riêng (file Canva gói cả trang vào form): khung của
|
||||
// form phủ kín trang sẽ che hết con → bỏ. Ảnh/form TRONG form: chưa sửa
|
||||
// được (di chuyển/thay cần địa chỉ lồng) → cũng bỏ khung.
|
||||
if (o.expanded || o.nested) return;
|
||||
const box = document.createElement("div");
|
||||
box.className = "edit-box kind-" + o.kind;
|
||||
box.dataset.index = String(o.index);
|
||||
@@ -2979,8 +2983,12 @@ function promptAddText(pdfX, pdfY) {
|
||||
function onEditBoxMouseDown(e, o, runs) {
|
||||
if (state.editArm) return;
|
||||
if (e.target.classList.contains("ed-handle")) return;
|
||||
const runIndices = (runs && runs.length ? runs : [o]).map((r) => (typeof r === "number" ? r : r.index));
|
||||
const runObjs = runs && runs.length ? runs : [o];
|
||||
const runIndices = runObjs.map((r) => (typeof r === "number" ? r : r.index));
|
||||
selectEditObject(o.index, runIndices);
|
||||
// Run TRONG Form XObject (file Canva...): sửa text được nhưng chưa hỗ trợ
|
||||
// kéo di chuyển/resize — chọn thôi, không bắt đầu drag.
|
||||
if (runObjs.some((r) => r && typeof r === "object" && r.nested)) return;
|
||||
const box = e.currentTarget;
|
||||
const startX = e.clientX, startY = e.clientY;
|
||||
const left0 = parseFloat(box.style.left), top0 = parseFloat(box.style.top);
|
||||
|
||||
Reference in New Issue
Block a user