From a1f519d8ca57fb567c42102e134a7958f931e92f Mon Sep 17 00:00:00 2001 From: fantasticit Date: Fri, 3 Jun 2022 16:35:31 +0800 Subject: [PATCH] tiptap: remove unused code --- .../tiptap/core/thritypart/react/index.tsx | 5 --- .../core/thritypart/react/useEditor.tsx | 42 ------------------- 2 files changed, 47 deletions(-) delete mode 100644 packages/client/src/tiptap/core/thritypart/react/index.tsx delete mode 100644 packages/client/src/tiptap/core/thritypart/react/useEditor.tsx diff --git a/packages/client/src/tiptap/core/thritypart/react/index.tsx b/packages/client/src/tiptap/core/thritypart/react/index.tsx deleted file mode 100644 index c04c4e6..0000000 --- a/packages/client/src/tiptap/core/thritypart/react/index.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { EditorContent, NodeViewContent, NodeViewWrapper } from '@tiptap/react'; - -import { Editor, useEditor } from './useEditor'; - -export { Editor, EditorContent, NodeViewContent, NodeViewWrapper, useEditor }; diff --git a/packages/client/src/tiptap/core/thritypart/react/useEditor.tsx b/packages/client/src/tiptap/core/thritypart/react/useEditor.tsx deleted file mode 100644 index 7994671..0000000 --- a/packages/client/src/tiptap/core/thritypart/react/useEditor.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { EditorOptions } from '@tiptap/core'; -import { Editor as BuiltInEditor } from '@tiptap/react'; -import { EventEmitter } from 'helpers/event-emitter'; -import { DependencyList, useEffect, useState } from 'react'; - -function useForceUpdate() { - const [, setValue] = useState(0); - - return () => setValue((value) => value + 1); -} - -export class Editor extends BuiltInEditor { - public eventEmitter: EventEmitter = new EventEmitter(); -} - -export const useEditor = (options: Partial = {}, deps: DependencyList = []) => { - const [editor, setEditor] = useState(null); - const forceUpdate = useForceUpdate(); - - useEffect(() => { - const instance = new Editor(options); - - setEditor(instance); - - if (!options.editable) { - instance.on('transaction', () => { - requestAnimationFrame(() => { - requestAnimationFrame(() => { - forceUpdate(); - }); - }); - }); - } - - return () => { - instance.destroy(); - }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, deps); - - return editor; -};