diff --git a/assets/webui/index.html b/assets/webui/index.html index 204e66e..87bd6b8 100644 --- a/assets/webui/index.html +++ b/assets/webui/index.html @@ -270,11 +270,11 @@
- + - +
diff --git a/assets/webui/ofdgo.css b/assets/webui/ofdgo.css index fb9ba85..205df7a 100644 --- a/assets/webui/ofdgo.css +++ b/assets/webui/ofdgo.css @@ -1316,6 +1316,7 @@ button.outline-link:hover { .navigation-tabs[hidden], .page-selection-tools[hidden], .form-row[hidden], +.form-pair[hidden], .form-actions > [hidden], .annotation-detail[hidden], .tool-group[hidden], @@ -1644,10 +1645,6 @@ button.outline-link:hover { content: ""; } -.edit-object.selected { - background: rgba(15, 123, 104, 0.04); -} - .edit-object.erasing { background: var(--accent-soft); outline-style: dashed; @@ -1849,6 +1846,19 @@ button.outline-link:hover { --note-rotation: calc(-1 * var(--surface-rotation, 0deg)); } +.edit-note-icon { + position: absolute; + inset: 0; + display: grid; + place-items: center; + border: 1px solid var(--line-strong); + background: var(--panel); + color: var(--accent-strong); + font-size: 16px; + line-height: 1; + pointer-events: none; +} + .annotation-detail { display: grid; gap: 8px; diff --git a/assets/webui/ofdgo_edit.js b/assets/webui/ofdgo_edit.js index 66f6ba3..84c7c8d 100644 --- a/assets/webui/ofdgo_edit.js +++ b/assets/webui/ofdgo_edit.js @@ -303,14 +303,21 @@ export class CanvasEditor { node.setAttribute("aria-label", { ImageObject: "图片对象", TextObject: "文字对象", PathObject: "图形对象", CompositeObject: "复合对象", CompositeGraphicUnit: "复合对象", Annotation: "注解对象" }[object.type]); const item = { ...object, index, page: { width: page.width, height: page.height }, node, surface }; item.artwork = artwork.get(object.id)?.node; - if (object.type === "PathObject" && (object.shape || object.outline) || (object.scoped || object.type === "CompositeObject" || object.type === "CompositeGraphicUnit" || object.type === "Annotation") && object.contours?.length) { + if (object.note) { + const icon = document.createElement("span"); + icon.className = "edit-note-icon"; + icon.setAttribute("aria-hidden", "true"); + icon.textContent = "\u24d8"; + node.append(icon); + } + if (object.type === "PathObject" && (object.shape || object.outline || object.contours?.length)) { node.classList.add("edit-contour"); const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); svg.classList.add("edit-outline"); svg.setAttribute("aria-hidden", "true"); svg.setAttribute("preserveAspectRatio", "none"); let contour; - if (object.type === "PathObject" && (object.shape || object.oriented || !object.contours?.length)) { + if (object.shape || object.oriented || !object.contours?.length) { const shape = object.shape || object.oriented?.kind; contour = document.createElementNS("http://www.w3.org/2000/svg", shape === "line" ? "line" : shape === "ellipse" ? "ellipse" : shape === "rectangle" ? "rect" : "path"); if (!shape) contour.setAttribute("d", object.outline); diff --git a/internal/webui/wasm.go b/internal/webui/wasm.go index 55292f1..3dd0a52 100644 --- a/internal/webui/wasm.go +++ b/internal/webui/wasm.go @@ -898,9 +898,15 @@ func editorObjects(index int, text *ofdgo.PageText) ([]any, error) { mixed = true } } - objects = append(objects, map[string]any{"id": "annotation:" + annotation.ID, "type": "Annotation", "annotationType": annotation.Type, - "x": box.X, "y": box.Y, "width": box.W, "height": box.H, "contours": paths, "remark": annotation.Remark, "creator": annotation.Creator, - "alpha": alpha, "alphaMixed": mixed, "capabilities": capabilities}) + item := map[string]any{"id": "annotation:" + annotation.ID, "type": "Annotation", "annotationType": annotation.Type, + "x": box.X, "y": box.Y, "width": box.W, "height": box.H, "remark": annotation.Remark, "creator": annotation.Creator, + "alpha": alpha, "alphaMixed": mixed, "capabilities": capabilities} + if len(annotation.Appearance.Objects) == 0 && strings.TrimSpace(annotation.Remark) != "" { + item["note"] = true + } else { + item["contours"] = paths + } + objects = append(objects, item) } return objects, nil } @@ -1066,13 +1072,6 @@ func writeAnnotation(args []js.Value) (any, error) { switch options.Kind { case "note": annotation.Type, annotation.Remark = "Path", options.Text - shape, shapeErr := ofdgo.NewShape(ofdgo.ShapeRectangle, ofdgo.Box{W: box.W, H: box.H}) - if shapeErr != nil { - return shapeErr - } - shape.LineWidth = 0.3 - shape.StrokeColor = &ofdgo.StrokeColor{Value: "0 128 112"} - annotation.Appearance.Objects = []ofdgo.GraphicObject{{Type: "PathObject", PathObject: shape}} case "watermark", "stamp": annotation.Type = "Watermark" if options.Kind == "stamp" {