diff --git a/packages/react/src/EditorContent.jsx b/packages/react/src/EditorContent.jsx index 64044ad6..3d7f48a2 100644 --- a/packages/react/src/EditorContent.jsx +++ b/packages/react/src/EditorContent.jsx @@ -1,37 +1,4 @@ -import React, { useState, useRef, useEffect } from 'react' -import ReactDOM from 'react-dom' -import { Editor } from './Editor' - -// export const EditorContent = ({ editor }) => { -// const editorContentRef = useRef(null) - -// useEffect(() => { -// if (editor && editor.options.element) { -// console.log('set editorContent element') - -// const element = editorContentRef.current - -// element.appendChild(editor.options.element.firstChild) - -// editor.setOptions({ -// element, -// }) - -// console.log({instance: this}) - -// // TODO: why setTimeout? -// setTimeout(() => { -// editor.createNodeViews() -// }, 0) -// } -// }) - -// return ( -//
-// ) -// } - - +import React from 'react' export class PureEditorContent extends React.Component { constructor(props) { @@ -72,5 +39,4 @@ export class PureEditorContent extends React.Component { } } - export const EditorContent = React.memo(PureEditorContent); diff --git a/packages/react/src/ReactNodeViewRenderer.ts b/packages/react/src/ReactNodeViewRenderer.ts index c4af67b4..c319fc69 100644 --- a/packages/react/src/ReactNodeViewRenderer.ts +++ b/packages/react/src/ReactNodeViewRenderer.ts @@ -7,7 +7,6 @@ import React from 'react' import ReactDOM from 'react-dom' import { Editor } from './Editor' import { ReactRenderer } from './ReactRenderer' -import test from './test' interface ReactNodeViewRendererOptions { stopEvent: ((event: Event) => boolean) | null, diff --git a/packages/react/src/components/Editor.jsx b/packages/react/src/components/Editor.jsx deleted file mode 100644 index 8eec95cd..00000000 --- a/packages/react/src/components/Editor.jsx +++ /dev/null @@ -1,34 +0,0 @@ -import React, { - useState, useRef, useEffect, createContext, useContext, -} from 'react' -import { Editor as Tiptap } from '@tiptap/core' - -export const EditorContext = createContext({}) - -export const useEditor = () => useContext(EditorContext) - -export const Editor = ({ - value, onChange, children, ...props -}) => { - const [editor, setEditor] = useState(null) - const editorRef = useRef(null) - - useEffect(() => { - const e = new Tiptap({ - element: editorRef.current, - content: value, - ...props, - }).on('transaction', () => { - onChange(e.getJSON()) - }) - - setEditor(e) - }, []) - - return ( -