Skip to content

feat: textbox object interaction#3721

Open
artem-harbour wants to merge 7 commits into
mainfrom
artem/textbox-v6
Open

feat: textbox object interaction#3721
artem-harbour wants to merge 7 commits into
mainfrom
artem/textbox-v6

Conversation

@artem-harbour

@artem-harbour artem-harbour commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Main task: SD-3395.

Sub-tasks (phases): SD-3405, SD-3406.

Textbox object interaction — selection, resize, and move (Phase 2 and 3).

Summary

Adds object-level interaction for floating DrawingML textboxes represented as
shapeContainer nodes: border selection, resize handles, and drag-to-move.

Selection

  • Border clicks within a 6 px hit margin create a ProseMirror NodeSelection
    on the textbox instead of placing a caret in its text content.
  • Selected textboxes get a superdoc-textbox-selected ring; clicking outside
    clears it.
  • Works in both body and header/footer contexts.

Resize

  • TextboxResizeOverlay renders four corner handles for selected textboxes.
  • Dragging a handle updates width/height on the shapeContainer.
  • Leading-edge handles also adjust marginOffset so the opposite corner
    remains fixed.
  • Export patches both wp:extent and wps:spPr > a:xfrm > a:ext in EMU.
    The a:ext update now targets the shape geometry path directly instead of
    relying on DFS first-match.

Move

  • Dragging the overlay body updates marginOffset on the shapeContainer.
  • A temporary CSS transform: translate(…) provides live drag feedback.
  • Textbox moves now invalidate the right caches for table-cell and
    header/footer relayout.
  • Export patches wp:positionH/V > wp:posOffset in EMU.
Screenshot

@github-actions

Copy link
Copy Markdown
Contributor

The ecma-spec MCP tools are blocked by the permission system in this session — I tried several times and each call is denied before it can run, so I couldn't execute live spec lookups. I reviewed the OOXML usage against the ECMA-376 schema from knowledge instead; flagging that so the verdict's basis is clear.

Status: PASS

The two handler changes only touch DrawingML/VML elements and attributes that exist in the spec, and they use them correctly.

translate-drawingml-textbox.js:

  • wp:extent / cx,cy — correct. extent is a direct child of wp:anchor (CT_PositiveSize2D, EMU), patched in place. No collision risk since the sibling wp:effectExtent uses l/t/r/b, not cx/cy. See https://ooxml.dev/spec?q=extent
  • a:ext / cx,cy inside wps:spPr > a:xfrm — correct. The explicit path walk (wp:anchor → a:graphic → a:graphicData → wps:wsp → wps:spPr → a:xfrm → a:ext) is the right call: it deliberately avoids the DFS-first-match trap where an a:ext in an a:extLst (which carries uri, not cx/cy) would be patched wrongly — and there's a dedicated test for exactly that. https://ooxml.dev/spec?q=ext
  • wp:positionH/wp:positionVwp:posOffset — correct. posOffset holds a signed EMU integer as text; only patched when it already exists (absolute positioning), correctly leaving align-based positioning untouched. https://ooxml.dev/spec?q=posOffset
  • EMU conversion (pixelsToEmu, 1px = 9525 EMU at 96 DPI) is right: 914400 EMU/inch ÷ 96.

translate-shape-container.js:

  • Adds width/height in pt to the VML shape style string. VML shapes carry dimensions as CSS-2 style properties, and pt is a valid unit there, so this is consistent with the VML element. https://ooxml.dev/spec?q=shape

No non-existent elements/attributes, no missing-required-attribute regressions (existing cx/cy/posOffset are mutated, not removed), and no incorrect defaults introduced.

One caveat worth noting: wps:* (WordprocessingShape) is the Microsoft 2010 MCE extension namespace, not part of base ECMA-376 — but that's the established representation for these textbox shapes in the codebase, not something this PR introduces, so it's out of scope for a spec-compliance flag.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@linear-code

linear-code Bot commented Jun 12, 2026

Copy link
Copy Markdown

SD-3405

SD-3406

SD-3395

@artem-harbour artem-harbour marked this pull request as ready for review June 12, 2026 16:17
@artem-harbour artem-harbour requested a review from a team as a code owner June 12, 2026 16:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19d0376a43

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants