This repository is a template for building third-party plugins for Phaser
Editor v5. If you are an AI assistant helping someone extend their plugin,
read this first, then read the focused docs under docs/.
- A Phaser Editor plugin is a folder with a
plugin.jsonmanifest plus the JavaScript/CSS it lists. There is no webpack and no runtime npm. - Source is TypeScript compiled with
tscandoutFileinto a single concatenated file (<plugin>/_out/<id>.js). Each plugin is one TS project. - The editor API is consumed through bundled declaration snapshots in
types/— one.d.tsper editor plugin (colibri.d.ts,phasereditor2d.files.d.ts,phasereditor2d.phaser.d.ts, and the rest), so the full editor API is available. You do not have the editor source — treat these.d.tsfiles as the API source of truth and grep them instead of guessing at API shapes. They are refreshed withnpm run update-types(needsPHASEREDITOR5_HOME). - Code is organized with TypeScript namespaces (e.g.
myplugin.example), not ES modules. Files in a plugin share one namespace and are merged by the compiler; do not addimport/exportstatements between plugin files.
myplugin.example/ is a complete, working plugin. It is the best reference for
patterns — when adding something new, find the closest existing piece and copy
its structure:
src/ExamplePlugin.ts— thecolibri.Pluginsubclass; everything is registered inregisterExtensions(reg)viareg.addExtension(...).src/editors/TodoModel.ts— a data model + content-type id.src/editors/TodoEditor.ts— a custom HTML-basedFileEditorwith commands, a toolbar, and selection wiring.src/editors/TodoEditorOutlineProvider.ts— feeds the Outline view.src/editors/TodoEditorProperties.ts— Inspector property sections.src/editors/NewTodoFileExtension.ts— a New File wizard entry.
- Pick the extension point. See the catalog in
docs/extension-points.md. Almost every feature is a subclass ofcolibri.Extensionregistered inregisterExtensions. - Read the matching recipe in
docs/recipes/and the referenced example file. - Confirm the API by grepping
types/colibri.d.ts(ortypes/phasereditor2d.files.d.ts) for the classes/methods you use. - Write the code in a new file inside the plugin's
src/(same namespace), and register it inExamplePlugin.ts. - Build with
npm run build(ornpm run watch) and fix any type errors before finishing.
- IDs are namespaced:
"<pluginId>.<Name>"(e.g.myplugin.example.AddTask). Keep command/category/content-type ids unique and prefixed with the plugin id. - Register CSS by adding the path to the
stylesarray inplugin.json. - Theme-correct UI: separate layout (theme-agnostic) from color (scoped per
theme class:
.dark .X,.light .X, …). Never hardcode a single color. Seedocs/recipes/add-styles.md. - Prefer existing controls (
colibri.ui.controls) over hand-built DOM when possible — they inherit theming for free.
npm install # once
npm run build # compile all plugins (tsc -b)
npm run watch # rebuild on change while developingA change is not done until npm run build succeeds with no type errors.
- Don't introduce a bundler, ES module
import/export, or runtime npm deps. - Don't edit files under
types/to make code compile — those are API snapshots. Update them only to track a new editor version (seedocs/architecture.md). - Don't invent API: if it isn't in the
.d.ts, it isn't available.