Download react-page/docs/examples/slate-plugin-src/slateEnhancer/withInline.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 802 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-page/docs/examples/slate-plugin-src/slateEnhancer/withInline.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-page/docs/examples/slate-plugin-src/slateEnhancer/withInline.ts
-
curl -L -o withInline.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-page/docs/examples/slate-plugin-src/slateEnhancer/withInline.ts
802 Bytes
| import type { Editor } from 'slate'; | |
| import type { SlatePlugin } from '../types/SlatePlugin'; | |
| const withInline = (plugins: SlatePlugin[]) => (editor: Editor) => { | |
| const { isInline, isVoid } = editor; | |
| editor.isInline = (element) => { | |
| return plugins.some( | |
| (plugin) => | |
| plugin.pluginType === 'component' && | |
| plugin.object === 'inline' && | |
| plugin.type === element.type | |
| ) | |
| ? true | |
| : isInline(element); | |
| }; | |
| editor.isVoid = (element) => { | |
| return plugins.some( | |
| (plugin) => | |
| plugin.pluginType === 'component' && | |
| (plugin.object === 'block' || plugin.object === 'inline') && | |
| plugin.type === element.type && | |
| plugin.isVoid | |
| ) | |
| ? true | |
| : isVoid(element); | |
| }; | |
| return editor; | |
| }; | |
| export default withInline; | |