Download react-page/docs/examples/slate-plugin-src/plugins/code/index.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/slate-plugin-src/plugins/code/index.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/slate-plugin-src/plugins/code/index.tsx
-
curl -L -o index.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/slate-plugin-src/plugins/code/index.tsx
1.09 kB
| import { lazyLoad } from '@react-page/editor'; | |
| import React from 'react'; | |
| import createComponentPlugin from '../../pluginFactories/createComponentPlugin'; | |
| const Icon = lazyLoad(() => import('@mui/icons-material/Code')); | |
| const block = createComponentPlugin({ | |
| type: 'CODE/CODE', | |
| object: 'block', | |
| icon: <Icon />, | |
| label: 'Code Block', | |
| addToolbarButton: true, | |
| addHoverButton: false, | |
| deserialize: { | |
| tagName: 'code', | |
| }, | |
| Component: ({ children, attributes }) => { | |
| return ( | |
| <code | |
| {...attributes} | |
| style={{ | |
| display: 'block', | |
| overflow: 'scroll', | |
| }} | |
| > | |
| {children} | |
| </code> | |
| ); | |
| }, | |
| }); | |
| const mark = createComponentPlugin({ | |
| type: 'CODE/CODE', | |
| object: 'mark', | |
| icon: <Icon />, | |
| label: 'Code', | |
| addHoverButton: true, | |
| addToolbarButton: false, | |
| deserialize: { | |
| tagName: 'code', | |
| }, | |
| Component: ({ children, attributes }) => { | |
| return ( | |
| <code style={{ whiteSpace: 'pre-wrap' }} {...attributes}> | |
| {children} | |
| </code> | |
| ); | |
| }, | |
| }); | |
| export default { | |
| mark, | |
| block, | |
| }; | |