feat: add shortcut to create todo in documents (#5827)

Signed-off-by: Danilo Gacevic <gacevic.danilo@gmail.com>
This commit is contained in:
Danilo Gačević 2024-06-26 08:19:37 +02:00 committed by GitHub
parent dfaddb86f7
commit 27454ca707
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 198 additions and 165 deletions

View File

@ -50,6 +50,7 @@
"Height": "Height",
"Unset": "Unset",
"Image": "Image",
"SeparatorLine": "Separator line"
"SeparatorLine": "Separator line",
"TodoList": "Todo list"
}
}

View File

@ -308,7 +308,8 @@
...(canEmbedImages ? [{ id: 'image', label: textEditorPlugin.string.Image, icon: view.icon.Image }] : []),
{ id: 'table', label: textEditorPlugin.string.Table, icon: view.icon.Table2 },
{ id: 'code-block', label: textEditorPlugin.string.CodeBlock, icon: view.icon.CodeBlock },
{ id: 'separator-line', label: textEditorPlugin.string.SeparatorLine, icon: view.icon.SeparatorLine }
{ id: 'separator-line', label: textEditorPlugin.string.SeparatorLine, icon: view.icon.SeparatorLine },
{ id: 'todo-list', label: textEditorPlugin.string.TodoList, icon: view.icon.TodoList }
],
handleSelect: handleLeftMenuClick
})
@ -402,6 +403,9 @@
)
editor.commands.focus(pos, { scrollIntoView: false })
break
case 'todo-list':
editor.commands.toggleTaskList()
break
case 'separator-line':
editor.commands.setHorizontalRule()
break

View File

@ -129,7 +129,7 @@ export const completionConfig: Partial<CompletionOptions> = {
}
}
const inlineCommandsIds = ['image', 'table', 'code-block', 'separator-line'] as const
const inlineCommandsIds = ['image', 'table', 'code-block', 'separator-line', 'todo-list'] as const
export type InlineCommandId = (typeof inlineCommandsIds)[number]
/**
@ -146,7 +146,8 @@ export function inlineCommandsConfig (
{ id: 'image', label: plugin.string.Image, icon: view.icon.Image },
{ id: 'table', label: plugin.string.Table, icon: view.icon.Table2 },
{ id: 'code-block', label: plugin.string.CodeBlock, icon: view.icon.CodeBlock },
{ id: 'separator-line', label: plugin.string.SeparatorLine, icon: view.icon.SeparatorLine }
{ id: 'separator-line', label: plugin.string.SeparatorLine, icon: view.icon.SeparatorLine },
{ id: 'todo-list', label: plugin.string.TodoList, icon: view.icon.TodoList }
].filter(({ id }) => !excludedCommands.includes(id as InlineCommandId))
},
command: ({ editor, range, props }: { editor: Editor, range: Range, props: any }) => {

View File

@ -81,6 +81,7 @@ export default plugin(textEditorId, {
Height: '' as IntlString,
Unset: '' as IntlString,
Image: '' as IntlString,
SeparatorLine: '' as IntlString
SeparatorLine: '' as IntlString,
TodoList: '' as IntlString
}
})

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -51,6 +51,7 @@ loadMetadata(view.icon, {
Table2: `${icons}#table2`,
CodeBlock: `${icons}#code-block`,
SeparatorLine: `${icons}#separator-line`,
TodoList: `${icons}#todo-list`,
Circle: `${icons}#circle`,
Join: `${icons}#join`,
Leave: `${icons}#leave`,

View File

@ -248,7 +248,8 @@ const view = plugin(viewId, {
Circle: '' as Asset,
Join: '' as Asset,
Leave: '' as Asset,
Copy: '' as Asset
Copy: '' as Asset,
TodoList: '' as Asset
},
category: {
General: '' as Ref<ActionCategory>,