@stoplight/elements-core 7.7.11 → 7.7.12

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/index.esm.js CHANGED
@@ -10,6 +10,7 @@ import { parse } from '@stoplight/yaml';
10
10
  import { isArray as isArray$1, Box, Panel, CopyButton, Menu, Button, Text, Flex, Input, Icon, Select, FieldButton, Image, Link, useThemeIsDark, HStack, VStack, InvertTheme, Tooltip, Badge, LinkHeading as LinkHeading$1, NodeAnnotation, Tabs, TabList, Tab, TabPanels, TabPanel, Heading, useClipboard, useBreakpoints, useMosaicContext, Provider as Provider$1 } from '@stoplight/mosaic';
11
11
  import isObject from 'lodash/isObject.js';
12
12
  import { withErrorBoundary } from '@stoplight/react-error-boundary';
13
+ import { useLocation, BrowserRouter, MemoryRouter, HashRouter, StaticRouter, Route } from 'react-router-dom';
13
14
  import { MarkdownViewer as MarkdownViewer$1, DefaultSMDComponents, MarkdownViewerProvider } from '@stoplight/markdown-viewer';
14
15
  export { DefaultSMDComponents } from '@stoplight/markdown-viewer';
15
16
  import cn from 'classnames';
@@ -38,7 +39,6 @@ import uniqBy from 'lodash/uniqBy.js';
38
39
  import formatXml from 'xml-formatter';
39
40
  import entries from 'lodash/entries.js';
40
41
  import keys from 'lodash/keys.js';
41
- import { useLocation, BrowserRouter, MemoryRouter, HashRouter, StaticRouter, Route } from 'react-router-dom';
42
42
  import { JsonSchemaViewer } from '@stoplight/json-schema-viewer';
43
43
  import sortBy from 'lodash/sortBy.js';
44
44
  import { HashLink } from 'react-router-hash-link';
@@ -246,14 +246,22 @@ function parseUnknown() {
246
246
  return undefined;
247
247
  }
248
248
 
249
+ const RouterTypeContext = React.createContext(null);
250
+ const useRouterType = () => {
251
+ return React.useContext(RouterTypeContext);
252
+ };
253
+
249
254
  const MarkdownViewer = (props) => {
250
255
  return React.createElement(MarkdownViewer$1, Object.assign({}, props));
251
256
  };
252
257
  MarkdownViewer.displayName = 'MarkdownViewer';
253
258
 
254
259
  const ArticleComponent = React.memo(({ data }) => {
260
+ const { pathname } = useLocation();
261
+ const routerKind = React.useContext(RouterTypeContext);
262
+ const basePath = routerKind === 'hash' ? `#${pathname.split('#')[0]}` : '';
255
263
  return (React.createElement(Box, { className: "sl-elements-article" },
256
- React.createElement(MarkdownViewer, { className: "sl-elements-article-content", markdown: data, includeToc: true })));
264
+ React.createElement(MarkdownViewer, { className: "sl-elements-article-content", markdown: data, includeToc: true, tocBasePath: basePath })));
257
265
  });
258
266
  const Article = withErrorBoundary(ArticleComponent, { recoverableProps: ['data'] });
259
267
 
@@ -2122,11 +2130,6 @@ ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
2122
2130
  return description;
2123
2131
  }
2124
2132
 
2125
- const RouterTypeContext = React.createContext(null);
2126
- const useRouterType = () => {
2127
- return React.useContext(RouterTypeContext);
2128
- };
2129
-
2130
2133
  const LinkHeading = React.memo(function LinkHeading(props) {
2131
2134
  const isUsingRouter = !!useRouterType();
2132
2135
  const Comp = isUsingRouter ? CustomLinkHeading : LinkHeading$1;
package/index.js CHANGED
@@ -13,6 +13,7 @@ var yaml = require('@stoplight/yaml');
13
13
  var mosaic = require('@stoplight/mosaic');
14
14
  var isObject = require('lodash/isObject.js');
15
15
  var reactErrorBoundary = require('@stoplight/react-error-boundary');
16
+ var reactRouterDom = require('react-router-dom');
16
17
  var markdownViewer = require('@stoplight/markdown-viewer');
17
18
  var cn = require('classnames');
18
19
  var utils = require('jotai/utils');
@@ -40,7 +41,6 @@ var uniqBy = require('lodash/uniqBy.js');
40
41
  var formatXml = require('xml-formatter');
41
42
  var entries = require('lodash/entries.js');
42
43
  var keys = require('lodash/keys.js');
43
- var reactRouterDom = require('react-router-dom');
44
44
  var jsonSchemaViewer = require('@stoplight/json-schema-viewer');
45
45
  var sortBy = require('lodash/sortBy.js');
46
46
  var reactRouterHashLink = require('react-router-hash-link');
@@ -300,14 +300,22 @@ function parseUnknown() {
300
300
  return undefined;
301
301
  }
302
302
 
303
+ const RouterTypeContext = React__namespace.createContext(null);
304
+ const useRouterType = () => {
305
+ return React__namespace.useContext(RouterTypeContext);
306
+ };
307
+
303
308
  const MarkdownViewer = (props) => {
304
309
  return React__namespace.createElement(markdownViewer.MarkdownViewer, Object.assign({}, props));
305
310
  };
306
311
  MarkdownViewer.displayName = 'MarkdownViewer';
307
312
 
308
313
  const ArticleComponent = React__namespace.memo(({ data }) => {
314
+ const { pathname } = reactRouterDom.useLocation();
315
+ const routerKind = React__namespace.useContext(RouterTypeContext);
316
+ const basePath = routerKind === 'hash' ? `#${pathname.split('#')[0]}` : '';
309
317
  return (React__namespace.createElement(mosaic.Box, { className: "sl-elements-article" },
310
- React__namespace.createElement(MarkdownViewer, { className: "sl-elements-article-content", markdown: data, includeToc: true })));
318
+ React__namespace.createElement(MarkdownViewer, { className: "sl-elements-article-content", markdown: data, includeToc: true, tocBasePath: basePath })));
311
319
  });
