@assistant-ui/react-markdown 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/styles/markdown.css +26 -25
- package/dist/styles/tailwindcss/markdown.css +40 -37
- package/package.json +2 -2
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/primitives/MarkdownText.tsx","../src/overrides/PreOverride.tsx","../src/overrides/defaultComponents.tsx","../src/overrides/CodeOverride.tsx","../src/overrides/withDefaults.tsx","../src/ui/markdown-text.tsx","../src/ui/code-header.tsx","../src/ui/useCopyToClipboard.tsx"],"sourcesContent":["export {\n MarkdownTextPrimitive,\n type MarkdownTextPrimitiveProps,\n} from \"./primitives/MarkdownText\";\n\nexport type {\n CodeHeaderProps,\n SyntaxHighlighterProps,\n} from \"./overrides/types\";\n\nexport {\n makeMarkdownText,\n type MakeMarkdownTextProps,\n} from \"./ui/markdown-text\";\n\nexport { CodeHeader } from \"./ui/code-header\";\n","import { INTERNAL, useContentPartText } from \"@assistant-ui/react\";\nimport type { ComponentType, FC } from \"react\";\nimport ReactMarkdown, { type Options } from \"react-markdown\";\nimport { SyntaxHighlighterProps, CodeHeaderProps } from \"../overrides/types\";\nimport { PreOverride } from \"../overrides/PreOverride\";\nimport {\n DefaultPre,\n DefaultCode,\n DefaultSyntaxHighlighter,\n DefaultCodeHeader,\n} from \"../overrides/defaultComponents\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { CodeOverride } from \"../overrides/CodeOverride\";\n\nconst { useSmooth } = INTERNAL;\n\nexport type MarkdownTextPrimitiveProps = Omit<\n Options,\n \"components\" | \"children\"\n> & {\n components?: NonNullable<Options[\"components\"]> & {\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n CodeHeader?: ComponentType<CodeHeaderProps>;\n };\n smooth?: boolean;\n};\nexport const MarkdownTextPrimitive: FC<MarkdownTextPrimitiveProps> = ({\n smooth = true,\n components: userComponents,\n ...rest\n}) => {\n const {\n part: { text },\n } = useContentPartText();\n const smoothText = useSmooth(text, smooth);\n\n const {\n pre = DefaultPre,\n code = DefaultCode,\n SyntaxHighlighter = DefaultSyntaxHighlighter,\n CodeHeader = DefaultCodeHeader,\n ...componentsRest\n } = userComponents ?? {};\n const components: typeof userComponents = {\n ...componentsRest,\n pre: PreOverride,\n code: useCallbackRef((props) => (\n <CodeOverride\n components={{ Pre: pre, Code: code, SyntaxHighlighter, CodeHeader }}\n {...props}\n />\n )),\n };\n\n return (\n <ReactMarkdown components={components} {...rest}>\n {smoothText}\n </ReactMarkdown>\n );\n};\n","import { createContext, ComponentPropsWithoutRef } from \"react\";\nimport { PreComponent } from \"./types\";\n\nexport const PreContext = createContext<Omit<\n ComponentPropsWithoutRef<PreComponent>,\n \"children\"\n> | null>(null);\n\nexport const PreOverride: PreComponent = ({ children, ...rest }) => {\n return <PreContext.Provider value={rest}>{children}</PreContext.Provider>;\n};\n","import type { ComponentType } from \"react\";\nimport {\n PreComponent,\n CodeComponent,\n SyntaxHighlighterProps,\n CodeHeaderProps,\n} from \"./types\";\n\nexport const DefaultPre: PreComponent = ({ node, ...rest }) => (\n <pre {...rest} />\n);\nexport const DefaultCode: CodeComponent = ({ node, ...rest }) => (\n <code {...rest} />\n);\nexport const DefaultSyntaxHighlighter: ComponentType<\n SyntaxHighlighterProps\n> = ({ components: { Pre, Code }, code }) => (\n <Pre>\n <Code>{code}</Code>\n </Pre>\n);\nexport const DefaultCodeHeader: ComponentType<CodeHeaderProps> = () => null;\n","import {\n ComponentPropsWithoutRef,\n ComponentType,\n FC,\n useContext,\n useMemo,\n} from \"react\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { PreContext } from \"./PreOverride\";\nimport {\n CodeComponent,\n CodeHeaderProps,\n PreComponent,\n SyntaxHighlighterProps,\n} from \"./types\";\nimport { DefaultSyntaxHighlighter } from \"./defaultComponents\";\nimport { withDefaultProps } from \"./withDefaults\";\n\ntype CodeOverrideProps = ComponentPropsWithoutRef<CodeComponent> & {\n components: {\n Pre: PreComponent;\n Code: CodeComponent;\n CodeHeader: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter: ComponentType<SyntaxHighlighterProps>;\n };\n};\n\nconst CodeBlockOverride: FC<CodeOverrideProps> = ({\n components: { Pre, Code, SyntaxHighlighter, CodeHeader },\n children,\n ...codeProps\n}) => {\n const preProps = useContext(PreContext)!;\n const getPreProps = withDefaultProps<any>(preProps);\n const WrappedPre: PreComponent = useCallbackRef((props) => (\n <Pre {...getPreProps(props)} />\n ));\n\n const getCodeProps = withDefaultProps<any>(codeProps);\n const WrappedCode: CodeComponent = useCallbackRef((props) => (\n <Code {...getCodeProps(props)} />\n ));\n\n const components = useMemo(\n () => ({ Pre: WrappedPre, Code: WrappedCode }),\n [WrappedPre, WrappedCode],\n );\n\n const language = /language-(\\w+)/.exec(codeProps.className || \"\")?.[1];\n const code = children as string;\n const SH = language ? SyntaxHighlighter : DefaultSyntaxHighlighter;\n\n return (\n <>\n <CodeHeader language={language} code={code} />\n <SH\n components={components}\n language={language ?? \"unknown\"}\n code={code}\n />\n </>\n );\n};\n\nexport const CodeOverride: FC<CodeOverrideProps> = ({\n components,\n ...props\n}) => {\n const preProps = useContext(PreContext);\n if (!preProps) return <components.Code {...(props as any)} />;\n return <CodeBlockOverride components={components} {...props} />;\n};\n","import classNames from \"classnames\";\n\nexport const withDefaultProps =\n <TProps extends { className?: string | undefined }>({\n className,\n ...defaultProps\n }: Partial<TProps>) =>\n ({ className: classNameProp, ...props }: TProps) => {\n return {\n className: classNames(className, classNameProp),\n ...defaultProps,\n ...props,\n } as TProps;\n };\n","import { TextContentPartProps } from \"@assistant-ui/react\";\nimport { FC, memo } from \"react\";\nimport { CodeHeader } from \"./code-header\";\nimport classNames from \"classnames\";\nimport {\n MarkdownTextPrimitive,\n MarkdownTextPrimitiveProps,\n} from \"../primitives/MarkdownText\";\n\nexport type MakeMarkdownTextProps = MarkdownTextPrimitiveProps;\n\nexport const makeMarkdownText = ({\n className,\n components: userComponents,\n ...rest\n}: MakeMarkdownTextProps = {}) => {\n const components = {\n ...userComponents,\n CodeHeader: userComponents?.CodeHeader ?? CodeHeader,\n };\n\n const MarkdownTextImpl: FC<TextContentPartProps> = ({ status }) => {\n return (\n <div\n className={classNames(\n \"aui-md-root\",\n status.type === \"in_progress\" && \"aui-md-in-progress\",\n className,\n )}\n >\n <MarkdownTextPrimitive components={components} {...rest} />\n </div>\n );\n };\n MarkdownTextImpl.displayName = \"MarkdownText\";\n\n return memo(\n MarkdownTextImpl,\n (prev, next) => prev.status.type === next.status.type,\n );\n};\n","import { FC } from \"react\";\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\nimport { useThreadConfig, INTERNAL } from \"@assistant-ui/react\";\n\nimport { CodeHeaderProps } from \"../overrides/types\";\nimport { useCopyToClipboard } from \"./useCopyToClipboard\";\n\nconst { TooltipIconButton } = INTERNAL;\n\nexport const CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {\n const {\n strings: {\n code: { header: { copy: { tooltip = \"Copy\" } = {} } = {} } = {},\n } = {},\n } = useThreadConfig();\n\n const { isCopied, copyToClipboard } = useCopyToClipboard();\n const onCopy = () => {\n if (!code || isCopied) return;\n copyToClipboard(code);\n };\n\n return (\n <div className=\"aui-code-header-root\">\n <span className=\"aui-code-header-language\">{language}</span>\n <TooltipIconButton tooltip={tooltip} onClick={onCopy}>\n {!isCopied && <CopyIcon />}\n {isCopied && <CheckIcon />}\n </TooltipIconButton>\n </div>\n );\n};\n","import { useState } from \"react\";\nimport { UseActionBarCopyProps } from \"@assistant-ui/react\";\n\nexport type useCopyToClipboardProps = UseActionBarCopyProps;\n\nexport const useCopyToClipboard = ({\n copiedDuration = 3000,\n}: useCopyToClipboardProps = {}) => {\n const [isCopied, setIsCopied] = useState<boolean>(false);\n\n const copyToClipboard = (value: string) => {\n if (!value) return;\n\n navigator.clipboard.writeText(value).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), copiedDuration);\n });\n };\n\n return { isCopied, copyToClipboard };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA6C;AAE7C,4BAA4C;;;ACF5C,mBAAwD;AAS/C;AANF,IAAM,iBAAa,4BAGhB,IAAI;AAEP,IAAM,cAA4B,CAAC,EAAE,UAAU,GAAG,KAAK,MAAM;AAClE,SAAO,4CAAC,WAAW,UAAX,EAAoB,OAAO,MAAO,UAAS;AACrD;;;ACDE,IAAAC,sBAAA;AADK,IAAM,aAA2B,CAAC,EAAE,MAAM,GAAG,KAAK,MACvD,6CAAC,SAAK,GAAG,MAAM;AAEV,IAAM,cAA6B,CAAC,EAAE,MAAM,GAAG,KAAK,MACzD,6CAAC,UAAM,GAAG,MAAM;AAEX,IAAM,2BAET,CAAC,EAAE,YAAY,EAAE,KAAK,KAAK,GAAG,KAAK,MACrC,6CAAC,OACC,uDAAC,QAAM,gBAAK,GACd;AAEK,IAAM,oBAAoD,MAAM;;;AFVvE,IAAAC,iCAA+B;;;AGX/B,IAAAC,gBAMO;AACP,oCAA+B;;;ACP/B,wBAAuB;AAEhB,IAAM,mBACX,CAAoD;AAAA,EAClD;AAAA,EACA,GAAG;AACL,MACA,CAAC,EAAE,WAAW,eAAe,GAAG,MAAM,MAAc;AAClD,SAAO;AAAA,IACL,eAAW,kBAAAC,SAAW,WAAW,aAAa;AAAA,IAC9C,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AACF;;;ADsBE,IAAAC,sBAAA;AARJ,IAAM,oBAA2C,CAAC;AAAA,EAChD,YAAY,EAAE,KAAK,MAAM,mBAAmB,YAAAC,YAAW;AAAA,EACvD;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,eAAW,0BAAW,U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iDAAC,UAAK,WAAU,4BAA4B,oBAAS;AAAA,IACrD,8CAAC,qBAAkB,SAAkB,SAAS,QAC3C;AAAA,OAAC,YAAY,6CAAC,gCAAS;AAAA,MACvB,YAAY,6CAAC,iCAAU;AAAA,OAC1B;AAAA,KACF;AAEJ;;;AD5BA,IAAAC,qBAAuB;AA2Bf,IAAAC,sBAAA;AAnBD,IAAM,mBAAmB,CAAC;AAAA,EAC/B;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,IAA2B,CAAC,MAAM;AAChC,QAAM,aAAa;AAAA,IACjB,GAAG;AAAA,IACH,YAAY,gBAAgB,cAAc;AAAA,EAC5C;AAEA,QAAM,mBAA6C,CAAC,EAAE,OAAO,MAAM;AACjE,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,mBAAAC;AAAA,UACT;AAAA,UACA,OAAO,SAAS,iBAAiB;AAAA,UACjC;AAAA,QACF;AAAA,QAEA,uDAAC,yBAAsB,YAAyB,GAAG,MAAM;AAAA;AAAA,IAC3D;AAAA,EAEJ;AACA,mBAAiB,cAAc;AAE/B,aAAO;AAAA,IACL;AAAA,IACA,CAAC,MAAM,SAAS,KAAK,OAAO,SAAS,KAAK,OAAO;AAAA,EACnD;AACF;","names":["import_react","import_jsx_runtime","import_react_use_callback_ref","import_react","classNames","import_jsx_runtime","CodeHeader","import_jsx_runtime","CodeHeader","ReactMarkdown","import_react","import_react","import_react","import_jsx_runtime","import_classnames","import_jsx_runtime","classNames"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/primitives/MarkdownText.tsx","../src/overrides/PreOverride.tsx","../src/overrides/defaultComponents.tsx","../src/overrides/CodeOverride.tsx","../src/overrides/withDefaults.tsx","../src/ui/markdown-text.tsx","../src/ui/code-header.tsx","../src/ui/useCopyToClipboard.tsx"],"sourcesContent":["export {\n MarkdownTextPrimitive,\n type MarkdownTextPrimitiveProps,\n} from \"./primitives/MarkdownText\";\n\nexport type {\n CodeHeaderProps,\n SyntaxHighlighterProps,\n} from \"./overrides/types\";\n\nexport {\n makeMarkdownText,\n type MakeMarkdownTextProps,\n} from \"./ui/markdown-text\";\n\nexport { CodeHeader } from \"./ui/code-header\";\n","\"use client\";\n\nimport { INTERNAL, useContentPartText } from \"@assistant-ui/react\";\nimport type { ComponentType, FC } from \"react\";\nimport ReactMarkdown, { type Options } from \"react-markdown\";\nimport { SyntaxHighlighterProps, CodeHeaderProps } from \"../overrides/types\";\nimport { PreOverride } from \"../overrides/PreOverride\";\nimport {\n DefaultPre,\n DefaultCode,\n DefaultSyntaxHighlighter,\n DefaultCodeHeader,\n} from \"../overrides/defaultComponents\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { CodeOverride } from \"../overrides/CodeOverride\";\n\nconst { useSmooth } = INTERNAL;\n\nexport type MarkdownTextPrimitiveProps = Omit<\n Options,\n \"components\" | \"children\"\n> & {\n components?: NonNullable<Options[\"components\"]> & {\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n CodeHeader?: ComponentType<CodeHeaderProps>;\n };\n smooth?: boolean;\n};\nexport const MarkdownTextPrimitive: FC<MarkdownTextPrimitiveProps> = ({\n smooth = true,\n components: userComponents,\n ...rest\n}) => {\n const {\n part: { text },\n } = useContentPartText();\n const smoothText = useSmooth(text, smooth);\n\n const {\n pre = DefaultPre,\n code = DefaultCode,\n SyntaxHighlighter = DefaultSyntaxHighlighter,\n CodeHeader = DefaultCodeHeader,\n ...componentsRest\n } = userComponents ?? {};\n const components: typeof userComponents = {\n ...componentsRest,\n pre: PreOverride,\n code: useCallbackRef((props) => (\n <CodeOverride\n components={{ Pre: pre, Code: code, SyntaxHighlighter, CodeHeader }}\n {...props}\n />\n )),\n };\n\n return (\n <ReactMarkdown components={components} {...rest}>\n {smoothText}\n </ReactMarkdown>\n );\n};\n","import { createContext, ComponentPropsWithoutRef } from \"react\";\nimport { PreComponent } from \"./types\";\n\nexport const PreContext = createContext<Omit<\n ComponentPropsWithoutRef<PreComponent>,\n \"children\"\n> | null>(null);\n\nexport const PreOverride: PreComponent = ({ children, ...rest }) => {\n return <PreContext.Provider value={rest}>{children}</PreContext.Provider>;\n};\n","import type { ComponentType } from \"react\";\nimport {\n PreComponent,\n CodeComponent,\n SyntaxHighlighterProps,\n CodeHeaderProps,\n} from \"./types\";\n\nexport const DefaultPre: PreComponent = ({ node, ...rest }) => (\n <pre {...rest} />\n);\nexport const DefaultCode: CodeComponent = ({ node, ...rest }) => (\n <code {...rest} />\n);\nexport const DefaultSyntaxHighlighter: ComponentType<\n SyntaxHighlighterProps\n> = ({ components: { Pre, Code }, code }) => (\n <Pre>\n <Code>{code}</Code>\n </Pre>\n);\nexport const DefaultCodeHeader: ComponentType<CodeHeaderProps> = () => null;\n","import {\n ComponentPropsWithoutRef,\n ComponentType,\n FC,\n useContext,\n useMemo,\n} from \"react\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { PreContext } from \"./PreOverride\";\nimport {\n CodeComponent,\n CodeHeaderProps,\n PreComponent,\n SyntaxHighlighterProps,\n} from \"./types\";\nimport { DefaultSyntaxHighlighter } from \"./defaultComponents\";\nimport { withDefaultProps } from \"./withDefaults\";\n\ntype CodeOverrideProps = ComponentPropsWithoutRef<CodeComponent> & {\n components: {\n Pre: PreComponent;\n Code: CodeComponent;\n CodeHeader: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter: ComponentType<SyntaxHighlighterProps>;\n };\n};\n\nconst CodeBlockOverride: FC<CodeOverrideProps> = ({\n components: { Pre, Code, SyntaxHighlighter, CodeHeader },\n children,\n ...codeProps\n}) => {\n const preProps = useContext(PreContext)!;\n const getPreProps = withDefaultProps<any>(preProps);\n const WrappedPre: PreComponent = useCallbackRef((props) => (\n <Pre {...getPreProps(props)} />\n ));\n\n const getCodeProps = withDefaultProps<any>(codeProps);\n const WrappedCode: CodeComponent = useCallbackRef((props) => (\n <Code {...getCodeProps(props)} />\n ));\n\n const components = useMemo(\n () => ({ Pre: WrappedPre, Code: WrappedCode }),\n [WrappedPre, WrappedCode],\n );\n\n const language = /language-(\\w+)/.exec(codeProps.className || \"\")?.[1];\n const code = children as string;\n const SH = language ? SyntaxHighlighter : DefaultSyntaxHighlighter;\n\n return (\n <>\n <CodeHeader language={language} code={code} />\n <SH\n components={components}\n language={language ?? \"unknown\"}\n code={code}\n />\n </>\n );\n};\n\nexport const CodeOverride: FC<CodeOverrideProps> = ({\n components,\n ...props\n}) => {\n const preProps = useContext(PreContext);\n if (!preProps) return <components.Code {...(props as any)} />;\n return <CodeBlockOverride components={components} {...props} />;\n};\n","import classNames from \"classnames\";\n\nexport const withDefaultProps =\n <TProps extends { className?: string | undefined }>({\n className,\n ...defaultProps\n }: Partial<TProps>) =>\n ({ className: classNameProp, ...props }: TProps) => {\n return {\n className: classNames(className, classNameProp),\n ...defaultProps,\n ...props,\n } as TProps;\n };\n","import { TextContentPartProps } from \"@assistant-ui/react\";\nimport { FC, memo } from \"react\";\nimport { CodeHeader } from \"./code-header\";\nimport classNames from \"classnames\";\nimport {\n MarkdownTextPrimitive,\n MarkdownTextPrimitiveProps,\n} from \"../primitives/MarkdownText\";\n\nexport type MakeMarkdownTextProps = MarkdownTextPrimitiveProps;\n\nexport const makeMarkdownText = ({\n className,\n components: userComponents,\n ...rest\n}: MakeMarkdownTextProps = {}) => {\n const components = {\n ...userComponents,\n CodeHeader: userComponents?.CodeHeader ?? CodeHeader,\n };\n\n const MarkdownTextImpl: FC<TextContentPartProps> = ({ status }) => {\n return (\n <div\n className={classNames(\n \"aui-md-root\",\n status.type === \"in_progress\" && \"aui-md-in-progress\",\n className,\n )}\n >\n <MarkdownTextPrimitive components={components} {...rest} />\n </div>\n );\n };\n MarkdownTextImpl.displayName = \"MarkdownText\";\n\n return memo(\n MarkdownTextImpl,\n (prev, next) => prev.status.type === next.status.type,\n );\n};\n","import { FC } from \"react\";\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\nimport { useThreadConfig, INTERNAL } from \"@assistant-ui/react\";\n\nimport { CodeHeaderProps } from \"../overrides/types\";\nimport { useCopyToClipboard } from \"./useCopyToClipboard\";\n\nconst { TooltipIconButton } = INTERNAL;\n\nexport const CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {\n const {\n strings: {\n code: { header: { copy: { tooltip = \"Copy\" } = {} } = {} } = {},\n } = {},\n } = useThreadConfig();\n\n const { isCopied, copyToClipboard } = useCopyToClipboard();\n const onCopy = () => {\n if (!code || isCopied) return;\n copyToClipboard(code);\n };\n\n return (\n <div className=\"aui-code-header-root\">\n <span className=\"aui-code-header-language\">{language}</span>\n <TooltipIconButton tooltip={tooltip} onClick={onCopy}>\n {!isCopied && <CopyIcon />}\n {isCopied && <CheckIcon />}\n </TooltipIconButton>\n </div>\n );\n};\n","import { useState } from \"react\";\nimport { UseActionBarCopyProps } from \"@assistant-ui/react\";\n\nexport type useCopyToClipboardProps = UseActionBarCopyProps;\n\nexport const useCopyToClipboard = ({\n copiedDuration = 3000,\n}: useCopyToClipboardProps = {}) => {\n const [isCopied, setIsCopied] = useState<boolean>(false);\n\n const copyToClipboard = (value: string) => {\n if (!value) return;\n\n navigator.clipboard.writeText(value).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), copiedDuration);\n });\n };\n\n return { isCopied, copyToClipboard };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAAA,gBAA6C;AAE7C,4BAA4C;;;ACJ5C,mBAAwD;AAS/C;AANF,IAAM,iBAAa,4BAGhB,IAAI;AAEP,IAAM,cAA4B,CAAC,EAAE,UAAU,GAAG,KAAK,MAAM;AAClE,SAAO,4CAAC,WAAW,UAAX,EAAoB,OAAO,MAAO,UAAS;AACrD;;;ACDE,IAAAC,sBAAA;AADK,IAAM,aAA2B,CAAC,EAAE,MAAM,GAAG,KAAK,MACvD,6CAAC,SAAK,GAAG,MAAM;AAEV,IAAM,cAA6B,C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QACF;AAAA,QAEA,uDAAC,yBAAsB,YAAyB,GAAG,MAAM;AAAA;AAAA,IAC3D;AAAA,EAEJ;AACA,mBAAiB,cAAc;AAE/B,aAAO;AAAA,IACL;AAAA,IACA,CAAC,MAAM,SAAS,KAAK,OAAO,SAAS,KAAK,OAAO;AAAA,EACnD;AACF;","names":["import_react","import_jsx_runtime","import_react_use_callback_ref","import_react","classNames","import_jsx_runtime","CodeHeader","import_jsx_runtime","CodeHeader","ReactMarkdown","import_react","import_react","import_react","import_jsx_runtime","import_classnames","import_jsx_runtime","classNames"]}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/primitives/MarkdownText.tsx","../src/overrides/PreOverride.tsx","../src/overrides/defaultComponents.tsx","../src/overrides/CodeOverride.tsx","../src/overrides/withDefaults.tsx","../src/ui/markdown-text.tsx","../src/ui/code-header.tsx","../src/ui/useCopyToClipboard.tsx"],"sourcesContent":["import { INTERNAL, useContentPartText } from \"@assistant-ui/react\";\nimport type { ComponentType, FC } from \"react\";\nimport ReactMarkdown, { type Options } from \"react-markdown\";\nimport { SyntaxHighlighterProps, CodeHeaderProps } from \"../overrides/types\";\nimport { PreOverride } from \"../overrides/PreOverride\";\nimport {\n DefaultPre,\n DefaultCode,\n DefaultSyntaxHighlighter,\n DefaultCodeHeader,\n} from \"../overrides/defaultComponents\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { CodeOverride } from \"../overrides/CodeOverride\";\n\nconst { useSmooth } = INTERNAL;\n\nexport type MarkdownTextPrimitiveProps = Omit<\n Options,\n \"components\" | \"children\"\n> & {\n components?: NonNullable<Options[\"components\"]> & {\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n CodeHeader?: ComponentType<CodeHeaderProps>;\n };\n smooth?: boolean;\n};\nexport const MarkdownTextPrimitive: FC<MarkdownTextPrimitiveProps> = ({\n smooth = true,\n components: userComponents,\n ...rest\n}) => {\n const {\n part: { text },\n } = useContentPartText();\n const smoothText = useSmooth(text, smooth);\n\n const {\n pre = DefaultPre,\n code = DefaultCode,\n SyntaxHighlighter = DefaultSyntaxHighlighter,\n CodeHeader = DefaultCodeHeader,\n ...componentsRest\n } = userComponents ?? {};\n const components: typeof userComponents = {\n ...componentsRest,\n pre: PreOverride,\n code: useCallbackRef((props) => (\n <CodeOverride\n components={{ Pre: pre, Code: code, SyntaxHighlighter, CodeHeader }}\n {...props}\n />\n )),\n };\n\n return (\n <ReactMarkdown components={components} {...rest}>\n {smoothText}\n </ReactMarkdown>\n );\n};\n","import { createContext, ComponentPropsWithoutRef } from \"react\";\nimport { PreComponent } from \"./types\";\n\nexport const PreContext = createContext<Omit<\n ComponentPropsWithoutRef<PreComponent>,\n \"children\"\n> | null>(null);\n\nexport const PreOverride: PreComponent = ({ children, ...rest }) => {\n return <PreContext.Provider value={rest}>{children}</PreContext.Provider>;\n};\n","import type { ComponentType } from \"react\";\nimport {\n PreComponent,\n CodeComponent,\n SyntaxHighlighterProps,\n CodeHeaderProps,\n} from \"./types\";\n\nexport const DefaultPre: PreComponent = ({ node, ...rest }) => (\n <pre {...rest} />\n);\nexport const DefaultCode: CodeComponent = ({ node, ...rest }) => (\n <code {...rest} />\n);\nexport const DefaultSyntaxHighlighter: ComponentType<\n SyntaxHighlighterProps\n> = ({ components: { Pre, Code }, code }) => (\n <Pre>\n <Code>{code}</Code>\n </Pre>\n);\nexport const DefaultCodeHeader: ComponentType<CodeHeaderProps> = () => null;\n","import {\n ComponentPropsWithoutRef,\n ComponentType,\n FC,\n useContext,\n useMemo,\n} from \"react\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { PreContext } from \"./PreOverride\";\nimport {\n CodeComponent,\n CodeHeaderProps,\n PreComponent,\n SyntaxHighlighterProps,\n} from \"./types\";\nimport { DefaultSyntaxHighlighter } from \"./defaultComponents\";\nimport { withDefaultProps } from \"./withDefaults\";\n\ntype CodeOverrideProps = ComponentPropsWithoutRef<CodeComponent> & {\n components: {\n Pre: PreComponent;\n Code: CodeComponent;\n CodeHeader: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter: ComponentType<SyntaxHighlighterProps>;\n };\n};\n\nconst CodeBlockOverride: FC<CodeOverrideProps> = ({\n components: { Pre, Code, SyntaxHighlighter, CodeHeader },\n children,\n ...codeProps\n}) => {\n const preProps = useContext(PreContext)!;\n const getPreProps = withDefaultProps<any>(preProps);\n const WrappedPre: PreComponent = useCallbackRef((props) => (\n <Pre {...getPreProps(props)} />\n ));\n\n const getCodeProps = withDefaultProps<any>(codeProps);\n const WrappedCode: CodeComponent = useCallbackRef((props) => (\n <Code {...getCodeProps(props)} />\n ));\n\n const components = useMemo(\n () => ({ Pre: WrappedPre, Code: WrappedCode }),\n [WrappedPre, WrappedCode],\n );\n\n const language = /language-(\\w+)/.exec(codeProps.className || \"\")?.[1];\n const code = children as string;\n const SH = language ? SyntaxHighlighter : DefaultSyntaxHighlighter;\n\n return (\n <>\n <CodeHeader language={language} code={code} />\n <SH\n components={components}\n language={language ?? \"unknown\"}\n code={code}\n />\n </>\n );\n};\n\nexport const CodeOverride: FC<CodeOverrideProps> = ({\n components,\n ...props\n}) => {\n const preProps = useContext(PreContext);\n if (!preProps) return <components.Code {...(props as any)} />;\n return <CodeBlockOverride components={components} {...props} />;\n};\n","import classNames from \"classnames\";\n\nexport const withDefaultProps =\n <TProps extends { className?: string | undefined }>({\n className,\n ...defaultProps\n }: Partial<TProps>) =>\n ({ className: classNameProp, ...props }: TProps) => {\n return {\n className: classNames(className, classNameProp),\n ...defaultProps,\n ...props,\n } as TProps;\n };\n","import { TextContentPartProps } from \"@assistant-ui/react\";\nimport { FC, memo } from \"react\";\nimport { CodeHeader } from \"./code-header\";\nimport classNames from \"classnames\";\nimport {\n MarkdownTextPrimitive,\n MarkdownTextPrimitiveProps,\n} from \"../primitives/MarkdownText\";\n\nexport type MakeMarkdownTextProps = MarkdownTextPrimitiveProps;\n\nexport const makeMarkdownText = ({\n className,\n components: userComponents,\n ...rest\n}: MakeMarkdownTextProps = {}) => {\n const components = {\n ...userComponents,\n CodeHeader: userComponents?.CodeHeader ?? CodeHeader,\n };\n\n const MarkdownTextImpl: FC<TextContentPartProps> = ({ status }) => {\n return (\n <div\n className={classNames(\n \"aui-md-root\",\n status.type === \"in_progress\" && \"aui-md-in-progress\",\n className,\n )}\n >\n <MarkdownTextPrimitive components={components} {...rest} />\n </div>\n );\n };\n MarkdownTextImpl.displayName = \"MarkdownText\";\n\n return memo(\n MarkdownTextImpl,\n (prev, next) => prev.status.type === next.status.type,\n );\n};\n","import { FC } from \"react\";\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\nimport { useThreadConfig, INTERNAL } from \"@assistant-ui/react\";\n\nimport { CodeHeaderProps } from \"../overrides/types\";\nimport { useCopyToClipboard } from \"./useCopyToClipboard\";\n\nconst { TooltipIconButton } = INTERNAL;\n\nexport const CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {\n const {\n strings: {\n code: { header: { copy: { tooltip = \"Copy\" } = {} } = {} } = {},\n } = {},\n } = useThreadConfig();\n\n const { isCopied, copyToClipboard } = useCopyToClipboard();\n const onCopy = () => {\n if (!code || isCopied) return;\n copyToClipboard(code);\n };\n\n return (\n <div className=\"aui-code-header-root\">\n <span className=\"aui-code-header-language\">{language}</span>\n <TooltipIconButton tooltip={tooltip} onClick={onCopy}>\n {!isCopied && <CopyIcon />}\n {isCopied && <CheckIcon />}\n </TooltipIconButton>\n </div>\n );\n};\n","import { useState } from \"react\";\nimport { UseActionBarCopyProps } from \"@assistant-ui/react\";\n\nexport type useCopyToClipboardProps = UseActionBarCopyProps;\n\nexport const useCopyToClipboard = ({\n copiedDuration = 3000,\n}: useCopyToClipboardProps = {}) => {\n const [isCopied, setIsCopied] = useState<boolean>(false);\n\n const copyToClipboard = (value: string) => {\n if (!value) return;\n\n navigator.clipboard.writeText(value).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), copiedDu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D,KAAC,UAAK,WAAU,4BAA4B,oBAAS;AAAA,IACrD,gBAAAC,MAAC,qBAAkB,SAAkB,SAAS,QAC3C;AAAA,OAAC,YAAY,gBAAAD,KAAC,YAAS;AAAA,MACvB,YAAY,gBAAAA,KAAC,aAAU;AAAA,OAC1B;AAAA,KACF;AAEJ;;;AD5BA,OAAOG,iBAAgB;AA2Bf,gBAAAC,YAAA;AAnBD,IAAM,mBAAmB,CAAC;AAAA,EAC/B;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,IAA2B,CAAC,MAAM;AAChC,QAAM,aAAa;AAAA,IACjB,GAAG;AAAA,IACH,YAAY,gBAAgB,cAAc;AAAA,EAC5C;AAEA,QAAM,mBAA6C,CAAC,EAAE,OAAO,MAAM;AACjE,WACE,gBAAAA;AAAA,MAAC;AAAA;AAAA,QACC,WAAWC;AAAA,UACT;AAAA,UACA,OAAO,SAAS,iBAAiB;AAAA,UACjC;AAAA,QACF;AAAA,QAEA,0BAAAD,KAAC,yBAAsB,YAAyB,GAAG,MAAM;AAAA;AAAA,IAC3D;AAAA,EAEJ;AACA,mBAAiB,cAAc;AAE/B,SAAO;AAAA,IACL;AAAA,IACA,CAAC,MAAM,SAAS,KAAK,OAAO,SAAS,KAAK,OAAO;AAAA,EACnD;AACF;","names":["jsx","useCallbackRef","jsx","CodeHeader","jsx","CodeHeader","useCallbackRef","INTERNAL","jsx","jsxs","INTERNAL","classNames","jsx","classNames"]}
|
|
1
|
+
{"version":3,"sources":["../src/primitives/MarkdownText.tsx","../src/overrides/PreOverride.tsx","../src/overrides/defaultComponents.tsx","../src/overrides/CodeOverride.tsx","../src/overrides/withDefaults.tsx","../src/ui/markdown-text.tsx","../src/ui/code-header.tsx","../src/ui/useCopyToClipboard.tsx"],"sourcesContent":["\"use client\";\n\nimport { INTERNAL, useContentPartText } from \"@assistant-ui/react\";\nimport type { ComponentType, FC } from \"react\";\nimport ReactMarkdown, { type Options } from \"react-markdown\";\nimport { SyntaxHighlighterProps, CodeHeaderProps } from \"../overrides/types\";\nimport { PreOverride } from \"../overrides/PreOverride\";\nimport {\n DefaultPre,\n DefaultCode,\n DefaultSyntaxHighlighter,\n DefaultCodeHeader,\n} from \"../overrides/defaultComponents\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { CodeOverride } from \"../overrides/CodeOverride\";\n\nconst { useSmooth } = INTERNAL;\n\nexport type MarkdownTextPrimitiveProps = Omit<\n Options,\n \"components\" | \"children\"\n> & {\n components?: NonNullable<Options[\"components\"]> & {\n SyntaxHighlighter?: ComponentType<SyntaxHighlighterProps>;\n CodeHeader?: ComponentType<CodeHeaderProps>;\n };\n smooth?: boolean;\n};\nexport const MarkdownTextPrimitive: FC<MarkdownTextPrimitiveProps> = ({\n smooth = true,\n components: userComponents,\n ...rest\n}) => {\n const {\n part: { text },\n } = useContentPartText();\n const smoothText = useSmooth(text, smooth);\n\n const {\n pre = DefaultPre,\n code = DefaultCode,\n SyntaxHighlighter = DefaultSyntaxHighlighter,\n CodeHeader = DefaultCodeHeader,\n ...componentsRest\n } = userComponents ?? {};\n const components: typeof userComponents = {\n ...componentsRest,\n pre: PreOverride,\n code: useCallbackRef((props) => (\n <CodeOverride\n components={{ Pre: pre, Code: code, SyntaxHighlighter, CodeHeader }}\n {...props}\n />\n )),\n };\n\n return (\n <ReactMarkdown components={components} {...rest}>\n {smoothText}\n </ReactMarkdown>\n );\n};\n","import { createContext, ComponentPropsWithoutRef } from \"react\";\nimport { PreComponent } from \"./types\";\n\nexport const PreContext = createContext<Omit<\n ComponentPropsWithoutRef<PreComponent>,\n \"children\"\n> | null>(null);\n\nexport const PreOverride: PreComponent = ({ children, ...rest }) => {\n return <PreContext.Provider value={rest}>{children}</PreContext.Provider>;\n};\n","import type { ComponentType } from \"react\";\nimport {\n PreComponent,\n CodeComponent,\n SyntaxHighlighterProps,\n CodeHeaderProps,\n} from \"./types\";\n\nexport const DefaultPre: PreComponent = ({ node, ...rest }) => (\n <pre {...rest} />\n);\nexport const DefaultCode: CodeComponent = ({ node, ...rest }) => (\n <code {...rest} />\n);\nexport const DefaultSyntaxHighlighter: ComponentType<\n SyntaxHighlighterProps\n> = ({ components: { Pre, Code }, code }) => (\n <Pre>\n <Code>{code}</Code>\n </Pre>\n);\nexport const DefaultCodeHeader: ComponentType<CodeHeaderProps> = () => null;\n","import {\n ComponentPropsWithoutRef,\n ComponentType,\n FC,\n useContext,\n useMemo,\n} from \"react\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { PreContext } from \"./PreOverride\";\nimport {\n CodeComponent,\n CodeHeaderProps,\n PreComponent,\n SyntaxHighlighterProps,\n} from \"./types\";\nimport { DefaultSyntaxHighlighter } from \"./defaultComponents\";\nimport { withDefaultProps } from \"./withDefaults\";\n\ntype CodeOverrideProps = ComponentPropsWithoutRef<CodeComponent> & {\n components: {\n Pre: PreComponent;\n Code: CodeComponent;\n CodeHeader: ComponentType<CodeHeaderProps>;\n SyntaxHighlighter: ComponentType<SyntaxHighlighterProps>;\n };\n};\n\nconst CodeBlockOverride: FC<CodeOverrideProps> = ({\n components: { Pre, Code, SyntaxHighlighter, CodeHeader },\n children,\n ...codeProps\n}) => {\n const preProps = useContext(PreContext)!;\n const getPreProps = withDefaultProps<any>(preProps);\n const WrappedPre: PreComponent = useCallbackRef((props) => (\n <Pre {...getPreProps(props)} />\n ));\n\n const getCodeProps = withDefaultProps<any>(codeProps);\n const WrappedCode: CodeComponent = useCallbackRef((props) => (\n <Code {...getCodeProps(props)} />\n ));\n\n const components = useMemo(\n () => ({ Pre: WrappedPre, Code: WrappedCode }),\n [WrappedPre, WrappedCode],\n );\n\n const language = /language-(\\w+)/.exec(codeProps.className || \"\")?.[1];\n const code = children as string;\n const SH = language ? SyntaxHighlighter : DefaultSyntaxHighlighter;\n\n return (\n <>\n <CodeHeader language={language} code={code} />\n <SH\n components={components}\n language={language ?? \"unknown\"}\n code={code}\n />\n </>\n );\n};\n\nexport const CodeOverride: FC<CodeOverrideProps> = ({\n components,\n ...props\n}) => {\n const preProps = useContext(PreContext);\n if (!preProps) return <components.Code {...(props as any)} />;\n return <CodeBlockOverride components={components} {...props} />;\n};\n","import classNames from \"classnames\";\n\nexport const withDefaultProps =\n <TProps extends { className?: string | undefined }>({\n className,\n ...defaultProps\n }: Partial<TProps>) =>\n ({ className: classNameProp, ...props }: TProps) => {\n return {\n className: classNames(className, classNameProp),\n ...defaultProps,\n ...props,\n } as TProps;\n };\n","import { TextContentPartProps } from \"@assistant-ui/react\";\nimport { FC, memo } from \"react\";\nimport { CodeHeader } from \"./code-header\";\nimport classNames from \"classnames\";\nimport {\n MarkdownTextPrimitive,\n MarkdownTextPrimitiveProps,\n} from \"../primitives/MarkdownText\";\n\nexport type MakeMarkdownTextProps = MarkdownTextPrimitiveProps;\n\nexport const makeMarkdownText = ({\n className,\n components: userComponents,\n ...rest\n}: MakeMarkdownTextProps = {}) => {\n const components = {\n ...userComponents,\n CodeHeader: userComponents?.CodeHeader ?? CodeHeader,\n };\n\n const MarkdownTextImpl: FC<TextContentPartProps> = ({ status }) => {\n return (\n <div\n className={classNames(\n \"aui-md-root\",\n status.type === \"in_progress\" && \"aui-md-in-progress\",\n className,\n )}\n >\n <MarkdownTextPrimitive components={components} {...rest} />\n </div>\n );\n };\n MarkdownTextImpl.displayName = \"MarkdownText\";\n\n return memo(\n MarkdownTextImpl,\n (prev, next) => prev.status.type === next.status.type,\n );\n};\n","import { FC } from \"react\";\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\nimport { useThreadConfig, INTERNAL } from \"@assistant-ui/react\";\n\nimport { CodeHeaderProps } from \"../overrides/types\";\nimport { useCopyToClipboard } from \"./useCopyToClipboard\";\n\nconst { TooltipIconButton } = INTERNAL;\n\nexport const CodeHeader: FC<CodeHeaderProps> = ({ language, code }) => {\n const {\n strings: {\n code: { header: { copy: { tooltip = \"Copy\" } = {} } = {} } = {},\n } = {},\n } = useThreadConfig();\n\n const { isCopied, copyToClipboard } = useCopyToClipboard();\n const onCopy = () => {\n if (!code || isCopied) return;\n copyToClipboard(code);\n };\n\n return (\n <div className=\"aui-code-header-root\">\n <span className=\"aui-code-header-language\">{language}</span>\n <TooltipIconButton tooltip={tooltip} onClick={onCopy}>\n {!isCopied && <CopyIcon />}\n {isCopied && <CheckIcon />}\n </TooltipIconButton>\n </div>\n );\n};\n","import { useState } from \"react\";\nimport { UseActionBarCopyProps } from \"@assistant-ui/react\";\n\nexport type useCopyToClipboardProps = UseActionBarCopyProps;\n\nexport const useCopyToClipboard = ({\n copiedDuration = 3000,\n}: useCopyToClipboardProps = {}) => {\n const [isCopied, setIsCopied] = useState<boolean>(false);\n\n const copyToClipboard = (value: string) => {\n if (!value) return;\n\n navigator.clipboard.writeText(value).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), copiedDuration);\n });\n };\n\n return { isCopied, copyToClipboard };\n};\n"],"mappings":";;;AAEA,SAAS,UAAU,0BAA0B;AAE7C,OAAO,mBAAqC;;;ACJ5C,SAAS,qBAA+C;AAS/C;AANF,IAAM,aAAa,cAGhB,IAAI;AAEP,IAAM,cAA4B,CAAC,EAAE,UAAU,GAAG,KAAK,MAAM;AAClE,SAAO,oBAAC,WAAW,UAAX,EAAoB,OAAO,MAAO,UAAS;AACrD;;;ACDE,gBAAAA,YAAA;AADK,IAAM,aAA2B,CAAC,EAAE,MAAM,GAAG,KAAK,MACvD,gBAAAA,KAAC,SAAK,GAAG,MAAM;AAEV,IAAM,cAA6B,CAAC,EAAE,MAAM,GAAG,KAAK,MACzD,gBAAAA,KAAC,UAAM,GAAG,MAAM;AAEX,IAAM,2BAET,CAAC,EAAE,YAAY,EAAE,KAAK,KAAK,GAAG,KAAK,MACrC,gBAAAA,KAAC,OACC,0BAAAA,KAAC,QAAM,gBAAK,GACd;AAEK,IAAM,oBAAoD,MAAM;;;AFRvE,SAAS,kBAAAC,uBAAsB;;;AGb/B;AAAA,EAIE;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAA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,IACL;AAAA,IACA,CAAC,MAAM,SAAS,KAAK,OAAO,SAAS,KAAK,OAAO;AAAA,EACnD;AACF;","names":["jsx","useCallbackRef","jsx","CodeHeader","jsx","CodeHeader","useCallbackRef","INTERNAL","jsx","jsxs","INTERNAL","classNames","jsx","classNames"]}
|
package/dist/styles/markdown.css
CHANGED
|
@@ -1,67 +1,68 @@
|
|
|
1
1
|
/* src/styles/tailwindcss/markdown.css */
|
|
2
|
-
.aui-md-in-progress:empty::after,
|
|
3
|
-
.aui-md-in-progress
|
|
4
|
-
.aui-md-in-progress
|
|
5
|
-
.aui-md-in-progress
|
|
6
|
-
.aui-md-in-progress
|
|
7
|
-
.aui-md-in-progress
|
|
2
|
+
.aui-md-in-progress:where(:empty)::after,
|
|
3
|
+
.aui-md-in-progress:where(> :not(ol):not(ul):not(pre):last-child)::after,
|
|
4
|
+
.aui-md-in-progress:where(> pre:last-child code)::after,
|
|
5
|
+
.aui-md-in-progress:where(> :is(ol, ul):last-child > li:last-child:not(:has(* > li)))::after,
|
|
6
|
+
.aui-md-in-progress:where(> :is(ol, ul):last-child > li:last-child > :is(ol, ul):last-child > li:last-child:not(:has(* > li)))::after,
|
|
7
|
+
.aui-md-in-progress:where(> :is(ol, ul):last-child > li:last-child > :is(ol, ul):last-child > li:last-child > :is(ol, ul):last-child > li:last-child)::after {
|
|
8
8
|
@apply animate-pulse font-sans content-["\25cf"] ltr:ml-1 rtl:mr-1;
|
|
9
9
|
}
|
|
10
|
-
.aui-md-root h1 {
|
|
10
|
+
:where(.aui-md-root) h1 {
|
|
11
11
|
@apply mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0;
|
|
12
12
|
}
|
|
13
|
-
.aui-md-root h2 {
|
|
13
|
+
:where(.aui-md-root) h2 {
|
|
14
14
|
@apply mb-4 mt-8 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0;
|
|
15
15
|
}
|
|
16
|
-
.aui-md-root h3 {
|
|
16
|
+
:where(.aui-md-root) h3 {
|
|
17
17
|
@apply mb-4 mt-6 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0;
|
|
18
18
|
}
|
|
19
|
-
.aui-md-root h4 {
|
|
19
|
+
:where(.aui-md-root) h4 {
|
|
20
20
|
@apply mb-4 mt-6 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0;
|
|
21
21
|
}
|
|
22
|
-
.aui-md-root h5 {
|
|
22
|
+
:where(.aui-md-root) h5 {
|
|
23
23
|
@apply my-4 text-lg font-semibold first:mt-0 last:mb-0;
|
|
24
24
|
}
|
|
25
|
-
.aui-md-root h6 {
|
|
25
|
+
:where(.aui-md-root) h6 {
|
|
26
26
|
@apply my-4 font-semibold first:mt-0 last:mb-0;
|
|
27
27
|
}
|
|
28
|
-
.aui-md-root p {
|
|
28
|
+
:where(.aui-md-root) p {
|
|
29
29
|
@apply mb-5 mt-5 leading-7 first:mt-0 last:mb-0;
|
|
30
30
|
}
|
|
31
|
-
.aui-md-root a {
|
|
31
|
+
:where(.aui-md-root) a {
|
|
32
32
|
@apply text-aui-primary font-medium underline underline-offset-4;
|
|
33
33
|
}
|
|
34
|
-
.aui-md-root blockquote {
|
|
34
|
+
:where(.aui-md-root) blockquote {
|
|
35
35
|
@apply border-l-2 pl-6 italic;
|
|
36
36
|
}
|
|
37
|
-
.aui-md-root ul {
|
|
37
|
+
:where(.aui-md-root) ul {
|
|
38
38
|
@apply my-5 ml-6 list-disc [&>li]:mt-2;
|
|
39
39
|
}
|
|
40
|
-
.aui-md-root ol {
|
|
40
|
+
:where(.aui-md-root) ol {
|
|
41
41
|
@apply my-5 ml-6 list-decimal [&>li]:mt-2;
|
|
42
42
|
}
|
|
43
|
-
.aui-md-root hr {
|
|
43
|
+
:where(.aui-md-root) hr {
|
|
44
44
|
@apply my-5 border-b;
|
|
45
45
|
}
|
|
46
|
-
.aui-md-root table {
|
|
46
|
+
:where(.aui-md-root) table {
|
|
47
47
|
@apply my-5 w-full border-separate border-spacing-0 overflow-y-auto;
|
|
48
48
|
}
|
|
49
|
-
.aui-md-root th {
|
|
49
|
+
:where(.aui-md-root) th {
|
|
50
50
|
@apply bg-aui-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [&[align=center]]:text-center [&[align=right]]:text-right;
|
|
51
51
|
}
|
|
52
|
-
.aui-md-root td {
|
|
52
|
+
:where(.aui-md-root) td {
|
|
53
53
|
@apply border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right;
|
|
54
54
|
}
|
|
55
|
-
.aui-md-root tr {
|
|
55
|
+
:where(.aui-md-root) tr {
|
|
56
56
|
@apply m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg;
|
|
57
57
|
}
|
|
58
|
-
.aui-md-root sup {
|
|
58
|
+
:where(.aui-md-root) sup {
|
|
59
59
|
@apply [&>a]:text-xs [&>a]:no-underline;
|
|
60
60
|
}
|
|
61
|
-
.aui-md-root pre {
|
|
61
|
+
:where(.aui-md-root) pre {
|
|
62
62
|
@apply overflow-x-auto rounded-b-lg bg-black p-4 text-white;
|
|
63
63
|
}
|
|
64
|
-
.aui-md-root
|
|
64
|
+
:where(.aui-md-root) > code,
|
|
65
|
+
:where(.aui-md-root) :not(:where(pre)) code {
|
|
65
66
|
@apply bg-aui-muted rounded border font-semibold;
|
|
66
67
|
}
|
|
67
68
|
.aui-code-header-root {
|
|
@@ -1,100 +1,103 @@
|
|
|
1
1
|
/* in progress indicator */
|
|
2
|
-
.aui-md-in-progress:empty::after,
|
|
3
|
-
.aui-md-in-progress
|
|
4
|
-
.aui-md-in-progress
|
|
5
|
-
.aui-md-in-progress
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.aui-md-in-progress
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
.aui-md-in-progress:where(:empty)::after,
|
|
3
|
+
.aui-md-in-progress:where(> :not(ol):not(ul):not(pre):last-child)::after,
|
|
4
|
+
.aui-md-in-progress:where(> pre:last-child code)::after,
|
|
5
|
+
.aui-md-in-progress:where(
|
|
6
|
+
> :is(ol, ul):last-child > li:last-child:not(:has(* > li))
|
|
7
|
+
)::after,
|
|
8
|
+
.aui-md-in-progress:where(
|
|
9
|
+
> :is(ol, ul):last-child
|
|
10
|
+
> li:last-child
|
|
11
|
+
> :is(ol, ul):last-child
|
|
12
|
+
> li:last-child:not(:has(* > li))
|
|
13
|
+
)::after,
|
|
14
|
+
.aui-md-in-progress:where(
|
|
15
|
+
> :is(ol, ul):last-child
|
|
16
|
+
> li:last-child
|
|
17
|
+
> :is(ol, ul):last-child
|
|
18
|
+
> li:last-child
|
|
19
|
+
> :is(ol, ul):last-child
|
|
20
|
+
> li:last-child
|
|
21
|
+
)::after {
|
|
20
22
|
@apply animate-pulse font-sans content-['\25CF'] ltr:ml-1 rtl:mr-1;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
/* typography */
|
|
24
26
|
|
|
25
|
-
.aui-md-root h1 {
|
|
27
|
+
:where(.aui-md-root) h1 {
|
|
26
28
|
@apply mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
.aui-md-root h2 {
|
|
31
|
+
:where(.aui-md-root) h2 {
|
|
30
32
|
@apply mb-4 mt-8 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
.aui-md-root h3 {
|
|
35
|
+
:where(.aui-md-root) h3 {
|
|
34
36
|
@apply mb-4 mt-6 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
.aui-md-root h4 {
|
|
39
|
+
:where(.aui-md-root) h4 {
|
|
38
40
|
@apply mb-4 mt-6 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
.aui-md-root h5 {
|
|
43
|
+
:where(.aui-md-root) h5 {
|
|
42
44
|
@apply my-4 text-lg font-semibold first:mt-0 last:mb-0;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
.aui-md-root h6 {
|
|
47
|
+
:where(.aui-md-root) h6 {
|
|
46
48
|
@apply my-4 font-semibold first:mt-0 last:mb-0;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
.aui-md-root p {
|
|
51
|
+
:where(.aui-md-root) p {
|
|
50
52
|
@apply mb-5 mt-5 leading-7 first:mt-0 last:mb-0;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
.aui-md-root a {
|
|
55
|
+
:where(.aui-md-root) a {
|
|
54
56
|
@apply text-aui-primary font-medium underline underline-offset-4;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
.aui-md-root blockquote {
|
|
59
|
+
:where(.aui-md-root) blockquote {
|
|
58
60
|
@apply border-l-2 pl-6 italic;
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
.aui-md-root ul {
|
|
63
|
+
:where(.aui-md-root) ul {
|
|
62
64
|
@apply my-5 ml-6 list-disc [&>li]:mt-2;
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
.aui-md-root ol {
|
|
67
|
+
:where(.aui-md-root) ol {
|
|
66
68
|
@apply my-5 ml-6 list-decimal [&>li]:mt-2;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
.aui-md-root hr {
|
|
71
|
+
:where(.aui-md-root) hr {
|
|
70
72
|
@apply my-5 border-b;
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
.aui-md-root table {
|
|
75
|
+
:where(.aui-md-root) table {
|
|
74
76
|
@apply my-5 w-full border-separate border-spacing-0 overflow-y-auto;
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
.aui-md-root th {
|
|
79
|
+
:where(.aui-md-root) th {
|
|
78
80
|
@apply bg-aui-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [&[align=center]]:text-center [&[align=right]]:text-right;
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
.aui-md-root td {
|
|
83
|
+
:where(.aui-md-root) td {
|
|
82
84
|
@apply border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right;
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
.aui-md-root tr {
|
|
87
|
+
:where(.aui-md-root) tr {
|
|
86
88
|
@apply m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg;
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
.aui-md-root sup {
|
|
91
|
+
:where(.aui-md-root) sup {
|
|
90
92
|
@apply [&>a]:text-xs [&>a]:no-underline;
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
.aui-md-root pre {
|
|
95
|
+
:where(.aui-md-root) pre {
|
|
94
96
|
@apply overflow-x-auto rounded-b-lg bg-black p-4 text-white;
|
|
95
97
|
}
|
|
96
98
|
|
|
97
|
-
.aui-md-root
|
|
99
|
+
:where(.aui-md-root) > code,
|
|
100
|
+
:where(.aui-md-root) :not(:where(pre)) code {
|
|
98
101
|
@apply bg-aui-muted rounded border font-semibold;
|
|
99
102
|
}
|
|
100
103
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/react-markdown",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"react-markdown": "^9.0.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@assistant-ui/react": "^0.4.
|
|
46
|
+
"@assistant-ui/react": "^0.4.4",
|
|
47
47
|
"@types/react": "*",
|
|
48
48
|
"react": "^18",
|
|
49
49
|
"tailwindcss": "^3.4.4"
|