Bulleted list
Group items into a bulleted list.
Try it
Select “A Bold button” and “A snack for code review” across both paragraphs. Click Bulleted list and check for a <ul> with two <li> elements.
Live example
Example result
Add it to your editor
Enable UnorderedList and connect a button to toggleUnorderedList. The command converts paragraphs or selected list items to a bulleted list.
import { EditorContent, EditorProvider, UnorderedList, useEditor, useIsActive } from 'yurich';
export function UnorderedListEditor() {
const editor = useEditor({
extensions: [UnorderedList],
initialValue: "<p>A Bold button</p><p>A snack for code review</p>",
});
const active = useIsActive(editor, 'toggleUnorderedList');
return (
<EditorProvider editor={editor}>
<button
type="button"
aria-pressed={active}
onMouseDown={event => event.preventDefault()}
onClick={() => editor.execute('toggleUnorderedList')}
>
Bulleted list
</button>
<EditorContent ariaLabel="Editor" />
</EditorProvider>
);
}
Behavior to account for
You can register OrderedList alongside it and convert a selection between the two types. Only the selected items change when converting part of a list.