@docusaurus/theme-classic 3.0.0-beta.0 → 3.0.0-rc.0

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/options.js CHANGED
@@ -7,9 +7,9 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.validateOptions = exports.validateThemeConfig = exports.ThemeConfigSchema = exports.DEFAULT_CONFIG = void 0;
10
- const tslib_1 = require("tslib");
11
- const palenight_1 = tslib_1.__importDefault(require("prism-react-renderer/themes/palenight"));
10
+ const prism_react_renderer_1 = require("prism-react-renderer");
12
11
  const utils_validation_1 = require("@docusaurus/utils-validation");
12
+ const defaultPrismTheme = prism_react_renderer_1.themes.palenight;
13
13
  const DEFAULT_DOCS_CONFIG = {
14
14
  versionPersistence: 'localStorage',
15
15
  sidebar: {
@@ -37,7 +37,7 @@ exports.DEFAULT_CONFIG = {
37
37
  metadata: [],
38
38
  prism: {
39
39
  additionalLanguages: [],
40
- theme: palenight_1.default,
40
+ theme: defaultPrismTheme,
41
41
  magicComments: [
42
42
  {
43
43
  className: 'theme-code-block-highlighted-line',
@@ -4,6 +4,6 @@
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 Prism from 'prism-react-renderer/prism';
7
+ import { Prism } from 'prism-react-renderer';
8
8
  import prismIncludeLanguages from '@theme/prism-include-languages';
9
9
  prismIncludeLanguages(Prism);
@@ -14,7 +14,7 @@ import {
14
14
  containsLineNumbers,
15
15
  useCodeWordWrap,
16
16
  } from '@docusaurus/theme-common/internal';
17
- import Highlight, {defaultProps} from 'prism-react-renderer';
17
+ import {Highlight} from 'prism-react-renderer';
18
18
  import Line from '@theme/CodeBlock/Line';
19
19
  import CopyButton from '@theme/CodeBlock/CopyButton';
20
20
  import WordWrapButton from '@theme/CodeBlock/WordWrapButton';
@@ -64,17 +64,14 @@ export default function CodeBlockString({
64
64
  )}>
65
65
  {title && <div className={styles.codeBlockTitle}>{title}</div>}
66
66
  <div className={styles.codeBlockContent}>
67
- <Highlight
68
- {...defaultProps}
69
- theme={prismTheme}
70
- code={code}
71
- language={language ?? 'text'}>
72
- {({className, tokens, getLineProps, getTokenProps}) => (
67
+ <Highlight theme={prismTheme} code={code} language={language ?? 'text'}>
68
+ {({className, style, tokens, getLineProps, getTokenProps}) => (
73
69
  <pre
74
70
  /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
75
71
  tabIndex={0}
76
72
  ref={wordWrap.codeBlockRef}
77
- className={clsx(className, styles.codeBlock, 'thin-scrollbar')}>
73
+ className={clsx(className, styles.codeBlock, 'thin-scrollbar')}
74
+ style={style}>
78
75
  <code
79
76
  className={clsx(
80
77
  styles.codeBlockLines,
@@ -8,5 +8,9 @@ import React from 'react';
8
8
  import clsx from 'clsx';
9
9
  import styles from './styles.module.css';
10
10
  export default function NavbarSearch({children, className}) {
11
- return <div className={clsx(className, styles.searchBox)}>{children}</div>;
11
+ return (
12
+ <div className={clsx(className, styles.navbarSearchContainer)}>
13
+ {children}
14
+ </div>
15
+ );
12
16
  }
@@ -5,15 +5,23 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ /*
9
+ Workaround to avoid rendering empty search container
10
+ See https://github.com/facebook/docusaurus/pull/9385
11
+ */
12
+ .navbarSearchContainer:not(:has(> *)) {
13
+ display: none;
14
+ }
15
+
8
16
  @media (max-width: 996px) {
9
- .searchBox {
17
+ .navbarSearchContainer {
10
18
  position: absolute;
11
19
  right: var(--ifm-navbar-padding-horizontal);
12
20
  }
13
21
  }
14
22
 
15
23
  @media (min-width: 997px) {
16
- .searchBox {
24
+ .navbarSearchContainer {
17
25
  padding: var(--ifm-navbar-item-padding-vertical)
18
26
  var(--ifm-navbar-item-padding-horizontal);
19
27
  }
@@ -18,6 +18,10 @@ export default function prismIncludeLanguages(PrismObject) {
18
18
  // long as you don't re-assign it
19
19
  globalThis.Prism = PrismObject;
20
20
  additionalLanguages.forEach((lang) => {
21
+ if (lang === 'php') {
22
+ // eslint-disable-next-line global-require
23
+ require('prismjs/components/prism-markup-templating.js');
24
+ }
21
25
  // eslint-disable-next-line global-require, import/no-dynamic-require
22
26
  require(`prismjs/components/prism-${lang}`);
23
27
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "3.0.0-beta.0",
3
+ "version": "3.0.0-rc.0",
4
4
  "description": "Classic theme for Docusaurus",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/theme-classic.d.ts",
@@ -20,18 +20,18 @@
20
20
  "copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@docusaurus/core": "3.0.0-beta.0",
24
- "@docusaurus/mdx-loader": "3.0.0-beta.0",
25
- "@docusaurus/module-type-aliases": "3.0.0-beta.0",
26
- "@docusaurus/plugin-content-blog": "3.0.0-beta.0",
27
- "@docusaurus/plugin-content-docs": "3.0.0-beta.0",
28
- "@docusaurus/plugin-content-pages": "3.0.0-beta.0",
29
- "@docusaurus/theme-common": "3.0.0-beta.0",
30
- "@docusaurus/theme-translations": "3.0.0-beta.0",
31
- "@docusaurus/types": "3.0.0-beta.0",
32
- "@docusaurus/utils": "3.0.0-beta.0",
33
- "@docusaurus/utils-common": "3.0.0-beta.0",
34
- "@docusaurus/utils-validation": "3.0.0-beta.0",
23
+ "@docusaurus/core": "3.0.0-rc.0",
24
+ "@docusaurus/mdx-loader": "3.0.0-rc.0",
25
+ "@docusaurus/module-type-aliases": "3.0.0-rc.0",
26
+ "@docusaurus/plugin-content-blog": "3.0.0-rc.0",
27
+ "@docusaurus/plugin-content-docs": "3.0.0-rc.0",
28
+ "@docusaurus/plugin-content-pages": "3.0.0-rc.0",
29
+ "@docusaurus/theme-common": "3.0.0-rc.0",
30
+ "@docusaurus/theme-translations": "3.0.0-rc.0",
31
+ "@docusaurus/types": "3.0.0-rc.0",
32
+ "@docusaurus/utils": "3.0.0-rc.0",
33
+ "@docusaurus/utils-common": "3.0.0-rc.0",
34
+ "@docusaurus/utils-validation": "3.0.0-rc.0",
35
35
  "@mdx-js/react": "^2.1.5",
36
36
  "clsx": "^1.2.1",
37
37
  "copy-text-to-clipboard": "^3.2.0",
@@ -39,7 +39,7 @@
39
39
  "lodash": "^4.17.21",
40
40
  "nprogress": "^0.2.0",
41
41
  "postcss": "^8.4.26",
42
- "prism-react-renderer": "^1.3.5",
42
+ "prism-react-renderer": "^2.1.0",
43
43
  "prismjs": "^1.29.0",
44
44
  "react-router-dom": "^5.3.4",
45
45
  "rtlcss": "^4.1.0",
@@ -60,7 +60,7 @@
60
60
  "react-dom": "^18.0.0"
61
61
  },
62
62
  "engines": {
63
- "node": ">=16.14"
63
+ "node": ">=18.0"
64
64
  },
65
- "gitHead": "27a1e90d9fff88af90ecad35bea16d4d7230482a"
65
+ "gitHead": "e66dfe04d2972edce66f431908470c61340f8ffc"
66
66
  }
package/src/options.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import defaultPrismTheme from 'prism-react-renderer/themes/palenight';
8
+ import {themes} from 'prism-react-renderer';
9
9
  import {Joi, URISchema} from '@docusaurus/utils-validation';
10
10
  import type {Options, PluginOptions} from '@docusaurus/theme-classic';
11
11
  import type {ThemeConfig} from '@docusaurus/theme-common';
@@ -14,6 +14,7 @@ import type {
14
14
  OptionValidationContext,
15
15
  } from '@docusaurus/types';
16
16
 
17
+ const defaultPrismTheme = themes.palenight;
17
18
  const DEFAULT_DOCS_CONFIG: ThemeConfig['docs'] = {
18
19
  versionPersistence: 'localStorage',
19
20
  sidebar: {
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import Prism from 'prism-react-renderer/prism';
8
+ import {Prism} from 'prism-react-renderer';
9
9
  import prismIncludeLanguages from '@theme/prism-include-languages';
10
10
 
11
11
  prismIncludeLanguages(Prism);
@@ -15,7 +15,7 @@ import {
15
15
  containsLineNumbers,
16
16
  useCodeWordWrap,
17
17
  } from '@docusaurus/theme-common/internal';
18
- import Highlight, {defaultProps, type Language} from 'prism-react-renderer';
18
+ import {Highlight, type Language} from 'prism-react-renderer';
19
19
  import Line from '@theme/CodeBlock/Line';
20
20
  import CopyButton from '@theme/CodeBlock/CopyButton';
21
21
  import WordWrapButton from '@theme/CodeBlock/WordWrapButton';
@@ -74,16 +74,16 @@ export default function CodeBlockString({
74
74
  {title && <div className={styles.codeBlockTitle}>{title}</div>}
75
75
  <div className={styles.codeBlockContent}>
76
76
  <Highlight
77
- {...defaultProps}
78
77
  theme={prismTheme}
79
78
  code={code}
80
79
  language={(language ?? 'text') as Language}>
81
- {({className, tokens, getLineProps, getTokenProps}) => (
80
+ {({className, style, tokens, getLineProps, getTokenProps}) => (
82
81
  <pre
83
82
  /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
84
83
  tabIndex={0}
85
84
  ref={wordWrap.codeBlockRef}
86
- className={clsx(className, styles.codeBlock, 'thin-scrollbar')}>
85
+ className={clsx(className, styles.codeBlock, 'thin-scrollbar')}
86
+ style={style}>
87
87
  <code
88
88
  className={clsx(
89
89
  styles.codeBlockLines,
@@ -15,5 +15,9 @@ export default function NavbarSearch({
15
15
  children,
16
16
  className,
17
17
  }: Props): JSX.Element {
18
- return <div className={clsx(className, styles.searchBox)}>{children}</div>;
18
+ return (
19
+ <div className={clsx(className, styles.navbarSearchContainer)}>
20
+ {children}
21
+ </div>
22
+ );
19
23
  }
@@ -5,15 +5,23 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ /*
9
+ Workaround to avoid rendering empty search container
10
+ See https://github.com/facebook/docusaurus/pull/9385
11
+ */
12
+ .navbarSearchContainer:not(:has(> *)) {
13
+ display: none;
14
+ }
15
+
8
16
  @media (max-width: 996px) {
9
- .searchBox {
17
+ .navbarSearchContainer {
10
18
  position: absolute;
11
19
  right: var(--ifm-navbar-padding-horizontal);
12
20
  }
13
21
  }
14
22
 
15
23
  @media (min-width: 997px) {
16
- .searchBox {
24
+ .navbarSearchContainer {
17
25
  padding: var(--ifm-navbar-item-padding-vertical)
18
26
  var(--ifm-navbar-item-padding-horizontal);
19
27
  }
@@ -26,6 +26,10 @@ export default function prismIncludeLanguages(
26
26
  globalThis.Prism = PrismObject;
27
27
 
28
28
  additionalLanguages.forEach((lang) => {
29
+ if (lang === 'php') {
30
+ // eslint-disable-next-line global-require
31
+ require('prismjs/components/prism-markup-templating.js');
32
+ }
29
33
  // eslint-disable-next-line global-require, import/no-dynamic-require
30
34
  require(`prismjs/components/prism-${lang}`);
31
35
  });
@@ -400,23 +400,20 @@ declare module '@theme/CodeBlock/Content/String' {
400
400
  }
401
401
 
402
402
  declare module '@theme/CodeBlock/Line' {
403
- import type {ComponentProps} from 'react';
404
- import type Highlight from 'prism-react-renderer';
405
-
406
- // Lib does not make this easy
407
- type RenderProps = Parameters<
408
- ComponentProps<typeof Highlight>['children']
409
- >[0];
410
- type GetLineProps = RenderProps['getLineProps'];
411
- type GetTokenProps = RenderProps['getTokenProps'];
412
- type Token = RenderProps['tokens'][number][number];
403
+ import type {
404
+ LineInputProps,
405
+ LineOutputProps,
406
+ Token,
407
+ TokenInputProps,
408
+ TokenOutputProps,
409
+ } from 'prism-react-renderer';
413
410
 
414
411
  export interface Props {
415
412
  readonly line: Token[];
416
413
  readonly classNames: string[] | undefined;
417
414
  readonly showLineNumbers: boolean;
418
- readonly getLineProps: GetLineProps;
419
- readonly getTokenProps: GetTokenProps;
415
+ readonly getLineProps: (input: LineInputProps) => LineOutputProps;
416
+ readonly getTokenProps: (input: TokenInputProps) => TokenOutputProps;
420
417
  }
421
418
 
422
419
  export default function CodeBlockLine(props: Props): JSX.Element;
package/src/deps.d.ts DELETED
@@ -1,13 +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
- declare module 'prism-react-renderer/prism' {
9
- import type * as PrismNamespace from 'prismjs';
10
-
11
- const Prism: typeof PrismNamespace;
12
- export default Prism;
13
- }