npm install @prosemirror-adapter/preact prosemirror-model prosemirror-state prosemirror-viewimport { ProsemirrorAdapterProvider, useNodeViewContext, useNodeViewFactory,} from '@prosemirror-adapter/preact';import { useEffect, useRef } from 'preact/hooks';import type { EditorState } from 'prosemirror-state';import { EditorView } from 'prosemirror-view'; function ParagraphView() { const { contentRef, selected } = useNodeViewContext(); return <div ref={contentRef} data-selected={selected || undefined} />;} function Editor({ state }: { state: EditorState }) { const host = useRef<HTMLDivElement>(null); const nodeViewFactory = useNodeViewFactory(); useEffect(() => { if (!host.current) return; const view = new EditorView(host.current, { state, nodeViews: { paragraph: nodeViewFactory({ component: ParagraphView, as: 'div', contentAs: 'p', }), }, }); return () => view.destroy(); }, [nodeViewFactory, state]); return <div ref={host} />;} export function EditorShell({ state }: { state: EditorState }) { return ( <ProsemirrorAdapterProvider> <Editor state={state} /> </ProsemirrorAdapterProvider> );}