Download react-page/docs/examples/plugins/customSlatePlugin.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/plugins/customSlatePlugin.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/plugins/customSlatePlugin.tsx
-
curl -L -o customSlatePlugin.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/plugins/customSlatePlugin.tsx
1.04 kB
| import { ColorPickerField } from '@react-page/editor'; | |
| import { pluginFactories } from '@react-page/plugins-slate'; | |
| import React from 'react'; | |
| export default pluginFactories.createComponentPlugin<{ | |
| color: string; | |
| }>({ | |
| addHoverButton: true, // whether to show it above the text when selected | |
| addToolbarButton: true, // whether to show it in the bottom toolbar | |
| type: 'SetColor', // a well defined string, this is kind of the id of the plugin | |
| object: 'mark', // mark is like a span, other options are inline and block | |
| icon: <span>Color</span>, // an icon to show | |
| label: 'Set Color', | |
| Component: 'span', // the component to render | |
| getStyle: ({ color }) => ({ color }), | |
| controls: { | |
| // identical to custom cell plugins | |
| type: 'autoform', | |
| schema: { | |
| type: 'object', | |
| required: ['color'], | |
| properties: { | |
| color: { | |
| uniforms: { | |
| component: ColorPickerField, | |
| }, | |
| default: 'rgba(0,0,255,1)', | |
| type: 'string', | |
| }, | |
| }, | |
| }, | |
| }, | |
| }); | |