'use client' import * as React from 'react' import type { Editor } from '@tiptap/react' // Whether the phone focus view's dock shows the selected block's actions instead of the formatting // keys (Paper `Posts / New · Writing · Block / Mobile`). A tap on the block handle enters it; a tap // in the text or typing returns to formatting, as does the dock's close button. export function useContentEditorBlockMode(editor: Editor | null) { const [isBlockMode, setIsBlockMode] = React.useState(false) React.useEffect(() => { if (!editor) return const dom = editor.view.dom const exit = () => setIsBlockMode(false) dom.addEventListener('pointerdown', exit) dom.addEventListener('beforeinput', exit) return () => { dom.removeEventListener('pointerdown', exit) dom.removeEventListener('beforeinput', exit) } }, [editor]) return { isBlockMode, enterBlockMode: () => setIsBlockMode(true), exitBlockMode: () => setIsBlockMode(false) } }