@stoplight/elements-core 7.5.7 → 7.5.8
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.
|
@@ -2,6 +2,7 @@ import { NodeType } from '@stoplight/types';
|
|
|
2
2
|
import { Location } from 'history';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ParsedNode } from '../../types';
|
|
5
|
+
import { ReferenceResolver } from '../../utils/ref-resolving/ReferenceResolver';
|
|
5
6
|
import { ExportButtonProps } from './HttpService/ExportButton';
|
|
6
7
|
interface BaseDocsProps {
|
|
7
8
|
className?: string;
|
|
@@ -27,6 +28,7 @@ export interface DocsProps extends BaseDocsProps {
|
|
|
27
28
|
nodeType: NodeType;
|
|
28
29
|
nodeData: unknown;
|
|
29
30
|
useNodeForRefResolving?: boolean;
|
|
31
|
+
refResolver?: ReferenceResolver;
|
|
30
32
|
}
|
|
31
33
|
export interface DocsComponentProps<T = unknown> extends BaseDocsProps {
|
|
32
34
|
data: T;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const ReactRouterMarkdownLink: ({ title, to, href: _href, children, }: import("react").ClassAttributes<HTMLAnchorElement> & import("react").AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
2
|
+
to?: string | undefined;
|
|
3
|
+
}) => JSX.Element;
|
package/index.esm.js
CHANGED
|
@@ -1610,9 +1610,9 @@ const bodyFormatMap = {
|
|
|
1610
1610
|
text: ['raw'],
|
|
1611
1611
|
};
|
|
1612
1612
|
const regex = {
|
|
1613
|
-
image: /image\/(
|
|
1614
|
-
json: /application\/(
|
|
1615
|
-
xml: /(text|application)\/(
|
|
1613
|
+
image: /image\/(.?)*(jpeg|gif|png|svg)/,
|
|
1614
|
+
json: /application\/(.?)*json/,
|
|
1615
|
+
xml: /(text|application)\/(.?)*(xml|html)/,
|
|
1616
1616
|
text: /text\/.*/,
|
|
1617
1617
|
};
|
|
1618
1618
|
function getResponseType(contentType) {
|
|
@@ -2347,14 +2347,14 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
2347
2347
|
const Model = withErrorBoundary(ModelComponent, { recoverableProps: ['data'] });
|
|
2348
2348
|
|
|
2349
2349
|
const Docs = React.memo((_a) => {
|
|
2350
|
-
var { nodeType, nodeData, useNodeForRefResolving = false } = _a, commonProps = __rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving"]);
|
|
2350
|
+
var { nodeType, nodeData, useNodeForRefResolving = false, refResolver } = _a, commonProps = __rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving", "refResolver"]);
|
|
2351
2351
|
const parsedNode = useParsedData(nodeType, nodeData);
|
|
2352
2352
|
if (!parsedNode) {
|
|
2353
2353
|
return null;
|
|
2354
2354
|
}
|
|
2355
2355
|
const parsedDocs = React.createElement(ParsedDocs, Object.assign({ node: parsedNode }, commonProps));
|
|
2356
2356
|
if (useNodeForRefResolving) {
|
|
2357
|
-
return React.createElement(InlineRefResolverProvider, { document: parsedNode.data }, parsedDocs);
|
|
2357
|
+
return (React.createElement(InlineRefResolverProvider, { document: parsedNode.data, resolver: refResolver }, parsedDocs));
|
|
2358
2358
|
}
|
|
2359
2359
|
return parsedDocs;
|
|
2360
2360
|
});
|
|
@@ -2512,7 +2512,8 @@ const MarkdownComponentsProvider = ({ value, children }) => {
|
|
|
2512
2512
|
};
|
|
2513
2513
|
|
|
2514
2514
|
const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
2515
|
-
const ReactRouterMarkdownLink = ({ title, href, children }) => {
|
|
2515
|
+
const ReactRouterMarkdownLink = ({ title, to, href: _href, children, }) => {
|
|
2516
|
+
const href = to || _href;
|
|
2516
2517
|
const isExternal = href !== undefined && externalRegex.test(href);
|
|
2517
2518
|
if (isExternal) {
|
|
2518
2519
|
return (React__default.createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
|
|
@@ -2758,7 +2759,7 @@ function withRouter(WrappedComponent) {
|
|
|
2758
2759
|
const { Router, routerProps } = useRouter((_c = props.router) !== null && _c !== void 0 ? _c : 'history', basePath, staticRouterPath);
|
|
2759
2760
|
return (React.createElement(Router, Object.assign({}, routerProps, { key: basePath }),
|
|
2760
2761
|
React.createElement(Route, { path: "/" },
|
|
2761
|
-
React.createElement(MarkdownComponentsProvider, { value: {
|
|
2762
|
+
React.createElement(MarkdownComponentsProvider, { value: { a: ReactRouterMarkdownLink } },
|
|
2762
2763
|
React.createElement(WrappedComponent, Object.assign({}, props))))));
|
|
2763
2764
|
};
|
|
2764
2765
|
WithRouter.displayName = `WithRouter(${getDisplayName(WrappedComponent)})`;
|
package/index.js
CHANGED
|
@@ -1665,9 +1665,9 @@ const bodyFormatMap = {
|
|
|
1665
1665
|
text: ['raw'],
|
|
1666
1666
|
};
|
|
1667
1667
|
const regex = {
|
|
1668
|
-
image: /image\/(
|
|
1669
|
-
json: /application\/(
|
|
1670
|
-
xml: /(text|application)\/(
|
|
1668
|
+
image: /image\/(.?)*(jpeg|gif|png|svg)/,
|
|
1669
|
+
json: /application\/(.?)*json/,
|
|
1670
|
+
xml: /(text|application)\/(.?)*(xml|html)/,
|
|
1671
1671
|
text: /text\/.*/,
|
|
1672
1672
|
};
|
|
1673
1673
|
function getResponseType(contentType) {
|
|
@@ -2402,14 +2402,14 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
2402
2402
|
const Model = reactErrorBoundary.withErrorBoundary(ModelComponent, { recoverableProps: ['data'] });
|
|
2403
2403
|
|
|
2404
2404
|
const Docs = React__namespace.memo((_a) => {
|
|
2405
|
-
var { nodeType, nodeData, useNodeForRefResolving = false } = _a, commonProps = tslib.__rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving"]);
|
|
2405
|
+
var { nodeType, nodeData, useNodeForRefResolving = false, refResolver } = _a, commonProps = tslib.__rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving", "refResolver"]);
|
|
2406
2406
|
const parsedNode = useParsedData(nodeType, nodeData);
|
|
2407
2407
|
if (!parsedNode) {
|
|
2408
2408
|
return null;
|
|
2409
2409
|
}
|
|
2410
2410
|
const parsedDocs = React__namespace.createElement(ParsedDocs, Object.assign({ node: parsedNode }, commonProps));
|
|
2411
2411
|
if (useNodeForRefResolving) {
|
|
2412
|
-
return React__namespace.createElement(InlineRefResolverProvider, { document: parsedNode.data }, parsedDocs);
|
|
2412
|
+
return (React__namespace.createElement(InlineRefResolverProvider, { document: parsedNode.data, resolver: refResolver }, parsedDocs));
|
|
2413
2413
|
}
|
|
2414
2414
|
return parsedDocs;
|
|
2415
2415
|
});
|
|
@@ -2567,7 +2567,8 @@ const MarkdownComponentsProvider = ({ value, children }) => {
|
|
|
2567
2567
|
};
|
|
2568
2568
|
|
|
2569
2569
|
const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
2570
|
-
const ReactRouterMarkdownLink = ({ title, href, children }) => {
|
|
2570
|
+
const ReactRouterMarkdownLink = ({ title, to, href: _href, children, }) => {
|
|
2571
|
+
const href = to || _href;
|
|
2571
2572
|
const isExternal = href !== undefined && externalRegex.test(href);
|
|
2572
2573
|
if (isExternal) {
|
|
2573
2574
|
return (React__default["default"].createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
|
|
@@ -2813,7 +2814,7 @@ function withRouter(WrappedComponent) {
|
|
|
2813
2814
|
const { Router, routerProps } = useRouter((_c = props.router) !== null && _c !== void 0 ? _c : 'history', basePath, staticRouterPath);
|
|
2814
2815
|
return (React__namespace.createElement(Router, Object.assign({}, routerProps, { key: basePath }),
|
|
2815
2816
|
React__namespace.createElement(reactRouterDom.Route, { path: "/" },
|
|
2816
|
-
React__namespace.createElement(MarkdownComponentsProvider, { value: {
|
|
2817
|
+
React__namespace.createElement(MarkdownComponentsProvider, { value: { a: ReactRouterMarkdownLink } },
|
|
2817
2818
|
React__namespace.createElement(WrappedComponent, Object.assign({}, props))))));
|
|
2818
2819
|
};
|
|
2819
2820
|
WithRouter.displayName = `WithRouter(${getDisplayName(WrappedComponent)})`;
|
package/index.mjs
CHANGED
|
@@ -1610,9 +1610,9 @@ const bodyFormatMap = {
|
|
|
1610
1610
|
text: ['raw'],
|
|
1611
1611
|
};
|
|
1612
1612
|
const regex = {
|
|
1613
|
-
image: /image\/(
|
|
1614
|
-
json: /application\/(
|
|
1615
|
-
xml: /(text|application)\/(
|
|
1613
|
+
image: /image\/(.?)*(jpeg|gif|png|svg)/,
|
|
1614
|
+
json: /application\/(.?)*json/,
|
|
1615
|
+
xml: /(text|application)\/(.?)*(xml|html)/,
|
|
1616
1616
|
text: /text\/.*/,
|
|
1617
1617
|
};
|
|
1618
1618
|
function getResponseType(contentType) {
|
|
@@ -2347,14 +2347,14 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
2347
2347
|
const Model = withErrorBoundary(ModelComponent, { recoverableProps: ['data'] });
|
|
2348
2348
|
|
|
2349
2349
|
const Docs = React.memo((_a) => {
|
|
2350
|
-
var { nodeType, nodeData, useNodeForRefResolving = false } = _a, commonProps = __rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving"]);
|
|
2350
|
+
var { nodeType, nodeData, useNodeForRefResolving = false, refResolver } = _a, commonProps = __rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving", "refResolver"]);
|
|
2351
2351
|
const parsedNode = useParsedData(nodeType, nodeData);
|
|
2352
2352
|
if (!parsedNode) {
|
|
2353
2353
|
return null;
|
|
2354
2354
|
}
|
|
2355
2355
|
const parsedDocs = React.createElement(ParsedDocs, Object.assign({ node: parsedNode }, commonProps));
|
|
2356
2356
|
if (useNodeForRefResolving) {
|
|
2357
|
-
return React.createElement(InlineRefResolverProvider, { document: parsedNode.data }, parsedDocs);
|
|
2357
|
+
return (React.createElement(InlineRefResolverProvider, { document: parsedNode.data, resolver: refResolver }, parsedDocs));
|
|
2358
2358
|
}
|
|
2359
2359
|
return parsedDocs;
|
|
2360
2360
|
});
|
|
@@ -2512,7 +2512,8 @@ const MarkdownComponentsProvider = ({ value, children }) => {
|
|
|
2512
2512
|
};
|
|
2513
2513
|
|
|
2514
2514
|
const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
2515
|
-
const ReactRouterMarkdownLink = ({ title, href, children }) => {
|
|
2515
|
+
const ReactRouterMarkdownLink = ({ title, to, href: _href, children, }) => {
|
|
2516
|
+
const href = to || _href;
|
|
2516
2517
|
const isExternal = href !== undefined && externalRegex.test(href);
|
|
2517
2518
|
if (isExternal) {
|
|
2518
2519
|
return (React__default.createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
|
|
@@ -2758,7 +2759,7 @@ function withRouter(WrappedComponent) {
|
|
|
2758
2759
|
const { Router, routerProps } = useRouter((_c = props.router) !== null && _c !== void 0 ? _c : 'history', basePath, staticRouterPath);
|
|
2759
2760
|
return (React.createElement(Router, Object.assign({}, routerProps, { key: basePath }),
|
|
2760
2761
|
React.createElement(Route, { path: "/" },
|
|
2761
|
-
React.createElement(MarkdownComponentsProvider, { value: {
|
|
2762
|
+
React.createElement(MarkdownComponentsProvider, { value: { a: ReactRouterMarkdownLink } },
|
|
2762
2763
|
React.createElement(WrappedComponent, Object.assign({}, props))))));
|
|
2763
2764
|
};
|
|
2764
2765
|
WithRouter.displayName = `WithRouter(${getDisplayName(WrappedComponent)})`;
|