@docusaurus/theme-classic 2.0.0-beta.18 → 2.0.0-beta.19
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/lib/admonitions.css +4 -0
- package/lib/default.css +3038 -0
- package/lib/getSwizzleConfig.js +9 -2
- package/lib/index.js +4 -4
- package/lib/nprogress.css +41 -0
- package/lib/nprogress.js +46 -0
- package/lib/theme-classic.d.ts +315 -33
- package/lib/validateThemeConfig.js +72 -14
- package/lib-next/theme/BackToTopButton/index.js +6 -102
- package/lib-next/theme/BlogLayout/index.js +1 -5
- package/lib-next/theme/BlogListPaginator/index.js +25 -28
- package/lib-next/theme/BlogPostAuthor/index.js +3 -6
- package/lib-next/theme/BlogPostItem/styles.module.css +9 -0
- package/lib-next/theme/BlogPostPaginator/index.js +25 -28
- package/lib-next/theme/BlogSidebar/Desktop/index.js +41 -0
- package/lib-next/theme/BlogSidebar/{styles.module.css → Desktop/styles.module.css} +1 -2
- package/lib-next/theme/BlogSidebar/Mobile/index.js +36 -0
- package/lib-next/theme/BlogSidebar/index.js +11 -31
- package/lib-next/theme/BlogTagsListPage/index.js +2 -3
- package/lib-next/theme/BlogTagsPostsPage/index.js +4 -6
- package/lib-next/theme/CodeBlock/Container/index.js +29 -0
- package/lib-next/theme/CodeBlock/Container/styles.module.css +14 -0
- package/lib-next/theme/CodeBlock/Content/Element.js +23 -0
- package/lib-next/theme/CodeBlock/Content/String.js +104 -0
- package/{src/theme/CodeBlock → lib-next/theme/CodeBlock/Content}/styles.module.css +39 -9
- package/lib-next/theme/CodeBlock/CopyButton/index.js +3 -2
- package/lib-next/theme/CodeBlock/CopyButton/styles.module.css +0 -19
- package/lib-next/theme/CodeBlock/Line/index.js +49 -0
- package/lib-next/theme/CodeBlock/Line/styles.module.css +51 -0
- package/lib-next/theme/CodeBlock/WordWrapButton/index.js +40 -0
- package/lib-next/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
- package/lib-next/theme/CodeBlock/index.js +27 -133
- package/lib-next/theme/Details/index.js +1 -1
- package/lib-next/theme/DocBreadcrumbs/index.js +50 -23
- package/lib-next/theme/DocBreadcrumbs/styles.module.css +8 -0
- package/lib-next/theme/DocCardList/index.js +6 -4
- package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +3 -3
- package/lib-next/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
- package/lib-next/theme/DocItem/index.js +1 -1
- package/lib-next/theme/DocItem/styles.module.css +6 -0
- package/lib-next/theme/DocPage/Layout/Main/index.js +29 -0
- package/lib-next/theme/DocPage/Layout/Main/styles.module.css +28 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/ExpandButton/index.js +34 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +33 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/index.js +68 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/index.module.css +32 -0
- package/lib-next/theme/DocPage/Layout/index.js +34 -0
- package/lib-next/theme/{BlogPostAuthor/styles.module.css → DocPage/Layout/index.module.css} +6 -3
- package/lib-next/theme/DocPage/index.js +28 -146
- package/lib-next/theme/DocPaginator/index.js +25 -28
- package/lib-next/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +11 -9
- package/lib-next/theme/DocSidebar/Desktop/Content/styles.module.css +6 -0
- package/lib-next/theme/DocSidebar/Desktop/index.js +4 -2
- package/lib-next/theme/DocSidebarItem/Category.js +197 -0
- package/lib-next/theme/DocSidebarItem/Html.js +27 -0
- package/{src/theme/DocSidebarItem/styles.module.css → lib-next/theme/DocSidebarItem/Html.module.css} +0 -4
- package/lib-next/theme/DocSidebarItem/Link.js +53 -0
- package/{src/theme/MDXComponents/Ul.module.css → lib-next/theme/DocSidebarItem/Link.module.css} +2 -3
- package/lib-next/theme/DocSidebarItem/index.js +4 -246
- package/lib-next/theme/DocSidebarItems/index.js +1 -6
- package/lib-next/theme/DocTagDocListPage/index.js +3 -3
- package/lib-next/theme/DocVersionBanner/index.js +2 -2
- package/lib-next/theme/Footer/Links/MultiColumn/index.js +1 -1
- package/lib-next/theme/Heading/index.js +4 -20
- package/lib-next/theme/IconHome/index.js +17 -0
- package/lib-next/theme/LastUpdated/index.js +1 -0
- package/lib-next/theme/Layout/index.js +1 -1
- package/lib-next/theme/MDXComponents/Ul.js +2 -4
- package/lib-next/theme/Navbar/Content/index.js +6 -1
- package/lib-next/theme/Navbar/Logo/index.js +1 -1
- package/lib-next/theme/Navbar/Search/index.js +11 -0
- package/lib-next/theme/Navbar/Search/styles.module.css +20 -0
- package/lib-next/theme/NavbarItem/ComponentTypes.js +27 -0
- package/lib-next/theme/NavbarItem/DocNavbarItem.js +11 -28
- package/lib-next/theme/NavbarItem/DocSidebarNavbarItem.js +10 -42
- package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +25 -29
- package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +2 -9
- package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +4 -1
- package/lib-next/theme/NavbarItem/HtmlNavbarItem.js +30 -0
- package/lib-next/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +5 -10
- package/lib-next/theme/NavbarItem/NavbarNavLink.js +49 -31
- package/lib-next/theme/NavbarItem/SearchNavbarItem.js +6 -1
- package/lib-next/theme/NavbarItem/index.js +4 -23
- package/lib-next/theme/NavbarItem/utils.js +2 -1
- package/lib-next/theme/PaginatorNavLink/index.js +8 -2
- package/lib-next/theme/SiteMetadata/index.js +8 -7
- package/lib-next/theme/SkipToContent/index.js +3 -29
- package/lib-next/theme/TOCCollapsible/CollapseButton.js +29 -0
- package/{src/theme/TOCCollapsible/styles.module.css → lib-next/theme/TOCCollapsible/CollapseButton.module.css} +1 -22
- package/lib-next/theme/TOCCollapsible/index.js +3 -13
- package/lib-next/theme/TOCCollapsible/index.module.css +31 -0
- package/lib-next/theme/TOCItems/Tree.js +40 -0
- package/lib-next/theme/TOCItems/index.js +3 -34
- package/lib-next/theme/TabItem/index.js +3 -1
- package/lib-next/theme/{MDXComponents/Ul.module.css → TabItem/styles.module.css} +2 -3
- package/lib-next/theme/Tabs/__tests__/index.test.js +3 -3
- package/lib-next/theme/Tabs/index.js +3 -3
- package/lib-next/theme/Tabs/styles.module.css +4 -0
- package/lib-next/theme/Tag/index.js +2 -3
- package/lib-next/theme/TagsListInline/index.js +1 -1
- package/package.json +23 -18
- package/src/admonitions.css +4 -0
- package/src/getSwizzleConfig.ts +10 -2
- package/src/index.ts +4 -3
- package/src/nprogress.css +41 -0
- package/src/nprogress.ts +31 -0
- package/src/theme/BackToTopButton/index.tsx +5 -112
- package/src/theme/BlogLayout/index.tsx +1 -5
- package/src/theme/BlogListPaginator/index.tsx +25 -28
- package/src/theme/BlogPostAuthor/index.tsx +3 -7
- package/src/theme/BlogPostItem/styles.module.css +9 -0
- package/src/theme/BlogPostPaginator/index.tsx +25 -28
- package/src/theme/BlogSidebar/Desktop/index.tsx +45 -0
- package/src/theme/BlogSidebar/{styles.module.css → Desktop/styles.module.css} +1 -2
- package/src/theme/BlogSidebar/Mobile/index.tsx +38 -0
- package/src/theme/BlogSidebar/index.tsx +10 -31
- package/src/theme/BlogTagsListPage/index.tsx +2 -3
- package/src/theme/BlogTagsPostsPage/index.tsx +8 -5
- package/src/theme/CodeBlock/Container/index.tsx +35 -0
- package/src/theme/CodeBlock/Container/styles.module.css +14 -0
- package/src/theme/CodeBlock/Content/Element.tsx +30 -0
- package/src/theme/CodeBlock/Content/String.tsx +111 -0
- package/{lib-next/theme/CodeBlock → src/theme/CodeBlock/Content}/styles.module.css +39 -9
- package/src/theme/CodeBlock/CopyButton/index.tsx +3 -2
- package/src/theme/CodeBlock/CopyButton/styles.module.css +0 -19
- package/src/theme/CodeBlock/Line/index.tsx +48 -0
- package/src/theme/CodeBlock/Line/styles.module.css +51 -0
- package/src/theme/CodeBlock/WordWrapButton/index.tsx +49 -0
- package/src/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
- package/src/theme/CodeBlock/index.tsx +29 -133
- package/src/theme/Details/index.tsx +1 -1
- package/src/theme/DocBreadcrumbs/index.tsx +50 -20
- package/src/theme/DocBreadcrumbs/styles.module.css +8 -0
- package/src/theme/DocCardList/index.tsx +5 -7
- package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +3 -3
- package/src/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
- package/src/theme/DocItem/index.tsx +1 -1
- package/src/theme/DocItem/styles.module.css +6 -0
- package/src/theme/DocPage/Layout/Main/index.tsx +37 -0
- package/src/theme/DocPage/Layout/Main/styles.module.css +28 -0
- package/src/theme/DocPage/Layout/Sidebar/ExpandButton/index.tsx +40 -0
- package/src/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +33 -0
- package/src/theme/DocPage/Layout/Sidebar/index.module.css +32 -0
- package/src/theme/DocPage/Layout/Sidebar/index.tsx +74 -0
- package/src/theme/{BlogPostAuthor/styles.module.css → DocPage/Layout/index.module.css} +6 -3
- package/src/theme/DocPage/Layout/index.tsx +39 -0
- package/src/theme/DocPage/index.tsx +28 -157
- package/src/theme/DocPaginator/index.tsx +25 -28
- package/src/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +11 -9
- package/src/theme/DocSidebar/Desktop/Content/styles.module.css +6 -0
- package/src/theme/DocSidebar/Desktop/index.tsx +4 -2
- package/src/theme/DocSidebarItem/Category.tsx +210 -0
- package/{lib-next/theme/DocSidebarItem/styles.module.css → src/theme/DocSidebarItem/Html.module.css} +0 -4
- package/src/theme/DocSidebarItem/Html.tsx +34 -0
- package/src/theme/DocSidebarItem/Link.module.css +10 -0
- package/src/theme/DocSidebarItem/Link.tsx +58 -0
- package/src/theme/DocSidebarItem/index.tsx +4 -259
- package/src/theme/DocSidebarItems/index.tsx +1 -6
- package/src/theme/DocTagDocListPage/index.tsx +3 -4
- package/src/theme/DocVersionBanner/index.tsx +2 -2
- package/src/theme/Footer/Links/MultiColumn/index.tsx +1 -1
- package/src/theme/Heading/index.tsx +4 -18
- package/src/theme/IconHome/index.tsx +20 -0
- package/src/theme/LastUpdated/index.tsx +1 -0
- package/src/theme/Layout/index.tsx +1 -1
- package/src/theme/MDXComponents/Details.tsx +2 -3
- package/src/theme/MDXComponents/Ul.tsx +2 -6
- package/src/theme/Navbar/Content/index.tsx +6 -1
- package/src/theme/Navbar/Logo/index.tsx +1 -1
- package/src/theme/Navbar/Search/index.tsx +15 -0
- package/src/theme/Navbar/Search/styles.module.css +20 -0
- package/src/theme/NavbarItem/ComponentTypes.tsx +32 -0
- package/src/theme/NavbarItem/DocNavbarItem.tsx +13 -32
- package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +9 -49
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +26 -33
- package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +3 -10
- package/src/theme/NavbarItem/DropdownNavbarItem.tsx +4 -1
- package/src/theme/NavbarItem/HtmlNavbarItem.tsx +32 -0
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +5 -9
- package/src/theme/NavbarItem/NavbarNavLink.tsx +41 -25
- package/src/theme/NavbarItem/SearchNavbarItem.tsx +6 -1
- package/src/theme/NavbarItem/index.tsx +9 -38
- package/src/theme/NavbarItem/utils.ts +5 -2
- package/src/theme/PaginatorNavLink/index.tsx +8 -2
- package/src/theme/SiteMetadata/index.tsx +8 -8
- package/src/theme/SkipToContent/index.tsx +3 -29
- package/{lib-next/theme/TOCCollapsible/styles.module.css → src/theme/TOCCollapsible/CollapseButton.module.css} +1 -22
- package/src/theme/TOCCollapsible/CollapseButton.tsx +35 -0
- package/src/theme/TOCCollapsible/index.module.css +31 -0
- package/src/theme/TOCCollapsible/index.tsx +3 -14
- package/src/theme/TOCItems/Tree.tsx +46 -0
- package/src/theme/TOCItems/index.tsx +2 -41
- package/src/theme/TabItem/index.tsx +7 -1
- package/src/theme/TabItem/styles.module.css +10 -0
- package/src/theme/Tabs/index.tsx +3 -3
- package/src/theme/Tabs/styles.module.css +4 -0
- package/src/theme/Tag/index.tsx +2 -4
- package/src/theme/TagsListInline/index.tsx +1 -1
- package/src/theme-classic.d.ts +315 -33
- package/src/validateThemeConfig.ts +80 -13
- package/lib/types.d.ts +0 -11
- package/lib-next/theme/DocPage/styles.module.css +0 -82
- package/src/theme/DocPage/styles.module.css +0 -82
- package/src/types.d.ts +0 -11
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
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 from 'react';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
import {
|
|
10
|
+
usePrismTheme,
|
|
11
|
+
getPrismCssVariables,
|
|
12
|
+
ThemeClassNames,
|
|
13
|
+
} from '@docusaurus/theme-common';
|
|
14
|
+
import styles from './styles.module.css';
|
|
15
|
+
export default function CodeBlockContainer({as: As, ...props}) {
|
|
16
|
+
const prismTheme = usePrismTheme();
|
|
17
|
+
const prismCssVariables = getPrismCssVariables(prismTheme);
|
|
18
|
+
return (
|
|
19
|
+
<As // Polymorphic components are hard to type, without `oneOf` generics
|
|
20
|
+
{...props}
|
|
21
|
+
style={prismCssVariables}
|
|
22
|
+
className={clsx(
|
|
23
|
+
props.className,
|
|
24
|
+
styles.codeBlockContainer,
|
|
25
|
+
ThemeClassNames.common.codeBlock,
|
|
26
|
+
)}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
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
|
+
|
|
8
|
+
.codeBlockContainer {
|
|
9
|
+
background: var(--prism-background-color);
|
|
10
|
+
color: var(--prism-color);
|
|
11
|
+
margin-bottom: var(--ifm-leading);
|
|
12
|
+
box-shadow: var(--ifm-global-shadow-lw);
|
|
13
|
+
border-radius: var(--ifm-code-border-radius);
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
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 from 'react';
|
|
8
|
+
import Container from '@theme/CodeBlock/Container';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import styles from './styles.module.css'; // <pre> tags in markdown map to CodeBlocks. They may contain JSX children. When
|
|
11
|
+
// the children is not a simple string, we just return a styled block without
|
|
12
|
+
// actually highlighting.
|
|
13
|
+
|
|
14
|
+
export default function CodeBlockJSX({children, className}) {
|
|
15
|
+
return (
|
|
16
|
+
<Container
|
|
17
|
+
as="pre"
|
|
18
|
+
tabIndex={0}
|
|
19
|
+
className={clsx(styles.codeBlockStandalone, 'thin-scrollbar', className)}>
|
|
20
|
+
<code className={styles.codeBlockLines}>{children}</code>
|
|
21
|
+
</Container>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
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 from 'react';
|
|
8
|
+
import {
|
|
9
|
+
useThemeConfig,
|
|
10
|
+
parseCodeBlockTitle,
|
|
11
|
+
parseLanguage,
|
|
12
|
+
parseLines,
|
|
13
|
+
containsLineNumbers,
|
|
14
|
+
usePrismTheme,
|
|
15
|
+
useCodeWordWrap,
|
|
16
|
+
} from '@docusaurus/theme-common';
|
|
17
|
+
import clsx from 'clsx';
|
|
18
|
+
import Highlight, {defaultProps} from 'prism-react-renderer';
|
|
19
|
+
import Line from '@theme/CodeBlock/Line';
|
|
20
|
+
import CopyButton from '@theme/CodeBlock/CopyButton';
|
|
21
|
+
import WordWrapButton from '@theme/CodeBlock/WordWrapButton';
|
|
22
|
+
import Container from '@theme/CodeBlock/Container';
|
|
23
|
+
import styles from './styles.module.css';
|
|
24
|
+
export default function CodeBlockString({
|
|
25
|
+
children,
|
|
26
|
+
className: blockClassName = '',
|
|
27
|
+
metastring,
|
|
28
|
+
title: titleProp,
|
|
29
|
+
showLineNumbers: showLineNumbersProp,
|
|
30
|
+
language: languageProp,
|
|
31
|
+
}) {
|
|
32
|
+
const {
|
|
33
|
+
prism: {defaultLanguage, magicComments},
|
|
34
|
+
} = useThemeConfig();
|
|
35
|
+
const language =
|
|
36
|
+
languageProp ?? parseLanguage(blockClassName) ?? defaultLanguage;
|
|
37
|
+
const prismTheme = usePrismTheme();
|
|
38
|
+
const wordWrap = useCodeWordWrap(); // We still parse the metastring in case we want to support more syntax in the
|
|
39
|
+
// future. Note that MDX doesn't strip quotes when parsing metastring:
|
|
40
|
+
// "title=\"xyz\"" => title: "\"xyz\""
|
|
41
|
+
|
|
42
|
+
const title = parseCodeBlockTitle(metastring) || titleProp;
|
|
43
|
+
const {lineClassNames, code} = parseLines(children, {
|
|
44
|
+
metastring,
|
|
45
|
+
language,
|
|
46
|
+
magicComments,
|
|
47
|
+
});
|
|
48
|
+
const showLineNumbers =
|
|
49
|
+
showLineNumbersProp || containsLineNumbers(metastring);
|
|
50
|
+
return (
|
|
51
|
+
<Container
|
|
52
|
+
as="div"
|
|
53
|
+
className={clsx(
|
|
54
|
+
blockClassName,
|
|
55
|
+
language &&
|
|
56
|
+
!blockClassName.includes(`language-${language}`) &&
|
|
57
|
+
`language-${language}`,
|
|
58
|
+
)}>
|
|
59
|
+
{title && <div className={styles.codeBlockTitle}>{title}</div>}
|
|
60
|
+
<div className={styles.codeBlockContent}>
|
|
61
|
+
<Highlight
|
|
62
|
+
{...defaultProps}
|
|
63
|
+
theme={prismTheme}
|
|
64
|
+
code={code}
|
|
65
|
+
language={language ?? 'text'}>
|
|
66
|
+
{({className, tokens, getLineProps, getTokenProps}) => (
|
|
67
|
+
<pre
|
|
68
|
+
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
|
69
|
+
tabIndex={0}
|
|
70
|
+
ref={wordWrap.codeBlockRef}
|
|
71
|
+
className={clsx(className, styles.codeBlock, 'thin-scrollbar')}>
|
|
72
|
+
<code
|
|
73
|
+
className={clsx(
|
|
74
|
+
styles.codeBlockLines,
|
|
75
|
+
showLineNumbers && styles.codeBlockLinesWithNumbering,
|
|
76
|
+
)}>
|
|
77
|
+
{tokens.map((line, i) => (
|
|
78
|
+
<Line
|
|
79
|
+
key={i}
|
|
80
|
+
line={line}
|
|
81
|
+
getLineProps={getLineProps}
|
|
82
|
+
getTokenProps={getTokenProps}
|
|
83
|
+
classNames={lineClassNames[i]}
|
|
84
|
+
showLineNumbers={showLineNumbers}
|
|
85
|
+
/>
|
|
86
|
+
))}
|
|
87
|
+
</code>
|
|
88
|
+
</pre>
|
|
89
|
+
)}
|
|
90
|
+
</Highlight>
|
|
91
|
+
<div className={styles.buttonGroup}>
|
|
92
|
+
{(wordWrap.isEnabled || wordWrap.isCodeScrollable) && (
|
|
93
|
+
<WordWrapButton
|
|
94
|
+
className={styles.codeButton}
|
|
95
|
+
onClick={() => wordWrap.toggle()}
|
|
96
|
+
isEnabled={wordWrap.isEnabled}
|
|
97
|
+
/>
|
|
98
|
+
)}
|
|
99
|
+
<CopyButton className={styles.codeButton} code={code} />
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
</Container>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
@@ -5,16 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
.codeBlockContainer {
|
|
9
|
-
margin-bottom: var(--ifm-leading);
|
|
10
|
-
box-shadow: var(--ifm-global-shadow-lw);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
8
|
.codeBlockContent {
|
|
14
9
|
position: relative;
|
|
15
10
|
/* rtl:ignore */
|
|
16
11
|
direction: ltr;
|
|
17
|
-
border-radius:
|
|
12
|
+
border-radius: inherit;
|
|
18
13
|
}
|
|
19
14
|
|
|
20
15
|
.codeBlockTitle {
|
|
@@ -22,14 +17,14 @@
|
|
|
22
17
|
font-size: var(--ifm-code-font-size);
|
|
23
18
|
font-weight: 500;
|
|
24
19
|
padding: 0.75rem var(--ifm-pre-padding);
|
|
25
|
-
border-top-left-radius:
|
|
26
|
-
border-top-right-radius:
|
|
20
|
+
border-top-left-radius: inherit;
|
|
21
|
+
border-top-right-radius: inherit;
|
|
27
22
|
}
|
|
28
23
|
|
|
29
24
|
.codeBlock {
|
|
25
|
+
--ifm-pre-background: var(--prism-background-color);
|
|
30
26
|
margin: 0;
|
|
31
27
|
padding: 0;
|
|
32
|
-
background-color: inherit;
|
|
33
28
|
}
|
|
34
29
|
|
|
35
30
|
.codeBlockTitle + .codeBlockContent .codeBlock {
|
|
@@ -49,8 +44,43 @@
|
|
|
49
44
|
padding: var(--ifm-pre-padding);
|
|
50
45
|
}
|
|
51
46
|
|
|
47
|
+
.codeBlockLinesWithNumbering {
|
|
48
|
+
display: table;
|
|
49
|
+
padding: var(--ifm-pre-padding) 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
52
|
@media print {
|
|
53
53
|
.codeBlockLines {
|
|
54
54
|
white-space: pre-wrap;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
|
|
58
|
+
.buttonGroup {
|
|
59
|
+
display: flex;
|
|
60
|
+
column-gap: 0.2rem;
|
|
61
|
+
position: absolute;
|
|
62
|
+
right: calc(var(--ifm-pre-padding) / 2);
|
|
63
|
+
top: calc(var(--ifm-pre-padding) / 2);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.buttonGroup button {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
background: var(--prism-background-color);
|
|
70
|
+
color: var(--prism-color);
|
|
71
|
+
border: 1px solid var(--ifm-color-emphasis-300);
|
|
72
|
+
border-radius: var(--ifm-global-radius);
|
|
73
|
+
padding: 0.4rem;
|
|
74
|
+
line-height: 0;
|
|
75
|
+
transition: opacity 200ms ease-in-out;
|
|
76
|
+
opacity: 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.buttonGroup button:focus-visible,
|
|
80
|
+
.buttonGroup button:hover {
|
|
81
|
+
opacity: 1 !important;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
:global(.theme-code-block:hover) .buttonGroup button {
|
|
85
|
+
opacity: 0.4;
|
|
86
|
+
}
|
|
@@ -9,7 +9,7 @@ import clsx from 'clsx';
|
|
|
9
9
|
import copy from 'copy-text-to-clipboard';
|
|
10
10
|
import {translate} from '@docusaurus/Translate';
|
|
11
11
|
import styles from './styles.module.css';
|
|
12
|
-
export default function CopyButton({code}) {
|
|
12
|
+
export default function CopyButton({code, className}) {
|
|
13
13
|
const [isCopied, setIsCopied] = useState(false);
|
|
14
14
|
const copyTimeout = useRef(undefined);
|
|
15
15
|
const handleCopyCode = useCallback(() => {
|
|
@@ -42,8 +42,9 @@ export default function CopyButton({code}) {
|
|
|
42
42
|
description: 'The copy button label on code blocks',
|
|
43
43
|
})}
|
|
44
44
|
className={clsx(
|
|
45
|
-
styles.copyButton,
|
|
46
45
|
'clean-btn',
|
|
46
|
+
className,
|
|
47
|
+
styles.copyButton,
|
|
47
48
|
isCopied && styles.copyButtonCopied,
|
|
48
49
|
)}
|
|
49
50
|
onClick={handleCopyCode}>
|
|
@@ -5,29 +5,10 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
.copyButton {
|
|
9
|
-
display: flex;
|
|
10
|
-
background: inherit;
|
|
11
|
-
border: 1px solid var(--ifm-color-emphasis-300);
|
|
12
|
-
border-radius: var(--ifm-global-radius);
|
|
13
|
-
padding: 0.4rem;
|
|
14
|
-
position: absolute;
|
|
15
|
-
right: calc(var(--ifm-pre-padding) / 2);
|
|
16
|
-
top: calc(var(--ifm-pre-padding) / 2);
|
|
17
|
-
transition: opacity 200ms ease-in-out;
|
|
18
|
-
opacity: 0;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.copyButton:focus-visible,
|
|
22
|
-
.copyButton:hover,
|
|
23
8
|
:global(.theme-code-block:hover) .copyButtonCopied {
|
|
24
9
|
opacity: 1 !important;
|
|
25
10
|
}
|
|
26
11
|
|
|
27
|
-
:global(.theme-code-block:hover) .copyButton:not(.copyButtonCopied) {
|
|
28
|
-
opacity: 0.4;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
12
|
.copyButtonIcons {
|
|
32
13
|
position: relative;
|
|
33
14
|
width: 1.125rem;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
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 from 'react';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
import styles from './styles.module.css';
|
|
10
|
+
export default function CodeBlockLine({
|
|
11
|
+
line,
|
|
12
|
+
classNames,
|
|
13
|
+
showLineNumbers,
|
|
14
|
+
getLineProps,
|
|
15
|
+
getTokenProps,
|
|
16
|
+
}) {
|
|
17
|
+
if (line.length === 1 && line[0].content === '\n') {
|
|
18
|
+
line[0].content = '';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const lineProps = getLineProps({
|
|
22
|
+
line,
|
|
23
|
+
className: clsx(classNames, showLineNumbers && styles.codeLine),
|
|
24
|
+
});
|
|
25
|
+
const lineTokens = line.map((token, key) => (
|
|
26
|
+
<span
|
|
27
|
+
key={key}
|
|
28
|
+
{...getTokenProps({
|
|
29
|
+
token,
|
|
30
|
+
key,
|
|
31
|
+
})}
|
|
32
|
+
/>
|
|
33
|
+
));
|
|
34
|
+
return (
|
|
35
|
+
<span {...lineProps}>
|
|
36
|
+
{showLineNumbers ? (
|
|
37
|
+
<>
|
|
38
|
+
<span className={styles.codeLineNumber} />
|
|
39
|
+
<span className={styles.codeLineContent}>{lineTokens}</span>
|
|
40
|
+
</>
|
|
41
|
+
) : (
|
|
42
|
+
<>
|
|
43
|
+
{lineTokens}
|
|
44
|
+
<br />
|
|
45
|
+
</>
|
|
46
|
+
)}
|
|
47
|
+
</span>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
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
|
+
|
|
8
|
+
:global(.theme-code-block-highlighted-line) {
|
|
9
|
+
background-color: var(--docusaurus-highlighted-code-line-bg);
|
|
10
|
+
display: block;
|
|
11
|
+
margin: 0 calc(-1 * var(--ifm-pre-padding));
|
|
12
|
+
padding: 0 var(--ifm-pre-padding);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* Intentionally has zero specificity, so that to be able to override
|
|
16
|
+
the background in custom CSS file due bug https://github.com/facebook/docusaurus/issues/3678 */
|
|
17
|
+
:where(:root) {
|
|
18
|
+
--docusaurus-highlighted-code-line-bg: rgb(72 77 91);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
:where([data-theme='dark']) {
|
|
22
|
+
--docusaurus-highlighted-code-line-bg: rgb(100 100 100);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.codeLine {
|
|
26
|
+
display: table-row;
|
|
27
|
+
counter-increment: line-count;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.codeLineNumber {
|
|
31
|
+
display: table-cell;
|
|
32
|
+
text-align: right;
|
|
33
|
+
width: 1%;
|
|
34
|
+
position: sticky;
|
|
35
|
+
left: 0;
|
|
36
|
+
padding: 0 var(--ifm-pre-padding);
|
|
37
|
+
background: var(--ifm-pre-background);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.codeLineNumber::before {
|
|
41
|
+
content: counter(line-count);
|
|
42
|
+
opacity: 0.4;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.highlightedCodeLine .codeLineNumber::before {
|
|
46
|
+
opacity: 0.8;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.codeLineContent {
|
|
50
|
+
padding-right: var(--ifm-pre-padding);
|
|
51
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
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 from 'react';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
import {translate} from '@docusaurus/Translate';
|
|
10
|
+
import styles from './styles.module.css';
|
|
11
|
+
export default function WordWrapButton({className, onClick, isEnabled}) {
|
|
12
|
+
const title = translate({
|
|
13
|
+
id: 'theme.CodeBlock.wordWrapToggle',
|
|
14
|
+
message: 'Toggle word wrap',
|
|
15
|
+
description:
|
|
16
|
+
'The title attribute for toggle word wrapping button of code block lines',
|
|
17
|
+
});
|
|
18
|
+
return (
|
|
19
|
+
<button
|
|
20
|
+
type="button"
|
|
21
|
+
onClick={onClick}
|
|
22
|
+
className={clsx(
|
|
23
|
+
'clean-btn',
|
|
24
|
+
className,
|
|
25
|
+
isEnabled && styles.wordWrapButtonEnabled,
|
|
26
|
+
)}
|
|
27
|
+
aria-label={title}
|
|
28
|
+
title={title}>
|
|
29
|
+
<svg
|
|
30
|
+
className={styles.wordWrapButtonIcon}
|
|
31
|
+
viewBox="0 0 24 24"
|
|
32
|
+
aria-hidden="true">
|
|
33
|
+
<path
|
|
34
|
+
fill="currentColor"
|
|
35
|
+
d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3l3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"
|
|
36
|
+
/>
|
|
37
|
+
</svg>
|
|
38
|
+
</button>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
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
|
+
|
|
8
|
+
.wordWrapButtonIcon {
|
|
9
|
+
width: 1.2rem;
|
|
10
|
+
height: 1.2rem;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.wordWrapButtonEnabled .wordWrapButtonIcon {
|
|
14
|
+
color: var(--ifm-color-primary);
|
|
15
|
+
}
|
|
@@ -4,143 +4,37 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, {isValidElement
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from '@docusaurus/theme-common';
|
|
18
|
-
import CopyButton from '@theme/CodeBlock/CopyButton';
|
|
19
|
-
import styles from './styles.module.css';
|
|
20
|
-
export default function CodeBlock({
|
|
21
|
-
children,
|
|
22
|
-
className: blockClassName = '',
|
|
23
|
-
metastring,
|
|
24
|
-
title,
|
|
25
|
-
language: languageProp,
|
|
26
|
-
}) {
|
|
27
|
-
const {prism} = useThemeConfig();
|
|
28
|
-
const [mounted, setMounted] = useState(false); // The Prism theme on SSR is always the default theme but the site theme
|
|
29
|
-
// can be in a different mode. React hydration doesn't update DOM styles
|
|
30
|
-
// that come from SSR. Hence force a re-render after mounting to apply the
|
|
31
|
-
// current relevant styles. There will be a flash seen of the original
|
|
32
|
-
// styles seen using this current approach but that's probably ok. Fixing
|
|
33
|
-
// the flash will require changing the theming approach and is not worth it
|
|
34
|
-
// at this point.
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
setMounted(true);
|
|
38
|
-
}, []); // We still parse the metastring in case we want to support more syntax in the
|
|
39
|
-
// future. Note that MDX doesn't strip quotes when parsing metastring:
|
|
40
|
-
// "title=\"xyz\"" => title: "\"xyz\""
|
|
41
|
-
|
|
42
|
-
const codeBlockTitle = parseCodeBlockTitle(metastring) || title;
|
|
43
|
-
const prismTheme = usePrismTheme(); // <pre> tags in markdown map to CodeBlocks and they may contain JSX children.
|
|
44
|
-
// When the children is not a simple string, we just return a styled block
|
|
45
|
-
// without actually highlighting.
|
|
7
|
+
import React, {isValidElement} from 'react';
|
|
8
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
9
|
+
import ElementContent from '@theme/CodeBlock/Content/Element';
|
|
10
|
+
import StringContent from '@theme/CodeBlock/Content/String';
|
|
11
|
+
/**
|
|
12
|
+
* Best attempt to make the children a plain string so it is copyable. If there
|
|
13
|
+
* are react elements, we will not be able to copy the content, and it will
|
|
14
|
+
* return `children` as-is; otherwise, it concatenates the string children
|
|
15
|
+
* together.
|
|
16
|
+
*/
|
|
46
17
|
|
|
18
|
+
function maybeStringifyChildren(children) {
|
|
47
19
|
if (React.Children.toArray(children).some((el) => isValidElement(el))) {
|
|
48
|
-
return
|
|
49
|
-
<Highlight
|
|
50
|
-
{...defaultProps}
|
|
51
|
-
key={String(mounted)}
|
|
52
|
-
theme={prismTheme}
|
|
53
|
-
code=""
|
|
54
|
-
language={'text'}>
|
|
55
|
-
{({className, style}) => (
|
|
56
|
-
<pre
|
|
57
|
-
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
|
58
|
-
tabIndex={0}
|
|
59
|
-
className={clsx(
|
|
60
|
-
className,
|
|
61
|
-
styles.codeBlockStandalone,
|
|
62
|
-
'thin-scrollbar',
|
|
63
|
-
styles.codeBlockContainer,
|
|
64
|
-
blockClassName,
|
|
65
|
-
ThemeClassNames.common.codeBlock,
|
|
66
|
-
)}
|
|
67
|
-
style={style}>
|
|
68
|
-
<code className={styles.codeBlockLines}>{children}</code>
|
|
69
|
-
</pre>
|
|
70
|
-
)}
|
|
71
|
-
</Highlight>
|
|
72
|
-
);
|
|
20
|
+
return children;
|
|
73
21
|
} // The children is now guaranteed to be one/more plain strings
|
|
74
22
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
languageProp ?? parseLanguage(blockClassName) ?? prism.defaultLanguage;
|
|
78
|
-
const {highlightLines, code} = parseLines(content, metastring, language);
|
|
79
|
-
return (
|
|
80
|
-
<Highlight
|
|
81
|
-
{...defaultProps}
|
|
82
|
-
key={String(mounted)}
|
|
83
|
-
theme={prismTheme}
|
|
84
|
-
code={code}
|
|
85
|
-
language={language ?? 'text'}>
|
|
86
|
-
{({className, style, tokens, getLineProps, getTokenProps}) => (
|
|
87
|
-
<div
|
|
88
|
-
className={clsx(
|
|
89
|
-
styles.codeBlockContainer,
|
|
90
|
-
blockClassName,
|
|
91
|
-
{
|
|
92
|
-
[`language-${language}`]:
|
|
93
|
-
language && !blockClassName.includes(`language-${language}`),
|
|
94
|
-
},
|
|
95
|
-
ThemeClassNames.common.codeBlock,
|
|
96
|
-
)}>
|
|
97
|
-
{codeBlockTitle && (
|
|
98
|
-
<div style={style} className={styles.codeBlockTitle}>
|
|
99
|
-
{codeBlockTitle}
|
|
100
|
-
</div>
|
|
101
|
-
)}
|
|
102
|
-
<div className={styles.codeBlockContent} style={style}>
|
|
103
|
-
<pre
|
|
104
|
-
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
|
105
|
-
tabIndex={0}
|
|
106
|
-
className={clsx(className, styles.codeBlock, 'thin-scrollbar')}>
|
|
107
|
-
<code className={styles.codeBlockLines}>
|
|
108
|
-
{tokens.map((line, i) => {
|
|
109
|
-
if (line.length === 1 && line[0].content === '\n') {
|
|
110
|
-
line[0].content = '';
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const lineProps = getLineProps({
|
|
114
|
-
line,
|
|
115
|
-
key: i,
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
if (highlightLines.includes(i)) {
|
|
119
|
-
lineProps.className += ' docusaurus-highlight-code-line';
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<span key={i} {...lineProps}>
|
|
124
|
-
{line.map((token, key) => (
|
|
125
|
-
<span
|
|
126
|
-
key={key}
|
|
127
|
-
{...getTokenProps({
|
|
128
|
-
token,
|
|
129
|
-
key,
|
|
130
|
-
})}
|
|
131
|
-
/>
|
|
132
|
-
))}
|
|
133
|
-
<br />
|
|
134
|
-
</span>
|
|
135
|
-
);
|
|
136
|
-
})}
|
|
137
|
-
</code>
|
|
138
|
-
</pre>
|
|
23
|
+
return Array.isArray(children) ? children.join('') : children;
|
|
24
|
+
}
|
|
139
25
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
26
|
+
export default function CodeBlock({children: rawChildren, ...props}) {
|
|
27
|
+
// The Prism theme on SSR is always the default theme but the site theme can
|
|
28
|
+
// be in a different mode. React hydration doesn't update DOM styles that come
|
|
29
|
+
// from SSR. Hence force a re-render after mounting to apply the current
|
|
30
|
+
// relevant styles.
|
|
31
|
+
const isBrowser = useIsBrowser();
|
|
32
|
+
const children = maybeStringifyChildren(rawChildren);
|
|
33
|
+
const CodeBlockComp =
|
|
34
|
+
typeof children === 'string' ? StringContent : ElementContent;
|
|
35
|
+
return (
|
|
36
|
+
<CodeBlockComp key={String(isBrowser)} {...props}>
|
|
37
|
+
{children}
|
|
38
|
+
</CodeBlockComp>
|
|
145
39
|
);
|
|
146
40
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
|
-
import {Details as DetailsGeneric} from '@docusaurus/theme-common';
|
|
9
|
+
import {Details as DetailsGeneric} from '@docusaurus/theme-common/Details';
|
|
10
10
|
import styles from './styles.module.css'; // Should we have a custom details/summary comp in Infima instead of reusing
|
|
11
11
|
// alert classes?
|
|
12
12
|
|