@bayonai/rich-text-editor
v1.0.1
Published
Reusable rich text editing, rendering, and unsaved-change session controls.
Readme
@bayonai/rich-text-editor
Reusable rich-text document utilities, native React editing components, and unsaved-change session controls.
Exports
@bayonai/rich-text-editorprovides document types, sanitization, serialization, comparison, statistics, and session controllers.@bayonai/rich-text-editor/reactprovides the editor, renderer,EditorSessionProvider, session hooks, and the Save/Discard/Stay dialog.
The package has no Next.js, Firebase, or application-domain dependencies. Hosts provide controlled document values, optional metadata, persistence callbacks, and navigation adapters.
Maintainer Notes
Internal structure and behavior contracts are documented in
BEHAVIOR.md. Read that file before changing tree-row,
toggle, cursor, clipboard, or persistence behavior.
Editor Capabilities
- Native rich-text body editing with headings, quotes, code, dividers, bullets, ordered bullets, checkboxes, toggles, image placeholders, and Markdown-compatible text storage.
- Empty, undesignated blocks expose the special block insertion tool.
- Non-empty top-level blocks expose a compact gutter handle for block actions.
- Dragging a block handle reorders blocks with a visible drop indicator.
- Clicking a block handle opens icon actions for copy, cut, delete, and close.
- Copy and cut write readable plain text to the clipboard; cut removes the block only after the clipboard write succeeds.
- Deleting the last block preserves one empty paragraph so the editor remains writable.
- Checkbox rows can be created with the
[]shortcut, reordered individually, copied, cut, and deleted. Pressing Enter from a checkbox creates the next checkbox, and Backspace at the start of a checkbox row converts that row back to a paragraph. - Bullet rows can be created with the
*shortcut, and ordered rows can be created with the1.shortcut. Empty list-like rows show placeholders instead of selecting placeholder text. - Bullet, ordered, checkbox, and toggle rows can hold nested children. Pressing
Tab indents a nestable row under the previous compatible row, and Shift+Tab
promotes it one level. Paragraph, heading, quote, code, divider, and image
blocks remain flat. Editable and read-only nested rows render as recursive
ul/olpluslitrees so list-like content keeps semantic list structure. - Toggle rows render as collapsible sections in read-only output and preserve their collapsed state in the stored block. Editable toggles can also be collapsed and expanded without dropping child content.
- Browser-native transcription can be enabled by hosts with the editor's
transcriptionEnabledoption. It defaults to enabled, uses the browserSpeechRecognitionorwebkitSpeechRecognitionAPI when available, inserts final transcript text into the current editor body, and never uploads or stores audio. Mobile Safari is treated as unavailable because its prefixed recognition sessions can get stuck and leave the editor unusable.
