From 7dd5254257c5f707b8a61649c96dfc6891d55bcc Mon Sep 17 00:00:00 2001 From: umaranis Date: Mon, 6 May 2024 18:41:23 +1000 Subject: [PATCH] bug: Fix Bulleting a Node Selection --- .../toolbar/BlockFormatDropDown/formatParagraph.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/svelte-lexical/src/lib/components/toolbar/BlockFormatDropDown/formatParagraph.ts b/packages/svelte-lexical/src/lib/components/toolbar/BlockFormatDropDown/formatParagraph.ts index 651d74b..fb18462 100644 --- a/packages/svelte-lexical/src/lib/components/toolbar/BlockFormatDropDown/formatParagraph.ts +++ b/packages/svelte-lexical/src/lib/components/toolbar/BlockFormatDropDown/formatParagraph.ts @@ -1,9 +1,16 @@ import {$setBlocksType} from '@lexical/selection'; -import {$createParagraphNode, $getSelection, type LexicalEditor} from 'lexical'; +import { + $createParagraphNode, + $getSelection, + $isRangeSelection, + type LexicalEditor, +} from 'lexical'; export function formatParagraph(editor: LexicalEditor) { editor.update(() => { const selection = $getSelection(); - $setBlocksType(selection, () => $createParagraphNode()); + if ($isRangeSelection(selection)) { + $setBlocksType(selection, () => $createParagraphNode()); + } }); }