feat(document-api): improve cross block selection and deleting#2391
feat(document-api): improve cross block selection and deleting#2391harbournick wants to merge 5 commits intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 18b0715f97
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| */ | ||
| function selectionTargetToRange(t: CompiledSelectionTarget): CompiledRangeTarget { | ||
| const startPoint = t.normalizedTarget.start; | ||
| const blockId = startPoint.kind === 'text' ? startPoint.blockId : '__selection__'; |
There was a problem hiding this comment.
Avoid synthetic blockId in selection rewrite targets
Using "__selection__" for node-edge CompiledSelectionTarget values breaks text.rewrite on collapsed edge selections (for example, inserting at document start via ranges.resolve + replace). In that case style capture can be empty, and the rewrite path falls back to block-based mark capture (resolveMarksForRange → toAbsoluteBlockPos), which cannot resolve this synthetic id and throws TARGET_NOT_FOUND instead of applying the mutation.
Useful? React with 👍 / 👎.
| const planRes = data.resolutions[0] as TextMutationResolution; | ||
| if (planRes.target?.blockId !== '__selection__') { | ||
| return planRes; |
There was a problem hiding this comment.
Return absolute ranges for ref-based mutation receipts
buildSelectionResolutionFromOutcome is returning data.resolutions[0] as a TextMutationResolution, but those resolutions are TextStepResolution values with block-relative offsets. For single-segment ref mutations (resolved as range targets), this produces incorrect receipt.resolution.range coordinates and violates the TextMutationResolution contract that the range is absolute document positions.
Useful? React with 👍 / 👎.
No description provided.