@docusaurus/theme-classic 3.7.0-canary-6248 → 3.7.0-canary-6250

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.
@@ -6,4 +6,4 @@
6
6
  */
7
7
  import { type ReactNode } from 'react';
8
8
  import type { Props } from '@theme/CodeBlock/Line';
9
- export default function CodeBlockLine({ line, classNames, showLineNumbers, getLineProps, getTokenProps, }: Props): ReactNode;
9
+ export default function CodeBlockLine({ line: lineProp, classNames, showLineNumbers, getLineProps, getTokenProps, }: Props): ReactNode;
@@ -7,16 +7,24 @@
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
9
  import styles from './styles.module.css';
10
+ // Replaces '\n' by ''
11
+ // Historical code, not sure why we even need this :/
12
+ function fixLineBreak(line) {
13
+ const singleLineBreakToken =
14
+ line.length === 1 && line[0].content === '\n' ? line[0] : undefined;
15
+ if (singleLineBreakToken) {
16
+ return [{...singleLineBreakToken, content: ''}];
17
+ }
18
+ return line;
19
+ }
10
20
  export default function CodeBlockLine({
11
- line,
21
+ line: lineProp,
12
22
  classNames,
13
23
  showLineNumbers,
14
24
  getLineProps,
15
25
  getTokenProps,
16
26
  }) {
17
- if (line.length === 1 && line[0].content === '\n') {
18
- line[0].content = '';
19
- }
27
+ const line = fixLineBreak(lineProp);
20
28
  const lineProps = getLineProps({
21
29
  line,
22
30
  className: clsx(classNames, showLineNumbers && styles.codeLine),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "3.7.0-canary-6248",
3
+ "version": "3.7.0-canary-6250",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -20,19 +20,19 @@
20
20
  "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@docusaurus/core": "3.7.0-canary-6248",
24
- "@docusaurus/logger": "3.7.0-canary-6248",
25
- "@docusaurus/mdx-loader": "3.7.0-canary-6248",
26
- "@docusaurus/module-type-aliases": "3.7.0-canary-6248",
27
- "@docusaurus/plugin-content-blog": "3.7.0-canary-6248",
28
- "@docusaurus/plugin-content-docs": "3.7.0-canary-6248",
29
- "@docusaurus/plugin-content-pages": "3.7.0-canary-6248",
30
- "@docusaurus/theme-common": "3.7.0-canary-6248",
31
- "@docusaurus/theme-translations": "3.7.0-canary-6248",
32
- "@docusaurus/types": "3.7.0-canary-6248",
33
- "@docusaurus/utils": "3.7.0-canary-6248",
34
- "@docusaurus/utils-common": "3.7.0-canary-6248",
35
- "@docusaurus/utils-validation": "3.7.0-canary-6248",
23
+ "@docusaurus/core": "3.7.0-canary-6250",
24
+ "@docusaurus/logger": "3.7.0-canary-6250",
25
+ "@docusaurus/mdx-loader": "3.7.0-canary-6250",
26
+ "@docusaurus/module-type-aliases": "3.7.0-canary-6250",
27
+ "@docusaurus/plugin-content-blog": "3.7.0-canary-6250",
28
+ "@docusaurus/plugin-content-docs": "3.7.0-canary-6250",
29
+ "@docusaurus/plugin-content-pages": "3.7.0-canary-6250",
30
+ "@docusaurus/theme-common": "3.7.0-canary-6250",
31
+ "@docusaurus/theme-translations": "3.7.0-canary-6250",
32
+ "@docusaurus/types": "3.7.0-canary-6250",
33
+ "@docusaurus/utils": "3.7.0-canary-6250",
34
+ "@docusaurus/utils-common": "3.7.0-canary-6250",
35
+ "@docusaurus/utils-validation": "3.7.0-canary-6250",
36
36
  "@mdx-js/react": "^3.0.0",
37
37
  "clsx": "^2.0.0",
38
38
  "copy-text-to-clipboard": "^3.2.0",
@@ -62,5 +62,5 @@
62
62
  "engines": {
63
63
  "node": ">=18.0"
64
64
  },
65
- "gitHead": "3c780f0974099a4c38da2a48a2b4bef65b14f46e"
65
+ "gitHead": "e11d596e19faf5888be145057410862c9b2970f7"
66
66
  }
@@ -11,16 +11,29 @@ import type {Props} from '@theme/CodeBlock/Line';
11
11
 
12
12
  import styles from './styles.module.css';
13
13
 
14
+ type Token = Props['line'][number];
15
+
16
+ // Replaces '\n' by ''
17
+ // Historical code, not sure why we even need this :/
18
+ function fixLineBreak(line: Token[]) {
19
+ const singleLineBreakToken =
20
+ line.length === 1 && line[0]!.content === '\n' ? line[0] : undefined;
21
+
22
+ if (singleLineBreakToken) {
23
+ return [{...singleLineBreakToken, content: ''}];
24
+ }
25
+
26
+ return line;
27
+ }
28
+
14
29
  export default function CodeBlockLine({
15
- line,
30
+ line: lineProp,
16
31
  classNames,
17
32
  showLineNumbers,
18
33
  getLineProps,
19
34
  getTokenProps,
20
35
  }: Props): ReactNode {
21
- if (line.length === 1 && line[0]!.content === '\n') {
22
- line[0]!.content = '';
23
- }
36
+ const line = fixLineBreak(lineProp);
24
37
 
25
38
  const lineProps = getLineProps({
26
39
  line,