Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .playwright/tests/strictMarks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,30 @@ test.describe('strict marks', () => {
await expect(boldBtn).toHaveClass(/toolbar-btn--active/);
});

test('pressing Enter in the middle of bold that is followed by plain text keeps bold and types bold', async ({
page,
}) => {
await setEditorHtml(page, '<html><p><b>hello</b> world</p></html>');

const editor = editorLocator(page);
const boldBtn = toolbarButton(page, 'bold');

await editor.click();
await editor.press('End');
// land in he|llo
for (let i = 0; i < 9; i++) {
await editor.press('ArrowLeft', { delay: 80 });
}
Comment thread
Copilot marked this conversation as resolved.

await editor.press('Enter');
await expect(boldBtn).toHaveClass(/toolbar-btn--active/);

await editor.pressSequentially('X', { delay: 80 });
await expect(boldBtn).toHaveClass(/toolbar-btn--active/);

await expect.poll(async () => getSerializedHtml(page)).toMatch(/<p><b>X/);
});

test('pressing Enter after the last bold character keeps bold when the rest of the line is plain', async ({
page,
}) => {
Expand Down
3 changes: 3 additions & 0 deletions src/web/pmPlugins/StrictMarksPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ export const StrictMarksPlugin = Extension.create({
if (!selection.empty) return null;

const docChanged = !oldState.doc.eq(newState.doc);
const selChanged = !oldState.selection.eq(newState.selection);
if (!docChanged && !selChanged) return null;

const isExplicitToggle =
!docChanged && transactions.some((tr) => tr.storedMarks !== null);
if (isExplicitToggle) return null;
Expand Down
Loading