Skip to content

feat: support for embeds - #1

Merged
unDemian merged 1 commit into
mainfrom
feat/embeds
Sep 1, 2026
Merged

feat: support for embeds#1
unDemian merged 1 commit into
mainfrom
feat/embeds

Conversation

@unDemian

@unDemian unDemian commented Sep 1, 2026

Copy link
Copy Markdown
Member

Note

High Risk
Changes core selection projection, Yoga/text measurement, and native layout on both platforms; incorrect placeholder or rect handling could break copy mapping or overlay positioning, though coverage is extensive.

Overview
Restores the embed API (removed in 0.10.0) so custom views like citation cards can live inside a prose selection run instead of forcing classifyBlock: 'standalone'. Consumers return declared width/height, optional copy text, and a render function; claimed nodes project as a single U+FFFC placeholder with exact source mapping, and selection/copy can sweep across them atomically.

JS pipeline: segmentRuns / projectRun gain EmbedLookup (wins over classifyBlock and view-kind standalone rules), ProjectedRun.embeds, and embed marks. resolveRunEmbeds and transparent + line-height attributes reserve layout height; SelectableMarkdown wraps runs with absolutely positioned overlays positioned from reported rects (skipped on unsettled streaming tail).

Native contract: New embeds prop and onEmbedLayout per embed (deduped rect updates). Android uses RunEmbedSpan / ReplacementSpan and layout-cache keys include embeds; iOS uses RNSMEmbedAttachment on the shared attributed-string builder. Fabric measurer comments clarify overlays are siblings, not shadow-tree attachments.

Quality & release: Corpus-scale embed projection oracle tests, unit tests for segmentation/projection/attributes, codegen checks for embed structs/events, and docs/README updated for 0.11.x. Package version bumped to 0.11.0.

Reviewed by Cursor Bugbot for commit 953814d. Bugbot is set up for automated code reviews on this repo. Configure here.

@unDemian
unDemian merged commit 6b6aee2 into main Sep 1, 2026
7 checks passed

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issues. You can view the agent here.

Reviewed by Cursor Bugbot for commit 953814d. Configure here.

rects: ReadonlyMap<number, EmbedRect>;
}>({ owner: null, rects: NO_EMBED_RECTS });
const rects =
embedRects.owner === projected ? embedRects.rects : NO_EMBED_RECTS;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Overlays vanish after projection swap

High Severity

Embed overlays are keyed to the projected object identity, so any reprojection drops every stored rect. Both hosts only re-fire onEmbedLayout when a rect moves, so unchanged reservations are never re-announced. After a stream settles — or any other re-render that rebuilds projected with the same geometry — the cards never appear.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 953814d. Configure here.

}
lastEmbedRects[embed.id] = rect
emit(embed.id, rect.origin.x, rect.origin.y, rect.width, rect.height)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

iOS embed events ignore declared size

Medium Severity

iOS onEmbedLayout sends the TextKit boundingRect width and height instead of the declared reservation stored in embed.size. Android echoes the declared size, and the overlay is sized from the event. A measured box that does not match the attachment leaves the card the wrong size on iOS only.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 953814d. Configure here.

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