312
320
  const Article = reactErrorBoundary.withErrorBoundary(ArticleComponent, { recoverableProps: ['data'] });
313
321
 
@@ -2176,11 +2184,6 @@ ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
2176
2184
  return description;
2177
2185
  }
2178
2186
 
2179
- const RouterTypeContext = React__namespace.createContext(null);
2180
- const useRouterType = () => {
2181
- return React__namespace.useContext(RouterTypeContext);
2182
- };
2183
-
2184
2187
  const LinkHeading = React__namespace.memo(function LinkHeading(props) {
2185
2188
  const isUsingRouter = !!useRouterType();
2186
2189
  const Comp = isUsingRouter ? CustomLinkHeading : mosaic.LinkHeading;
package/index.mjs CHANGED
@@ -10,6 +10,7 @@ import { parse } from '@stoplight/yaml';
10
10
  import { isArray as isArray$1, Box, Panel, CopyButton, Menu, Button, Text, Flex, Input, Icon, Select, FieldButton, Image, Link, useThemeIsDark, HStack, VStack, InvertTheme, Tooltip, Badge, LinkHeading as LinkHeading$1, NodeAnnotation, Tabs, TabList, Tab, TabPanels, TabPanel, Heading, useClipboard, useBreakpoints, useMosaicContext, Provider as Provider$1 } from '@stoplight/mosaic';
11
11
  import isObject from 'lodash/isObject.js';
12
12
  import { withErrorBoundary } from '@stoplight/react-error-boundary';
13
+ import { useLocation, BrowserRouter, MemoryRouter, HashRouter, StaticRouter, Route } from 'react-router-dom';
13
14
  import { MarkdownViewer as MarkdownViewer$1, DefaultSMDComponents, MarkdownViewerProvider } from '@stoplight/markdown-viewer';
14
15
  export { DefaultSMDComponents } from '@stoplight/markdown-viewer';
15
16
  import cn from 'classnames';
@@ -38,7 +39,6 @@ import uniqBy from 'lodash/uniqBy.js';
38
39
  import formatXml from 'xml-formatter';
39
40
  import entries from 'lodash/entries.js';
40
41
  import keys from 'lodash/keys.js';
41
- import { useLocation, BrowserRouter, MemoryRouter, HashRouter, StaticRouter, Route } from 'react-router-dom';
42
42
  import { JsonSchemaViewer } from '@stoplight/json-schema-viewer';
43
43
  import sortBy from 'lodash/sortBy.js';
44
44
  import { HashLink } from 'react-router-hash-link';
@@ -246,14 +246,22 @@ function parseUnknown() {
246
246
  return undefined;
247
247
  }
248
248
 
249
+ const RouterTypeContext = React.createContext(null);
250
+ const useRouterType = () => {
251
+ return React.useContext(RouterTypeContext);
252
+ };
253
+
249
254
  const MarkdownViewer = (props) => {
250
255
  return React.createElement(MarkdownViewer$1, Object.assign({}, props));
251
256
  };
252
257
  MarkdownViewer.displayName = 'MarkdownViewer';
253
258
 
254
259
  const ArticleComponent = React.memo(({ data }) => {
260
+ const { pathname } = useLocation();
261
+ const routerKind = React.useContext(RouterTypeContext);
262
+ const basePath = routerKind === 'hash' ? `#${pathname.split('#')[0]}` : '';
255
263
  return (React.createElement(Box, { className: "sl-elements-article" },
256
- React.createElement(MarkdownViewer, { className: "sl-elements-article-content", markdown: data, includeToc: true })));
264
+ React.createElement(MarkdownViewer, { className: "sl-elements-article-content", markdown: data, includeToc: true, tocBasePath: basePath })));
257
265
  });
258
266
  const Article = withErrorBoundary(ArticleComponent, { recoverableProps: ['data'] });
259
267
 
@@ -2122,11 +2130,6 @@ ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
2122
2130
  return description;
2123
2131
  }
2124
2132
 
2125
- const RouterTypeContext = React.createContext(null);
2126
- const useRouterType = () => {
2127
- return React.useContext(RouterTypeContext);
2128
- };
2129
-
2130
2133
  const LinkHeading = React.memo(function LinkHeading(props) {
2131
2134
  const isUsingRouter = !!useRouterType();
2132
2135
  const Comp = isUsingRouter ? CustomLinkHeading : LinkHeading$1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-core",
3
- "version": "7.7.11",
3
+ "version": "7.7.12",
4
4
  "main": "./index.js",
5
5
  "sideEffects": [
6
6
  "web-components.min.js",
@@ -29,7 +29,7 @@
29
29
  "@stoplight/json-schema-ref-parser": "^9.0.5",
30
30
  "@stoplight/json-schema-sampler": "0.2.3",
31
31
  "@stoplight/json-schema-viewer": "^4.9.0",
32
- "@stoplight/markdown-viewer": "^5.5.0",
32
+ "@stoplight/markdown-viewer": "^5.6.0",
33
33
  "@stoplight/mosaic": "^1.33.0",
34
34
  "@stoplight/mosaic-code-editor": "^1.33.0",
35
35
  "@stoplight/mosaic-code-viewer": "^1.33.0",