react-code-dataset / react-page /docs /examples /slate-plugin-src /pluginFactories /createHeadingsPlugin.tsx
Download react-page/docs/examples/slate-plugin-src/pluginFactories/createHeadingsPlugin.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 808 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/slate-plugin-src/pluginFactories/createHeadingsPlugin.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/slate-plugin-src/pluginFactories/createHeadingsPlugin.tsx
-
curl -L -o createHeadingsPlugin.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/slate-plugin-src/pluginFactories/createHeadingsPlugin.tsx
808 Bytes
| import type { SlateComponentPluginDefinition } from '../types/slatePluginDefinitions'; | |
| import type { HtmlBlockData } from './createSimpleHtmlBlockPlugin'; | |
| import createSimpleHtmlBlockPlugin from './createSimpleHtmlBlockPlugin'; | |
| export type HeadingsDef<T> = { | |
| level: 1 | 2 | 3 | 4 | 5 | 6; | |
| } & Pick< | |
| SlateComponentPluginDefinition<HtmlBlockData<T>>, | |
| 'type' | 'getInitialData' | 'icon' | |
| >; | |
| // eslint-disable-next-line @typescript-eslint/ban-types | |
| function createHeadingsPlugin<T = {}>(def: HeadingsDef<T>) { | |
| return createSimpleHtmlBlockPlugin<T>({ | |
| type: def.type, | |
| hotKey: 'mod+' + def.level, | |
| replaceWithDefaultOnRemove: true, | |
| icon: def.icon, | |
| label: `Heading ${def.level}`, | |
| tagName: ('h' + def.level) as keyof JSX.IntrinsicElements, | |
| }); | |
| } | |
| export default createHeadingsPlugin; | |