@mintlify/msft-sdk 0.1.3 → 0.1.5
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.
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsxs as h, jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import T, { useState as N, useEffect as j } from "react";
|
|
3
3
|
import u from "prismjs";
|
|
4
|
-
import "prismjs/components/prism-javascript";
|
|
5
|
-
import "prismjs/components/prism-typescript";
|
|
6
|
-
import "prismjs/components/prism-python";
|
|
7
|
-
import "prismjs/components/prism-bash";
|
|
8
|
-
import "prismjs/components/prism-json";
|
|
9
|
-
import "prismjs/components/prism-markdown";
|
|
10
|
-
import "prismjs/components/prism-csharp";
|
|
11
|
-
import "prismjs/components/prism-powershell";
|
|
4
|
+
import "prismjs/components/prism-javascript.js";
|
|
5
|
+
import "prismjs/components/prism-typescript.js";
|
|
6
|
+
import "prismjs/components/prism-python.js";
|
|
7
|
+
import "prismjs/components/prism-bash.js";
|
|
8
|
+
import "prismjs/components/prism-json.js";
|
|
9
|
+
import "prismjs/components/prism-markdown.js";
|
|
10
|
+
import "prismjs/components/prism-csharp.js";
|
|
11
|
+
import "prismjs/components/prism-powershell.js";
|
|
12
12
|
import { getNodeText as A } from "../../utils/get-node-text.js";
|
|
13
13
|
import { Checkmark20Regular as k, Copy20Regular as I } from "@fluentui/react-icons";
|
|
14
14
|
import { capitalize as R } from "../../utils/string.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-block.js","sources":["../../../src/components/content-components/code-block.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport Prism from \"prismjs\";\nimport \"prismjs/components/prism-javascript\";\nimport \"prismjs/components/prism-typescript\";\nimport \"prismjs/components/prism-python\";\nimport \"prismjs/components/prism-bash\";\nimport \"prismjs/components/prism-json\";\nimport \"prismjs/components/prism-markdown\";\nimport \"prismjs/components/prism-csharp\";\nimport \"prismjs/components/prism-powershell\";\nimport { getNodeText } from \"../../utils/get-node-text\";\nimport { Copy20Regular, Checkmark20Regular } from \"@fluentui/react-icons\";\nimport { capitalize } from \"../../utils/string\";\nimport styles from \"./code-block.module.css\";\n\ninterface CodeBlockProps {\n children: React.ReactNode;\n className?: string;\n language?: string;\n fileName?: string;\n}\n\nfunction useCopyToClipboard() {\n const [isCopied, setIsCopied] = useState(false);\n\n const copy = async (text: string) => {\n try {\n await navigator.clipboard.writeText(text);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n } catch (error) {\n console.error(\"Failed to copy to clipboard:\", error);\n }\n };\n\n return { isCopied, copy };\n}\n\nexport function CodeBlock({\n children,\n className,\n fileName,\n language,\n}: CodeBlockProps) {\n const [highlightedCode, setHighlightedCode] = useState<string>(\"\");\n const { isCopied, copy } = useCopyToClipboard();\n const lang = language || className?.replace(/^language-/, \"\") || \"text\";\n const codeText = getNodeText(children);\n const showContainer = !!fileName;\n\n const isSSRHighlighted = React.useMemo(() => {\n if (typeof children !== \"object\" || children == null) {\n return false;\n }\n\n const childrenArray = Array.isArray(children) ? children : [children];\n for (const child of childrenArray) {\n if (\n typeof child === \"object\" &&\n child != null &&\n \"props\" in child &&\n child.props?.children\n ) {\n const codeChildren = Array.isArray(child.props.children)\n ? child.props.children\n : [child.props.children];\n\n for (const codeChild of codeChildren) {\n if (\n typeof codeChild === \"object\" &&\n codeChild != null &&\n \"props\" in codeChild &&\n codeChild.props?.className\n ) {\n return true;\n }\n }\n }\n }\n return false;\n }, [children]);\n\n useEffect(() => {\n if (isSSRHighlighted) {\n return;\n }\n\n try {\n const grammar = Prism.languages[lang] || Prism.languages.plaintext;\n const html = Prism.highlight(codeText, grammar, lang);\n setHighlightedCode(html);\n } catch (error) {\n console.error(\"Failed to highlight code:\", error);\n setHighlightedCode(codeText);\n }\n }, [codeText, lang, isSSRHighlighted]);\n\n const handleCopy = () => {\n copy(codeText);\n };\n\n return (\n <div className={showContainer ? styles.container : undefined}>\n {fileName && <span className={styles.fileName}>{fileName}</span>}\n <div className={`${styles.codeWrapper} not-prose`}>\n <div className={styles.header}>\n <span className={styles.language}
|
|
1
|
+
{"version":3,"file":"code-block.js","sources":["../../../src/components/content-components/code-block.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport Prism from \"prismjs\";\nimport \"prismjs/components/prism-javascript.js\";\nimport \"prismjs/components/prism-typescript.js\";\nimport \"prismjs/components/prism-python.js\";\nimport \"prismjs/components/prism-bash.js\";\nimport \"prismjs/components/prism-json.js\";\nimport \"prismjs/components/prism-markdown.js\";\nimport \"prismjs/components/prism-csharp.js\";\nimport \"prismjs/components/prism-powershell.js\";\nimport { getNodeText } from \"../../utils/get-node-text\";\nimport { Copy20Regular, Checkmark20Regular } from \"@fluentui/react-icons\";\nimport { capitalize } from \"../../utils/string\";\nimport styles from \"./code-block.module.css\";\n\ninterface CodeBlockProps {\n children: React.ReactNode;\n className?: string;\n language?: string;\n fileName?: string;\n}\n\nfunction useCopyToClipboard() {\n const [isCopied, setIsCopied] = useState(false);\n\n const copy = async (text: string) => {\n try {\n await navigator.clipboard.writeText(text);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n } catch (error) {\n console.error(\"Failed to copy to clipboard:\", error);\n }\n };\n\n return { isCopied, copy };\n}\n\nexport function CodeBlock({\n children,\n className,\n fileName,\n language,\n}: CodeBlockProps) {\n const [highlightedCode, setHighlightedCode] = useState<string>(\"\");\n const { isCopied, copy } = useCopyToClipboard();\n const lang = language || className?.replace(/^language-/, \"\") || \"text\";\n const codeText = getNodeText(children);\n const showContainer = !!fileName;\n\n const isSSRHighlighted = React.useMemo(() => {\n if (typeof children !== \"object\" || children == null) {\n return false;\n }\n\n const childrenArray = Array.isArray(children) ? children : [children];\n for (const child of childrenArray) {\n if (\n typeof child === \"object\" &&\n child != null &&\n \"props\" in child &&\n child.props?.children\n ) {\n const codeChildren = Array.isArray(child.props.children)\n ? child.props.children\n : [child.props.children];\n\n for (const codeChild of codeChildren) {\n if (\n typeof codeChild === \"object\" &&\n codeChild != null &&\n \"props\" in codeChild &&\n codeChild.props?.className\n ) {\n return true;\n }\n }\n }\n }\n return false;\n }, [children]);\n\n useEffect(() => {\n if (isSSRHighlighted) {\n return;\n }\n\n try {\n const grammar = Prism.languages[lang] || Prism.languages.plaintext;\n const html = Prism.highlight(codeText, grammar, lang);\n setHighlightedCode(html);\n } catch (error) {\n console.error(\"Failed to highlight code:\", error);\n setHighlightedCode(codeText);\n }\n }, [codeText, lang, isSSRHighlighted]);\n\n const handleCopy = () => {\n copy(codeText);\n };\n\n return (\n <div className={showContainer ? styles.container : undefined}>\n {fileName && <span className={styles.fileName}>{fileName}</span>}\n <div className={`${styles.codeWrapper} not-prose`}>\n <div className={styles.header}>\n <span className={styles.language}>{capitalize(lang)}</span>\n <button\n onClick={handleCopy}\n className={styles.copyButton}\n aria-label={isCopied ? \"Copied\" : \"Copy code\"}\n >\n {isCopied ? (\n <Checkmark20Regular className={styles.copiedIcon} />\n ) : (\n <Copy20Regular className={styles.copyIcon} />\n )}\n </button>\n </div>\n <div className={`${styles.scrollContainer} code-scrollbar`}>\n <pre className={styles.pre}>\n {isSSRHighlighted ? (\n <code className={`language-${lang} ${styles.code}`}>\n {children}\n </code>\n ) : highlightedCode ? (\n <code\n className={`language-${lang} ${styles.code}`}\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n />\n ) : (\n <code className={`language-${lang} ${styles.code}`}>\n {codeText}\n </code>\n )}\n </pre>\n </div>\n </div>\n </div>\n );\n}\n"],"names":["useCopyToClipboard","isCopied","setIsCopied","useState","text","error","CodeBlock","children","className","fileName","language","highlightedCode","setHighlightedCode","copy","lang","codeText","getNodeText","showContainer","isSSRHighlighted","React","childrenArray","child","_a","codeChildren","codeChild","_b","useEffect","grammar","Prism","html","handleCopy","styles","jsx","jsxs","capitalize","Checkmark20Regular","Copy20Regular"],"mappings":";;;;;;;;;;;;;;;AAsBA,SAASA,IAAqB;AAC5B,QAA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ACEI,IACF,gBAAAqB;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW,YAAYlB,CAAI,IAAIiB,EAAO,IAAI;AAAA,UAC1C,yBAAyB,EAAE,QAAQpB,EAAA;AAAA,QAAgB;AAAA,MAAA,IAGrD,gBAAAqB,EAAC,QAAA,EAAK,WAAW,YAAYlB,CAAI,IAAIiB,EAAO,IAAI,IAC7C,UAAAhB,EAAA,CACH,EAAA,CAEJ,EAAA,CACF;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/msft-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Lightweight SDK for Microsoft documentation with MDX rendering",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"README.md"
|
|
29
29
|
],
|
|
30
30
|
"publishConfig": {
|
|
31
|
-
"access": "
|
|
31
|
+
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "vite build",
|