docusaurus-theme-openapi-docs 0.0.0-740 → 0.0.0-751
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/lib/markdown/utils.d.ts +2 -1
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.d.ts +4 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.js +25 -19
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.d.ts +4 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.js +27 -16
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.d.ts +4 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +116 -97
- package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js +115 -54
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.d.ts +6 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.js +41 -30
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.d.ts +14 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.js +201 -121
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.js +36 -24
- package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.js +35 -28
- package/lib/theme/ApiExplorer/ApiCodeBlock/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/index.js +72 -14
- package/lib/theme/ApiExplorer/Body/slice.d.ts +8 -8
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +2 -2
- package/lib/theme/ApiExplorer/CodeSnippets/languages.json +1290 -0
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +4 -2
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +15 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.js +122 -76
- package/lib/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +3 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +4 -4
- package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +2 -1
- package/lib/theme/ApiExplorer/Request/_Request.scss +4 -6
- package/lib/theme/ApiExplorer/Response/_Response.scss +4 -2
- package/lib/theme/ApiExplorer/Response/index.js +23 -20
- package/lib/theme/ApiExplorer/index.js +0 -4
- package/lib/theme/ApiExplorer/persistanceMiddleware.js +6 -6
- package/lib/theme/ApiItem/Layout/index.js +3 -0
- package/lib/theme/ApiItem/index.js +6 -5
- package/lib/theme/ApiLogo/index.d.ts +2 -2
- package/lib/theme/ApiTabs/_ApiTabs.scss +3 -1
- package/lib/theme/ApiTabs/index.d.ts +7 -0
- package/lib/theme/ApiTabs/index.js +152 -98
- package/lib/theme/DiscriminatorTabs/index.d.ts +3 -0
- package/lib/theme/DiscriminatorTabs/index.js +146 -94
- package/lib/theme/MimeTabs/index.d.ts +6 -0
- package/lib/theme/MimeTabs/index.js +163 -114
- package/lib/theme/OperationTabs/_OperationTabs.scss +4 -1
- package/lib/theme/OperationTabs/index.d.ts +3 -0
- package/lib/theme/OperationTabs/index.js +148 -103
- package/lib/theme/ParamsItem/index.d.ts +23 -0
- package/lib/theme/ParamsItem/index.js +168 -123
- package/lib/theme/ResponseSamples/index.d.ts +8 -0
- package/lib/theme/ResponseSamples/index.js +18 -13
- package/lib/theme/SchemaItem/index.d.ts +12 -0
- package/lib/theme/SchemaItem/index.js +123 -88
- package/lib/theme/SchemaTabs/_SchemaTabs.scss +0 -4
- package/lib/theme/SchemaTabs/index.d.ts +3 -0
- package/lib/theme/SchemaTabs/index.js +148 -93
- package/lib/theme/styles.scss +4 -0
- package/package.json +8 -7
- package/src/markdown/utils.ts +4 -2
- package/src/theme/ApiExplorer/ApiCodeBlock/Container/{index.js → index.tsx} +6 -3
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/{Element.js → Element.tsx} +5 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/{String.js → String.tsx} +5 -5
- package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/{index.js → index.tsx} +8 -3
- package/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/{index.js → index.tsx} +9 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/{index.js → index.tsx} +13 -3
- package/src/theme/ApiExplorer/ApiCodeBlock/Line/{index.js → index.tsx} +2 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/{index.js → index.tsx} +11 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/{index.js → index.tsx} +10 -5
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +3 -5
- package/src/theme/ApiExplorer/CodeSnippets/languages.json +1290 -0
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +4 -2
- package/src/theme/ApiExplorer/CodeTabs/{index.js → index.tsx} +56 -26
- package/src/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +3 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +4 -4
- package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +2 -1
- package/src/theme/ApiExplorer/Request/_Request.scss +4 -6
- package/src/theme/ApiExplorer/Response/_Response.scss +4 -2
- package/src/theme/ApiExplorer/Response/index.tsx +6 -3
- package/src/theme/ApiExplorer/index.tsx +0 -3
- package/src/theme/ApiExplorer/persistanceMiddleware.ts +6 -6
- package/src/theme/ApiItem/Layout/index.tsx +3 -0
- package/src/theme/ApiItem/index.tsx +3 -4
- package/src/theme/ApiLogo/index.tsx +1 -1
- package/src/theme/ApiTabs/_ApiTabs.scss +3 -1
- package/src/theme/ApiTabs/{index.js → index.tsx} +60 -26
- package/src/theme/DiscriminatorTabs/{index.js → index.tsx} +57 -24
- package/src/theme/MimeTabs/{index.js → index.tsx} +57 -25
- package/src/theme/OperationTabs/_OperationTabs.scss +4 -1
- package/src/theme/OperationTabs/{index.js → index.tsx} +54 -25
- package/src/theme/ParamsItem/{index.js → index.tsx} +31 -14
- package/src/theme/ResponseSamples/{index.js → index.tsx} +10 -1
- package/src/theme/SchemaItem/{index.js → index.tsx} +18 -9
- package/src/theme/SchemaTabs/_SchemaTabs.scss +0 -4
- package/src/theme/SchemaTabs/{index.js → index.tsx} +64 -28
- package/src/theme/styles.scss +4 -0
- package/src/theme-classic.d.ts +69 -2
- package/src/theme-openapi.d.ts +3 -0
- package/tsconfig.json +4 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-theme-openapi-docs",
|
|
3
3
|
"description": "OpenAPI theme for Docusaurus.",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-751",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -28,27 +28,28 @@
|
|
|
28
28
|
"watch": "concurrently --names \"lib,lib-next,tsc\" --kill-others \"yarn babel:lib --watch\" \"yarn babel:lib-next --watch\" \"yarn tsc --watch\""
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@docusaurus/types": "
|
|
31
|
+
"@docusaurus/types": "^3.0.1",
|
|
32
32
|
"@types/crypto-js": "^4.1.0",
|
|
33
33
|
"@types/file-saver": "^2.0.5",
|
|
34
34
|
"@types/lodash": "^4.14.176",
|
|
35
|
-
"concurrently": "^5.2.0"
|
|
35
|
+
"concurrently": "^5.2.0",
|
|
36
|
+
"eslint-plugin-prettier": "^5.0.1"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"@docusaurus/theme-common": "
|
|
39
|
+
"@docusaurus/theme-common": "^3.0.1",
|
|
39
40
|
"@hookform/error-message": "^2.0.1",
|
|
40
41
|
"@reduxjs/toolkit": "^1.7.1",
|
|
41
42
|
"clsx": "^1.1.1",
|
|
42
43
|
"copy-text-to-clipboard": "^3.1.0",
|
|
43
44
|
"crypto-js": "^4.1.1",
|
|
44
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
45
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-751",
|
|
45
46
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
46
47
|
"file-saver": "^2.0.5",
|
|
47
48
|
"lodash": "^4.17.20",
|
|
48
49
|
"node-polyfill-webpack-plugin": "^2.0.1",
|
|
49
50
|
"postman-code-generators": "^1.10.1",
|
|
50
51
|
"postman-collection": "^4.4.0",
|
|
51
|
-
"prism-react-renderer": "^
|
|
52
|
+
"prism-react-renderer": "^2.3.0",
|
|
52
53
|
"react-hook-form": "^7.43.8",
|
|
53
54
|
"react-live": "^4.0.0",
|
|
54
55
|
"react-magic-dropzone": "^1.0.1",
|
|
@@ -68,5 +69,5 @@
|
|
|
68
69
|
"engines": {
|
|
69
70
|
"node": ">=14"
|
|
70
71
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "87427f0ab49405d1aef03436e5c5babc9641dd45"
|
|
72
73
|
}
|
package/src/markdown/utils.ts
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import { ReactNode } from "react";
|
|
9
|
+
|
|
10
|
+
export type Children = ReactNode | string | undefined | (string | undefined)[];
|
|
9
11
|
|
|
10
12
|
export type Props = Record<string, any> & { children?: Children };
|
|
11
13
|
|
|
@@ -35,7 +37,7 @@ export function render(children: Children): string {
|
|
|
35
37
|
if (Array.isArray(children)) {
|
|
36
38
|
return children.filter((c) => c !== undefined).join("");
|
|
37
39
|
}
|
|
38
|
-
return children ?? "";
|
|
40
|
+
return (children as string) ?? "";
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export function toString(value: any): string | undefined {
|
|
@@ -5,19 +5,22 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import React from "react";
|
|
8
|
+
import React, { ComponentProps } from "react";
|
|
9
9
|
|
|
10
10
|
import { ThemeClassNames, usePrismTheme } from "@docusaurus/theme-common";
|
|
11
11
|
import { getPrismCssVariables } from "@docusaurus/theme-common/internal";
|
|
12
12
|
import clsx from "clsx";
|
|
13
13
|
|
|
14
|
-
export default function CodeBlockContainer
|
|
14
|
+
export default function CodeBlockContainer<T extends "div" | "pre">({
|
|
15
|
+
as: As,
|
|
16
|
+
...props
|
|
17
|
+
}: { as: T } & ComponentProps<T>): React.JSX.Element {
|
|
15
18
|
const prismTheme = usePrismTheme();
|
|
16
19
|
const prismCssVariables = getPrismCssVariables(prismTheme);
|
|
17
20
|
return (
|
|
18
21
|
<As
|
|
19
22
|
// Polymorphic components are hard to type, without `oneOf` generics
|
|
20
|
-
{...props}
|
|
23
|
+
{...(props as any)}
|
|
21
24
|
style={prismCssVariables}
|
|
22
25
|
className={clsx(
|
|
23
26
|
"openapi-explorer__code-block-container",
|
|
@@ -8,12 +8,16 @@
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
10
|
import Container from "@theme/ApiExplorer/ApiCodeBlock/Container";
|
|
11
|
+
import type { Props } from "@theme/CodeBlock/Content/Element";
|
|
11
12
|
import clsx from "clsx";
|
|
12
13
|
|
|
13
14
|
// <pre> tags in markdown map to CodeBlocks. They may contain JSX children. When
|
|
14
15
|
// the children is not a simple string, we just return a styled block without
|
|
15
16
|
// actually highlighting.
|
|
16
|
-
export default function CodeBlockJSX({
|
|
17
|
+
export default function CodeBlockJSX({
|
|
18
|
+
children,
|
|
19
|
+
className,
|
|
20
|
+
}: Props): React.JSX.Element {
|
|
17
21
|
return (
|
|
18
22
|
<Container
|
|
19
23
|
as="pre"
|
|
@@ -20,8 +20,9 @@ import CopyButton from "@theme/ApiExplorer/ApiCodeBlock/CopyButton";
|
|
|
20
20
|
import ExpandButton from "@theme/ApiExplorer/ApiCodeBlock/ExpandButton";
|
|
21
21
|
import Line from "@theme/ApiExplorer/ApiCodeBlock/Line";
|
|
22
22
|
import WordWrapButton from "@theme/ApiExplorer/ApiCodeBlock/WordWrapButton";
|
|
23
|
+
import type { Props } from "@theme/CodeBlock/Content/String";
|
|
23
24
|
import clsx from "clsx";
|
|
24
|
-
import Highlight,
|
|
25
|
+
import { Highlight, Language } from "prism-react-renderer";
|
|
25
26
|
|
|
26
27
|
export default function CodeBlockString({
|
|
27
28
|
children,
|
|
@@ -30,7 +31,7 @@ export default function CodeBlockString({
|
|
|
30
31
|
title: titleProp,
|
|
31
32
|
showLineNumbers: showLineNumbersProp,
|
|
32
33
|
language: languageProp,
|
|
33
|
-
}) {
|
|
34
|
+
}: Props): React.JSX.Element {
|
|
34
35
|
const {
|
|
35
36
|
prism: { defaultLanguage, magicComments },
|
|
36
37
|
} = useThemeConfig();
|
|
@@ -65,7 +66,7 @@ export default function CodeBlockString({
|
|
|
65
66
|
)}
|
|
66
67
|
<div className="openapi-explorer__code-block-content">
|
|
67
68
|
<Highlight
|
|
68
|
-
{...defaultProps}
|
|
69
|
+
// {...defaultProps}
|
|
69
70
|
theme={prismTheme}
|
|
70
71
|
code={code}
|
|
71
72
|
language={language ?? "text"}
|
|
@@ -120,12 +121,11 @@ export default function CodeBlockString({
|
|
|
120
121
|
"openapi-explorer__expand-btn"
|
|
121
122
|
)}
|
|
122
123
|
code={code}
|
|
123
|
-
language={language}
|
|
124
|
+
language={(language ?? "text") as Language}
|
|
124
125
|
showLineNumbers={showLineNumbers}
|
|
125
126
|
blockClassName={blockClassName}
|
|
126
127
|
title={title}
|
|
127
128
|
lineClassNames={lineClassNames}
|
|
128
|
-
wordWrap={wordWrap}
|
|
129
129
|
/>
|
|
130
130
|
</div>
|
|
131
131
|
</div>
|
|
@@ -7,14 +7,17 @@
|
|
|
7
7
|
|
|
8
8
|
import React, { useCallback, useState, useRef, useEffect } from "react";
|
|
9
9
|
|
|
10
|
+
import { CopyButtonProps } from "@docusaurus/theme-common/internal";
|
|
10
11
|
import { translate } from "@docusaurus/Translate";
|
|
11
12
|
import clsx from "clsx";
|
|
12
|
-
// @ts-expect-error: TODO, we need to make theme-classic have type: module
|
|
13
13
|
import copy from "copy-text-to-clipboard";
|
|
14
14
|
|
|
15
|
-
export default function CopyButton({
|
|
15
|
+
export default function CopyButton({
|
|
16
|
+
code,
|
|
17
|
+
className,
|
|
18
|
+
}: CopyButtonProps): React.JSX.Element {
|
|
16
19
|
const [isCopied, setIsCopied] = useState(false);
|
|
17
|
-
const copyTimeout = useRef(undefined);
|
|
20
|
+
const copyTimeout = useRef<number | undefined>(undefined);
|
|
18
21
|
const handleCopyCode = useCallback(() => {
|
|
19
22
|
copy(code);
|
|
20
23
|
setIsCopied(true);
|
|
@@ -22,7 +25,9 @@ export default function CopyButton({ code, className }) {
|
|
|
22
25
|
setIsCopied(false);
|
|
23
26
|
}, 1000);
|
|
24
27
|
}, [code]);
|
|
28
|
+
|
|
25
29
|
useEffect(() => () => window.clearTimeout(copyTimeout.current), []);
|
|
30
|
+
|
|
26
31
|
return (
|
|
27
32
|
<button
|
|
28
33
|
type="button"
|
|
@@ -10,7 +10,15 @@ import React from "react";
|
|
|
10
10
|
import { translate } from "@docusaurus/Translate";
|
|
11
11
|
import clsx from "clsx";
|
|
12
12
|
|
|
13
|
-
export
|
|
13
|
+
export interface Props {
|
|
14
|
+
readonly className: string;
|
|
15
|
+
readonly handler: () => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default function ExitButton({
|
|
19
|
+
className,
|
|
20
|
+
handler,
|
|
21
|
+
}: Props): React.JSX.Element {
|
|
14
22
|
return (
|
|
15
23
|
<button
|
|
16
24
|
type="button"
|
|
@@ -14,9 +14,19 @@ import CopyButton from "@theme/ApiExplorer/ApiCodeBlock/CopyButton";
|
|
|
14
14
|
import ExitButton from "@theme/ApiExplorer/ApiCodeBlock/ExitButton";
|
|
15
15
|
import Line from "@theme/ApiExplorer/ApiCodeBlock/Line";
|
|
16
16
|
import clsx from "clsx";
|
|
17
|
-
import Highlight,
|
|
17
|
+
import { Highlight, Language } from "prism-react-renderer";
|
|
18
18
|
import Modal from "react-modal";
|
|
19
19
|
|
|
20
|
+
export interface Props {
|
|
21
|
+
readonly code: string;
|
|
22
|
+
readonly className: string;
|
|
23
|
+
readonly language: Language;
|
|
24
|
+
readonly showLineNumbers: boolean;
|
|
25
|
+
readonly blockClassName: string;
|
|
26
|
+
readonly title: string | undefined;
|
|
27
|
+
readonly lineClassNames: { [lineIndex: number]: string[] };
|
|
28
|
+
}
|
|
29
|
+
|
|
20
30
|
export default function ExpandButton({
|
|
21
31
|
code,
|
|
22
32
|
className,
|
|
@@ -25,7 +35,7 @@ export default function ExpandButton({
|
|
|
25
35
|
blockClassName,
|
|
26
36
|
title,
|
|
27
37
|
lineClassNames,
|
|
28
|
-
}) {
|
|
38
|
+
}: Props): React.JSX.Element {
|
|
29
39
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
30
40
|
const prismTheme = usePrismTheme();
|
|
31
41
|
|
|
@@ -102,7 +112,7 @@ export default function ExpandButton({
|
|
|
102
112
|
)}
|
|
103
113
|
<div className="openapi-explorer__code-block-content">
|
|
104
114
|
<Highlight
|
|
105
|
-
{...defaultProps}
|
|
115
|
+
// {...defaultProps}
|
|
106
116
|
theme={prismTheme}
|
|
107
117
|
code={code}
|
|
108
118
|
language={language ?? "text"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import { LineProps } from "@docusaurus/theme-common/internal";
|
|
10
11
|
import clsx from "clsx";
|
|
11
12
|
|
|
12
13
|
export default function CodeBlockLine({
|
|
@@ -15,7 +16,7 @@ export default function CodeBlockLine({
|
|
|
15
16
|
showLineNumbers,
|
|
16
17
|
getLineProps,
|
|
17
18
|
getTokenProps,
|
|
18
|
-
}) {
|
|
19
|
+
}: LineProps): React.JSX.Element {
|
|
19
20
|
if (line.length === 1 && line[0].content === "\n") {
|
|
20
21
|
line[0].content = "";
|
|
21
22
|
}
|
|
@@ -10,7 +10,17 @@ import React from "react";
|
|
|
10
10
|
import { translate } from "@docusaurus/Translate";
|
|
11
11
|
import clsx from "clsx";
|
|
12
12
|
|
|
13
|
-
export
|
|
13
|
+
export interface Props {
|
|
14
|
+
readonly className?: string;
|
|
15
|
+
readonly onClick: React.MouseEventHandler;
|
|
16
|
+
readonly isEnabled: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default function WordWrapButton({
|
|
20
|
+
className,
|
|
21
|
+
onClick,
|
|
22
|
+
isEnabled,
|
|
23
|
+
}: Props): React.JSX.Element | null {
|
|
14
24
|
const title = translate({
|
|
15
25
|
id: "theme.CodeBlock.wordWrapToggle",
|
|
16
26
|
message: "Toggle word wrap",
|
|
@@ -5,25 +5,30 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import React, { isValidElement } from "react";
|
|
8
|
+
import React, { isValidElement, ReactNode } from "react";
|
|
9
9
|
|
|
10
|
+
import { CodeBlockProps } from "@docusaurus/theme-common/internal";
|
|
10
11
|
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
11
12
|
import ElementContent from "@theme/ApiExplorer/ApiCodeBlock/Content/Element";
|
|
12
13
|
import StringContent from "@theme/ApiExplorer/ApiCodeBlock/Content/String";
|
|
14
|
+
|
|
13
15
|
/**
|
|
14
16
|
* Best attempt to make the children a plain string so it is copyable. If there
|
|
15
17
|
* are react elements, we will not be able to copy the content, and it will
|
|
16
18
|
* return `children` as-is; otherwise, it concatenates the string children
|
|
17
19
|
* together.
|
|
18
20
|
*/
|
|
19
|
-
function maybeStringifyChildren(children) {
|
|
21
|
+
function maybeStringifyChildren(children: ReactNode): ReactNode {
|
|
20
22
|
if (React.Children.toArray(children).some((el) => isValidElement(el))) {
|
|
21
23
|
return children;
|
|
22
24
|
}
|
|
23
25
|
// The children is now guaranteed to be one/more plain strings
|
|
24
|
-
return Array.isArray(children) ? children.join("") : children;
|
|
26
|
+
return Array.isArray(children) ? children.join("") : (children as string);
|
|
25
27
|
}
|
|
26
|
-
export default function ApiCodeBlock({
|
|
28
|
+
export default function ApiCodeBlock({
|
|
29
|
+
children: rawChildren,
|
|
30
|
+
...props
|
|
31
|
+
}: CodeBlockProps) {
|
|
27
32
|
// The Prism theme on SSR is always the default theme but the site theme can
|
|
28
33
|
// be in a different mode. React hydration doesn't update DOM styles that come
|
|
29
34
|
// from SSR. Hence force a re-render after mounting to apply the current
|
|
@@ -34,7 +39,7 @@ export default function ApiCodeBlock({ children: rawChildren, ...props }) {
|
|
|
34
39
|
typeof children === "string" ? StringContent : ElementContent;
|
|
35
40
|
return (
|
|
36
41
|
<CodeBlockComp key={String(isBrowser)} {...props}>
|
|
37
|
-
{children}
|
|
42
|
+
{children as string}
|
|
38
43
|
</CodeBlockComp>
|
|
39
44
|
);
|
|
40
45
|
}
|
|
@@ -172,9 +172,9 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
172
172
|
|
|
173
173
|
// User-defined languages array
|
|
174
174
|
// Can override languageSet, change order of langs, override options and variants
|
|
175
|
-
const userDefinedLanguageSet =
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
const userDefinedLanguageSet =
|
|
176
|
+
(siteConfig?.themeConfig?.languageTabs as Language[] | undefined) ??
|
|
177
|
+
languageSet;
|
|
178
178
|
|
|
179
179
|
// Filter languageSet by user-defined langs
|
|
180
180
|
const filteredLanguageSet = languageSet.filter((ls) => {
|
|
@@ -189,8 +189,6 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
189
189
|
codeSamples
|
|
190
190
|
);
|
|
191
191
|
|
|
192
|
-
console.log("merged", mergedLangs);
|
|
193
|
-
|
|
194
192
|
// Read defaultLang from localStorage
|
|
195
193
|
const defaultLang: Language[] = mergedLangs.filter(
|
|
196
194
|
(lang) =>
|