Download react-page/docs/examples/slate-plugin-src/components/ReadOnlySlate.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 986 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/slate-plugin-src/components/ReadOnlySlate.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/slate-plugin-src/components/ReadOnlySlate.tsx
-
curl -L -o ReadOnlySlate.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-page/docs/examples/slate-plugin-src/components/ReadOnlySlate.tsx
986 Bytes
| import React from 'react'; | |
| import { SlateReactPresentation } from 'slate-react-presentation'; | |
| import type { SlateProps } from '../types/component'; | |
| import { useRenderElement, useRenderLeave } from './renderHooks'; | |
| const ReadOnlySlate = (props: SlateProps) => { | |
| const { plugins, defaultPluginType } = props; | |
| const renderElement = useRenderElement( | |
| { | |
| plugins, | |
| defaultPluginType, | |
| }, | |
| [] | |
| ); | |
| const renderLeaf = useRenderLeave({ plugins, readOnly: true }, []); | |
| // the div around is required to be consistent in styling with the default editor | |
| return ( | |
| <div | |
| style={{ | |
| position: 'relative', | |
| outline: 'none', | |
| whiteSpace: 'pre-wrap', | |
| overflowWrap: 'break-word', | |
| }} | |
| > | |
| <SlateReactPresentation | |
| renderElement={renderElement} | |
| renderLeaf={renderLeaf} | |
| value={props.data.slate} | |
| LeafWrapper={React.Fragment} | |
| /> | |
| </div> | |
| ); | |
| }; | |
| export default React.memo(ReadOnlySlate); | |