Skip to content

Commit

Permalink
bug: Fix Bulleting a Node Selection
Browse files Browse the repository at this point in the history
  • Loading branch information
umaranis committed May 6, 2024
1 parent 006de58 commit 7dd5254
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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());
}
});
}

0 comments on commit 7dd5254

Please sign in to comment.