MCPcopy
hub / github.com/GrapesJS/grapesjs / usePlugin

Function usePlugin

packages/core/src/plugin_manager/utils.ts:98–114  ·  view source on GitHub ↗
(plugin: P, opts?: P extends Plugin<infer C> ? C : {})

Source from the content-addressed store, hash-verified

96};
97
98export const usePlugin = <P extends Plugin<any> | string>(plugin: P, opts?: P extends Plugin<infer C> ? C : {}) => {
99 const options = opts || {};
100 const wrapped: PluginWithMeta<any> = (editor: Editor) => {
101 const pluginResult = getPlugin(plugin);
102
103 if (pluginResult) {
104 pluginResult(editor, options);
105 } else {
106 logPluginWarn(editor, plugin as string);
107 }
108 };
109
110 const id = typeof plugin === 'string' ? plugin : plugin.__gjsPluginId;
111 wrapped.__gjsPluginMeta = { id, plugin, options };
112
113 return wrapped;
114};

Callers 1

index.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected