import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { createEditor } from 'slate'; import { withReact, Slate, Editable, RenderElementProps, RenderLeafProps, } from 'slate-react'; type ExtendedRenderElementProps = RenderElementProps & { mode?: string }; export const renderElement = ({ attributes, children, element, mode, }: ExtendedRenderElementProps) => { switch (element.type) { case 'block-quote': return
{children}; case 'heading-2': return (
{children}
);
case 'code-line':
return {children}
); } }; export const renderLeaf = ({ attributes, children, leaf }: RenderLeafProps) => { let el = children; if (leaf.bold) { el = {el}; } if (leaf.italic) { el = {el}; } if (leaf.underline) { el = {el}; } if (leaf.link) { el = ( {el} ); } return {el}; }; interface ReadOnlySlateProps { content: any; mode?: string; } const ReadOnlySlate: React.FC