Skip to content

Commit

Permalink
fix not checked
Browse files Browse the repository at this point in the history
  • Loading branch information
potatowagon committed May 29, 2024
1 parent db1212b commit b74318f
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions packages/lexical-list/src/LexicalListItemNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ export class ListItemNode extends ElementNode {

static importDOM(): DOMConversionMap | null {
return {
input: (node: Node) => ({
conversion: $convertCheckboxInput,
priority: 0,
}),
li: (node: Node) => ({
conversion: $convertListItemElement,
priority: 0,
Expand Down Expand Up @@ -498,20 +494,29 @@ function updateListItemChecked(
}

function $convertListItemElement(domNode: Node): DOMConversionOutput {
if (!isHTMLElement(domNode)) {
return {node: null};
}

const isGitHubCheckList = domNode.classList.contains('task-list-item');
if (isGitHubCheckList) {
for (const child of domNode.children) {
if (child.tagName === 'INPUT') {
return $convertCheckboxInput(child);
}
}
}

const checked =
isHTMLElement(domNode) &&
(domNode.getAttribute('aria-checked') === 'true'
domNode.getAttribute('aria-checked') === 'true'
? true
: domNode.getAttribute('aria-checked') === 'false'
? false
: undefined);
: undefined;
return {node: $createListItemNode(checked)};
}

function $convertCheckboxInput(domNode: Node): DOMConversionOutput {
if (!isHTMLElement(domNode)) {
return {node: null};
}
function $convertCheckboxInput(domNode: Element): DOMConversionOutput {
const isCheckboxInput = domNode.getAttribute('type') === 'checkbox';
if (!isCheckboxInput) {
return {node: null};
Expand Down

0 comments on commit b74318f

Please sign in to comment.