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/lib/markdown/utils.d.ts
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/* ============================================================================
|
|
2
3
|
* Copyright (c) Palo Alto Networks
|
|
3
4
|
*
|
|
4
5
|
* This source code is licensed under the MIT license found in the
|
|
5
6
|
* LICENSE file in the root directory of this source tree.
|
|
6
7
|
* ========================================================================== */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
var __importDefault =
|
|
9
|
+
(this && this.__importDefault) ||
|
|
10
|
+
function (mod) {
|
|
11
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const react_1 = __importDefault(require("react"));
|
|
15
|
+
const theme_common_1 = require("@docusaurus/theme-common");
|
|
16
|
+
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
17
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
18
|
+
function CodeBlockContainer({ as: As, ...props }) {
|
|
19
|
+
const prismTheme = (0, theme_common_1.usePrismTheme)();
|
|
20
|
+
const prismCssVariables = (0, internal_1.getPrismCssVariables)(prismTheme);
|
|
21
|
+
return react_1.default.createElement(
|
|
22
|
+
As,
|
|
23
|
+
// Polymorphic components are hard to type, without `oneOf` generics
|
|
24
|
+
{
|
|
25
|
+
...props,
|
|
26
|
+
style: prismCssVariables,
|
|
27
|
+
className: (0, clsx_1.default)(
|
|
23
28
|
"openapi-explorer__code-block-container",
|
|
24
29
|
props.className,
|
|
25
|
-
ThemeClassNames.common.codeBlock
|
|
26
|
-
)
|
|
27
|
-
|
|
30
|
+
theme_common_1.ThemeClassNames.common.codeBlock
|
|
31
|
+
),
|
|
32
|
+
}
|
|
28
33
|
);
|
|
29
34
|
}
|
|
35
|
+
exports.default = CodeBlockContainer;
|
|
@@ -1,30 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/* ============================================================================
|
|
2
3
|
* Copyright (c) Palo Alto Networks
|
|
3
4
|
*
|
|
4
5
|
* This source code is licensed under the MIT license found in the
|
|
5
6
|
* LICENSE file in the root directory of this source tree.
|
|
6
7
|
* ========================================================================== */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
var __importDefault =
|
|
9
|
+
(this && this.__importDefault) ||
|
|
10
|
+
function (mod) {
|
|
11
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const react_1 = __importDefault(require("react"));
|
|
15
|
+
const Container_1 = __importDefault(
|
|
16
|
+
require("@theme/ApiExplorer/ApiCodeBlock/Container")
|
|
17
|
+
);
|
|
18
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
13
19
|
// <pre> tags in markdown map to CodeBlocks. They may contain JSX children. When
|
|
14
20
|
// the children is not a simple string, we just return a styled block without
|
|
15
21
|
// actually highlighting.
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
function CodeBlockJSX({ children, className }) {
|
|
23
|
+
return react_1.default.createElement(
|
|
24
|
+
Container_1.default,
|
|
25
|
+
{
|
|
26
|
+
as: "pre",
|
|
27
|
+
tabIndex: 0,
|
|
28
|
+
className: (0, clsx_1.default)(
|
|
22
29
|
"openapi-explorer__code-block-standalone",
|
|
23
30
|
"thin-scrollbar",
|
|
24
31
|
className
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
),
|
|
33
|
+
},
|
|
34
|
+
react_1.default.createElement(
|
|
35
|
+
"code",
|
|
36
|
+
{ className: "openapi-explorer__code-block-lines" },
|
|
37
|
+
children
|
|
38
|
+
)
|
|
29
39
|
);
|
|
30
40
|
}
|
|
41
|
+
exports.default = CodeBlockJSX;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="@docusaurus/theme-classic" />
|
|
2
|
+
import React from "react";
|
|
3
|
+
import type { Props } from "@theme/CodeBlock/Content/String";
|
|
4
|
+
export default function CodeBlockString({ children, className: blockClassName, metastring, title: titleProp, showLineNumbers: showLineNumbersProp, language: languageProp, }: Props): React.JSX.Element;
|
|
@@ -1,29 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/* ============================================================================
|
|
2
3
|
* Copyright (c) Palo Alto Networks
|
|
3
4
|
*
|
|
4
5
|
* This source code is licensed under the MIT license found in the
|
|
5
6
|
* LICENSE file in the root directory of this source tree.
|
|
6
7
|
* ========================================================================== */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
var __importDefault =
|
|
9
|
+
(this && this.__importDefault) ||
|
|
10
|
+
function (mod) {
|
|
11
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const react_1 = __importDefault(require("react"));
|
|
15
|
+
const theme_common_1 = require("@docusaurus/theme-common");
|
|
16
|
+
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
17
|
+
const Container_1 = __importDefault(
|
|
18
|
+
require("@theme/ApiExplorer/ApiCodeBlock/Container")
|
|
19
|
+
);
|
|
20
|
+
const CopyButton_1 = __importDefault(
|
|
21
|
+
require("@theme/ApiExplorer/ApiCodeBlock/CopyButton")
|
|
22
|
+
);
|
|
23
|
+
const ExpandButton_1 = __importDefault(
|
|
24
|
+
require("@theme/ApiExplorer/ApiCodeBlock/ExpandButton")
|
|
25
|
+
);
|
|
26
|
+
const Line_1 = __importDefault(require("@theme/ApiExplorer/ApiCodeBlock/Line"));
|
|
27
|
+
const WordWrapButton_1 = __importDefault(
|
|
28
|
+
require("@theme/ApiExplorer/ApiCodeBlock/WordWrapButton")
|
|
29
|
+
);
|
|
30
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
31
|
+
const prism_react_renderer_1 = require("prism-react-renderer");
|
|
32
|
+
function CodeBlockString({
|
|
27
33
|
children,
|
|
28
34
|
className: blockClassName = "",
|
|
29
35
|
metastring,
|
|
@@ -33,102 +39,115 @@ export default function CodeBlockString({
|
|
|
33
39
|
}) {
|
|
34
40
|
const {
|
|
35
41
|
prism: { defaultLanguage, magicComments },
|
|
36
|
-
} = useThemeConfig();
|
|
42
|
+
} = (0, theme_common_1.useThemeConfig)();
|
|
37
43
|
const language =
|
|
38
|
-
languageProp ??
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
languageProp ??
|
|
45
|
+
(0, internal_1.parseLanguage)(blockClassName) ??
|
|
46
|
+
defaultLanguage;
|
|
47
|
+
const prismTheme = (0, theme_common_1.usePrismTheme)();
|
|
48
|
+
const wordWrap = (0, internal_1.useCodeWordWrap)();
|
|
41
49
|
// We still parse the metastring in case we want to support more syntax in the
|
|
42
50
|
// future. Note that MDX doesn't strip quotes when parsing metastring:
|
|
43
51
|
// "title=\"xyz\"" => title: "\"xyz\""
|
|
44
|
-
const title = parseCodeBlockTitle(metastring) || titleProp;
|
|
45
|
-
const { lineClassNames, code } = parseLines(children, {
|
|
52
|
+
const title = (0, internal_1.parseCodeBlockTitle)(metastring) || titleProp;
|
|
53
|
+
const { lineClassNames, code } = (0, internal_1.parseLines)(children, {
|
|
46
54
|
metastring,
|
|
47
55
|
language,
|
|
48
56
|
magicComments,
|
|
49
57
|
});
|
|
50
58
|
const showLineNumbers =
|
|
51
|
-
showLineNumbersProp ?? containsLineNumbers(metastring);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
as
|
|
56
|
-
className
|
|
59
|
+
showLineNumbersProp ?? (0, internal_1.containsLineNumbers)(metastring);
|
|
60
|
+
return react_1.default.createElement(
|
|
61
|
+
Container_1.default,
|
|
62
|
+
{
|
|
63
|
+
as: "div",
|
|
64
|
+
className: (0, clsx_1.default)(
|
|
57
65
|
blockClassName,
|
|
58
66
|
language &&
|
|
59
67
|
!blockClassName.includes(`language-${language}`) &&
|
|
60
68
|
`language-${language}`
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
),
|
|
70
|
+
},
|
|
71
|
+
title &&
|
|
72
|
+
react_1.default.createElement(
|
|
73
|
+
"div",
|
|
74
|
+
{ className: "openapi-explorer__code-block-title" },
|
|
75
|
+
title
|
|
76
|
+
),
|
|
77
|
+
react_1.default.createElement(
|
|
78
|
+
"div",
|
|
79
|
+
{ className: "openapi-explorer__code-block-content" },
|
|
80
|
+
react_1.default.createElement(
|
|
81
|
+
prism_react_renderer_1.Highlight,
|
|
82
|
+
// {...defaultProps}
|
|
83
|
+
{
|
|
84
|
+
// {...defaultProps}
|
|
85
|
+
theme: prismTheme,
|
|
86
|
+
code: code,
|
|
87
|
+
language: language ?? "text",
|
|
88
|
+
},
|
|
89
|
+
({ className, tokens, getLineProps, getTokenProps }) =>
|
|
90
|
+
react_1.default.createElement(
|
|
91
|
+
"pre",
|
|
92
|
+
{
|
|
75
93
|
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
|
76
|
-
tabIndex
|
|
77
|
-
ref
|
|
78
|
-
className
|
|
94
|
+
tabIndex: 0,
|
|
95
|
+
ref: wordWrap.codeBlockRef,
|
|
96
|
+
className: (0, clsx_1.default)(
|
|
79
97
|
className,
|
|
80
98
|
"openapi-explorer__code-block",
|
|
81
99
|
"thin-scrollbar"
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
100
|
+
),
|
|
101
|
+
},
|
|
102
|
+
react_1.default.createElement(
|
|
103
|
+
"code",
|
|
104
|
+
{
|
|
105
|
+
className: (0, clsx_1.default)(
|
|
86
106
|
"openapi-explorer__code-block-lines",
|
|
87
107
|
showLineNumbers &&
|
|
88
108
|
"openapi-explorer__code-block-lines-numbering"
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
</div>
|
|
132
|
-
</Container>
|
|
109
|
+
),
|
|
110
|
+
},
|
|
111
|
+
tokens.map((line, i) =>
|
|
112
|
+
react_1.default.createElement(Line_1.default, {
|
|
113
|
+
key: i,
|
|
114
|
+
line: line,
|
|
115
|
+
getLineProps: getLineProps,
|
|
116
|
+
getTokenProps: getTokenProps,
|
|
117
|
+
classNames: lineClassNames[i],
|
|
118
|
+
showLineNumbers: showLineNumbers,
|
|
119
|
+
})
|
|
120
|
+
)
|
|
121
|
+
)
|
|
122
|
+
)
|
|
123
|
+
),
|
|
124
|
+
react_1.default.createElement(
|
|
125
|
+
"div",
|
|
126
|
+
{ className: "openapi-explorer__code-block-btn-group" },
|
|
127
|
+
(wordWrap.isEnabled || wordWrap.isCodeScrollable) &&
|
|
128
|
+
react_1.default.createElement(WordWrapButton_1.default, {
|
|
129
|
+
className: "openapi-explorer__code-block-code-btn",
|
|
130
|
+
onClick: () => wordWrap.toggle(),
|
|
131
|
+
isEnabled: wordWrap.isEnabled,
|
|
132
|
+
}),
|
|
133
|
+
react_1.default.createElement(CopyButton_1.default, {
|
|
134
|
+
className: "openapi-explorer__code-block-code-btn",
|
|
135
|
+
code: code,
|
|
136
|
+
}),
|
|
137
|
+
react_1.default.createElement(ExpandButton_1.default, {
|
|
138
|
+
className: (0, clsx_1.default)(
|
|
139
|
+
"openapi-explorer__code-block-code-btn",
|
|
140
|
+
"openapi-explorer__expand-btn"
|
|
141
|
+
),
|
|
142
|
+
code: code,
|
|
143
|
+
language: language ?? "text",
|
|
144
|
+
showLineNumbers: showLineNumbers,
|
|
145
|
+
blockClassName: blockClassName,
|
|
146
|
+
title: title,
|
|
147
|
+
lineClassNames: lineClassNames,
|
|
148
|
+
})
|
|
149
|
+
)
|
|
150
|
+
)
|
|
133
151
|
);
|
|
134
152
|
}
|
|
153
|
+
exports.default = CodeBlockString;
|
|
@@ -1,74 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/* ============================================================================
|
|
2
3
|
* Copyright (c) Palo Alto Networks
|
|
3
4
|
*
|
|
4
5
|
* This source code is licensed under the MIT license found in the
|
|
5
6
|
* LICENSE file in the root directory of this source tree.
|
|
6
7
|
* ========================================================================== */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
var __createBinding =
|
|
9
|
+
(this && this.__createBinding) ||
|
|
10
|
+
(Object.create
|
|
11
|
+
? function (o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (
|
|
15
|
+
!desc ||
|
|
16
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
17
|
+
) {
|
|
18
|
+
desc = {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return m[k];
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
26
|
+
}
|
|
27
|
+
: function (o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
});
|
|
31
|
+
var __setModuleDefault =
|
|
32
|
+
(this && this.__setModuleDefault) ||
|
|
33
|
+
(Object.create
|
|
34
|
+
? function (o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}
|
|
37
|
+
: function (o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
var __importStar =
|
|
41
|
+
(this && this.__importStar) ||
|
|
42
|
+
function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null)
|
|
46
|
+
for (var k in mod)
|
|
47
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
48
|
+
__createBinding(result, mod, k);
|
|
49
|
+
__setModuleDefault(result, mod);
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
var __importDefault =
|
|
53
|
+
(this && this.__importDefault) ||
|
|
54
|
+
function (mod) {
|
|
55
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
56
|
+
};
|
|
57
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
|
+
const react_1 = __importStar(require("react"));
|
|
59
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
60
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
61
|
+
const copy_text_to_clipboard_1 = __importDefault(
|
|
62
|
+
require("copy-text-to-clipboard")
|
|
63
|
+
);
|
|
64
|
+
function CopyButton({ code, className }) {
|
|
65
|
+
const [isCopied, setIsCopied] = (0, react_1.useState)(false);
|
|
66
|
+
const copyTimeout = (0, react_1.useRef)(undefined);
|
|
67
|
+
const handleCopyCode = (0, react_1.useCallback)(() => {
|
|
68
|
+
(0, copy_text_to_clipboard_1.default)(code);
|
|
20
69
|
setIsCopied(true);
|
|
21
70
|
copyTimeout.current = window.setTimeout(() => {
|
|
22
71
|
setIsCopied(false);
|
|
23
72
|
}, 1000);
|
|
24
73
|
}, [code]);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
74
|
+
(0, react_1.useEffect)(
|
|
75
|
+
() => () => window.clearTimeout(copyTimeout.current),
|
|
76
|
+
[]
|
|
77
|
+
);
|
|
78
|
+
return react_1.default.createElement(
|
|
79
|
+
"button",
|
|
80
|
+
{
|
|
81
|
+
type: "button",
|
|
82
|
+
"aria-label": isCopied
|
|
83
|
+
? (0, Translate_1.translate)({
|
|
84
|
+
id: "theme.CodeBlock.copied",
|
|
85
|
+
message: "Copied",
|
|
86
|
+
description: "The copied button label on code blocks",
|
|
87
|
+
})
|
|
88
|
+
: (0, Translate_1.translate)({
|
|
89
|
+
id: "theme.CodeBlock.copyButtonAriaLabel",
|
|
90
|
+
message: "Copy code to clipboard",
|
|
91
|
+
description: "The ARIA label for copy code blocks button",
|
|
92
|
+
}),
|
|
93
|
+
title: (0, Translate_1.translate)({
|
|
43
94
|
id: "theme.CodeBlock.copy",
|
|
44
95
|
message: "Copy",
|
|
45
96
|
description: "The copy button label on code blocks",
|
|
46
|
-
})
|
|
47
|
-
className
|
|
97
|
+
}),
|
|
98
|
+
className: (0, clsx_1.default)(
|
|
48
99
|
"clean-btn",
|
|
49
100
|
className,
|
|
50
101
|
"openapi-explorer__code-block-copy-btn",
|
|
51
102
|
isCopied && "openapi-explorer__code-block-copy-btn--copied"
|
|
52
|
-
)
|
|
53
|
-
onClick
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
103
|
+
),
|
|
104
|
+
onClick: handleCopyCode,
|
|
105
|
+
},
|
|
106
|
+
react_1.default.createElement(
|
|
107
|
+
"span",
|
|
108
|
+
{
|
|
109
|
+
className: "openapi-explorer__code-block-copy-btn-icons",
|
|
110
|
+
"aria-hidden": "true",
|
|
111
|
+
},
|
|
112
|
+
react_1.default.createElement(
|
|
113
|
+
"svg",
|
|
114
|
+
{
|
|
115
|
+
className: "openapi-explorer__code-block-copy-btn-icon",
|
|
116
|
+
viewBox: "0 0 24 24",
|
|
117
|
+
},
|
|
118
|
+
react_1.default.createElement("path", {
|
|
119
|
+
d: "M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z",
|
|
120
|
+
})
|
|
121
|
+
),
|
|
122
|
+
react_1.default.createElement(
|
|
123
|
+
"svg",
|
|
124
|
+
{
|
|
125
|
+
className: "openapi-explorer__code-block-copy-btn-icon--success",
|
|
126
|
+
viewBox: "0 0 24 24",
|
|
127
|
+
},
|
|
128
|
+
react_1.default.createElement("path", {
|
|
129
|
+
d: "M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z",
|
|
130
|
+
})
|
|
131
|
+
)
|
|
132
|
+
)
|
|
73
133
|
);
|
|
74
134
|
}
|
|
135
|
+
exports.default = CopyButton;
|