Hello Summernote
'); returnHi
', onChange: (html) => console.log(html), }); core.command('bold'); core.command('insertText', 'Hello'); const html = core.getHTML(); core.destroy(); ``` -------------------------------- ### Define and Use a Custom Plugin in Summernote React Source: https://github.com/eaeao/summernote-react/blob/main/docs/examples.md This example shows how to define a custom plugin with a command to insert a star character and a button to trigger it. Ensure the plugin is included in the `plugins` array and the button is referenced in the `toolbar` configuration. ```tsx import { definePlugin, useChrome, useCommand, SummernoteEditor, } from '@eaeao/summernote-react'; function StarButton(): JSX.Element { const { options } = useChrome(); const cmd = useCommand(); return ( ); } const starPlugin = definePlugin({ name: 'star', commands: { insertStar: (core): boolean => { const sel = window.getSelection(); if (!sel || sel.rangeCount === 0) return false; const range = sel.getRangeAt(0); if (!core.ownsRange(range)) return false; // guard: must be inside this editor range.deleteContents(); range.insertNode(document.createTextNode('★')); range.collapse(false); return true; // changed → one undo step + onChange }, }, buttons: { star: StarButton }, }); export function PluginEditor() { return (Hello
');