-
Notifications
You must be signed in to change notification settings - Fork 122
SD-2570 - fix: document API tracked changes not fully rendered on document #2825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7696,11 +7696,50 @@ const stripListIndent = (attrs?: ParagraphAttrs): ParagraphAttrs | undefined => | |
| * // Returns runs or run slices that fall within the specified character range | ||
| * ``` | ||
| */ | ||
| const expandRunsForInlineNewlines = (runs: Run[]): Run[] => { | ||
| const expanded: Run[] = []; | ||
|
|
||
| for (const run of runs) { | ||
| if ((run as TextRun).text && typeof (run as TextRun).text === 'string' && (run as TextRun).text.includes('\n')) { | ||
| const textRun = run as TextRun; | ||
| const segments = textRun.text.split('\n'); | ||
| let cursor = textRun.pmStart ?? 0; | ||
|
|
||
| segments.forEach((segment, idx) => { | ||
| expanded.push({ | ||
| ...textRun, | ||
| text: segment, | ||
| pmStart: cursor, | ||
| pmEnd: cursor + segment.length, | ||
| }); | ||
| cursor += segment.length; | ||
|
|
||
| if (idx !== segments.length - 1) { | ||
| expanded.push({ | ||
| kind: 'break', | ||
| breakType: 'line', | ||
| pmStart: cursor, | ||
| pmEnd: cursor + 1, | ||
| sdt: textRun.sdt, | ||
| }); | ||
| cursor += 1; | ||
| } | ||
| }); | ||
| continue; | ||
| } | ||
|
|
||
| expanded.push(run); | ||
| } | ||
|
|
||
| return expanded; | ||
| }; | ||
|
|
||
| export const sliceRunsForLine = (block: ParagraphBlock, line: Line): Run[] => { | ||
| const runs = expandRunsForInlineNewlines(block.runs as Run[]); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This call now recomputes newline expansion for the full paragraph run list every time a single line is rendered. Since Useful? React with 👍 / 👎. |
||
| const result: Run[] = []; | ||
|
|
||
| for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) { | ||
| const run = block.runs[runIndex]; | ||
| const run = runs[runIndex]; | ||
| if (!run) continue; | ||
|
|
||
| // FIXED: ImageRun handling - images are atomic units, no slicing needed | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newline expansion path seeds
cursorwithtextRun.pmStart ?? 0, which means runs that originally had no PM mapping are rewritten with syntheticpmStart/pmEndvalues. Those fabricated offsets are later emitted asdata-pm-*attributes during rendering, so in documents rendered without real PM coordinates the caret/click mapping can resolve to incorrect positions (often near the document start) instead of using the no-position fallback path. PreservepmStart/pmEndas undefined when the source run has no PM metadata.Useful? React with 👍 / 👎.