Emdash source with visual editor image upload fix
Fixes: 1. media.ts: wrap placeholder generation in try-catch 2. toolbar.ts: check r.ok, display error message in popover
This commit is contained in:
32
packages/plugins/marketplace-test/src/index.ts
Normal file
32
packages/plugins/marketplace-test/src/index.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Marketplace Test Plugin for EmDash CMS
|
||||
*
|
||||
* A self-contained plugin designed for end-to-end testing of the marketplace
|
||||
* publish → audit → approval pipeline. Includes:
|
||||
* - Backend sandbox code (content:beforeSave hook)
|
||||
* - Icon and screenshot assets
|
||||
* - Full manifest with capabilities
|
||||
*
|
||||
* Usage:
|
||||
* emdash plugin bundle --dir packages/plugins/marketplace-test
|
||||
* emdash plugin publish dist/marketplace-test-0.1.0.tar.gz --registry <url>
|
||||
*/
|
||||
|
||||
import type { PluginDescriptor } from "emdash";
|
||||
|
||||
/**
|
||||
* Plugin factory -- returns a descriptor for the integration.
|
||||
*/
|
||||
export function marketplaceTestPlugin(): PluginDescriptor {
|
||||
return {
|
||||
id: "marketplace-test",
|
||||
version: "0.1.0",
|
||||
format: "standard",
|
||||
entrypoint: "@emdash-cms/plugin-marketplace-test/sandbox",
|
||||
capabilities: ["read:content", "write:content"],
|
||||
allowedHosts: [],
|
||||
storage: {
|
||||
events: { indexes: ["timestamp", "type"] },
|
||||
},
|
||||
};
|
||||
}
|
||||
55
packages/plugins/marketplace-test/src/sandbox-entry.ts
Normal file
55
packages/plugins/marketplace-test/src/sandbox-entry.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Sandbox Entry Point
|
||||
*
|
||||
* Canonical plugin implementation using the standard format.
|
||||
* Runs in both trusted (in-process) and sandboxed (isolate) modes.
|
||||
*/
|
||||
|
||||
import { definePlugin } from "emdash";
|
||||
import type { PluginContext } from "emdash";
|
||||
|
||||
interface HookEvent {
|
||||
content?: Record<string, unknown>;
|
||||
collection?: string;
|
||||
isNew?: boolean;
|
||||
}
|
||||
|
||||
export default definePlugin({
|
||||
hooks: {
|
||||
"content:beforeSave": {
|
||||
handler: async (event: HookEvent, ctx: PluginContext) => {
|
||||
ctx.log.info("[marketplace-test] beforeSave fired", {
|
||||
collection: event.collection,
|
||||
isNew: event.isNew,
|
||||
});
|
||||
|
||||
// Record execution in storage
|
||||
await ctx.storage.events.put(`hook-${Date.now()}`, {
|
||||
timestamp: new Date().toISOString(),
|
||||
type: "content:beforeSave",
|
||||
collection: event.collection,
|
||||
isNew: event.isNew,
|
||||
});
|
||||
|
||||
return event.content;
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
routes: {
|
||||
ping: {
|
||||
handler: async (_ctx: { input: unknown; request: unknown }, pluginCtx: PluginContext) => ({
|
||||
pong: true,
|
||||
pluginId: pluginCtx.plugin.id,
|
||||
timestamp: Date.now(),
|
||||
}),
|
||||
},
|
||||
|
||||
events: {
|
||||
handler: async (_ctx: { input: unknown; request: unknown }, pluginCtx: PluginContext) => {
|
||||
const result = await pluginCtx.storage.events.query({ limit: 10 });
|
||||
return { count: result.items.length, items: result.items };
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user