import { Button, Card, Stack, Text, Wrap } from '@chakra-ui/react'; import isHotkey from 'is-hotkey'; import React, { KeyboardEvent, MouseEvent, useCallback, useMemo } from 'react'; import { createEditor, Descendant, Editor, Element as SlateElement, Transforms } from 'slate'; import { withHistory } from 'slate-history'; import { Editable, RenderElementProps, RenderLeafProps, Slate, useSlate, withReact } from 'slate-react'; import { CustomEditor, CustomElement, CustomElementType, CustomElementWithAlign, CustomTextKey } from '../types'; import { Prose } from './ui/prose'; export function EditorSlate() { return ( <> {/* Editor */} ); } const HOTKEYS: Record = { 'mod+b': 'bold', 'mod+i': 'italic', 'mod+u': 'underline', 'mod+`': 'code' }; const LIST_TYPES = ['numbered-list', 'bulleted-list'] as const; const TEXT_ALIGN_TYPES = ['left', 'center', 'right', 'justify'] as const; type AlignType = (typeof TEXT_ALIGN_TYPES)[number]; type ListType = (typeof LIST_TYPES)[number]; type CustomElementFormat = CustomElementType | AlignType | ListType; function EditorViewport() { const renderElement = useCallback((props: RenderElementProps) => , []); const renderLeaf = useCallback((props: RenderLeafProps) => , []); const editor = useMemo(() => withHistory(withReact(createEditor())), []); const initialValue: Descendant[] = [ { type: 'paragraph', children: [ { text: 'This is editable ' }, { text: 'rich', bold: true }, { text: ' text, ' }, { text: 'much', italic: true }, { text: ' better than a ' }, { text: '