Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

editor: fix outline list toggle not handling nested lists #7092

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

01zulfi
Copy link
Collaborator

@01zulfi 01zulfi commented Dec 12, 2024

Signed-off-by: 01zulfi [email protected]

Comment on lines +133 to +161

const processNestedNodes = (parentNode: Fragment, parentPos: number) => {
parentNode.forEach((child, offset) => {
const childPos = parentPos + offset + 1;
if (
child.type.name === "bulletList" ||
child.type.name === "orderedList"
) {
editor.commands.command(({ tr }) => {
tr.setNodeMarkup(childPos, editor.schema.nodes.outlineList);
return true;
});
}
if (child.type.name === "listItem") {
editor.commands.command(({ tr }) => {
tr.setNodeMarkup(childPos, editor.schema.nodes.outlineListItem);
return true;
});
}
processNestedNodes(child.content, childPos);
});
};

if (typeof getPos === "function") {
processNestedNodes(node.content, getPos());
} else {
processNestedNodes(node.content, Number(getPos));
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the wrong place to do this. We need to convert the nodes in toggleOutlineList command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants