docusaurus-theme-openapi-docs 2.1.3 → 2.2.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/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +16 -10
- package/lib/theme/ApiExplorer/CodeSnippets/languages.d.ts +1 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.js +29 -2
- package/lib/theme/ApiExplorer/Request/index.js +1 -3
- package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +1 -1
- package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +1 -1
- package/lib/theme/ApiExplorer/buildPostmanRequest.js +1 -3
- package/lib/theme/ApiExplorer/index.js +1 -3
- package/lib/theme/ApiItem/Layout/index.js +19 -6
- package/lib/theme/ApiItem/index.js +6 -4
- package/lib/theme/ApiTabs/_ApiTabs.scss +1 -0
- package/lib/theme/DiscriminatorTabs/_DiscriminatorTabs.scss +1 -0
- package/lib/theme/MimeTabs/_MimeTabs.scss +1 -0
- package/lib/theme/OperationTabs/_OperationTabs.scss +1 -0
- package/lib/theme/SchemaTabs/_SchemaTabs.scss +1 -0
- package/lib/theme/SchemaTabs/index.js +4 -2
- package/lib/theme/styles.scss +15 -15
- package/package.json +5 -5
- package/src/postman-code-generators.d.ts +1 -1
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +15 -11
- package/src/theme/ApiExplorer/CodeSnippets/languages.ts +22 -0
- package/src/theme/ApiExplorer/Request/index.tsx +1 -1
- package/src/theme/ApiExplorer/Request/makeRequest.ts +1 -1
- package/src/theme/ApiExplorer/buildPostmanRequest.ts +1 -1
- package/src/theme/ApiExplorer/index.tsx +1 -1
- package/src/theme/ApiExplorer/postman-collection.d.ts +1 -1
- package/src/theme/ApiItem/Layout/index.tsx +8 -4
- package/src/theme/ApiItem/index.tsx +6 -5
- package/src/theme/ApiTabs/_ApiTabs.scss +1 -0
- package/src/theme/DiscriminatorTabs/_DiscriminatorTabs.scss +1 -0
- package/src/theme/MimeTabs/_MimeTabs.scss +1 -0
- package/src/theme/OperationTabs/_OperationTabs.scss +1 -0
- package/src/theme/SchemaTabs/_SchemaTabs.scss +1 -0
- package/src/theme/SchemaTabs/index.js +4 -2
- package/src/theme/styles.scss +15 -15
- package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js +0 -165
- package/lib/theme/ApiDemoPanel/ApiCodeBlock/Line/_Line.scss +0 -46
- package/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js +0 -165
- package/src/theme/ApiDemoPanel/ApiCodeBlock/Line/_Line.scss +0 -46
|
@@ -56,13 +56,16 @@ var __importDefault =
|
|
|
56
56
|
};
|
|
57
57
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
58
|
exports.languageSet = void 0;
|
|
59
|
+
/* ============================================================================
|
|
60
|
+
* Copyright (c) Palo Alto Networks
|
|
61
|
+
*
|
|
62
|
+
* This source code is licensed under the MIT license found in the
|
|
63
|
+
* LICENSE file in the root directory of this source tree.
|
|
64
|
+
* ========================================================================== */
|
|
59
65
|
const react_1 = __importStar(require("react"));
|
|
60
66
|
const useDocusaurusContext_1 = __importDefault(
|
|
61
67
|
require("@docusaurus/useDocusaurusContext")
|
|
62
68
|
);
|
|
63
|
-
const postman_code_generators_1 = __importDefault(
|
|
64
|
-
require("@paloaltonetworks/postman-code-generators")
|
|
65
|
-
);
|
|
66
69
|
const ApiCodeBlock_1 = __importDefault(
|
|
67
70
|
require("@theme/ApiExplorer/ApiCodeBlock")
|
|
68
71
|
);
|
|
@@ -71,7 +74,9 @@ const buildPostmanRequest_1 = __importDefault(
|
|
|
71
74
|
);
|
|
72
75
|
const CodeTabs_1 = __importDefault(require("@theme/ApiExplorer/CodeTabs"));
|
|
73
76
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
74
|
-
const
|
|
77
|
+
const postman_code_generators_1 = __importDefault(
|
|
78
|
+
require("postman-code-generators")
|
|
79
|
+
);
|
|
75
80
|
const languages_1 = require("./languages");
|
|
76
81
|
exports.languageSet = [
|
|
77
82
|
{
|
|
@@ -193,7 +198,6 @@ function CodeTab({ children, hidden, className }) {
|
|
|
193
198
|
);
|
|
194
199
|
}
|
|
195
200
|
function CodeSnippets({ postman, codeSamples }) {
|
|
196
|
-
// TODO: match theme for vscode.
|
|
197
201
|
const { siteConfig } = (0, useDocusaurusContext_1.default)();
|
|
198
202
|
const contentType = (0, hooks_1.useTypedSelector)(
|
|
199
203
|
(state) => state.contentType.value
|
|
@@ -216,18 +220,20 @@ function CodeSnippets({ postman, codeSamples }) {
|
|
|
216
220
|
const auth = (0, hooks_1.useTypedSelector)((state) => state.auth);
|
|
217
221
|
// User-defined languages array
|
|
218
222
|
// Can override languageSet, change order of langs, override options and variants
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
];
|
|
223
|
+
const userDefinedLanguageSet =
|
|
224
|
+
siteConfig?.themeConfig?.languageTabs ?? exports.languageSet;
|
|
222
225
|
// Filter languageSet by user-defined langs
|
|
223
226
|
const filteredLanguageSet = exports.languageSet.filter((ls) => {
|
|
224
|
-
return
|
|
227
|
+
return userDefinedLanguageSet?.some((lang) => {
|
|
225
228
|
return lang.language === ls.language;
|
|
226
229
|
});
|
|
227
230
|
});
|
|
228
231
|
// Merge user-defined langs into languageSet
|
|
229
232
|
const mergedLangs = (0, languages_1.mergeCodeSampleLanguage)(
|
|
230
|
-
(0,
|
|
233
|
+
(0, languages_1.mergeArraysbyLanguage)(
|
|
234
|
+
userDefinedLanguageSet,
|
|
235
|
+
filteredLanguageSet
|
|
236
|
+
),
|
|
231
237
|
codeSamples
|
|
232
238
|
);
|
|
233
239
|
// Read defaultLang from localStorage
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { CodeSample, Language } from "./code-snippets-types";
|
|
2
2
|
export declare function mergeCodeSampleLanguage(languages: Language[], codeSamples: CodeSample[]): Language[];
|
|
3
|
+
export declare const mergeArraysbyLanguage: (arr1: any, arr2: any) => any[];
|
|
3
4
|
export declare function getCodeSampleSourceFromLanguage(language: Language): string;
|
|
@@ -5,9 +5,20 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
|
+
var __importDefault =
|
|
9
|
+
(this && this.__importDefault) ||
|
|
10
|
+
function (mod) {
|
|
11
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
|
+
};
|
|
8
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.getCodeSampleSourceFromLanguage =
|
|
10
|
-
|
|
14
|
+
exports.getCodeSampleSourceFromLanguage =
|
|
15
|
+
exports.mergeArraysbyLanguage =
|
|
16
|
+
exports.mergeCodeSampleLanguage =
|
|
17
|
+
void 0;
|
|
18
|
+
const find_1 = __importDefault(require("lodash/find"));
|
|
19
|
+
const isArray_1 = __importDefault(require("lodash/isArray"));
|
|
20
|
+
const mergeWith_1 = __importDefault(require("lodash/mergeWith"));
|
|
21
|
+
const unionBy_1 = __importDefault(require("lodash/unionBy"));
|
|
11
22
|
function mergeCodeSampleLanguage(languages, codeSamples) {
|
|
12
23
|
return languages.map((language) => {
|
|
13
24
|
const languageCodeSamples = codeSamples.filter(
|
|
@@ -31,6 +42,22 @@ function mergeCodeSampleLanguage(languages, codeSamples) {
|
|
|
31
42
|
});
|
|
32
43
|
}
|
|
33
44
|
exports.mergeCodeSampleLanguage = mergeCodeSampleLanguage;
|
|
45
|
+
const mergeArraysbyLanguage = (arr1, arr2) => {
|
|
46
|
+
const mergedArray = (0, unionBy_1.default)(arr1, arr2, "language");
|
|
47
|
+
return mergedArray.map((item) => {
|
|
48
|
+
const matchingItems = [
|
|
49
|
+
(0, find_1.default)(arr1, ["language", item["language"]]),
|
|
50
|
+
(0, find_1.default)(arr2, ["language", item["language"]]),
|
|
51
|
+
];
|
|
52
|
+
return (0, mergeWith_1.default)({}, ...matchingItems, (objValue) => {
|
|
53
|
+
if ((0, isArray_1.default)(objValue)) {
|
|
54
|
+
return objValue;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
exports.mergeArraysbyLanguage = mergeArraysbyLanguage;
|
|
34
61
|
function getCodeSampleSourceFromLanguage(language) {
|
|
35
62
|
if (
|
|
36
63
|
language &&
|
|
@@ -58,9 +58,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
58
58
|
// @ts-nocheck
|
|
59
59
|
const react_1 = __importStar(require("react"));
|
|
60
60
|
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
61
|
-
const postman_collection_1 = __importDefault(
|
|
62
|
-
require("@paloaltonetworks/postman-collection")
|
|
63
|
-
);
|
|
64
61
|
const Accept_1 = __importDefault(require("@theme/ApiExplorer/Accept"));
|
|
65
62
|
const Authorization_1 = __importDefault(
|
|
66
63
|
require("@theme/ApiExplorer/Authorization")
|
|
@@ -78,6 +75,7 @@ const ParamOptions_1 = __importDefault(
|
|
|
78
75
|
const slice_1 = require("@theme/ApiExplorer/Response/slice");
|
|
79
76
|
const Server_1 = __importDefault(require("@theme/ApiExplorer/Server"));
|
|
80
77
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
78
|
+
const postman_collection_1 = __importDefault(require("postman-collection"));
|
|
81
79
|
const react_hook_form_1 = require("react-hook-form");
|
|
82
80
|
const makeRequest_1 = __importDefault(require("./makeRequest"));
|
|
83
81
|
function Request({ item }) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import sdk from "@paloaltonetworks/postman-collection";
|
|
2
1
|
import { Body } from "@theme/ApiExplorer/Body/slice";
|
|
2
|
+
import sdk from "postman-collection";
|
|
3
3
|
declare function makeRequest(request: sdk.Request, proxy: string | undefined, _body: Body): Promise<any>;
|
|
4
4
|
export default makeRequest;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import sdk from "@paloaltonetworks/postman-collection";
|
|
2
1
|
import { AuthState } from "@theme/ApiExplorer/Authorization/slice";
|
|
3
2
|
import { Body } from "@theme/ApiExplorer/Body/slice";
|
|
4
3
|
import { ParameterObject, ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
4
|
+
import sdk from "postman-collection";
|
|
5
5
|
type Param = {
|
|
6
6
|
value?: string | string[];
|
|
7
7
|
} & ParameterObject;
|
|
@@ -11,10 +11,8 @@ var __importDefault =
|
|
|
11
11
|
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
const postman_collection_1 = __importDefault(
|
|
15
|
-
require("@paloaltonetworks/postman-collection")
|
|
16
|
-
);
|
|
17
14
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
15
|
+
const postman_collection_1 = __importDefault(require("postman-collection"));
|
|
18
16
|
function setQueryParams(postman, queryParams) {
|
|
19
17
|
postman.url.query.clear();
|
|
20
18
|
const qp = queryParams
|
|
@@ -12,14 +12,12 @@ var __importDefault =
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const react_1 = __importDefault(require("react"));
|
|
15
|
-
const postman_collection_1 = __importDefault(
|
|
16
|
-
require("@paloaltonetworks/postman-collection")
|
|
17
|
-
);
|
|
18
15
|
const CodeSnippets_1 = __importDefault(
|
|
19
16
|
require("@theme/ApiExplorer/CodeSnippets")
|
|
20
17
|
);
|
|
21
18
|
const Request_1 = __importDefault(require("@theme/ApiExplorer/Request"));
|
|
22
19
|
const Response_1 = __importDefault(require("@theme/ApiExplorer/Response"));
|
|
20
|
+
const postman_collection_1 = __importDefault(require("postman-collection"));
|
|
23
21
|
const SecuritySchemes_1 = __importDefault(require("./SecuritySchemes"));
|
|
24
22
|
function ApiExplorer({ item, infoPath }) {
|
|
25
23
|
const postman = new postman_collection_1.default.Request(item.postman);
|
|
@@ -74,16 +74,29 @@ function DocItemLayout({ children }) {
|
|
|
74
74
|
react_1.default.createElement(Content_1.default, null, children),
|
|
75
75
|
react_1.default.createElement(
|
|
76
76
|
"div",
|
|
77
|
-
{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
{ className: "row" },
|
|
78
|
+
react_1.default.createElement(
|
|
79
|
+
"div",
|
|
80
|
+
{
|
|
81
|
+
className: (0, clsx_1.default)(
|
|
82
|
+
"col",
|
|
83
|
+
api ? "col--7" : "col--12"
|
|
84
|
+
),
|
|
85
|
+
},
|
|
86
|
+
react_1.default.createElement(Footer_1.default, null)
|
|
87
|
+
)
|
|
81
88
|
)
|
|
82
89
|
),
|
|
83
90
|
react_1.default.createElement(
|
|
84
91
|
"div",
|
|
85
|
-
{ className:
|
|
86
|
-
react_1.default.createElement(
|
|
92
|
+
{ className: "row" },
|
|
93
|
+
react_1.default.createElement(
|
|
94
|
+
"div",
|
|
95
|
+
{
|
|
96
|
+
className: (0, clsx_1.default)("col", api ? "col--7" : "col--12"),
|
|
97
|
+
},
|
|
98
|
+
react_1.default.createElement(Paginator_1.default, null)
|
|
99
|
+
)
|
|
87
100
|
)
|
|
88
101
|
)
|
|
89
102
|
),
|
|
@@ -43,9 +43,11 @@ function ApiItem(props) {
|
|
|
43
43
|
const { schema } = frontMatter;
|
|
44
44
|
// decompress and parse
|
|
45
45
|
if (api) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
try {
|
|
47
|
+
api = JSON.parse(
|
|
48
|
+
zlib_1.default.inflateSync(Buffer.from(api, "base64")).toString()
|
|
49
|
+
);
|
|
50
|
+
} catch {}
|
|
49
51
|
}
|
|
50
52
|
const { siteConfig } = (0, useDocusaurusContext_1.default)();
|
|
51
53
|
const themeConfig = siteConfig.themeConfig;
|
|
@@ -204,7 +206,7 @@ function ApiItem(props) {
|
|
|
204
206
|
{ className: "row" },
|
|
205
207
|
react_1.default.createElement(
|
|
206
208
|
"div",
|
|
207
|
-
{ className: "col col--12" },
|
|
209
|
+
{ className: "col col--12 markdown" },
|
|
208
210
|
react_1.default.createElement(MDXComponent, null)
|
|
209
211
|
)
|
|
210
212
|
)
|
|
@@ -74,11 +74,13 @@ function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
|
74
74
|
};
|
|
75
75
|
}, []);
|
|
76
76
|
|
|
77
|
-
const handleRightClick = () => {
|
|
77
|
+
const handleRightClick = (e) => {
|
|
78
|
+
e.preventDefault();
|
|
78
79
|
tabItemListContainerRef.current.scrollLeft += 90;
|
|
79
80
|
};
|
|
80
81
|
|
|
81
|
-
const handleLeftClick = () => {
|
|
82
|
+
const handleLeftClick = (e) => {
|
|
83
|
+
e.preventDefault();
|
|
82
84
|
tabItemListContainerRef.current.scrollLeft -= 90;
|
|
83
85
|
};
|
|
84
86
|
|
package/lib/theme/styles.scss
CHANGED
|
@@ -130,22 +130,22 @@
|
|
|
130
130
|
|
|
131
131
|
/* Version button */
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
.version-button div {
|
|
134
|
+
display: block;
|
|
135
|
+
}
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
137
|
+
.version-button div > button > span::after {
|
|
138
|
+
border-color: currentcolor transparent;
|
|
139
|
+
border-style: solid;
|
|
140
|
+
border-width: 0.4em 0.4em 0;
|
|
141
|
+
content: "";
|
|
142
|
+
margin-left: 0.3em;
|
|
143
|
+
position: relative;
|
|
144
|
+
transform: translateY(-50%);
|
|
145
|
+
display: inline-block;
|
|
146
|
+
font-size: 0.8rem;
|
|
147
|
+
top: 1px;
|
|
148
|
+
}
|
|
149
149
|
|
|
150
150
|
.openapi__logo {
|
|
151
151
|
width: 250px;
|
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": "2.1
|
|
4
|
+
"version": "2.2.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -37,17 +37,17 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@docusaurus/theme-common": ">=2.4.1 <=2.4.3",
|
|
39
39
|
"@hookform/error-message": "^2.0.1",
|
|
40
|
-
"@paloaltonetworks/postman-code-generators": "1.1.15-patch.2",
|
|
41
|
-
"@paloaltonetworks/postman-collection": "^4.1.0",
|
|
42
40
|
"@reduxjs/toolkit": "^1.7.1",
|
|
43
41
|
"clsx": "^1.1.1",
|
|
44
42
|
"copy-text-to-clipboard": "^3.1.0",
|
|
45
43
|
"crypto-js": "^4.1.1",
|
|
46
|
-
"docusaurus-plugin-openapi-docs": "^2.
|
|
44
|
+
"docusaurus-plugin-openapi-docs": "^2.2.0",
|
|
47
45
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
48
46
|
"file-saver": "^2.0.5",
|
|
49
47
|
"lodash": "^4.17.20",
|
|
50
48
|
"node-polyfill-webpack-plugin": "^2.0.1",
|
|
49
|
+
"postman-code-generators": "^1.10.1",
|
|
50
|
+
"postman-collection": "^4.4.0",
|
|
51
51
|
"prism-react-renderer": "^1.3.5",
|
|
52
52
|
"react-hook-form": "^7.43.8",
|
|
53
53
|
"react-live": "^4.0.0",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=14"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "73b212d18343aa7a35ede5136f5353f06b89d25f"
|
|
72
72
|
}
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
8
|
// TODO: Remove this when https://github.com/facebook/docusaurus/issues/6087 is resolved.
|
|
9
|
-
declare module "
|
|
9
|
+
declare module "postman-code-generators";
|
|
@@ -5,20 +5,27 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
+
/* ============================================================================
|
|
9
|
+
* Copyright (c) Palo Alto Networks
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the MIT license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
* ========================================================================== */
|
|
14
|
+
|
|
8
15
|
import React, { useState, useEffect } from "react";
|
|
9
16
|
|
|
10
17
|
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
|
11
|
-
import codegen from "@paloaltonetworks/postman-code-generators";
|
|
12
|
-
import sdk from "@paloaltonetworks/postman-collection";
|
|
13
18
|
import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
|
|
14
19
|
import buildPostmanRequest from "@theme/ApiExplorer/buildPostmanRequest";
|
|
15
20
|
import CodeTabs from "@theme/ApiExplorer/CodeTabs";
|
|
16
21
|
import { useTypedSelector } from "@theme/ApiItem/hooks";
|
|
17
|
-
import
|
|
22
|
+
import codegen from "postman-code-generators";
|
|
23
|
+
import sdk from "postman-collection";
|
|
18
24
|
|
|
19
25
|
import { CodeSample, Language } from "./code-snippets-types";
|
|
20
26
|
import {
|
|
21
27
|
getCodeSampleSourceFromLanguage,
|
|
28
|
+
mergeArraysbyLanguage,
|
|
22
29
|
mergeCodeSampleLanguage,
|
|
23
30
|
} from "./languages";
|
|
24
31
|
|
|
@@ -149,8 +156,6 @@ function CodeTab({ children, hidden, className }: any): JSX.Element {
|
|
|
149
156
|
}
|
|
150
157
|
|
|
151
158
|
function CodeSnippets({ postman, codeSamples }: Props) {
|
|
152
|
-
// TODO: match theme for vscode.
|
|
153
|
-
|
|
154
159
|
const { siteConfig } = useDocusaurusContext();
|
|
155
160
|
|
|
156
161
|
const contentType = useTypedSelector((state: any) => state.contentType.value);
|
|
@@ -167,21 +172,20 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
167
172
|
|
|
168
173
|
// User-defined languages array
|
|
169
174
|
// Can override languageSet, change order of langs, override options and variants
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
];
|
|
175
|
+
const userDefinedLanguageSet =
|
|
176
|
+
(siteConfig?.themeConfig?.languageTabs as Language[] | undefined) ??
|
|
177
|
+
languageSet;
|
|
174
178
|
|
|
175
179
|
// Filter languageSet by user-defined langs
|
|
176
180
|
const filteredLanguageSet = languageSet.filter((ls) => {
|
|
177
|
-
return
|
|
181
|
+
return userDefinedLanguageSet?.some((lang) => {
|
|
178
182
|
return lang.language === ls.language;
|
|
179
183
|
});
|
|
180
184
|
});
|
|
181
185
|
|
|
182
186
|
// Merge user-defined langs into languageSet
|
|
183
187
|
const mergedLangs = mergeCodeSampleLanguage(
|
|
184
|
-
|
|
188
|
+
mergeArraysbyLanguage(userDefinedLanguageSet, filteredLanguageSet),
|
|
185
189
|
codeSamples
|
|
186
190
|
);
|
|
187
191
|
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
+
import find from "lodash/find";
|
|
9
|
+
import isArray from "lodash/isArray";
|
|
10
|
+
import mergeWith from "lodash/mergeWith";
|
|
11
|
+
import unionBy from "lodash/unionBy";
|
|
12
|
+
|
|
8
13
|
import { CodeSample, Language } from "./code-snippets-types";
|
|
9
14
|
|
|
10
15
|
export function mergeCodeSampleLanguage(
|
|
@@ -36,6 +41,23 @@ export function mergeCodeSampleLanguage(
|
|
|
36
41
|
});
|
|
37
42
|
}
|
|
38
43
|
|
|
44
|
+
export const mergeArraysbyLanguage = (arr1: any, arr2: any) => {
|
|
45
|
+
const mergedArray = unionBy(arr1, arr2, "language");
|
|
46
|
+
|
|
47
|
+
return mergedArray.map((item: any) => {
|
|
48
|
+
const matchingItems = [
|
|
49
|
+
find(arr1, ["language", item["language"]]),
|
|
50
|
+
find(arr2, ["language", item["language"]]),
|
|
51
|
+
];
|
|
52
|
+
return mergeWith({}, ...matchingItems, (objValue: any) => {
|
|
53
|
+
if (isArray(objValue)) {
|
|
54
|
+
return objValue;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
39
61
|
export function getCodeSampleSourceFromLanguage(language: Language) {
|
|
40
62
|
if (
|
|
41
63
|
language &&
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import React, { useState } from "react";
|
|
10
10
|
|
|
11
11
|
import { useDoc } from "@docusaurus/theme-common/internal";
|
|
12
|
-
import sdk from "@paloaltonetworks/postman-collection";
|
|
13
12
|
import Accept from "@theme/ApiExplorer/Accept";
|
|
14
13
|
import Authorization from "@theme/ApiExplorer/Authorization";
|
|
15
14
|
import Body from "@theme/ApiExplorer/Body";
|
|
@@ -27,6 +26,7 @@ import Server from "@theme/ApiExplorer/Server";
|
|
|
27
26
|
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
|
|
28
27
|
import { ParameterObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
29
28
|
import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
|
|
29
|
+
import sdk from "postman-collection";
|
|
30
30
|
import { FormProvider, useForm } from "react-hook-form";
|
|
31
31
|
|
|
32
32
|
import makeRequest from "./makeRequest";
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import sdk from "@paloaltonetworks/postman-collection";
|
|
9
8
|
import { Body } from "@theme/ApiExplorer/Body/slice";
|
|
9
|
+
import sdk from "postman-collection";
|
|
10
10
|
|
|
11
11
|
function fetchWithtimeout(
|
|
12
12
|
url: string,
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import sdk from "@paloaltonetworks/postman-collection";
|
|
9
8
|
import { AuthState, Scheme } from "@theme/ApiExplorer/Authorization/slice";
|
|
10
9
|
import { Body, Content } from "@theme/ApiExplorer/Body/slice";
|
|
11
10
|
import {
|
|
@@ -13,6 +12,7 @@ import {
|
|
|
13
12
|
ServerObject,
|
|
14
13
|
} from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
15
14
|
import cloneDeep from "lodash/cloneDeep";
|
|
15
|
+
import sdk from "postman-collection";
|
|
16
16
|
|
|
17
17
|
type Param = {
|
|
18
18
|
value?: string | string[];
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
-
import sdk from "@paloaltonetworks/postman-collection";
|
|
11
10
|
import CodeSnippets from "@theme/ApiExplorer/CodeSnippets";
|
|
12
11
|
import Request from "@theme/ApiExplorer/Request";
|
|
13
12
|
import Response from "@theme/ApiExplorer/Response";
|
|
14
13
|
import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
|
|
14
|
+
import sdk from "postman-collection";
|
|
15
15
|
|
|
16
16
|
import SecuritySchemes from "./SecuritySchemes";
|
|
17
17
|
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
declare module "
|
|
8
|
+
declare module "postman-collection" {
|
|
9
9
|
export = Request.sdk;
|
|
10
10
|
}
|
|
@@ -62,12 +62,16 @@ export default function DocItemLayout({ children }: Props): JSX.Element {
|
|
|
62
62
|
<DocVersionBadge />
|
|
63
63
|
{docTOC.mobile}
|
|
64
64
|
<DocItemContent>{children}</DocItemContent>
|
|
65
|
-
<div className=
|
|
66
|
-
<
|
|
65
|
+
<div className="row">
|
|
66
|
+
<div className={clsx("col", api ? "col--7" : "col--12")}>
|
|
67
|
+
<DocItemFooter />
|
|
68
|
+
</div>
|
|
67
69
|
</div>
|
|
68
70
|
</article>
|
|
69
|
-
<div className=
|
|
70
|
-
<
|
|
71
|
+
<div className="row">
|
|
72
|
+
<div className={clsx("col", api ? "col--7" : "col--12")}>
|
|
73
|
+
<DocItemPaginator />
|
|
74
|
+
</div>
|
|
71
75
|
</div>
|
|
72
76
|
</div>
|
|
73
77
|
</div>
|
|
@@ -57,11 +57,12 @@ export default function ApiItem(props: Props): JSX.Element {
|
|
|
57
57
|
const { schema } = frontMatter as SchemaFrontMatter;
|
|
58
58
|
// decompress and parse
|
|
59
59
|
if (api) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
try {
|
|
61
|
+
api = JSON.parse(
|
|
62
|
+
zlib.inflateSync(Buffer.from(api as any, "base64")).toString()
|
|
63
|
+
);
|
|
64
|
+
} catch {}
|
|
63
65
|
}
|
|
64
|
-
|
|
65
66
|
const { siteConfig } = useDocusaurusContext();
|
|
66
67
|
const themeConfig = siteConfig.themeConfig as ThemeConfig;
|
|
67
68
|
const options = themeConfig.api;
|
|
@@ -188,7 +189,7 @@ export default function ApiItem(props: Props): JSX.Element {
|
|
|
188
189
|
<DocItemMetadata />
|
|
189
190
|
<DocItemLayout>
|
|
190
191
|
<div className="row">
|
|
191
|
-
<div className="col col--12">
|
|
192
|
+
<div className="col col--12 markdown">
|
|
192
193
|
<MDXComponent />
|
|
193
194
|
</div>
|
|
194
195
|
</div>
|
|
@@ -74,11 +74,13 @@ function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
|
74
74
|
};
|
|
75
75
|
}, []);
|
|
76
76
|
|
|
77
|
-
const handleRightClick = () => {
|
|
77
|
+
const handleRightClick = (e) => {
|
|
78
|
+
e.preventDefault();
|
|
78
79
|
tabItemListContainerRef.current.scrollLeft += 90;
|
|
79
80
|
};
|
|
80
81
|
|
|
81
|
-
const handleLeftClick = () => {
|
|
82
|
+
const handleLeftClick = (e) => {
|
|
83
|
+
e.preventDefault();
|
|
82
84
|
tabItemListContainerRef.current.scrollLeft -= 90;
|
|
83
85
|
};
|
|
84
86
|
|
package/src/theme/styles.scss
CHANGED
|
@@ -130,22 +130,22 @@
|
|
|
130
130
|
|
|
131
131
|
/* Version button */
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
.version-button div {
|
|
134
|
+
display: block;
|
|
135
|
+
}
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
137
|
+
.version-button div > button > span::after {
|
|
138
|
+
border-color: currentcolor transparent;
|
|
139
|
+
border-style: solid;
|
|
140
|
+
border-width: 0.4em 0.4em 0;
|
|
141
|
+
content: "";
|
|
142
|
+
margin-left: 0.3em;
|
|
143
|
+
position: relative;
|
|
144
|
+
transform: translateY(-50%);
|
|
145
|
+
display: inline-block;
|
|
146
|
+
font-size: 0.8rem;
|
|
147
|
+
top: 1px;
|
|
148
|
+
}
|
|
149
149
|
|
|
150
150
|
.openapi__logo {
|
|
151
151
|
width: 250px;
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/* ============================================================================
|
|
2
|
-
* Copyright (c) Palo Alto Networks
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
* ========================================================================== */
|
|
7
|
-
|
|
8
|
-
import React, { useEffect } from "react";
|
|
9
|
-
|
|
10
|
-
import { usePrismTheme } from "@docusaurus/theme-common";
|
|
11
|
-
import { translate } from "@docusaurus/Translate";
|
|
12
|
-
import Container from "@theme/ApiDemoPanel/ApiCodeBlock/Container";
|
|
13
|
-
import CopyButton from "@theme/ApiDemoPanel/ApiCodeBlock/CopyButton";
|
|
14
|
-
import ExitButton from "@theme/ApiDemoPanel/ApiCodeBlock/ExitButton";
|
|
15
|
-
import Line from "@theme/ApiDemoPanel/ApiCodeBlock/Line";
|
|
16
|
-
import clsx from "clsx";
|
|
17
|
-
import Highlight, { defaultProps } from "prism-react-renderer";
|
|
18
|
-
import Modal from "react-modal";
|
|
19
|
-
|
|
20
|
-
export default function ExpandButton({
|
|
21
|
-
code,
|
|
22
|
-
className,
|
|
23
|
-
language,
|
|
24
|
-
showLineNumbers,
|
|
25
|
-
blockClassName,
|
|
26
|
-
title,
|
|
27
|
-
lineClassNames,
|
|
28
|
-
}) {
|
|
29
|
-
const prismTheme = usePrismTheme();
|
|
30
|
-
|
|
31
|
-
function openModal() {
|
|
32
|
-
setIsOpen(true);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function closeModal() {
|
|
36
|
-
setIsOpen(false);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const [modalIsOpen, setIsOpen] = React.useState(false);
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
Modal.setAppElement("body");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<>
|
|
47
|
-
<button
|
|
48
|
-
type="button"
|
|
49
|
-
aria-label={
|
|
50
|
-
modalIsOpen
|
|
51
|
-
? translate({
|
|
52
|
-
id: "theme.CodeBlock.expanded",
|
|
53
|
-
message: "Expanded",
|
|
54
|
-
description: "The expanded button label on code blocks",
|
|
55
|
-
})
|
|
56
|
-
: translate({
|
|
57
|
-
id: "theme.CodeBlock.expandButtonAriaLabel",
|
|
58
|
-
message: "Expand code to fullscreen",
|
|
59
|
-
description: "The ARIA label for expand code blocks button",
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
title={translate({
|
|
63
|
-
id: "theme.CodeBlock.expand",
|
|
64
|
-
message: "Expand",
|
|
65
|
-
description: "The expand button label on code blocks",
|
|
66
|
-
})}
|
|
67
|
-
className={clsx(
|
|
68
|
-
"clean-btn",
|
|
69
|
-
className,
|
|
70
|
-
"openapi-explorer__code-block-expand-btn",
|
|
71
|
-
modalIsOpen && "openapi-explorer__code-block-expand-btn--copied"
|
|
72
|
-
)}
|
|
73
|
-
onClick={openModal}
|
|
74
|
-
>
|
|
75
|
-
<span
|
|
76
|
-
className="openapi-explorer__code-block-expand-btn-icons"
|
|
77
|
-
aria-hidden="true"
|
|
78
|
-
>
|
|
79
|
-
<svg
|
|
80
|
-
className="openapi-explorer__code-block-expand-btn-icon"
|
|
81
|
-
viewBox="0 0 448 512"
|
|
82
|
-
>
|
|
83
|
-
<path d="M32 32C14.3 32 0 46.3 0 64v96c0 17.7 14.3 32 32 32s32-14.3 32-32V96h64c17.7 0 32-14.3 32-32s-14.3-32-32-32H32zM64 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7 14.3 32 32 32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H64V352zM320 32c-17.7 0-32 14.3-32 32s14.3 32 32 32h64v64c0 17.7 14.3 32 32 32s32-14.3 32-32V64c0-17.7-14.3-32-32-32H320zM448 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v64H320c-17.7 0-32 14.3-32 32s14.3 32 32 32h96c17.7 0 32-14.3 32-32V352z" />
|
|
84
|
-
</svg>
|
|
85
|
-
<svg
|
|
86
|
-
className="openapi-explorer__code-block-expand-btn-icon--success"
|
|
87
|
-
viewBox="0 0 24 24"
|
|
88
|
-
>
|
|
89
|
-
<path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" />
|
|
90
|
-
</svg>
|
|
91
|
-
</span>
|
|
92
|
-
</button>
|
|
93
|
-
<Modal
|
|
94
|
-
className="openapi-explorer__expand-modal-content"
|
|
95
|
-
overlayClassName="openapi-explorer__expand-modal-overlay"
|
|
96
|
-
isOpen={modalIsOpen}
|
|
97
|
-
onRequestClose={closeModal}
|
|
98
|
-
contentLabel="Code Snippet"
|
|
99
|
-
>
|
|
100
|
-
<Container
|
|
101
|
-
as="div"
|
|
102
|
-
className={clsx(
|
|
103
|
-
"openapi-explorer__code-block-container",
|
|
104
|
-
language &&
|
|
105
|
-
!blockClassName.includes(`language-${language}`) &&
|
|
106
|
-
`language-${language}`
|
|
107
|
-
)}
|
|
108
|
-
>
|
|
109
|
-
{title && (
|
|
110
|
-
<div className="openapi-explorer__code-block-title">{title}</div>
|
|
111
|
-
)}
|
|
112
|
-
<div className="openapi-explorer__code-block-content">
|
|
113
|
-
<Highlight
|
|
114
|
-
{...defaultProps}
|
|
115
|
-
theme={prismTheme}
|
|
116
|
-
code={code}
|
|
117
|
-
language={language ?? "text"}
|
|
118
|
-
>
|
|
119
|
-
{({ className, tokens, getLineProps, getTokenProps }) => (
|
|
120
|
-
<pre
|
|
121
|
-
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
|
122
|
-
tabIndex={0}
|
|
123
|
-
className={clsx(
|
|
124
|
-
className,
|
|
125
|
-
"openapi-explorer__code-block",
|
|
126
|
-
"thin-scrollbar"
|
|
127
|
-
)}
|
|
128
|
-
>
|
|
129
|
-
<code
|
|
130
|
-
className={clsx(
|
|
131
|
-
"openapi-explorer__code-block-lines",
|
|
132
|
-
showLineNumbers &&
|
|
133
|
-
"openapi-explorer__code-block-lines-numbers"
|
|
134
|
-
)}
|
|
135
|
-
>
|
|
136
|
-
{tokens.map((line, i) => (
|
|
137
|
-
<Line
|
|
138
|
-
key={i}
|
|
139
|
-
line={line}
|
|
140
|
-
getLineProps={getLineProps}
|
|
141
|
-
getTokenProps={getTokenProps}
|
|
142
|
-
classNames={lineClassNames[i]}
|
|
143
|
-
showLineNumbers={showLineNumbers}
|
|
144
|
-
/>
|
|
145
|
-
))}
|
|
146
|
-
</code>
|
|
147
|
-
</pre>
|
|
148
|
-
)}
|
|
149
|
-
</Highlight>
|
|
150
|
-
<div className="openapi-explorer__code-block-btn-group">
|
|
151
|
-
<CopyButton
|
|
152
|
-
className="openapi-explorer__code-block-code-btn"
|
|
153
|
-
code={code}
|
|
154
|
-
/>
|
|
155
|
-
<ExitButton
|
|
156
|
-
className="openapi-dmeo__code-block-code-btn"
|
|
157
|
-
handler={closeModal}
|
|
158
|
-
/>
|
|
159
|
-
</div>
|
|
160
|
-
</div>
|
|
161
|
-
</Container>
|
|
162
|
-
</Modal>
|
|
163
|
-
</>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/* Intentionally has zero specificity, so that to be able to override
|
|
2
|
-
the background in custom CSS file due bug https://github.com/facebook/docusaurus/issues/3678 */
|
|
3
|
-
:where(:root) {
|
|
4
|
-
--docusaurus-highlighted-code-line-bg: rgb(72 77 91);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
:where([data-theme="dark"]) {
|
|
8
|
-
--docusaurus-highlighted-code-line-bg: rgb(100 100 100);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.theme-code-block-highlighted-line {
|
|
12
|
-
background-color: var(--docusaurus-highlighted-code-line-bg);
|
|
13
|
-
display: block;
|
|
14
|
-
margin: 0 calc(-1 * var(--ifm-pre-padding));
|
|
15
|
-
padding: 0 var(--ifm-pre-padding);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.openapi-explorer__code-block-code-line {
|
|
19
|
-
display: table-row;
|
|
20
|
-
counter-increment: line-count;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.openapi-explorer__code-block-code-line-number {
|
|
24
|
-
display: table-cell;
|
|
25
|
-
text-align: right;
|
|
26
|
-
width: 1%;
|
|
27
|
-
position: sticky;
|
|
28
|
-
left: 0;
|
|
29
|
-
padding: 0 var(--ifm-pre-padding);
|
|
30
|
-
background: var(--ifm-pre-background);
|
|
31
|
-
overflow-wrap: normal;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.openapi-explorer__code-block-code-line-number::before {
|
|
35
|
-
content: counter(line-count);
|
|
36
|
-
opacity: 0.4;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
:global(.theme-code-block-highlighted-line)
|
|
40
|
-
.openapi-explorer__code-block-code-line-number::before {
|
|
41
|
-
opacity: 0.8;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.openapi-explorer__code-block-code-line-number {
|
|
45
|
-
padding-right: var(--ifm-pre-padding);
|
|
46
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/* ============================================================================
|
|
2
|
-
* Copyright (c) Palo Alto Networks
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
* ========================================================================== */
|
|
7
|
-
|
|
8
|
-
import React, { useEffect } from "react";
|
|
9
|
-
|
|
10
|
-
import { usePrismTheme } from "@docusaurus/theme-common";
|
|
11
|
-
import { translate } from "@docusaurus/Translate";
|
|
12
|
-
import Container from "@theme/ApiDemoPanel/ApiCodeBlock/Container";
|
|
13
|
-
import CopyButton from "@theme/ApiDemoPanel/ApiCodeBlock/CopyButton";
|
|
14
|
-
import ExitButton from "@theme/ApiDemoPanel/ApiCodeBlock/ExitButton";
|
|
15
|
-
import Line from "@theme/ApiDemoPanel/ApiCodeBlock/Line";
|
|
16
|
-
import clsx from "clsx";
|
|
17
|
-
import Highlight, { defaultProps } from "prism-react-renderer";
|
|
18
|
-
import Modal from "react-modal";
|
|
19
|
-
|
|
20
|
-
export default function ExpandButton({
|
|
21
|
-
code,
|
|
22
|
-
className,
|
|
23
|
-
language,
|
|
24
|
-
showLineNumbers,
|
|
25
|
-
blockClassName,
|
|
26
|
-
title,
|
|
27
|
-
lineClassNames,
|
|
28
|
-
}) {
|
|
29
|
-
const prismTheme = usePrismTheme();
|
|
30
|
-
|
|
31
|
-
function openModal() {
|
|
32
|
-
setIsOpen(true);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function closeModal() {
|
|
36
|
-
setIsOpen(false);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const [modalIsOpen, setIsOpen] = React.useState(false);
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
Modal.setAppElement("body");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<>
|
|
47
|
-
<button
|
|
48
|
-
type="button"
|
|
49
|
-
aria-label={
|
|
50
|
-
modalIsOpen
|
|
51
|
-
? translate({
|
|
52
|
-
id: "theme.CodeBlock.expanded",
|
|
53
|
-
message: "Expanded",
|
|
54
|
-
description: "The expanded button label on code blocks",
|
|
55
|
-
})
|
|
56
|
-
: translate({
|
|
57
|
-
id: "theme.CodeBlock.expandButtonAriaLabel",
|
|
58
|
-
message: "Expand code to fullscreen",
|
|
59
|
-
description: "The ARIA label for expand code blocks button",
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
title={translate({
|
|
63
|
-
id: "theme.CodeBlock.expand",
|
|
64
|
-
message: "Expand",
|
|
65
|
-
description: "The expand button label on code blocks",
|
|
66
|
-
})}
|
|
67
|
-
className={clsx(
|
|
68
|
-
"clean-btn",
|
|
69
|
-
className,
|
|
70
|
-
"openapi-explorer__code-block-expand-btn",
|
|
71
|
-
modalIsOpen && "openapi-explorer__code-block-expand-btn--copied"
|
|
72
|
-
)}
|
|
73
|
-
onClick={openModal}
|
|
74
|
-
>
|
|
75
|
-
<span
|
|
76
|
-
className="openapi-explorer__code-block-expand-btn-icons"
|
|
77
|
-
aria-hidden="true"
|
|
78
|
-
>
|
|
79
|
-
<svg
|
|
80
|
-
className="openapi-explorer__code-block-expand-btn-icon"
|
|
81
|
-
viewBox="0 0 448 512"
|
|
82
|
-
>
|
|
83
|
-
<path d="M32 32C14.3 32 0 46.3 0 64v96c0 17.7 14.3 32 32 32s32-14.3 32-32V96h64c17.7 0 32-14.3 32-32s-14.3-32-32-32H32zM64 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7 14.3 32 32 32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H64V352zM320 32c-17.7 0-32 14.3-32 32s14.3 32 32 32h64v64c0 17.7 14.3 32 32 32s32-14.3 32-32V64c0-17.7-14.3-32-32-32H320zM448 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v64H320c-17.7 0-32 14.3-32 32s14.3 32 32 32h96c17.7 0 32-14.3 32-32V352z" />
|
|
84
|
-
</svg>
|
|
85
|
-
<svg
|
|
86
|
-
className="openapi-explorer__code-block-expand-btn-icon--success"
|
|
87
|
-
viewBox="0 0 24 24"
|
|
88
|
-
>
|
|
89
|
-
<path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" />
|
|
90
|
-
</svg>
|
|
91
|
-
</span>
|
|
92
|
-
</button>
|
|
93
|
-
<Modal
|
|
94
|
-
className="openapi-explorer__expand-modal-content"
|
|
95
|
-
overlayClassName="openapi-explorer__expand-modal-overlay"
|
|
96
|
-
isOpen={modalIsOpen}
|
|
97
|
-
onRequestClose={closeModal}
|
|
98
|
-
contentLabel="Code Snippet"
|
|
99
|
-
>
|
|
100
|
-
<Container
|
|
101
|
-
as="div"
|
|
102
|
-
className={clsx(
|
|
103
|
-
"openapi-explorer__code-block-container",
|
|
104
|
-
language &&
|
|
105
|
-
!blockClassName.includes(`language-${language}`) &&
|
|
106
|
-
`language-${language}`
|
|
107
|
-
)}
|
|
108
|
-
>
|
|
109
|
-
{title && (
|
|
110
|
-
<div className="openapi-explorer__code-block-title">{title}</div>
|
|
111
|
-
)}
|
|
112
|
-
<div className="openapi-explorer__code-block-content">
|
|
113
|
-
<Highlight
|
|
114
|
-
{...defaultProps}
|
|
115
|
-
theme={prismTheme}
|
|
116
|
-
code={code}
|
|
117
|
-
language={language ?? "text"}
|
|
118
|
-
>
|
|
119
|
-
{({ className, tokens, getLineProps, getTokenProps }) => (
|
|
120
|
-
<pre
|
|
121
|
-
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
|
122
|
-
tabIndex={0}
|
|
123
|
-
className={clsx(
|
|
124
|
-
className,
|
|
125
|
-
"openapi-explorer__code-block",
|
|
126
|
-
"thin-scrollbar"
|
|
127
|
-
)}
|
|
128
|
-
>
|
|
129
|
-
<code
|
|
130
|
-
className={clsx(
|
|
131
|
-
"openapi-explorer__code-block-lines",
|
|
132
|
-
showLineNumbers &&
|
|
133
|
-
"openapi-explorer__code-block-lines-numbers"
|
|
134
|
-
)}
|
|
135
|
-
>
|
|
136
|
-
{tokens.map((line, i) => (
|
|
137
|
-
<Line
|
|
138
|
-
key={i}
|
|
139
|
-
line={line}
|
|
140
|
-
getLineProps={getLineProps}
|
|
141
|
-
getTokenProps={getTokenProps}
|
|
142
|
-
classNames={lineClassNames[i]}
|
|
143
|
-
showLineNumbers={showLineNumbers}
|
|
144
|
-
/>
|
|
145
|
-
))}
|
|
146
|
-
</code>
|
|
147
|
-
</pre>
|
|
148
|
-
)}
|
|
149
|
-
</Highlight>
|
|
150
|
-
<div className="openapi-explorer__code-block-btn-group">
|
|
151
|
-
<CopyButton
|
|
152
|
-
className="openapi-explorer__code-block-code-btn"
|
|
153
|
-
code={code}
|
|
154
|
-
/>
|
|
155
|
-
<ExitButton
|
|
156
|
-
className="openapi-dmeo__code-block-code-btn"
|
|
157
|
-
handler={closeModal}
|
|
158
|
-
/>
|
|
159
|
-
</div>
|
|
160
|
-
</div>
|
|
161
|
-
</Container>
|
|
162
|
-
</Modal>
|
|
163
|
-
</>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/* Intentionally has zero specificity, so that to be able to override
|
|
2
|
-
the background in custom CSS file due bug https://github.com/facebook/docusaurus/issues/3678 */
|
|
3
|
-
:where(:root) {
|
|
4
|
-
--docusaurus-highlighted-code-line-bg: rgb(72 77 91);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
:where([data-theme="dark"]) {
|
|
8
|
-
--docusaurus-highlighted-code-line-bg: rgb(100 100 100);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.theme-code-block-highlighted-line {
|
|
12
|
-
background-color: var(--docusaurus-highlighted-code-line-bg);
|
|
13
|
-
display: block;
|
|
14
|
-
margin: 0 calc(-1 * var(--ifm-pre-padding));
|
|
15
|
-
padding: 0 var(--ifm-pre-padding);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.openapi-explorer__code-block-code-line {
|
|
19
|
-
display: table-row;
|
|
20
|
-
counter-increment: line-count;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.openapi-explorer__code-block-code-line-number {
|
|
24
|
-
display: table-cell;
|
|
25
|
-
text-align: right;
|
|
26
|
-
width: 1%;
|
|
27
|
-
position: sticky;
|
|
28
|
-
left: 0;
|
|
29
|
-
padding: 0 var(--ifm-pre-padding);
|
|
30
|
-
background: var(--ifm-pre-background);
|
|
31
|
-
overflow-wrap: normal;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.openapi-explorer__code-block-code-line-number::before {
|
|
35
|
-
content: counter(line-count);
|
|
36
|
-
opacity: 0.4;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
:global(.theme-code-block-highlighted-line)
|
|
40
|
-
.openapi-explorer__code-block-code-line-number::before {
|
|
41
|
-
opacity: 0.8;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.openapi-explorer__code-block-code-line-number {
|
|
45
|
-
padding-right: var(--ifm-pre-padding);
|
|
46
|
-
}
|