An Obsidian plugin that adds a center-alignment toggle for Canvas text nodes (command palette and right-click menus). State is persisted in the Canvas data, so alignment survives reloads and restarts. Works on Windows, macOS, and Linux.
- Command palette: “Toggle Center Alignment for Canvas Node(s)” on selected text nodes.
- Context menus: right-click a text node or a multi-selection to toggle centering.
- Persistence:
centerAlignedflag stored in Canvas data; reapplied on load. - Light footprint: no HTML injection; uses CSS + stored flag.
- Copy the ocd-plugin zip into your vault at:
<YourVault>/.obsidian/plugins/ - Extract it so you end up with:
<YourVault>/.obsidian/plugins/ocd-plugin/containingmain.js,manifest.json,styles.css. - Reload Obsidian and enable the plugin in Settings → Community plugins.
- Copy the contents of
build/into your vault at:<YourVault>/.obsidian/plugins/ocd-plugin/main.jsmanifest.jsonstyles.css
- Reload Obsidian and enable the plugin in Settings → Community plugins.
npm install
npm run buildThen copy main.js, manifest.json, and styles.css to:
<YourVault>/.obsidian/plugins/ocd-plugin/
- Command palette: select one or more Canvas text nodes → run “Toggle Center Alignment for Canvas Node(s)”.
- Right-click a text node → “Toggle Center Alignment”.
- Right-click a selection of nodes → “Toggle Center Alignment”.
npm install # install dependencies
npm run dev # watch/build
npm run build # type-check then production buildOutputs go to main.js in the plugin root.
src/main.ts— plugin logicsrc/styles.css— centering stylesmanifest.json— Obsidian manifestesbuild.config.mjs/tsconfig.json— build/ts setup
Tested on Obsidian desktop (Canvas) and works cross-platform (Windows/macOS/Linux) since it’s pure JS/CSS + Obsidian APIs.
MIT