import { Node } from '@tiptap/core'; declare module '@tiptap/core' { interface Commands { nbsp: { /** * Add a hard break */ setNonBreakingSpace: () => ReturnType; }; } } export const NonBreakingSpace = Node.create({ name: 'nbsp', inline: true, group: 'inline', addCommands() { return { setNonBreakingSpace: () => ({ commands, chain }) => { return commands.first([ () => commands.exitCode(), () => commands.command(() => { return chain() .insertContent(String.fromCharCode(160)) // <= 160 = non breaking space https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/character-set-128255 .run(); }) ]); } }; } });