doccupine 0.0.138 → 0.0.139
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/templates/components/layout/Card.d.ts +1 -1
- package/dist/templates/components/layout/Card.js +3 -0
- package/dist/templates/components/layout/Mermaid.d.ts +1 -1
- package/dist/templates/components/layout/Mermaid.js +5 -1
- package/dist/templates/mdx/mermaid.mdx.d.ts +1 -1
- package/dist/templates/mdx/mermaid.mdx.js +1 -1
- package/dist/templates/package.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const cardTemplate = "\"use client\";\nimport Link from \"next/link\";\nimport styled, { css, useTheme } from \"styled-components\";\nimport { styledText } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon, IconProps } from \"@/components/layout/Icon\";\nimport { interactiveStyles } from \"@/components/layout/SharedStyled\";\n\nconst cardStyles = css<{ theme: Theme }>`\n background: ${({ theme }) => theme.colors.light};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 20px;\n margin: 0;\n ${({ theme }) => styledText(theme)}\n color: ${({ theme }) => theme.colors.grayDark};\n`;\n\nconst StyledCard = styled.div<{ theme: Theme }>`\n ${cardStyles}\n`;\n\nconst StyledCardLink = styled(Link)<{ theme: Theme }>`\n ${interactiveStyles};\n ${cardStyles}\n text-decoration: none;\n`;\n\nconst StyledCardTitle = styled.p<{ theme: Theme }>`\n font-weight: bold;\n margin: 0;\n color: ${({ theme }) => theme.colors.dark};\n ${({ theme }) => styledText(theme)};\n`;\n\ninterface CardProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n title?: string;\n icon?: IconProps;\n href?: string;\n}\n\nfunction Card({ children, title, icon, href }: CardProps) {\n const theme = useTheme() as Theme;\n\n const content = (\n <>\n {icon && <Icon name={icon} color={theme.colors.primary} />}\n {title && <StyledCardTitle>{title}</StyledCardTitle>}\n {children}\n </>\n );\n\n if (href) {\n const isExternal = /^(https?:)?\\/\\//i.test(href);\n return (\n <StyledCardLink\n href={href}\n target={isExternal ? \"_blank\" : undefined}\n rel={isExternal ? \"noopener noreferrer\" : undefined}\n >\n {content}\n </StyledCardLink>\n );\n }\n\n return <StyledCard>{content}</StyledCard>;\n}\n\nexport { Card };\n";
|
|
1
|
+
export declare const cardTemplate = "\"use client\";\nimport Link from \"next/link\";\nimport styled, { css, useTheme } from \"styled-components\";\nimport { styledText } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon, IconProps } from \"@/components/layout/Icon\";\nimport { interactiveStyles } from \"@/components/layout/SharedStyled\";\n\nconst cardStyles = css<{ theme: Theme }>`\n display: flex;\n flex-direction: column;\n gap: 12px;\n background: ${({ theme }) => theme.colors.light};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 20px;\n margin: 0;\n ${({ theme }) => styledText(theme)}\n color: ${({ theme }) => theme.colors.grayDark};\n`;\n\nconst StyledCard = styled.div<{ theme: Theme }>`\n ${cardStyles}\n`;\n\nconst StyledCardLink = styled(Link)<{ theme: Theme }>`\n ${interactiveStyles};\n ${cardStyles}\n text-decoration: none;\n`;\n\nconst StyledCardTitle = styled.p<{ theme: Theme }>`\n font-weight: bold;\n margin: 0;\n color: ${({ theme }) => theme.colors.dark};\n ${({ theme }) => styledText(theme)};\n`;\n\ninterface CardProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n title?: string;\n icon?: IconProps;\n href?: string;\n}\n\nfunction Card({ children, title, icon, href }: CardProps) {\n const theme = useTheme() as Theme;\n\n const content = (\n <>\n {icon && <Icon name={icon} color={theme.colors.primary} />}\n {title && <StyledCardTitle>{title}</StyledCardTitle>}\n {children}\n </>\n );\n\n if (href) {\n const isExternal = /^(https?:)?\\/\\//i.test(href);\n return (\n <StyledCardLink\n href={href}\n target={isExternal ? \"_blank\" : undefined}\n rel={isExternal ? \"noopener noreferrer\" : undefined}\n >\n {content}\n </StyledCardLink>\n );\n }\n\n return <StyledCard>{content}</StyledCard>;\n}\n\nexport { Card };\n";
|
|
@@ -7,6 +7,9 @@ import { Icon, IconProps } from "@/components/layout/Icon";
|
|
|
7
7
|
import { interactiveStyles } from "@/components/layout/SharedStyled";
|
|
8
8
|
|
|
9
9
|
const cardStyles = css<{ theme: Theme }>\`
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
gap: 12px;
|
|
10
13
|
background: \${({ theme }) => theme.colors.light};
|
|
11
14
|
border: solid 1px \${({ theme }) => theme.colors.grayLight};
|
|
12
15
|
border-radius: \${({ theme }) => theme.spacing.radius.lg};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const mermaidViewTemplate = "\"use client\";\nimport {\n useCallback,\n useEffect,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { interactiveStyles, resetButton } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon } from \"@/components/layout/Icon\";\n\nconst MIN_SCALE = 0.5;\nconst MAX_SCALE = 4;\nconst SCALE_STEP = 0.25;\nconst PAN_STEP = 48;\nconst AUTO_ACTIONS_MIN_HEIGHT = 120;\n\n// Whether the Fullscreen API is available. Read via useSyncExternalStore so it\n// resolves during render (SSR-safe: false on the server) instead of via a\n// synchronous setState inside an effect. The capability never changes, so the\n// subscribe callback is a stable no-op.\nconst subscribeFullscreenCapability = () => () => {};\nconst getFullscreenCapability = () =>\n typeof document !== \"undefined\" && Boolean(document.fullscreenEnabled);\nconst getFullscreenCapabilityServer = () => false;\n\nexport type MermaidPlacement =\n \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n\ninterface MermaidViewProps {\n svg: string;\n width?: number | null;\n placement?: MermaidPlacement;\n actions?: boolean;\n theme?: Theme;\n}\n\nconst Viewport = styled.div<{ $draggable: boolean; $dragging: boolean }>`\n overflow: hidden;\n padding: 16px;\n ${({ $draggable, $dragging }) =>\n $draggable &&\n css`\n cursor: ${$dragging ? \"grabbing\" : \"grab\"};\n user-select: none;\n `}\n`;\n\nconst Stage = styled.div<{\n $scale: number;\n $x: number;\n $y: number;\n $dragging: boolean;\n}>`\n transform: translate(${({ $x }) => $x}px, ${({ $y }) => $y}px)\n scale(${({ $scale }) => $scale});\n transform-origin: center center;\n transition: ${({ $dragging }) =>\n $dragging ? \"none\" : \"transform 0.15s ease-out\"};\n margin: 0 auto;\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n\n & > svg {\n display: block;\n width: 100%;\n height: auto;\n margin: 0 auto;\n }\n`;\n\nconst Figure = styled.figure<{ theme: Theme }>`\n position: relative;\n flex-shrink: 0;\n margin: 0;\n padding: 0;\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n background: ${({ theme }) => theme.colors.light};\n overflow: hidden;\n\n &:fullscreen {\n border: none;\n border-radius: 0;\n\n ${Viewport} {\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n ${Stage} {\n width: 100%;\n height: 100%;\n }\n\n ${Stage} > svg {\n height: 100%;\n }\n }\n`;\n\nconst Controls = styled.div<{ theme: Theme; $placement: MermaidPlacement }>`\n position: absolute;\n ${({ $placement }) => {\n const [vertical, horizontal] = $placement.split(\"-\");\n return css`\n ${vertical}: 8px;\n ${horizontal}: 8px;\n `;\n }}\n display: grid;\n grid-template-columns: repeat(3, 24px);\n grid-template-rows: repeat(3, 24px);\n gap: 2px;\n padding: 4px;\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n background: ${({ theme }) => theme.colors.light};\n box-shadow: ${({ theme }) => theme.shadows.sm};\n`;\n\nconst ControlButton = styled.button<{ theme: Theme }>`\n ${resetButton};\n ${interactiveStyles};\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n color: ${({ theme }) => theme.colors.grayDark};\n cursor: pointer;\n\n &:hover:not(:disabled) {\n background: ${({ theme }) => theme.colors.grayLight};\n color: ${({ theme }) => theme.colors.dark};\n }\n\n &:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n }\n`;\n\nfunction MermaidView({\n svg,\n width,\n placement = \"bottom-right\",\n actions,\n ...props\n}: MermaidViewProps) {\n const [scale, setScale] = useState(1);\n const [offset, setOffset] = useState({ x: 0, y: 0 });\n const [autoShow, setAutoShow] = useState(false);\n const [dragging, setDragging] = useState(false);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const canFullscreen = useSyncExternalStore(\n subscribeFullscreenCapability,\n getFullscreenCapability,\n getFullscreenCapabilityServer,\n );\n const viewportRef = useRef<HTMLDivElement>(null);\n const figureRef = useRef<HTMLElement>(null);\n const dragStart = useRef<{\n x: number;\n y: number;\n ox: number;\n oy: number;\n } | null>(null);\n\n useEffect(() => {\n if (actions !== undefined) return;\n const element = viewportRef.current;\n if (!element || typeof ResizeObserver === \"undefined\") return;\n\n const measure = () => {\n setAutoShow(\n element.getBoundingClientRect().height > AUTO_ACTIONS_MIN_HEIGHT,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, [actions]);\n\n useEffect(() => {\n const onChange = () =>\n setIsFullscreen(document.fullscreenElement === figureRef.current);\n document.addEventListener(\"fullscreenchange\", onChange);\n return () => document.removeEventListener(\"fullscreenchange\", onChange);\n }, []);\n\n const showControls = actions ?? autoShow;\n\n const zoom = useCallback((delta: number) => {\n setScale((current) =>\n Math.min(\n MAX_SCALE,\n Math.max(MIN_SCALE, Math.round((current + delta) * 100) / 100),\n ),\n );\n }, []);\n\n const pan = useCallback((x: number, y: number) => {\n setOffset((current) => ({ x: current.x + x, y: current.y + y }));\n }, []);\n\n const reset = useCallback(() => {\n setScale(1);\n setOffset({ x: 0, y: 0 });\n }, []);\n\n const toggleFullscreen = useCallback(() => {\n const element = figureRef.current;\n if (!element) return;\n if (document.fullscreenElement === element) {\n void document.exitFullscreen().catch(() => {});\n } else {\n void element.requestFullscreen().catch(() => {});\n }\n }, []);\n\n const handlePointerDown = (event: React.PointerEvent<HTMLDivElement>) => {\n if (!showControls || event.pointerType !== \"mouse\" || event.button !== 0) {\n return;\n }\n event.currentTarget.setPointerCapture(event.pointerId);\n dragStart.current = {\n x: event.clientX,\n y: event.clientY,\n ox: offset.x,\n oy: offset.y,\n };\n setDragging(true);\n };\n\n const handlePointerMove = (event: React.PointerEvent<HTMLDivElement>) => {\n const start = dragStart.current;\n if (!start) return;\n setOffset({\n x: start.ox + (event.clientX - start.x),\n y: start.oy + (event.clientY - start.y),\n });\n };\n\n const endDrag = (event: React.PointerEvent<HTMLDivElement>) => {\n if (!dragStart.current) return;\n dragStart.current = null;\n setDragging(false);\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n };\n\n const isReset = scale === 1 && offset.x === 0 && offset.y === 0;\n\n return (\n <Figure ref={figureRef} {...props}>\n <Viewport\n ref={viewportRef}\n $draggable={showControls}\n $dragging={dragging}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={endDrag}\n onPointerCancel={endDrag}\n >\n <Stage\n $scale={scale}\n $x={offset.x}\n $y={offset.y}\n $dragging={dragging}\n style={\n width && !isFullscreen ? { maxWidth: `${width}px` } : undefined\n }\n dangerouslySetInnerHTML={{ __html: svg }}\n />\n </Viewport>\n\n {showControls && (\n <Controls $placement={placement}>\n <ControlButton\n type=\"button\"\n aria-label=\"Zoom out\"\n onClick={() => zoom(-SCALE_STEP)}\n disabled={scale <= MIN_SCALE}\n >\n <Icon name=\"zoom-out\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Pan up\"\n onClick={() => pan(0, -PAN_STEP)}\n >\n <Icon name=\"chevron-up\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Zoom in\"\n onClick={() => zoom(SCALE_STEP)}\n disabled={scale >= MAX_SCALE}\n >\n <Icon name=\"zoom-in\" size={14} />\n </ControlButton>\n\n <ControlButton\n type=\"button\"\n aria-label=\"Pan left\"\n onClick={() => pan(-PAN_STEP, 0)}\n >\n <Icon name=\"chevron-left\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Reset view\"\n onClick={reset}\n disabled={isReset}\n >\n <Icon name=\"rotate-ccw\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Pan right\"\n onClick={() => pan(PAN_STEP, 0)}\n >\n <Icon name=\"chevron-right\" size={14} />\n </ControlButton>\n\n {canFullscreen ? (\n <ControlButton\n type=\"button\"\n aria-label={isFullscreen ? \"Exit full screen\" : \"Full screen\"}\n onClick={toggleFullscreen}\n >\n <Icon name={isFullscreen ? \"minimize\" : \"maximize\"} size={14} />\n </ControlButton>\n ) : (\n <span />\n )}\n <ControlButton\n type=\"button\"\n aria-label=\"Pan down\"\n onClick={() => pan(0, PAN_STEP)}\n >\n <Icon name=\"chevron-down\" size={14} />\n </ControlButton>\n <span />\n </Controls>\n )}\n </Figure>\n );\n}\n\nexport { MermaidView };\n";
|
|
1
|
+
export declare const mermaidViewTemplate = "\"use client\";\nimport {\n useCallback,\n useEffect,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { interactiveStyles, resetButton } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon } from \"@/components/layout/Icon\";\n\nconst MIN_SCALE = 0.5;\nconst MAX_SCALE = 4;\nconst SCALE_STEP = 0.25;\nconst PAN_STEP = 48;\nconst MIN_DIAGRAM_HEIGHT = 320;\n// Must exceed MIN_DIAGRAM_HEIGHT plus the viewport padding (2 x 16px), so\n// diagrams sitting on the min-height floor don't auto-show the controls.\nconst AUTO_ACTIONS_MIN_HEIGHT = 420;\n\n// Whether the Fullscreen API is available. Read via useSyncExternalStore so it\n// resolves during render (SSR-safe: false on the server) instead of via a\n// synchronous setState inside an effect. The capability never changes, so the\n// subscribe callback is a stable no-op.\nconst subscribeFullscreenCapability = () => () => {};\nconst getFullscreenCapability = () =>\n typeof document !== \"undefined\" && Boolean(document.fullscreenEnabled);\nconst getFullscreenCapabilityServer = () => false;\n\nexport type MermaidPlacement =\n \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n\ninterface MermaidViewProps {\n svg: string;\n width?: number | null;\n placement?: MermaidPlacement;\n actions?: boolean;\n theme?: Theme;\n}\n\nconst Viewport = styled.div<{ $draggable: boolean; $dragging: boolean }>`\n overflow: hidden;\n padding: 16px;\n ${({ $draggable, $dragging }) =>\n $draggable &&\n css`\n cursor: ${$dragging ? \"grabbing\" : \"grab\"};\n user-select: none;\n `}\n`;\n\nconst Stage = styled.div<{\n $scale: number;\n $x: number;\n $y: number;\n $dragging: boolean;\n}>`\n transform: translate(${({ $x }) => $x}px, ${({ $y }) => $y}px)\n scale(${({ $scale }) => $scale});\n transform-origin: center center;\n transition: ${({ $dragging }) =>\n $dragging ? \"none\" : \"transform 0.15s ease-out\"};\n margin: 0 auto;\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n\n & > svg {\n display: block;\n width: 100%;\n height: auto;\n min-height: ${MIN_DIAGRAM_HEIGHT}px;\n margin: 0 auto;\n }\n`;\n\nconst Figure = styled.figure<{ theme: Theme }>`\n position: relative;\n flex-shrink: 0;\n margin: 0;\n padding: 0;\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n background: ${({ theme }) => theme.colors.light};\n overflow: hidden;\n\n &:fullscreen {\n border: none;\n border-radius: 0;\n\n ${Viewport} {\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n ${Stage} {\n width: 100%;\n height: 100%;\n }\n\n ${Stage} > svg {\n height: 100%;\n }\n }\n`;\n\nconst Controls = styled.div<{ theme: Theme; $placement: MermaidPlacement }>`\n position: absolute;\n ${({ $placement }) => {\n const [vertical, horizontal] = $placement.split(\"-\");\n return css`\n ${vertical}: 8px;\n ${horizontal}: 8px;\n `;\n }}\n display: grid;\n grid-template-columns: repeat(3, 24px);\n grid-template-rows: repeat(3, 24px);\n gap: 2px;\n padding: 4px;\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n background: ${({ theme }) => theme.colors.light};\n box-shadow: ${({ theme }) => theme.shadows.sm};\n`;\n\nconst ControlButton = styled.button<{ theme: Theme }>`\n ${resetButton};\n ${interactiveStyles};\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n color: ${({ theme }) => theme.colors.grayDark};\n cursor: pointer;\n\n &:hover:not(:disabled) {\n background: ${({ theme }) => theme.colors.grayLight};\n color: ${({ theme }) => theme.colors.dark};\n }\n\n &:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n }\n`;\n\nfunction MermaidView({\n svg,\n width,\n placement = \"bottom-right\",\n actions,\n ...props\n}: MermaidViewProps) {\n const [scale, setScale] = useState(1);\n const [offset, setOffset] = useState({ x: 0, y: 0 });\n const [autoShow, setAutoShow] = useState(false);\n const [dragging, setDragging] = useState(false);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const canFullscreen = useSyncExternalStore(\n subscribeFullscreenCapability,\n getFullscreenCapability,\n getFullscreenCapabilityServer,\n );\n const viewportRef = useRef<HTMLDivElement>(null);\n const figureRef = useRef<HTMLElement>(null);\n const dragStart = useRef<{\n x: number;\n y: number;\n ox: number;\n oy: number;\n } | null>(null);\n\n useEffect(() => {\n if (actions !== undefined) return;\n const element = viewportRef.current;\n if (!element || typeof ResizeObserver === \"undefined\") return;\n\n const measure = () => {\n setAutoShow(\n element.getBoundingClientRect().height > AUTO_ACTIONS_MIN_HEIGHT,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, [actions]);\n\n useEffect(() => {\n const onChange = () =>\n setIsFullscreen(document.fullscreenElement === figureRef.current);\n document.addEventListener(\"fullscreenchange\", onChange);\n return () => document.removeEventListener(\"fullscreenchange\", onChange);\n }, []);\n\n const showControls = actions ?? autoShow;\n\n const zoom = useCallback((delta: number) => {\n setScale((current) =>\n Math.min(\n MAX_SCALE,\n Math.max(MIN_SCALE, Math.round((current + delta) * 100) / 100),\n ),\n );\n }, []);\n\n const pan = useCallback((x: number, y: number) => {\n setOffset((current) => ({ x: current.x + x, y: current.y + y }));\n }, []);\n\n const reset = useCallback(() => {\n setScale(1);\n setOffset({ x: 0, y: 0 });\n }, []);\n\n const toggleFullscreen = useCallback(() => {\n const element = figureRef.current;\n if (!element) return;\n if (document.fullscreenElement === element) {\n void document.exitFullscreen().catch(() => {});\n } else {\n void element.requestFullscreen().catch(() => {});\n }\n }, []);\n\n const handlePointerDown = (event: React.PointerEvent<HTMLDivElement>) => {\n if (!showControls || event.pointerType !== \"mouse\" || event.button !== 0) {\n return;\n }\n event.currentTarget.setPointerCapture(event.pointerId);\n dragStart.current = {\n x: event.clientX,\n y: event.clientY,\n ox: offset.x,\n oy: offset.y,\n };\n setDragging(true);\n };\n\n const handlePointerMove = (event: React.PointerEvent<HTMLDivElement>) => {\n const start = dragStart.current;\n if (!start) return;\n setOffset({\n x: start.ox + (event.clientX - start.x),\n y: start.oy + (event.clientY - start.y),\n });\n };\n\n const endDrag = (event: React.PointerEvent<HTMLDivElement>) => {\n if (!dragStart.current) return;\n dragStart.current = null;\n setDragging(false);\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n };\n\n const isReset = scale === 1 && offset.x === 0 && offset.y === 0;\n\n return (\n <Figure ref={figureRef} {...props}>\n <Viewport\n ref={viewportRef}\n $draggable={showControls}\n $dragging={dragging}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={endDrag}\n onPointerCancel={endDrag}\n >\n <Stage\n $scale={scale}\n $x={offset.x}\n $y={offset.y}\n $dragging={dragging}\n style={\n width && !isFullscreen ? { maxWidth: `${width}px` } : undefined\n }\n dangerouslySetInnerHTML={{ __html: svg }}\n />\n </Viewport>\n\n {showControls && (\n <Controls $placement={placement}>\n <ControlButton\n type=\"button\"\n aria-label=\"Zoom out\"\n onClick={() => zoom(-SCALE_STEP)}\n disabled={scale <= MIN_SCALE}\n >\n <Icon name=\"zoom-out\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Pan up\"\n onClick={() => pan(0, -PAN_STEP)}\n >\n <Icon name=\"chevron-up\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Zoom in\"\n onClick={() => zoom(SCALE_STEP)}\n disabled={scale >= MAX_SCALE}\n >\n <Icon name=\"zoom-in\" size={14} />\n </ControlButton>\n\n <ControlButton\n type=\"button\"\n aria-label=\"Pan left\"\n onClick={() => pan(-PAN_STEP, 0)}\n >\n <Icon name=\"chevron-left\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Reset view\"\n onClick={reset}\n disabled={isReset}\n >\n <Icon name=\"rotate-ccw\" size={14} />\n </ControlButton>\n <ControlButton\n type=\"button\"\n aria-label=\"Pan right\"\n onClick={() => pan(PAN_STEP, 0)}\n >\n <Icon name=\"chevron-right\" size={14} />\n </ControlButton>\n\n {canFullscreen ? (\n <ControlButton\n type=\"button\"\n aria-label={isFullscreen ? \"Exit full screen\" : \"Full screen\"}\n onClick={toggleFullscreen}\n >\n <Icon name={isFullscreen ? \"minimize\" : \"maximize\"} size={14} />\n </ControlButton>\n ) : (\n <span />\n )}\n <ControlButton\n type=\"button\"\n aria-label=\"Pan down\"\n onClick={() => pan(0, PAN_STEP)}\n >\n <Icon name=\"chevron-down\" size={14} />\n </ControlButton>\n <span />\n </Controls>\n )}\n </Figure>\n );\n}\n\nexport { MermaidView };\n";
|
|
@@ -15,7 +15,10 @@ const MIN_SCALE = 0.5;
|
|
|
15
15
|
const MAX_SCALE = 4;
|
|
16
16
|
const SCALE_STEP = 0.25;
|
|
17
17
|
const PAN_STEP = 48;
|
|
18
|
-
const
|
|
18
|
+
const MIN_DIAGRAM_HEIGHT = 320;
|
|
19
|
+
// Must exceed MIN_DIAGRAM_HEIGHT plus the viewport padding (2 x 16px), so
|
|
20
|
+
// diagrams sitting on the min-height floor don't auto-show the controls.
|
|
21
|
+
const AUTO_ACTIONS_MIN_HEIGHT = 420;
|
|
19
22
|
|
|
20
23
|
// Whether the Fullscreen API is available. Read via useSyncExternalStore so it
|
|
21
24
|
// resolves during render (SSR-safe: false on the server) instead of via a
|
|
@@ -69,6 +72,7 @@ const Stage = styled.div<{
|
|
|
69
72
|
display: block;
|
|
70
73
|
width: 100%;
|
|
71
74
|
height: auto;
|
|
75
|
+
min-height: \${MIN_DIAGRAM_HEIGHT}px;
|
|
72
76
|
margin: 0 auto;
|
|
73
77
|
}
|
|
74
78
|
\`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const mermaidMdxTemplate = "---\ntitle: \"Mermaid\"\ndescription: \"Create flowcharts, sequence diagrams, and other visualizations using Mermaid syntax.\"\ndate: \"2026-07-16\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 23\n---\n# Mermaid\n\nCreate flowcharts, sequence diagrams, and other visualizations using Mermaid syntax with automatic rendering.\n\nWrite a diagram inside a `mermaid` code fence and it renders as an SVG:\n\n````mdx\n```mermaid\nflowchart LR\n A[Start] --> B{Decision}\n B -->|Yes| C[Action]\n B -->|No| D[End]\n```\n````\n\n```mermaid\nflowchart LR\n A[Start] --> B{Decision}\n B -->|Yes| C[Action]\n B -->|No| D[End]\n```\n\nDiagrams are rendered when your site is built, so no diagramming library is shipped to your readers' browsers. They are drawn with your theme's colors and follow the light and dark toggle automatically.\n\n## Supported diagram types\n\nDoccupine renders diagrams with [beautiful-mermaid](https://github.com/lukilabs/beautiful-mermaid), which supports six diagram types:\n\n| Type | Opening keyword |\n| --- | --- |\n| Flowchart | `flowchart` or `graph` |\n| Sequence | `sequenceDiagram` |\n| State | `stateDiagram-v2` |\n| Class | `classDiagram` |\n| Entity relationship | `erDiagram` |\n| XY chart | `xychart-beta` |\n\nOther Mermaid diagram types - including `pie`, `gantt`, `mindmap`, `journey`, and `gitGraph` - are not supported. A diagram that cannot be rendered falls back to a plain code block showing its source, and the reason is logged when your site builds. A broken diagram never breaks the page.\n\n## Examples\n\n### Sequence diagram\n\n```mermaid\nsequenceDiagram\n participant Reader\n participant Docs\n participant Search\n Reader->>Docs: Open a page\n Docs->>Search: Index the content\n Search-->>Reader: Return results\n```\n\n### Subgraphs\n\n```mermaid placement=\"top-right\"\nflowchart LR\n subgraph one\n direction TB\n top1[top] --> bottom1[bottom]\n end\n subgraph two\n direction TB\n top2[top] --> bottom2[bottom]\n end\n outside --> one\n outside --> top2\n```\n\n## Interactive controls\n\nDiagrams include zoom in and out, pan in four directions, reset the view, and full screen. You can also drag a diagram with your mouse to move it around.\n\nBy default the controls appear once a diagram is taller than 120px, since a diagram that already fits does not need them. Use the `actions` property to decide explicitly. Setting `actions={false}` turns off the whole interactive layer, including dragging.\n\n## Properties\n\n<Field value=\"placement\" type=\"string\">\n Where the controls sit. One of `top-left`, `top-right`, `bottom-left`, or `bottom-right`. Defaults to `bottom-right`.\n</Field>\n\n<Field value=\"actions\" type=\"boolean\">\n Show or hide the controls. When set, this overrides the default behavior of showing them only on diagrams
|
|
1
|
+
export declare const mermaidMdxTemplate = "---\ntitle: \"Mermaid\"\ndescription: \"Create flowcharts, sequence diagrams, and other visualizations using Mermaid syntax.\"\ndate: \"2026-07-16\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 23\n---\n# Mermaid\n\nCreate flowcharts, sequence diagrams, and other visualizations using Mermaid syntax with automatic rendering.\n\nWrite a diagram inside a `mermaid` code fence and it renders as an SVG:\n\n````mdx\n```mermaid\nflowchart LR\n A[Start] --> B{Decision}\n B -->|Yes| C[Action]\n B -->|No| D[End]\n```\n````\n\n```mermaid\nflowchart LR\n A[Start] --> B{Decision}\n B -->|Yes| C[Action]\n B -->|No| D[End]\n```\n\nDiagrams are rendered when your site is built, so no diagramming library is shipped to your readers' browsers. They are drawn with your theme's colors and follow the light and dark toggle automatically.\n\n## Supported diagram types\n\nDoccupine renders diagrams with [beautiful-mermaid](https://github.com/lukilabs/beautiful-mermaid), which supports six diagram types:\n\n| Type | Opening keyword |\n| --- | --- |\n| Flowchart | `flowchart` or `graph` |\n| Sequence | `sequenceDiagram` |\n| State | `stateDiagram-v2` |\n| Class | `classDiagram` |\n| Entity relationship | `erDiagram` |\n| XY chart | `xychart-beta` |\n\nOther Mermaid diagram types - including `pie`, `gantt`, `mindmap`, `journey`, and `gitGraph` - are not supported. A diagram that cannot be rendered falls back to a plain code block showing its source, and the reason is logged when your site builds. A broken diagram never breaks the page.\n\n## Examples\n\n### Sequence diagram\n\n```mermaid\nsequenceDiagram\n participant Reader\n participant Docs\n participant Search\n Reader->>Docs: Open a page\n Docs->>Search: Index the content\n Search-->>Reader: Return results\n```\n\n### Subgraphs\n\n```mermaid placement=\"top-right\"\nflowchart LR\n subgraph one\n direction TB\n top1[top] --> bottom1[bottom]\n end\n subgraph two\n direction TB\n top2[top] --> bottom2[bottom]\n end\n outside --> one\n outside --> top2\n```\n\n## Interactive controls\n\nDiagrams include zoom in and out, pan in four directions, reset the view, and full screen. You can also drag a diagram with your mouse to move it around.\n\nBy default the controls appear once a diagram is taller than 120px, since a diagram that already fits does not need them. Use the `actions` property to decide explicitly. Setting `actions={false}` turns off the whole interactive layer, including dragging.\n\n## Properties\n\n<Field value=\"placement\" type=\"string\">\n Where the controls sit. One of `top-left`, `top-right`, `bottom-left`, or `bottom-right`. Defaults to `bottom-right`.\n</Field>\n\n<Field value=\"actions\" type=\"boolean\">\n Show or hide the controls. When set, this overrides the default behavior of showing them only on larger diagrams.\n</Field>\n\nSet properties on the opening fence, after the language:\n\n````mdx\n```mermaid placement=\"top-left\" actions={true}\nflowchart LR\n A --> B\n```\n````\n\nTo hide the controls entirely:\n\n````mdx\n```mermaid actions={false}\nflowchart LR\n A --> B\n```\n````\n\n```mermaid actions={false}\nflowchart LR\n A --> B\n```\n\n## Layout\n\nDiagrams are laid out with the [ELK](https://eclipse.dev/elk/) engine, which arranges nodes to reduce overlapping edges and keep large diagrams readable. It is always on, so no directive is needed to enable it.\n\nIf you are porting diagrams from another tool, a `%%{init: ...}%%` directive is read as a comment and ignored rather than causing an error.\n\n## Theming\n\nDiagram colors come from CSS variables, so they follow your theme and the light/dark toggle without re-rendering. Override any of them in your own CSS to restyle diagrams:\n\n```css\n:root {\n --mermaid-bg: var(--color-light);\n --mermaid-fg: var(--color-dark);\n --mermaid-line: var(--color-grayDark);\n --mermaid-accent: var(--color-accent);\n --mermaid-muted: var(--color-grayDark);\n --mermaid-surface: var(--color-grayLight);\n --mermaid-border: var(--color-gray);\n}\n```\n\n## Syntax reference\n\nFor the syntax of each supported diagram type, see the [Mermaid documentation](https://mermaid.js.org/intro/). Keep to the six types listed above.";
|
|
@@ -88,7 +88,7 @@ By default the controls appear once a diagram is taller than 120px, since a diag
|
|
|
88
88
|
</Field>
|
|
89
89
|
|
|
90
90
|
<Field value="actions" type="boolean">
|
|
91
|
-
Show or hide the controls. When set, this overrides the default behavior of showing them only on diagrams
|
|
91
|
+
Show or hide the controls. When set, this overrides the default behavior of showing them only on larger diagrams.
|
|
92
92
|
</Field>
|
|
93
93
|
|
|
94
94
|
Set properties on the opening fence, after the language:
|
|
@@ -24,7 +24,7 @@ export const packageJsonTemplate = JSON.stringify({
|
|
|
24
24
|
minisearch: "^7.2.0",
|
|
25
25
|
next: "16.2.12",
|
|
26
26
|
"next-mdx-remote": "^6.0.0",
|
|
27
|
-
"posthog-js": "^1.407.
|
|
27
|
+
"posthog-js": "^1.407.4",
|
|
28
28
|
"posthog-node": "^5.46.1",
|
|
29
29
|
react: "19.2.8",
|
|
30
30
|
"react-dom": "19.2.8",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "doccupine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.139",
|
|
4
4
|
"description": "Free and open-source documentation platform. Write MDX, get a production-ready site with AI chat, built-in components, and an MCP server - in one command.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|