@docusaurus/theme-common 2.0.0-beta.16 → 2.0.0-beta.19
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/Details.d.ts +14 -0
- package/lib/components/Collapsible/index.d.ts +32 -4
- package/lib/components/Collapsible/index.d.ts.map +1 -1
- package/lib/components/Collapsible/index.js +18 -10
- package/lib/components/Collapsible/index.js.map +1 -1
- package/lib/components/Details/index.d.ts +6 -1
- package/lib/components/Details/index.d.ts.map +1 -1
- package/lib/components/Details/index.js +11 -6
- package/lib/components/Details/index.js.map +1 -1
- package/lib/components/Details/styles.module.css +4 -0
- package/lib/{utils/announcementBarUtils.d.ts → contexts/announcementBar.d.ts} +7 -3
- package/lib/contexts/announcementBar.d.ts.map +1 -0
- package/lib/{utils/announcementBarUtils.js → contexts/announcementBar.js} +15 -14
- package/lib/contexts/announcementBar.js.map +1 -0
- package/lib/contexts/colorMode.d.ts +27 -0
- package/lib/contexts/colorMode.d.ts.map +1 -0
- package/lib/contexts/colorMode.js +132 -0
- package/lib/contexts/colorMode.js.map +1 -0
- package/lib/contexts/docSidebarItemsExpandedState.d.ts +31 -0
- package/lib/contexts/docSidebarItemsExpandedState.d.ts.map +1 -0
- package/lib/{utils → contexts}/docSidebarItemsExpandedState.js +10 -4
- package/lib/contexts/docSidebarItemsExpandedState.js.map +1 -0
- package/lib/contexts/docsPreferredVersion.d.ts +31 -0
- package/lib/contexts/docsPreferredVersion.d.ts.map +1 -0
- package/lib/contexts/docsPreferredVersion.js +128 -0
- package/lib/contexts/docsPreferredVersion.js.map +1 -0
- package/lib/contexts/docsSidebar.d.ts +26 -0
- package/lib/contexts/docsSidebar.d.ts.map +1 -0
- package/lib/contexts/docsSidebar.js +30 -0
- package/lib/contexts/docsSidebar.js.map +1 -0
- package/lib/contexts/docsVersion.d.ts +20 -0
- package/lib/contexts/docsVersion.d.ts.map +1 -0
- package/lib/contexts/docsVersion.js +26 -0
- package/lib/contexts/docsVersion.js.map +1 -0
- package/lib/contexts/navbarMobileSidebar.d.ts +31 -0
- package/lib/contexts/navbarMobileSidebar.d.ts.map +1 -0
- package/lib/contexts/navbarMobileSidebar.js +56 -0
- package/lib/contexts/navbarMobileSidebar.js.map +1 -0
- package/lib/contexts/navbarSecondaryMenu/content.d.ts +37 -0
- package/lib/contexts/navbarSecondaryMenu/content.d.ts.map +1 -0
- package/lib/contexts/navbarSecondaryMenu/content.js +56 -0
- package/lib/contexts/navbarSecondaryMenu/content.js.map +1 -0
- package/lib/contexts/navbarSecondaryMenu/display.d.ts +24 -0
- package/lib/contexts/navbarSecondaryMenu/display.d.ts.map +1 -0
- package/lib/contexts/navbarSecondaryMenu/display.js +62 -0
- package/lib/contexts/navbarSecondaryMenu/display.js.map +1 -0
- package/lib/{utils/tabGroupChoiceUtils.d.ts → contexts/tabGroupChoice.d.ts} +5 -3
- package/lib/contexts/tabGroupChoice.d.ts.map +1 -0
- package/lib/{utils/tabGroupChoiceUtils.js → contexts/tabGroupChoice.js} +15 -20
- package/lib/contexts/tabGroupChoice.js.map +1 -0
- package/lib/hooks/useBackToTopButton.d.ts +27 -0
- package/lib/hooks/useBackToTopButton.d.ts.map +1 -0
- package/lib/hooks/useBackToTopButton.js +50 -0
- package/lib/hooks/useBackToTopButton.js.map +1 -0
- package/lib/hooks/useCodeWordWrap.d.ts +14 -0
- package/lib/hooks/useCodeWordWrap.d.ts.map +1 -0
- package/lib/hooks/useCodeWordWrap.js +41 -0
- package/lib/hooks/useCodeWordWrap.js.map +1 -0
- package/lib/hooks/useHideableNavbar.d.ts +7 -3
- package/lib/hooks/useHideableNavbar.d.ts.map +1 -1
- package/lib/hooks/useHideableNavbar.js +10 -9
- package/lib/hooks/useHideableNavbar.js.map +1 -1
- package/lib/hooks/useKeyboardNavigation.d.ts +11 -1
- package/lib/hooks/useKeyboardNavigation.d.ts.map +1 -1
- package/lib/hooks/useKeyboardNavigation.js +11 -3
- package/lib/hooks/useKeyboardNavigation.js.map +1 -1
- package/lib/hooks/useLockBodyScroll.d.ts +5 -1
- package/lib/hooks/useLockBodyScroll.d.ts.map +1 -1
- package/lib/hooks/useLockBodyScroll.js +5 -1
- package/lib/hooks/useLockBodyScroll.js.map +1 -1
- package/lib/hooks/usePrismTheme.d.ts +6 -2
- package/lib/hooks/usePrismTheme.d.ts.map +1 -1
- package/lib/hooks/usePrismTheme.js +9 -6
- package/lib/hooks/usePrismTheme.js.map +1 -1
- package/lib/hooks/useSearchPage.d.ts +15 -4
- package/lib/hooks/useSearchPage.d.ts.map +1 -1
- package/lib/hooks/useSearchPage.js +4 -4
- package/lib/hooks/useSearchPage.js.map +1 -1
- package/lib/hooks/useSkipToContent.d.ts +25 -0
- package/lib/hooks/useSkipToContent.d.ts.map +1 -0
- package/lib/hooks/useSkipToContent.js +35 -0
- package/lib/hooks/useSkipToContent.js.map +1 -0
- package/lib/hooks/useTOCHighlight.d.ts +25 -0
- package/lib/hooks/useTOCHighlight.d.ts.map +1 -0
- package/lib/{utils → hooks}/useTOCHighlight.js +18 -16
- package/lib/hooks/useTOCHighlight.js.map +1 -0
- package/lib/hooks/useWindowSize.d.ts +14 -1
- package/lib/hooks/useWindowSize.d.ts.map +1 -1
- package/lib/hooks/useWindowSize.js +14 -11
- package/lib/hooks/useWindowSize.js.map +1 -1
- package/lib/index.d.ts +31 -32
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +31 -26
- package/lib/index.js.map +1 -1
- package/lib/utils/ThemeClassNames.d.ts +7 -0
- package/lib/utils/ThemeClassNames.d.ts.map +1 -1
- package/lib/utils/ThemeClassNames.js +7 -4
- package/lib/utils/ThemeClassNames.js.map +1 -1
- package/lib/utils/codeBlockUtils.d.ts +57 -4
- package/lib/utils/codeBlockUtils.d.ts.map +1 -1
- package/lib/utils/codeBlockUtils.js +111 -80
- package/lib/utils/codeBlockUtils.js.map +1 -1
- package/lib/utils/docsUtils.d.ts +83 -18
- package/lib/utils/docsUtils.d.ts.map +1 -1
- package/lib/utils/docsUtils.js +143 -62
- package/lib/utils/docsUtils.js.map +1 -1
- package/lib/utils/footerUtils.d.ts +13 -0
- package/lib/utils/footerUtils.d.ts.map +1 -0
- package/lib/utils/footerUtils.js +14 -0
- package/lib/utils/footerUtils.js.map +1 -0
- package/lib/utils/generalUtils.d.ts +4 -1
- package/lib/utils/generalUtils.d.ts.map +1 -1
- package/lib/utils/generalUtils.js +6 -3
- package/lib/utils/generalUtils.js.map +1 -1
- package/lib/utils/historyUtils.d.ts +1 -7
- package/lib/utils/historyUtils.d.ts.map +1 -1
- package/lib/utils/historyUtils.js +10 -13
- package/lib/utils/historyUtils.js.map +1 -1
- package/lib/utils/jsUtils.d.ts +1 -1
- package/lib/utils/jsUtils.js +1 -1
- package/lib/utils/metadataUtils.d.ts +38 -0
- package/lib/utils/metadataUtils.d.ts.map +1 -0
- package/lib/utils/metadataUtils.js +61 -0
- package/lib/utils/metadataUtils.js.map +1 -0
- package/lib/utils/navbarUtils.d.ts +21 -0
- package/lib/utils/navbarUtils.d.ts.map +1 -0
- package/lib/utils/navbarUtils.js +32 -0
- package/lib/utils/navbarUtils.js.map +1 -0
- package/lib/utils/reactUtils.d.ts +21 -7
- package/lib/utils/reactUtils.d.ts.map +1 -1
- package/lib/utils/reactUtils.js +34 -6
- package/lib/utils/reactUtils.js.map +1 -1
- package/lib/utils/regexpUtils.d.ts +2 -1
- package/lib/utils/regexpUtils.d.ts.map +1 -1
- package/lib/utils/regexpUtils.js +2 -1
- package/lib/utils/regexpUtils.js.map +1 -1
- package/lib/utils/routesUtils.d.ts +19 -4
- package/lib/utils/routesUtils.d.ts.map +1 -1
- package/lib/utils/routesUtils.js +40 -19
- package/lib/utils/routesUtils.js.map +1 -1
- package/lib/utils/scrollUtils.d.ts +55 -25
- package/lib/utils/scrollUtils.d.ts.map +1 -1
- package/lib/utils/scrollUtils.js +85 -21
- package/lib/utils/scrollUtils.js.map +1 -1
- package/lib/utils/searchUtils.d.ts +12 -0
- package/lib/utils/searchUtils.d.ts.map +1 -1
- package/lib/utils/searchUtils.js +36 -0
- package/lib/utils/searchUtils.js.map +1 -1
- package/lib/utils/storageUtils.d.ts +12 -9
- package/lib/utils/storageUtils.d.ts.map +1 -1
- package/lib/utils/storageUtils.js +21 -13
- package/lib/utils/storageUtils.js.map +1 -1
- package/lib/utils/tagsUtils.d.ts +7 -8
- package/lib/utils/tagsUtils.d.ts.map +1 -1
- package/lib/utils/tagsUtils.js +8 -6
- package/lib/utils/tagsUtils.js.map +1 -1
- package/lib/utils/tocUtils.d.ts +17 -1
- package/lib/utils/tocUtils.d.ts.map +1 -1
- package/lib/utils/tocUtils.js +20 -9
- package/lib/utils/tocUtils.js.map +1 -1
- package/lib/utils/useAlternatePageUtils.d.ts +20 -1
- package/lib/utils/useAlternatePageUtils.d.ts.map +1 -1
- package/lib/utils/useAlternatePageUtils.js +6 -3
- package/lib/utils/useAlternatePageUtils.js.map +1 -1
- package/lib/utils/useLocalPathname.d.ts +5 -0
- package/lib/utils/useLocalPathname.d.ts.map +1 -1
- package/lib/utils/useLocalPathname.js +6 -4
- package/lib/utils/useLocalPathname.js.map +1 -1
- package/lib/utils/useLocationChange.d.ts +7 -5
- package/lib/utils/useLocationChange.d.ts.map +1 -1
- package/lib/utils/useLocationChange.js +6 -2
- package/lib/utils/useLocationChange.js.map +1 -1
- package/lib/utils/usePluralForm.d.ts +11 -0
- package/lib/utils/usePluralForm.d.ts.map +1 -1
- package/lib/utils/usePluralForm.js +19 -24
- package/lib/utils/usePluralForm.js.map +1 -1
- package/lib/utils/useThemeConfig.d.ts +28 -22
- package/lib/utils/useThemeConfig.d.ts.map +1 -1
- package/lib/utils/useThemeConfig.js +3 -0
- package/lib/utils/useThemeConfig.js.map +1 -1
- package/package.json +18 -11
- package/src/components/Collapsible/index.tsx +42 -24
- package/src/components/Details/index.tsx +15 -8
- package/src/components/Details/styles.module.css +4 -0
- package/src/{utils/announcementBarUtils.tsx → contexts/announcementBar.tsx} +20 -22
- package/src/contexts/colorMode.tsx +199 -0
- package/src/contexts/docSidebarItemsExpandedState.tsx +55 -0
- package/src/contexts/docsPreferredVersion.tsx +253 -0
- package/src/contexts/docsSidebar.tsx +50 -0
- package/src/contexts/docsVersion.tsx +36 -0
- package/src/contexts/navbarMobileSidebar.tsx +99 -0
- package/src/contexts/navbarSecondaryMenu/content.tsx +110 -0
- package/src/contexts/navbarSecondaryMenu/display.tsx +102 -0
- package/src/{utils/tabGroupChoiceUtils.tsx → contexts/tabGroupChoice.tsx} +28 -33
- package/src/hooks/useBackToTopButton.ts +73 -0
- package/src/hooks/useCodeWordWrap.ts +56 -0
- package/src/hooks/useHideableNavbar.ts +12 -14
- package/src/hooks/useKeyboardNavigation.ts +11 -3
- package/src/hooks/useLockBodyScroll.ts +5 -2
- package/src/hooks/usePrismTheme.ts +10 -6
- package/src/hooks/useSearchPage.ts +18 -5
- package/src/hooks/useSkipToContent.ts +58 -0
- package/src/{utils → hooks}/useTOCHighlight.ts +24 -15
- package/src/hooks/useWindowSize.ts +14 -12
- package/src/index.ts +77 -57
- package/src/utils/ThemeClassNames.ts +10 -6
- package/src/utils/codeBlockUtils.ts +178 -92
- package/src/utils/docsUtils.tsx +205 -101
- package/src/utils/footerUtils.ts +18 -0
- package/src/utils/generalUtils.ts +6 -3
- package/src/utils/historyUtils.ts +11 -17
- package/src/utils/jsUtils.ts +1 -1
- package/src/utils/metadataUtils.tsx +115 -0
- package/src/utils/navbarUtils.tsx +45 -0
- package/src/utils/reactUtils.tsx +40 -7
- package/src/utils/regexpUtils.ts +2 -1
- package/src/utils/routesUtils.ts +58 -22
- package/src/utils/scrollUtils.tsx +120 -49
- package/src/utils/searchUtils.ts +51 -0
- package/src/utils/storageUtils.ts +23 -15
- package/src/utils/tagsUtils.ts +12 -10
- package/src/utils/tocUtils.ts +22 -11
- package/src/utils/useAlternatePageUtils.ts +17 -5
- package/src/utils/useLocalPathname.ts +6 -4
- package/src/utils/useLocationChange.ts +12 -10
- package/src/utils/usePluralForm.ts +27 -24
- package/src/utils/useThemeConfig.ts +23 -22
- package/yarn-error.log +20199 -0
- package/lib/utils/announcementBarUtils.d.ts.map +0 -1
- package/lib/utils/announcementBarUtils.js.map +0 -1
- package/lib/utils/colorModeUtils.d.ts +0 -18
- package/lib/utils/colorModeUtils.d.ts.map +0 -1
- package/lib/utils/colorModeUtils.js +0 -106
- package/lib/utils/colorModeUtils.js.map +0 -1
- package/lib/utils/docSidebarItemsExpandedState.d.ts +0 -17
- package/lib/utils/docSidebarItemsExpandedState.d.ts.map +0 -1
- package/lib/utils/docSidebarItemsExpandedState.js.map +0 -1
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts +0 -22
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts.map +0 -1
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js +0 -91
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js.map +0 -1
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts +0 -14
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts.map +0 -1
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js +0 -19
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js.map +0 -1
- package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts +0 -14
- package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts.map +0 -1
- package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js +0 -41
- package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js.map +0 -1
- package/lib/utils/mobileSecondaryMenu.d.ts +0 -21
- package/lib/utils/mobileSecondaryMenu.d.ts.map +0 -1
- package/lib/utils/mobileSecondaryMenu.js +0 -50
- package/lib/utils/mobileSecondaryMenu.js.map +0 -1
- package/lib/utils/pathUtils.d.ts +0 -8
- package/lib/utils/pathUtils.d.ts.map +0 -1
- package/lib/utils/pathUtils.js +0 -17
- package/lib/utils/pathUtils.js.map +0 -1
- package/lib/utils/tabGroupChoiceUtils.d.ts.map +0 -1
- package/lib/utils/tabGroupChoiceUtils.js.map +0 -1
- package/lib/utils/useContextualSearchFilters.d.ts +0 -12
- package/lib/utils/useContextualSearchFilters.d.ts.map +0 -1
- package/lib/utils/useContextualSearchFilters.js +0 -37
- package/lib/utils/useContextualSearchFilters.js.map +0 -1
- package/lib/utils/usePrevious.d.ts +0 -8
- package/lib/utils/usePrevious.d.ts.map +0 -1
- package/lib/utils/usePrevious.js +0 -16
- package/lib/utils/usePrevious.js.map +0 -1
- package/lib/utils/useTOCHighlight.d.ts +0 -14
- package/lib/utils/useTOCHighlight.d.ts.map +0 -1
- package/lib/utils/useTOCHighlight.js.map +0 -1
- package/src/utils/colorModeUtils.tsx +0 -156
- package/src/utils/docSidebarItemsExpandedState.tsx +0 -41
- package/src/utils/docsPreferredVersion/DocsPreferredVersionProvider.tsx +0 -167
- package/src/utils/docsPreferredVersion/DocsPreferredVersionStorage.ts +0 -33
- package/src/utils/docsPreferredVersion/useDocsPreferredVersion.ts +0 -70
- package/src/utils/mobileSecondaryMenu.tsx +0 -115
- package/src/utils/pathUtils.ts +0 -19
- package/src/utils/useContextualSearchFilters.ts +0 -53
- package/src/utils/usePrevious.ts +0 -19
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import {useEffect, useRef} from 'react';
|
|
9
|
-
import {useThemeConfig} from '
|
|
9
|
+
import {useThemeConfig} from '../utils/useThemeConfig';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
(or add them to ThemeClassNames?)
|
|
14
|
-
*/
|
|
11
|
+
// TODO make the hardcoded theme-classic classnames configurable (or add them
|
|
12
|
+
// to ThemeClassNames?)
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
/**
|
|
15
|
+
* If the anchor has no height and is just a "marker" in the DOM; we'll use the
|
|
16
|
+
* parent (normally the link text) rect boundaries instead
|
|
17
|
+
*/
|
|
18
18
|
function getVisibleBoundingClientRect(element: HTMLElement): DOMRect {
|
|
19
19
|
const rect = element.getBoundingClientRect();
|
|
20
20
|
const hasNoHeight = rect.top === rect.bottom;
|
|
@@ -26,7 +26,7 @@ function getVisibleBoundingClientRect(element: HTMLElement): DOMRect {
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Considering we divide viewport into 2 zones of each 50vh, this returns true
|
|
29
|
-
* if an element is in the first zone (
|
|
29
|
+
* if an element is in the first zone (i.e., appear in viewport, near the top)
|
|
30
30
|
*/
|
|
31
31
|
function isInViewportTopHalf(boundingRect: DOMRect) {
|
|
32
32
|
return boundingRect.top > 0 && boundingRect.bottom < window.innerHeight / 2;
|
|
@@ -81,9 +81,9 @@ function getActiveAnchor(
|
|
|
81
81
|
// https://github.com/facebook/docusaurus/issues/5318
|
|
82
82
|
return anchors[anchors.indexOf(nextVisibleAnchor) - 1] ?? null;
|
|
83
83
|
}
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
return anchors[anchors.length - 1];
|
|
84
|
+
// No anchor under viewport top (i.e. we are at the bottom of the page),
|
|
85
|
+
// highlight the last anchor found
|
|
86
|
+
return anchors[anchors.length - 1] ?? null;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
function getLinkAnchorValue(link: HTMLAnchorElement): string {
|
|
@@ -116,22 +116,31 @@ function useAnchorTopOffsetRef() {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
export type TOCHighlightConfig = {
|
|
119
|
+
/** A class name that all TOC links share. */
|
|
119
120
|
linkClassName: string;
|
|
121
|
+
/** The class name applied to the active (highlighted) link. */
|
|
120
122
|
linkActiveClassName: string;
|
|
123
|
+
/**
|
|
124
|
+
* The minimum heading level that the TOC includes. Only headings that are in
|
|
125
|
+
* this range will be eligible as "active heading".
|
|
126
|
+
*/
|
|
121
127
|
minHeadingLevel: number;
|
|
128
|
+
/** @see {@link TOCHighlightConfig.minHeadingLevel} */
|
|
122
129
|
maxHeadingLevel: number;
|
|
123
130
|
};
|
|
124
131
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Side-effect that applies the active class name to the TOC heading that the
|
|
134
|
+
* user is currently viewing. Disabled when `config` is undefined.
|
|
135
|
+
*/
|
|
136
|
+
export function useTOCHighlight(config: TOCHighlightConfig | undefined): void {
|
|
128
137
|
const lastActiveLinkRef = useRef<HTMLAnchorElement | undefined>(undefined);
|
|
129
138
|
|
|
130
139
|
const anchorTopOffsetRef = useAnchorTopOffsetRef();
|
|
131
140
|
|
|
132
141
|
useEffect(() => {
|
|
133
142
|
if (!config) {
|
|
134
|
-
//
|
|
143
|
+
// No-op, highlighting is disabled
|
|
135
144
|
return () => {};
|
|
136
145
|
}
|
|
137
146
|
|
|
@@ -12,12 +12,6 @@ import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
|
12
12
|
const windowSizes = {
|
|
13
13
|
desktop: 'desktop',
|
|
14
14
|
mobile: 'mobile',
|
|
15
|
-
|
|
16
|
-
// This "ssr" value is very important to handle hydration FOUC / layout shifts
|
|
17
|
-
// You have to handle server-rendering explicitly on the call-site
|
|
18
|
-
// On the server, you may need to render BOTH the mobile/desktop elements (and
|
|
19
|
-
// hide one of them with mediaquery)
|
|
20
|
-
// We don't return "undefined" on purpose, to make it more explicit
|
|
21
15
|
ssr: 'ssr',
|
|
22
16
|
} as const;
|
|
23
17
|
|
|
@@ -34,14 +28,22 @@ function getWindowSize() {
|
|
|
34
28
|
: windowSizes.mobile;
|
|
35
29
|
}
|
|
36
30
|
|
|
37
|
-
// Simulate the SSR window size in dev, so that potential hydration FOUC/layout
|
|
38
|
-
// shift problems can be seen in dev too!
|
|
39
31
|
const DevSimulateSSR = process.env.NODE_ENV === 'development' && true;
|
|
40
32
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Gets the current window size as an enum value. We don't want it to return the
|
|
35
|
+
* actual width value, so that it only re-renders once a breakpoint is crossed.
|
|
36
|
+
*
|
|
37
|
+
* It may return `"ssr"`, which is very important to handle hydration FOUC or
|
|
38
|
+
* layout shifts. You have to handle it explicitly upfront. On the server, you
|
|
39
|
+
* may need to render BOTH the mobile/desktop elements (and hide one of them
|
|
40
|
+
* with mediaquery). We don't return `undefined` on purpose, to make it more
|
|
41
|
+
* explicit.
|
|
42
|
+
*
|
|
43
|
+
* In development mode, this hook will still return `"ssr"` for one second, to
|
|
44
|
+
* catch potential layout shifts, similar to strict mode calling effects twice.
|
|
45
|
+
*/
|
|
46
|
+
export function useWindowSize(): WindowSize {
|
|
45
47
|
const [windowSize, setWindowSize] = useState<WindowSize>(() => {
|
|
46
48
|
if (DevSimulateSSR) {
|
|
47
49
|
return 'ssr';
|
package/src/index.ts
CHANGED
|
@@ -5,104 +5,96 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export {
|
|
8
|
+
export {
|
|
9
|
+
useThemeConfig,
|
|
10
|
+
type ThemeConfig,
|
|
11
|
+
type UserThemeConfig,
|
|
12
|
+
type Navbar,
|
|
13
|
+
type NavbarItem,
|
|
14
|
+
type NavbarLogo,
|
|
15
|
+
type MultiColumnFooter,
|
|
16
|
+
type SimpleFooter,
|
|
17
|
+
type Footer,
|
|
18
|
+
type FooterLogo,
|
|
19
|
+
type FooterLinkItem,
|
|
20
|
+
type ColorModeConfig,
|
|
21
|
+
} from './utils/useThemeConfig';
|
|
9
22
|
export {
|
|
10
23
|
DocSidebarItemsExpandedStateProvider,
|
|
11
24
|
useDocSidebarItemsExpandedState,
|
|
12
|
-
} from './
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
ThemeConfig,
|
|
16
|
-
UserThemeConfig,
|
|
17
|
-
Navbar,
|
|
18
|
-
NavbarItem,
|
|
19
|
-
NavbarLogo,
|
|
20
|
-
MultiColumnFooter,
|
|
21
|
-
SimpleFooter,
|
|
22
|
-
Footer,
|
|
23
|
-
FooterLinkItem,
|
|
24
|
-
ColorModeConfig,
|
|
25
|
-
} from './utils/useThemeConfig';
|
|
25
|
+
} from './contexts/docSidebarItemsExpandedState';
|
|
26
|
+
export {DocsVersionProvider, useDocsVersion} from './contexts/docsVersion';
|
|
27
|
+
export {DocsSidebarProvider, useDocsSidebar} from './contexts/docsSidebar';
|
|
26
28
|
|
|
27
29
|
export {createStorageSlot, listStorageKeys} from './utils/storageUtils';
|
|
28
30
|
|
|
29
31
|
export {useAlternatePageUtils} from './utils/useAlternatePageUtils';
|
|
30
32
|
|
|
31
|
-
export {useContextualSearchFilters} from './utils/useContextualSearchFilters';
|
|
32
|
-
|
|
33
33
|
export {
|
|
34
34
|
parseCodeBlockTitle,
|
|
35
35
|
parseLanguage,
|
|
36
36
|
parseLines,
|
|
37
|
+
containsLineNumbers,
|
|
38
|
+
getPrismCssVariables,
|
|
37
39
|
} from './utils/codeBlockUtils';
|
|
38
40
|
|
|
39
|
-
export {
|
|
41
|
+
export {
|
|
42
|
+
docVersionSearchTag,
|
|
43
|
+
DEFAULT_SEARCH_TAG,
|
|
44
|
+
useContextualSearchFilters,
|
|
45
|
+
} from './utils/searchUtils';
|
|
40
46
|
|
|
41
47
|
export {
|
|
42
48
|
isDocsPluginEnabled,
|
|
43
|
-
DocsVersionProvider,
|
|
44
|
-
useDocsVersion,
|
|
45
49
|
useDocById,
|
|
46
|
-
DocsSidebarProvider,
|
|
47
|
-
useDocsSidebar,
|
|
48
50
|
findSidebarCategory,
|
|
49
51
|
findFirstCategoryLink,
|
|
50
52
|
useCurrentSidebarCategory,
|
|
51
53
|
isActiveSidebarItem,
|
|
52
54
|
useSidebarBreadcrumbs,
|
|
55
|
+
useDocsVersionCandidates,
|
|
56
|
+
useLayoutDoc,
|
|
57
|
+
useLayoutDocsSidebar,
|
|
58
|
+
useDocRouteMetadata,
|
|
53
59
|
} from './utils/docsUtils';
|
|
54
60
|
|
|
55
|
-
export {isSamePath} from './utils/pathUtils';
|
|
56
|
-
|
|
57
61
|
export {useTitleFormatter} from './utils/generalUtils';
|
|
58
62
|
|
|
59
63
|
export {usePluralForm} from './utils/usePluralForm';
|
|
60
64
|
|
|
61
65
|
export {useLocationChange} from './utils/useLocationChange';
|
|
62
66
|
|
|
63
|
-
export {usePrevious} from './utils/usePrevious';
|
|
64
|
-
|
|
65
67
|
export {useCollapsible, Collapsible} from './components/Collapsible';
|
|
66
|
-
export type {
|
|
67
|
-
UseCollapsibleConfig,
|
|
68
|
-
UseCollapsibleReturns,
|
|
69
|
-
} from './components/Collapsible';
|
|
70
|
-
|
|
71
|
-
export {default as Details} from './components/Details';
|
|
72
|
-
export type {DetailsProps} from './components/Details';
|
|
73
|
-
|
|
74
|
-
export {
|
|
75
|
-
MobileSecondaryMenuProvider,
|
|
76
|
-
MobileSecondaryMenuFiller,
|
|
77
|
-
useMobileSecondaryMenuRenderer,
|
|
78
|
-
} from './utils/mobileSecondaryMenu';
|
|
79
|
-
export type {MobileSecondaryMenuComponent} from './utils/mobileSecondaryMenu';
|
|
80
68
|
|
|
81
69
|
export {
|
|
82
70
|
useDocsPreferredVersion,
|
|
83
71
|
useDocsPreferredVersionByPluginId,
|
|
84
|
-
|
|
72
|
+
DocsPreferredVersionContextProvider,
|
|
73
|
+
} from './contexts/docsPreferredVersion';
|
|
85
74
|
|
|
86
75
|
export {duplicates, uniq} from './utils/jsUtils';
|
|
87
76
|
|
|
88
|
-
export {DocsPreferredVersionContextProvider} from './utils/docsPreferredVersion/DocsPreferredVersionProvider';
|
|
89
|
-
|
|
90
77
|
export {ThemeClassNames} from './utils/ThemeClassNames';
|
|
91
78
|
|
|
92
79
|
export {
|
|
93
80
|
AnnouncementBarProvider,
|
|
94
81
|
useAnnouncementBar,
|
|
95
|
-
} from './
|
|
82
|
+
} from './contexts/announcementBar';
|
|
96
83
|
|
|
97
84
|
export {useLocalPathname} from './utils/useLocalPathname';
|
|
98
85
|
|
|
99
|
-
export {
|
|
100
|
-
|
|
86
|
+
export {
|
|
87
|
+
translateTagsPageTitle,
|
|
88
|
+
listTagsByLetters,
|
|
89
|
+
type TagLetterEntry,
|
|
90
|
+
} from './utils/tagsUtils';
|
|
101
91
|
|
|
102
92
|
export {useHistoryPopHandler} from './utils/historyUtils';
|
|
103
93
|
|
|
104
|
-
export {
|
|
105
|
-
|
|
94
|
+
export {
|
|
95
|
+
useTOCHighlight,
|
|
96
|
+
type TOCHighlightConfig,
|
|
97
|
+
} from './hooks/useTOCHighlight';
|
|
106
98
|
|
|
107
99
|
export {
|
|
108
100
|
useFilteredAndTreeifiedTOC,
|
|
@@ -110,34 +102,62 @@ export {
|
|
|
110
102
|
type TOCTreeNode,
|
|
111
103
|
} from './utils/tocUtils';
|
|
112
104
|
|
|
105
|
+
export {isMultiColumnFooterLinks} from './utils/footerUtils';
|
|
106
|
+
|
|
113
107
|
export {
|
|
114
108
|
ScrollControllerProvider,
|
|
115
109
|
useScrollController,
|
|
116
110
|
useScrollPosition,
|
|
117
111
|
useScrollPositionBlocker,
|
|
112
|
+
useSmoothScrollTo,
|
|
118
113
|
} from './utils/scrollUtils';
|
|
119
114
|
|
|
120
115
|
export {
|
|
121
116
|
useIsomorphicLayoutEffect,
|
|
122
117
|
useDynamicCallback,
|
|
118
|
+
usePrevious,
|
|
119
|
+
ReactContextError,
|
|
123
120
|
} from './utils/reactUtils';
|
|
124
121
|
|
|
125
122
|
export {isRegexpStringMatch} from './utils/regexpUtils';
|
|
126
123
|
|
|
127
|
-
export {useHomePageRoute} from './utils/routesUtils';
|
|
124
|
+
export {useHomePageRoute, isSamePath} from './utils/routesUtils';
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
PageMetadata,
|
|
128
|
+
HtmlClassNameProvider,
|
|
129
|
+
PluginHtmlClassNameProvider,
|
|
130
|
+
} from './utils/metadataUtils';
|
|
131
|
+
|
|
132
|
+
export {
|
|
133
|
+
useColorMode,
|
|
134
|
+
ColorModeProvider,
|
|
135
|
+
type ColorMode,
|
|
136
|
+
} from './contexts/colorMode';
|
|
137
|
+
|
|
138
|
+
export {splitNavbarItems, NavbarProvider} from './utils/navbarUtils';
|
|
128
139
|
|
|
129
|
-
export {useColorMode, ColorModeProvider} from './utils/colorModeUtils';
|
|
130
140
|
export {
|
|
131
141
|
useTabGroupChoice,
|
|
132
142
|
TabGroupChoiceProvider,
|
|
133
|
-
} from './
|
|
143
|
+
} from './contexts/tabGroupChoice';
|
|
144
|
+
|
|
145
|
+
export {useNavbarMobileSidebar} from './contexts/navbarMobileSidebar';
|
|
146
|
+
export {
|
|
147
|
+
NavbarSecondaryMenuFiller,
|
|
148
|
+
type NavbarSecondaryMenuComponent,
|
|
149
|
+
} from './contexts/navbarSecondaryMenu/content';
|
|
150
|
+
export {useNavbarSecondaryMenu} from './contexts/navbarSecondaryMenu/display';
|
|
134
151
|
|
|
135
|
-
export {
|
|
152
|
+
export {useBackToTopButton} from './hooks/useBackToTopButton';
|
|
153
|
+
export {useHideableNavbar} from './hooks/useHideableNavbar';
|
|
136
154
|
export {
|
|
137
|
-
|
|
155
|
+
useKeyboardNavigation,
|
|
138
156
|
keyboardFocusedClassName,
|
|
139
157
|
} from './hooks/useKeyboardNavigation';
|
|
140
|
-
export {
|
|
141
|
-
export {
|
|
142
|
-
export {
|
|
143
|
-
export {
|
|
158
|
+
export {usePrismTheme} from './hooks/usePrismTheme';
|
|
159
|
+
export {useLockBodyScroll} from './hooks/useLockBodyScroll';
|
|
160
|
+
export {useWindowSize} from './hooks/useWindowSize';
|
|
161
|
+
export {useSearchPage} from './hooks/useSearchPage';
|
|
162
|
+
export {useCodeWordWrap} from './hooks/useCodeWordWrap';
|
|
163
|
+
export {useSkipToContent} from './hooks/useSkipToContent';
|
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
// These class names are used to style page layouts in Docusaurus
|
|
9
|
-
// Those are meant to be targeted by user-provided custom CSS selectors
|
|
10
8
|
// Please do not modify the classnames! This is a breaking change, and annoying
|
|
11
9
|
// for users!
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* These class names are used to style page layouts in Docusaurus, meant to be
|
|
13
|
+
* targeted by user-provided custom CSS selectors.
|
|
14
|
+
*/
|
|
12
15
|
export const ThemeClassNames = {
|
|
13
16
|
page: {
|
|
14
17
|
blogListPage: 'blog-list-page',
|
|
@@ -17,8 +20,8 @@ export const ThemeClassNames = {
|
|
|
17
20
|
blogTagPostListPage: 'blog-tags-post-list-page',
|
|
18
21
|
|
|
19
22
|
docsDocPage: 'docs-doc-page',
|
|
20
|
-
docsTagsListPage: 'docs-tags-list-page',
|
|
21
|
-
docsTagDocListPage: 'docs-tags-doc-list-page',
|
|
23
|
+
docsTagsListPage: 'docs-tags-list-page',
|
|
24
|
+
docsTagDocListPage: 'docs-tags-doc-list-page',
|
|
22
25
|
|
|
23
26
|
mdxPage: 'mdx-page',
|
|
24
27
|
},
|
|
@@ -29,8 +32,9 @@ export const ThemeClassNames = {
|
|
|
29
32
|
mdxPages: 'mdx-wrapper',
|
|
30
33
|
},
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Follows the naming convention "theme-{blog,doc,version,page}?-<suffix>"
|
|
37
|
+
*/
|
|
34
38
|
common: {
|
|
35
39
|
editThisPage: 'theme-edit-this-page',
|
|
36
40
|
lastUpdated: 'theme-last-updated',
|