react-code-dataset / react-page /docs /examples /slate-plugin-src /pluginFactories /createMarkPlugin.tsx
Download react-page/docs/examples/slate-plugin-src/pluginFactories/createMarkPlugin.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 826 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/slate-plugin-src/pluginFactories/createMarkPlugin.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/slate-plugin-src/pluginFactories/createMarkPlugin.tsx
-
curl -L -o createMarkPlugin.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/slate-plugin-src/pluginFactories/createMarkPlugin.tsx
826 Bytes
| import type { ComponentType, PropsWithChildren } from 'react'; | |
| import React from 'react'; | |
| import createComponentPlugin from './createComponentPlugin'; | |
| type MarkPluginDefinition = { | |
| type: string; | |
| tagName: keyof JSX.IntrinsicElements; | |
| icon?: JSX.Element; | |
| hotKey?: string; | |
| label?: string; | |
| }; | |
| export default (markDef: MarkPluginDefinition) => { | |
| return createComponentPlugin({ | |
| type: markDef.type, | |
| object: 'mark', | |
| hotKey: markDef.hotKey, | |
| icon: markDef.icon, | |
| label: markDef.label, | |
| addToolbarButton: false, | |
| addHoverButton: true, | |
| deserialize: { | |
| tagName: markDef.tagName, | |
| }, | |
| Component: ({ children, attributes }) => { | |
| const Tag = | |
| markDef.tagName as unknown as ComponentType<PropsWithChildren>; | |
| return <Tag {...attributes}>{children}</Tag>; | |
| }, | |
| }); | |
| }; | |