@docusaurus/theme-classic 0.0.0-4900 → 0.0.0-4901
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/theme-classic.d.ts +11 -0
- package/lib-next/theme/CodeBlock/Content/String.js +15 -2
- package/lib-next/theme/CodeBlock/Content/styles.module.css +30 -0
- package/lib-next/theme/CodeBlock/CopyButton/index.js +3 -2
- package/lib-next/theme/CodeBlock/CopyButton/styles.module.css +0 -21
- package/lib-next/theme/CodeBlock/WordWrapButton/index.js +40 -0
- package/lib-next/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
- package/package.json +13 -13
- package/src/theme/CodeBlock/Content/String.tsx +14 -1
- package/src/theme/CodeBlock/Content/styles.module.css +30 -0
- package/src/theme/CodeBlock/CopyButton/index.tsx +3 -2
- package/src/theme/CodeBlock/CopyButton/styles.module.css +0 -21
- package/src/theme/CodeBlock/WordWrapButton/index.tsx +49 -0
- package/src/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
- package/src/theme-classic.d.ts +11 -0
package/lib/theme-classic.d.ts
CHANGED
|
@@ -165,6 +165,7 @@ declare module '@theme/CodeBlock' {
|
|
|
165
165
|
declare module '@theme/CodeBlock/CopyButton' {
|
|
166
166
|
export interface Props {
|
|
167
167
|
readonly code: string;
|
|
168
|
+
readonly className?: string;
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
export default function CopyButton(props: Props): JSX.Element;
|
|
@@ -220,6 +221,16 @@ declare module '@theme/CodeBlock/Line' {
|
|
|
220
221
|
export default function CodeBlockLine(props: Props): JSX.Element;
|
|
221
222
|
}
|
|
222
223
|
|
|
224
|
+
declare module '@theme/CodeBlock/WordWrapButton' {
|
|
225
|
+
export interface Props {
|
|
226
|
+
readonly className?: string;
|
|
227
|
+
readonly onClick: React.MouseEventHandler;
|
|
228
|
+
readonly isEnabled: boolean;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export default function WordWrapButton(props: Props): JSX.Element;
|
|
232
|
+
}
|
|
233
|
+
|
|
223
234
|
declare module '@theme/DocCard' {
|
|
224
235
|
import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
|
|
225
236
|
|
|
@@ -12,11 +12,13 @@ import {
|
|
|
12
12
|
parseLines,
|
|
13
13
|
containsLineNumbers,
|
|
14
14
|
usePrismTheme,
|
|
15
|
+
useCodeWordWrap,
|
|
15
16
|
} from '@docusaurus/theme-common';
|
|
16
17
|
import clsx from 'clsx';
|
|
17
18
|
import Highlight, {defaultProps} from 'prism-react-renderer';
|
|
18
19
|
import Line from '@theme/CodeBlock/Line';
|
|
19
20
|
import CopyButton from '@theme/CodeBlock/CopyButton';
|
|
21
|
+
import WordWrapButton from '@theme/CodeBlock/WordWrapButton';
|
|
20
22
|
import Container from '@theme/CodeBlock/Container';
|
|
21
23
|
import styles from './styles.module.css';
|
|
22
24
|
export default function CodeBlockString({
|
|
@@ -32,7 +34,8 @@ export default function CodeBlockString({
|
|
|
32
34
|
} = useThemeConfig();
|
|
33
35
|
const language =
|
|
34
36
|
languageProp ?? parseLanguage(blockClassName) ?? defaultLanguage;
|
|
35
|
-
const prismTheme = usePrismTheme();
|
|
37
|
+
const prismTheme = usePrismTheme();
|
|
38
|
+
const wordWrap = useCodeWordWrap(); // We still parse the metastring in case we want to support more syntax in the
|
|
36
39
|
// future. Note that MDX doesn't strip quotes when parsing metastring:
|
|
37
40
|
// "title=\"xyz\"" => title: "\"xyz\""
|
|
38
41
|
|
|
@@ -60,6 +63,7 @@ export default function CodeBlockString({
|
|
|
60
63
|
<pre
|
|
61
64
|
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
|
62
65
|
tabIndex={0}
|
|
66
|
+
ref={wordWrap.codeBlockRef}
|
|
63
67
|
className={clsx(className, styles.codeBlock, 'thin-scrollbar')}>
|
|
64
68
|
<code
|
|
65
69
|
className={clsx(
|
|
@@ -80,7 +84,16 @@ export default function CodeBlockString({
|
|
|
80
84
|
</pre>
|
|
81
85
|
)}
|
|
82
86
|
</Highlight>
|
|
83
|
-
<
|
|
87
|
+
<div className={styles.buttonGroup}>
|
|
88
|
+
{(wordWrap.isEnabled || wordWrap.isCodeScrollable) && (
|
|
89
|
+
<WordWrapButton
|
|
90
|
+
className={styles.codeButton}
|
|
91
|
+
onClick={() => wordWrap.toggle()}
|
|
92
|
+
isEnabled={wordWrap.isEnabled}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
95
|
+
<CopyButton className={styles.codeButton} code={code} />
|
|
96
|
+
</div>
|
|
84
97
|
</div>
|
|
85
98
|
</Container>
|
|
86
99
|
);
|
|
@@ -54,3 +54,33 @@
|
|
|
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,31 +5,10 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
.copyButton {
|
|
9
|
-
display: flex;
|
|
10
|
-
/* TODO: move to base button styling */
|
|
11
|
-
background: var(--prism-background-color);
|
|
12
|
-
color: var(--prism-color);
|
|
13
|
-
border: 1px solid var(--ifm-color-emphasis-300);
|
|
14
|
-
border-radius: var(--ifm-global-radius);
|
|
15
|
-
padding: 0.4rem;
|
|
16
|
-
position: absolute;
|
|
17
|
-
right: calc(var(--ifm-pre-padding) / 2);
|
|
18
|
-
top: calc(var(--ifm-pre-padding) / 2);
|
|
19
|
-
transition: opacity 200ms ease-in-out;
|
|
20
|
-
opacity: 0;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.copyButton:focus-visible,
|
|
24
|
-
.copyButton:hover,
|
|
25
8
|
:global(.theme-code-block:hover) .copyButtonCopied {
|
|
26
9
|
opacity: 1 !important;
|
|
27
10
|
}
|
|
28
11
|
|
|
29
|
-
:global(.theme-code-block:hover) .copyButton:not(.copyButtonCopied) {
|
|
30
|
-
opacity: 0.4;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
12
|
.copyButtonIcons {
|
|
34
13
|
position: relative;
|
|
35
14
|
width: 1.125rem;
|
|
@@ -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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4901",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@docusaurus/core": "0.0.0-
|
|
25
|
-
"@docusaurus/plugin-content-blog": "0.0.0-
|
|
26
|
-
"@docusaurus/plugin-content-docs": "0.0.0-
|
|
27
|
-
"@docusaurus/plugin-content-pages": "0.0.0-
|
|
28
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
29
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
30
|
-
"@docusaurus/utils": "0.0.0-
|
|
31
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
32
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
24
|
+
"@docusaurus/core": "0.0.0-4901",
|
|
25
|
+
"@docusaurus/plugin-content-blog": "0.0.0-4901",
|
|
26
|
+
"@docusaurus/plugin-content-docs": "0.0.0-4901",
|
|
27
|
+
"@docusaurus/plugin-content-pages": "0.0.0-4901",
|
|
28
|
+
"@docusaurus/theme-common": "0.0.0-4901",
|
|
29
|
+
"@docusaurus/theme-translations": "0.0.0-4901",
|
|
30
|
+
"@docusaurus/utils": "0.0.0-4901",
|
|
31
|
+
"@docusaurus/utils-common": "0.0.0-4901",
|
|
32
|
+
"@docusaurus/utils-validation": "0.0.0-4901",
|
|
33
33
|
"@mdx-js/react": "^1.6.22",
|
|
34
34
|
"clsx": "^1.1.1",
|
|
35
35
|
"copy-text-to-clipboard": "^3.0.1",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@babel/cli": "^7.17.6",
|
|
46
46
|
"@babel/core": "^7.17.9",
|
|
47
47
|
"@babel/preset-typescript": "^7.16.7",
|
|
48
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
49
|
-
"@docusaurus/types": "0.0.0-
|
|
48
|
+
"@docusaurus/module-type-aliases": "0.0.0-4901",
|
|
49
|
+
"@docusaurus/types": "0.0.0-4901",
|
|
50
50
|
"@types/mdx-js__react": "^1.5.5",
|
|
51
51
|
"@types/prismjs": "^1.26.0",
|
|
52
52
|
"@types/rtlcss": "^3.1.4",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=14"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "6dd77ca6acf315addc7252112093a4ac4ebfe7f7"
|
|
66
66
|
}
|
|
@@ -13,11 +13,13 @@ import {
|
|
|
13
13
|
parseLines,
|
|
14
14
|
containsLineNumbers,
|
|
15
15
|
usePrismTheme,
|
|
16
|
+
useCodeWordWrap,
|
|
16
17
|
} from '@docusaurus/theme-common';
|
|
17
18
|
import clsx from 'clsx';
|
|
18
19
|
import Highlight, {defaultProps, type Language} from 'prism-react-renderer';
|
|
19
20
|
import Line from '@theme/CodeBlock/Line';
|
|
20
21
|
import CopyButton from '@theme/CodeBlock/CopyButton';
|
|
22
|
+
import WordWrapButton from '@theme/CodeBlock/WordWrapButton';
|
|
21
23
|
import Container from '@theme/CodeBlock/Container';
|
|
22
24
|
import type {Props} from '@theme/CodeBlock/Content/String';
|
|
23
25
|
|
|
@@ -37,6 +39,7 @@ export default function CodeBlockString({
|
|
|
37
39
|
const language =
|
|
38
40
|
languageProp ?? parseLanguage(blockClassName) ?? defaultLanguage;
|
|
39
41
|
const prismTheme = usePrismTheme();
|
|
42
|
+
const wordWrap = useCodeWordWrap();
|
|
40
43
|
|
|
41
44
|
// We still parse the metastring in case we want to support more syntax in the
|
|
42
45
|
// future. Note that MDX doesn't strip quotes when parsing metastring:
|
|
@@ -67,6 +70,7 @@ export default function CodeBlockString({
|
|
|
67
70
|
<pre
|
|
68
71
|
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
|
69
72
|
tabIndex={0}
|
|
73
|
+
ref={wordWrap.codeBlockRef}
|
|
70
74
|
className={clsx(className, styles.codeBlock, 'thin-scrollbar')}>
|
|
71
75
|
<code
|
|
72
76
|
className={clsx(
|
|
@@ -87,7 +91,16 @@ export default function CodeBlockString({
|
|
|
87
91
|
</pre>
|
|
88
92
|
)}
|
|
89
93
|
</Highlight>
|
|
90
|
-
<
|
|
94
|
+
<div className={styles.buttonGroup}>
|
|
95
|
+
{(wordWrap.isEnabled || wordWrap.isCodeScrollable) && (
|
|
96
|
+
<WordWrapButton
|
|
97
|
+
className={styles.codeButton}
|
|
98
|
+
onClick={() => wordWrap.toggle()}
|
|
99
|
+
isEnabled={wordWrap.isEnabled}
|
|
100
|
+
/>
|
|
101
|
+
)}
|
|
102
|
+
<CopyButton className={styles.codeButton} code={code} />
|
|
103
|
+
</div>
|
|
91
104
|
</div>
|
|
92
105
|
</Container>
|
|
93
106
|
);
|
|
@@ -54,3 +54,33 @@
|
|
|
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
|
+
}
|
|
@@ -13,7 +13,7 @@ import type {Props} from '@theme/CodeBlock/CopyButton';
|
|
|
13
13
|
|
|
14
14
|
import styles from './styles.module.css';
|
|
15
15
|
|
|
16
|
-
export default function CopyButton({code}: Props): JSX.Element {
|
|
16
|
+
export default function CopyButton({code, className}: Props): JSX.Element {
|
|
17
17
|
const [isCopied, setIsCopied] = useState(false);
|
|
18
18
|
const copyTimeout = useRef<number | undefined>(undefined);
|
|
19
19
|
const handleCopyCode = useCallback(() => {
|
|
@@ -48,8 +48,9 @@ export default function CopyButton({code}: Props): JSX.Element {
|
|
|
48
48
|
description: 'The copy button label on code blocks',
|
|
49
49
|
})}
|
|
50
50
|
className={clsx(
|
|
51
|
-
styles.copyButton,
|
|
52
51
|
'clean-btn',
|
|
52
|
+
className,
|
|
53
|
+
styles.copyButton,
|
|
53
54
|
isCopied && styles.copyButtonCopied,
|
|
54
55
|
)}
|
|
55
56
|
onClick={handleCopyCode}>
|
|
@@ -5,31 +5,10 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
.copyButton {
|
|
9
|
-
display: flex;
|
|
10
|
-
/* TODO: move to base button styling */
|
|
11
|
-
background: var(--prism-background-color);
|
|
12
|
-
color: var(--prism-color);
|
|
13
|
-
border: 1px solid var(--ifm-color-emphasis-300);
|
|
14
|
-
border-radius: var(--ifm-global-radius);
|
|
15
|
-
padding: 0.4rem;
|
|
16
|
-
position: absolute;
|
|
17
|
-
right: calc(var(--ifm-pre-padding) / 2);
|
|
18
|
-
top: calc(var(--ifm-pre-padding) / 2);
|
|
19
|
-
transition: opacity 200ms ease-in-out;
|
|
20
|
-
opacity: 0;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.copyButton:focus-visible,
|
|
24
|
-
.copyButton:hover,
|
|
25
8
|
:global(.theme-code-block:hover) .copyButtonCopied {
|
|
26
9
|
opacity: 1 !important;
|
|
27
10
|
}
|
|
28
11
|
|
|
29
|
-
:global(.theme-code-block:hover) .copyButton:not(.copyButtonCopied) {
|
|
30
|
-
opacity: 0.4;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
12
|
.copyButtonIcons {
|
|
34
13
|
position: relative;
|
|
35
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
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import {translate} from '@docusaurus/Translate';
|
|
11
|
+
import type {Props} from '@theme/CodeBlock/WordWrapButton';
|
|
12
|
+
|
|
13
|
+
import styles from './styles.module.css';
|
|
14
|
+
|
|
15
|
+
export default function WordWrapButton({
|
|
16
|
+
className,
|
|
17
|
+
onClick,
|
|
18
|
+
isEnabled,
|
|
19
|
+
}: Props): JSX.Element | null {
|
|
20
|
+
const title = translate({
|
|
21
|
+
id: 'theme.CodeBlock.wordWrapToggle',
|
|
22
|
+
message: 'Toggle word wrap',
|
|
23
|
+
description:
|
|
24
|
+
'The title attribute for toggle word wrapping button of code block lines',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<button
|
|
29
|
+
type="button"
|
|
30
|
+
onClick={onClick}
|
|
31
|
+
className={clsx(
|
|
32
|
+
'clean-btn',
|
|
33
|
+
className,
|
|
34
|
+
isEnabled && styles.wordWrapButtonEnabled,
|
|
35
|
+
)}
|
|
36
|
+
aria-label={title}
|
|
37
|
+
title={title}>
|
|
38
|
+
<svg
|
|
39
|
+
className={styles.wordWrapButtonIcon}
|
|
40
|
+
viewBox="0 0 24 24"
|
|
41
|
+
aria-hidden="true">
|
|
42
|
+
<path
|
|
43
|
+
fill="currentColor"
|
|
44
|
+
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"
|
|
45
|
+
/>
|
|
46
|
+
</svg>
|
|
47
|
+
</button>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -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
|
+
}
|
package/src/theme-classic.d.ts
CHANGED
|
@@ -165,6 +165,7 @@ declare module '@theme/CodeBlock' {
|
|
|
165
165
|
declare module '@theme/CodeBlock/CopyButton' {
|
|
166
166
|
export interface Props {
|
|
167
167
|
readonly code: string;
|
|
168
|
+
readonly className?: string;
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
export default function CopyButton(props: Props): JSX.Element;
|
|
@@ -220,6 +221,16 @@ declare module '@theme/CodeBlock/Line' {
|
|
|
220
221
|
export default function CodeBlockLine(props: Props): JSX.Element;
|
|
221
222
|
}
|
|
222
223
|
|
|
224
|
+
declare module '@theme/CodeBlock/WordWrapButton' {
|
|
225
|
+
export interface Props {
|
|
226
|
+
readonly className?: string;
|
|
227
|
+
readonly onClick: React.MouseEventHandler;
|
|
228
|
+
readonly isEnabled: boolean;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export default function WordWrapButton(props: Props): JSX.Element;
|
|
232
|
+
}
|
|
233
|
+
|
|
223
234
|
declare module '@theme/DocCard' {
|
|
224
235
|
import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
|
|
225
236
|
|