fix(richtext-lexical): unchecked list items were rendered as checked in html converter (#11747)

Previously, unchecked list items had the `checked="false"` attribute,
which is not valid in HTML and renders them as checked.

This PR omits the `checked` attribute if the list item is unchecked,
which is the correct behavior.
This commit is contained in:
Alessio Gravili
2025-03-18 11:30:52 -06:00
committed by GitHub
parent aa3737ca39
commit 3f23160a96
2 changed files with 2 additions and 2 deletions

View File

@@ -37,7 +37,7 @@ export const ListHTMLConverterAsync: HTMLConvertersAsync<
${
hasSubLists
? children
: `<input checked="${node.checked}" id="${uuid}" readOnly="true" type="checkbox" />
: `<input${node.checked ? ' checked' : ''} id="${uuid}" readOnly="true" type="checkbox" />
<label htmlFor="${uuid}">${children}</label>
<br />`
}

View File

@@ -31,7 +31,7 @@ export const ListHTMLConverter: HTMLConverters<SerializedListItemNode | Serializ
${
hasSubLists
? children
: `<input checked="${node.checked}" id="${uuid}" readOnly="true" type="checkbox" />
: `<input${node.checked ? ' checked' : ''} id="${uuid}" readOnly="true" type="checkbox" />
<label htmlFor="${uuid}">${children}</label>
<br />`
}