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

feat(markdown): action_item in list by markdown #3872

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,14 @@ export const remarkDefaultElementRules: RemarkElementRules = {
indent = 1
) => {
_node.children?.forEach((listItem) => {
const defaultType = options.editor.getType({ key: 'p' });
const todoListType = options.editor.getType({ key: 'action_item' }) ?? defaultType
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the PR! We don't use TodoListPlugin with indent list, hence it can't be in this if (options.indentList) condition. Would love a unit test!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Firstly, I would like to confirm whether TodoListPlugin will be applied in the indentList? Why are there no checks for mutually exclusive plugins, such as indentListPlugin and listPlugin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry to say that it took me some time to understand the relationship between indentListPlugin and listPlugin, but my user data has been contaminated and I have to go extra and clean up the old data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I may have made the same mistake again. I didn't understand the connection between todoPlugin and indentList, and I have been confused about why there is a checked judgment in indentList. So, please clearly tell me that indentList=list+todoPlugin

Copy link
Member

@zbeyens zbeyens Dec 24, 2024

Choose a reason for hiding this comment

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

Either use https://platejs.org/docs/list or https://platejs.org/docs/indent-list, both have their own to-do list implementation

const listItemType = [false, true].includes(listItem.checked) ? todoListType : defaultType;
if (!listItem.children) {
listItems.push({
children: remarkTransformElementChildren(listItem, options),
type: options.editor.getType({ key: 'p' }),
checked: listItem.checked,
type: listItemType,
});

return listItems;
Expand All @@ -98,7 +102,8 @@ export const remarkDefaultElementRules: RemarkElementRules = {
),
indent,
listStyleType,
type: options.editor.getType({ key: 'p' }),
checked: listItem.checked,
type: listItemType,
});

subLists.forEach((subList) => {
Expand Down
Loading