From babec3ec97c3c9fd3a174da5a88ac76540ab256d Mon Sep 17 00:00:00 2001 From: tomdyqin Date: Thu, 19 Dec 2024 16:35:52 +0800 Subject: [PATCH 1/3] feat(markdown): action_item in list by markdown --- .../src/lib/remark-slate/remarkDefaultElementRules.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/markdown/src/lib/remark-slate/remarkDefaultElementRules.ts b/packages/markdown/src/lib/remark-slate/remarkDefaultElementRules.ts index 21eac86b12..06379ba181 100644 --- a/packages/markdown/src/lib/remark-slate/remarkDefaultElementRules.ts +++ b/packages/markdown/src/lib/remark-slate/remarkDefaultElementRules.ts @@ -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 + const listItemType = 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; @@ -98,7 +102,8 @@ export const remarkDefaultElementRules: RemarkElementRules = { ), indent, listStyleType, - type: options.editor.getType({ key: 'p' }), + checked: listItem.checked, + type: listItemType, }); subLists.forEach((subList) => { From 444307e08b03dec2d329ded0916d39b63e89dcc3 Mon Sep 17 00:00:00 2001 From: tomdyqin Date: Thu, 19 Dec 2024 16:43:04 +0800 Subject: [PATCH 2/3] fix: action_item not checked --- .../markdown/src/lib/remark-slate/remarkDefaultElementRules.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/markdown/src/lib/remark-slate/remarkDefaultElementRules.ts b/packages/markdown/src/lib/remark-slate/remarkDefaultElementRules.ts index 06379ba181..9805959048 100644 --- a/packages/markdown/src/lib/remark-slate/remarkDefaultElementRules.ts +++ b/packages/markdown/src/lib/remark-slate/remarkDefaultElementRules.ts @@ -82,7 +82,7 @@ export const remarkDefaultElementRules: RemarkElementRules = { _node.children?.forEach((listItem) => { const defaultType = options.editor.getType({ key: 'p' }); const todoListType = options.editor.getType({ key: 'action_item' }) ?? defaultType - const listItemType = listItem.checked ? todoListType : defaultType; + const listItemType = typeof listItem.checked !== 'undefined' ? todoListType : defaultType; if (!listItem.children) { listItems.push({ children: remarkTransformElementChildren(listItem, options), From 28a5109aca9c0a163f778949e59021aac0bc4742 Mon Sep 17 00:00:00 2001 From: tomdyqin Date: Tue, 24 Dec 2024 15:03:10 +0800 Subject: [PATCH 3/3] feat: fix todo list --- .../markdown/src/lib/remark-slate/remarkDefaultElementRules.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/markdown/src/lib/remark-slate/remarkDefaultElementRules.ts b/packages/markdown/src/lib/remark-slate/remarkDefaultElementRules.ts index 9805959048..2b755593f4 100644 --- a/packages/markdown/src/lib/remark-slate/remarkDefaultElementRules.ts +++ b/packages/markdown/src/lib/remark-slate/remarkDefaultElementRules.ts @@ -82,7 +82,7 @@ export const remarkDefaultElementRules: RemarkElementRules = { _node.children?.forEach((listItem) => { const defaultType = options.editor.getType({ key: 'p' }); const todoListType = options.editor.getType({ key: 'action_item' }) ?? defaultType - const listItemType = typeof listItem.checked !== 'undefined' ? todoListType : defaultType; + const listItemType = [false, true].includes(listItem.checked) ? todoListType : defaultType; if (!listItem.children) { listItems.push({ children: remarkTransformElementChildren(listItem, options),