@wingleeio/ori-react 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useEditor.ts","../src/hooks.ts","../src/renderers.tsx","../src/BlockView.tsx","../src/Overlay.tsx","../src/internal.ts","../src/keymap.ts","../src/NoteEditor.tsx"],"names":["useRef","EditorController","createCanvasMeasurer","useEffect","useSyncExternalStore","createContext","useContext","jsx","isCollapsed","useMemo","forwardRef","NoteEditor","useState","useImperativeHandle","useLayoutEffect","jsxs"],"mappings":";;;;;;;AA0BO,SAAS,SAAA,CAAU,OAAA,GAA4B,EAAC,EAAqB;AAC1E,EAAA,MAAM,GAAA,GAAMA,aAAgC,IAAI,CAAA;AAChD,EAAA,IAAI,GAAA,CAAI,YAAY,IAAA,EAAM;AACxB,IAAA,GAAA,CAAI,OAAA,GAAU,IAAIC,wBAAA,CAAiB;AAAA,MACjC,KAAK,OAAA,CAAQ,GAAA;AAAA,MACb,QAAA,EAAU,OAAA,CAAQ,QAAA,IAAYC,4BAAA,EAAqB;AAAA,MACnD,YAAY,OAAA,CAAQ,UAAA;AAAA,MACpB,UAAU,OAAA,CAAQ,QAAA;AAAA,MAClB,cAAc,OAAA,CAAQ,YAAA;AAAA,MACtB,QAAQ,OAAA,CAAQ;AAAA,KACjB,CAAA;AAAA,EACH;AACA,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,SAAS,GAAA,CAAI,OAAA;AACnB,IAAA,OAAO,MAAM,QAAQ,OAAA,EAAQ;AAAA,EAC/B,CAAA,EAAG,EAAE,CAAA;AACL,EA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A,KAAA,EAAO,CAAC,CAAA,KAAM;AACZ,kBAAA,CAAA,CAAE,cAAA,EAAe;AACjB,kBAAA,CAAA,CAAE,aAAA,CAAc,OAAA,CAAQ,YAAA,EAAc,MAAA,CAAO,iBAAiB,CAAA;AAC9D,kBAAA,MAAA,CAAO,cAAA,EAAe;AAAA,gBACxB,CAAA;AAAA,gBACA,OAAA,EAAS,CAAC,CAAA,KAAM;AACd,kBAAA,CAAA,CAAE,cAAA,EAAe;AACjB,kBAAA,SAAA,CAAU,MAAA,EAAQ,CAAA,CAAE,aAAA,CAAc,OAAA,CAAQ,YAAY,CAAC,CAAA;AAAA,gBACzD;AAAA;AAAA,aACF,GACE;AAAA;AAAA;AAAA;AACN;AAAA,GACF,EACF,GACA,CAAA,EACF,CAAA;AAEJ,CAAC","file":"index.cjs","sourcesContent":["import {\n EditorController,\n createCanvasMeasurer,\n type EditorSchema,\n type Measurer,\n type Typography,\n} from \"@wingleeio/ori-core\";\nimport { useEffect, useRef } from \"react\";\nimport type * as Y from \"yjs\";\n\nexport interface UseEditorOptions {\n /** Existing note `Y.Doc`. When switching notes, remount via `key` instead. */\n doc?: Y.Doc;\n typography?: Typography;\n measurer?: Measurer;\n overscan?: number;\n blockSpacing?: number;\n /** Custom block/atom nodes, merged over the built-ins. */\n schema?: Partial<EditorSchema>;\n}\n\n/**\n * Create (once) and own an {@link EditorController} for the lifetime of the\n * component. The controller is destroyed on unmount. To switch documents, give\n * the hosting component a `key` so it remounts with a fresh controller.\n */\nexport function useEditor(options: UseEditorOptions = {}): EditorController {\n const ref = useRef<EditorController | null>(null);\n if (ref.current === null) {\n ref.current = new EditorController({\n doc: options.doc,\n measurer: options.measurer ?? createCanvasMeasurer(),\n typography: options.typography,\n overscan: options.overscan,\n blockSpacing: options.blockSpacing,\n schema: options.schema,\n });\n }\n useEffect(() => {\n const editor = ref.current;\n return () => editor?.destroy();\n }, []);\n return ref.current;\n}\n","import type { EditorController, EditorSnapshot, Marks } from \"@wingleeio/ori-core\";\nimport { useSyncExternalStore } from \"react\";\n\n/** Subscribe a component to the controller's snapshot stream. */\nexport function useEditorSnapshot(editor: EditorController): EditorSnapshot {\n return useSyncExternalStore(editor.subscribe, editor.getSnapshot, editor.getSnapshot);\n}\n\n/**\n * The marks active at the current selection. Recomputed whenever the editor\n * notifies (selection move, edit, or pending-mark toggle), so toolbars stay in\n * sync without their own subscription.\n */\nexport function useActiveMarks(editor: EditorController): Marks {\n const snapshot = useEditorSnapshot(editor);\n // `revision` changes on every notify; reading it ties this to the store.\n void snapshot.revision;\n return editor.getActiveMarks();\n}\n","import type { BlockLayout, EditorController, InlineAtom, VisibleBlock } from \"@wingleeio/ori-core\";\nimport { createContext, useContext, type ReactNode } from \"react\";\n\n/** Props for a custom block renderer (atomic nodes: divider, image, …). */\nexport interface BlockRendererProps {\n editor: EditorController;\n block: VisibleBlock;\n /** The block's synthetic layout (atomic blocks: one line, no fragments). */\n layout: BlockLayout;\n}\nexport type BlockRenderer = (props: BlockRendererProps) => ReactNode;\n\n/** Props for a custom inline-atom renderer (mention chip, inline math, …). */\nexport interface AtomRendererProps {\n editor: EditorController;\n atom: InlineAtom;\n}\nexport type AtomRenderer = (props: AtomRendererProps) => ReactNode;\n\nexport interface Renderers {\n blocks: Record<string, BlockRenderer>;\n atoms: Record<string, AtomRenderer>;\n}\n\nconst EMPTY: Renderers = { blocks: {}, atoms: {} };\n\nconst RenderersContext = createContext<Renderers>(EMPTY);\nexport const RenderersProvider = RenderersContext.Provider;\nexport const useRenderers = (): Renderers => useContext(RenderersContext);\n","import type { EditorController, Fragment, InlineAtom, Line, VisibleBlock } from \"@wingleeio/ori-core\";\nimport type { CSSProperties } from \"react\";\nimport { useRenderers, type AtomRenderer } from \"./renderers\";\n\nfunction fragmentStyle(frag: Fragment): CSSProperties {\n const f = frag.font;\n const decoration: string[] = [];\n if (frag.marks.underline) decoration.push(\"underline\");\n if (frag.marks.strike) decoration.push(\"line-through\");\n return {\n fontFamily: f.fontFamily,\n fontSize: f.fontSize,\n fontWeight: f.fontWeight,\n fontStyle: f.italic ? \"italic\" : \"normal\",\n letterSpacing: f.letterSpacing || undefined,\n textDecorationLine: decoration.length ? decoration.join(\" \") : undefined,\n };\n}\n\n/** An inline atom, sized to the exact width Pretext laid out for it. */\nfunction AtomFragment({\n editor,\n atom,\n render,\n}: {\n editor: EditorController;\n atom: InlineAtom;\n render?: AtomRenderer;\n}) {\n return (\n <span\n className=\"ori-atom\"\n style={{\n display: \"inline-block\",\n width: atom.width,\n verticalAlign: \"middle\",\n whiteSpace: \"normal\",\n }}\n >\n {render ? render({ editor, atom }) : null}\n </span>\n );\n}\n\nfunction LineView({\n line,\n editor,\n atoms,\n}: {\n line: Line;\n editor: EditorController;\n atoms: Record<string, AtomRenderer>;\n}) {\n return (\n <div\n className=\"ori-line\"\n style={{ height: line.height, lineHeight: `${line.height}px`, whiteSpace: \"pre\" }}\n >\n {line.fragments.map((frag) => {\n if (frag.atom) {\n return (\n <AtomFragment\n key={frag.start}\n editor={editor}\n atom={frag.atom}\n render={atoms[frag.atom.type]}\n />\n );\n }\n const className = [\"ori-frag\"];\n if (frag.marks.code) className.push(\"ori-frag-code\");\n if (frag.marks.link) className.push(\"ori-frag-link\");\n return (\n <span\n key={frag.start}\n className={className.join(\" \")}\n style={fragmentStyle(frag)}\n data-start={frag.start}\n >\n {frag.text}\n </span>\n );\n })}\n </div>\n );\n}\n\n/**\n * Render a visible block. Custom (atomic) block types use their registered\n * renderer; text blocks render materialized Pretext lines, with any inline\n * atoms drawn by their registered atom renderer at the measured width.\n */\nexport function BlockView({ editor, block }: { editor: EditorController; block: VisibleBlock }) {\n const { blocks, atoms } = useRenderers();\n const layout = editor.getLayout(block.id);\n if (!layout) return null;\n const custom = blocks[block.type];\n return (\n <div\n className={`ori-block ori-block-${block.type}`}\n data-block-id={block.id}\n style={{\n position: \"absolute\",\n top: block.top,\n left: 0,\n width: \"100%\",\n height: block.height,\n }}\n >\n {custom\n ? custom({ editor, block, layout })\n : layout.lines.map((line) => (\n <LineView key={line.index} line={line} editor={editor} atoms={atoms} />\n ))}\n </div>\n );\n}\n","import type { EditorController, EditorSnapshot } from \"@wingleeio/ori-core\";\nimport { isCollapsed } from \"@wingleeio/ori-core\";\n\n/** Selection rectangles for visible blocks (rendered beneath the text). */\nexport function SelectionLayer({\n editor,\n snapshot,\n}: {\n editor: EditorController;\n snapshot: EditorSnapshot;\n}) {\n // Tie recomputation to the snapshot revision.\n void snapshot.revision;\n const rects = editor.selectionRectsForViewport();\n if (rects.length === 0) return null;\n return (\n <div className=\"ori-selection-layer\" aria-hidden>\n {rects.map((r, i) => (\n <div\n key={`${r.blockId}:${i}`}\n className=\"ori-selection-rect\"\n style={{ position: \"absolute\", left: r.x, top: r.y, width: r.width, height: r.height }}\n />\n ))}\n </div>\n );\n}\n\n/** Blinking caret, shown only when focused and the selection is collapsed. */\nexport function CaretLayer({\n editor,\n snapshot,\n focused,\n}: {\n editor: EditorController;\n snapshot: EditorSnapshot;\n focused: boolean;\n}) {\n const sel = snapshot.selection;\n if (!focused || !sel || !isCollapsed(sel)) return null;\n const rect = editor.caretRect();\n if (!rect) return null;\n return (\n <div\n className=\"ori-caret\"\n style={{ position: \"absolute\", left: rect.x, top: rect.y, height: rect.height }}\n aria-hidden\n />\n );\n}\n","import { useMemo, useRef } from \"react\";\n\n/**\n * Wrap a frequently-changing callback in a stable identity so it can be used in\n * effect dependency lists without re-subscribing. The latest closure is always\n * invoked.\n */\nexport function useCallbackRef<Args extends unknown[], Return>(\n fn: (...args: Args) => Return,\n): (...args: Args) => Return {\n const ref = useRef(fn);\n ref.current = fn;\n return useMemo(() => (...args: Args) => ref.current(...args), []);\n}\n","import type { EditorController } from \"@wingleeio/ori-core\";\nimport type { KeyboardEvent } from \"react\";\n\nexport interface KeymapOptions {\n readOnly?: boolean;\n}\n\n/** Insert clipboard text, mapping newlines to paragraph splits. */\nexport function pasteText(editor: EditorController, text: string): void {\n const parts = text.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n editor.insertText(parts[0]);\n for (let i = 1; i < parts.length; i += 1) {\n editor.insertParagraphBreak();\n if (parts[i]) editor.insertText(parts[i]);\n }\n}\n\n/**\n * Translate a keyboard event into editor commands. Character insertion is left\n * to the textarea `input`/`composition` events; this handles control keys,\n * navigation and formatting shortcuts only.\n *\n * Returns true if the event was handled (and `preventDefault` was called).\n */\nexport function handleKeyDown(\n editor: EditorController,\n e: KeyboardEvent,\n opts: KeymapOptions = {},\n): boolean {\n if (e.nativeEvent.isComposing) return false;\n // Alt/Option combos are reserved for app-level shortcuts (e.g. note switching),\n // so let them bubble instead of moving the caret.\n if (e.altKey) return false;\n const mod = e.metaKey || e.ctrlKey;\n const shift = e.shiftKey;\n const ro = !!opts.readOnly;\n\n if (mod) {\n switch (e.key.toLowerCase()) {\n case \"b\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"bold\");\n return true;\n case \"i\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"italic\");\n return true;\n case \"u\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"underline\");\n return true;\n case \"e\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"code\");\n return true;\n case \"a\":\n e.preventDefault();\n editor.selectAll();\n return true;\n case \"z\":\n e.preventDefault();\n if (!ro) (shift ? editor.redo() : editor.undo());\n return true;\n case \"y\":\n e.preventDefault();\n if (!ro) editor.redo();\n return true;\n case \"arrowleft\":\n e.preventDefault();\n editor.moveCaret(\"lineStart\", shift);\n return true;\n case \"arrowright\":\n e.preventDefault();\n editor.moveCaret(\"lineEnd\", shift);\n return true;\n // Let the browser raise copy/cut/paste on the textarea.\n case \"c\":\n case \"x\":\n case \"v\":\n return false;\n default:\n return false;\n }\n }\n\n switch (e.key) {\n case \"Backspace\":\n e.preventDefault();\n if (!ro) editor.deleteBackward();\n return true;\n case \"Delete\":\n e.preventDefault();\n if (!ro) editor.deleteForward();\n return true;\n case \"Enter\":\n e.preventDefault();\n if (!ro) editor.insertParagraphBreak();\n return true;\n case \"Tab\":\n e.preventDefault();\n if (!ro) editor.insertText(\" \");\n return true;\n case \"ArrowLeft\":\n e.preventDefault();\n editor.moveCaret(\"left\", shift);\n return true;\n case \"ArrowRight\":\n e.preventDefault();\n editor.moveCaret(\"right\", shift);\n return true;\n case \"ArrowUp\":\n e.preventDefault();\n editor.moveCaret(\"up\", shift);\n return true;\n case \"ArrowDown\":\n e.preventDefault();\n editor.moveCaret(\"down\", shift);\n return true;\n case \"Home\":\n e.preventDefault();\n editor.moveCaret(\"lineStart\", shift);\n return true;\n case \"End\":\n e.preventDefault();\n editor.moveCaret(\"lineEnd\", shift);\n return true;\n default:\n return false;\n }\n}\n","import type { EditorController } from \"@wingleeio/ori-core\";\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type CompositionEvent,\n type FormEvent,\n type KeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n} from \"react\";\nimport { BlockView } from \"./BlockView\";\nimport { CaretLayer, SelectionLayer } from \"./Overlay\";\nimport { useEditorSnapshot } from \"./hooks\";\nimport { useCallbackRef } from \"./internal\";\nimport { handleKeyDown, pasteText } from \"./keymap\";\nimport { RenderersProvider, type AtomRenderer, type BlockRenderer } from \"./renderers\";\n\nexport interface NoteEditorProps {\n editor: EditorController;\n className?: string;\n style?: CSSProperties;\n /** Max width of the centered content column, in px. */\n maxWidth?: number;\n placeholder?: string;\n autoFocus?: boolean;\n readOnly?: boolean;\n /** Renderers for custom (atomic) block node types. */\n blockRenderers?: Record<string, BlockRenderer>;\n /** Renderers for custom inline atom types. */\n atomRenderers?: Record<string, AtomRenderer>;\n}\n\n/** A viewport-space rectangle (client coordinates). */\nexport interface ViewportRect {\n top: number;\n left: number;\n right: number;\n bottom: number;\n width: number;\n height: number;\n}\n\n/** Imperative handle for building floating UI (slash / selection menus). */\nexport interface NoteEditorHandle {\n focus(): void;\n /** Caret position in viewport coordinates, or null if unavailable. */\n getCaretRect(): { x: number; y: number; height: number } | null;\n /** Bounding box of the current selection in viewport coordinates, or null. */\n getSelectionRect(): ViewportRect | null;\n /** The scrolling element, for scroll-aware positioning. */\n getScrollElement(): HTMLElement | null;\n}\n\n/**\n * A fully virtualized, Pretext-laid-out note editor. Renders only the blocks\n * intersecting the viewport; selection and caret are drawn from logical state\n * so they remain correct across offscreen content.\n */\nexport const NoteEditor = forwardRef<NoteEditorHandle, NoteEditorProps>(function NoteEditor(\n {\n editor,\n className,\n style,\n maxWidth = 720,\n placeholder = \"Start writing…\",\n autoFocus,\n readOnly,\n blockRenderers,\n atomRenderers,\n },\n ref,\n) {\n const snapshot = useEditorSnapshot(editor);\n const renderers = useMemo(\n () => ({ blocks: blockRenderers ?? {}, atoms: atomRenderers ?? {} }),\n [blockRenderers, atomRenderers],\n );\n const scrollerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const draggingRef = useRef(false);\n const composingRef = useRef(false);\n const [focused, setFocused] = useState(false);\n\n useImperativeHandle(\n ref,\n (): NoteEditorHandle => ({\n focus: () => inputRef.current?.focus(),\n getCaretRect: () => {\n const c = editor.caretRect();\n const content = contentRef.current;\n if (!c || !content) return null;\n const r = content.getBoundingClientRect();\n return { x: r.left + c.x, y: r.top + c.y, height: c.height };\n },\n getSelectionRect: () => {\n const content = contentRef.current;\n if (!content) return null;\n const rects = editor.selectionRectsForViewport();\n if (rects.length === 0) return null;\n const r = content.getBoundingClientRect();\n let top = Infinity;\n let left = Infinity;\n let bottom = -Infinity;\n let right = -Infinity;\n for (const rc of rects) {\n top = Math.min(top, r.top + rc.y);\n left = Math.min(left, r.left + rc.x);\n bottom = Math.max(bottom, r.top + rc.y + rc.height);\n right = Math.max(right, r.left + rc.x + rc.width);\n }\n return { top, left, right, bottom, width: right - left, height: bottom - top };\n },\n getScrollElement: () => scrollerRef.current,\n }),\n [editor],\n );\n\n // Keep width + viewport in sync with the DOM.\n useLayoutEffect(() => {\n const scroller = scrollerRef.current;\n const content = contentRef.current;\n if (!scroller || !content) return;\n const sync = () => {\n editor.setWidth(content.clientWidth);\n editor.setViewport(scroller.scrollTop, scroller.clientHeight);\n };\n sync();\n const ro = new ResizeObserver(sync);\n ro.observe(scroller);\n ro.observe(content);\n return () => ro.disconnect();\n }, [editor]);\n\n // Recompute measurements once web fonts have loaded.\n useEffect(() => {\n const fonts = (document as Document & { fonts?: FontFaceSet }).fonts;\n if (fonts?.ready) void fonts.ready.then(() => editor.invalidateMeasurements());\n }, [editor]);\n\n useEffect(() => {\n if (autoFocus) inputRef.current?.focus();\n }, [autoFocus]);\n\n const pointToPosition = useCallbackRef((clientX: number, clientY: number) => {\n const content = contentRef.current;\n if (!content) return null;\n const rect = content.getBoundingClientRect();\n return editor.positionFromPoint(clientX - rect.left, clientY - rect.top);\n });\n\n // Drag-to-select with window-level listeners.\n useEffect(() => {\n const onMove = (e: globalThis.MouseEvent) => {\n if (!draggingRef.current) return;\n const pos = pointToPosition(e.clientX, e.clientY);\n const sel = editor.getSelection();\n if (pos && sel) editor.setSelection({ anchor: sel.anchor, focus: pos });\n };\n const onUp = () => {\n draggingRef.current = false;\n };\n window.addEventListener(\"mousemove\", onMove);\n window.addEventListener(\"mouseup\", onUp);\n return () => {\n window.removeEventListener(\"mousemove\", onMove);\n window.removeEventListener(\"mouseup\", onUp);\n };\n }, [editor, pointToPosition]);\n\n const onScroll = () => {\n const scroller = scrollerRef.current;\n if (scroller) editor.setViewport(scroller.scrollTop, scroller.clientHeight);\n };\n\n // Bound to the whole scroller (not just the text canvas) so clicking any\n // empty space — padding, the gutter below the last block — still focuses the\n // editor and drops the caret at the nearest position (positionFromPoint clamps).\n const onMouseDown = (e: ReactMouseEvent) => {\n if (e.button !== 0) return;\n const scroller = scrollerRef.current;\n // Ignore the native scrollbar gutter so scrollbar drags keep working.\n if (scroller && e.clientX - scroller.getBoundingClientRect().left >= scroller.clientWidth) {\n return;\n }\n inputRef.current?.focus();\n const pos = pointToPosition(e.clientX, e.clientY);\n if (!pos) return;\n e.preventDefault();\n const sel = editor.getSelection();\n if (e.shiftKey && sel) {\n editor.setSelection({ anchor: sel.anchor, focus: pos });\n } else {\n editor.collapse(pos);\n }\n draggingRef.current = true;\n };\n\n const onKeyDown = (e: KeyboardEvent) => {\n handleKeyDown(editor, e, { readOnly });\n };\n\n const commitInput = () => {\n const el = inputRef.current;\n if (!el) return;\n const value = el.value;\n if (value) {\n if (!readOnly) editor.insertText(value);\n el.value = \"\";\n }\n };\n\n const onInput = (e: FormEvent<HTMLTextAreaElement>) => {\n if (composingRef.current || (e.nativeEvent as InputEvent).isComposing) return;\n commitInput();\n };\n\n const onCompositionStart = () => {\n composingRef.current = true;\n };\n\n const onCompositionEnd = (e: CompositionEvent<HTMLTextAreaElement>) => {\n composingRef.current = false;\n const el = inputRef.current;\n if (el) {\n if (e.data && !readOnly) editor.insertText(e.data);\n el.value = \"\";\n }\n };\n\n const caret = editor.caretRect();\n const inputStyle: CSSProperties = {\n position: \"absolute\",\n left: caret ? caret.x : 0,\n top: caret ? caret.y : 0,\n width: 1,\n height: caret ? caret.height : 16,\n opacity: 0,\n padding: 0,\n border: 0,\n outline: \"none\",\n resize: \"none\",\n background: \"transparent\",\n caretColor: \"transparent\",\n color: \"transparent\",\n overflow: \"hidden\",\n whiteSpace: \"pre\",\n zIndex: 1,\n };\n\n return (\n <RenderersProvider value={renderers}>\n <div className={`ori-root${className ? ` ${className}` : \"\"}`} style={style}>\n <div className=\"ori-scroller\" ref={scrollerRef} onScroll={onScroll} onMouseDown={onMouseDown}>\n <div\n className=\"ori-content\"\n ref={contentRef}\n style={{ maxWidth, marginInline: \"auto\", position: \"relative\" }}\n >\n <div\n className=\"ori-canvas\"\n style={{ position: \"relative\", width: \"100%\", height: snapshot.totalHeight }}\n >\n <SelectionLayer editor={editor} snapshot={snapshot} />\n {snapshot.visible.map((block) => (\n <BlockView key={block.id} editor={editor} block={block} />\n ))}\n <CaretLayer editor={editor} snapshot={snapshot} focused={focused} />\n {snapshot.empty && placeholder ? (\n <div className=\"ori-placeholder\" aria-hidden>\n {placeholder}\n </div>\n ) : null}\n {!readOnly ? (\n <textarea\n ref={inputRef}\n className=\"ori-input\"\n style={inputStyle}\n spellCheck={false}\n autoCapitalize=\"off\"\n autoCorrect=\"off\"\n onKeyDown={onKeyDown}\n onInput={onInput}\n onCompositionStart={onCompositionStart}\n onCompositionEnd={onCompositionEnd}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n onCopy={(e) => {\n e.preventDefault();\n e.clipboardData.setData(\"text/plain\", editor.getSelectedText());\n }}\n onCut={(e) => {\n e.preventDefault();\n e.clipboardData.setData(\"text/plain\", editor.getSelectedText());\n editor.deleteBackward();\n }}\n onPaste={(e) => {\n e.preventDefault();\n pasteText(editor, e.clipboardData.getData(\"text/plain\"));\n }}\n />\n ) : null}\n </div>\n </div>\n </div>\n </div>\n </RenderersProvider>\n );\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/useEditor.ts","../src/hooks.ts","../src/renderers.tsx","../src/BlockView.tsx","../src/Overlay.tsx","../src/internal.ts","../src/keymap.ts","../src/NoteEditor.tsx"],"names":["useRef","EditorController","createCanvasMeasurer","useEffect","useSyncExternalStore","createContext","useContext","jsx","isCollapsed","useMemo","forwardRef","NoteEditor","useState","useImperativeHandle","useLayoutEffect","jsxs"],"mappings":";;;;;;;AA8BO,SAAS,SAAA,CAAU,OAAA,GAA4B,EAAC,EAAqB;AAC1E,EAAA,MAAM,GAAA,GAAMA,aAAgC,IAAI,CAAA;AAChD,EAAA,IAAI,GAAA,CAAI,YAAY,IAAA,EAAM;AACxB,IAAA,GAAA,CAAI,OAAA,GAAU,IAAIC,wBAAA,CAAiB;AAAA,MACjC,KAAK,OAAA,CAAQ,GAAA;AAAA,MACb,QAAA,EAAU,OAAA,CAAQ,QAAA,IAAYC,4BAAA,EAAqB;AAAA,MACnD,YAAY,OAAA,CAAQ,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kBAAA;AAAA,gBACA,gBAAA;AAAA,gBACA,OAAA,EAAS,MAAM,UAAA,CAAW,IAAI,CAAA;AAAA,gBAC9B,MAAA,EAAQ,MAAM,UAAA,CAAW,KAAK,CAAA;AAAA,gBAC9B,MAAA,EAAQ,CAAC,CAAA,KAAM;AACb,kBAAA,CAAA,CAAE,cAAA,EAAe;AACjB,kBAAA,CAAA,CAAE,aAAA,CAAc,OAAA,CAAQ,YAAA,EAAc,MAAA,CAAO,iBAAiB,CAAA;AAAA,gBAChE,CAAA;AAAA,gBACA,KAAA,EAAO,CAAC,CAAA,KAAM;AACZ,kBAAA,CAAA,CAAE,cAAA,EAAe;AACjB,kBAAA,CAAA,CAAE,aAAA,CAAc,OAAA,CAAQ,YAAA,EAAc,MAAA,CAAO,iBAAiB,CAAA;AAC9D,kBAAA,MAAA,CAAO,cAAA,EAAe;AAAA,gBACxB,CAAA;AAAA,gBACA,OAAA,EAAS,CAAC,CAAA,KAAM;AACd,kBAAA,CAAA,CAAE,cAAA,EAAe;AACjB,kBAAA,SAAA,CAAU,MAAA,EAAQ,CAAA,CAAE,aAAA,CAAc,OAAA,CAAQ,YAAY,CAAC,CAAA;AAAA,gBACzD;AAAA;AAAA,aACF,GACE;AAAA;AAAA;AAAA;AACN;AAAA,GACF,EACF,GACA,CAAA,EACF,CAAA;AAEJ,CAAC","file":"index.cjs","sourcesContent":["import {\n EditorController,\n createCanvasMeasurer,\n type EditorSchema,\n type Measurer,\n type Typography,\n} from \"@wingleeio/ori-core\";\nimport { useEffect, useRef } from \"react\";\nimport type * as Y from \"yjs\";\n\nexport interface UseEditorOptions {\n /** Existing note `Y.Doc`. When switching notes, remount via `key` instead. */\n doc?: Y.Doc;\n typography?: Typography;\n measurer?: Measurer;\n overscan?: number;\n blockSpacing?: number;\n /** Custom block/atom nodes, merged over the built-ins. */\n schema?: Partial<EditorSchema>;\n}\n\n/**\n * Create (once) and own an {@link EditorController} for the lifetime of the\n * component. To switch documents, give the hosting component a `key` so it\n * remounts with a fresh controller.\n *\n * The controller is reconnected on mount and disconnected on unmount rather than\n * destroyed, so React StrictMode's dev mount → unmount → remount cycle reuses the\n * same controller (with all its state) instead of leaving a torn-down one behind.\n */\nexport function useEditor(options: UseEditorOptions = {}): EditorController {\n const ref = useRef<EditorController | null>(null);\n if (ref.current === null) {\n ref.current = new EditorController({\n doc: options.doc,\n measurer: options.measurer ?? createCanvasMeasurer(),\n typography: options.typography,\n overscan: options.overscan,\n blockSpacing: options.blockSpacing,\n schema: options.schema,\n });\n }\n useEffect(() => {\n const editor = ref.current;\n editor?.connect();\n return () => editor?.disconnect();\n }, []);\n return ref.current;\n}\n","import type { EditorController, EditorSnapshot, Marks } from \"@wingleeio/ori-core\";\nimport { useSyncExternalStore } from \"react\";\n\n/** Subscribe a component to the controller's snapshot stream. */\nexport function useEditorSnapshot(editor: EditorController): EditorSnapshot {\n return useSyncExternalStore(editor.subscribe, editor.getSnapshot, editor.getSnapshot);\n}\n\n/**\n * The marks active at the current selection. Recomputed whenever the editor\n * notifies (selection move, edit, or pending-mark toggle), so toolbars stay in\n * sync without their own subscription.\n */\nexport function useActiveMarks(editor: EditorController): Marks {\n const snapshot = useEditorSnapshot(editor);\n // `revision` changes on every notify; reading it ties this to the store.\n void snapshot.revision;\n return editor.getActiveMarks();\n}\n","import type { BlockLayout, EditorController, InlineAtom, VisibleBlock } from \"@wingleeio/ori-core\";\nimport { createContext, useContext, type ReactNode } from \"react\";\n\n/** Props for a custom block renderer (atomic nodes: divider, image, …). */\nexport interface BlockRendererProps {\n editor: EditorController;\n block: VisibleBlock;\n /** The block's synthetic layout (atomic blocks: one line, no fragments). */\n layout: BlockLayout;\n}\nexport type BlockRenderer = (props: BlockRendererProps) => ReactNode;\n\n/** Props for a custom inline-atom renderer (mention chip, inline math, …). */\nexport interface AtomRendererProps {\n editor: EditorController;\n atom: InlineAtom;\n}\nexport type AtomRenderer = (props: AtomRendererProps) => ReactNode;\n\nexport interface Renderers {\n blocks: Record<string, BlockRenderer>;\n atoms: Record<string, AtomRenderer>;\n}\n\nconst EMPTY: Renderers = { blocks: {}, atoms: {} };\n\nconst RenderersContext = createContext<Renderers>(EMPTY);\nexport const RenderersProvider = RenderersContext.Provider;\nexport const useRenderers = (): Renderers => useContext(RenderersContext);\n","import type { EditorController, Fragment, InlineAtom, Line, VisibleBlock } from \"@wingleeio/ori-core\";\nimport type { CSSProperties } from \"react\";\nimport { useRenderers, type AtomRenderer } from \"./renderers\";\n\nfunction fragmentStyle(frag: Fragment): CSSProperties {\n const f = frag.font;\n const decoration: string[] = [];\n if (frag.marks.underline) decoration.push(\"underline\");\n if (frag.marks.strike) decoration.push(\"line-through\");\n return {\n fontFamily: f.fontFamily,\n fontSize: f.fontSize,\n fontWeight: f.fontWeight,\n fontStyle: f.italic ? \"italic\" : \"normal\",\n letterSpacing: f.letterSpacing || undefined,\n textDecorationLine: decoration.length ? decoration.join(\" \") : undefined,\n };\n}\n\n/** An inline atom, sized to the exact width Pretext laid out for it. */\nfunction AtomFragment({\n editor,\n atom,\n render,\n}: {\n editor: EditorController;\n atom: InlineAtom;\n render?: AtomRenderer;\n}) {\n return (\n <span\n className=\"ori-atom\"\n style={{\n display: \"inline-block\",\n width: atom.width,\n verticalAlign: \"middle\",\n whiteSpace: \"normal\",\n }}\n >\n {render ? render({ editor, atom }) : null}\n </span>\n );\n}\n\nfunction LineView({\n line,\n editor,\n atoms,\n}: {\n line: Line;\n editor: EditorController;\n atoms: Record<string, AtomRenderer>;\n}) {\n return (\n <div\n className=\"ori-line\"\n style={{ height: line.height, lineHeight: `${line.height}px`, whiteSpace: \"pre\" }}\n >\n {line.fragments.map((frag) => {\n if (frag.atom) {\n return (\n <AtomFragment\n key={frag.start}\n editor={editor}\n atom={frag.atom}\n render={atoms[frag.atom.type]}\n />\n );\n }\n const className = [\"ori-frag\"];\n if (frag.marks.code) className.push(\"ori-frag-code\");\n if (frag.marks.link) className.push(\"ori-frag-link\");\n return (\n <span\n key={frag.start}\n className={className.join(\" \")}\n style={fragmentStyle(frag)}\n data-start={frag.start}\n >\n {frag.text}\n </span>\n );\n })}\n </div>\n );\n}\n\n/**\n * Render a visible block. Custom (atomic) block types use their registered\n * renderer; text blocks render materialized Pretext lines, with any inline\n * atoms drawn by their registered atom renderer at the measured width.\n */\nexport function BlockView({ editor, block }: { editor: EditorController; block: VisibleBlock }) {\n const { blocks, atoms } = useRenderers();\n const layout = editor.getLayout(block.id);\n if (!layout) return null;\n const custom = blocks[block.type];\n return (\n <div\n className={`ori-block ori-block-${block.type}`}\n data-block-id={block.id}\n style={{\n position: \"absolute\",\n top: block.top,\n left: 0,\n width: \"100%\",\n height: block.height,\n }}\n >\n {custom\n ? custom({ editor, block, layout })\n : layout.lines.map((line) => (\n <LineView key={line.index} line={line} editor={editor} atoms={atoms} />\n ))}\n </div>\n );\n}\n","import type { EditorController, EditorSnapshot } from \"@wingleeio/ori-core\";\nimport { isCollapsed } from \"@wingleeio/ori-core\";\n\n/** Selection rectangles for visible blocks (rendered beneath the text). */\nexport function SelectionLayer({\n editor,\n snapshot,\n}: {\n editor: EditorController;\n snapshot: EditorSnapshot;\n}) {\n // Tie recomputation to the snapshot revision.\n void snapshot.revision;\n const rects = editor.selectionRectsForViewport();\n if (rects.length === 0) return null;\n return (\n <div className=\"ori-selection-layer\" aria-hidden>\n {rects.map((r, i) => (\n <div\n key={`${r.blockId}:${i}`}\n className=\"ori-selection-rect\"\n style={{ position: \"absolute\", left: r.x, top: r.y, width: r.width, height: r.height }}\n />\n ))}\n </div>\n );\n}\n\n/** Blinking caret, shown only when focused and the selection is collapsed. */\nexport function CaretLayer({\n editor,\n snapshot,\n focused,\n}: {\n editor: EditorController;\n snapshot: EditorSnapshot;\n focused: boolean;\n}) {\n const sel = snapshot.selection;\n if (!focused || !sel || !isCollapsed(sel)) return null;\n const rect = editor.caretRect();\n if (!rect) return null;\n return (\n <div\n className=\"ori-caret\"\n style={{ position: \"absolute\", left: rect.x, top: rect.y, height: rect.height }}\n aria-hidden\n />\n );\n}\n","import { useMemo, useRef } from \"react\";\n\n/**\n * Wrap a frequently-changing callback in a stable identity so it can be used in\n * effect dependency lists without re-subscribing. The latest closure is always\n * invoked.\n */\nexport function useCallbackRef<Args extends unknown[], Return>(\n fn: (...args: Args) => Return,\n): (...args: Args) => Return {\n const ref = useRef(fn);\n ref.current = fn;\n return useMemo(() => (...args: Args) => ref.current(...args), []);\n}\n","import type { EditorController } from \"@wingleeio/ori-core\";\nimport type { KeyboardEvent } from \"react\";\n\nexport interface KeymapOptions {\n readOnly?: boolean;\n}\n\n/** Insert clipboard text, mapping newlines to paragraph splits. */\nexport function pasteText(editor: EditorController, text: string): void {\n const parts = text.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n editor.insertText(parts[0]);\n for (let i = 1; i < parts.length; i += 1) {\n editor.insertParagraphBreak();\n if (parts[i]) editor.insertText(parts[i]);\n }\n}\n\n/**\n * Translate a keyboard event into editor commands. Character insertion is left\n * to the textarea `input`/`composition` events; this handles control keys,\n * navigation and formatting shortcuts only.\n *\n * Returns true if the event was handled (and `preventDefault` was called).\n */\nexport function handleKeyDown(\n editor: EditorController,\n e: KeyboardEvent,\n opts: KeymapOptions = {},\n): boolean {\n if (e.nativeEvent.isComposing) return false;\n // Alt/Option combos are reserved for app-level shortcuts (e.g. note switching),\n // so let them bubble instead of moving the caret.\n if (e.altKey) return false;\n const mod = e.metaKey || e.ctrlKey;\n const shift = e.shiftKey;\n const ro = !!opts.readOnly;\n\n if (mod) {\n switch (e.key.toLowerCase()) {\n case \"b\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"bold\");\n return true;\n case \"i\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"italic\");\n return true;\n case \"u\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"underline\");\n return true;\n case \"e\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"code\");\n return true;\n case \"a\":\n e.preventDefault();\n editor.selectAll();\n return true;\n case \"z\":\n e.preventDefault();\n if (!ro) (shift ? editor.redo() : editor.undo());\n return true;\n case \"y\":\n e.preventDefault();\n if (!ro) editor.redo();\n return true;\n case \"arrowleft\":\n e.preventDefault();\n editor.moveCaret(\"lineStart\", shift);\n return true;\n case \"arrowright\":\n e.preventDefault();\n editor.moveCaret(\"lineEnd\", shift);\n return true;\n // Let the browser raise copy/cut/paste on the textarea.\n case \"c\":\n case \"x\":\n case \"v\":\n return false;\n default:\n return false;\n }\n }\n\n switch (e.key) {\n case \"Backspace\":\n e.preventDefault();\n if (!ro) editor.deleteBackward();\n return true;\n case \"Delete\":\n e.preventDefault();\n if (!ro) editor.deleteForward();\n return true;\n case \"Enter\":\n e.preventDefault();\n if (!ro) editor.insertParagraphBreak();\n return true;\n case \"Tab\":\n e.preventDefault();\n if (!ro) editor.insertText(\" \");\n return true;\n case \"ArrowLeft\":\n e.preventDefault();\n editor.moveCaret(\"left\", shift);\n return true;\n case \"ArrowRight\":\n e.preventDefault();\n editor.moveCaret(\"right\", shift);\n return true;\n case \"ArrowUp\":\n e.preventDefault();\n editor.moveCaret(\"up\", shift);\n return true;\n case \"ArrowDown\":\n e.preventDefault();\n editor.moveCaret(\"down\", shift);\n return true;\n case \"Home\":\n e.preventDefault();\n editor.moveCaret(\"lineStart\", shift);\n return true;\n case \"End\":\n e.preventDefault();\n editor.moveCaret(\"lineEnd\", shift);\n return true;\n default:\n return false;\n }\n}\n","import type { EditorController } from \"@wingleeio/ori-core\";\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type CompositionEvent,\n type FormEvent,\n type KeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n} from \"react\";\nimport { BlockView } from \"./BlockView\";\nimport { CaretLayer, SelectionLayer } from \"./Overlay\";\nimport { useEditorSnapshot } from \"./hooks\";\nimport { useCallbackRef } from \"./internal\";\nimport { handleKeyDown, pasteText } from \"./keymap\";\nimport { RenderersProvider, type AtomRenderer, type BlockRenderer } from \"./renderers\";\n\nexport interface NoteEditorProps {\n editor: EditorController;\n className?: string;\n style?: CSSProperties;\n /** Max width of the centered content column, in px. */\n maxWidth?: number;\n placeholder?: string;\n autoFocus?: boolean;\n readOnly?: boolean;\n /** Renderers for custom (atomic) block node types. */\n blockRenderers?: Record<string, BlockRenderer>;\n /** Renderers for custom inline atom types. */\n atomRenderers?: Record<string, AtomRenderer>;\n}\n\n/** A viewport-space rectangle (client coordinates). */\nexport interface ViewportRect {\n top: number;\n left: number;\n right: number;\n bottom: number;\n width: number;\n height: number;\n}\n\n/** Imperative handle for building floating UI (slash / selection menus). */\nexport interface NoteEditorHandle {\n focus(): void;\n /** Caret position in viewport coordinates, or null if unavailable. */\n getCaretRect(): { x: number; y: number; height: number } | null;\n /** Bounding box of the current selection in viewport coordinates, or null. */\n getSelectionRect(): ViewportRect | null;\n /** The scrolling element, for scroll-aware positioning. */\n getScrollElement(): HTMLElement | null;\n}\n\n/**\n * A fully virtualized, Pretext-laid-out note editor. Renders only the blocks\n * intersecting the viewport; selection and caret are drawn from logical state\n * so they remain correct across offscreen content.\n */\nexport const NoteEditor = forwardRef<NoteEditorHandle, NoteEditorProps>(function NoteEditor(\n {\n editor,\n className,\n style,\n maxWidth = 720,\n placeholder = \"Start writing…\",\n autoFocus,\n readOnly,\n blockRenderers,\n atomRenderers,\n },\n ref,\n) {\n const snapshot = useEditorSnapshot(editor);\n const renderers = useMemo(\n () => ({ blocks: blockRenderers ?? {}, atoms: atomRenderers ?? {} }),\n [blockRenderers, atomRenderers],\n );\n const scrollerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const draggingRef = useRef(false);\n const composingRef = useRef(false);\n const [focused, setFocused] = useState(false);\n\n useImperativeHandle(\n ref,\n (): NoteEditorHandle => ({\n focus: () => inputRef.current?.focus(),\n getCaretRect: () => {\n const c = editor.caretRect();\n const content = contentRef.current;\n if (!c || !content) return null;\n const r = content.getBoundingClientRect();\n return { x: r.left + c.x, y: r.top + c.y, height: c.height };\n },\n getSelectionRect: () => {\n const content = contentRef.current;\n if (!content) return null;\n const rects = editor.selectionRectsForViewport();\n if (rects.length === 0) return null;\n const r = content.getBoundingClientRect();\n let top = Infinity;\n let left = Infinity;\n let bottom = -Infinity;\n let right = -Infinity;\n for (const rc of rects) {\n top = Math.min(top, r.top + rc.y);\n left = Math.min(left, r.left + rc.x);\n bottom = Math.max(bottom, r.top + rc.y + rc.height);\n right = Math.max(right, r.left + rc.x + rc.width);\n }\n return { top, left, right, bottom, width: right - left, height: bottom - top };\n },\n getScrollElement: () => scrollerRef.current,\n }),\n [editor],\n );\n\n // Keep width + viewport in sync with the DOM.\n useLayoutEffect(() => {\n const scroller = scrollerRef.current;\n const content = contentRef.current;\n if (!scroller || !content) return;\n const sync = () => {\n editor.setWidth(content.clientWidth);\n editor.setViewport(scroller.scrollTop, scroller.clientHeight);\n };\n sync();\n const ro = new ResizeObserver(sync);\n ro.observe(scroller);\n ro.observe(content);\n return () => ro.disconnect();\n }, [editor]);\n\n // Recompute measurements once web fonts have loaded.\n useEffect(() => {\n const fonts = (document as Document & { fonts?: FontFaceSet }).fonts;\n if (fonts?.ready) void fonts.ready.then(() => editor.invalidateMeasurements());\n }, [editor]);\n\n useEffect(() => {\n if (autoFocus) inputRef.current?.focus();\n }, [autoFocus]);\n\n const pointToPosition = useCallbackRef((clientX: number, clientY: number) => {\n const content = contentRef.current;\n if (!content) return null;\n const rect = content.getBoundingClientRect();\n return editor.positionFromPoint(clientX - rect.left, clientY - rect.top);\n });\n\n // Drag-to-select with window-level listeners.\n useEffect(() => {\n const onMove = (e: globalThis.MouseEvent) => {\n if (!draggingRef.current) return;\n const pos = pointToPosition(e.clientX, e.clientY);\n const sel = editor.getSelection();\n if (pos && sel) editor.setSelection({ anchor: sel.anchor, focus: pos });\n };\n const onUp = () => {\n draggingRef.current = false;\n };\n window.addEventListener(\"mousemove\", onMove);\n window.addEventListener(\"mouseup\", onUp);\n return () => {\n window.removeEventListener(\"mousemove\", onMove);\n window.removeEventListener(\"mouseup\", onUp);\n };\n }, [editor, pointToPosition]);\n\n const onScroll = () => {\n const scroller = scrollerRef.current;\n if (scroller) editor.setViewport(scroller.scrollTop, scroller.clientHeight);\n };\n\n // Bound to the whole scroller (not just the text canvas) so clicking any\n // empty space — padding, the gutter below the last block — still focuses the\n // editor and drops the caret at the nearest position (positionFromPoint clamps).\n const onMouseDown = (e: ReactMouseEvent) => {\n if (e.button !== 0) return;\n const scroller = scrollerRef.current;\n // Ignore the native scrollbar gutter so scrollbar drags keep working.\n if (scroller && e.clientX - scroller.getBoundingClientRect().left >= scroller.clientWidth) {\n return;\n }\n inputRef.current?.focus();\n const pos = pointToPosition(e.clientX, e.clientY);\n if (!pos) return;\n e.preventDefault();\n const sel = editor.getSelection();\n if (e.shiftKey && sel) {\n editor.setSelection({ anchor: sel.anchor, focus: pos });\n } else {\n editor.collapse(pos);\n }\n draggingRef.current = true;\n };\n\n const onKeyDown = (e: KeyboardEvent) => {\n handleKeyDown(editor, e, { readOnly });\n };\n\n const commitInput = () => {\n const el = inputRef.current;\n if (!el) return;\n const value = el.value;\n if (value) {\n if (!readOnly) editor.insertText(value);\n el.value = \"\";\n }\n };\n\n const onInput = (e: FormEvent<HTMLTextAreaElement>) => {\n if (composingRef.current || (e.nativeEvent as InputEvent).isComposing) return;\n commitInput();\n };\n\n const onCompositionStart = () => {\n composingRef.current = true;\n };\n\n const onCompositionEnd = (e: CompositionEvent<HTMLTextAreaElement>) => {\n composingRef.current = false;\n const el = inputRef.current;\n if (el) {\n if (e.data && !readOnly) editor.insertText(e.data);\n el.value = \"\";\n }\n };\n\n const caret = editor.caretRect();\n const inputStyle: CSSProperties = {\n position: \"absolute\",\n left: caret ? caret.x : 0,\n top: caret ? caret.y : 0,\n width: 1,\n height: caret ? caret.height : 16,\n opacity: 0,\n padding: 0,\n border: 0,\n outline: \"none\",\n resize: \"none\",\n background: \"transparent\",\n caretColor: \"transparent\",\n color: \"transparent\",\n overflow: \"hidden\",\n whiteSpace: \"pre\",\n zIndex: 1,\n };\n\n return (\n <RenderersProvider value={renderers}>\n <div className={`ori-root${className ? ` ${className}` : \"\"}`} style={style}>\n <div className=\"ori-scroller\" ref={scrollerRef} onScroll={onScroll} onMouseDown={onMouseDown}>\n <div\n className=\"ori-content\"\n ref={contentRef}\n style={{ maxWidth, marginInline: \"auto\", position: \"relative\" }}\n >\n <div\n className=\"ori-canvas\"\n style={{ position: \"relative\", width: \"100%\", height: snapshot.totalHeight }}\n >\n <SelectionLayer editor={editor} snapshot={snapshot} />\n {snapshot.visible.map((block) => (\n <BlockView key={block.id} editor={editor} block={block} />\n ))}\n <CaretLayer editor={editor} snapshot={snapshot} focused={focused} />\n {snapshot.empty && placeholder ? (\n <div className=\"ori-placeholder\" aria-hidden>\n {placeholder}\n </div>\n ) : null}\n {!readOnly ? (\n <textarea\n ref={inputRef}\n className=\"ori-input\"\n style={inputStyle}\n spellCheck={false}\n autoCapitalize=\"off\"\n autoCorrect=\"off\"\n onKeyDown={onKeyDown}\n onInput={onInput}\n onCompositionStart={onCompositionStart}\n onCompositionEnd={onCompositionEnd}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n onCopy={(e) => {\n e.preventDefault();\n e.clipboardData.setData(\"text/plain\", editor.getSelectedText());\n }}\n onCut={(e) => {\n e.preventDefault();\n e.clipboardData.setData(\"text/plain\", editor.getSelectedText());\n editor.deleteBackward();\n }}\n onPaste={(e) => {\n e.preventDefault();\n pasteText(editor, e.clipboardData.getData(\"text/plain\"));\n }}\n />\n ) : null}\n </div>\n </div>\n </div>\n </div>\n </RenderersProvider>\n );\n});\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -16,8 +16,12 @@ interface UseEditorOptions {
|
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Create (once) and own an {@link EditorController} for the lifetime of the
|
|
19
|
-
* component.
|
|
20
|
-
*
|
|
19
|
+
* component. To switch documents, give the hosting component a `key` so it
|
|
20
|
+
* remounts with a fresh controller.
|
|
21
|
+
*
|
|
22
|
+
* The controller is reconnected on mount and disconnected on unmount rather than
|
|
23
|
+
* destroyed, so React StrictMode's dev mount → unmount → remount cycle reuses the
|
|
24
|
+
* same controller (with all its state) instead of leaving a torn-down one behind.
|
|
21
25
|
*/
|
|
22
26
|
declare function useEditor(options?: UseEditorOptions): EditorController;
|
|
23
27
|
|
package/dist/index.d.ts
CHANGED
|
@@ -16,8 +16,12 @@ interface UseEditorOptions {
|
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Create (once) and own an {@link EditorController} for the lifetime of the
|
|
19
|
-
* component.
|
|
20
|
-
*
|
|
19
|
+
* component. To switch documents, give the hosting component a `key` so it
|
|
20
|
+
* remounts with a fresh controller.
|
|
21
|
+
*
|
|
22
|
+
* The controller is reconnected on mount and disconnected on unmount rather than
|
|
23
|
+
* destroyed, so React StrictMode's dev mount → unmount → remount cycle reuses the
|
|
24
|
+
* same controller (with all its state) instead of leaving a torn-down one behind.
|
|
21
25
|
*/
|
|
22
26
|
declare function useEditor(options?: UseEditorOptions): EditorController;
|
|
23
27
|
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useEditor.ts","../src/hooks.ts","../src/renderers.tsx","../src/BlockView.tsx","../src/Overlay.tsx","../src/internal.ts","../src/keymap.ts","../src/NoteEditor.tsx"],"names":["jsx","useRef","NoteEditor","useMemo","useEffect"],"mappings":";;;;;;AA0BO,SAAS,SAAA,CAAU,OAAA,GAA4B,EAAC,EAAqB;AAC1E,EAAA,MAAM,GAAA,GAAM,OAAgC,IAAI,CAAA;AAChD,EAAA,IAAI,GAAA,CAAI,YAAY,IAAA,EAAM;AACxB,IAAA,GAAA,CAAI,OAAA,GAAU,IAAI,gBAAA,CAAiB;AAAA,MACjC,KAAK,OAAA,CAAQ,GAAA;AAA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AA,gBACA,OAAA;AAAA,gBACA,kBAAA;AAAA,gBACA,gBAAA;AAAA,gBACA,OAAA,EAAS,MAAM,UAAA,CAAW,IAAI,CAAA;AAAA,gBAC9B,MAAA,EAAQ,MAAM,UAAA,CAAW,KAAK,CAAA;AAAA,gBAC9B,MAAA,EAAQ,CAAC,CAAA,KAAM;AACb,kBAAA,CAAA,CAAE,cAAA,EAAe;AACjB,kBAAA,CAAA,CAAE,aAAA,CAAc,OAAA,CAAQ,YAAA,EAAc,MAAA,CAAO,iBAAiB,CAAA;AAAA,gBAChE,CAAA;AAAA,gBACA,KAAA,EAAO,CAAC,CAAA,KAAM;AACZ,kBAAA,CAAA,CAAE,cAAA,EAAe;AACjB,kBAAA,CAAA,CAAE,aAAA,CAAc,OAAA,CAAQ,YAAA,EAAc,MAAA,CAAO,iBAAiB,CAAA;AAC9D,kBAAA,MAAA,CAAO,cAAA,EAAe;AAAA,gBACxB,CAAA;AAAA,gBACA,OAAA,EAAS,CAAC,CAAA,KAAM;AACd,kBAAA,CAAA,CAAE,cAAA,EAAe;AACjB,kBAAA,SAAA,CAAU,MAAA,EAAQ,CAAA,CAAE,aAAA,CAAc,OAAA,CAAQ,YAAY,CAAC,CAAA;AAAA,gBACzD;AAAA;AAAA,aACF,GACE;AAAA;AAAA;AAAA;AACN;AAAA,GACF,EACF,GACA,CAAA,EACF,CAAA;AAEJ,CAAC","file":"index.js","sourcesContent":["import {\n EditorController,\n createCanvasMeasurer,\n type EditorSchema,\n type Measurer,\n type Typography,\n} from \"@wingleeio/ori-core\";\nimport { useEffect, useRef } from \"react\";\nimport type * as Y from \"yjs\";\n\nexport interface UseEditorOptions {\n /** Existing note `Y.Doc`. When switching notes, remount via `key` instead. */\n doc?: Y.Doc;\n typography?: Typography;\n measurer?: Measurer;\n overscan?: number;\n blockSpacing?: number;\n /** Custom block/atom nodes, merged over the built-ins. */\n schema?: Partial<EditorSchema>;\n}\n\n/**\n * Create (once) and own an {@link EditorController} for the lifetime of the\n * component. The controller is destroyed on unmount. To switch documents, give\n * the hosting component a `key` so it remounts with a fresh controller.\n */\nexport function useEditor(options: UseEditorOptions = {}): EditorController {\n const ref = useRef<EditorController | null>(null);\n if (ref.current === null) {\n ref.current = new EditorController({\n doc: options.doc,\n measurer: options.measurer ?? createCanvasMeasurer(),\n typography: options.typography,\n overscan: options.overscan,\n blockSpacing: options.blockSpacing,\n schema: options.schema,\n });\n }\n useEffect(() => {\n const editor = ref.current;\n return () => editor?.destroy();\n }, []);\n return ref.current;\n}\n","import type { EditorController, EditorSnapshot, Marks } from \"@wingleeio/ori-core\";\nimport { useSyncExternalStore } from \"react\";\n\n/** Subscribe a component to the controller's snapshot stream. */\nexport function useEditorSnapshot(editor: EditorController): EditorSnapshot {\n return useSyncExternalStore(editor.subscribe, editor.getSnapshot, editor.getSnapshot);\n}\n\n/**\n * The marks active at the current selection. Recomputed whenever the editor\n * notifies (selection move, edit, or pending-mark toggle), so toolbars stay in\n * sync without their own subscription.\n */\nexport function useActiveMarks(editor: EditorController): Marks {\n const snapshot = useEditorSnapshot(editor);\n // `revision` changes on every notify; reading it ties this to the store.\n void snapshot.revision;\n return editor.getActiveMarks();\n}\n","import type { BlockLayout, EditorController, InlineAtom, VisibleBlock } from \"@wingleeio/ori-core\";\nimport { createContext, useContext, type ReactNode } from \"react\";\n\n/** Props for a custom block renderer (atomic nodes: divider, image, …). */\nexport interface BlockRendererProps {\n editor: EditorController;\n block: VisibleBlock;\n /** The block's synthetic layout (atomic blocks: one line, no fragments). */\n layout: BlockLayout;\n}\nexport type BlockRenderer = (props: BlockRendererProps) => ReactNode;\n\n/** Props for a custom inline-atom renderer (mention chip, inline math, …). */\nexport interface AtomRendererProps {\n editor: EditorController;\n atom: InlineAtom;\n}\nexport type AtomRenderer = (props: AtomRendererProps) => ReactNode;\n\nexport interface Renderers {\n blocks: Record<string, BlockRenderer>;\n atoms: Record<string, AtomRenderer>;\n}\n\nconst EMPTY: Renderers = { blocks: {}, atoms: {} };\n\nconst RenderersContext = createContext<Renderers>(EMPTY);\nexport const RenderersProvider = RenderersContext.Provider;\nexport const useRenderers = (): Renderers => useContext(RenderersContext);\n","import type { EditorController, Fragment, InlineAtom, Line, VisibleBlock } from \"@wingleeio/ori-core\";\nimport type { CSSProperties } from \"react\";\nimport { useRenderers, type AtomRenderer } from \"./renderers\";\n\nfunction fragmentStyle(frag: Fragment): CSSProperties {\n const f = frag.font;\n const decoration: string[] = [];\n if (frag.marks.underline) decoration.push(\"underline\");\n if (frag.marks.strike) decoration.push(\"line-through\");\n return {\n fontFamily: f.fontFamily,\n fontSize: f.fontSize,\n fontWeight: f.fontWeight,\n fontStyle: f.italic ? \"italic\" : \"normal\",\n letterSpacing: f.letterSpacing || undefined,\n textDecorationLine: decoration.length ? decoration.join(\" \") : undefined,\n };\n}\n\n/** An inline atom, sized to the exact width Pretext laid out for it. */\nfunction AtomFragment({\n editor,\n atom,\n render,\n}: {\n editor: EditorController;\n atom: InlineAtom;\n render?: AtomRenderer;\n}) {\n return (\n <span\n className=\"ori-atom\"\n style={{\n display: \"inline-block\",\n width: atom.width,\n verticalAlign: \"middle\",\n whiteSpace: \"normal\",\n }}\n >\n {render ? render({ editor, atom }) : null}\n </span>\n );\n}\n\nfunction LineView({\n line,\n editor,\n atoms,\n}: {\n line: Line;\n editor: EditorController;\n atoms: Record<string, AtomRenderer>;\n}) {\n return (\n <div\n className=\"ori-line\"\n style={{ height: line.height, lineHeight: `${line.height}px`, whiteSpace: \"pre\" }}\n >\n {line.fragments.map((frag) => {\n if (frag.atom) {\n return (\n <AtomFragment\n key={frag.start}\n editor={editor}\n atom={frag.atom}\n render={atoms[frag.atom.type]}\n />\n );\n }\n const className = [\"ori-frag\"];\n if (frag.marks.code) className.push(\"ori-frag-code\");\n if (frag.marks.link) className.push(\"ori-frag-link\");\n return (\n <span\n key={frag.start}\n className={className.join(\" \")}\n style={fragmentStyle(frag)}\n data-start={frag.start}\n >\n {frag.text}\n </span>\n );\n })}\n </div>\n );\n}\n\n/**\n * Render a visible block. Custom (atomic) block types use their registered\n * renderer; text blocks render materialized Pretext lines, with any inline\n * atoms drawn by their registered atom renderer at the measured width.\n */\nexport function BlockView({ editor, block }: { editor: EditorController; block: VisibleBlock }) {\n const { blocks, atoms } = useRenderers();\n const layout = editor.getLayout(block.id);\n if (!layout) return null;\n const custom = blocks[block.type];\n return (\n <div\n className={`ori-block ori-block-${block.type}`}\n data-block-id={block.id}\n style={{\n position: \"absolute\",\n top: block.top,\n left: 0,\n width: \"100%\",\n height: block.height,\n }}\n >\n {custom\n ? custom({ editor, block, layout })\n : layout.lines.map((line) => (\n <LineView key={line.index} line={line} editor={editor} atoms={atoms} />\n ))}\n </div>\n );\n}\n","import type { EditorController, EditorSnapshot } from \"@wingleeio/ori-core\";\nimport { isCollapsed } from \"@wingleeio/ori-core\";\n\n/** Selection rectangles for visible blocks (rendered beneath the text). */\nexport function SelectionLayer({\n editor,\n snapshot,\n}: {\n editor: EditorController;\n snapshot: EditorSnapshot;\n}) {\n // Tie recomputation to the snapshot revision.\n void snapshot.revision;\n const rects = editor.selectionRectsForViewport();\n if (rects.length === 0) return null;\n return (\n <div className=\"ori-selection-layer\" aria-hidden>\n {rects.map((r, i) => (\n <div\n key={`${r.blockId}:${i}`}\n className=\"ori-selection-rect\"\n style={{ position: \"absolute\", left: r.x, top: r.y, width: r.width, height: r.height }}\n />\n ))}\n </div>\n );\n}\n\n/** Blinking caret, shown only when focused and the selection is collapsed. */\nexport function CaretLayer({\n editor,\n snapshot,\n focused,\n}: {\n editor: EditorController;\n snapshot: EditorSnapshot;\n focused: boolean;\n}) {\n const sel = snapshot.selection;\n if (!focused || !sel || !isCollapsed(sel)) return null;\n const rect = editor.caretRect();\n if (!rect) return null;\n return (\n <div\n className=\"ori-caret\"\n style={{ position: \"absolute\", left: rect.x, top: rect.y, height: rect.height }}\n aria-hidden\n />\n );\n}\n","import { useMemo, useRef } from \"react\";\n\n/**\n * Wrap a frequently-changing callback in a stable identity so it can be used in\n * effect dependency lists without re-subscribing. The latest closure is always\n * invoked.\n */\nexport function useCallbackRef<Args extends unknown[], Return>(\n fn: (...args: Args) => Return,\n): (...args: Args) => Return {\n const ref = useRef(fn);\n ref.current = fn;\n return useMemo(() => (...args: Args) => ref.current(...args), []);\n}\n","import type { EditorController } from \"@wingleeio/ori-core\";\nimport type { KeyboardEvent } from \"react\";\n\nexport interface KeymapOptions {\n readOnly?: boolean;\n}\n\n/** Insert clipboard text, mapping newlines to paragraph splits. */\nexport function pasteText(editor: EditorController, text: string): void {\n const parts = text.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n editor.insertText(parts[0]);\n for (let i = 1; i < parts.length; i += 1) {\n editor.insertParagraphBreak();\n if (parts[i]) editor.insertText(parts[i]);\n }\n}\n\n/**\n * Translate a keyboard event into editor commands. Character insertion is left\n * to the textarea `input`/`composition` events; this handles control keys,\n * navigation and formatting shortcuts only.\n *\n * Returns true if the event was handled (and `preventDefault` was called).\n */\nexport function handleKeyDown(\n editor: EditorController,\n e: KeyboardEvent,\n opts: KeymapOptions = {},\n): boolean {\n if (e.nativeEvent.isComposing) return false;\n // Alt/Option combos are reserved for app-level shortcuts (e.g. note switching),\n // so let them bubble instead of moving the caret.\n if (e.altKey) return false;\n const mod = e.metaKey || e.ctrlKey;\n const shift = e.shiftKey;\n const ro = !!opts.readOnly;\n\n if (mod) {\n switch (e.key.toLowerCase()) {\n case \"b\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"bold\");\n return true;\n case \"i\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"italic\");\n return true;\n case \"u\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"underline\");\n return true;\n case \"e\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"code\");\n return true;\n case \"a\":\n e.preventDefault();\n editor.selectAll();\n return true;\n case \"z\":\n e.preventDefault();\n if (!ro) (shift ? editor.redo() : editor.undo());\n return true;\n case \"y\":\n e.preventDefault();\n if (!ro) editor.redo();\n return true;\n case \"arrowleft\":\n e.preventDefault();\n editor.moveCaret(\"lineStart\", shift);\n return true;\n case \"arrowright\":\n e.preventDefault();\n editor.moveCaret(\"lineEnd\", shift);\n return true;\n // Let the browser raise copy/cut/paste on the textarea.\n case \"c\":\n case \"x\":\n case \"v\":\n return false;\n default:\n return false;\n }\n }\n\n switch (e.key) {\n case \"Backspace\":\n e.preventDefault();\n if (!ro) editor.deleteBackward();\n return true;\n case \"Delete\":\n e.preventDefault();\n if (!ro) editor.deleteForward();\n return true;\n case \"Enter\":\n e.preventDefault();\n if (!ro) editor.insertParagraphBreak();\n return true;\n case \"Tab\":\n e.preventDefault();\n if (!ro) editor.insertText(\" \");\n return true;\n case \"ArrowLeft\":\n e.preventDefault();\n editor.moveCaret(\"left\", shift);\n return true;\n case \"ArrowRight\":\n e.preventDefault();\n editor.moveCaret(\"right\", shift);\n return true;\n case \"ArrowUp\":\n e.preventDefault();\n editor.moveCaret(\"up\", shift);\n return true;\n case \"ArrowDown\":\n e.preventDefault();\n editor.moveCaret(\"down\", shift);\n return true;\n case \"Home\":\n e.preventDefault();\n editor.moveCaret(\"lineStart\", shift);\n return true;\n case \"End\":\n e.preventDefault();\n editor.moveCaret(\"lineEnd\", shift);\n return true;\n default:\n return false;\n }\n}\n","import type { EditorController } from \"@wingleeio/ori-core\";\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type CompositionEvent,\n type FormEvent,\n type KeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n} from \"react\";\nimport { BlockView } from \"./BlockView\";\nimport { CaretLayer, SelectionLayer } from \"./Overlay\";\nimport { useEditorSnapshot } from \"./hooks\";\nimport { useCallbackRef } from \"./internal\";\nimport { handleKeyDown, pasteText } from \"./keymap\";\nimport { RenderersProvider, type AtomRenderer, type BlockRenderer } from \"./renderers\";\n\nexport interface NoteEditorProps {\n editor: EditorController;\n className?: string;\n style?: CSSProperties;\n /** Max width of the centered content column, in px. */\n maxWidth?: number;\n placeholder?: string;\n autoFocus?: boolean;\n readOnly?: boolean;\n /** Renderers for custom (atomic) block node types. */\n blockRenderers?: Record<string, BlockRenderer>;\n /** Renderers for custom inline atom types. */\n atomRenderers?: Record<string, AtomRenderer>;\n}\n\n/** A viewport-space rectangle (client coordinates). */\nexport interface ViewportRect {\n top: number;\n left: number;\n right: number;\n bottom: number;\n width: number;\n height: number;\n}\n\n/** Imperative handle for building floating UI (slash / selection menus). */\nexport interface NoteEditorHandle {\n focus(): void;\n /** Caret position in viewport coordinates, or null if unavailable. */\n getCaretRect(): { x: number; y: number; height: number } | null;\n /** Bounding box of the current selection in viewport coordinates, or null. */\n getSelectionRect(): ViewportRect | null;\n /** The scrolling element, for scroll-aware positioning. */\n getScrollElement(): HTMLElement | null;\n}\n\n/**\n * A fully virtualized, Pretext-laid-out note editor. Renders only the blocks\n * intersecting the viewport; selection and caret are drawn from logical state\n * so they remain correct across offscreen content.\n */\nexport const NoteEditor = forwardRef<NoteEditorHandle, NoteEditorProps>(function NoteEditor(\n {\n editor,\n className,\n style,\n maxWidth = 720,\n placeholder = \"Start writing…\",\n autoFocus,\n readOnly,\n blockRenderers,\n atomRenderers,\n },\n ref,\n) {\n const snapshot = useEditorSnapshot(editor);\n const renderers = useMemo(\n () => ({ blocks: blockRenderers ?? {}, atoms: atomRenderers ?? {} }),\n [blockRenderers, atomRenderers],\n );\n const scrollerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const draggingRef = useRef(false);\n const composingRef = useRef(false);\n const [focused, setFocused] = useState(false);\n\n useImperativeHandle(\n ref,\n (): NoteEditorHandle => ({\n focus: () => inputRef.current?.focus(),\n getCaretRect: () => {\n const c = editor.caretRect();\n const content = contentRef.current;\n if (!c || !content) return null;\n const r = content.getBoundingClientRect();\n return { x: r.left + c.x, y: r.top + c.y, height: c.height };\n },\n getSelectionRect: () => {\n const content = contentRef.current;\n if (!content) return null;\n const rects = editor.selectionRectsForViewport();\n if (rects.length === 0) return null;\n const r = content.getBoundingClientRect();\n let top = Infinity;\n let left = Infinity;\n let bottom = -Infinity;\n let right = -Infinity;\n for (const rc of rects) {\n top = Math.min(top, r.top + rc.y);\n left = Math.min(left, r.left + rc.x);\n bottom = Math.max(bottom, r.top + rc.y + rc.height);\n right = Math.max(right, r.left + rc.x + rc.width);\n }\n return { top, left, right, bottom, width: right - left, height: bottom - top };\n },\n getScrollElement: () => scrollerRef.current,\n }),\n [editor],\n );\n\n // Keep width + viewport in sync with the DOM.\n useLayoutEffect(() => {\n const scroller = scrollerRef.current;\n const content = contentRef.current;\n if (!scroller || !content) return;\n const sync = () => {\n editor.setWidth(content.clientWidth);\n editor.setViewport(scroller.scrollTop, scroller.clientHeight);\n };\n sync();\n const ro = new ResizeObserver(sync);\n ro.observe(scroller);\n ro.observe(content);\n return () => ro.disconnect();\n }, [editor]);\n\n // Recompute measurements once web fonts have loaded.\n useEffect(() => {\n const fonts = (document as Document & { fonts?: FontFaceSet }).fonts;\n if (fonts?.ready) void fonts.ready.then(() => editor.invalidateMeasurements());\n }, [editor]);\n\n useEffect(() => {\n if (autoFocus) inputRef.current?.focus();\n }, [autoFocus]);\n\n const pointToPosition = useCallbackRef((clientX: number, clientY: number) => {\n const content = contentRef.current;\n if (!content) return null;\n const rect = content.getBoundingClientRect();\n return editor.positionFromPoint(clientX - rect.left, clientY - rect.top);\n });\n\n // Drag-to-select with window-level listeners.\n useEffect(() => {\n const onMove = (e: globalThis.MouseEvent) => {\n if (!draggingRef.current) return;\n const pos = pointToPosition(e.clientX, e.clientY);\n const sel = editor.getSelection();\n if (pos && sel) editor.setSelection({ anchor: sel.anchor, focus: pos });\n };\n const onUp = () => {\n draggingRef.current = false;\n };\n window.addEventListener(\"mousemove\", onMove);\n window.addEventListener(\"mouseup\", onUp);\n return () => {\n window.removeEventListener(\"mousemove\", onMove);\n window.removeEventListener(\"mouseup\", onUp);\n };\n }, [editor, pointToPosition]);\n\n const onScroll = () => {\n const scroller = scrollerRef.current;\n if (scroller) editor.setViewport(scroller.scrollTop, scroller.clientHeight);\n };\n\n // Bound to the whole scroller (not just the text canvas) so clicking any\n // empty space — padding, the gutter below the last block — still focuses the\n // editor and drops the caret at the nearest position (positionFromPoint clamps).\n const onMouseDown = (e: ReactMouseEvent) => {\n if (e.button !== 0) return;\n const scroller = scrollerRef.current;\n // Ignore the native scrollbar gutter so scrollbar drags keep working.\n if (scroller && e.clientX - scroller.getBoundingClientRect().left >= scroller.clientWidth) {\n return;\n }\n inputRef.current?.focus();\n const pos = pointToPosition(e.clientX, e.clientY);\n if (!pos) return;\n e.preventDefault();\n const sel = editor.getSelection();\n if (e.shiftKey && sel) {\n editor.setSelection({ anchor: sel.anchor, focus: pos });\n } else {\n editor.collapse(pos);\n }\n draggingRef.current = true;\n };\n\n const onKeyDown = (e: KeyboardEvent) => {\n handleKeyDown(editor, e, { readOnly });\n };\n\n const commitInput = () => {\n const el = inputRef.current;\n if (!el) return;\n const value = el.value;\n if (value) {\n if (!readOnly) editor.insertText(value);\n el.value = \"\";\n }\n };\n\n const onInput = (e: FormEvent<HTMLTextAreaElement>) => {\n if (composingRef.current || (e.nativeEvent as InputEvent).isComposing) return;\n commitInput();\n };\n\n const onCompositionStart = () => {\n composingRef.current = true;\n };\n\n const onCompositionEnd = (e: CompositionEvent<HTMLTextAreaElement>) => {\n composingRef.current = false;\n const el = inputRef.current;\n if (el) {\n if (e.data && !readOnly) editor.insertText(e.data);\n el.value = \"\";\n }\n };\n\n const caret = editor.caretRect();\n const inputStyle: CSSProperties = {\n position: \"absolute\",\n left: caret ? caret.x : 0,\n top: caret ? caret.y : 0,\n width: 1,\n height: caret ? caret.height : 16,\n opacity: 0,\n padding: 0,\n border: 0,\n outline: \"none\",\n resize: \"none\",\n background: \"transparent\",\n caretColor: \"transparent\",\n color: \"transparent\",\n overflow: \"hidden\",\n whiteSpace: \"pre\",\n zIndex: 1,\n };\n\n return (\n <RenderersProvider value={renderers}>\n <div className={`ori-root${className ? ` ${className}` : \"\"}`} style={style}>\n <div className=\"ori-scroller\" ref={scrollerRef} onScroll={onScroll} onMouseDown={onMouseDown}>\n <div\n className=\"ori-content\"\n ref={contentRef}\n style={{ maxWidth, marginInline: \"auto\", position: \"relative\" }}\n >\n <div\n className=\"ori-canvas\"\n style={{ position: \"relative\", width: \"100%\", height: snapshot.totalHeight }}\n >\n <SelectionLayer editor={editor} snapshot={snapshot} />\n {snapshot.visible.map((block) => (\n <BlockView key={block.id} editor={editor} block={block} />\n ))}\n <CaretLayer editor={editor} snapshot={snapshot} focused={focused} />\n {snapshot.empty && placeholder ? (\n <div className=\"ori-placeholder\" aria-hidden>\n {placeholder}\n </div>\n ) : null}\n {!readOnly ? (\n <textarea\n ref={inputRef}\n className=\"ori-input\"\n style={inputStyle}\n spellCheck={false}\n autoCapitalize=\"off\"\n autoCorrect=\"off\"\n onKeyDown={onKeyDown}\n onInput={onInput}\n onCompositionStart={onCompositionStart}\n onCompositionEnd={onCompositionEnd}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n onCopy={(e) => {\n e.preventDefault();\n e.clipboardData.setData(\"text/plain\", editor.getSelectedText());\n }}\n onCut={(e) => {\n e.preventDefault();\n e.clipboardData.setData(\"text/plain\", editor.getSelectedText());\n editor.deleteBackward();\n }}\n onPaste={(e) => {\n e.preventDefault();\n pasteText(editor, e.clipboardData.getData(\"text/plain\"));\n }}\n />\n ) : null}\n </div>\n </div>\n </div>\n </div>\n </RenderersProvider>\n );\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/useEditor.ts","../src/hooks.ts","../src/renderers.tsx","../src/BlockView.tsx","../src/Overlay.tsx","../src/internal.ts","../src/keymap.ts","../src/NoteEditor.tsx"],"names":["jsx","useRef","NoteEditor","useMemo","useEffect"],"mappings":";;;;;;AA8BO,SAAS,SAAA,CAAU,OAAA,GAA4B,EAAC,EAAqB;AAC1E,EAAA,MA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;AAAA,cAAA;AAAA,gBACC,GAAA,EAAK,QAAA;AAAA,gBACL,SAAA,EAAU,WAAA;AAAA,gBACV,KAAA,EAAO,UAAA;AAAA,gBACP,UAAA,EAAY,KAAA;AAAA,gBACZ,cAAA,EAAe,KAAA;AAAA,gBACf,WAAA,EAAY,KAAA;AAAA,gBACZ,SAAA;AAAA,gBACA,OAAA;AAAA,gBACA,kBAAA;AAAA,gBACA,gBAAA;AAAA,gBACA,OAAA,EAAS,MAAM,UAAA,CAAW,IAAI,CAAA;AAAA,gBAC9B,MAAA,EAAQ,MAAM,UAAA,CAAW,KAAK,CAAA;AAAA,gBAC9B,MAAA,EAAQ,CAAC,CAAA,KAAM;AACb,kBAAA,CAAA,CAAE,cAAA,EAAe;AACjB,kBAAA,CAAA,CAAE,aAAA,CAAc,OAAA,CAAQ,YAAA,EAAc,MAAA,CAAO,iBAAiB,CAAA;AAAA,gBAChE,CAAA;AAAA,gBACA,KAAA,EAAO,CAAC,CAAA,KAAM;AACZ,kBAAA,CAAA,CAAE,cAAA,EAAe;AACjB,kBAAA,CAAA,CAAE,aAAA,CAAc,OAAA,CAAQ,YAAA,EAAc,MAAA,CAAO,iBAAiB,CAAA;AAC9D,kBAAA,MAAA,CAAO,cAAA,EAAe;AAAA,gBACxB,CAAA;AAAA,gBACA,OAAA,EAAS,CAAC,CAAA,KAAM;AACd,kBAAA,CAAA,CAAE,cAAA,EAAe;AACjB,kBAAA,SAAA,CAAU,MAAA,EAAQ,CAAA,CAAE,aAAA,CAAc,OAAA,CAAQ,YAAY,CAAC,CAAA;AAAA,gBACzD;AAAA;AAAA,aACF,GACE;AAAA;AAAA;AAAA;AACN;AAAA,GACF,EACF,GACA,CAAA,EACF,CAAA;AAEJ,CAAC","file":"index.js","sourcesContent":["import {\n EditorController,\n createCanvasMeasurer,\n type EditorSchema,\n type Measurer,\n type Typography,\n} from \"@wingleeio/ori-core\";\nimport { useEffect, useRef } from \"react\";\nimport type * as Y from \"yjs\";\n\nexport interface UseEditorOptions {\n /** Existing note `Y.Doc`. When switching notes, remount via `key` instead. */\n doc?: Y.Doc;\n typography?: Typography;\n measurer?: Measurer;\n overscan?: number;\n blockSpacing?: number;\n /** Custom block/atom nodes, merged over the built-ins. */\n schema?: Partial<EditorSchema>;\n}\n\n/**\n * Create (once) and own an {@link EditorController} for the lifetime of the\n * component. To switch documents, give the hosting component a `key` so it\n * remounts with a fresh controller.\n *\n * The controller is reconnected on mount and disconnected on unmount rather than\n * destroyed, so React StrictMode's dev mount → unmount → remount cycle reuses the\n * same controller (with all its state) instead of leaving a torn-down one behind.\n */\nexport function useEditor(options: UseEditorOptions = {}): EditorController {\n const ref = useRef<EditorController | null>(null);\n if (ref.current === null) {\n ref.current = new EditorController({\n doc: options.doc,\n measurer: options.measurer ?? createCanvasMeasurer(),\n typography: options.typography,\n overscan: options.overscan,\n blockSpacing: options.blockSpacing,\n schema: options.schema,\n });\n }\n useEffect(() => {\n const editor = ref.current;\n editor?.connect();\n return () => editor?.disconnect();\n }, []);\n return ref.current;\n}\n","import type { EditorController, EditorSnapshot, Marks } from \"@wingleeio/ori-core\";\nimport { useSyncExternalStore } from \"react\";\n\n/** Subscribe a component to the controller's snapshot stream. */\nexport function useEditorSnapshot(editor: EditorController): EditorSnapshot {\n return useSyncExternalStore(editor.subscribe, editor.getSnapshot, editor.getSnapshot);\n}\n\n/**\n * The marks active at the current selection. Recomputed whenever the editor\n * notifies (selection move, edit, or pending-mark toggle), so toolbars stay in\n * sync without their own subscription.\n */\nexport function useActiveMarks(editor: EditorController): Marks {\n const snapshot = useEditorSnapshot(editor);\n // `revision` changes on every notify; reading it ties this to the store.\n void snapshot.revision;\n return editor.getActiveMarks();\n}\n","import type { BlockLayout, EditorController, InlineAtom, VisibleBlock } from \"@wingleeio/ori-core\";\nimport { createContext, useContext, type ReactNode } from \"react\";\n\n/** Props for a custom block renderer (atomic nodes: divider, image, …). */\nexport interface BlockRendererProps {\n editor: EditorController;\n block: VisibleBlock;\n /** The block's synthetic layout (atomic blocks: one line, no fragments). */\n layout: BlockLayout;\n}\nexport type BlockRenderer = (props: BlockRendererProps) => ReactNode;\n\n/** Props for a custom inline-atom renderer (mention chip, inline math, …). */\nexport interface AtomRendererProps {\n editor: EditorController;\n atom: InlineAtom;\n}\nexport type AtomRenderer = (props: AtomRendererProps) => ReactNode;\n\nexport interface Renderers {\n blocks: Record<string, BlockRenderer>;\n atoms: Record<string, AtomRenderer>;\n}\n\nconst EMPTY: Renderers = { blocks: {}, atoms: {} };\n\nconst RenderersContext = createContext<Renderers>(EMPTY);\nexport const RenderersProvider = RenderersContext.Provider;\nexport const useRenderers = (): Renderers => useContext(RenderersContext);\n","import type { EditorController, Fragment, InlineAtom, Line, VisibleBlock } from \"@wingleeio/ori-core\";\nimport type { CSSProperties } from \"react\";\nimport { useRenderers, type AtomRenderer } from \"./renderers\";\n\nfunction fragmentStyle(frag: Fragment): CSSProperties {\n const f = frag.font;\n const decoration: string[] = [];\n if (frag.marks.underline) decoration.push(\"underline\");\n if (frag.marks.strike) decoration.push(\"line-through\");\n return {\n fontFamily: f.fontFamily,\n fontSize: f.fontSize,\n fontWeight: f.fontWeight,\n fontStyle: f.italic ? \"italic\" : \"normal\",\n letterSpacing: f.letterSpacing || undefined,\n textDecorationLine: decoration.length ? decoration.join(\" \") : undefined,\n };\n}\n\n/** An inline atom, sized to the exact width Pretext laid out for it. */\nfunction AtomFragment({\n editor,\n atom,\n render,\n}: {\n editor: EditorController;\n atom: InlineAtom;\n render?: AtomRenderer;\n}) {\n return (\n <span\n className=\"ori-atom\"\n style={{\n display: \"inline-block\",\n width: atom.width,\n verticalAlign: \"middle\",\n whiteSpace: \"normal\",\n }}\n >\n {render ? render({ editor, atom }) : null}\n </span>\n );\n}\n\nfunction LineView({\n line,\n editor,\n atoms,\n}: {\n line: Line;\n editor: EditorController;\n atoms: Record<string, AtomRenderer>;\n}) {\n return (\n <div\n className=\"ori-line\"\n style={{ height: line.height, lineHeight: `${line.height}px`, whiteSpace: \"pre\" }}\n >\n {line.fragments.map((frag) => {\n if (frag.atom) {\n return (\n <AtomFragment\n key={frag.start}\n editor={editor}\n atom={frag.atom}\n render={atoms[frag.atom.type]}\n />\n );\n }\n const className = [\"ori-frag\"];\n if (frag.marks.code) className.push(\"ori-frag-code\");\n if (frag.marks.link) className.push(\"ori-frag-link\");\n return (\n <span\n key={frag.start}\n className={className.join(\" \")}\n style={fragmentStyle(frag)}\n data-start={frag.start}\n >\n {frag.text}\n </span>\n );\n })}\n </div>\n );\n}\n\n/**\n * Render a visible block. Custom (atomic) block types use their registered\n * renderer; text blocks render materialized Pretext lines, with any inline\n * atoms drawn by their registered atom renderer at the measured width.\n */\nexport function BlockView({ editor, block }: { editor: EditorController; block: VisibleBlock }) {\n const { blocks, atoms } = useRenderers();\n const layout = editor.getLayout(block.id);\n if (!layout) return null;\n const custom = blocks[block.type];\n return (\n <div\n className={`ori-block ori-block-${block.type}`}\n data-block-id={block.id}\n style={{\n position: \"absolute\",\n top: block.top,\n left: 0,\n width: \"100%\",\n height: block.height,\n }}\n >\n {custom\n ? custom({ editor, block, layout })\n : layout.lines.map((line) => (\n <LineView key={line.index} line={line} editor={editor} atoms={atoms} />\n ))}\n </div>\n );\n}\n","import type { EditorController, EditorSnapshot } from \"@wingleeio/ori-core\";\nimport { isCollapsed } from \"@wingleeio/ori-core\";\n\n/** Selection rectangles for visible blocks (rendered beneath the text). */\nexport function SelectionLayer({\n editor,\n snapshot,\n}: {\n editor: EditorController;\n snapshot: EditorSnapshot;\n}) {\n // Tie recomputation to the snapshot revision.\n void snapshot.revision;\n const rects = editor.selectionRectsForViewport();\n if (rects.length === 0) return null;\n return (\n <div className=\"ori-selection-layer\" aria-hidden>\n {rects.map((r, i) => (\n <div\n key={`${r.blockId}:${i}`}\n className=\"ori-selection-rect\"\n style={{ position: \"absolute\", left: r.x, top: r.y, width: r.width, height: r.height }}\n />\n ))}\n </div>\n );\n}\n\n/** Blinking caret, shown only when focused and the selection is collapsed. */\nexport function CaretLayer({\n editor,\n snapshot,\n focused,\n}: {\n editor: EditorController;\n snapshot: EditorSnapshot;\n focused: boolean;\n}) {\n const sel = snapshot.selection;\n if (!focused || !sel || !isCollapsed(sel)) return null;\n const rect = editor.caretRect();\n if (!rect) return null;\n return (\n <div\n className=\"ori-caret\"\n style={{ position: \"absolute\", left: rect.x, top: rect.y, height: rect.height }}\n aria-hidden\n />\n );\n}\n","import { useMemo, useRef } from \"react\";\n\n/**\n * Wrap a frequently-changing callback in a stable identity so it can be used in\n * effect dependency lists without re-subscribing. The latest closure is always\n * invoked.\n */\nexport function useCallbackRef<Args extends unknown[], Return>(\n fn: (...args: Args) => Return,\n): (...args: Args) => Return {\n const ref = useRef(fn);\n ref.current = fn;\n return useMemo(() => (...args: Args) => ref.current(...args), []);\n}\n","import type { EditorController } from \"@wingleeio/ori-core\";\nimport type { KeyboardEvent } from \"react\";\n\nexport interface KeymapOptions {\n readOnly?: boolean;\n}\n\n/** Insert clipboard text, mapping newlines to paragraph splits. */\nexport function pasteText(editor: EditorController, text: string): void {\n const parts = text.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n editor.insertText(parts[0]);\n for (let i = 1; i < parts.length; i += 1) {\n editor.insertParagraphBreak();\n if (parts[i]) editor.insertText(parts[i]);\n }\n}\n\n/**\n * Translate a keyboard event into editor commands. Character insertion is left\n * to the textarea `input`/`composition` events; this handles control keys,\n * navigation and formatting shortcuts only.\n *\n * Returns true if the event was handled (and `preventDefault` was called).\n */\nexport function handleKeyDown(\n editor: EditorController,\n e: KeyboardEvent,\n opts: KeymapOptions = {},\n): boolean {\n if (e.nativeEvent.isComposing) return false;\n // Alt/Option combos are reserved for app-level shortcuts (e.g. note switching),\n // so let them bubble instead of moving the caret.\n if (e.altKey) return false;\n const mod = e.metaKey || e.ctrlKey;\n const shift = e.shiftKey;\n const ro = !!opts.readOnly;\n\n if (mod) {\n switch (e.key.toLowerCase()) {\n case \"b\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"bold\");\n return true;\n case \"i\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"italic\");\n return true;\n case \"u\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"underline\");\n return true;\n case \"e\":\n e.preventDefault();\n if (!ro) editor.toggleMark(\"code\");\n return true;\n case \"a\":\n e.preventDefault();\n editor.selectAll();\n return true;\n case \"z\":\n e.preventDefault();\n if (!ro) (shift ? editor.redo() : editor.undo());\n return true;\n case \"y\":\n e.preventDefault();\n if (!ro) editor.redo();\n return true;\n case \"arrowleft\":\n e.preventDefault();\n editor.moveCaret(\"lineStart\", shift);\n return true;\n case \"arrowright\":\n e.preventDefault();\n editor.moveCaret(\"lineEnd\", shift);\n return true;\n // Let the browser raise copy/cut/paste on the textarea.\n case \"c\":\n case \"x\":\n case \"v\":\n return false;\n default:\n return false;\n }\n }\n\n switch (e.key) {\n case \"Backspace\":\n e.preventDefault();\n if (!ro) editor.deleteBackward();\n return true;\n case \"Delete\":\n e.preventDefault();\n if (!ro) editor.deleteForward();\n return true;\n case \"Enter\":\n e.preventDefault();\n if (!ro) editor.insertParagraphBreak();\n return true;\n case \"Tab\":\n e.preventDefault();\n if (!ro) editor.insertText(\" \");\n return true;\n case \"ArrowLeft\":\n e.preventDefault();\n editor.moveCaret(\"left\", shift);\n return true;\n case \"ArrowRight\":\n e.preventDefault();\n editor.moveCaret(\"right\", shift);\n return true;\n case \"ArrowUp\":\n e.preventDefault();\n editor.moveCaret(\"up\", shift);\n return true;\n case \"ArrowDown\":\n e.preventDefault();\n editor.moveCaret(\"down\", shift);\n return true;\n case \"Home\":\n e.preventDefault();\n editor.moveCaret(\"lineStart\", shift);\n return true;\n case \"End\":\n e.preventDefault();\n editor.moveCaret(\"lineEnd\", shift);\n return true;\n default:\n return false;\n }\n}\n","import type { EditorController } from \"@wingleeio/ori-core\";\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type CompositionEvent,\n type FormEvent,\n type KeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n} from \"react\";\nimport { BlockView } from \"./BlockView\";\nimport { CaretLayer, SelectionLayer } from \"./Overlay\";\nimport { useEditorSnapshot } from \"./hooks\";\nimport { useCallbackRef } from \"./internal\";\nimport { handleKeyDown, pasteText } from \"./keymap\";\nimport { RenderersProvider, type AtomRenderer, type BlockRenderer } from \"./renderers\";\n\nexport interface NoteEditorProps {\n editor: EditorController;\n className?: string;\n style?: CSSProperties;\n /** Max width of the centered content column, in px. */\n maxWidth?: number;\n placeholder?: string;\n autoFocus?: boolean;\n readOnly?: boolean;\n /** Renderers for custom (atomic) block node types. */\n blockRenderers?: Record<string, BlockRenderer>;\n /** Renderers for custom inline atom types. */\n atomRenderers?: Record<string, AtomRenderer>;\n}\n\n/** A viewport-space rectangle (client coordinates). */\nexport interface ViewportRect {\n top: number;\n left: number;\n right: number;\n bottom: number;\n width: number;\n height: number;\n}\n\n/** Imperative handle for building floating UI (slash / selection menus). */\nexport interface NoteEditorHandle {\n focus(): void;\n /** Caret position in viewport coordinates, or null if unavailable. */\n getCaretRect(): { x: number; y: number; height: number } | null;\n /** Bounding box of the current selection in viewport coordinates, or null. */\n getSelectionRect(): ViewportRect | null;\n /** The scrolling element, for scroll-aware positioning. */\n getScrollElement(): HTMLElement | null;\n}\n\n/**\n * A fully virtualized, Pretext-laid-out note editor. Renders only the blocks\n * intersecting the viewport; selection and caret are drawn from logical state\n * so they remain correct across offscreen content.\n */\nexport const NoteEditor = forwardRef<NoteEditorHandle, NoteEditorProps>(function NoteEditor(\n {\n editor,\n className,\n style,\n maxWidth = 720,\n placeholder = \"Start writing…\",\n autoFocus,\n readOnly,\n blockRenderers,\n atomRenderers,\n },\n ref,\n) {\n const snapshot = useEditorSnapshot(editor);\n const renderers = useMemo(\n () => ({ blocks: blockRenderers ?? {}, atoms: atomRenderers ?? {} }),\n [blockRenderers, atomRenderers],\n );\n const scrollerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const draggingRef = useRef(false);\n const composingRef = useRef(false);\n const [focused, setFocused] = useState(false);\n\n useImperativeHandle(\n ref,\n (): NoteEditorHandle => ({\n focus: () => inputRef.current?.focus(),\n getCaretRect: () => {\n const c = editor.caretRect();\n const content = contentRef.current;\n if (!c || !content) return null;\n const r = content.getBoundingClientRect();\n return { x: r.left + c.x, y: r.top + c.y, height: c.height };\n },\n getSelectionRect: () => {\n const content = contentRef.current;\n if (!content) return null;\n const rects = editor.selectionRectsForViewport();\n if (rects.length === 0) return null;\n const r = content.getBoundingClientRect();\n let top = Infinity;\n let left = Infinity;\n let bottom = -Infinity;\n let right = -Infinity;\n for (const rc of rects) {\n top = Math.min(top, r.top + rc.y);\n left = Math.min(left, r.left + rc.x);\n bottom = Math.max(bottom, r.top + rc.y + rc.height);\n right = Math.max(right, r.left + rc.x + rc.width);\n }\n return { top, left, right, bottom, width: right - left, height: bottom - top };\n },\n getScrollElement: () => scrollerRef.current,\n }),\n [editor],\n );\n\n // Keep width + viewport in sync with the DOM.\n useLayoutEffect(() => {\n const scroller = scrollerRef.current;\n const content = contentRef.current;\n if (!scroller || !content) return;\n const sync = () => {\n editor.setWidth(content.clientWidth);\n editor.setViewport(scroller.scrollTop, scroller.clientHeight);\n };\n sync();\n const ro = new ResizeObserver(sync);\n ro.observe(scroller);\n ro.observe(content);\n return () => ro.disconnect();\n }, [editor]);\n\n // Recompute measurements once web fonts have loaded.\n useEffect(() => {\n const fonts = (document as Document & { fonts?: FontFaceSet }).fonts;\n if (fonts?.ready) void fonts.ready.then(() => editor.invalidateMeasurements());\n }, [editor]);\n\n useEffect(() => {\n if (autoFocus) inputRef.current?.focus();\n }, [autoFocus]);\n\n const pointToPosition = useCallbackRef((clientX: number, clientY: number) => {\n const content = contentRef.current;\n if (!content) return null;\n const rect = content.getBoundingClientRect();\n return editor.positionFromPoint(clientX - rect.left, clientY - rect.top);\n });\n\n // Drag-to-select with window-level listeners.\n useEffect(() => {\n const onMove = (e: globalThis.MouseEvent) => {\n if (!draggingRef.current) return;\n const pos = pointToPosition(e.clientX, e.clientY);\n const sel = editor.getSelection();\n if (pos && sel) editor.setSelection({ anchor: sel.anchor, focus: pos });\n };\n const onUp = () => {\n draggingRef.current = false;\n };\n window.addEventListener(\"mousemove\", onMove);\n window.addEventListener(\"mouseup\", onUp);\n return () => {\n window.removeEventListener(\"mousemove\", onMove);\n window.removeEventListener(\"mouseup\", onUp);\n };\n }, [editor, pointToPosition]);\n\n const onScroll = () => {\n const scroller = scrollerRef.current;\n if (scroller) editor.setViewport(scroller.scrollTop, scroller.clientHeight);\n };\n\n // Bound to the whole scroller (not just the text canvas) so clicking any\n // empty space — padding, the gutter below the last block — still focuses the\n // editor and drops the caret at the nearest position (positionFromPoint clamps).\n const onMouseDown = (e: ReactMouseEvent) => {\n if (e.button !== 0) return;\n const scroller = scrollerRef.current;\n // Ignore the native scrollbar gutter so scrollbar drags keep working.\n if (scroller && e.clientX - scroller.getBoundingClientRect().left >= scroller.clientWidth) {\n return;\n }\n inputRef.current?.focus();\n const pos = pointToPosition(e.clientX, e.clientY);\n if (!pos) return;\n e.preventDefault();\n const sel = editor.getSelection();\n if (e.shiftKey && sel) {\n editor.setSelection({ anchor: sel.anchor, focus: pos });\n } else {\n editor.collapse(pos);\n }\n draggingRef.current = true;\n };\n\n const onKeyDown = (e: KeyboardEvent) => {\n handleKeyDown(editor, e, { readOnly });\n };\n\n const commitInput = () => {\n const el = inputRef.current;\n if (!el) return;\n const value = el.value;\n if (value) {\n if (!readOnly) editor.insertText(value);\n el.value = \"\";\n }\n };\n\n const onInput = (e: FormEvent<HTMLTextAreaElement>) => {\n if (composingRef.current || (e.nativeEvent as InputEvent).isComposing) return;\n commitInput();\n };\n\n const onCompositionStart = () => {\n composingRef.current = true;\n };\n\n const onCompositionEnd = (e: CompositionEvent<HTMLTextAreaElement>) => {\n composingRef.current = false;\n const el = inputRef.current;\n if (el) {\n if (e.data && !readOnly) editor.insertText(e.data);\n el.value = \"\";\n }\n };\n\n const caret = editor.caretRect();\n const inputStyle: CSSProperties = {\n position: \"absolute\",\n left: caret ? caret.x : 0,\n top: caret ? caret.y : 0,\n width: 1,\n height: caret ? caret.height : 16,\n opacity: 0,\n padding: 0,\n border: 0,\n outline: \"none\",\n resize: \"none\",\n background: \"transparent\",\n caretColor: \"transparent\",\n color: \"transparent\",\n overflow: \"hidden\",\n whiteSpace: \"pre\",\n zIndex: 1,\n };\n\n return (\n <RenderersProvider value={renderers}>\n <div className={`ori-root${className ? ` ${className}` : \"\"}`} style={style}>\n <div className=\"ori-scroller\" ref={scrollerRef} onScroll={onScroll} onMouseDown={onMouseDown}>\n <div\n className=\"ori-content\"\n ref={contentRef}\n style={{ maxWidth, marginInline: \"auto\", position: \"relative\" }}\n >\n <div\n className=\"ori-canvas\"\n style={{ position: \"relative\", width: \"100%\", height: snapshot.totalHeight }}\n >\n <SelectionLayer editor={editor} snapshot={snapshot} />\n {snapshot.visible.map((block) => (\n <BlockView key={block.id} editor={editor} block={block} />\n ))}\n <CaretLayer editor={editor} snapshot={snapshot} focused={focused} />\n {snapshot.empty && placeholder ? (\n <div className=\"ori-placeholder\" aria-hidden>\n {placeholder}\n </div>\n ) : null}\n {!readOnly ? (\n <textarea\n ref={inputRef}\n className=\"ori-input\"\n style={inputStyle}\n spellCheck={false}\n autoCapitalize=\"off\"\n autoCorrect=\"off\"\n onKeyDown={onKeyDown}\n onInput={onInput}\n onCompositionStart={onCompositionStart}\n onCompositionEnd={onCompositionEnd}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n onCopy={(e) => {\n e.preventDefault();\n e.clipboardData.setData(\"text/plain\", editor.getSelectedText());\n }}\n onCut={(e) => {\n e.preventDefault();\n e.clipboardData.setData(\"text/plain\", editor.getSelectedText());\n editor.deleteBackward();\n }}\n onPaste={(e) => {\n e.preventDefault();\n pasteText(editor, e.clipboardData.getData(\"text/plain\"));\n }}\n />\n ) : null}\n </div>\n </div>\n </div>\n </div>\n </RenderersProvider>\n );\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wingleeio/ori-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "React bindings for the Ori virtualized, local-first note editor.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"styles.css"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@wingleeio/ori-core": "0.0.
|
|
38
|
+
"@wingleeio/ori-core": "0.0.2",
|
|
39
39
|
"@wingleeio/ori-pretext": "0.0.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|