Skip to content
Open
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
11 changes: 9 additions & 2 deletions packages/koenig-lexical/src/styles/components/kg-prose.css
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,16 @@
/* -------------------------------------------------------------------- */

:where(
blockquote p
blockquote > *
):not(:where(.not-kg-prose, [class~='not-kg-prose'] *)) {
margin: 0;
margin-top: 0;
margin-bottom: 0;
}

:where(
blockquote > * + *
):not(:where(.not-kg-prose, [class~='not-kg-prose'] *)) {
margin-top: 1em;
}
Comment on lines +552 to 562
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change expands the reset from blockquote p to blockquote > *, which will now also strip top/bottom margins from any other direct children inside blockquotes (e.g., lists, headings, pre/code blocks). That’s a behavioral change beyond paragraphs and could unintentionally compress other markdown constructs. Consider scoping the selector to the elements you explicitly want to normalize (e.g., p and nested blockquote, or a curated set like p, blockquote, ul/ol) and/or adding a regression test for another block element (like a list) inside a blockquote.

Copilot uses AI. Check for mistakes.

:where(
Expand Down
67 changes: 67 additions & 0 deletions packages/koenig-lexical/test/e2e/cards/markdown-card.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,73 @@ test.describe('Markdown card', async () => {
`);
});

test('preserves multi-paragraph and nested blockquote spacing in read-only mode', async function () {
await page.evaluate(() => {
const markdown = [
'> First paragraph',
'>',
'> Second paragraph',
'>',
'> > Nested one',
'> >',
'> > Nested two'
].join('\n');

const serializedState = JSON.stringify({
root: {
children: [{
type: 'markdown',
version: 1,
markdown
}],
direction: null,
format: '',
indent: 0,
type: 'root',
version: 1
}
});
const editor = window.lexicalEditor;
const editorState = editor.parseEditorState(serializedState);
editor.setEditorState(editorState);
});

Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test sets editor state in page.evaluate and immediately asserts HTML/styles. If DOM updates are async in this environment, this can be flaky in CI. Add an explicit wait point after setEditorState (e.g., wait for the expected blockquote/paragraph selectors to appear, or for the markdown card to contain First paragraph) before calling assertHTML and computing styles.

Suggested change
await page.waitForFunction(() => {
const card = document.querySelector('[data-kg-card="markdown"]');
return card &&
card.textContent.includes('First paragraph') &&
card.querySelector('blockquote > p + p') &&
card.querySelector('blockquote > blockquote');
});

Copilot uses AI. Check for mistakes.
await assertHTML(page, html`
<div data-lexical-decorator="true" contenteditable="false">
<div><svg></svg></div>
<div data-kg-card-editing="false" data-kg-card-selected="false" data-kg-card="markdown">
<div>
<div>
<blockquote>
<p>First paragraph</p>
<p>Second paragraph</p>
<blockquote>
<p>Nested one</p>
<p>Nested two</p>
</blockquote>
</blockquote>
</div>
<div></div>
</div>
</div>
</div>
`);

const quoteStyles = await page.evaluate(() => {
const card = document.querySelector('[data-kg-card="markdown"]');
const secondParagraph = card.querySelector('blockquote > p + p');
const nestedQuote = card.querySelector('blockquote > blockquote');

return {
secondParagraphMarginTop: getComputedStyle(secondParagraph).marginTop,
nestedQuoteBorderLeftWidth: getComputedStyle(nestedQuote).borderLeftWidth
};
});
Comment on lines +128 to +137
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If either secondParagraph or nestedQuote is missing (e.g., markup changes slightly), getComputedStyle(null) will throw with a less actionable error. Consider asserting these nodes exist inside the evaluation (or returning a boolean + values) so failures clearly indicate which expected element wasn’t found.

Copilot uses AI. Check for mistakes.

expect(parseFloat(quoteStyles.secondParagraphMarginTop)).toBeGreaterThan(0);
expect(parseFloat(quoteStyles.nestedQuoteBorderLeftWidth)).toBeGreaterThan(0);
});

test('renders markdown card node', async function () {
await focusEditor(page);
await page.keyboard.type('/');
Expand Down