docusaurus-theme-openapi-docs 1.0.3 → 1.0.6

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.
Files changed (46) hide show
  1. package/lib/theme/ApiDemoPanel/Body/index.js +11 -9
  2. package/lib/theme/ApiDemoPanel/Body/json2xml.js +43 -0
  3. package/lib/theme/ApiDemoPanel/CodeTabs/index.js +188 -0
  4. package/lib/theme/ApiDemoPanel/CodeTabs/styles.module.css +11 -0
  5. package/lib/theme/ApiDemoPanel/Curl/index.js +41 -110
  6. package/lib/theme/ApiDemoPanel/LiveEditor/index.js +61 -0
  7. package/lib/theme/ApiDemoPanel/LiveEditor/styles.module.css +34 -0
  8. package/lib/theme/ApiItem/icons/bash-original.svg +1 -0
  9. package/lib/theme/ApiItem/icons/go-original-wordmark.svg +1 -0
  10. package/lib/theme/ApiItem/icons/javascript-original.svg +1 -0
  11. package/lib/theme/ApiItem/icons/linux-original.svg +1 -0
  12. package/lib/theme/ApiItem/icons/python-original.svg +1 -0
  13. package/lib/theme/ApiItem/styles.module.css +89 -0
  14. package/lib-next/theme/ApiDemoPanel/Body/index.js +11 -15
  15. package/lib-next/theme/ApiDemoPanel/Body/json2xml.js +43 -0
  16. package/lib-next/theme/ApiDemoPanel/CodeTabs/index.js +214 -0
  17. package/lib-next/theme/ApiDemoPanel/CodeTabs/styles.module.css +11 -0
  18. package/lib-next/theme/ApiDemoPanel/Curl/index.js +46 -135
  19. package/lib-next/theme/ApiDemoPanel/LiveEditor/index.js +49 -0
  20. package/lib-next/theme/ApiDemoPanel/LiveEditor/styles.module.css +34 -0
  21. package/lib-next/theme/ApiItem/icons/bash-original.svg +1 -0
  22. package/lib-next/theme/ApiItem/icons/go-original-wordmark.svg +1 -0
  23. package/lib-next/theme/ApiItem/icons/javascript-original.svg +1 -0
  24. package/lib-next/theme/ApiItem/icons/linux-original.svg +1 -0
  25. package/lib-next/theme/ApiItem/icons/python-original.svg +1 -0
  26. package/lib-next/theme/ApiItem/styles.module.css +89 -0
  27. package/package.json +4 -6
  28. package/src/theme/ApiDemoPanel/Body/index.tsx +9 -13
  29. package/src/theme/ApiDemoPanel/Body/json2xml.js +43 -0
  30. package/src/theme/ApiDemoPanel/CodeTabs/index.tsx +237 -0
  31. package/src/theme/ApiDemoPanel/CodeTabs/styles.module.css +11 -0
  32. package/src/theme/ApiDemoPanel/Curl/index.tsx +45 -124
  33. package/src/theme/ApiDemoPanel/LiveEditor/index.tsx +59 -0
  34. package/src/theme/ApiDemoPanel/LiveEditor/styles.module.css +34 -0
  35. package/src/theme/ApiItem/icons/bash-original.svg +1 -0
  36. package/src/theme/ApiItem/icons/go-original-wordmark.svg +1 -0
  37. package/src/theme/ApiItem/icons/javascript-original.svg +1 -0
  38. package/src/theme/ApiItem/icons/linux-original.svg +1 -0
  39. package/src/theme/ApiItem/icons/python-original.svg +1 -0
  40. package/src/theme/ApiItem/styles.module.css +89 -0
  41. package/lib/theme/ApiDemoPanel/VSCode/index.js +0 -252
  42. package/lib/theme/ApiDemoPanel/VSCode/styles.module.css +0 -19
  43. package/lib-next/theme/ApiDemoPanel/VSCode/index.js +0 -265
  44. package/lib-next/theme/ApiDemoPanel/VSCode/styles.module.css +0 -19
  45. package/src/theme/ApiDemoPanel/VSCode/index.tsx +0 -205
  46. package/src/theme/ApiDemoPanel/VSCode/styles.module.css +0 -19
