Download react-page/docs/examples/slate-plugin-src/plugins/paragraphs/index.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-page/docs/examples/slate-plugin-src/plugins/paragraphs/index.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-page/docs/examples/slate-plugin-src/plugins/paragraphs/index.tsx
-
curl -L -o index.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-page/docs/examples/slate-plugin-src/plugins/paragraphs/index.tsx
1.07 kB
| import createComponentPlugin from '../../pluginFactories/createComponentPlugin'; | |
| type Align = 'left' | 'right' | 'center' | 'justify'; | |
| export const getAlignmentFromElement = (el: HTMLElement) => { | |
| const align = el?.style?.textAlign as Align; | |
| if (align) { | |
| return { | |
| align, | |
| }; | |
| } | |
| }; | |
| export default { | |
| paragraph: createComponentPlugin<{ | |
| align?: Align; | |
| }>({ | |
| type: 'PARAGRAPH/PARAGRAPH', | |
| label: 'Paragraph', | |
| object: 'block', | |
| addToolbarButton: false, | |
| addHoverButton: false, | |
| deserialize: { | |
| tagName: 'p', | |
| getData: getAlignmentFromElement, | |
| }, | |
| getStyle: ({ align }) => ({ textAlign: align }), | |
| Component: 'p', | |
| }), | |
| // currently only for deserialize | |
| pre: createComponentPlugin<{ | |
| align?: Align; | |
| }>({ | |
| type: 'PARAGRAPH/PRE', | |
| label: 'Pre', | |
| object: 'block', | |
| addToolbarButton: false, | |
| addHoverButton: false, | |
| deserialize: { | |
| tagName: 'pre', | |
| getData: getAlignmentFromElement, | |
| }, | |
| getStyle: ({ align }) => ({ textAlign: align }), | |
| Component: 'pre', | |
| }), | |
| }; | |