"use client";
'use strict';

const index = require('../../../../../../node_modules/.pnpm/@tiptap_react@3.15.3_@floating-ui_dom@1.7.4_@tiptap_core@3.15.3_@tiptap_pm@3.15.3__@tip_d7a2a9a319317617a8908309649a6dda/node_modules/@tiptap/react/dist/index.cjs');
const React = require('react');

function useTiptapEditor(providedEditor) {
  const { editor: coreEditor } = index.useCurrentEditor();
  const mainEditor = React.useMemo(
    () => providedEditor || coreEditor,
    [providedEditor, coreEditor]
  );
  const editorState = index.useEditorState({
    editor: mainEditor,
    selector(context) {
      if (!context.editor) {
        return {
          editor: null,
          editorState: void 0,
          canCommand: void 0
        };
      }
      return {
        editor: context.editor,
        editorState: context.editor.state,
        canCommand: context.editor.can
      };
    }
  });
  return editorState || { editor: null };
}

exports.useTiptapEditor = useTiptapEditor;
