diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/AIButton.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/AIButton.tsx index c7915bfe..31c98291 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/AIButton.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/AIButton.tsx @@ -281,10 +281,14 @@ const AIMenuItem = ({ const handleAIError = useHandleAIError(); const handleAIAction = async () => { - const selectedBlocks = editor.getSelection()?.blocks; + let selectedBlocks = editor.getSelection()?.blocks; if (!selectedBlocks || selectedBlocks.length === 0) { - return; + selectedBlocks = [editor.getTextCursorPosition().block]; + + if (!selectedBlocks || selectedBlocks.length === 0) { + return; + } } const markdown = await editor.blocksToMarkdownLossy(selectedBlocks); diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/MarkdownButton.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/MarkdownButton.tsx index f84f1cd2..7cae642a 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/MarkdownButton.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/MarkdownButton.tsx @@ -46,7 +46,11 @@ export function MarkdownButton() { const { t } = useTranslation(); const handleConvertMarkdown = () => { - const blocks = editor.getSelection()?.blocks; + let blocks = editor.getSelection()?.blocks; + + if (!blocks || blocks.length === 0) { + blocks = [editor.getTextCursorPosition().block]; + } forEach(blocks, async (block) => { if (!isBlock(block as unknown as Block)) {