@@ -11,6 +11,23 @@
11
11
  margin-top: 0;
12
12
  }
13
13
 
14
+ :global(.version-button div) {
15
+ display: block;
16
+ }
17
+
18
+ :global(.version-button div > button > span::after) {
19
+ border-color: currentcolor transparent;
20
+ border-style: solid;
21
+ border-width: 0.4em 0.4em 0;
22
+ content: "";
23
+ margin-left: 0.3em;
24
+ position: relative;
25
+ transform: translateY(-50%);
26
+ display: inline-block;
27
+ font-size: 0.8rem;
28
+ top: 1px;
29
+ }
30
+
14
31
  /* default markdown margins look really silly in a table */
15
32
  :global(.theme-api-markdown table *:last-child) {
16
33
  margin-bottom: 0;
@@ -111,3 +128,75 @@
111
128
  margin-top: 0 !important;
112
129
  padding-left: 2px;
113
130
  }
131
+
132
+ :global(.code__tab--python::after) {
133
+ content: "";
134
+ width: 32px;
135
+ height: 32px;
136
+ background: url(./icons/python-original.svg);
137
+ margin-block: auto;
138
+ }
139
+
140
+ :global(.code__tab--python) {
141
+ color: var(--ifm-color-success);
142
+ padding-left: 2rem;
143
+ padding-right: 2rem;
144
+ }
145
+
146
+ :global(.code__tab--python.tabs__item--active) {
147
+ border-bottom-color: var(--ifm-color-success);
148
+ }
149
+
150
+ :global(.code__tab--go::after) {
151
+ content: "";
152
+ width: 32px;
153
+ height: 32px;
154
+ background: url(./icons/go-original-wordmark.svg);
155
+ margin-block: auto;
156
+ }
157
+
158
+ :global(.code__tab--go) {
159
+ color: var(--ifm-color-info);
160
+ padding-left: 2rem;
161
+ padding-right: 2rem;
162
+ }
163
+
164
+ :global(.code__tab--go.tabs__item--active) {
165
+ border-bottom-color: var(--ifm-color-info);
166
+ }
167
+
168
+ :global(.code__tab--javascript::after) {
169
+ content: "";
170
+ width: 32px;
171
+ height: 32px;
172
+ background: url(./icons/javascript-original.svg);
173
+ margin-block: auto;
174
+ }
175
+
176
+ :global(.code__tab--javascript) {
177
+ color: var(--ifm-color-warning);
178
+ padding-left: 2rem;
179
+ padding-right: 2rem;
180
+ }
181
+
182
+ :global(.code__tab--javascript.tabs__item--active) {
183
+ border-bottom-color: var(--ifm-color-warning);
184
+ }
185
+
186
+ :global(.code__tab--bash::after) {
187
+ content: "";
188
+ width: 32px;
189
+ height: 32px;
190
+ background: url(./icons/linux-original.svg);
191
+ margin-block: auto;
192
+ }
193
+
194
+ :global(.code__tab--bash) {
195
+ color: var(--ifm-color-danger);
196
+ padding-left: 2rem;
197
+ padding-right: 2rem;
198
+ }
199
+
200
+ :global(.code__tab--bash.tabs__item--active) {
201
+ border-bottom-color: var(--ifm-color-danger);
202
+ }
@@ -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
- }
@@ -1,265 +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
- import React, { useState } from "react";
8
- import { useColorMode } from "@docusaurus/theme-common";
9
- import Editor from "@monaco-editor/react";
10
- import styles from "./styles.module.css";
11
-
12
- function VSCode({ value, language, onChange }) {
13
- const [focused, setFocused] = useState(false);
14
- const isDarkTheme = useColorMode().colorMode === "dark" ?? false;
15
-
16
- function handleEditorWillMount(monaco) {
17
- const styles = getComputedStyle(document.documentElement);
18
-
19
- function getColor(property) {
20
- // Weird chrome bug, returns " #ffffff " instead of "#ffffff", see: https://github.com/cloud-annotations/docusaurus-openapi/issues/144
21
- const color = styles.getPropertyValue(property).trim();
22
- const isColorRgb = color.includes("rgb");
23
- const isColorHexShortened = color.length === 4; // Convert "rgb(r, g, b)" to color hex code
24
-
25
- const getColorHex = (color) => {
26
- const rgbValues = color.substring(4).split(")")[0].split(",");
27
- const [r, g, b] = rgbValues;
28
-
29
- const colorToHex = (rgb) => {
30
- const hexadecimal = parseInt(rgb).toString(16);
31
- return hexadecimal.length === 1 ? "0" + hexadecimal : hexadecimal;
32
- };
33
-
34
- return "#" + colorToHex(r) + colorToHex(g) + colorToHex(b);
35
- }; // Extend shortened hex codes ie. "#aaa" => "#aaaaaa" or "#xyz" => "#xxyyzz"
36
-
37
- const getFullColorHex = (color) => {
38
- let fullColorHex = "#";
39
- const hexValues = color.slice(1);
40
-
41
- for (let i = 0; i < hexValues.length; i++) {
42
- for (let j = 0; j < 2; j++) {
43
- fullColorHex += hexValues[i];
44
- }
45
- }
46
-
47
- return fullColorHex.toLowerCase();
48
- };
49
-
50
- if (isColorRgb) {
51
- return getColorHex(color);
52
- } else if (isColorHexShortened) {
53
- return getFullColorHex(color);
54
- } else {
55
- return color;
56
- }
57
- }
58
-
59
- const LIGHT_BACKGROUND = getColor(
60
- "--openapi-monaco-background-color-light"
61
- );
62
- const LIGHT_BRIGHT = getColor("--openapi-code-bright-light");
63
- const LIGHT_DIM = getColor("--openapi-code-dim-light");
64
- const LIGHT_BLUE = getColor("--openapi-code-blue-light");
65
- const LIGHT_GREEN = getColor("--openapi-code-green-light");
66
- const LIGHT_SELECT = getColor("--openapi-code-select-light");
67
- const DARK_BACKGROUND = getColor("--openapi-monaco-background-color-dark");
68
- const DARK_BRIGHT = getColor("--openapi-code-bright-dark");
69
- const DARK_DIM = getColor("--openapi-code-dim-dark");
70
- const DARK_BLUE = getColor("--openapi-code-blue-dark");
71
- const DARK_GREEN = getColor("--openapi-code-green-dark");
72
- const DARK_SELECT = getColor("--openapi-code-select-dark");
73
- monaco.editor.defineTheme("OpenApiDark", {
74
- base: "vs-dark",
75
- inherit: true,
76
- rules: [
77
- {
78
- token: "",
79
- foreground: DARK_BRIGHT,
80
- },
81
- {
82
- token: "string.key.json",
83
- foreground: DARK_BRIGHT,
84
- },
85
- {
86
- token: "string.value.json",
87
- foreground: DARK_GREEN,
88
- },
89
- {
90
- token: "number",
91
- foreground: DARK_BLUE,
92
- },
93
- {
94
- token: "keyword.json",
95
- foreground: DARK_BLUE,
96
- },
97
- {
98
- token: "delimiter",
99
- foreground: DARK_DIM,
100
- },
101
- {
102
- token: "tag.xml",
103
- foreground: DARK_DIM,
104
- },
105
- {
106
- token: "metatag.xml",
107
- foreground: DARK_DIM,
108
- },
109
- {
110
- token: "attribute.name.xml",
111
- foreground: DARK_BRIGHT,
112
- },
113
- {
114
- token: "attribute.value.xml",
115
- foreground: DARK_GREEN,
116
- },
117
- {
118
- token: "metatag.xml",
119
- foreground: DARK_BLUE,
120
- },
121
- {
122
- token: "tag.xml",
123
- foreground: DARK_BLUE,
124
- },
125
- ],
126
- colors: {
127
- "editor.background": DARK_BACKGROUND,
128
- "editor.lineHighlightBackground": DARK_BACKGROUND,
129
- "editorBracketMatch.background": DARK_BACKGROUND,
130
- "editorBracketMatch.border": DARK_BACKGROUND,
131
- "editor.selectionBackground": DARK_SELECT,
132
- },
133
- });
134
- monaco.editor.defineTheme("OpenApiLight", {
135
- base: "vs",
136
- inherit: true,
137
- rules: [
138
- {
139
- token: "",
140
- foreground: LIGHT_BRIGHT,
141
- },
142
- {
143
- token: "string.key.json",
144
- foreground: LIGHT_BRIGHT,
145
- },
146
- {
147
- token: "string.value.json",
148
- foreground: LIGHT_GREEN,
149
- },
150
- {
151
- token: "number",
152
- foreground: LIGHT_BLUE,
153
- },
154
- {
155
- token: "keyword.json",
156
- foreground: LIGHT_BLUE,
157
- },
158
- {
159
- token: "delimiter",
160
- foreground: LIGHT_DIM,
161
- },
162
- {
163
- token: "tag.xml",
164
- foreground: LIGHT_DIM,
165
- },
166
- {
167
- token: "metatag.xml",
168
- foreground: LIGHT_DIM,
169
- },
170
- {
171
- token: "attribute.name.xml",
172
- foreground: LIGHT_BRIGHT,
173
- },
174
- {
175
- token: "attribute.value.xml",
176
- foreground: LIGHT_GREEN,
177
- },
178
- {
179
- token: "metatag.xml",
180
- foreground: LIGHT_BLUE,
181
- },
182
- {
183
- token: "tag.xml",
184
- foreground: LIGHT_BLUE,
185
- },
186
- ],
187
- colors: {
188
- "editor.background": LIGHT_BACKGROUND,
189
- "editor.lineHighlightBackground": LIGHT_BACKGROUND,
190
- "editorBracketMatch.background": LIGHT_BACKGROUND,
191
- "editorBracketMatch.border": LIGHT_BACKGROUND,
192
- "editor.selectionBackground": LIGHT_SELECT,
193
- },
194
- });
195
- }
196
-
197
- return (
198
- <div className={focused ? styles.monacoFocus : styles.monaco}>
199
- <Editor
200
- value={value}
201
- language={language}
202
- theme={isDarkTheme ? "OpenApiDark" : "OpenApiLight"}
203
- beforeMount={handleEditorWillMount}
204
- options={{
205
- lineNumbers: "off",
206
- scrollBeyondLastLine: false,
207
- scrollBeyondLastColumn: 3,
208
- readOnly: false,
209
- minimap: {
210
- enabled: false,
211
- },
212
- fontFamily:
213
- "SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace",
214
- fontSize: 14.4,
215
- overviewRulerLanes: 0,
216
- folding: false,
217
- lineDecorationsWidth: 0,
218
- contextmenu: false,
219
- scrollbar: {
220
- horizontal: "hidden",
221
- },
222
- }}
223
- onMount={(editor) => {
224
- editor.onDidFocusEditorText(() => {
225
- setFocused(true);
226
- });
227
- editor.onDidBlurEditorText(() => {
228
- setFocused(false);
229
- });
230
- editor.onDidChangeModelDecorations(() => {
231
- updateEditorHeight(); // typing
232
-
233
- requestAnimationFrame(updateEditorHeight); // folding
234
- });
235
- let prevHeight = 0;
236
-
237
- const updateEditorHeight = () => {
238
- onChange(editor.getValue());
239
- const editorElement = editor.getDomNode();
240
-
241
- if (!editorElement) {
242
- return;
243
- }
244
-
245
- const lineHeight = 22;
246
- const lineCount = editor.getModel()?.getLineCount() || 1;
247
- const height =
248
- editor.getTopForLineNumber(lineCount + 1) + lineHeight;
249
- const clippedHeight = Math.min(height, 500);
250
-
251
- if (prevHeight !== clippedHeight) {
252
- prevHeight = clippedHeight;
253
- editorElement.style.height = `${clippedHeight}px`;
254
- editor.layout();
255
- }
256
- };
257
-
258
- updateEditorHeight();
259
- }}
260
- />
261
- </div>
262
- );
263
- }
264
-
265
- export default VSCode;
@@ -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
- }