docusaurus-theme-openapi-docs 0.0.0-346 → 0.0.0-348
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/package.json +3 -3
- package/src/theme/ApiItem/styles.module.css +4 -0
- package/lib/index.js +0 -48
- package/lib/markdown/createDescription.js +0 -20
- package/lib/markdown/schema.js +0 -121
- package/lib/markdown/utils.js +0 -45
- package/lib/postman-code-generators.d.ts +0 -9
- package/lib/react-magic-dropzone.d.ts +0 -9
- package/lib/theme/ApiDemoPanel/Accept/index.js +0 -41
- package/lib/theme/ApiDemoPanel/Accept/slice.js +0 -32
- package/lib/theme/ApiDemoPanel/Authorization/auth-types.js +0 -32
- package/lib/theme/ApiDemoPanel/Authorization/index.js +0 -174
- package/lib/theme/ApiDemoPanel/Authorization/slice.js +0 -137
- package/lib/theme/ApiDemoPanel/Body/index.js +0 -185
- package/lib/theme/ApiDemoPanel/Body/slice.js +0 -105
- package/lib/theme/ApiDemoPanel/ContentType/index.js +0 -41
- package/lib/theme/ApiDemoPanel/ContentType/slice.js +0 -32
- package/lib/theme/ApiDemoPanel/Curl/index.js +0 -235
- package/lib/theme/ApiDemoPanel/Curl/styles.module.css +0 -84
- package/lib/theme/ApiDemoPanel/Execute/index.js +0 -85
- package/lib/theme/ApiDemoPanel/Execute/makeRequest.js +0 -200
- package/lib/theme/ApiDemoPanel/FloatingButton/index.js +0 -32
- package/lib/theme/ApiDemoPanel/FloatingButton/styles.module.css +0 -26
- package/lib/theme/ApiDemoPanel/FormFileUpload/index.js +0 -96
- package/lib/theme/ApiDemoPanel/FormFileUpload/styles.module.css +0 -75
- package/lib/theme/ApiDemoPanel/FormItem/index.js +0 -35
- package/lib/theme/ApiDemoPanel/FormItem/styles.module.css +0 -7
- package/lib/theme/ApiDemoPanel/FormMultiSelect/index.js +0 -52
- package/lib/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +0 -38
- package/lib/theme/ApiDemoPanel/FormSelect/index.js +0 -39
- package/lib/theme/ApiDemoPanel/FormSelect/styles.module.css +0 -51
- package/lib/theme/ApiDemoPanel/FormTextInput/index.js +0 -30
- package/lib/theme/ApiDemoPanel/FormTextInput/styles.module.css +0 -21
- package/lib/theme/ApiDemoPanel/MethodEndpoint/index.js +0 -60
- package/lib/theme/ApiDemoPanel/ParamOptions/index.js +0 -248
- package/lib/theme/ApiDemoPanel/ParamOptions/slice.js +0 -35
- package/lib/theme/ApiDemoPanel/ParamOptions/styles.module.css +0 -180
- package/lib/theme/ApiDemoPanel/Response/index.js +0 -75
- package/lib/theme/ApiDemoPanel/Response/slice.js +0 -37
- package/lib/theme/ApiDemoPanel/SecuritySchemes/index.js +0 -51
- package/lib/theme/ApiDemoPanel/Server/index.js +0 -109
- package/lib/theme/ApiDemoPanel/Server/slice.js +0 -41
- package/lib/theme/ApiDemoPanel/Server/styles.module.css +0 -61
- package/lib/theme/ApiDemoPanel/VSCode/index.js +0 -252
- package/lib/theme/ApiDemoPanel/VSCode/styles.module.css +0 -19
- package/lib/theme/ApiDemoPanel/buildPostmanRequest.js +0 -328
- package/lib/theme/ApiDemoPanel/hooks.js +0 -20
- package/lib/theme/ApiDemoPanel/index.js +0 -132
- package/lib/theme/ApiDemoPanel/persistanceMiddleware.js +0 -44
- package/lib/theme/ApiDemoPanel/postman-collection.d.ts +0 -10
- package/lib/theme/ApiDemoPanel/storage-utils.js +0 -47
- package/lib/theme/ApiDemoPanel/store.js +0 -48
- package/lib/theme/ApiDemoPanel/styles.module.css +0 -44
- package/lib/theme/ApiItem/index.js +0 -160
- package/lib/theme/ApiItem/styles.module.css +0 -109
- package/lib/theme/ApiTabs/index.js +0 -258
- package/lib/theme/ApiTabs/styles.module.css +0 -118
- package/lib/theme/ParamsItem/index.js +0 -68
- package/lib/theme/ParamsItem/styles.module.css +0 -24
- package/lib/theme/SchemaItem/index.js +0 -58
- package/lib/theme/SchemaItem/styles.module.css +0 -24
- package/lib/theme-classic.d.ts +0 -8
- package/lib/theme-openapi.d.ts +0 -48
- package/lib/theme-translations.d.ts +0 -9
- package/lib/types.js +0 -1
- package/lib-next/index.js +0 -38
- package/lib-next/markdown/createDescription.js +0 -13
- package/lib-next/markdown/schema.js +0 -115
- package/lib-next/markdown/utils.js +0 -31
- package/lib-next/postman-code-generators.d.ts +0 -9
- package/lib-next/react-magic-dropzone.d.ts +0 -9
- package/lib-next/theme/ApiDemoPanel/Accept/index.js +0 -33
- package/lib-next/theme/ApiDemoPanel/Accept/slice.js +0 -19
- package/lib-next/theme/ApiDemoPanel/Authorization/auth-types.js +0 -22
- package/lib-next/theme/ApiDemoPanel/Authorization/index.js +0 -203
- package/lib-next/theme/ApiDemoPanel/Authorization/slice.js +0 -101
- package/lib-next/theme/ApiDemoPanel/Body/index.js +0 -210
- package/lib-next/theme/ApiDemoPanel/Body/slice.js +0 -89
- package/lib-next/theme/ApiDemoPanel/ContentType/index.js +0 -33
- package/lib-next/theme/ApiDemoPanel/ContentType/slice.js +0 -19
- package/lib-next/theme/ApiDemoPanel/Curl/index.js +0 -262
- package/lib-next/theme/ApiDemoPanel/Curl/styles.module.css +0 -84
- package/lib-next/theme/ApiDemoPanel/Execute/index.js +0 -73
- package/lib-next/theme/ApiDemoPanel/Execute/makeRequest.js +0 -181
- package/lib-next/theme/ApiDemoPanel/FloatingButton/index.js +0 -19
- package/lib-next/theme/ApiDemoPanel/FloatingButton/styles.module.css +0 -26
- package/lib-next/theme/ApiDemoPanel/FormFileUpload/index.js +0 -112
- package/lib-next/theme/ApiDemoPanel/FormFileUpload/styles.module.css +0 -75
- package/lib-next/theme/ApiDemoPanel/FormItem/index.js +0 -29
- package/lib-next/theme/ApiDemoPanel/FormItem/styles.module.css +0 -7
- package/lib-next/theme/ApiDemoPanel/FormMultiSelect/index.js +0 -49
- package/lib-next/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +0 -38
- package/lib-next/theme/ApiDemoPanel/FormSelect/index.js +0 -28
- package/lib-next/theme/ApiDemoPanel/FormSelect/styles.module.css +0 -51
- package/lib-next/theme/ApiDemoPanel/FormTextInput/index.js +0 -23
- package/lib-next/theme/ApiDemoPanel/FormTextInput/styles.module.css +0 -21
- package/lib-next/theme/ApiDemoPanel/MethodEndpoint/index.js +0 -53
- package/lib-next/theme/ApiDemoPanel/ParamOptions/index.js +0 -284
- package/lib-next/theme/ApiDemoPanel/ParamOptions/slice.js +0 -22
- package/lib-next/theme/ApiDemoPanel/ParamOptions/styles.module.css +0 -180
- package/lib-next/theme/ApiDemoPanel/Response/index.js +0 -65
- package/lib-next/theme/ApiDemoPanel/Response/slice.js +0 -22
- package/lib-next/theme/ApiDemoPanel/SecuritySchemes/index.js +0 -48
- package/lib-next/theme/ApiDemoPanel/Server/index.js +0 -114
- package/lib-next/theme/ApiDemoPanel/Server/slice.js +0 -25
- package/lib-next/theme/ApiDemoPanel/Server/styles.module.css +0 -61
- package/lib-next/theme/ApiDemoPanel/VSCode/index.js +0 -265
- package/lib-next/theme/ApiDemoPanel/VSCode/styles.module.css +0 -19
- package/lib-next/theme/ApiDemoPanel/buildPostmanRequest.js +0 -309
- package/lib-next/theme/ApiDemoPanel/hooks.js +0 -9
- package/lib-next/theme/ApiDemoPanel/index.js +0 -108
- package/lib-next/theme/ApiDemoPanel/persistanceMiddleware.js +0 -38
- package/lib-next/theme/ApiDemoPanel/postman-collection.d.ts +0 -10
- package/lib-next/theme/ApiDemoPanel/storage-utils.js +0 -35
- package/lib-next/theme/ApiDemoPanel/store.js +0 -30
- package/lib-next/theme/ApiDemoPanel/styles.module.css +0 -44
- package/lib-next/theme/ApiItem/index.js +0 -171
- package/lib-next/theme/ApiItem/styles.module.css +0 -109
- package/lib-next/theme/ApiTabs/index.js +0 -258
- package/lib-next/theme/ApiTabs/styles.module.css +0 -118
- package/lib-next/theme/ParamsItem/index.js +0 -68
- package/lib-next/theme/ParamsItem/styles.module.css +0 -24
- package/lib-next/theme/SchemaItem/index.js +0 -58
- package/lib-next/theme/SchemaItem/styles.module.css +0 -24
- package/lib-next/theme-classic.d.ts +0 -8
- package/lib-next/theme-openapi.d.ts +0 -48
- package/lib-next/theme-translations.d.ts +0 -9
- package/lib-next/types.js +0 -1
- package/yarn-error.log +0 -15035
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
var _FloatingButton = _interopRequireDefault(require("../FloatingButton"));
|
|
11
|
-
|
|
12
|
-
var _hooks = require("../hooks");
|
|
13
|
-
|
|
14
|
-
var _FormItem = _interopRequireDefault(require("./../FormItem"));
|
|
15
|
-
|
|
16
|
-
var _FormSelect = _interopRequireDefault(require("./../FormSelect"));
|
|
17
|
-
|
|
18
|
-
var _FormTextInput = _interopRequireDefault(require("./../FormTextInput"));
|
|
19
|
-
|
|
20
|
-
var _slice = require("./slice");
|
|
21
|
-
|
|
22
|
-
var _stylesModule = _interopRequireDefault(require("./styles.module.css"));
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
-
|
|
30
|
-
/* ============================================================================
|
|
31
|
-
* Copyright (c) Palo Alto Networks
|
|
32
|
-
*
|
|
33
|
-
* This source code is licensed under the MIT license found in the
|
|
34
|
-
* LICENSE file in the root directory of this source tree.
|
|
35
|
-
* ========================================================================== */
|
|
36
|
-
function Server() {
|
|
37
|
-
const [isEditing, setIsEditing] = (0, _react.useState)(false);
|
|
38
|
-
const value = (0, _hooks.useTypedSelector)(state => state.server.value);
|
|
39
|
-
const options = (0, _hooks.useTypedSelector)(state => state.server.options);
|
|
40
|
-
const dispatch = (0, _hooks.useTypedDispatch)();
|
|
41
|
-
|
|
42
|
-
if (options.length <= 0) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (options.length <= 1 && (value === null || value === void 0 ? void 0 : value.variables) === undefined) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (!isEditing) {
|
|
51
|
-
let url = "";
|
|
52
|
-
|
|
53
|
-
if (value) {
|
|
54
|
-
url = value.url.replace(/\/$/, "");
|
|
55
|
-
|
|
56
|
-
if (value.variables) {
|
|
57
|
-
Object.keys(value.variables).forEach(variable => {
|
|
58
|
-
var _value$variables$vari, _value$variables;
|
|
59
|
-
|
|
60
|
-
url = url.replace(`{${variable}}`, (_value$variables$vari = (_value$variables = value.variables) === null || _value$variables === void 0 ? void 0 : _value$variables[variable].default) !== null && _value$variables$vari !== void 0 ? _value$variables$vari : "");
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return <_FloatingButton.default onClick={() => setIsEditing(true)} label="Edit">
|
|
66
|
-
<pre style={{
|
|
67
|
-
background: "var(--openapi-card-background-color)",
|
|
68
|
-
paddingRight: "60px"
|
|
69
|
-
}}>
|
|
70
|
-
<code>{url}</code>
|
|
71
|
-
</pre>
|
|
72
|
-
</_FloatingButton.default>;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return <div className={_stylesModule.default.optionsPanel}>
|
|
76
|
-
<button className={_stylesModule.default.showMoreButton} onClick={() => setIsEditing(false)}>
|
|
77
|
-
Hide
|
|
78
|
-
</button>
|
|
79
|
-
<_FormItem.default label="Endpoint">
|
|
80
|
-
<_FormSelect.default options={options.map(s => s.url)} onChange={e => dispatch((0, _slice.setServer)(e.target.value))} />
|
|
81
|
-
</_FormItem.default>
|
|
82
|
-
{(value === null || value === void 0 ? void 0 : value.variables) && Object.keys(value.variables).map(key => {
|
|
83
|
-
var _value$variables2, _value$variables3;
|
|
84
|
-
|
|
85
|
-
if (((_value$variables2 = value.variables) === null || _value$variables2 === void 0 ? void 0 : _value$variables2[key].enum) !== undefined) {
|
|
86
|
-
return <_FormItem.default label={key}>
|
|
87
|
-
<_FormSelect.default options={value.variables[key].enum} onChange={e => {
|
|
88
|
-
dispatch((0, _slice.setServerVariable)({
|
|
89
|
-
key,
|
|
90
|
-
value: e.target.value
|
|
91
|
-
}));
|
|
92
|
-
}} />
|
|
93
|
-
</_FormItem.default>;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return <_FormItem.default label={key}>
|
|
97
|
-
<_FormTextInput.default placeholder={(_value$variables3 = value.variables) === null || _value$variables3 === void 0 ? void 0 : _value$variables3[key].default} onChange={e => {
|
|
98
|
-
dispatch((0, _slice.setServerVariable)({
|
|
99
|
-
key,
|
|
100
|
-
value: e.target.value
|
|
101
|
-
}));
|
|
102
|
-
}} />
|
|
103
|
-
</_FormItem.default>;
|
|
104
|
-
})}
|
|
105
|
-
</div>;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
var _default = Server;
|
|
109
|
-
exports.default = _default;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.slice = exports.setServerVariable = exports.setServer = exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _toolkit = require("@reduxjs/toolkit");
|
|
9
|
-
|
|
10
|
-
/* ============================================================================
|
|
11
|
-
* Copyright (c) Palo Alto Networks
|
|
12
|
-
*
|
|
13
|
-
* This source code is licensed under the MIT license found in the
|
|
14
|
-
* LICENSE file in the root directory of this source tree.
|
|
15
|
-
* ========================================================================== */
|
|
16
|
-
const initialState = {};
|
|
17
|
-
const slice = (0, _toolkit.createSlice)({
|
|
18
|
-
name: "server",
|
|
19
|
-
initialState,
|
|
20
|
-
reducers: {
|
|
21
|
-
setServer: (state, action) => {
|
|
22
|
-
state.value = state.options.find(s => s.url === action.payload);
|
|
23
|
-
},
|
|
24
|
-
setServerVariable: (state, action) => {
|
|
25
|
-
var _state$value;
|
|
26
|
-
|
|
27
|
-
if ((_state$value = state.value) !== null && _state$value !== void 0 && _state$value.variables) {
|
|
28
|
-
state.value.variables[action.payload.key].default = action.payload.value;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
exports.slice = slice;
|
|
34
|
-
const {
|
|
35
|
-
setServer,
|
|
36
|
-
setServerVariable
|
|
37
|
-
} = slice.actions;
|
|
38
|
-
exports.setServerVariable = setServerVariable;
|
|
39
|
-
exports.setServer = setServer;
|
|
40
|
-
var _default = slice.reducer;
|
|
41
|
-
exports.default = _default;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
.showMoreButton {
|
|
2
|
-
-webkit-appearance: none;
|
|
3
|
-
-moz-appearance: none;
|
|
4
|
-
appearance: none;
|
|
5
|
-
|
|
6
|
-
cursor: pointer;
|
|
7
|
-
font-size: var(--ifm-code-font-size);
|
|
8
|
-
/* font-weight: var(--ifm-button-font-weight); */
|
|
9
|
-
/* line-height: 1.5; */
|
|
10
|
-
|
|
11
|
-
padding: 0;
|
|
12
|
-
|
|
13
|
-
user-select: none;
|
|
14
|
-
white-space: nowrap;
|
|
15
|
-
|
|
16
|
-
border: 0px solid transparent;
|
|
17
|
-
|
|
18
|
-
display: block;
|
|
19
|
-
/* width: 100%; */
|
|
20
|
-
|
|
21
|
-
background-color: transparent;
|
|
22
|
-
|
|
23
|
-
color: var(--ifm-color-primary);
|
|
24
|
-
cursor: pointer;
|
|
25
|
-
margin-top: var(--ifm-pre-padding);
|
|
26
|
-
margin-bottom: 0;
|
|
27
|
-
text-align: left;
|
|
28
|
-
display: block;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.showMoreButton:focus {
|
|
32
|
-
outline: 0;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.showMoreButton:hover {
|
|
36
|
-
/* text-decoration: underline; */
|
|
37
|
-
/* background-color: red; */
|
|
38
|
-
color: var(--ifm-color-primary-hover);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.showMoreButton:first-child {
|
|
42
|
-
margin-top: 0;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.optionsPanel:empty {
|
|
46
|
-
display: none;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.optionsPanel {
|
|
50
|
-
background: var(--openapi-card-background-color);
|
|
51
|
-
border-radius: var(--openapi-card-border-radius);
|
|
52
|
-
color: var(--ifm-pre-color);
|
|
53
|
-
line-height: var(--ifm-pre-line-height);
|
|
54
|
-
margin-bottom: var(--ifm-spacing-vertical);
|
|
55
|
-
margin-top: 0;
|
|
56
|
-
overflow: auto;
|
|
57
|
-
padding: var(--ifm-pre-padding);
|
|
58
|
-
|
|
59
|
-
/* hack for view calculation when monaco is hidden */
|
|
60
|
-
position: relative;
|
|
61
|
-
}
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
var _themeCommon = require("@docusaurus/theme-common");
|
|
11
|
-
|
|
12
|
-
var _react2 = _interopRequireDefault(require("@monaco-editor/react"));
|
|
13
|
-
|
|
14
|
-
var _stylesModule = _interopRequireDefault(require("./styles.module.css"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
|
|
20
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
|
|
22
|
-
/* ============================================================================
|
|
23
|
-
* Copyright (c) Palo Alto Networks
|
|
24
|
-
*
|
|
25
|
-
* This source code is licensed under the MIT license found in the
|
|
26
|
-
* LICENSE file in the root directory of this source tree.
|
|
27
|
-
* ========================================================================== */
|
|
28
|
-
function VSCode({
|
|
29
|
-
value,
|
|
30
|
-
language,
|
|
31
|
-
onChange
|
|
32
|
-
}) {
|
|
33
|
-
var _ref;
|
|
34
|
-
|
|
35
|
-
const [focused, setFocused] = (0, _react.useState)(false);
|
|
36
|
-
const isDarkTheme = (_ref = (0, _themeCommon.useColorMode)().colorMode === "dark") !== null && _ref !== void 0 ? _ref : false;
|
|
37
|
-
|
|
38
|
-
function handleEditorWillMount(monaco) {
|
|
39
|
-
const styles = getComputedStyle(document.documentElement);
|
|
40
|
-
|
|
41
|
-
function getColor(property) {
|
|
42
|
-
// Weird chrome bug, returns " #ffffff " instead of "#ffffff", see: https://github.com/cloud-annotations/docusaurus-openapi/issues/144
|
|
43
|
-
const color = styles.getPropertyValue(property).trim();
|
|
44
|
-
const isColorRgb = color.includes("rgb");
|
|
45
|
-
const isColorHexShortened = color.length === 4; // Convert "rgb(r, g, b)" to color hex code
|
|
46
|
-
|
|
47
|
-
const getColorHex = color => {
|
|
48
|
-
const rgbValues = color.substring(4).split(")")[0].split(",");
|
|
49
|
-
const [r, g, b] = rgbValues;
|
|
50
|
-
|
|
51
|
-
const colorToHex = rgb => {
|
|
52
|
-
const hexadecimal = parseInt(rgb).toString(16);
|
|
53
|
-
return hexadecimal.length === 1 ? "0" + hexadecimal : hexadecimal;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
return "#" + colorToHex(r) + colorToHex(g) + colorToHex(b);
|
|
57
|
-
}; // Extend shortened hex codes ie. "#aaa" => "#aaaaaa" or "#xyz" => "#xxyyzz"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const getFullColorHex = color => {
|
|
61
|
-
let fullColorHex = "#";
|
|
62
|
-
const hexValues = color.slice(1);
|
|
63
|
-
|
|
64
|
-
for (let i = 0; i < hexValues.length; i++) {
|
|
65
|
-
for (let j = 0; j < 2; j++) {
|
|
66
|
-
fullColorHex += hexValues[i];
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return fullColorHex.toLowerCase();
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
if (isColorRgb) {
|
|
74
|
-
return getColorHex(color);
|
|
75
|
-
} else if (isColorHexShortened) {
|
|
76
|
-
return getFullColorHex(color);
|
|
77
|
-
} else {
|
|
78
|
-
return color;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const LIGHT_BACKGROUND = getColor("--openapi-monaco-background-color-light");
|
|
83
|
-
const LIGHT_BRIGHT = getColor("--openapi-code-bright-light");
|
|
84
|
-
const LIGHT_DIM = getColor("--openapi-code-dim-light");
|
|
85
|
-
const LIGHT_BLUE = getColor("--openapi-code-blue-light");
|
|
86
|
-
const LIGHT_GREEN = getColor("--openapi-code-green-light");
|
|
87
|
-
const LIGHT_SELECT = getColor("--openapi-code-select-light");
|
|
88
|
-
const DARK_BACKGROUND = getColor("--openapi-monaco-background-color-dark");
|
|
89
|
-
const DARK_BRIGHT = getColor("--openapi-code-bright-dark");
|
|
90
|
-
const DARK_DIM = getColor("--openapi-code-dim-dark");
|
|
91
|
-
const DARK_BLUE = getColor("--openapi-code-blue-dark");
|
|
92
|
-
const DARK_GREEN = getColor("--openapi-code-green-dark");
|
|
93
|
-
const DARK_SELECT = getColor("--openapi-code-select-dark");
|
|
94
|
-
monaco.editor.defineTheme("OpenApiDark", {
|
|
95
|
-
base: "vs-dark",
|
|
96
|
-
inherit: true,
|
|
97
|
-
rules: [{
|
|
98
|
-
token: "",
|
|
99
|
-
foreground: DARK_BRIGHT
|
|
100
|
-
}, {
|
|
101
|
-
token: "string.key.json",
|
|
102
|
-
foreground: DARK_BRIGHT
|
|
103
|
-
}, {
|
|
104
|
-
token: "string.value.json",
|
|
105
|
-
foreground: DARK_GREEN
|
|
106
|
-
}, {
|
|
107
|
-
token: "number",
|
|
108
|
-
foreground: DARK_BLUE
|
|
109
|
-
}, {
|
|
110
|
-
token: "keyword.json",
|
|
111
|
-
foreground: DARK_BLUE
|
|
112
|
-
}, {
|
|
113
|
-
token: "delimiter",
|
|
114
|
-
foreground: DARK_DIM
|
|
115
|
-
}, {
|
|
116
|
-
token: "tag.xml",
|
|
117
|
-
foreground: DARK_DIM
|
|
118
|
-
}, {
|
|
119
|
-
token: "metatag.xml",
|
|
120
|
-
foreground: DARK_DIM
|
|
121
|
-
}, {
|
|
122
|
-
token: "attribute.name.xml",
|
|
123
|
-
foreground: DARK_BRIGHT
|
|
124
|
-
}, {
|
|
125
|
-
token: "attribute.value.xml",
|
|
126
|
-
foreground: DARK_GREEN
|
|
127
|
-
}, {
|
|
128
|
-
token: "metatag.xml",
|
|
129
|
-
foreground: DARK_BLUE
|
|
130
|
-
}, {
|
|
131
|
-
token: "tag.xml",
|
|
132
|
-
foreground: DARK_BLUE
|
|
133
|
-
}],
|
|
134
|
-
colors: {
|
|
135
|
-
"editor.background": DARK_BACKGROUND,
|
|
136
|
-
"editor.lineHighlightBackground": DARK_BACKGROUND,
|
|
137
|
-
"editorBracketMatch.background": DARK_BACKGROUND,
|
|
138
|
-
"editorBracketMatch.border": DARK_BACKGROUND,
|
|
139
|
-
"editor.selectionBackground": DARK_SELECT
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
monaco.editor.defineTheme("OpenApiLight", {
|
|
143
|
-
base: "vs",
|
|
144
|
-
inherit: true,
|
|
145
|
-
rules: [{
|
|
146
|
-
token: "",
|
|
147
|
-
foreground: LIGHT_BRIGHT
|
|
148
|
-
}, {
|
|
149
|
-
token: "string.key.json",
|
|
150
|
-
foreground: LIGHT_BRIGHT
|
|
151
|
-
}, {
|
|
152
|
-
token: "string.value.json",
|
|
153
|
-
foreground: LIGHT_GREEN
|
|
154
|
-
}, {
|
|
155
|
-
token: "number",
|
|
156
|
-
foreground: LIGHT_BLUE
|
|
157
|
-
}, {
|
|
158
|
-
token: "keyword.json",
|
|
159
|
-
foreground: LIGHT_BLUE
|
|
160
|
-
}, {
|
|
161
|
-
token: "delimiter",
|
|
162
|
-
foreground: LIGHT_DIM
|
|
163
|
-
}, {
|
|
164
|
-
token: "tag.xml",
|
|
165
|
-
foreground: LIGHT_DIM
|
|
166
|
-
}, {
|
|
167
|
-
token: "metatag.xml",
|
|
168
|
-
foreground: LIGHT_DIM
|
|
169
|
-
}, {
|
|
170
|
-
token: "attribute.name.xml",
|
|
171
|
-
foreground: LIGHT_BRIGHT
|
|
172
|
-
}, {
|
|
173
|
-
token: "attribute.value.xml",
|
|
174
|
-
foreground: LIGHT_GREEN
|
|
175
|
-
}, {
|
|
176
|
-
token: "metatag.xml",
|
|
177
|
-
foreground: LIGHT_BLUE
|
|
178
|
-
}, {
|
|
179
|
-
token: "tag.xml",
|
|
180
|
-
foreground: LIGHT_BLUE
|
|
181
|
-
}],
|
|
182
|
-
colors: {
|
|
183
|
-
"editor.background": LIGHT_BACKGROUND,
|
|
184
|
-
"editor.lineHighlightBackground": LIGHT_BACKGROUND,
|
|
185
|
-
"editorBracketMatch.background": LIGHT_BACKGROUND,
|
|
186
|
-
"editorBracketMatch.border": LIGHT_BACKGROUND,
|
|
187
|
-
"editor.selectionBackground": LIGHT_SELECT
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return <div className={focused ? _stylesModule.default.monacoFocus : _stylesModule.default.monaco}>
|
|
193
|
-
<_react2.default value={value} language={language} theme={isDarkTheme ? "OpenApiDark" : "OpenApiLight"} beforeMount={handleEditorWillMount} options={{
|
|
194
|
-
lineNumbers: "off",
|
|
195
|
-
scrollBeyondLastLine: false,
|
|
196
|
-
scrollBeyondLastColumn: 3,
|
|
197
|
-
readOnly: false,
|
|
198
|
-
minimap: {
|
|
199
|
-
enabled: false
|
|
200
|
-
},
|
|
201
|
-
fontFamily: "SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace",
|
|
202
|
-
fontSize: 14.4,
|
|
203
|
-
overviewRulerLanes: 0,
|
|
204
|
-
folding: false,
|
|
205
|
-
lineDecorationsWidth: 0,
|
|
206
|
-
contextmenu: false,
|
|
207
|
-
scrollbar: {
|
|
208
|
-
horizontal: "hidden"
|
|
209
|
-
}
|
|
210
|
-
}} onMount={editor => {
|
|
211
|
-
editor.onDidFocusEditorText(() => {
|
|
212
|
-
setFocused(true);
|
|
213
|
-
});
|
|
214
|
-
editor.onDidBlurEditorText(() => {
|
|
215
|
-
setFocused(false);
|
|
216
|
-
});
|
|
217
|
-
editor.onDidChangeModelDecorations(() => {
|
|
218
|
-
updateEditorHeight(); // typing
|
|
219
|
-
|
|
220
|
-
requestAnimationFrame(updateEditorHeight); // folding
|
|
221
|
-
});
|
|
222
|
-
let prevHeight = 0;
|
|
223
|
-
|
|
224
|
-
const updateEditorHeight = () => {
|
|
225
|
-
var _editor$getModel;
|
|
226
|
-
|
|
227
|
-
onChange(editor.getValue());
|
|
228
|
-
const editorElement = editor.getDomNode();
|
|
229
|
-
|
|
230
|
-
if (!editorElement) {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const lineHeight = 22;
|
|
235
|
-
const lineCount = ((_editor$getModel = editor.getModel()) === null || _editor$getModel === void 0 ? void 0 : _editor$getModel.getLineCount()) || 1;
|
|
236
|
-
const height = editor.getTopForLineNumber(lineCount + 1) + lineHeight;
|
|
237
|
-
const clippedHeight = Math.min(height, 500);
|
|
238
|
-
|
|
239
|
-
if (prevHeight !== clippedHeight) {
|
|
240
|
-
prevHeight = clippedHeight;
|
|
241
|
-
editorElement.style.height = `${clippedHeight}px`;
|
|
242
|
-
editor.layout();
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
updateEditorHeight();
|
|
247
|
-
}} />
|
|
248
|
-
</div>;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
var _default = VSCode;
|
|
252
|
-
exports.default = _default;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
.monacoBase {
|
|
2
|
-
margin-top: calc(var(--ifm-pre-padding) / 2);
|
|
3
|
-
border-radius: 4px;
|
|
4
|
-
padding: var(--ifm-pre-padding);
|
|
5
|
-
background-color: var(--openapi-monaco-background-color);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.monaco {
|
|
9
|
-
composes: monacoBase;
|
|
10
|
-
|
|
11
|
-
box-shadow: 0 0 0 1px var(--openapi-monaco-border-color);
|
|
12
|
-
border: 2px solid transparent;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.monacoFocus {
|
|
16
|
-
composes: monacoBase;
|
|
17
|
-
|
|
18
|
-
border: 2px solid var(--openapi-input-border);
|
|
19
|
-
}
|