import {useContext} from 'react'
import {EditorContext} from '../editor/editor_context'

export const useEditorContext = () => {
  const editorContext = useContext(EditorContext)

  if (!editorContext) {
    throw new Error(
      `The \`useEditor\` hook must be used inside the <EditorWrapper> component's context.`
    )
  }
  return editorContext
}
