fix(editor): clamp paste mark range to document size in authored-tracker - #77
Draft
posthog[bot] wants to merge 1 commit into
Draft
Conversation
handlePaste computed insertTo = insertFrom + slice.size with no clamp against the document size. slice.size counts the slice's open ends, which merge into surrounding blocks when you paste multiple blocks into a paragraph, so removeMark walked past the end of the document and threw "Cannot read properties of undefined (reading 'nodeSize')". The handler returns true, so the plugin owned the paste and the user's content was dropped. Clamp insertFrom and insertTo to tr.doc.content.size before the removeMark/addMark pair, matching the clamping the same file already does in appendTransaction. Generated-By: PostHog Desktop Task-Id: ee2f2fca-abd7-4a4a-a035-2b37dea8bddc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
authored-trackerplugin owns the paste (returnstrue), then throws before the content lands, so nothing is inserted.handlePastemarks the rangeinsertFrom + slice.size, butslice.sizecounts the slice's open ends. Those ends merge into the surrounding blocks when you paste multiple blocks into a paragraph, so the real inserted range is shorter thanslice.size.removeMarkwalks past the end of the document,Fragment.nodesBetweenreaches for a child that is absent, and you getTypeError: Cannot read properties of undefined (reading 'nodeSize').Changes
insertFromandinsertTototr.doc.content.sizebefore theremoveMark/addMarkpair.appendTransactionin the same file already clamps the same way.Testing
npm testpasses (74 checks).tsc --noEmitreports no new errors for the changed file.Created with PostHog Desktop from this inbox report.