@stoplight/elements-dev-portal 1.6.15 → 1.6.18
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/components/NodeContent/NodeContent.d.ts +4 -0
- package/index.esm.js +22 -3
- package/index.js +22 -3
- package/index.mjs +22 -3
- package/package.json +2 -2
- package/version.d.ts +1 -1
- package/web-components.min.js +1 -1
|
@@ -12,3 +12,7 @@ export declare type NodeContentProps = {
|
|
|
12
12
|
refResolver?: ReferenceResolver;
|
|
13
13
|
};
|
|
14
14
|
export declare const NodeContent: ({ node, Link, hideTryIt, hideTryItPanel, hideMocking, hideExport, tryItCredentialsPolicy, tryItCorsProxy, refResolver, }: NodeContentProps) => JSX.Element;
|
|
15
|
+
export declare const getNodeUriParts: (uri: string) => {
|
|
16
|
+
fileUri: string;
|
|
17
|
+
pointer: string;
|
|
18
|
+
};
|
package/index.esm.js
CHANGED
|
@@ -66,7 +66,15 @@ const LinkComponent = ({ children, href }) => {
|
|
|
66
66
|
}
|
|
67
67
|
if (href && ctx) {
|
|
68
68
|
const [node, Link] = ctx;
|
|
69
|
-
const
|
|
69
|
+
const { fileUri } = getNodeUriParts(node.uri);
|
|
70
|
+
const { fileUri: hrefFileUri } = getNodeUriParts(href);
|
|
71
|
+
let resolvedUri;
|
|
72
|
+
if (hrefFileUri) {
|
|
73
|
+
resolvedUri = resolve(dirname(fileUri), href);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
resolvedUri = resolve(fileUri, href);
|
|
77
|
+
}
|
|
70
78
|
const [resolvedUriWithoutAnchor, hash] = resolvedUri.split('#');
|
|
71
79
|
const decodedUrl = decodeURIComponent(href);
|
|
72
80
|
const decodedResolvedUriWithoutAnchor = decodeURIComponent(resolvedUriWithoutAnchor);
|
|
@@ -85,7 +93,15 @@ function getBundledUrl(url) {
|
|
|
85
93
|
searchParams.append('deref', 'optimizedBundle');
|
|
86
94
|
bundledUrl.search = searchParams.toString();
|
|
87
95
|
return bundledUrl.toString();
|
|
88
|
-
}
|
|
96
|
+
}
|
|
97
|
+
const getNodeUriParts = (uri) => {
|
|
98
|
+
const parts = uri.split(/(\.yaml|\.yml|\.json|\.md)/);
|
|
99
|
+
if (parts.length === 1) {
|
|
100
|
+
return { fileUri: '', pointer: parts[0] || '' };
|
|
101
|
+
}
|
|
102
|
+
const fileUri = `${parts[0] || ''}${parts[1] || ''}`;
|
|
103
|
+
return { fileUri, pointer: parts[2] || '' };
|
|
104
|
+
};
|
|
89
105
|
|
|
90
106
|
const SearchImpl = ({ isLoading, search, searchResults, isOpen, onClose, onClick, onSearch }) => {
|
|
91
107
|
const listBoxRef = React.useRef(null);
|
|
@@ -202,7 +218,7 @@ const UpgradeToStarter = () => (React__default.createElement(Flex, { as: "a", hr
|
|
|
202
218
|
React__default.createElement(Icon, { icon: faExclamationTriangle, size: "4x" }),
|
|
203
219
|
React__default.createElement(Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
|
|
204
220
|
|
|
205
|
-
const appVersion = '1.6.
|
|
221
|
+
const appVersion = '1.6.18';
|
|
206
222
|
|
|
207
223
|
class ResponseError extends Error {
|
|
208
224
|
constructor(message, responseCode) {
|
|
@@ -321,6 +337,9 @@ const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, c
|
|
|
321
337
|
else if (!node) {
|
|
322
338
|
elem = React.createElement(NotFound, null);
|
|
323
339
|
}
|
|
340
|
+
else if ((node === null || node === void 0 ? void 0 : node.slug) && nodeSlug !== node.slug) {
|
|
341
|
+
return React.createElement(Redirect, { to: branchSlug ? `/branches/${branchSlug}/${node.slug}` : `/${node.slug}` });
|
|
342
|
+
}
|
|
324
343
|
else {
|
|
325
344
|
elem = (React.createElement(NodeContent, { node: node, Link: ReactRouterMarkdownLink, hideTryIt: hideTryIt, hideMocking: hideMocking, hideExport: hideExport, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }));
|
|
326
345
|
}
|
package/index.js
CHANGED
|
@@ -93,7 +93,15 @@ const LinkComponent = ({ children, href }) => {
|
|
|
93
93
|
}
|
|
94
94
|
if (href && ctx) {
|
|
95
95
|
const [node, Link] = ctx;
|
|
96
|
-
const
|
|
96
|
+
const { fileUri } = getNodeUriParts(node.uri);
|
|
97
|
+
const { fileUri: hrefFileUri } = getNodeUriParts(href);
|
|
98
|
+
let resolvedUri;
|
|
99
|
+
if (hrefFileUri) {
|
|
100
|
+
resolvedUri = path.resolve(path.dirname(fileUri), href);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
resolvedUri = path.resolve(fileUri, href);
|
|
104
|
+
}
|
|
97
105
|
const [resolvedUriWithoutAnchor, hash] = resolvedUri.split('#');
|
|
98
106
|
const decodedUrl = decodeURIComponent(href);
|
|
99
107
|
const decodedResolvedUriWithoutAnchor = decodeURIComponent(resolvedUriWithoutAnchor);
|
|
@@ -112,7 +120,15 @@ function getBundledUrl(url) {
|
|
|
112
120
|
searchParams.append('deref', 'optimizedBundle');
|
|
113
121
|
bundledUrl.search = searchParams.toString();
|
|
114
122
|
return bundledUrl.toString();
|
|
115
|
-
}
|
|
123
|
+
}
|
|
124
|
+
const getNodeUriParts = (uri) => {
|
|
125
|
+
const parts = uri.split(/(\.yaml|\.yml|\.json|\.md)/);
|
|
126
|
+
if (parts.length === 1) {
|
|
127
|
+
return { fileUri: '', pointer: parts[0] || '' };
|
|
128
|
+
}
|
|
129
|
+
const fileUri = `${parts[0] || ''}${parts[1] || ''}`;
|
|
130
|
+
return { fileUri, pointer: parts[2] || '' };
|
|
131
|
+
};
|
|
116
132
|
|
|
117
133
|
const SearchImpl = ({ isLoading, search, searchResults, isOpen, onClose, onClick, onSearch }) => {
|
|
118
134
|
const listBoxRef = React__namespace.useRef(null);
|
|
@@ -229,7 +245,7 @@ const UpgradeToStarter = () => (React__default["default"].createElement(mosaic.F
|
|
|
229
245
|
React__default["default"].createElement(mosaic.Icon, { icon: freeSolidSvgIcons.faExclamationTriangle, size: "4x" }),
|
|
230
246
|
React__default["default"].createElement(mosaic.Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
|
|
231
247
|
|
|
232
|
-
const appVersion = '1.6.
|
|
248
|
+
const appVersion = '1.6.18';
|
|
233
249
|
|
|
234
250
|
class ResponseError extends Error {
|
|
235
251
|
constructor(message, responseCode) {
|
|
@@ -348,6 +364,9 @@ const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, c
|
|
|
348
364
|
else if (!node) {
|
|
349
365
|
elem = React__namespace.createElement(NotFound, null);
|
|
350
366
|
}
|
|
367
|
+
else if ((node === null || node === void 0 ? void 0 : node.slug) && nodeSlug !== node.slug) {
|
|
368
|
+
return React__namespace.createElement(reactRouterDom.Redirect, { to: branchSlug ? `/branches/${branchSlug}/${node.slug}` : `/${node.slug}` });
|
|
369
|
+
}
|
|
351
370
|
else {
|
|
352
371
|
elem = (React__namespace.createElement(NodeContent, { node: node, Link: elementsCore.ReactRouterMarkdownLink, hideTryIt: hideTryIt, hideMocking: hideMocking, hideExport: hideExport, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }));
|
|
353
372
|
}
|
package/index.mjs
CHANGED
|
@@ -66,7 +66,15 @@ const LinkComponent = ({ children, href }) => {
|
|
|
66
66
|
}
|
|
67
67
|
if (href && ctx) {
|
|
68
68
|
const [node, Link] = ctx;
|
|
69
|
-
const
|
|
69
|
+
const { fileUri } = getNodeUriParts(node.uri);
|
|
70
|
+
const { fileUri: hrefFileUri } = getNodeUriParts(href);
|
|
71
|
+
let resolvedUri;
|
|
72
|
+
if (hrefFileUri) {
|
|
73
|
+
resolvedUri = resolve(dirname(fileUri), href);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
resolvedUri = resolve(fileUri, href);
|
|
77
|
+
}
|
|
70
78
|
const [resolvedUriWithoutAnchor, hash] = resolvedUri.split('#');
|
|
71
79
|
const decodedUrl = decodeURIComponent(href);
|
|
72
80
|
const decodedResolvedUriWithoutAnchor = decodeURIComponent(resolvedUriWithoutAnchor);
|
|
@@ -85,7 +93,15 @@ function getBundledUrl(url) {
|
|
|
85
93
|
searchParams.append('deref', 'optimizedBundle');
|
|
86
94
|
bundledUrl.search = searchParams.toString();
|
|
87
95
|
return bundledUrl.toString();
|
|
88
|
-
}
|
|
96
|
+
}
|
|
97
|
+
const getNodeUriParts = (uri) => {
|
|
98
|
+
const parts = uri.split(/(\.yaml|\.yml|\.json|\.md)/);
|
|
99
|
+
if (parts.length === 1) {
|
|
100
|
+
return { fileUri: '', pointer: parts[0] || '' };
|
|
101
|
+
}
|
|
102
|
+
const fileUri = `${parts[0] || ''}${parts[1] || ''}`;
|
|
103
|
+
return { fileUri, pointer: parts[2] || '' };
|
|
104
|
+
};
|
|
89
105
|
|
|
90
106
|
const SearchImpl = ({ isLoading, search, searchResults, isOpen, onClose, onClick, onSearch }) => {
|
|
91
107
|
const listBoxRef = React.useRef(null);
|
|
@@ -202,7 +218,7 @@ const UpgradeToStarter = () => (React__default.createElement(Flex, { as: "a", hr
|
|
|
202
218
|
React__default.createElement(Icon, { icon: faExclamationTriangle, size: "4x" }),
|
|
203
219
|
React__default.createElement(Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
|
|
204
220
|
|
|
205
|
-
const appVersion = '1.6.
|
|
221
|
+
const appVersion = '1.6.18';
|
|
206
222
|
|
|
207
223
|
class ResponseError extends Error {
|
|
208
224
|
constructor(message, responseCode) {
|
|
@@ -321,6 +337,9 @@ const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, c
|
|
|
321
337
|
else if (!node) {
|
|
322
338
|
elem = React.createElement(NotFound, null);
|
|
323
339
|
}
|
|
340
|
+
else if ((node === null || node === void 0 ? void 0 : node.slug) && nodeSlug !== node.slug) {
|
|
341
|
+
return React.createElement(Redirect, { to: branchSlug ? `/branches/${branchSlug}/${node.slug}` : `/${node.slug}` });
|
|
342
|
+
}
|
|
324
343
|
else {
|
|
325
344
|
elem = (React.createElement(NodeContent, { node: node, Link: ReactRouterMarkdownLink, hideTryIt: hideTryIt, hideMocking: hideMocking, hideExport: hideExport, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }));
|
|
326
345
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoplight/elements-dev-portal",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.18",
|
|
4
4
|
"description": "UI components for composing beautiful developer documentation.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"main": "./index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@fortawesome/free-solid-svg-icons": "^5.10.2",
|
|
30
|
-
"@stoplight/elements-core": "~7.5.
|
|
30
|
+
"@stoplight/elements-core": "~7.5.14",
|
|
31
31
|
"@stoplight/markdown-viewer": "^5.4.2",
|
|
32
32
|
"@stoplight/mosaic": "^1.16.2",
|
|
33
33
|
"@stoplight/path": "^1.3.2",
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const appVersion = "1.6.
|
|
1
|
+
export declare const appVersion = "1.6.18";
|