Commit Graph

10 Commits

Author SHA1 Message Date
gsb
1f523cbc0f Implement Toolbar 2026-04-29 07:11:31 +00:00
gsb
98719ec8cd Use data- attributes to preserve macro configs 2026-04-29 05:19:17 +00:00
gsb
2b88d2c10b Reimplement tests 2026-04-29 05:02:25 +00:00
gsb
4237a3f6a2 Add support for wysiwyg markdown preview 2026-04-29 05:01:51 +00:00
gsb
86d59877f1 feat: Add macro support
New: macros.ts with MacroDef, parseBlockMacro, matchInlineMacro,
buildMacroTags, processInlineMacros.

Macro syntax:
  @user                     — bare, no args
  @user()                   — empty parens, same as bare
  @npc(Goblin King)         — self-closing with args
  @style(box center         — block: no closing paren on first line
  Content here.             — content on subsequent lines
  )                         — closing paren on its own line

Unknown macro names now render as an error:
  <span class="ribbit-error">Unknown macro: @bogus</span>

The verbatim keyword causes the contents to render as literals and also
preserves line breaks.
2026-04-29 03:03:58 +00:00
gsb
df49ce7545 Single ribbit namespace instead of window globals
Use esbuild --global-name=ribbit to expose a single namespace.
2026-04-29 01:40:18 +00:00
gsb
f76ebbf2e5 feat: Add typed event system with on/off/emit
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.
2026-04-29 01:35:06 +00:00
gsb
ac7a698c4f Add themes support
Usage:

  const editor = new RibbitEditor({
    themes: [
        { name: 'dark', features: { sourceMode: false } },
        { name: 'minimal', tags: minimalTags },
    ],
    currentTheme: 'dark',
  });

The built-in theme is 'ribbit-default' and is always available.
Additional themes from the themes array are registered on top.
2026-04-29 01:20:55 +00:00
gsb
5983ce50fd Initial commit of ribbit library
Zero-dependency WYSIWYG markdown editor for the browser, extracted
from the ttfrog wiki engine. Initial commit.
2026-04-28 23:30:53 +00:00
5dc50c3c75 Initial commit 2026-04-28 16:21:33 -07:00