Skip to content

Fix/block text bbox and panel - #100

Merged
u8array merged 3 commits into
mainfrom
fix/block-text-bbox-and-panel
May 27, 2026
Merged

u8array merged 3 commits into
mainfrom
fix/block-text-bbox-and-panel

Conversation

@u8array

@u8array u8array commented May 27, 2026

Copy link
Copy Markdown
Owner

No description provided.

u8array added 2 commits May 27, 2026 17:03
The Transformer's selection bbox for ^FB text used to follow the
rendered glyph spans, so C/R-justified text pulled the left edge
rightwards away from the field anchor. Pin the bbox with an invisible
Rect at (0,0)-(blockWidth, blockHeight) inside the field Group so
the selection always covers the full block extent at the FO position.

Extract blockBoundsPx() to zebraTextLayout for unit tests that pin
the (0,0)-anchor + dimension contract.

Restructure BlockTextSettings: indent + left-border marks the sub-
panel as belonging to the FELDBLOCK checkbox (same convention as the
Font-Advanced block), justify becomes an inline mini-toolbar
(label left, four fixed-width icon buttons right) freeing the
~110px grid cell that previously collided with ZEILENABSTAND, and
the number-input grid uses items-end so wrapped labels keep their
inputs aligned.
Lift `blockBoundsDots` to pure ZPL-dot space (no Konva-pixel inputs)
so the helper is reusable by future consumers (ZPL generator, pixel-
regression renderer) without forcing them to pre-multiply by scale.
Drop the literal-typed (0,0) anchor to widen consumer-side
destructuring; the anchor invariant lives in the doc comment.

Extract `blockLineStepDots` so block-area height and per-line text
rendering share one row-step definition.

Replace the tautological "ignores text/justify" test (it just
checked determinism) with an explicit assertion in the (0,0)-anchor
test, where the missing parameter list is the real contract.

BlockTextSettings: drop the single-child grid wrapper around
ZEILENABSTAND in favour of an explicit `w-1/2` row, and split the
multi-topic layout comment to sit next to the rule it explains.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a visual block wrap guide and selection anchor bounding box for text blocks on the canvas, ensuring the selection bounds align correctly with the field anchor regardless of text justification. However, the review identified two critical issues: first, removing the useMemo hook around the active CSV row calculation defeats downstream identity-preservation and causes unnecessary canvas re-renders; second, the block height calculation incorrectly adds an extra line spacing at the bottom of the block, which deviates from the actual rendered layout and ZPL generation.

Comment thread src/components/Canvas/KonvaObject.tsx
Comment thread src/components/Canvas/KonvaObject.tsx
Comment thread src/lib/zebraTextLayout.ts Outdated
Comment thread src/lib/zebraTextLayout.test.ts Outdated
`blockBoundsDots` was computing height as `lines × (fontHeight +
spacing)`, which adds one spacing too many at the bottom. N lines
have only N-1 inter-line gaps, matching the existing ZPL emit
formula in text.tsx (`fontHeight * lines + spacing * (lines - 1)`).

Effect: with non-zero blockLineSpacing the canvas wrap guide and
Transformer selection extended past the actual printed block by
exactly one spacing unit. Now the on-screen bbox matches Labelary.

Single-line and zero-line edge cases added to the test suite.
@u8array
u8array merged commit a1ce0ab into main May 27, 2026
2 checks passed
@u8array
u8array deleted the fix/block-text-bbox-and-panel branch May 27, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant