Dependency-free WYSIWYG markdown/html editor
New events with structured payloads:
change({ markdown, html })
Fires on every content edit.
save({ markdown, html })
Fires when editor.save() is called. Consumer handles persistence.
modeChange({ current, previous })
Fires on VIEW/EDIT/WYSIWYG transitions.
themeChange({ current, previous })
Fires when themes.set() switches the active theme.
ready({ markdown, html, mode, theme })
Fires after editor.run() completes first render.
Events can be registered in the constructor via the 'on' setting
or at any time via editor.on(event, callback) / editor.off().
202/202 tests passing.
|
||
|---|---|---|
| src | ||
| test | ||
| .gitignore | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
ribbit
Zero-dependency WYSIWYG markdown editor
Files
src/hopdown.js— Markdown ↔ HTML converter (HopDown.toHTML(),HopDown.toMarkdown())src/ribbit.js— Base viewer class (Ribbit), plugin base class (RibbitPlugin), utilitiessrc/ribbit-editor.js— Editor class (RibbitEditor) with VIEW/EDIT/WYSIWYG modessrc/ribbit.css— Editor and content styles
Usage
<link rel="stylesheet" href="ribbit/src/ribbit.css">
<article id="ribbit">your markdown here</article>
<script src="ribbit/src/hopdown.js"></script>
<script src="ribbit/src/ribbit.js"></script>
<script src="ribbit/src/ribbit-editor.js"></script>
<script>
const editor = new RibbitEditor({ plugins: [] });
editor.run();
// Switch modes
editor.wysiwyg(); // WYSIWYG editing
editor.edit(); // Source editing
editor.view(); // Read-only view
// Get content
editor.getMarkdown();
editor.getHTML();
</script>
Supported Markdown
Bold, italic, inline code, links, headings (h1-h6), unordered/ordered/nested lists, blockquotes, fenced code blocks with language, horizontal rules, GFM tables with column alignment, and paragraphs. Arbitrary nesting of all inline formatting.
Tests
Open test/test_ribbit-down.html in a browser.