Switchable Markdown editing mode for DokuWiki's toolbar — markdown buttons, shortcuts, and smart list continuation alongside the stock DokuWiki syntax tools.
  • PHP 50.8%
  • JavaScript 45.3%
  • Less 3.9%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
cblte 996b2f2c60 rename: mdeditor -> mdtoolbar
Renamed to match the repo (dokuwiki-plugin-mdtoolbar): base name, action
class, toolbar button types, JS globals, cookie key, data attribute, and
CSS classes all updated accordingly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-06 14:31:54 +02:00
images feat: initial mdeditor plugin 2026-10-06 14:29:48 +02:00
lang rename: mdeditor -> mdtoolbar 2026-10-06 14:31:54 +02:00
action.php rename: mdeditor -> mdtoolbar 2026-10-06 14:31:54 +02:00
plugin.info.txt rename: mdeditor -> mdtoolbar 2026-10-06 14:31:54 +02:00
README.md rename: mdeditor -> mdtoolbar 2026-10-06 14:31:54 +02:00
script.js rename: mdeditor -> mdtoolbar 2026-10-06 14:31:54 +02:00
style.less rename: mdeditor -> mdtoolbar 2026-10-06 14:31:54 +02:00

MdEditor Plugin for DokuWiki

Adds a switchable Markdown editing mode to DokuWiki's toolbar — for wikis that render pages with the Commonmark plugin but still want proper markdown editing ergonomics instead of DokuWiki's native toolbar/list behaviour.

Features

  • 🔀 Mode toggle button: switches the whole toolbar between DokuWiki syntax buttons (stock) and Markdown syntax buttons, live, no reload. Persisted in DokuWiki's own preference cookie, so it's remembered per browser, exactly like the editor size/wrap toggles.
  • 🖊️ Markdown toolbar buttons: bold, italic, strikethrough, inline code, link, image, headings (H1–H6), blockquote, bulleted/numbered/task lists, fenced code block, horizontal rule, table.
  • ⌨️ Keyboard shortcuts (while Markdown mode is active):
    • Ctrl/Cmd+B bold, Ctrl/Cmd+I italic, Ctrl/Cmd+K link, Ctrl/Cmd+` inline code
    • Ctrl/Cmd+Shift+X strikethrough, Ctrl/Cmd+Shift+K code block
    • Ctrl/Cmd+Shift+. blockquote, Ctrl/Cmd+Shift+8 bulleted list, Ctrl/Cmd+Shift+7 numbered list, Ctrl/Cmd+Shift+9 task list
    • Ctrl/Cmd+Alt+1…6 headings
  • ↩️ Smart list continuation on Enter (Markdown mode only): continues -, *, +, 1. and - [ ] items on the next line, renumbers ordered lists, and cancels the list when you press Enter on an empty item — mirroring DokuWiki's own native-syntax list handling (lib/scripts/editor.js), but for markdown markers instead of *.
  • 🧼 Zero effect on DokuWiki mode: all markdown-specific JS is gated on the active mode, so stock editing behaviour is untouched when toggled off.

How it works

  • action.php hooks TOOLBAR_DEFINE (AFTER only) and tags every button — DokuWiki's own defaults and the new markdown ones — with a mdtoolbar-dw-btn or mdtoolbar-md-btn class. Both sets are always present in the toolbar array.
    • This is deliberate, not an oversight: that array gets serialized into lib/exe/js.php, which DokuWiki caches as one shared file for every visitor (keyed by template + files, not by visitor/cookie/session). Branching the button array itself on a cookie would leak one visitor's mode choice to everyone else until the cache next invalidated. Keeping the PHP output unconditional avoids that trap entirely.
  • style.less hides one class or the other via a data-mdtoolbar-mode attribute on <html>. script.js flips that attribute (and the mdtoolbar_mode key in DokuWiki's DOKU_PREFS cookie, via the core DokuCookie JS helper) on toggle-button click — purely client-side, so it takes effect instantly with no page reload.
  • The Enter-key override in script.js attaches a capturing keydown listener on document. Capture-phase listeners on an ancestor run before bubble-phase listeners on the target itself, so our handler sees the key first and can stopPropagation() to stop DokuWiki core's own list handler (bound directly on #wiki__text) from also firing — no core files touched.

Installation

Copy (or symlink) this directory to lib/plugins/mdtoolbar in your DokuWiki install, named exactly mdtoolbar.

Compatibility

Markdown-syntax icons reuse DokuWiki's own toolbar icon set (bold.png, italic.png, strike.png, mono.png, link.png, image.png, hr.png, ul.png, ol.png, h1.png–h5.png) where available; a handful of custom SVGs cover toggle/quote/task-list/code-block/table.

License

MIT