@docusaurus/theme-common 2.0.0-beta.20 → 2.0.0-beta.21
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/components/Collapsible/index.d.ts +1 -1
- package/lib/components/Collapsible/index.d.ts.map +1 -1
- package/lib/components/Collapsible/index.js +9 -11
- package/lib/components/Collapsible/index.js.map +1 -1
- package/lib/components/Details/index.js +16 -11
- package/lib/components/Details/index.js.map +1 -1
- package/lib/contexts/announcementBar.js +1 -1
- package/lib/contexts/announcementBar.js.map +1 -1
- package/lib/contexts/colorMode.d.ts.map +1 -1
- package/lib/contexts/colorMode.js +2 -2
- package/lib/contexts/colorMode.js.map +1 -1
- package/lib/contexts/docSidebarItemsExpandedState.js +1 -1
- package/lib/contexts/docSidebarItemsExpandedState.js.map +1 -1
- package/lib/contexts/docsPreferredVersion.d.ts.map +1 -1
- package/lib/contexts/docsPreferredVersion.js +6 -4
- package/lib/contexts/docsPreferredVersion.js.map +1 -1
- package/lib/contexts/docsSidebar.d.ts.map +1 -1
- package/lib/contexts/docsSidebar.js +1 -1
- package/lib/contexts/docsSidebar.js.map +1 -1
- package/lib/contexts/docsVersion.d.ts.map +1 -1
- package/lib/contexts/docsVersion.js +1 -1
- package/lib/contexts/docsVersion.js.map +1 -1
- package/lib/contexts/navbarMobileSidebar.js +1 -1
- package/lib/contexts/navbarMobileSidebar.js.map +1 -1
- package/lib/contexts/navbarSecondaryMenu/content.js +1 -1
- package/lib/contexts/navbarSecondaryMenu/content.js.map +1 -1
- package/lib/contexts/navbarSecondaryMenu/display.js +2 -2
- package/lib/contexts/navbarSecondaryMenu/display.js.map +1 -1
- package/lib/contexts/tabGroupChoice.js +1 -1
- package/lib/contexts/tabGroupChoice.js.map +1 -1
- package/lib/hooks/usePrismTheme.d.ts.map +1 -1
- package/lib/hooks/usePrismTheme.js.map +1 -1
- package/lib/hooks/useSearchPage.js +1 -1
- package/lib/hooks/useSearchPage.js.map +1 -1
- package/lib/hooks/useSkipToContent.js +1 -1
- package/lib/hooks/useTOCHighlight.d.ts.map +1 -1
- package/lib/hooks/useTOCHighlight.js +1 -1
- package/lib/hooks/useTOCHighlight.js.map +1 -1
- package/lib/utils/codeBlockUtils.d.ts +1 -1
- package/lib/utils/codeBlockUtils.d.ts.map +1 -1
- package/lib/utils/codeBlockUtils.js +5 -3
- package/lib/utils/codeBlockUtils.js.map +1 -1
- package/lib/utils/docsUtils.d.ts +1 -1
- package/lib/utils/docsUtils.d.ts.map +1 -1
- package/lib/utils/docsUtils.js +2 -2
- package/lib/utils/docsUtils.js.map +1 -1
- package/lib/utils/metadataUtils.js +25 -16
- package/lib/utils/metadataUtils.js.map +1 -1
- package/lib/utils/navbarUtils.js +7 -3
- package/lib/utils/navbarUtils.js.map +1 -1
- package/lib/utils/reactUtils.js +1 -1
- package/lib/utils/reactUtils.js.map +1 -1
- package/lib/utils/routesUtils.js +1 -1
- package/lib/utils/routesUtils.js.map +1 -1
- package/lib/utils/scrollUtils.d.ts.map +1 -1
- package/lib/utils/scrollUtils.js +5 -5
- package/lib/utils/scrollUtils.js.map +1 -1
- package/lib/utils/searchUtils.js +2 -2
- package/lib/utils/searchUtils.js.map +1 -1
- package/lib/utils/tagsUtils.js +1 -1
- package/lib/utils/tagsUtils.js.map +1 -1
- package/lib/utils/tocUtils.js.map +1 -1
- package/lib/utils/useLocationChange.d.ts.map +1 -1
- package/lib/utils/useLocationChange.js.map +1 -1
- package/lib/utils/usePluralForm.d.ts.map +1 -1
- package/lib/utils/usePluralForm.js +1 -1
- package/lib/utils/usePluralForm.js.map +1 -1
- package/lib/utils/useThemeConfig.d.ts +5 -5
- package/lib/utils/useThemeConfig.d.ts.map +1 -1
- package/package.json +14 -12
- package/src/components/Collapsible/index.tsx +4 -6
- package/src/components/Details/index.tsx +2 -2
- package/src/contexts/colorMode.tsx +1 -2
- package/src/contexts/docsPreferredVersion.tsx +7 -9
- package/src/contexts/docsSidebar.tsx +1 -1
- package/src/contexts/docsVersion.tsx +1 -1
- package/src/hooks/usePrismTheme.ts +1 -1
- package/src/hooks/useSearchPage.ts +1 -1
- package/src/hooks/useSkipToContent.ts +1 -1
- package/src/hooks/useTOCHighlight.ts +3 -6
- package/src/utils/codeBlockUtils.ts +7 -5
- package/src/utils/docsUtils.tsx +9 -9
- package/src/utils/metadataUtils.tsx +1 -1
- package/src/utils/reactUtils.tsx +2 -2
- package/src/utils/routesUtils.ts +1 -1
- package/src/utils/scrollUtils.tsx +2 -6
- package/src/utils/searchUtils.ts +2 -2
- package/src/utils/tocUtils.ts +1 -1
- package/src/utils/useLocationChange.ts +1 -1
- package/src/utils/usePluralForm.ts +5 -1
- package/src/utils/useThemeConfig.ts +4 -4
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
9
8
|
import React, {
|
|
10
9
|
useState,
|
|
11
10
|
useEffect,
|
|
@@ -17,6 +16,7 @@ import React, {
|
|
|
17
16
|
type SetStateAction,
|
|
18
17
|
type ReactNode,
|
|
19
18
|
} from 'react';
|
|
19
|
+
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
20
20
|
|
|
21
21
|
const DefaultAnimationEasing = 'ease-in-out';
|
|
22
22
|
|
|
@@ -27,7 +27,7 @@ export function useCollapsible({
|
|
|
27
27
|
initialState,
|
|
28
28
|
}: {
|
|
29
29
|
/** The initial state. Will be non-collapsed by default. */
|
|
30
|
-
initialState
|
|
30
|
+
initialState?: boolean | (() => boolean);
|
|
31
31
|
}): {
|
|
32
32
|
collapsed: boolean;
|
|
33
33
|
setCollapsed: Dispatch<SetStateAction<boolean>>;
|
|
@@ -196,9 +196,7 @@ function CollapsibleBase({
|
|
|
196
196
|
className,
|
|
197
197
|
disableSSRStyle,
|
|
198
198
|
}: CollapsibleBaseProps) {
|
|
199
|
-
|
|
200
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
201
|
-
const collapsibleRef = useRef<any>(null);
|
|
199
|
+
const collapsibleRef = useRef<HTMLElement>(null);
|
|
202
200
|
|
|
203
201
|
useCollapseAnimation({collapsibleRef, collapsed, animation});
|
|
204
202
|
|
|
@@ -206,7 +204,7 @@ function CollapsibleBase({
|
|
|
206
204
|
<As
|
|
207
205
|
// @ts-expect-error: the "too complicated type" is produced from
|
|
208
206
|
// "CollapsibleElementType" being a huge union
|
|
209
|
-
ref={collapsibleRef}
|
|
207
|
+
ref={collapsibleRef as RefObject<never>} // Refs are contravariant, which is not expressible in TS
|
|
210
208
|
style={disableSSRStyle ? undefined : getSSRStyle(collapsed)}
|
|
211
209
|
onTransitionEnd={(e: React.TransitionEvent) => {
|
|
212
210
|
if (e.propertyName !== 'height') {
|
|
@@ -11,8 +11,8 @@ import React, {
|
|
|
11
11
|
type ComponentProps,
|
|
12
12
|
type ReactElement,
|
|
13
13
|
} from 'react';
|
|
14
|
-
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
15
14
|
import clsx from 'clsx';
|
|
15
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
16
16
|
import {useCollapsible, Collapsible} from '../Collapsible';
|
|
17
17
|
import styles from './styles.module.css';
|
|
18
18
|
|
|
@@ -92,7 +92,7 @@ export function Details({
|
|
|
92
92
|
}
|
|
93
93
|
}}>
|
|
94
94
|
{/* eslint-disable-next-line @docusaurus/no-untranslated-text */}
|
|
95
|
-
{summary
|
|
95
|
+
{summary ?? <summary>Details</summary>}
|
|
96
96
|
|
|
97
97
|
<Collapsible
|
|
98
98
|
lazy={false} // Content might matter for SEO in this case
|
|
@@ -14,9 +14,8 @@ import React, {
|
|
|
14
14
|
useRef,
|
|
15
15
|
type ReactNode,
|
|
16
16
|
} from 'react';
|
|
17
|
-
import {ReactContextError} from '../utils/reactUtils';
|
|
18
|
-
|
|
19
17
|
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
18
|
+
import {ReactContextError} from '../utils/reactUtils';
|
|
20
19
|
import {createStorageSlot} from '../utils/storageUtils';
|
|
21
20
|
import {useThemeConfig} from '../utils/useThemeConfig';
|
|
22
21
|
|
|
@@ -13,22 +13,20 @@ import React, {
|
|
|
13
13
|
useCallback,
|
|
14
14
|
type ReactNode,
|
|
15
15
|
} from 'react';
|
|
16
|
-
import {
|
|
17
|
-
useThemeConfig,
|
|
18
|
-
type DocsVersionPersistence,
|
|
19
|
-
} from '../utils/useThemeConfig';
|
|
20
|
-
import {isDocsPluginEnabled} from '../utils/docsUtils';
|
|
21
|
-
import {ReactContextError} from '../utils/reactUtils';
|
|
22
|
-
import {createStorageSlot} from '../utils/storageUtils';
|
|
23
|
-
|
|
24
16
|
import {
|
|
25
17
|
useAllDocsData,
|
|
26
18
|
useDocsData,
|
|
27
19
|
type GlobalPluginData,
|
|
28
20
|
type GlobalVersion,
|
|
29
21
|
} from '@docusaurus/plugin-content-docs/client';
|
|
30
|
-
|
|
31
22
|
import {DEFAULT_PLUGIN_ID} from '@docusaurus/constants';
|
|
23
|
+
import {
|
|
24
|
+
useThemeConfig,
|
|
25
|
+
type DocsVersionPersistence,
|
|
26
|
+
} from '../utils/useThemeConfig';
|
|
27
|
+
import {isDocsPluginEnabled} from '../utils/docsUtils';
|
|
28
|
+
import {ReactContextError} from '../utils/reactUtils';
|
|
29
|
+
import {createStorageSlot} from '../utils/storageUtils';
|
|
32
30
|
|
|
33
31
|
const storageKey = (pluginId: string) => `docs-preferred-version-${pluginId}`;
|
|
34
32
|
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React, {useMemo, useContext, type ReactNode} from 'react';
|
|
9
|
-
import type {PropSidebar} from '@docusaurus/plugin-content-docs';
|
|
10
9
|
import {ReactContextError} from '../utils/reactUtils';
|
|
10
|
+
import type {PropSidebar} from '@docusaurus/plugin-content-docs';
|
|
11
11
|
|
|
12
12
|
// Using a Symbol because null is a valid context value (a doc with no sidebar)
|
|
13
13
|
// Inspired by https://github.com/jamiebuilds/unstated-next/blob/master/src/unstated-next.tsx
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React, {type ReactNode, useContext} from 'react';
|
|
9
|
-
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
|
|
10
9
|
import {ReactContextError} from '../utils/reactUtils';
|
|
10
|
+
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
|
|
11
11
|
|
|
12
12
|
const Context = React.createContext<PropVersionMetadata | null>(null);
|
|
13
13
|
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type {PrismTheme} from 'prism-react-renderer';
|
|
9
8
|
import {useColorMode} from '../contexts/colorMode';
|
|
10
9
|
import {useThemeConfig} from '../utils/useThemeConfig';
|
|
10
|
+
import type {PrismTheme} from 'prism-react-renderer';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Returns a color-mode-dependent Prism theme: whatever the user specified in
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import {useCallback, useEffect, useState} from 'react';
|
|
8
9
|
import {useHistory} from '@docusaurus/router';
|
|
9
10
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
10
|
-
import {useCallback, useEffect, useState} from 'react';
|
|
11
11
|
|
|
12
12
|
const SEARCH_PARAM_QUERY = 'q';
|
|
13
13
|
|
|
@@ -40,7 +40,7 @@ export function useSkipToContent(): {
|
|
|
40
40
|
e.preventDefault();
|
|
41
41
|
|
|
42
42
|
const targetElement: HTMLElement | null =
|
|
43
|
-
document.querySelector('main:first-of-type')
|
|
43
|
+
document.querySelector('main:first-of-type') ??
|
|
44
44
|
document.querySelector(`.${ThemeClassNames.wrapper.main}`);
|
|
45
45
|
|
|
46
46
|
if (targetElement) {
|
|
@@ -38,15 +38,12 @@ function getAnchors({
|
|
|
38
38
|
}: {
|
|
39
39
|
minHeadingLevel: number;
|
|
40
40
|
maxHeadingLevel: number;
|
|
41
|
-
}) {
|
|
41
|
+
}): HTMLElement[] {
|
|
42
42
|
const selectors = [];
|
|
43
43
|
for (let i = minHeadingLevel; i <= maxHeadingLevel; i += 1) {
|
|
44
44
|
selectors.push(`h${i}.anchor`);
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
return Array.from(
|
|
48
|
-
document.querySelectorAll(selectors.join()),
|
|
49
|
-
) as HTMLElement[];
|
|
46
|
+
return Array.from(document.querySelectorAll(selectors.join()));
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
function getActiveAnchor(
|
|
@@ -154,7 +151,7 @@ export function useTOCHighlight(config: TOCHighlightConfig | undefined): void {
|
|
|
154
151
|
function updateLinkActiveClass(link: HTMLAnchorElement, active: boolean) {
|
|
155
152
|
if (active) {
|
|
156
153
|
if (lastActiveLinkRef.current && lastActiveLinkRef.current !== link) {
|
|
157
|
-
lastActiveLinkRef.current
|
|
154
|
+
lastActiveLinkRef.current.classList.remove(linkActiveClassName);
|
|
158
155
|
}
|
|
159
156
|
link.classList.add(linkActiveClassName);
|
|
160
157
|
lastActiveLinkRef.current = link;
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import type {CSSProperties} from 'react';
|
|
8
9
|
import rangeParser from 'parse-numeric-range';
|
|
9
10
|
import type {PrismTheme} from 'prism-react-renderer';
|
|
10
|
-
import type {CSSProperties} from 'react';
|
|
11
11
|
|
|
12
12
|
const codeBlockTitleRegex = /title=(?<quote>["'])(?<title>.*?)\1/;
|
|
13
13
|
const metastringLinesRangeRegex = /\{(?<range>[\d,-]+)\}/;
|
|
@@ -97,7 +97,7 @@ export function parseCodeBlockTitle(metastring?: string): string {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export function containsLineNumbers(metastring?: string): boolean {
|
|
100
|
-
return metastring?.includes('showLineNumbers')
|
|
100
|
+
return Boolean(metastring?.includes('showLineNumbers'));
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
/**
|
|
@@ -171,7 +171,7 @@ export function parseLines(
|
|
|
171
171
|
const metastringRangeClassName = magicComments[0]!.className;
|
|
172
172
|
const lines = rangeParser(linesRange)
|
|
173
173
|
.filter((n) => n > 0)
|
|
174
|
-
.map((n) => [n - 1, [metastringRangeClassName]]);
|
|
174
|
+
.map((n) => [n - 1, [metastringRangeClassName]] as [number, string[]]);
|
|
175
175
|
return {lineClassNames: Object.fromEntries(lines), code};
|
|
176
176
|
}
|
|
177
177
|
if (language === undefined) {
|
|
@@ -189,7 +189,7 @@ export function parseLines(
|
|
|
189
189
|
const lineToClassName: {[comment: string]: string} = Object.fromEntries(
|
|
190
190
|
magicComments
|
|
191
191
|
.filter((d) => d.line)
|
|
192
|
-
.map(({className, line}) => [line
|
|
192
|
+
.map(({className, line}) => [line!, className] as [string, string]),
|
|
193
193
|
);
|
|
194
194
|
const blockStartToClassName: {[comment: string]: string} = Object.fromEntries(
|
|
195
195
|
magicComments
|
|
@@ -209,7 +209,9 @@ export function parseLines(
|
|
|
209
209
|
lineNumber += 1;
|
|
210
210
|
continue;
|
|
211
211
|
}
|
|
212
|
-
const directive = match
|
|
212
|
+
const directive = match
|
|
213
|
+
.slice(1)
|
|
214
|
+
.find((item: string | undefined) => item !== undefined)!;
|
|
213
215
|
if (lineToClassName[directive]) {
|
|
214
216
|
blocks[lineToClassName[directive]!]!.range += `${lineNumber},`;
|
|
215
217
|
} else if (blockStartToClassName[directive]) {
|
package/src/utils/docsUtils.tsx
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import {useMemo} from 'react';
|
|
9
|
+
import {matchPath, useLocation} from '@docusaurus/router';
|
|
10
|
+
import renderRoutes from '@docusaurus/renderRoutes';
|
|
9
11
|
import {
|
|
10
12
|
useAllDocsData,
|
|
11
13
|
useActivePlugin,
|
|
@@ -15,6 +17,12 @@ import {
|
|
|
15
17
|
type GlobalSidebar,
|
|
16
18
|
type GlobalDoc,
|
|
17
19
|
} from '@docusaurus/plugin-content-docs/client';
|
|
20
|
+
import type {Props as DocPageProps} from '@theme/DocPage';
|
|
21
|
+
import {useDocsPreferredVersion} from '../contexts/docsPreferredVersion';
|
|
22
|
+
import {useDocsVersion} from '../contexts/docsVersion';
|
|
23
|
+
import {useDocsSidebar} from '../contexts/docsSidebar';
|
|
24
|
+
import {uniq} from './jsUtils';
|
|
25
|
+
import {isSamePath} from './routesUtils';
|
|
18
26
|
import type {
|
|
19
27
|
PropSidebar,
|
|
20
28
|
PropSidebarItem,
|
|
@@ -22,14 +30,6 @@ import type {
|
|
|
22
30
|
PropVersionDoc,
|
|
23
31
|
PropSidebarBreadcrumbsItem,
|
|
24
32
|
} from '@docusaurus/plugin-content-docs';
|
|
25
|
-
import type {Props as DocPageProps} from '@theme/DocPage';
|
|
26
|
-
import {useDocsPreferredVersion} from '../contexts/docsPreferredVersion';
|
|
27
|
-
import {useDocsVersion} from '../contexts/docsVersion';
|
|
28
|
-
import {useDocsSidebar} from '../contexts/docsSidebar';
|
|
29
|
-
import {uniq} from './jsUtils';
|
|
30
|
-
import {isSamePath} from './routesUtils';
|
|
31
|
-
import {matchPath, useLocation} from '@docusaurus/router';
|
|
32
|
-
import renderRoutes from '@docusaurus/renderRoutes';
|
|
33
33
|
|
|
34
34
|
// TODO not ideal, see also "useDocs"
|
|
35
35
|
export const isDocsPluginEnabled: boolean = !!useAllDocsData;
|
|
@@ -318,7 +318,7 @@ export function useDocRouteMetadata({
|
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
// For now, the sidebarName is added as route config: not ideal!
|
|
321
|
-
const sidebarName = currentDocRoute.sidebar;
|
|
321
|
+
const sidebarName = currentDocRoute.sidebar as string;
|
|
322
322
|
|
|
323
323
|
const sidebarItems = sidebarName
|
|
324
324
|
? versionMetadata.docsSidebars[sidebarName]
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React, {type ReactNode} from 'react';
|
|
9
|
-
import Head from '@docusaurus/Head';
|
|
10
9
|
import clsx from 'clsx';
|
|
10
|
+
import Head from '@docusaurus/Head';
|
|
11
11
|
import useRouteContext from '@docusaurus/useRouteContext';
|
|
12
12
|
import {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
|
|
13
13
|
import {useTitleFormatter} from './generalUtils';
|
package/src/utils/reactUtils.tsx
CHANGED
|
@@ -70,7 +70,7 @@ export class ReactContextError extends Error {
|
|
|
70
70
|
this.name = 'ReactContextError';
|
|
71
71
|
this.message = `Hook ${
|
|
72
72
|
this.stack?.split('\n')[1]?.match(/at (?:\w+\.)?(?<name>\w+)/)?.groups!
|
|
73
|
-
.name
|
|
74
|
-
} is called outside the <${providerName}>. ${additionalInfo
|
|
73
|
+
.name ?? ''
|
|
74
|
+
} is called outside the <${providerName}>. ${additionalInfo ?? ''}`;
|
|
75
75
|
}
|
|
76
76
|
}
|
package/src/utils/routesUtils.ts
CHANGED
|
@@ -18,7 +18,7 @@ export function isSamePath(
|
|
|
18
18
|
path2: string | undefined,
|
|
19
19
|
): boolean {
|
|
20
20
|
const normalize = (pathname: string | undefined) =>
|
|
21
|
-
(!pathname || pathname
|
|
21
|
+
(!pathname || pathname.endsWith('/')
|
|
22
22
|
? pathname
|
|
23
23
|
: `${pathname}/`
|
|
24
24
|
)?.toLowerCase();
|
|
@@ -14,9 +14,9 @@ import React, {
|
|
|
14
14
|
useRef,
|
|
15
15
|
type ReactNode,
|
|
16
16
|
} from 'react';
|
|
17
|
-
import {useDynamicCallback, ReactContextError} from './reactUtils';
|
|
18
17
|
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
19
18
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
19
|
+
import {useDynamicCallback, ReactContextError} from './reactUtils';
|
|
20
20
|
|
|
21
21
|
type ScrollController = {
|
|
22
22
|
/** A boolean ref tracking whether scroll events are enabled. */
|
|
@@ -112,11 +112,7 @@ export function useScrollPosition(
|
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
114
|
const currentPosition = getScrollPosition()!;
|
|
115
|
-
|
|
116
|
-
if (dynamicEffect) {
|
|
117
|
-
dynamicEffect(currentPosition, lastPositionRef.current);
|
|
118
|
-
}
|
|
119
|
-
|
|
115
|
+
dynamicEffect(currentPosition, lastPositionRef.current);
|
|
120
116
|
lastPositionRef.current = currentPosition;
|
|
121
117
|
};
|
|
122
118
|
|
package/src/utils/searchUtils.ts
CHANGED
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
useAllDocsData,
|
|
10
10
|
useActivePluginAndVersion,
|
|
11
11
|
} from '@docusaurus/plugin-content-docs/client';
|
|
12
|
-
import {useDocsPreferredVersionByPluginId} from '../contexts/docsPreferredVersion';
|
|
13
12
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
13
|
+
import {useDocsPreferredVersionByPluginId} from '../contexts/docsPreferredVersion';
|
|
14
14
|
|
|
15
15
|
export const DEFAULT_SEARCH_TAG = 'default';
|
|
16
16
|
|
|
@@ -39,7 +39,7 @@ export function useContextualSearchFilters(): {locale: string; tags: string[]} {
|
|
|
39
39
|
// plugin instances.
|
|
40
40
|
function getDocPluginTags(pluginId: string) {
|
|
41
41
|
const activeVersion =
|
|
42
|
-
activePluginAndVersion?.activePlugin
|
|
42
|
+
activePluginAndVersion?.activePlugin.pluginId === pluginId
|
|
43
43
|
? activePluginAndVersion.activeVersion
|
|
44
44
|
: undefined;
|
|
45
45
|
|
package/src/utils/tocUtils.ts
CHANGED
|
@@ -27,7 +27,7 @@ function treeifyTOC(flatTOC: readonly TOCItem[]): TOCTreeNode[] {
|
|
|
27
27
|
// level <i>. We will modify these indices as we iterate through all headings.
|
|
28
28
|
// e.g. if an ### H3 was last seen at index 2, then prevIndexForLevel[3] === 2
|
|
29
29
|
// indices 0 and 1 will remain unused.
|
|
30
|
-
const prevIndexForLevel = Array(7).fill(-1);
|
|
30
|
+
const prevIndexForLevel = Array<number>(7).fill(-1);
|
|
31
31
|
|
|
32
32
|
headings.forEach((curr, currIndex) => {
|
|
33
33
|
// Take the last seen index for each ancestor level. the highest index will
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
import {useEffect} from 'react';
|
|
9
9
|
import {useLocation} from '@docusaurus/router';
|
|
10
|
-
import type {Location} from 'history';
|
|
11
10
|
import {useDynamicCallback, usePrevious} from './reactUtils';
|
|
11
|
+
import type {Location} from 'history';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Fires an effect when the location changes (which includes hash, query, etc.).
|
|
@@ -95,7 +95,11 @@ function selectPluralMessage(
|
|
|
95
95
|
}
|
|
96
96
|
if (parts.length > localePluralForms.pluralForms.length) {
|
|
97
97
|
console.error(
|
|
98
|
-
`For locale=${localePluralForms.locale}, a maximum of ${
|
|
98
|
+
`For locale=${localePluralForms.locale}, a maximum of ${
|
|
99
|
+
localePluralForms.pluralForms.length
|
|
100
|
+
} plural forms are expected (${localePluralForms.pluralForms.join(
|
|
101
|
+
',',
|
|
102
|
+
)}), but the message contains ${parts.length}: ${pluralMessages}`,
|
|
99
103
|
);
|
|
100
104
|
}
|
|
101
105
|
const pluralForm = localePluralForms.select(count);
|
|
@@ -32,7 +32,7 @@ export type NavbarLogo = {
|
|
|
32
32
|
|
|
33
33
|
// TODO improve
|
|
34
34
|
export type Navbar = {
|
|
35
|
-
style
|
|
35
|
+
style?: 'dark' | 'primary';
|
|
36
36
|
hideOnScroll: boolean;
|
|
37
37
|
title?: string;
|
|
38
38
|
items: NavbarItem[];
|
|
@@ -85,10 +85,10 @@ export type FooterBase = {
|
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
export type MultiColumnFooter = FooterBase & {
|
|
88
|
-
links:
|
|
88
|
+
links: {
|
|
89
89
|
title: string | null;
|
|
90
90
|
items: FooterLinkItem[];
|
|
91
|
-
}
|
|
91
|
+
}[];
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
export type SimpleFooter = FooterBase & {
|
|
@@ -123,7 +123,7 @@ export type ThemeConfig = {
|
|
|
123
123
|
prism: PrismConfig;
|
|
124
124
|
footer?: Footer;
|
|
125
125
|
image?: string;
|
|
126
|
-
metadata:
|
|
126
|
+
metadata: {[key: string]: string}[];
|
|
127
127
|
tableOfContents: TableOfContents;
|
|
128
128
|
};
|
|
129
129
|
|