@docusaurus/theme-classic 4.0.0-canary-6953 → 4.0.0-canary-6952
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/getSwizzleConfig.js +1 -1
- package/lib/theme/CodeBlock/{Element/index.d.ts → Content/Element.d.ts} +2 -2
- package/lib/theme/CodeBlock/{Element/index.js → Content/Element.js} +2 -1
- package/lib/theme/CodeBlock/{String/index.d.ts → Content/String.d.ts} +1 -1
- package/lib/theme/CodeBlock/{String/index.js → Content/String.js} +1 -0
- package/lib/theme/CodeBlock/Content/styles.module.css +4 -0
- package/lib/theme/CodeBlock/index.js +3 -3
- package/package.json +13 -13
- package/src/getSwizzleConfig.ts +1 -1
- package/src/theme/CodeBlock/{Element/index.tsx → Content/Element.tsx} +3 -5
- package/src/theme/CodeBlock/{String/index.tsx → Content/String.tsx} +2 -1
- package/src/theme/CodeBlock/Content/styles.module.css +4 -0
- package/src/theme/CodeBlock/index.tsx +3 -3
- package/src/theme-classic.d.ts +4 -4
- package/lib/theme/CodeBlock/Element/styles.module.css +0 -24
- package/src/theme/CodeBlock/Element/styles.module.css +0 -24
package/lib/getSwizzleConfig.js
CHANGED
|
@@ -143,7 +143,7 @@ function getSwizzleConfig() {
|
|
|
143
143
|
eject: 'unsafe',
|
|
144
144
|
wrap: 'unsafe',
|
|
145
145
|
},
|
|
146
|
-
description: 'The
|
|
146
|
+
description: 'The folder containing components responsible for rendering different types of CodeBlock content.',
|
|
147
147
|
},
|
|
148
148
|
ColorModeToggle: {
|
|
149
149
|
actions: {
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { ReactNode } from 'react';
|
|
8
|
-
import type { Props } from '@theme/CodeBlock/Element';
|
|
9
|
-
export default function
|
|
8
|
+
import type { Props } from '@theme/CodeBlock/Content/Element';
|
|
9
|
+
export default function CodeBlockJSX({ children, className }: Props): ReactNode;
|
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import Container from '@theme/CodeBlock/Container';
|
|
9
9
|
import styles from './styles.module.css';
|
|
10
|
+
// TODO Docusaurus v4: move this component at the root?
|
|
10
11
|
// This component only handles a rare edge-case: <pre><MyComp/></pre> in MDX
|
|
11
12
|
// <pre> tags in markdown map to CodeBlocks. They may contain JSX children.
|
|
12
13
|
// When children is not a simple string, we just return a styled block without
|
|
13
14
|
// actually highlighting.
|
|
14
|
-
export default function
|
|
15
|
+
export default function CodeBlockJSX({children, className}) {
|
|
15
16
|
return (
|
|
16
17
|
<Container
|
|
17
18
|
as="pre"
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { ReactNode } from 'react';
|
|
8
|
-
import type { Props } from '@theme/CodeBlock/String';
|
|
8
|
+
import type { Props } from '@theme/CodeBlock/Content/String';
|
|
9
9
|
export default function CodeBlockString(props: Props): ReactNode;
|
|
@@ -24,6 +24,7 @@ function useCodeBlockMetadata(props) {
|
|
|
24
24
|
showLineNumbers: props.showLineNumbers,
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
+
// TODO Docusaurus v4: move this component at the root?
|
|
27
28
|
export default function CodeBlockString(props) {
|
|
28
29
|
const metadata = useCodeBlockMetadata(props);
|
|
29
30
|
const wordWrap = useCodeWordWrap();
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, {isValidElement} from 'react';
|
|
8
8
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
import ElementContent from '@theme/CodeBlock/Content/Element';
|
|
10
|
+
import StringContent from '@theme/CodeBlock/Content/String';
|
|
11
11
|
/**
|
|
12
12
|
* Best attempt to make the children a plain string so it is copyable. If there
|
|
13
13
|
* are react elements, we will not be able to copy the content, and it will
|
|
@@ -29,7 +29,7 @@ export default function CodeBlock({children: rawChildren, ...props}) {
|
|
|
29
29
|
const isBrowser = useIsBrowser();
|
|
30
30
|
const children = maybeStringifyChildren(rawChildren);
|
|
31
31
|
const CodeBlockComp =
|
|
32
|
-
typeof children === 'string' ?
|
|
32
|
+
typeof children === 'string' ? StringContent : ElementContent;
|
|
33
33
|
return (
|
|
34
34
|
<CodeBlockComp key={String(isBrowser)} {...props}>
|
|
35
35
|
{children}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "4.0.0-canary-
|
|
3
|
+
"version": "4.0.0-canary-6952",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
},
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@docusaurus/core": "4.0.0-canary-
|
|
18
|
-
"@docusaurus/mdx-loader": "4.0.0-canary-
|
|
19
|
-
"@docusaurus/module-type-aliases": "4.0.0-canary-
|
|
20
|
-
"@docusaurus/plugin-content-blog": "4.0.0-canary-
|
|
21
|
-
"@docusaurus/plugin-content-docs": "4.0.0-canary-
|
|
22
|
-
"@docusaurus/plugin-content-pages": "4.0.0-canary-
|
|
23
|
-
"@docusaurus/theme-common": "4.0.0-canary-
|
|
24
|
-
"@docusaurus/theme-translations": "4.0.0-canary-
|
|
25
|
-
"@docusaurus/types": "4.0.0-canary-
|
|
26
|
-
"@docusaurus/utils": "4.0.0-canary-
|
|
27
|
-
"@docusaurus/utils-common": "4.0.0-canary-
|
|
28
|
-
"@docusaurus/utils-validation": "4.0.0-canary-
|
|
17
|
+
"@docusaurus/core": "4.0.0-canary-6952",
|
|
18
|
+
"@docusaurus/mdx-loader": "4.0.0-canary-6952",
|
|
19
|
+
"@docusaurus/module-type-aliases": "4.0.0-canary-6952",
|
|
20
|
+
"@docusaurus/plugin-content-blog": "4.0.0-canary-6952",
|
|
21
|
+
"@docusaurus/plugin-content-docs": "4.0.0-canary-6952",
|
|
22
|
+
"@docusaurus/plugin-content-pages": "4.0.0-canary-6952",
|
|
23
|
+
"@docusaurus/theme-common": "4.0.0-canary-6952",
|
|
24
|
+
"@docusaurus/theme-translations": "4.0.0-canary-6952",
|
|
25
|
+
"@docusaurus/types": "4.0.0-canary-6952",
|
|
26
|
+
"@docusaurus/utils": "4.0.0-canary-6952",
|
|
27
|
+
"@docusaurus/utils-common": "4.0.0-canary-6952",
|
|
28
|
+
"@docusaurus/utils-validation": "4.0.0-canary-6952",
|
|
29
29
|
"@mdx-js/react": "^3.1.1",
|
|
30
30
|
"clsx": "^2.1.1",
|
|
31
31
|
"copy-text-to-clipboard": "^3.2.2",
|
package/src/getSwizzleConfig.ts
CHANGED
|
@@ -154,7 +154,7 @@ export default function getSwizzleConfig(): SwizzleConfig {
|
|
|
154
154
|
wrap: 'unsafe',
|
|
155
155
|
},
|
|
156
156
|
description:
|
|
157
|
-
'The
|
|
157
|
+
'The folder containing components responsible for rendering different types of CodeBlock content.',
|
|
158
158
|
},
|
|
159
159
|
ColorModeToggle: {
|
|
160
160
|
actions: {
|
|
@@ -8,18 +8,16 @@
|
|
|
8
8
|
import type {ReactNode} from 'react';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
10
|
import Container from '@theme/CodeBlock/Container';
|
|
11
|
-
import type {Props} from '@theme/CodeBlock/Element';
|
|
11
|
+
import type {Props} from '@theme/CodeBlock/Content/Element';
|
|
12
12
|
|
|
13
13
|
import styles from './styles.module.css';
|
|
14
14
|
|
|
15
|
+
// TODO Docusaurus v4: move this component at the root?
|
|
15
16
|
// This component only handles a rare edge-case: <pre><MyComp/></pre> in MDX
|
|
16
17
|
// <pre> tags in markdown map to CodeBlocks. They may contain JSX children.
|
|
17
18
|
// When children is not a simple string, we just return a styled block without
|
|
18
19
|
// actually highlighting.
|
|
19
|
-
export default function
|
|
20
|
-
children,
|
|
21
|
-
className,
|
|
22
|
-
}: Props): ReactNode {
|
|
20
|
+
export default function CodeBlockJSX({children, className}: Props): ReactNode {
|
|
23
21
|
return (
|
|
24
22
|
<Container
|
|
25
23
|
as="pre"
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
createCodeBlockMetadata,
|
|
14
14
|
useCodeWordWrap,
|
|
15
15
|
} from '@docusaurus/theme-common/internal';
|
|
16
|
-
import type {Props} from '@theme/CodeBlock/String';
|
|
16
|
+
import type {Props} from '@theme/CodeBlock/Content/String';
|
|
17
17
|
import CodeBlockLayout from '@theme/CodeBlock/Layout';
|
|
18
18
|
|
|
19
19
|
function useCodeBlockMetadata(props: Props): CodeBlockMetadata {
|
|
@@ -30,6 +30,7 @@ function useCodeBlockMetadata(props: Props): CodeBlockMetadata {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
// TODO Docusaurus v4: move this component at the root?
|
|
33
34
|
export default function CodeBlockString(props: Props): ReactNode {
|
|
34
35
|
const metadata = useCodeBlockMetadata(props);
|
|
35
36
|
const wordWrap = useCodeWordWrap();
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
import React, {isValidElement, type ReactNode} from 'react';
|
|
9
9
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
10
|
+
import ElementContent from '@theme/CodeBlock/Content/Element';
|
|
11
|
+
import StringContent from '@theme/CodeBlock/Content/String';
|
|
12
12
|
import type {Props} from '@theme/CodeBlock';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -36,7 +36,7 @@ export default function CodeBlock({
|
|
|
36
36
|
const isBrowser = useIsBrowser();
|
|
37
37
|
const children = maybeStringifyChildren(rawChildren);
|
|
38
38
|
const CodeBlockComp =
|
|
39
|
-
typeof children === 'string' ?
|
|
39
|
+
typeof children === 'string' ? StringContent : ElementContent;
|
|
40
40
|
return (
|
|
41
41
|
<CodeBlockComp key={String(isBrowser)} {...props}>
|
|
42
42
|
{children as string}
|
package/src/theme-classic.d.ts
CHANGED
|
@@ -507,16 +507,16 @@ declare module '@theme/CodeBlock/Content' {
|
|
|
507
507
|
export default function CodeBlockContent(props: Props): ReactNode;
|
|
508
508
|
}
|
|
509
509
|
|
|
510
|
-
declare module '@theme/CodeBlock/Element' {
|
|
510
|
+
declare module '@theme/CodeBlock/Content/Element' {
|
|
511
511
|
import type {ReactNode} from 'react';
|
|
512
512
|
import type {Props} from '@theme/CodeBlock';
|
|
513
513
|
|
|
514
514
|
export type {Props};
|
|
515
515
|
|
|
516
|
-
export default function
|
|
516
|
+
export default function CodeBlockContentElement(props: Props): ReactNode;
|
|
517
517
|
}
|
|
518
518
|
|
|
519
|
-
declare module '@theme/CodeBlock/String' {
|
|
519
|
+
declare module '@theme/CodeBlock/Content/String' {
|
|
520
520
|
import type {ReactNode} from 'react';
|
|
521
521
|
import type {Props as CodeBlockProps} from '@theme/CodeBlock';
|
|
522
522
|
|
|
@@ -524,7 +524,7 @@ declare module '@theme/CodeBlock/String' {
|
|
|
524
524
|
readonly children: string;
|
|
525
525
|
}
|
|
526
526
|
|
|
527
|
-
export default function
|
|
527
|
+
export default function CodeBlockContentString(props: Props): ReactNode;
|
|
528
528
|
}
|
|
529
529
|
|
|
530
530
|
declare module '@theme/CodeBlock/Line' {
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
.codeBlockStandalone {
|
|
9
|
-
padding: 0;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.codeBlockLines {
|
|
13
|
-
font: inherit;
|
|
14
|
-
/* rtl:ignore */
|
|
15
|
-
float: left;
|
|
16
|
-
min-width: 100%;
|
|
17
|
-
padding: var(--ifm-pre-padding);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@media print {
|
|
21
|
-
.codeBlockLines {
|
|
22
|
-
white-space: pre-wrap;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
.codeBlockStandalone {
|
|
9
|
-
padding: 0;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.codeBlockLines {
|
|
13
|
-
font: inherit;
|
|
14
|
-
/* rtl:ignore */
|
|
15
|
-
float: left;
|
|
16
|
-
min-width: 100%;
|
|
17
|
-
padding: var(--ifm-pre-padding);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@media print {
|
|
21
|
-
.codeBlockLines {
|
|
22
|
-
white-space: pre-wrap;
|
|
23
|
-
}
|
|
24
|
-
}
|