"use client";
'use strict';

const index = require('../../../../../../node_modules/.pnpm/@tiptap_react@3.15.3_@floating-ui_dom@1.7.4_@tiptap_core@3.20.0_@tiptap_pm@3.15.3__@tip_b42b5b2d59902d8a01cd4cc3e2d5dc64/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;
