import { Mark, mergeAttributes } from '@tiptap/core'; export interface StrongOptions { /** * HTML attributes to add to the strong element. * @default {} * @example { class: 'foo' } */ HTMLAttributes: Record; } declare module '@tiptap/core' { interface Commands { strong: { /** * Set a strong mark */ setStrong: () => ReturnType; /** * Toggle a strong mark */ toggleStrong: () => ReturnType; /** * Unset a strong mark */ unsetStrong: () => ReturnType; }; } } /** * This extension allows you to mark text as strong. * @see https://tiptap.dev/api/marks/strong */ export const Strong = Mark.create({ name: 'strong', addOptions() { return { HTMLAttributes: {} }; }, parseHTML() { return [ { tag: 'strong' } ]; }, renderHTML({ HTMLAttributes }) { return ['strong', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]; }, addCommands() { return { setStrong: () => ({ commands }) => { return commands.setMark(this.name); }, toggleStrong: () => ({ commands }) => { return commands.toggleMark(this.name); }, unsetStrong: () => ({ commands }) => { return commands.unsetMark(this.name); } }; } });