Skip to content

fix(math): enable cursor positioning after inline math equations#2616

Merged
caio-pizzol merged 4 commits intomainfrom
caio/sd-2402-fixmath-cursor-cannot-be-positioned-after-inline-math
Mar 28, 2026
Merged

fix(math): enable cursor positioning after inline math equations#2616
caio-pizzol merged 4 commits intomainfrom
caio/sd-2402-fixmath-cursor-cannot-be-positioned-after-inline-math

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

Two fixes:

  1. renderer.ts: use minWidth/minHeight instead of fixed width/height on the sd-math wrapper so it auto-sizes to MathML content. The estimated dimensions caused overflow β€” clicks in the overflow area couldn't resolve to PM positions.

  2. DomSelectionGeometry.ts: position caret at elRect.right (not left) when pos === pmEnd for non-text elements. This fixes cursor positioning after all atomic inline elements (math, images).

SD-2402

Two fixes:

1. renderer.ts: use minWidth/minHeight instead of fixed width/height
   on the sd-math wrapper so it auto-sizes to MathML content. The
   estimated dimensions caused overflow β€” clicks in the overflow area
   couldn't resolve to PM positions.

2. DomSelectionGeometry.ts: position caret at elRect.right (not left)
   when pos === pmEnd for non-text elements. This fixes cursor
   positioning after all atomic inline elements (math, images).

SD-2402
@linear
Copy link
Copy Markdown

linear bot commented Mar 28, 2026

caio-pizzol and others added 3 commits March 28, 2026 06:09
Address review findings:
- Use pos >= entry.pmEnd instead of === to handle gap/closest-entry
  fallback path where pos may exceed the entry's end
- Add unit test verifying caret positions at right edge of non-text
  elements when pos matches pmEnd

SD-2402
6 tests covering:
- PM document contains mathInline/mathBlock nodes after import
- DomPainter renders <math> MathML elements
- Fraction renders as <mfrac> with correct numerator/denominator
- Math wrapper spans have data-pm-start/end attributes
- Text content preserved for unimplemented math objects
- Document text labels render alongside math elements

SD-2402
@caio-pizzol caio-pizzol enabled auto-merge (squash) March 28, 2026 09:30
@caio-pizzol caio-pizzol merged commit 3ad0ffc into main Mar 28, 2026
40 checks passed
@caio-pizzol caio-pizzol deleted the caio/sd-2402-fixmath-cursor-cannot-be-positioned-after-inline-math branch March 28, 2026 09:33
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Mar 28, 2026

πŸŽ‰ This PR is included in vscode-ext v1.1.0-next.33

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Mar 28, 2026

πŸŽ‰ This PR is included in superdoc v1.24.0-next.32

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Mar 28, 2026

πŸŽ‰ This PR is included in superdoc-cli v0.5.0-next.32

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Mar 28, 2026

πŸŽ‰ This PR is included in superdoc-sdk v1.3.0-next.32

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.

1 participant