Add Bold Formatting
This code demonstrates how to add the Bold extension to a Tiptap editor instance. The Bold extension is imported and included in the editor's extensions array, enabling bold formatting in the editor.
import { Bold } from '@tiptap/extension-bold';
import { Editor } from '@tiptap/core';
const editor = new Editor({
extensions: [
Bold,
],
content: '<p>Hello World!</p>',
});
Toggle Bold Formatting
This code shows how to programmatically toggle bold formatting on the selected text in the Tiptap editor. The `toggleBold` command is chained with `focus` to ensure the editor is focused before applying the bold formatting.
editor.chain().focus().toggleBold().run();