Official plugin repository for math-painter.
Plugins here are built to static ES modules and hosted on Cloudflare Pages; the
app's Plugins panel fetches plugins.json and installs them with one click.
plugins/<name>/
mp.config.json # { name, title, description, version, minApi, entry, author }
index.ts # export default function activate(mp: MathPainter)
<shape>.ts # a ShapeDefinition
<tool>.ts # a Tool
shared/
types.ts # the frozen MathPainter / ShapeDefinition / Tool contract
geom.ts # small vector helpers
style.ts # DEFAULT_STYLE
plugins.json # the official index (deployed to dist/plugins.json)
Each plugin is multi-file TypeScript for maintainability. The build bundles
it into a single self-contained ES module with esbuild, so the host app
loads one file (via a blob URL) with no runtime relative-import resolution.
Shared helpers and any npm dependency (e.g. katex) are inlined by the bundle.
External assets (CSS/fonts) are fetched from globalThis.__MP_EXT_BASE__ — see
math-painter/EXTENSIONS.md. The host contract shared/types.ts mirrors
math-painter/src/core/extension.ts — keep the two in sync.
| 插件 | 说明 |
|---|---|
arrow |
带箭头的向量/有向线段工具(快捷键 y) |
latex |
内置标签的 KaTeX 公式渲染器(无单独形状/工具),标签里写 $...$ 即排版 |
export |
SVG / PNG 导出:白底黑字、自动裁剪到内容边界(快捷键 P,也有工具栏按钮) |
Full plugin-development docs live in docs/, split by
language for the best experience:
Read them before authoring a plugin.
- Copy
plugins/arrowtoplugins/<your-name>. - Edit
mp.config.json(uniquename,entry: "<your-name>/index.js",minApi≤ currentAPI_VERSION). - Implement
index.ts(export default function activate(mp)), yourShapeDefinition, and yourTool. - Add an entry to
plugins.json.
npm install
npm run build # esbuild bundles each plugin -> dist/<name>/index.js,
# copies KaTeX CSS/fonts + plugins.json into dist/Deploy dist/ to Cloudflare Pages:
- Dashboard: connect this repo, build command
npm install && npm run build, output directorydist. - Or CLI:
npx wrangler pages deploy dist.
The deployed base URL must match what the app expects
(https://mp-ext.doi.l.cd by default; overridable in-app via the
math-painter:plugin-base localStorage setting for mirrors).