@particle-academy/react-fancy 6.4.0 → 6.5.0
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/CHANGELOG.md +16 -0
- package/dist/CodeBlock.types-BFMFB4X2.d.cts +53 -0
- package/dist/CodeBlock.types-BFMFB4X2.d.ts +53 -0
- package/dist/{chunk-P24A2BIR.js → chunk-PVHZO4T3.js} +4 -4
- package/dist/chunk-PVHZO4T3.js.map +1 -0
- package/dist/{chunk-VAVS6WRZ.cjs → chunk-QH4YSG7C.cjs} +3 -4
- package/dist/chunk-QH4YSG7C.cjs.map +1 -0
- package/dist/{chunk-VQLPAYQF.cjs → chunk-RE4BYTVM.cjs} +4 -4
- package/dist/{chunk-VQLPAYQF.cjs.map → chunk-RE4BYTVM.cjs.map} +1 -1
- package/dist/{chunk-NIAG6OF6.cjs → chunk-TQL3QW7F.cjs} +3 -3
- package/dist/chunk-TQL3QW7F.cjs.map +1 -0
- package/dist/{chunk-AHZIT3CM.js → chunk-YRI6OFLY.js} +4 -5
- package/dist/chunk-YRI6OFLY.js.map +1 -0
- package/dist/{chunk-UMDOSJUH.js → chunk-YYNUTUJO.js} +3 -3
- package/dist/{chunk-UMDOSJUH.js.map → chunk-YYNUTUJO.js.map} +1 -1
- package/dist/code-block.cjs +2 -2
- package/dist/code-block.d.cts +3 -45
- package/dist/code-block.d.ts +3 -45
- package/dist/code-block.js +1 -1
- package/dist/code-view.cjs +2 -2
- package/dist/code-view.d.cts +9 -6
- package/dist/code-view.d.ts +9 -6
- package/dist/code-view.js +1 -1
- package/dist/editor.cjs +4 -4
- package/dist/editor.js +2 -2
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -3
- package/docs/CodeBlock.md +19 -2
- package/docs/CodeView.md +21 -5
- package/package.json +2 -2
- package/dist/chunk-AHZIT3CM.js.map +0 -1
- package/dist/chunk-NIAG6OF6.cjs.map +0 -1
- package/dist/chunk-P24A2BIR.js.map +0 -1
- package/dist/chunk-VAVS6WRZ.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Editor/Editor.context.ts","../src/components/Editor/EditorSourceToggle.tsx","../src/components/Editor/EditorFullScreenToggle.tsx","../src/components/Editor/EditorToolbar.tsx","../src/components/Editor/EditorToolbarSeparator.tsx","../src/components/Editor/EditorContent.tsx","../src/components/Editor/Editor.tsx"],"names":["jsx","useRef","useEffect","useMemo"],"mappings":";;;;;;;;;;;;AAgCO,IAAM,aAAA,GAAgB,cAAyC,IAAI,CAAA;AAEnE,SAAS,SAAA,GAAgC;AAC9C,EAAA,MAAM,GAAA,GAAM,WAAW,aAAa,CAAA;AACpC,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA,MAAM,IAAI,MAAM,qDAAqD,CAAA;AAAA,EACvE;AACA,EAAA,OAAO,GAAA;AACT;AC/BO,SAAS,kBAAA,CAAmB;AAAA,EACjC,SAAA;AAAA,EACA,IAAA,GAAO,KAAA;AAAA,EACP,KAAA,GAAQ,QAAA;AAAA,EACR,WAAA,GAAc;AAChB,CAAA,EAA4B;AAC1B,EAAA,MAAM,EAAE,UAAA,EAAY,aAAA,EAAc,GAAI,SAAA,EAAU;AAEhD,EAAA,uBACE,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAK,QAAA;AAAA,MACL,OAAA,EAAS,MAAM,aAAA,CAAc,CAAC,UAAU,CAAA;AAAA,MACxC,KAAA,EAAO,aAAa,WAAA,GAAc,KAAA;AAAA,MAClC,cAAA,EAAc,UAAA;AAAA,MACd,uCAAA,EAAsC,EAAA;AAAA,MACtC,SAAA,EAAW,EAAA;AAAA,QACT,iGAAA;AAAA,QACA,aACI,qHAAA,GACA,+IAAA;AAAA,QACJ;AAAA,OACF;AAAA,MAEC,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ;AAEA,kBAAA,CAAmB,WAA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AA;AAAA,YACC,KAAA;AAAA,YACA,MAAA,EAAQ,WAAA,KAAgB,MAAA,GAAS,WAAA,GAAc,YAAA;AAAA,YAC/C,WAAA;AAAA,YACA,UAAA,EAAY,kBAAA;AAAA,YACZ,MAAA;AAAA,YACA,WAAA;AAAA,YACA,eAAA;AAAA,YACA,MAAA;AAAA,YACA,SAAA,EAAU;AAAA;AAAA;AACZ;AAAA,KACF,EACF,CAAA;AAAA,EAEJ;AAEA,EAAA,uBACEA,GAAAA,CAAC,aAAA,CAAc,QAAA,EAAd,EAAuB,KAAA,EAAO,YAAA,EAC7B,QAAA,kBAAAA,GAAAA,CAAC,kBAAA,EAAA,EAAmB,KAAA,EAAO,EAAA,EACzB,QAAA,kBAAAA,GAAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACE,GAAG,EAAA,CAAG,WAAA;AAAA,MACP,yBAAA,EAAwB,EAAA;AAAA,MACxB,WAAA,EAAU,MAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,gSAAA;AAAA,QACA;AAAA,OACF;AAAA,MAEC;AAAA;AAAA,KAEL,CAAA,EACF,CAAA;AAEJ;AAEA,IAAM,oBAAA,GAAuB,MAAA,CAAO,MAAA,CAAO,aAAA,EAAe;AAAA,EACxD,SAAA,EAAW;AACb,CAAC,CAAA;AAEM,IAAM,MAAA,GAAS,MAAA,CAAO,MAAA,CAAO,UAAA,EAAY;AAAA,EAC9C,OAAA,EAAS,oBAAA;AAAA,EACT,OAAA,EAAS,aAAA;AAAA,EACT,YAAA,EAAc,kBAAA;AAAA,EACd,gBAAA,EAAkB;AACpB,CAAC","file":"chunk-UMDOSJUH.js","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { RefObject } from \"react\";\nimport type { RenderExtension } from \"../ContentRenderer/extensions\";\n\nexport interface EditorContextValue {\n contentRef: RefObject<HTMLDivElement | null>;\n exec: (command: string, arg?: string) => void;\n insertText: (text: string) => void;\n wrapSelection: (before: string, after: string) => void;\n outputFormat: \"html\" | \"markdown\";\n lineSpacing: number;\n placeholder?: string;\n /** Merged render extensions (global + instance). */\n extensions: RenderExtension[];\n /** Whether the raw-source view (textarea) is showing instead of the rich-text surface. */\n showSource: boolean;\n /** Toggle/set the raw-source view. */\n setShowSource: (showSource: boolean) => void;\n /** Whether the editor currently covers the viewport. */\n fullScreen: boolean;\n /** Enter/leave full screen. Goes through `onFullScreenChange` when controlled. */\n setFullScreen: (fullScreen: boolean) => void;\n /** Initial HTML content to load into the editor on mount */\n _initialHtml: string;\n /** @internal Called by EditorContent on input events */\n _onInput: () => void;\n /** @internal Raw source value (`value` in `outputFormat`), for the source textarea. */\n _sourceValue: string;\n /** @internal Commit an edit made directly in the source textarea. */\n _onSourceInput: (value: string) => void;\n}\n\nexport const EditorContext = createContext<EditorContextValue | null>(null);\n\nexport function useEditor(): EditorContextValue {\n const ctx = useContext(EditorContext);\n if (!ctx) {\n throw new Error(\"useEditor must be used within an <Editor> component\");\n }\n return ctx;\n}\n","import { cn } from \"../../utils/cn\";\nimport { useEditor } from \"./Editor.context\";\nimport type { EditorSourceToggleProps } from \"./Editor.types\";\n\n/**\n * Toolbar button that reveals the raw HTML/Markdown behind the editor. Reads\n * `showSource` / `setShowSource` from context, so it works in the default\n * toolbar and in any custom toolbar composed with `useEditor()`.\n */\nexport function EditorSourceToggle({\n className,\n icon = \"</>\",\n title = \"Source\",\n activeTitle = \"Rich text\",\n}: EditorSourceToggleProps) {\n const { showSource, setShowSource } = useEditor();\n\n return (\n <button\n type=\"button\"\n onClick={() => setShowSource(!showSource)}\n title={showSource ? activeTitle : title}\n aria-pressed={showSource}\n data-react-fancy-editor-source-toggle=\"\"\n className={cn(\n \"inline-flex h-8 items-center justify-center rounded-md px-2 font-mono text-xs transition-colors\",\n showSource\n ? \"bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\"\n : \"hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\",\n className,\n )}\n >\n {icon}\n </button>\n );\n}\n\nEditorSourceToggle.displayName = \"EditorSourceToggle\";\n","import { cn } from \"../../utils/cn\";\nimport { FullScreenToggle } from \"../FullScreen/FullScreenToggle\";\nimport type { EditorFullScreenToggleProps } from \"./Editor.types\";\n\n/**\n * Toolbar button that takes the editor full screen and back. The shared\n * `FullScreen.Toggle`, styled for the editor toolbar and carrying the editor's\n * own handle (`data-react-fancy-editor-fullscreen-toggle`) next to the shared\n * one (`data-react-fancy-fullscreen-toggle`).\n */\nexport function EditorFullScreenToggle({ className, enterIcon, exitIcon }: EditorFullScreenToggleProps) {\n return (\n <FullScreenToggle\n data-react-fancy-editor-fullscreen-toggle=\"\"\n enterIcon={enterIcon}\n exitIcon={exitIcon}\n className={cn(className)}\n />\n );\n}\n\nEditorFullScreenToggle.displayName = \"EditorFullScreenToggle\";\n","import { cn } from \"../../utils/cn\";\nimport { useEditor } from \"./Editor.context\";\nimport { EditorSourceToggle } from \"./EditorSourceToggle\";\nimport { EditorFullScreenToggle } from \"./EditorFullScreenToggle\";\nimport type { EditorToolbarProps } from \"./Editor.types\";\n\nconst DEFAULT_ACTIONS = [\n { icon: \"B\", label: \"Bold\", command: \"bold\" },\n { icon: \"I\", label: \"Italic\", command: \"italic\" },\n { icon: \"U\", label: \"Underline\", command: \"underline\" },\n { icon: \"S\", label: \"Strikethrough\", command: \"strikeThrough\" },\n];\n\nexport function EditorToolbar({\n actions = DEFAULT_ACTIONS,\n onAction,\n children,\n className,\n showSourceToggle = true,\n showFullScreenToggle = false,\n toolbarExtra,\n}: EditorToolbarProps) {\n const { exec, showSource } = useEditor();\n // `null` / `false` / `undefined` render nothing, so they must not add a\n // wrapper either: an unused slot leaves the toolbar byte-identical.\n const hasExtra = toolbarExtra !== undefined && toolbarExtra !== null && toolbarExtra !== false;\n\n return (\n <div\n data-react-fancy-editor-toolbar=\"\"\n className={cn(\n \"flex shrink-0 items-center gap-0.5 border-b border-[color:var(--fancy-border,var(--color-zinc-200))] px-2 py-1.5 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n className,\n )}\n >\n {children ?? (\n <>\n {actions.map((action) => (\n <button\n key={`${action.command}-${action.commandArg ?? \"\"}`}\n type=\"button\"\n // Rich-text commands don't apply to the raw-source textarea.\n disabled={showSource}\n onClick={() => {\n if (onAction) {\n onAction(action.command);\n } else {\n exec(action.command, action.commandArg);\n }\n }}\n title={action.label}\n className={cn(\n \"inline-flex h-8 w-8 items-center justify-center rounded-md text-sm transition-colors\",\n action.active\n ? \"bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\"\n : \"hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\",\n showSource && \"cursor-not-allowed opacity-40 hover:bg-transparent\",\n )}\n >\n {action.icon}\n </button>\n ))}\n {showSourceToggle && <EditorSourceToggle className=\"ml-auto\" />}\n {hasExtra && (\n <div\n data-react-fancy-editor-toolbar-extra=\"\"\n className={cn(\"flex items-center gap-0.5\", !showSourceToggle && \"ml-auto\")}\n >\n {toolbarExtra}\n </div>\n )}\n {showFullScreenToggle && (\n <EditorFullScreenToggle className={showSourceToggle || hasExtra ? undefined : \"ml-auto\"} />\n )}\n </>\n )}\n </div>\n );\n}\n\nEditorToolbar.displayName = \"EditorToolbar\";\n","export function EditorToolbarSeparator() {\n return (\n <span\n data-react-fancy-editor-toolbar-separator=\"\"\n className=\"mx-1 h-5 w-px bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\"\n />\n );\n}\n\nEditorToolbarSeparator.displayName = \"EditorToolbarSeparator\";\n","import { useEffect, useMemo, useRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { CodeView } from \"../CodeView\";\nimport { useEditor } from \"./Editor.context\";\nimport { proseClasses, extensionEditorClasses } from \"./editor.utils\";\nimport type { EditorContentProps } from \"./Editor.types\";\n\nexport function EditorContent({ className, maxHeight: maxHeightProp, sourceClassName }: EditorContentProps) {\n const {\n contentRef,\n lineSpacing,\n placeholder,\n extensions,\n outputFormat,\n showSource,\n _initialHtml,\n _onInput,\n _sourceValue,\n _onSourceInput,\n fullScreen,\n } = useEditor();\n // Full screen means \"fill the viewport\": a height cap would leave the bottom\n // of the screen empty under a scrolled box.\n const maxHeight = fullScreen ? undefined : maxHeightProp;\n // Tracks which seed HTML is currently in the contentEditable. Seeding on the\n // seed VALUE (not a one-shot boolean) re-seeds when the source view rewrites\n // `value`, while still never re-seeding on plain keystrokes — typing leaves\n // `_initialHtml` untouched, so `seededHtml.current === _initialHtml` holds.\n const seededHtml = useRef<string | null>(null);\n\n useEffect(() => {\n // Source view replaces the contentEditable in the tree, so it unmounts.\n // Forget what we seeded — the div that returns is a fresh, empty one and\n // must always be re-seeded, even if `value` was left untouched.\n if (showSource) {\n seededHtml.current = null;\n return;\n }\n const el = contentRef.current;\n if (el && seededHtml.current !== _initialHtml) {\n el.innerHTML = _initialHtml;\n seededHtml.current = _initialHtml;\n }\n }, [contentRef, _initialHtml, showSource]);\n\n const extClasses = useMemo(\n () => extensionEditorClasses(extensions),\n [extensions],\n );\n\n if (showSource) {\n // Raw-source view — a syntax-highlighted code surface (HTML highlighted;\n // markdown/plain un-highlighted), built on the shared fancy-file-commons\n // primitives. It's a DIRECT child of the flex-column editor root (no\n // wrapper — a nested flex box collapses the fill), so `flex-auto` makes it\n // fill the editor body when height-constrained and grow with content\n // (≥ minHeight) when not. `maxHeight` caps + scrolls.\n return (\n <CodeView\n value={_sourceValue}\n onChange={_onSourceInput}\n language={outputFormat === \"html\" ? \"html\" : \"plaintext\"}\n placeholder={placeholder}\n maxHeight={maxHeight}\n className={cn(\"min-h-0 flex-auto\", sourceClassName)}\n />\n );\n }\n\n return (\n <div\n ref={contentRef}\n contentEditable\n suppressContentEditableWarning\n data-react-fancy-editor-content=\"\"\n data-placeholder={placeholder}\n onInput={_onInput}\n style={{\n lineHeight: lineSpacing,\n maxHeight: maxHeight ? `${maxHeight}px` : undefined,\n }}\n className={cn(\n \"min-h-[120px] flex-auto overflow-y-auto px-4 py-3 text-sm outline-none\",\n \"focus:outline-none\",\n proseClasses,\n extClasses,\n \"empty:before:content-[attr(data-placeholder)] empty:before:text-zinc-400 empty:before:pointer-events-none\",\n className,\n )}\n />\n );\n}\n\nEditorContent.displayName = \"EditorContent\";\n","import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { marked } from \"marked\";\nimport { cn } from \"../../utils/cn\";\nimport { sanitizeHtml } from \"../../utils/sanitize\";\nimport { useControllableState } from \"../../hooks\";\nimport { useFullScreen } from \"../../hooks/use-full-screen\";\nimport { FullScreenProvider } from \"../FullScreen/FullScreen.context\";\nimport { EditorContext } from \"./Editor.context\";\nimport { EditorToolbar } from \"./EditorToolbar\";\nimport { EditorToolbarSeparator } from \"./EditorToolbarSeparator\";\nimport { EditorSourceToggle } from \"./EditorSourceToggle\";\nimport { EditorContent } from \"./EditorContent\";\nimport { EditorFullScreenToggle } from \"./EditorFullScreenToggle\";\nimport { htmlToMarkdown, detectFormat, markdownToEditorHtml, type MarkdownSource } from \"./editor.utils\";\nimport { mergeExtensions } from \"../ContentRenderer/extensions\";\nimport { ContentRenderer } from \"../ContentRenderer/ContentRenderer\";\nimport { useFieldMode } from \"../inputs/mode/FieldMode.context\";\nimport type { EditorProps } from \"./Editor.types\";\n\ninterface Seed {\n html: string;\n /** Source map for source-preserving markdown output; null when there is none. */\n source: MarkdownSource | null;\n}\n\nfunction toHtml(\n value: string,\n outputFormat: \"html\" | \"markdown\",\n unsafe: boolean,\n valueFormat: \"markdown\" | \"html\" | \"auto\" = \"auto\",\n): Seed {\n if (!value) return { html: \"\", source: null };\n const sanitize = (html: string) => (unsafe ? html : sanitizeHtml(html));\n // An explicit valueFormat is authoritative — the sniff misclassifies\n // markdown that merely MENTIONS HTML-ish snippets (`<code>`, `<table`),\n // collapsing it into an innerHTML wall of text (#10).\n const format =\n valueFormat !== \"auto\"\n ? valueFormat\n : outputFormat === \"html\"\n ? \"html\"\n : detectFormat(value);\n if (format === \"html\") return { html: sanitize(value), source: null };\n // Markdown in, markdown out: tag each block with its source so untouched\n // blocks are emitted byte-identical.\n if (outputFormat === \"markdown\") return markdownToEditorHtml(value, sanitize);\n return { html: sanitize((marked.parse(value, { async: false }) as string).trim()), source: null };\n}\n\nfunction EditorRoot({\n children,\n className,\n value: controlledValue,\n defaultValue = \"\",\n onChange,\n outputFormat = \"html\",\n valueFormat = \"auto\",\n lineSpacing = 1.6,\n placeholder,\n mode: modeProp,\n extensions: instanceExtensions,\n unsafe = false,\n showSource: showSourceProp,\n defaultShowSource = false,\n onShowSourceChange,\n fullScreen: fullScreenProp,\n defaultFullScreen = false,\n onFullScreenChange,\n fullScreenMode = \"overlay\",\n copyButtons,\n clipboardWriter,\n onCopy,\n}: EditorProps) {\n const contentRef = useRef<HTMLDivElement | null>(null);\n const [value, setValue] = useControllableState(controlledValue, defaultValue, onChange);\n const [showSource, setShowSource] = useControllableState(\n showSourceProp,\n defaultShowSource,\n onShowSourceChange,\n );\n // Full screen is the element itself going `position: fixed`, not a portal:\n // reparenting would remount the contentEditable and lose the caret, the\n // browser's undo stack and the seeded HTML.\n const fs = useFullScreen<HTMLDivElement>({\n fullScreen: fullScreenProp,\n defaultFullScreen,\n onFullScreenChange,\n mode: fullScreenMode,\n });\n // View/edit mode — same resolution as the inputs: prop → <Form> context → \"edit\".\n const mode = useFieldMode(modeProp);\n const isView = mode === \"view\";\n\n // The value this editor last emitted through `onChange`. An incoming `value`\n // equal to it is our own keystroke echoing back; anything else came from\n // OUTSIDE — an async load, a host reset, a form repopulating.\n const lastEmitted = useRef<string | null>(null);\n\n // Bumped only on an external `value` change, so the seed memo below recomputes\n // for those and stays put while the user types. Without this, `value` was\n // excluded from the deps to avoid re-seeding on keystrokes, which also meant a\n // value arriving after mount was silently dropped and the editor stayed blank\n // forever (#15).\n const [externalSeed, setExternalSeed] = useState(0);\n useEffect(() => {\n if (value !== lastEmitted.current) setExternalSeed((n) => n + 1);\n }, [value]);\n\n const seed = useMemo(\n () => toHtml(value, outputFormat, unsafe, valueFormat),\n // Seed the contentEditable from the LIVE value when (re)entering edit mode —\n // and when returning from the raw-source view, which may have rewritten the\n // value out from under the rich-text surface. `value` itself stays out of\n // the deps so typing never re-seeds (which would fight the caret);\n // `externalSeed` covers the externally-driven case instead.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [isView, outputFormat, unsafe, valueFormat, showSource, externalSeed],\n );\n const initialHtml = seed.html;\n const seedSource = seed.source;\n\n const extensions = useMemo(\n () => mergeExtensions(instanceExtensions),\n [instanceExtensions],\n );\n\n const getOutputValue = useCallback(\n (html: string): string => {\n return outputFormat === \"markdown\" ? htmlToMarkdown(html, seedSource) : html;\n },\n [outputFormat, seedSource],\n );\n\n const handleInput = useCallback(() => {\n const el = contentRef.current;\n if (!el) return;\n const next = getOutputValue(el.innerHTML);\n // Record what we emitted BEFORE publishing it, so the value coming back in\n // is recognised as our own and does not trigger a re-seed mid-keystroke.\n lastEmitted.current = next;\n setValue(next);\n }, [setValue, getOutputValue]);\n\n const exec = useCallback(\n (command: string, arg?: string) => {\n const el = contentRef.current;\n if (!el) return;\n el.focus();\n document.execCommand(command, false, arg);\n handleInput();\n },\n [handleInput],\n );\n\n const insertText = useCallback(\n (text: string) => {\n const el = contentRef.current;\n if (!el) return;\n el.focus();\n document.execCommand(\"insertText\", false, text);\n handleInput();\n },\n [handleInput],\n );\n\n // The source textarea edits `value` directly — it is already the canonical\n // source in `outputFormat` (html or markdown), so no conversion round-trip.\n const handleSourceInput = useCallback(\n (next: string) => {\n // Also an internal emission — record it so typing in the source view is\n // not mistaken for an external change on every keystroke.\n lastEmitted.current = next;\n setValue(next);\n },\n [setValue],\n );\n\n const wrapSelection = useCallback(\n (before: string, after: string) => {\n const sel = window.getSelection();\n if (!sel || sel.rangeCount === 0) return;\n const range = sel.getRangeAt(0);\n const selectedText = range.toString();\n const el = contentRef.current;\n if (!el) return;\n el.focus();\n document.execCommand(\"insertText\", false, `${before}${selectedText}${after}`);\n handleInput();\n },\n [handleInput],\n );\n\n const contextValue = {\n contentRef,\n exec,\n insertText,\n wrapSelection,\n outputFormat,\n lineSpacing,\n placeholder,\n extensions,\n showSource,\n setShowSource,\n fullScreen: fs.fullScreen,\n setFullScreen: fs.setFullScreen,\n _initialHtml: initialHtml,\n _onInput: handleInput,\n _sourceValue: value,\n _onSourceInput: handleSourceInput,\n };\n\n // View mode — render the value read-only through ContentRenderer, matching the\n // editor's own format (markdown/html), instead of the editable toolbar+content\n // tree. Driven by `mode` / a `<Form mode=\"view\">`, exactly like the inputs.\n if (isView) {\n return (\n <FullScreenProvider value={fs}>\n <div\n {...fs.targetProps}\n data-react-fancy-editor=\"\"\n data-mode=\"view\"\n className={cn(\n \"overflow-hidden rounded-xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n className,\n // Read-only content taller than the viewport must scroll in place.\n fs.fullScreen && \"overflow-auto\",\n )}\n >\n <ContentRenderer\n value={value}\n format={valueFormat !== \"auto\" ? valueFormat : outputFormat}\n lineSpacing={lineSpacing}\n extensions={instanceExtensions}\n unsafe={unsafe}\n copyButtons={copyButtons}\n clipboardWriter={clipboardWriter}\n onCopy={onCopy}\n className=\"px-4 py-3\"\n />\n </div>\n </FullScreenProvider>\n );\n }\n\n return (\n <EditorContext.Provider value={contextValue}>\n <FullScreenProvider value={fs}>\n <div\n {...fs.targetProps}\n data-react-fancy-editor=\"\"\n data-mode=\"edit\"\n className={cn(\n \"flex flex-col overflow-hidden rounded-xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n className,\n )}\n >\n {children}\n </div>\n </FullScreenProvider>\n </EditorContext.Provider>\n );\n}\n\nconst ToolbarWithSeparator = Object.assign(EditorToolbar, {\n Separator: EditorToolbarSeparator,\n});\n\nexport const Editor = Object.assign(EditorRoot, {\n Toolbar: ToolbarWithSeparator,\n Content: EditorContent,\n SourceToggle: EditorSourceToggle,\n FullScreenToggle: EditorFullScreenToggle,\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/Editor/Editor.context.ts","../src/components/Editor/EditorSourceToggle.tsx","../src/components/Editor/EditorFullScreenToggle.tsx","../src/components/Editor/EditorToolbar.tsx","../src/components/Editor/EditorToolbarSeparator.tsx","../src/components/Editor/EditorContent.tsx","../src/components/Editor/Editor.tsx"],"names":["jsx","useRef","useEffect","useMemo"],"mappings":";;;;;;;;;;;;AAgCO,IAAM,aAAA,GAAgB,cAAyC,IAAI,CAAA;AAEnE,SAAS,SAAA,GAAgC;AAC9C,EAAA,MAAM,GAAA,GAAM,WAAW,aAAa,CAAA;AACpC,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA,MAAM,IAAI,MAAM,qDAAqD,CAAA;AAAA,EACvE;AACA,EAAA,OAAO,GAAA;AACT;AC/BO,SAAS,kBAAA,CAAmB;AAAA,EACjC,SAAA;AAAA,EACA,IAAA,GAAO,KAAA;AAAA,EACP,KAAA,GAAQ,QAAA;AAAA,EACR,WAAA,GAAc;AAChB,CAAA,EAA4B;AAC1B,EAAA,MAAM,EAAE,UAAA,EAAY,aAAA,EAAc,GAAI,SAAA,EAAU;AAEhD,EAAA,uBACE,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAK,QAAA;AAAA,MACL,OAAA,EAAS,MAAM,aAAA,CAAc,CAAC,UAAU,CAAA;AAAA,MACxC,KAAA,EAAO,aAAa,WA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d,gBAAA,EAAkB;AACpB,CAAC","file":"chunk-YYNUTUJO.js","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { RefObject } from \"react\";\nimport type { RenderExtension } from \"../ContentRenderer/extensions\";\n\nexport interface EditorContextValue {\n contentRef: RefObject<HTMLDivElement | null>;\n exec: (command: string, arg?: string) => void;\n insertText: (text: string) => void;\n wrapSelection: (before: string, after: string) => void;\n outputFormat: \"html\" | \"markdown\";\n lineSpacing: number;\n placeholder?: string;\n /** Merged render extensions (global + instance). */\n extensions: RenderExtension[];\n /** Whether the raw-source view (textarea) is showing instead of the rich-text surface. */\n showSource: boolean;\n /** Toggle/set the raw-source view. */\n setShowSource: (showSource: boolean) => void;\n /** Whether the editor currently covers the viewport. */\n fullScreen: boolean;\n /** Enter/leave full screen. Goes through `onFullScreenChange` when controlled. */\n setFullScreen: (fullScreen: boolean) => void;\n /** Initial HTML content to load into the editor on mount */\n _initialHtml: string;\n /** @internal Called by EditorContent on input events */\n _onInput: () => void;\n /** @internal Raw source value (`value` in `outputFormat`), for the source textarea. */\n _sourceValue: string;\n /** @internal Commit an edit made directly in the source textarea. */\n _onSourceInput: (value: string) => void;\n}\n\nexport const EditorContext = createContext<EditorContextValue | null>(null);\n\nexport function useEditor(): EditorContextValue {\n const ctx = useContext(EditorContext);\n if (!ctx) {\n throw new Error(\"useEditor must be used within an <Editor> component\");\n }\n return ctx;\n}\n","import { cn } from \"../../utils/cn\";\nimport { useEditor } from \"./Editor.context\";\nimport type { EditorSourceToggleProps } from \"./Editor.types\";\n\n/**\n * Toolbar button that reveals the raw HTML/Markdown behind the editor. Reads\n * `showSource` / `setShowSource` from context, so it works in the default\n * toolbar and in any custom toolbar composed with `useEditor()`.\n */\nexport function EditorSourceToggle({\n className,\n icon = \"</>\",\n title = \"Source\",\n activeTitle = \"Rich text\",\n}: EditorSourceToggleProps) {\n const { showSource, setShowSource } = useEditor();\n\n return (\n <button\n type=\"button\"\n onClick={() => setShowSource(!showSource)}\n title={showSource ? activeTitle : title}\n aria-pressed={showSource}\n data-react-fancy-editor-source-toggle=\"\"\n className={cn(\n \"inline-flex h-8 items-center justify-center rounded-md px-2 font-mono text-xs transition-colors\",\n showSource\n ? \"bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\"\n : \"hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\",\n className,\n )}\n >\n {icon}\n </button>\n );\n}\n\nEditorSourceToggle.displayName = \"EditorSourceToggle\";\n","import { cn } from \"../../utils/cn\";\nimport { FullScreenToggle } from \"../FullScreen/FullScreenToggle\";\nimport type { EditorFullScreenToggleProps } from \"./Editor.types\";\n\n/**\n * Toolbar button that takes the editor full screen and back. The shared\n * `FullScreen.Toggle`, styled for the editor toolbar and carrying the editor's\n * own handle (`data-react-fancy-editor-fullscreen-toggle`) next to the shared\n * one (`data-react-fancy-fullscreen-toggle`).\n */\nexport function EditorFullScreenToggle({ className, enterIcon, exitIcon }: EditorFullScreenToggleProps) {\n return (\n <FullScreenToggle\n data-react-fancy-editor-fullscreen-toggle=\"\"\n enterIcon={enterIcon}\n exitIcon={exitIcon}\n className={cn(className)}\n />\n );\n}\n\nEditorFullScreenToggle.displayName = \"EditorFullScreenToggle\";\n","import { cn } from \"../../utils/cn\";\nimport { useEditor } from \"./Editor.context\";\nimport { EditorSourceToggle } from \"./EditorSourceToggle\";\nimport { EditorFullScreenToggle } from \"./EditorFullScreenToggle\";\nimport type { EditorToolbarProps } from \"./Editor.types\";\n\nconst DEFAULT_ACTIONS = [\n { icon: \"B\", label: \"Bold\", command: \"bold\" },\n { icon: \"I\", label: \"Italic\", command: \"italic\" },\n { icon: \"U\", label: \"Underline\", command: \"underline\" },\n { icon: \"S\", label: \"Strikethrough\", command: \"strikeThrough\" },\n];\n\nexport function EditorToolbar({\n actions = DEFAULT_ACTIONS,\n onAction,\n children,\n className,\n showSourceToggle = true,\n showFullScreenToggle = false,\n toolbarExtra,\n}: EditorToolbarProps) {\n const { exec, showSource } = useEditor();\n // `null` / `false` / `undefined` render nothing, so they must not add a\n // wrapper either: an unused slot leaves the toolbar byte-identical.\n const hasExtra = toolbarExtra !== undefined && toolbarExtra !== null && toolbarExtra !== false;\n\n return (\n <div\n data-react-fancy-editor-toolbar=\"\"\n className={cn(\n \"flex shrink-0 items-center gap-0.5 border-b border-[color:var(--fancy-border,var(--color-zinc-200))] px-2 py-1.5 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n className,\n )}\n >\n {children ?? (\n <>\n {actions.map((action) => (\n <button\n key={`${action.command}-${action.commandArg ?? \"\"}`}\n type=\"button\"\n // Rich-text commands don't apply to the raw-source textarea.\n disabled={showSource}\n onClick={() => {\n if (onAction) {\n onAction(action.command);\n } else {\n exec(action.command, action.commandArg);\n }\n }}\n title={action.label}\n className={cn(\n \"inline-flex h-8 w-8 items-center justify-center rounded-md text-sm transition-colors\",\n action.active\n ? \"bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\"\n : \"hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\",\n showSource && \"cursor-not-allowed opacity-40 hover:bg-transparent\",\n )}\n >\n {action.icon}\n </button>\n ))}\n {showSourceToggle && <EditorSourceToggle className=\"ml-auto\" />}\n {hasExtra && (\n <div\n data-react-fancy-editor-toolbar-extra=\"\"\n className={cn(\"flex items-center gap-0.5\", !showSourceToggle && \"ml-auto\")}\n >\n {toolbarExtra}\n </div>\n )}\n {showFullScreenToggle && (\n <EditorFullScreenToggle className={showSourceToggle || hasExtra ? undefined : \"ml-auto\"} />\n )}\n </>\n )}\n </div>\n );\n}\n\nEditorToolbar.displayName = \"EditorToolbar\";\n","export function EditorToolbarSeparator() {\n return (\n <span\n data-react-fancy-editor-toolbar-separator=\"\"\n className=\"mx-1 h-5 w-px bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\"\n />\n );\n}\n\nEditorToolbarSeparator.displayName = \"EditorToolbarSeparator\";\n","import { useEffect, useMemo, useRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { CodeView } from \"../CodeView\";\nimport { useEditor } from \"./Editor.context\";\nimport { proseClasses, extensionEditorClasses } from \"./editor.utils\";\nimport type { EditorContentProps } from \"./Editor.types\";\n\nexport function EditorContent({ className, maxHeight: maxHeightProp, sourceClassName }: EditorContentProps) {\n const {\n contentRef,\n lineSpacing,\n placeholder,\n extensions,\n outputFormat,\n showSource,\n _initialHtml,\n _onInput,\n _sourceValue,\n _onSourceInput,\n fullScreen,\n } = useEditor();\n // Full screen means \"fill the viewport\": a height cap would leave the bottom\n // of the screen empty under a scrolled box.\n const maxHeight = fullScreen ? undefined : maxHeightProp;\n // Tracks which seed HTML is currently in the contentEditable. Seeding on the\n // seed VALUE (not a one-shot boolean) re-seeds when the source view rewrites\n // `value`, while still never re-seeding on plain keystrokes — typing leaves\n // `_initialHtml` untouched, so `seededHtml.current === _initialHtml` holds.\n const seededHtml = useRef<string | null>(null);\n\n useEffect(() => {\n // Source view replaces the contentEditable in the tree, so it unmounts.\n // Forget what we seeded — the div that returns is a fresh, empty one and\n // must always be re-seeded, even if `value` was left untouched.\n if (showSource) {\n seededHtml.current = null;\n return;\n }\n const el = contentRef.current;\n if (el && seededHtml.current !== _initialHtml) {\n el.innerHTML = _initialHtml;\n seededHtml.current = _initialHtml;\n }\n }, [contentRef, _initialHtml, showSource]);\n\n const extClasses = useMemo(\n () => extensionEditorClasses(extensions),\n [extensions],\n );\n\n if (showSource) {\n // Raw-source view — a syntax-highlighted code surface (HTML highlighted;\n // markdown/plain un-highlighted), built on the shared fancy-file-commons\n // primitives. It's a DIRECT child of the flex-column editor root (no\n // wrapper — a nested flex box collapses the fill), so `flex-auto` makes it\n // fill the editor body when height-constrained and grow with content\n // (≥ minHeight) when not. `maxHeight` caps + scrolls.\n return (\n <CodeView\n value={_sourceValue}\n onChange={_onSourceInput}\n language={outputFormat === \"html\" ? \"html\" : \"plaintext\"}\n placeholder={placeholder}\n maxHeight={maxHeight}\n className={cn(\"min-h-0 flex-auto\", sourceClassName)}\n />\n );\n }\n\n return (\n <div\n ref={contentRef}\n contentEditable\n suppressContentEditableWarning\n data-react-fancy-editor-content=\"\"\n data-placeholder={placeholder}\n onInput={_onInput}\n style={{\n lineHeight: lineSpacing,\n maxHeight: maxHeight ? `${maxHeight}px` : undefined,\n }}\n className={cn(\n \"min-h-[120px] flex-auto overflow-y-auto px-4 py-3 text-sm outline-none\",\n \"focus:outline-none\",\n proseClasses,\n extClasses,\n \"empty:before:content-[attr(data-placeholder)] empty:before:text-zinc-400 empty:before:pointer-events-none\",\n className,\n )}\n />\n );\n}\n\nEditorContent.displayName = \"EditorContent\";\n","import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { marked } from \"marked\";\nimport { cn } from \"../../utils/cn\";\nimport { sanitizeHtml } from \"../../utils/sanitize\";\nimport { useControllableState } from \"../../hooks\";\nimport { useFullScreen } from \"../../hooks/use-full-screen\";\nimport { FullScreenProvider } from \"../FullScreen/FullScreen.context\";\nimport { EditorContext } from \"./Editor.context\";\nimport { EditorToolbar } from \"./EditorToolbar\";\nimport { EditorToolbarSeparator } from \"./EditorToolbarSeparator\";\nimport { EditorSourceToggle } from \"./EditorSourceToggle\";\nimport { EditorContent } from \"./EditorContent\";\nimport { EditorFullScreenToggle } from \"./EditorFullScreenToggle\";\nimport { htmlToMarkdown, detectFormat, markdownToEditorHtml, type MarkdownSource } from \"./editor.utils\";\nimport { mergeExtensions } from \"../ContentRenderer/extensions\";\nimport { ContentRenderer } from \"../ContentRenderer/ContentRenderer\";\nimport { useFieldMode } from \"../inputs/mode/FieldMode.context\";\nimport type { EditorProps } from \"./Editor.types\";\n\ninterface Seed {\n html: string;\n /** Source map for source-preserving markdown output; null when there is none. */\n source: MarkdownSource | null;\n}\n\nfunction toHtml(\n value: string,\n outputFormat: \"html\" | \"markdown\",\n unsafe: boolean,\n valueFormat: \"markdown\" | \"html\" | \"auto\" = \"auto\",\n): Seed {\n if (!value) return { html: \"\", source: null };\n const sanitize = (html: string) => (unsafe ? html : sanitizeHtml(html));\n // An explicit valueFormat is authoritative — the sniff misclassifies\n // markdown that merely MENTIONS HTML-ish snippets (`<code>`, `<table`),\n // collapsing it into an innerHTML wall of text (#10).\n const format =\n valueFormat !== \"auto\"\n ? valueFormat\n : outputFormat === \"html\"\n ? \"html\"\n : detectFormat(value);\n if (format === \"html\") return { html: sanitize(value), source: null };\n // Markdown in, markdown out: tag each block with its source so untouched\n // blocks are emitted byte-identical.\n if (outputFormat === \"markdown\") return markdownToEditorHtml(value, sanitize);\n return { html: sanitize((marked.parse(value, { async: false }) as string).trim()), source: null };\n}\n\nfunction EditorRoot({\n children,\n className,\n value: controlledValue,\n defaultValue = \"\",\n onChange,\n outputFormat = \"html\",\n valueFormat = \"auto\",\n lineSpacing = 1.6,\n placeholder,\n mode: modeProp,\n extensions: instanceExtensions,\n unsafe = false,\n showSource: showSourceProp,\n defaultShowSource = false,\n onShowSourceChange,\n fullScreen: fullScreenProp,\n defaultFullScreen = false,\n onFullScreenChange,\n fullScreenMode = \"overlay\",\n copyButtons,\n clipboardWriter,\n onCopy,\n}: EditorProps) {\n const contentRef = useRef<HTMLDivElement | null>(null);\n const [value, setValue] = useControllableState(controlledValue, defaultValue, onChange);\n const [showSource, setShowSource] = useControllableState(\n showSourceProp,\n defaultShowSource,\n onShowSourceChange,\n );\n // Full screen is the element itself going `position: fixed`, not a portal:\n // reparenting would remount the contentEditable and lose the caret, the\n // browser's undo stack and the seeded HTML.\n const fs = useFullScreen<HTMLDivElement>({\n fullScreen: fullScreenProp,\n defaultFullScreen,\n onFullScreenChange,\n mode: fullScreenMode,\n });\n // View/edit mode — same resolution as the inputs: prop → <Form> context → \"edit\".\n const mode = useFieldMode(modeProp);\n const isView = mode === \"view\";\n\n // The value this editor last emitted through `onChange`. An incoming `value`\n // equal to it is our own keystroke echoing back; anything else came from\n // OUTSIDE — an async load, a host reset, a form repopulating.\n const lastEmitted = useRef<string | null>(null);\n\n // Bumped only on an external `value` change, so the seed memo below recomputes\n // for those and stays put while the user types. Without this, `value` was\n // excluded from the deps to avoid re-seeding on keystrokes, which also meant a\n // value arriving after mount was silently dropped and the editor stayed blank\n // forever (#15).\n const [externalSeed, setExternalSeed] = useState(0);\n useEffect(() => {\n if (value !== lastEmitted.current) setExternalSeed((n) => n + 1);\n }, [value]);\n\n const seed = useMemo(\n () => toHtml(value, outputFormat, unsafe, valueFormat),\n // Seed the contentEditable from the LIVE value when (re)entering edit mode —\n // and when returning from the raw-source view, which may have rewritten the\n // value out from under the rich-text surface. `value` itself stays out of\n // the deps so typing never re-seeds (which would fight the caret);\n // `externalSeed` covers the externally-driven case instead.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [isView, outputFormat, unsafe, valueFormat, showSource, externalSeed],\n );\n const initialHtml = seed.html;\n const seedSource = seed.source;\n\n const extensions = useMemo(\n () => mergeExtensions(instanceExtensions),\n [instanceExtensions],\n );\n\n const getOutputValue = useCallback(\n (html: string): string => {\n return outputFormat === \"markdown\" ? htmlToMarkdown(html, seedSource) : html;\n },\n [outputFormat, seedSource],\n );\n\n const handleInput = useCallback(() => {\n const el = contentRef.current;\n if (!el) return;\n const next = getOutputValue(el.innerHTML);\n // Record what we emitted BEFORE publishing it, so the value coming back in\n // is recognised as our own and does not trigger a re-seed mid-keystroke.\n lastEmitted.current = next;\n setValue(next);\n }, [setValue, getOutputValue]);\n\n const exec = useCallback(\n (command: string, arg?: string) => {\n const el = contentRef.current;\n if (!el) return;\n el.focus();\n document.execCommand(command, false, arg);\n handleInput();\n },\n [handleInput],\n );\n\n const insertText = useCallback(\n (text: string) => {\n const el = contentRef.current;\n if (!el) return;\n el.focus();\n document.execCommand(\"insertText\", false, text);\n handleInput();\n },\n [handleInput],\n );\n\n // The source textarea edits `value` directly — it is already the canonical\n // source in `outputFormat` (html or markdown), so no conversion round-trip.\n const handleSourceInput = useCallback(\n (next: string) => {\n // Also an internal emission — record it so typing in the source view is\n // not mistaken for an external change on every keystroke.\n lastEmitted.current = next;\n setValue(next);\n },\n [setValue],\n );\n\n const wrapSelection = useCallback(\n (before: string, after: string) => {\n const sel = window.getSelection();\n if (!sel || sel.rangeCount === 0) return;\n const range = sel.getRangeAt(0);\n const selectedText = range.toString();\n const el = contentRef.current;\n if (!el) return;\n el.focus();\n document.execCommand(\"insertText\", false, `${before}${selectedText}${after}`);\n handleInput();\n },\n [handleInput],\n );\n\n const contextValue = {\n contentRef,\n exec,\n insertText,\n wrapSelection,\n outputFormat,\n lineSpacing,\n placeholder,\n extensions,\n showSource,\n setShowSource,\n fullScreen: fs.fullScreen,\n setFullScreen: fs.setFullScreen,\n _initialHtml: initialHtml,\n _onInput: handleInput,\n _sourceValue: value,\n _onSourceInput: handleSourceInput,\n };\n\n // View mode — render the value read-only through ContentRenderer, matching the\n // editor's own format (markdown/html), instead of the editable toolbar+content\n // tree. Driven by `mode` / a `<Form mode=\"view\">`, exactly like the inputs.\n if (isView) {\n return (\n <FullScreenProvider value={fs}>\n <div\n {...fs.targetProps}\n data-react-fancy-editor=\"\"\n data-mode=\"view\"\n className={cn(\n \"overflow-hidden rounded-xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n className,\n // Read-only content taller than the viewport must scroll in place.\n fs.fullScreen && \"overflow-auto\",\n )}\n >\n <ContentRenderer\n value={value}\n format={valueFormat !== \"auto\" ? valueFormat : outputFormat}\n lineSpacing={lineSpacing}\n extensions={instanceExtensions}\n unsafe={unsafe}\n copyButtons={copyButtons}\n clipboardWriter={clipboardWriter}\n onCopy={onCopy}\n className=\"px-4 py-3\"\n />\n </div>\n </FullScreenProvider>\n );\n }\n\n return (\n <EditorContext.Provider value={contextValue}>\n <FullScreenProvider value={fs}>\n <div\n {...fs.targetProps}\n data-react-fancy-editor=\"\"\n data-mode=\"edit\"\n className={cn(\n \"flex flex-col overflow-hidden rounded-xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n className,\n )}\n >\n {children}\n </div>\n </FullScreenProvider>\n </EditorContext.Provider>\n );\n}\n\nconst ToolbarWithSeparator = Object.assign(EditorToolbar, {\n Separator: EditorToolbarSeparator,\n});\n\nexport const Editor = Object.assign(EditorRoot, {\n Toolbar: ToolbarWithSeparator,\n Content: EditorContent,\n SourceToggle: EditorSourceToggle,\n FullScreenToggle: EditorFullScreenToggle,\n});\n"]}
|
package/dist/code-block.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkQH4YSG7C_cjs = require('./chunk-QH4YSG7C.cjs');
|
|
4
4
|
require('./chunk-7ZCNZUZK.cjs');
|
|
5
5
|
require('./chunk-2C64OVOZ.cjs');
|
|
6
6
|
require('./chunk-HZUKPYR3.cjs');
|
|
@@ -13,7 +13,7 @@ require('./chunk-ZU5Q77OT.cjs');
|
|
|
13
13
|
|
|
14
14
|
Object.defineProperty(exports, "CodeBlock", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkQH4YSG7C_cjs.CodeBlock; }
|
|
17
17
|
});
|
|
18
18
|
//# sourceMappingURL=code-block.cjs.map
|
|
19
19
|
//# sourceMappingURL=code-block.cjs.map
|
package/dist/code-block.d.cts
CHANGED
|
@@ -1,48 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
/** Words on the copy button, for translation. */
|
|
5
|
-
interface CodeBlockCopyLabels {
|
|
6
|
-
/** Idle label (aria-label and tooltip). @default "Copy code" */
|
|
7
|
-
copy?: string;
|
|
8
|
-
/** Shown, visibly and to screen readers, after a successful copy. @default "Copied" */
|
|
9
|
-
copied?: string;
|
|
10
|
-
/** Shown after a copy that could not be written. @default "Copy failed" */
|
|
11
|
-
failed?: string;
|
|
12
|
-
}
|
|
13
|
-
/** Reported through `onCopyCode` after every copy attempt. */
|
|
14
|
-
interface CodeBlockCopyEvent {
|
|
15
|
-
/** Exactly the `code` prop: the raw source, never the highlighted HTML. */
|
|
16
|
-
text: string;
|
|
17
|
-
/** Whether the clipboard accepted it. */
|
|
18
|
-
ok: boolean;
|
|
19
|
-
}
|
|
20
|
-
interface CodeBlockProps extends Omit<HTMLAttributes<HTMLDivElement>, "children" | "title"> {
|
|
21
|
-
/** The source to show. Rendered as text; never parsed as HTML. */
|
|
22
|
-
code: string;
|
|
23
|
-
/**
|
|
24
|
-
* Language id. Only `"html"` (and its aliases `"htm"`, `"xml"`, `"xhtml"`)
|
|
25
|
-
* is highlighted today: it is the one grammar `fancy-file-commons` ships.
|
|
26
|
-
* Every other value, known or not, renders as plain text. Reflected as
|
|
27
|
-
* `data-language` either way.
|
|
28
|
-
* @default "plaintext"
|
|
29
|
-
*/
|
|
30
|
-
language?: "html" | "xml" | "plaintext" | (string & {});
|
|
31
|
-
/** Show a copy button. It copies `code` exactly. @default true */
|
|
32
|
-
copyable?: boolean;
|
|
33
|
-
/** Header above the code: a filename, or a short label like "Terminal". */
|
|
34
|
-
title?: ReactNode;
|
|
35
|
-
/** Number each line in a gutter that is not part of the code text. @default false */
|
|
36
|
-
showLineNumbers?: boolean;
|
|
37
|
-
/** Wrap long lines instead of scrolling horizontally. @default false */
|
|
38
|
-
wrap?: boolean;
|
|
39
|
-
/** Words on the copy button. */
|
|
40
|
-
copyLabels?: CodeBlockCopyLabels;
|
|
41
|
-
/** Called after every copy attempt, successful or not. */
|
|
42
|
-
onCopyCode?: (event: CodeBlockCopyEvent) => void;
|
|
43
|
-
/** Additional classes on the root element. */
|
|
44
|
-
className?: string;
|
|
45
|
-
}
|
|
2
|
+
import { b as CodeBlockProps } from './CodeBlock.types-BFMFB4X2.cjs';
|
|
3
|
+
export { C as CodeBlockCopyEvent, a as CodeBlockCopyLabels, c as CodeLanguage } from './CodeBlock.types-BFMFB4X2.cjs';
|
|
46
4
|
|
|
47
5
|
/**
|
|
48
6
|
* A display-only code block: `<pre><code>`, syntax-highlighted where a grammar
|
|
@@ -52,4 +10,4 @@ interface CodeBlockProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"
|
|
|
52
10
|
*/
|
|
53
11
|
declare const CodeBlock: react.ForwardRefExoticComponent<CodeBlockProps & react.RefAttributes<HTMLDivElement>>;
|
|
54
12
|
|
|
55
|
-
export { CodeBlock,
|
|
13
|
+
export { CodeBlock, CodeBlockProps };
|
package/dist/code-block.d.ts
CHANGED
|
@@ -1,48 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
/** Words on the copy button, for translation. */
|
|
5
|
-
interface CodeBlockCopyLabels {
|
|
6
|
-
/** Idle label (aria-label and tooltip). @default "Copy code" */
|
|
7
|
-
copy?: string;
|
|
8
|
-
/** Shown, visibly and to screen readers, after a successful copy. @default "Copied" */
|
|
9
|
-
copied?: string;
|
|
10
|
-
/** Shown after a copy that could not be written. @default "Copy failed" */
|
|
11
|
-
failed?: string;
|
|
12
|
-
}
|
|
13
|
-
/** Reported through `onCopyCode` after every copy attempt. */
|
|
14
|
-
interface CodeBlockCopyEvent {
|
|
15
|
-
/** Exactly the `code` prop: the raw source, never the highlighted HTML. */
|
|
16
|
-
text: string;
|
|
17
|
-
/** Whether the clipboard accepted it. */
|
|
18
|
-
ok: boolean;
|
|
19
|
-
}
|
|
20
|
-
interface CodeBlockProps extends Omit<HTMLAttributes<HTMLDivElement>, "children" | "title"> {
|
|
21
|
-
/** The source to show. Rendered as text; never parsed as HTML. */
|
|
22
|
-
code: string;
|
|
23
|
-
/**
|
|
24
|
-
* Language id. Only `"html"` (and its aliases `"htm"`, `"xml"`, `"xhtml"`)
|
|
25
|
-
* is highlighted today: it is the one grammar `fancy-file-commons` ships.
|
|
26
|
-
* Every other value, known or not, renders as plain text. Reflected as
|
|
27
|
-
* `data-language` either way.
|
|
28
|
-
* @default "plaintext"
|
|
29
|
-
*/
|
|
30
|
-
language?: "html" | "xml" | "plaintext" | (string & {});
|
|
31
|
-
/** Show a copy button. It copies `code` exactly. @default true */
|
|
32
|
-
copyable?: boolean;
|
|
33
|
-
/** Header above the code: a filename, or a short label like "Terminal". */
|
|
34
|
-
title?: ReactNode;
|
|
35
|
-
/** Number each line in a gutter that is not part of the code text. @default false */
|
|
36
|
-
showLineNumbers?: boolean;
|
|
37
|
-
/** Wrap long lines instead of scrolling horizontally. @default false */
|
|
38
|
-
wrap?: boolean;
|
|
39
|
-
/** Words on the copy button. */
|
|
40
|
-
copyLabels?: CodeBlockCopyLabels;
|
|
41
|
-
/** Called after every copy attempt, successful or not. */
|
|
42
|
-
onCopyCode?: (event: CodeBlockCopyEvent) => void;
|
|
43
|
-
/** Additional classes on the root element. */
|
|
44
|
-
className?: string;
|
|
45
|
-
}
|
|
2
|
+
import { b as CodeBlockProps } from './CodeBlock.types-BFMFB4X2.js';
|
|
3
|
+
export { C as CodeBlockCopyEvent, a as CodeBlockCopyLabels, c as CodeLanguage } from './CodeBlock.types-BFMFB4X2.js';
|
|
46
4
|
|
|
47
5
|
/**
|
|
48
6
|
* A display-only code block: `<pre><code>`, syntax-highlighted where a grammar
|
|
@@ -52,4 +10,4 @@ interface CodeBlockProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"
|
|
|
52
10
|
*/
|
|
53
11
|
declare const CodeBlock: react.ForwardRefExoticComponent<CodeBlockProps & react.RefAttributes<HTMLDivElement>>;
|
|
54
12
|
|
|
55
|
-
export { CodeBlock,
|
|
13
|
+
export { CodeBlock, CodeBlockProps };
|
package/dist/code-block.js
CHANGED
package/dist/code-view.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkTQL3QW7F_cjs = require('./chunk-TQL3QW7F.cjs');
|
|
4
4
|
require('./chunk-HZUKPYR3.cjs');
|
|
5
5
|
require('./chunk-ZU5Q77OT.cjs');
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ require('./chunk-ZU5Q77OT.cjs');
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "CodeView", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkTQL3QW7F_cjs.CodeView; }
|
|
12
12
|
});
|
|
13
13
|
//# sourceMappingURL=code-view.cjs.map
|
|
14
14
|
//# sourceMappingURL=code-view.cjs.map
|
package/dist/code-view.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
+
import { c as CodeLanguage } from './CodeBlock.types-BFMFB4X2.cjs';
|
|
2
3
|
|
|
3
4
|
interface CodeViewProps {
|
|
4
5
|
/** Source text to display / edit. Controlled. */
|
|
@@ -10,13 +11,14 @@ interface CodeViewProps {
|
|
|
10
11
|
*/
|
|
11
12
|
onChange?: (value: string) => void;
|
|
12
13
|
/**
|
|
13
|
-
* Language id for syntax highlighting
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Language id or alias for syntax highlighting, case-insensitive — the same
|
|
15
|
+
* set as `CodeBlock`: TypeScript, JavaScript, JSON, PHP, Python, Go,
|
|
16
|
+
* Markdown, shell, dotenv and HTML/XML, via `fancy-file-commons`'
|
|
17
|
+
* `tokenize`. Anything else, including `"plaintext"`, renders un-highlighted.
|
|
18
|
+
* For a full editor use `@particle-academy/fancy-code`'s `CodeEditor`.
|
|
17
19
|
* @default "plaintext"
|
|
18
20
|
*/
|
|
19
|
-
language?:
|
|
21
|
+
language?: CodeLanguage;
|
|
20
22
|
/** Read-only mode (no editing even if `onChange` is passed). @default false */
|
|
21
23
|
readOnly?: boolean;
|
|
22
24
|
/** Placeholder shown when empty. */
|
|
@@ -34,7 +36,8 @@ interface CodeViewProps {
|
|
|
34
36
|
* primitives in `@particle-academy/fancy-file-commons` — a highlight overlay
|
|
35
37
|
* with a transparent, auto-growing textarea on top; the container scrolls both
|
|
36
38
|
* together. Fills its parent's height (`h-full`) and grows with content down to
|
|
37
|
-
* `minHeight`.
|
|
39
|
+
* `minHeight`. Highlights every language fancy-file-commons ships (see
|
|
40
|
+
* `CodeViewProps.language`); anything else renders as plain text.
|
|
38
41
|
*/
|
|
39
42
|
declare function CodeView({ value, onChange, language, readOnly, placeholder, minHeight, maxHeight, className, }: CodeViewProps): react.JSX.Element;
|
|
40
43
|
declare namespace CodeView {
|
package/dist/code-view.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
+
import { c as CodeLanguage } from './CodeBlock.types-BFMFB4X2.js';
|
|
2
3
|
|
|
3
4
|
interface CodeViewProps {
|
|
4
5
|
/** Source text to display / edit. Controlled. */
|
|
@@ -10,13 +11,14 @@ interface CodeViewProps {
|
|
|
10
11
|
*/
|
|
11
12
|
onChange?: (value: string) => void;
|
|
12
13
|
/**
|
|
13
|
-
* Language id for syntax highlighting
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Language id or alias for syntax highlighting, case-insensitive — the same
|
|
15
|
+
* set as `CodeBlock`: TypeScript, JavaScript, JSON, PHP, Python, Go,
|
|
16
|
+
* Markdown, shell, dotenv and HTML/XML, via `fancy-file-commons`'
|
|
17
|
+
* `tokenize`. Anything else, including `"plaintext"`, renders un-highlighted.
|
|
18
|
+
* For a full editor use `@particle-academy/fancy-code`'s `CodeEditor`.
|
|
17
19
|
* @default "plaintext"
|
|
18
20
|
*/
|
|
19
|
-
language?:
|
|
21
|
+
language?: CodeLanguage;
|
|
20
22
|
/** Read-only mode (no editing even if `onChange` is passed). @default false */
|
|
21
23
|
readOnly?: boolean;
|
|
22
24
|
/** Placeholder shown when empty. */
|
|
@@ -34,7 +36,8 @@ interface CodeViewProps {
|
|
|
34
36
|
* primitives in `@particle-academy/fancy-file-commons` — a highlight overlay
|
|
35
37
|
* with a transparent, auto-growing textarea on top; the container scrolls both
|
|
36
38
|
* together. Fills its parent's height (`h-full`) and grows with content down to
|
|
37
|
-
* `minHeight`.
|
|
39
|
+
* `minHeight`. Highlights every language fancy-file-commons ships (see
|
|
40
|
+
* `CodeViewProps.language`); anything else renders as plain text.
|
|
38
41
|
*/
|
|
39
42
|
declare function CodeView({ value, onChange, language, readOnly, placeholder, minHeight, maxHeight, className, }: CodeViewProps): react.JSX.Element;
|
|
40
43
|
declare namespace CodeView {
|
package/dist/code-view.js
CHANGED
package/dist/editor.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkRE4BYTVM_cjs = require('./chunk-RE4BYTVM.cjs');
|
|
4
4
|
require('./chunk-A2JUTNE6.cjs');
|
|
5
5
|
require('./chunk-T6YELZPJ.cjs');
|
|
6
6
|
require('./chunk-VQJ5LJJH.cjs');
|
|
@@ -11,7 +11,7 @@ require('./chunk-AIA5UNQ5.cjs');
|
|
|
11
11
|
require('./chunk-MPCZUZ4O.cjs');
|
|
12
12
|
require('./chunk-7ZCNZUZK.cjs');
|
|
13
13
|
require('./chunk-2C64OVOZ.cjs');
|
|
14
|
-
require('./chunk-
|
|
14
|
+
require('./chunk-TQL3QW7F.cjs');
|
|
15
15
|
require('./chunk-HZUKPYR3.cjs');
|
|
16
16
|
require('./chunk-J2DI6RMR.cjs');
|
|
17
17
|
require('./chunk-TI7D4QDM.cjs');
|
|
@@ -28,11 +28,11 @@ require('./chunk-ZU5Q77OT.cjs');
|
|
|
28
28
|
|
|
29
29
|
Object.defineProperty(exports, "Editor", {
|
|
30
30
|
enumerable: true,
|
|
31
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunkRE4BYTVM_cjs.Editor; }
|
|
32
32
|
});
|
|
33
33
|
Object.defineProperty(exports, "useEditor", {
|
|
34
34
|
enumerable: true,
|
|
35
|
-
get: function () { return
|
|
35
|
+
get: function () { return chunkRE4BYTVM_cjs.useEditor; }
|
|
36
36
|
});
|
|
37
37
|
//# sourceMappingURL=editor.cjs.map
|
|
38
38
|
//# sourceMappingURL=editor.cjs.map
|
package/dist/editor.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Editor, useEditor } from './chunk-
|
|
1
|
+
export { Editor, useEditor } from './chunk-YYNUTUJO.js';
|
|
2
2
|
import './chunk-2BXMMVQS.js';
|
|
3
3
|
import './chunk-CPY7NHXM.js';
|
|
4
4
|
import './chunk-RP43ZFZP.js';
|
|
@@ -9,7 +9,7 @@ import './chunk-TJ66S5K6.js';
|
|
|
9
9
|
import './chunk-QF2FODTG.js';
|
|
10
10
|
import './chunk-J2BWXCES.js';
|
|
11
11
|
import './chunk-I3LAFKJU.js';
|
|
12
|
-
import './chunk-
|
|
12
|
+
import './chunk-PVHZO4T3.js';
|
|
13
13
|
import './chunk-6BB32POL.js';
|
|
14
14
|
import './chunk-MQ6VGG62.js';
|
|
15
15
|
import './chunk-RBCMKPBX.js';
|
package/dist/index.cjs
CHANGED
|
@@ -85,7 +85,7 @@ var chunkFQSSVOVQ_cjs = require('./chunk-FQSSVOVQ.cjs');
|
|
|
85
85
|
var chunkZ7SQMQTF_cjs = require('./chunk-Z7SQMQTF.cjs');
|
|
86
86
|
var chunkAJPYGRLA_cjs = require('./chunk-AJPYGRLA.cjs');
|
|
87
87
|
var chunkXZOBGKZL_cjs = require('./chunk-XZOBGKZL.cjs');
|
|
88
|
-
var
|
|
88
|
+
var chunkRE4BYTVM_cjs = require('./chunk-RE4BYTVM.cjs');
|
|
89
89
|
var chunkA2JUTNE6_cjs = require('./chunk-A2JUTNE6.cjs');
|
|
90
90
|
var chunkT6YELZPJ_cjs = require('./chunk-T6YELZPJ.cjs');
|
|
91
91
|
var chunkVQJ5LJJH_cjs = require('./chunk-VQJ5LJJH.cjs');
|
|
@@ -102,10 +102,10 @@ require('./chunk-AIA5UNQ5.cjs');
|
|
|
102
102
|
var chunk2G6TIX5Q_cjs = require('./chunk-2G6TIX5Q.cjs');
|
|
103
103
|
require('./chunk-S3TRSECD.cjs');
|
|
104
104
|
var chunkMPCZUZ4O_cjs = require('./chunk-MPCZUZ4O.cjs');
|
|
105
|
-
var
|
|
105
|
+
var chunkQH4YSG7C_cjs = require('./chunk-QH4YSG7C.cjs');
|
|
106
106
|
require('./chunk-7ZCNZUZK.cjs');
|
|
107
107
|
require('./chunk-2C64OVOZ.cjs');
|
|
108
|
-
var
|
|
108
|
+
var chunkTQL3QW7F_cjs = require('./chunk-TQL3QW7F.cjs');
|
|
109
109
|
require('./chunk-HZUKPYR3.cjs');
|
|
110
110
|
require('./chunk-XFBLUPKF.cjs');
|
|
111
111
|
var chunkGKLETY7D_cjs = require('./chunk-GKLETY7D.cjs');
|
|
@@ -713,11 +713,11 @@ Object.defineProperty(exports, "useDropdown", {
|
|
|
713
713
|
});
|
|
714
714
|
Object.defineProperty(exports, "Editor", {
|
|
715
715
|
enumerable: true,
|
|
716
|
-
get: function () { return
|
|
716
|
+
get: function () { return chunkRE4BYTVM_cjs.Editor; }
|
|
717
717
|
});
|
|
718
718
|
Object.defineProperty(exports, "useEditor", {
|
|
719
719
|
enumerable: true,
|
|
720
|
-
get: function () { return
|
|
720
|
+
get: function () { return chunkRE4BYTVM_cjs.useEditor; }
|
|
721
721
|
});
|
|
722
722
|
Object.defineProperty(exports, "THEME_STORAGE_KEY", {
|
|
723
723
|
enumerable: true,
|
|
@@ -841,11 +841,11 @@ Object.defineProperty(exports, "renderMarkdown", {
|
|
|
841
841
|
});
|
|
842
842
|
Object.defineProperty(exports, "CodeBlock", {
|
|
843
843
|
enumerable: true,
|
|
844
|
-
get: function () { return
|
|
844
|
+
get: function () { return chunkQH4YSG7C_cjs.CodeBlock; }
|
|
845
845
|
});
|
|
846
846
|
Object.defineProperty(exports, "CodeView", {
|
|
847
847
|
enumerable: true,
|
|
848
|
-
get: function () { return
|
|
848
|
+
get: function () { return chunkTQL3QW7F_cjs.CodeView; }
|
|
849
849
|
});
|
|
850
850
|
Object.defineProperty(exports, "ColorPicker", {
|
|
851
851
|
enumerable: true,
|
package/dist/index.d.cts
CHANGED
|
@@ -79,7 +79,8 @@ export { I as InlinePasteEditor, a as InlinePasteEditorHandle, P as PastedFilesI
|
|
|
79
79
|
export { Chart, ChartAreaProps, ChartBarData, ChartBarProps, ChartCommonProps, ChartDonutData, ChartDonutProps, ChartHorizontalBarProps, ChartLineProps, ChartPieData, ChartPieProps, ChartSeries, ChartSparklineProps, ChartStackedBarProps } from './chart.cjs';
|
|
80
80
|
export { Editor, EditorAction, EditorContentProps, EditorContextValue, EditorFullScreenToggleProps, EditorProps, EditorSourceToggleProps, EditorToolbarProps, useEditor } from './editor.cjs';
|
|
81
81
|
export { CodeView, CodeViewProps } from './code-view.cjs';
|
|
82
|
-
export { CodeBlock
|
|
82
|
+
export { CodeBlock } from './code-block.cjs';
|
|
83
|
+
export { C as CodeBlockCopyEvent, a as CodeBlockCopyLabels, b as CodeBlockProps, c as CodeLanguage } from './CodeBlock.types-BFMFB4X2.cjs';
|
|
83
84
|
export { ContentRenderer } from './content-renderer.cjs';
|
|
84
85
|
export { C as ContentClipboardPayload, a as ContentClipboardWriter, b as ContentCopyEvent, c as ContentCopyKind, d as ContentRendererProps, R as RenderExtension, e as RenderExtensionProps, r as registerExtension, f as registerExtensions } from './ContentRenderer.types-RO_l7_6N.cjs';
|
|
85
86
|
export { Menu, MenuContextValue, MenuGroupProps, MenuItemProps, MenuOrientation, MenuProps, MenuSubmenuProps, useMenu } from './menu.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -79,7 +79,8 @@ export { I as InlinePasteEditor, a as InlinePasteEditorHandle, P as PastedFilesI
|
|
|
79
79
|
export { Chart, ChartAreaProps, ChartBarData, ChartBarProps, ChartCommonProps, ChartDonutData, ChartDonutProps, ChartHorizontalBarProps, ChartLineProps, ChartPieData, ChartPieProps, ChartSeries, ChartSparklineProps, ChartStackedBarProps } from './chart.js';
|
|
80
80
|
export { Editor, EditorAction, EditorContentProps, EditorContextValue, EditorFullScreenToggleProps, EditorProps, EditorSourceToggleProps, EditorToolbarProps, useEditor } from './editor.js';
|
|
81
81
|
export { CodeView, CodeViewProps } from './code-view.js';
|
|
82
|
-
export { CodeBlock
|
|
82
|
+
export { CodeBlock } from './code-block.js';
|
|
83
|
+
export { C as CodeBlockCopyEvent, a as CodeBlockCopyLabels, b as CodeBlockProps, c as CodeLanguage } from './CodeBlock.types-BFMFB4X2.js';
|
|
83
84
|
export { ContentRenderer } from './content-renderer.js';
|
|
84
85
|
export { C as ContentClipboardPayload, a as ContentClipboardWriter, b as ContentCopyEvent, c as ContentCopyKind, d as ContentRendererProps, R as RenderExtension, e as RenderExtensionProps, r as registerExtension, f as registerExtensions } from './ContentRenderer.types-RO_l7_6N.js';
|
|
85
86
|
export { Menu, MenuContextValue, MenuGroupProps, MenuItemProps, MenuOrientation, MenuProps, MenuSubmenuProps, useMenu } from './menu.js';
|
package/dist/index.js
CHANGED
|
@@ -83,7 +83,7 @@ export { Container } from './chunk-VKMPVFQK.js';
|
|
|
83
83
|
export { ContextMenu, useContextMenu } from './chunk-NSJBVV7R.js';
|
|
84
84
|
export { Drawer, useDrawer } from './chunk-PXZRYL5I.js';
|
|
85
85
|
export { Dropdown, useDropdown } from './chunk-BXPLERIJ.js';
|
|
86
|
-
export { Editor, useEditor } from './chunk-
|
|
86
|
+
export { Editor, useEditor } from './chunk-YYNUTUJO.js';
|
|
87
87
|
export { THEME_STORAGE_KEY, getThemePreference, initTheme, resolveTheme, setThemePreference, subscribeTheme, useId, useNodeRegistry, useTheme } from './chunk-2BXMMVQS.js';
|
|
88
88
|
export { usePanZoom } from './chunk-CPY7NHXM.js';
|
|
89
89
|
export { FullScreenContext, FullScreenProvider, FullScreenToggle, useFullScreenContext } from './chunk-RP43ZFZP.js';
|
|
@@ -100,10 +100,10 @@ import './chunk-TJ66S5K6.js';
|
|
|
100
100
|
export { ChatMessage, ChatThread } from './chunk-UUEAFG6V.js';
|
|
101
101
|
import './chunk-AUTW5O4W.js';
|
|
102
102
|
export { ContentRenderer, registerExtension, registerExtensions, renderMarkdown } from './chunk-QF2FODTG.js';
|
|
103
|
-
export { CodeBlock } from './chunk-
|
|
103
|
+
export { CodeBlock } from './chunk-YRI6OFLY.js';
|
|
104
104
|
import './chunk-J2BWXCES.js';
|
|
105
105
|
import './chunk-I3LAFKJU.js';
|
|
106
|
-
export { CodeView } from './chunk-
|
|
106
|
+
export { CodeView } from './chunk-PVHZO4T3.js';
|
|
107
107
|
import './chunk-6BB32POL.js';
|
|
108
108
|
import './chunk-J324MF75.js';
|
|
109
109
|
export { ColorPicker } from './chunk-SVSQXKFL.js';
|
package/docs/CodeBlock.md
CHANGED
|
@@ -35,7 +35,24 @@ With `title`, the copy button sits in the header with a visible "Copy" label. Wi
|
|
|
35
35
|
|
|
36
36
|
## Highlighting
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
Every grammar `@particle-academy/fancy-file-commons` ships is highlighted, through its `tokenize(code, language)` lookup. `language` is case-insensitive:
|
|
39
|
+
|
|
40
|
+
| Language | `language` values |
|
|
41
|
+
|---|---|
|
|
42
|
+
| TypeScript | `typescript`, `ts`, `tsx` |
|
|
43
|
+
| JavaScript | `javascript`, `js`, `jsx` |
|
|
44
|
+
| JSON | `json` (highlighted by the JavaScript grammar) |
|
|
45
|
+
| PHP | `php` |
|
|
46
|
+
| Python | `python`, `py` |
|
|
47
|
+
| Go | `go` |
|
|
48
|
+
| Markdown | `markdown`, `md` |
|
|
49
|
+
| Shell | `shell`, `sh`, `bash`, `zsh` |
|
|
50
|
+
| dotenv | `dotenv`, `env` |
|
|
51
|
+
| HTML / XML | `html`, `htm`, `xml`, `xhtml` |
|
|
52
|
+
|
|
53
|
+
**Any other language renders as plain, un-highlighted text** in the same font, size and palette, and nothing throws. `language` is reflected as `data-language` either way.
|
|
54
|
+
|
|
55
|
+
The colours are `CodeView`'s palette; the shell and dotenv grammars reuse its existing slots rather than adding new ones: shell flags (`-x`, `--flag`) and dotenv keys use the `attribute` colour, the command word uses `function`, and `$VAR` / `${VAR}` use `variable`.
|
|
39
56
|
|
|
40
57
|
## Props
|
|
41
58
|
|
|
@@ -44,7 +61,7 @@ Also accepts every `<div>` attribute (`id`, `aria-label`, `style`, `data-*`, ...
|
|
|
44
61
|
| Prop | Type | Default | Description |
|
|
45
62
|
|------|------|---------|-------------|
|
|
46
63
|
| code | `string` | - | The source to show. Rendered as text, never parsed as HTML |
|
|
47
|
-
| language | `
|
|
64
|
+
| language | `CodeLanguage` (any string) | `"plaintext"` | Language id or alias, case-insensitive (see Highlighting). Unknown values are plain text |
|
|
48
65
|
| copyable | `boolean` | `true` | Show the copy button |
|
|
49
66
|
| title | `ReactNode` | - | Header above the code (a filename, or a label like "Terminal") |
|
|
50
67
|
| showLineNumbers | `boolean` | `false` | Number each line in a gutter that is not part of the code text |
|
package/docs/CodeView.md
CHANGED
|
@@ -6,10 +6,26 @@ primitives in [`@particle-academy/fancy-file-commons`](https://www.npmjs.com/pac
|
|
|
6
6
|
(no CodeMirror, no heavy dependency). Powers the [`Editor`](./Editor.md)'s Source
|
|
7
7
|
view, and is usable standalone.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
It highlights every grammar commons ships, case-insensitively — the same set as
|
|
10
|
+
[`CodeBlock`](./CodeBlock.md):
|
|
11
|
+
|
|
12
|
+
| Language | `language` values |
|
|
13
|
+
|---|---|
|
|
14
|
+
| TypeScript | `typescript`, `ts`, `tsx` |
|
|
15
|
+
| JavaScript | `javascript`, `js`, `jsx` |
|
|
16
|
+
| JSON | `json` (highlighted by the JavaScript grammar) |
|
|
17
|
+
| PHP | `php` |
|
|
18
|
+
| Python | `python`, `py` |
|
|
19
|
+
| Go | `go` |
|
|
20
|
+
| Markdown | `markdown`, `md` |
|
|
21
|
+
| Shell | `shell`, `sh`, `bash`, `zsh` |
|
|
22
|
+
| dotenv | `dotenv`, `env` |
|
|
23
|
+
| HTML / XML | `html`, `htm`, `xml`, `xhtml` |
|
|
24
|
+
|
|
25
|
+
Anything else, including `"plaintext"`, renders as plain text. The `Editor`'s
|
|
26
|
+
Source view passes `"html"` for HTML output and `"plaintext"` otherwise, so it is
|
|
27
|
+
unchanged. For a full IDE (line numbers, diff gutter), use
|
|
28
|
+
[`@particle-academy/fancy-code`](https://www.npmjs.com/package/@particle-academy/fancy-code)'s
|
|
13
29
|
`CodeEditor`.
|
|
14
30
|
|
|
15
31
|
## Import
|
|
@@ -50,7 +66,7 @@ Read-only (omit `onChange` or pass `readOnly`):
|
|
|
50
66
|
|------|------|---------|-------------|
|
|
51
67
|
| value | `string` | — | Source text (controlled). |
|
|
52
68
|
| onChange | `(value: string) => void` | — | Called on edit. Omit for a read-only view. |
|
|
53
|
-
| language | `
|
|
69
|
+
| language | `CodeLanguage` (any string) | `"plaintext"` | Language id or alias, case-insensitive (table above). Unknown values render plain. |
|
|
54
70
|
| readOnly | `boolean` | `false` | Read-only even if `onChange` is passed. |
|
|
55
71
|
| placeholder | `string` | — | Shown when empty. |
|
|
56
72
|
| minHeight | `number` | `120` | Min height (px) before growing with content. |
|