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%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
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> |
||
| images | ||
| lang | ||
| action.php | ||
| plugin.info.txt | ||
| README.md | ||
| script.js | ||
| style.less | ||
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+Bbold,Ctrl/Cmd+Iitalic,Ctrl/Cmd+Klink,Ctrl/Cmd+`inline codeCtrl/Cmd+Shift+Xstrikethrough,Ctrl/Cmd+Shift+Kcode blockCtrl/Cmd+Shift+.blockquote,Ctrl/Cmd+Shift+8bulleted list,Ctrl/Cmd+Shift+7numbered list,Ctrl/Cmd+Shift+9task listCtrl/Cmd+Alt+1…6headings
- ↩️ 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.phphooksTOOLBAR_DEFINE(AFTERonly) and tags every button — DokuWiki's own defaults and the new markdown ones — with amdtoolbar-dw-btnormdtoolbar-md-btnclass. 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.
- This is deliberate, not an oversight: that array gets serialized into
style.lesshides one class or the other via adata-mdtoolbar-modeattribute on<html>.script.jsflips that attribute (and themdtoolbar_modekey in DokuWiki'sDOKU_PREFScookie, via the coreDokuCookieJS helper) on toggle-button click — purely client-side, so it takes effect instantly with no page reload.- The Enter-key override in
script.jsattaches a capturingkeydownlistener ondocument. Capture-phase listeners on an ancestor run before bubble-phase listeners on the target itself, so our handler sees the key first and canstopPropagation()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