Skip to content

Commit 4ac0252

Browse files
fix: inline styles detection in newline
1 parent 6409223 commit 4ac0252

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

.playwright/tests/strictMarks.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,30 @@ test.describe('strict marks', () => {
143143
await expect(boldBtn).toHaveClass(/toolbar-btn--active/);
144144
});
145145

146+
test('pressing Enter in the middle of bold that is followed by plain text keeps bold and types bold', async ({
147+
page,
148+
}) => {
149+
await setEditorHtml(page, '<html><p><b>hello</b> world</p></html>');
150+
151+
const editor = editorLocator(page);
152+
const boldBtn = toolbarButton(page, 'bold');
153+
154+
await editor.click();
155+
await editor.press('End');
156+
// land in he|llo
157+
for (let i = 0; i < 9; i++) {
158+
await editor.press('ArrowLeft', { delay: 40 });
159+
}
160+
161+
await editor.press('Enter');
162+
await expect(boldBtn).toHaveClass(/toolbar-btn--active/);
163+
164+
await editor.pressSequentially('X', { delay: 40 });
165+
await expect(boldBtn).toHaveClass(/toolbar-btn--active/);
166+
167+
await expect.poll(async () => getSerializedHtml(page)).toMatch(/<p><b>X/);
168+
});
169+
146170
test('pressing Enter after the last bold character keeps bold when the rest of the line is plain', async ({
147171
page,
148172
}) => {

src/web/pmPlugins/StrictMarksPlugin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ export const StrictMarksPlugin = Extension.create({
104104
if (!selection.empty) return null;
105105

106106
const docChanged = !oldState.doc.eq(newState.doc);
107+
const selChanged = !oldState.selection.eq(newState.selection);
108+
if (!docChanged && !selChanged) return null;
109+
107110
const isExplicitToggle =
108111
!docChanged && transactions.some((tr) => tr.storedMarks !== null);
109112
if (isExplicitToggle) return null;

0 commit comments

Comments
 (0)