-
Notifications
You must be signed in to change notification settings - Fork 127
fix(track-changes): allow linked style changes in suggesting mode (SD-2182) #2373
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
Merged
caio-pizzol
merged 5 commits into
main
from
caio/sd-2182-track-linked-style-changes-in-suggesting-mode
Mar 19, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d18953e
fix(track-changes): allow linked style changes in suggesting mode (SD…
caio-pizzol 1e1b59b
fix(track-changes): tighten setNodeMarkup heuristic and fix toggleLin…
caio-pizzol f27557e
test(track-changes): add tests for linked style changes in suggesting…
caio-pizzol 8a03c46
refactor(track-changes): improve comment accuracy and deduplicate tes…
caio-pizzol 0290f8a
fix(test): update toggleHeading test for cursor selection behavior
caio-pizzol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
92 changes: 92 additions & 0 deletions
92
tests/behavior/tests/formatting/heading-style-suggesting-mode.spec.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import { test, expect } from '../../fixtures/superdoc.js'; | ||
| import type { Page } from '@playwright/test'; | ||
|
|
||
| async function getFirstParagraphStyleId(page: Page): Promise<string | null> { | ||
| return page.evaluate(() => { | ||
| const editor = (window as any).editor; | ||
| let result: string | null = null; | ||
| editor.state.doc.descendants((node: any) => { | ||
| if (node.type.name === 'paragraph') { | ||
| result = node.attrs?.paragraphProperties?.styleId ?? null; | ||
| return false; | ||
| } | ||
| return true; | ||
| }); | ||
| return result; | ||
| }); | ||
| } | ||
|
|
||
| test.use({ config: { toolbar: 'full', comments: 'on', trackChanges: true } }); | ||
|
|
||
| test.describe('SD-2182 heading style changes in suggesting mode', () => { | ||
| test('applying heading style via setStyleById works in suggesting mode', async ({ superdoc }) => { | ||
| // Type text in editing mode | ||
| await superdoc.type('Hello world'); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| // Switch to suggesting mode | ||
| await superdoc.setDocumentMode('suggesting'); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| // Select all and apply Heading1 style | ||
| await superdoc.selectAll(); | ||
| await superdoc.page.evaluate(() => { | ||
| (window as any).editor.commands.setStyleById('Heading1'); | ||
| }); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| const styleId = await getFirstParagraphStyleId(superdoc.page); | ||
| expect(styleId).toBe('Heading1'); | ||
| }); | ||
|
|
||
| test('toggling heading style with cursor works in suggesting mode', async ({ superdoc }) => { | ||
| // Type text in editing mode | ||
| await superdoc.type('Hello world'); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| // Switch to suggesting mode (cursor is at end of text — empty selection) | ||
| await superdoc.setDocumentMode('suggesting'); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| // Apply Heading1 via toggleLinkedStyle with cursor (no selection) | ||
| const result = await superdoc.page.evaluate(() => { | ||
| const editor = (window as any).editor; | ||
| const style = editor.helpers.linkedStyles.getStyleById('Heading1'); | ||
| return editor.commands.toggleLinkedStyle(style); | ||
| }); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| expect(result).toBe(true); | ||
|
|
||
| const styleId = await getFirstParagraphStyleId(superdoc.page); | ||
| expect(styleId).toBe('Heading1'); | ||
| }); | ||
|
|
||
| test('toggling heading style off with cursor works in suggesting mode', async ({ superdoc }) => { | ||
| // Type text and apply heading in editing mode | ||
| await superdoc.type('Hello world'); | ||
| await superdoc.waitForStable(); | ||
| await superdoc.selectAll(); | ||
| await superdoc.page.evaluate(() => { | ||
| (window as any).editor.commands.setStyleById('Heading1'); | ||
| }); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| // Switch to suggesting mode | ||
| await superdoc.setDocumentMode('suggesting'); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| // Toggle off Heading1 with cursor (no selection) | ||
| const result = await superdoc.page.evaluate(() => { | ||
| const editor = (window as any).editor; | ||
| const style = editor.helpers.linkedStyles.getStyleById('Heading1'); | ||
| return editor.commands.toggleLinkedStyle(style); | ||
| }); | ||
| await superdoc.waitForStable(); | ||
|
|
||
| expect(result).toBe(true); | ||
|
|
||
| const styleId = await getFirstParagraphStyleId(superdoc.page); | ||
| expect(styleId).toBeNull(); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.