mooreseditor のプラグインは、ユーザーが開いたプロジェクトから実行時に読み込まれる Vite/React 製の外部 bundle です。新規プラグインは npm 公開済みの SDK を使って作ります。
npm install @moorestech/mooreseditor-plugin-sdknpm: https://www.npmjs.com/package/@moorestech/mooreseditor-plugin-sdk
SDK はホストアプリとプラグインの実行時契約です。対象にする mooreseditor が同梱している SDK と同じバージョンを exact pin してください。例: "@moorestech/mooreseditor-plugin-sdk": "1.0.0"。固定リリース向けのプラグインでは ^1.0.0 のような範囲指定は避けます。
対応 starter は examples/external-plugin-starter です。
cp -R examples/external-plugin-starter ../my-mooreseditor-plugin
cd ../my-mooreseditor-plugin
npm install
npm run buildビルド成果物:
dist/index.js: プラグイン本体の ESM bundledist/index.css: Vite が CSS を出力した場合のスタイルplugin.json: mooreseditor が読む実行時 manifest
外部プラグインの最小構成は次の形です。
my-mooreseditor-plugin/
├── package.json
├── vite.config.ts
├── tsconfig.json
└── src/
├── pluginMetadata.ts
├── plugin-entry.tsx
└── MyPluginView.tsx
src/pluginMetadata.ts に id/name/version を集約します。
export const pluginMetadata = {
id: "my-plugin",
name: "My Plugin",
version: "0.1.0",
} as const;src/plugin-entry.tsx は PluginManifest を default export します。
import { MyPluginView } from "./MyPluginView";
import { pluginMetadata } from "./pluginMetadata";
import type {
HostAPI,
PluginManifest,
PluginView,
} from "@moorestech/mooreseditor-plugin-sdk";
const manifest: PluginManifest = {
...pluginMetadata,
createView(host: HostAPI): PluginView {
return {
render: () => <MyPluginView projectDir={host.projectDir} />,
save: async () => {
await host.saveProject(host.getColumns());
},
isDirty: () => false,
};
},
};
export default manifest;vite.config.ts では SDK の Vite helper を使います。
import react from "@vitejs/plugin-react";
import { mooresPlugin } from "@moorestech/mooreseditor-plugin-sdk/vite";
import { defineConfig, mergeConfig } from "vite";
import { pluginMetadata } from "./src/pluginMetadata";
export default defineConfig(
mergeConfig({ plugins: [react()] }, mooresPlugin(pluginMetadata)),
);mooresPlugin(pluginMetadata) は src/plugin-entry.tsx を entry にし、dist/index.js と plugin.json を出力します。React、Mantine、SDK などのホスト共有依存は bundle に含めず、mooreseditor 側の実行時インスタンスを使います。
プラグインは PluginManifest.createView(host) で HostAPI を受け取ります。
主な用途:
getColumns()/setColumns()で master カラムを読み書きするschemas/loadSchema(name)でロード済みスキーマを参照するprojectDir/masterDirでプロジェクトパスを読むmarkDirty()でホストへ未保存変更を通知するsaveExtraFile(relativePath, content)でプラグイン専用ファイルを保存するreadExtraFile(relativePath)でプラグイン専用ファイルを読むsaveProject(columns, extraFiles)で master データとプラグイン専用ファイルをまとめて保存する
saveExtraFile、readExtraFile、saveProject(..., extraFiles) に渡すパスはプロジェクト相対パスにしてください。絶対パスや .. でプロジェクト外へ出る指定は使いません。
ビルドした plugin.json と dist/ を、mooreseditor で開くプロジェクト配下へコピーします。
<project>/
├── mooreseditor.config.yml
└── plugins/
└── my-plugin/
├── plugin.json
└── dist/
├── index.js
└── index.css
<project>/mooreseditor.config.yml にプラグインを宣言します。
plugins:
- dir: ./plugins/my-plugin現在の production loader は plugins/<name> 形式のディレクトリをサポートしています。配置先はこの形にしてください。
ホスト共有依存は bundle に含めず、peerDependencies と devDependencies に置きます。
reactreact-dom@mantine/core@mantine/hooks@mantine/notifications@tabler/icons-react@moorestech/mooreseditor-plugin-sdk
プラグインだけが使う runtime package は通常の dependencies に置けます。SDK helper が共有依存として扱わない @tauri-apps/* などはプラグイン bundle に含まれます。
古い移行メモには、モノレポ内 workspace 前提、静的 import による暫定ロード、Vite/Rollup の手動 external 設定などが残っています。これらは実装移行の履歴であり、新規プラグイン作成手順ではありません。
新規プラグインでは次を使います。
- npm の
@moorestech/mooreseditor-plugin-sdk @moorestech/mooreseditor-plugin-sdk/viteのmooresPlugin(pluginMetadata)- Vite helper が生成する
plugin.json <project>/plugins/<name>/への配置とmooreseditor.config.ymlのplugins:宣言