Underline
Draw a line under selected text.
Try it
Select “Yurich” and click Underline. The output contains <u>Yurich</u>. Toggle the same selection again to remove the underline.
Live example
Example result
Add it to your editor
Enable Underline for underlined text. The command is toggleUnderline, and useIsActive can drive the button’s pressed state.
import { EditorContent, EditorProvider, Underline, useEditor, useIsActive } from 'yurich';
export function UnderlineEditor() {
const editor = useEditor({
extensions: [Underline],
initialValue: "<p>Give Yurich a line of its own.</p>",
});
const active = useIsActive(editor, 'toggleUnderline');
return (
<EditorProvider editor={editor}>
<button
type="button"
aria-pressed={active}
onMouseDown={event => event.preventDefault()}
onClick={() => editor.execute('toggleUnderline')}
>
Underline
</button>
<EditorContent ariaLabel="Editor" />
</EditorProvider>
);
}
Behavior to account for
Use Mod+U to run the command by keyboard. Choose the Link extension and setLink when the text needs to navigate to a URL.