react-code-dataset / react-page /docs /examples /slate-plugin-src /pluginFactories /createComponentPlugin.tsx
Download react-page/docs/examples/slate-plugin-src/pluginFactories/createComponentPlugin.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 789 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/slate-plugin-src/pluginFactories/createComponentPlugin.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/slate-plugin-src/pluginFactories/createComponentPlugin.tsx
-
curl -L -o createComponentPlugin.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/slate-plugin-src/pluginFactories/createComponentPlugin.tsx
789 Bytes
| /* eslint-disable @typescript-eslint/ban-types */ | |
| import type { SlatePlugin } from '../types/SlatePlugin'; | |
| import type { SlateComponentPluginDefinition } from '../types/slatePluginDefinitions'; | |
| function createComponentPlugin<T extends Record<string, unknown>>( | |
| def: SlateComponentPluginDefinition<T> | |
| ) { | |
| const customizablePlugin = function <CT extends Record<string, unknown> = T>( | |
| customize: ( | |
| t: SlateComponentPluginDefinition<T> | |
| ) => SlateComponentPluginDefinition<CT> = (d) => | |
| d as unknown as SlateComponentPluginDefinition<CT> | |
| ) { | |
| return createComponentPlugin(customize(def)); | |
| }; | |
| customizablePlugin.toPlugin = (): SlatePlugin => ({ | |
| ...def, | |
| pluginType: 'component', | |
| }); | |
| return customizablePlugin; | |
| } | |
| export default createComponentPlugin; | |