MCPcopy
hub / github.com/udecode/plate / toPlatePlugin

Function toPlatePlugin

packages/core/src/react/plugin/toPlatePlugin.ts:70–107  ·  view source on GitHub ↗
(
  basePlugin: SlatePlugin<C>,
  extendConfig?:
    | ((ctx: PlatePluginContext<C>) => PlatePluginConfig<C, EO, EA, ET>)
    | PlatePluginConfig<C, EO, EA, ET>
)

Source from the content-addressed store, hash-verified

68 * with React-specific features defined in the extension configuration.
69 */
70export function toPlatePlugin<
71 C extends AnyPluginConfig,
72 EO = {},
73 EA = {},
74 ET = {},
75 ES = {},
76>(
77 basePlugin: SlatePlugin<C>,
78 extendConfig?:
79 | ((ctx: PlatePluginContext<C>) => PlatePluginConfig<C, EO, EA, ET>)
80 | PlatePluginConfig<C, EO, EA, ET>
81): PlatePlugin<
82 PluginConfig<
83 C['key'],
84 EO & InferOptions<C>,
85 EA & InferApi<C>,
86 ET & InferTransforms<C>,
87 ES & InferSelectors<C>
88 >
89> {
90 const plugin = { ...basePlugin } as unknown as PlatePlugin;
91
92 methodsToWrap.forEach((method) => {
93 const originalMethod = plugin[method];
94
95 (plugin as any)[method] = (...args: any[]) => {
96 const slatePlugin = originalMethod(...args);
97
98 return toPlatePlugin(slatePlugin);
99 };
100 });
101
102 if (!extendConfig) return plugin as any;
103
104 const extendedPlugin = plugin.extend(extendConfig as any);
105
106 return extendedPlugin as any;
107}
108
109type ExtendPluginConfig<C extends AnyPluginConfig = PluginConfig> = Omit<
110 Partial<

Callers 15

ColumnPlugin.tsxFile · 0.90
EmojiPlugin.tsxFile · 0.90
plugins.tsFile · 0.90
SlashPlugin.tsxFile · 0.90
createPlatePluginFunction · 0.90
ReactPlugin.tsFile · 0.90
HeadingPlugin.tsxFile · 0.90
KbdPlugin.tsxFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…