( editor: SlateEditor, plugin: SlatePlugin )
| 13 | ) => React.ReactElement<any> | undefined; |
| 14 | |
| 15 | export const pluginRenderTextStatic = ( |
| 16 | editor: SlateEditor, |
| 17 | plugin: SlatePlugin |
| 18 | ): SlateRenderText => |
| 19 | function render(nodeProps) { |
| 20 | const { children, text } = nodeProps; |
| 21 | |
| 22 | if (text[plugin.node.type ?? plugin.key]) { |
| 23 | const Component = editor.meta.components?.[plugin.key] as any; |
| 24 | const Text = Component ?? SlateText; |
| 25 | |
| 26 | // const dataAttributes = getPluginDataAttributes(editor, plugin, text); |
| 27 | |
| 28 | const ctxProps = getRenderNodeStaticProps({ |
| 29 | attributes: { ...(text.attributes as any) }, |
| 30 | editor, |
| 31 | node: text, |
| 32 | path: nodeProps.path, |
| 33 | plugin, |
| 34 | props: nodeProps as any, |
| 35 | }) as any; |
| 36 | |
| 37 | const defaultProps = Component ? {} : { as: plugin.render?.as }; |
| 38 | |
| 39 | return ( |
| 40 | <Text {...defaultProps} {...ctxProps}> |
| 41 | {children} |
| 42 | </Text> |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | return children; |
| 47 | }; |
| 48 | |
| 49 | /** @see {@link RenderText} */ |
| 50 | export const pipeRenderTextStatic = ( |
no test coverage detected
searching dependent graphs…