diff --git a/readme.md b/readme.md index 60c86ed..d4ce50d 100644 --- a/readme.md +++ b/readme.md @@ -26,15 +26,16 @@ The editor core, built with [TipTap](https://tiptap.dev) & [ProseMirror](https:/ ```tsx import { EditorContent, - useArticleEditor, - useCommentEditor, + articleEditorExtensions, + useEditor, } from '@matters/matters-editor' const Editor = () => { - const editor = useArticleEditor({ + const editor = useEditor({ editable: true, placeholder: 'Write your article here...', content: '', // initial content + extensions: articleEditorExtensions, onUpdate: async ({ editor, transaction }) => { const content = editor.getHTML() // update({ content }) diff --git a/src/editors/index.ts b/src/editors/index.ts index b4ab3cf..c14dbf2 100644 --- a/src/editors/index.ts +++ b/src/editors/index.ts @@ -1,71 +1,3 @@ export * from './extensions' export * from '@tiptap/react' export * from '@tiptap/suggestion' - -import type { EditorOptions } from '@tiptap/react' -import { useEditor } from '@tiptap/react' - -import { - articleEditorExtensions, - campaignEditorExtensions, - commentEditorExtensions, - momentEditorExtensions, -} from './extensions' - -type UseEditorProps = EditorOptions - -export const useArticleEditor = ({ - extensions, - content, - ...restProps -}: UseEditorProps) => { - const editor = useEditor({ - extensions: [...articleEditorExtensions, ...(extensions ?? [])], - content, - ...restProps, - }) - - return editor -} - -export const useCommentEditor = ({ - extensions, - content, - ...restProps -}: UseEditorProps) => { - const editor = useEditor({ - extensions: [...commentEditorExtensions, ...(extensions ?? [])], - content, - ...restProps, - }) - - return editor -} - -export const useMomentEditor = ({ - extensions, - content, - ...restProps -}: UseEditorProps) => { - const editor = useEditor({ - extensions: [...momentEditorExtensions, ...(extensions ?? [])], - content, - ...restProps, - }) - - return editor -} - -export const useCampaignEditor = ({ - extensions, - content, - ...restProps -}: UseEditorProps) => { - const editor = useEditor({ - extensions: [...campaignEditorExtensions, ...(extensions ?? [])], - content, - ...restProps, - }) - - return editor -}