hanger-editor-rich
v0.2.0
Published
Formatted textarea overlay for the hanger-editor markdown composer
Maintainers
Readme
hanger-editor-rich
Formatted textarea overlay for hanger-editor.
The textarea keeps plain markdown as its value. A second, source-aligned layer renders bold, italic, code, quotes and links underneath the transparent textarea, so formatting is visible without putting HTML into the value.
The package installs the core package automatically.
Install
pnpm add hanger-editor-richUsage
import { createRichTextarea } from 'hanger-editor-rich'
import 'hanger-editor-rich/rich-textarea.css'
const rich = createRichTextarea(document.querySelector('#composer')!, {
value: '',
placeholder: 'Write a message…',
markers: 'dim',
submitOnEnter: true,
maxHeight: 320,
onChange: ({ value }) => saveDraft(value),
onSubmit: ({ raw, html }) => sendMessage({ content: raw, html }),
})
rich.editor.toggleBold()
rich.focus()markers accepts visible, dim or hidden. Hidden delimiters keep their
advance width for caret alignment; use dim if the resulting gaps are
distracting.
Links
MIT
