@docusaurus/theme-common 2.1.0 → 2.3.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/hooks/useHideableNavbar.d.ts.map +1 -1
- package/lib/hooks/useHideableNavbar.js +6 -1
- package/lib/hooks/useHideableNavbar.js.map +1 -1
- package/lib/hooks/useSearchPage.d.ts.map +1 -1
- package/lib/hooks/useSearchPage.js +4 -2
- package/lib/hooks/useSearchPage.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/internal.d.ts +3 -3
- package/lib/internal.d.ts.map +1 -1
- package/lib/internal.js +2 -3
- package/lib/internal.js.map +1 -1
- package/lib/utils/admonitionUtils.d.ts +12 -0
- package/lib/utils/admonitionUtils.d.ts.map +1 -0
- package/lib/utils/admonitionUtils.js +33 -0
- package/lib/utils/admonitionUtils.js.map +1 -0
- package/lib/utils/historyUtils.d.ts +12 -1
- package/lib/utils/historyUtils.d.ts.map +1 -1
- package/lib/utils/historyUtils.js +23 -0
- package/lib/utils/historyUtils.js.map +1 -1
- package/lib/utils/skipToContentUtils.d.ts +17 -0
- package/lib/utils/skipToContentUtils.d.ts.map +1 -0
- package/lib/utils/skipToContentUtils.js +71 -0
- package/lib/utils/skipToContentUtils.js.map +1 -0
- package/lib/utils/storageUtils.d.ts +4 -0
- package/lib/utils/storageUtils.d.ts.map +1 -1
- package/lib/utils/storageUtils.js +70 -7
- package/lib/utils/storageUtils.js.map +1 -1
- package/lib/utils/tabsUtils.d.ts +46 -0
- package/lib/utils/tabsUtils.d.ts.map +1 -0
- package/lib/utils/tabsUtils.js +151 -0
- package/lib/utils/tabsUtils.js.map +1 -0
- package/package.json +11 -10
- package/src/hooks/useHideableNavbar.ts +7 -1
- package/src/hooks/useSearchPage.ts +10 -5
- package/src/index.ts +12 -1
- package/src/internal.ts +7 -6
- package/src/utils/admonitionUtils.tsx +43 -0
- package/src/utils/historyUtils.ts +29 -1
- package/src/utils/skipToContentUtils.tsx +103 -0
- package/src/utils/storageUtils.ts +108 -7
- package/src/utils/tabsUtils.tsx +266 -0
- package/lib/contexts/tabGroupChoice.d.ts +0 -21
- package/lib/contexts/tabGroupChoice.d.ts.map +0 -1
- package/lib/contexts/tabGroupChoice.js +0 -49
- package/lib/contexts/tabGroupChoice.js.map +0 -1
- package/lib/hooks/useSkipToContent.d.ts +0 -25
- package/lib/hooks/useSkipToContent.d.ts.map +0 -1
- package/lib/hooks/useSkipToContent.js +0 -35
- package/lib/hooks/useSkipToContent.js.map +0 -1
- package/src/contexts/tabGroupChoice.tsx +0 -85
- package/src/hooks/useSkipToContent.ts +0 -58
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHideableNavbar.d.ts","sourceRoot":"","sources":["../../src/hooks/useHideableNavbar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,OAAO,GAAG;IACxD,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IACvD,+DAA+D;IAC/D,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CACnC,
|
|
1
|
+
{"version":3,"file":"useHideableNavbar.d.ts","sourceRoot":"","sources":["../../src/hooks/useHideableNavbar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,OAAO,GAAG;IACxD,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IACvD,+DAA+D;IAC/D,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CACnC,CA4DA"}
|
|
@@ -48,7 +48,12 @@ export function useHideableNavbar(hideOnScroll) {
|
|
|
48
48
|
if (!hideOnScroll) {
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
// See https://github.com/facebook/docusaurus/pull/8059#issuecomment-1239639480
|
|
52
|
+
const currentHash = locationChangeEvent.location.hash;
|
|
53
|
+
const currentHashAnchor = currentHash
|
|
54
|
+
? document.getElementById(currentHash.substring(1))
|
|
55
|
+
: undefined;
|
|
56
|
+
if (currentHashAnchor) {
|
|
52
57
|
isFocusedAnchor.current = true;
|
|
53
58
|
setIsNavbarVisible(false);
|
|
54
59
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHideableNavbar.js","sourceRoot":"","sources":["../../src/hooks/useHideableNavbar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AACpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAEvD;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,YAAqB;IAMrD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IACrE,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,IAAwB,EAAE,EAAE;QACzD,IAAI,IAAI,KAAK,IAAI,EAAE;YACjB,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC;SAC5D;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,iBAAiB,CAAC,CAAC,EAAC,OAAO,EAAE,SAAS,EAAC,EAAE,YAAY,EAAE,EAAE;QACvD,IAAI,CAAC,YAAY,EAAE;YACjB,OA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AAc,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACnD,CAAC,CAAC,SAAS,CAAC;QAEd,IAAI,iBAAiB,EAAE;YACrB,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;YAC/B,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC1B,OAAO;SACR;QAED,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,CAAC;AACtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSearchPage.d.ts","sourceRoot":"","sources":["../../src/hooks/useSearchPage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"useSearchPage.d.ts","sourceRoot":"","sources":["../../src/hooks/useSearchPage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,oDAAoD;AACpD,wBAAgB,aAAa,IAAI;IAC/B;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,cAAc,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD;;;OAGG;IACH,sBAAsB,EAAE,CAAC,iBAAiB,EAAE,MAAM,KAAK,MAAM,CAAC;CAC/D,CAoDA"}
|
|
@@ -11,7 +11,8 @@ const SEARCH_PARAM_QUERY = 'q';
|
|
|
11
11
|
/** Some utility functions around search queries. */
|
|
12
12
|
export function useSearchPage() {
|
|
13
13
|
const history = useHistory();
|
|
14
|
-
const { siteConfig: { baseUrl }, } = useDocusaurusContext();
|
|
14
|
+
const { siteConfig: { baseUrl, themeConfig }, } = useDocusaurusContext();
|
|
15
|
+
const { algolia: { searchPagePath }, } = themeConfig;
|
|
15
16
|
const [searchQuery, setSearchQueryState] = useState('');
|
|
16
17
|
// Init search query just after React hydration
|
|
17
18
|
useEffect(() => {
|
|
@@ -33,7 +34,8 @@ export function useSearchPage() {
|
|
|
33
34
|
}, [history]);
|
|
34
35
|
const generateSearchPageLink = useCallback((targetSearchQuery) =>
|
|
35
36
|
// Refer to https://github.com/facebook/docusaurus/pull/2838
|
|
36
|
-
|
|
37
|
+
// Note: if searchPagePath is falsy, useSearchPage() will not be called
|
|
38
|
+
`${baseUrl}${searchPagePath}?${SEARCH_PARAM_QUERY}=${encodeURIComponent(targetSearchQuery)}`, [baseUrl, searchPagePath]);
|
|
37
39
|
return {
|
|
38
40
|
searchQuery,
|
|
39
41
|
setSearchQuery,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSearchPage.js","sourceRoot":"","sources":["../../src/hooks/useSearchPage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAC9C,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"useSearchPage.js","sourceRoot":"","sources":["../../src/hooks/useSearchPage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAC9C,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AAGpE,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B,oDAAoD;AACpD,MAAM,UAAU,aAAa;IAiB3B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,EACJ,UAAU,EAAE,EAAC,OAAO,EAAE,WAAW,EAAC,GACnC,GAAG,oBAAoB,EAAE,CAAC;IAC3B,MAAM,EACJ,OAAO,EAAE,EAAC,cAAc,EAAC,GAC1B,GAAG,WAAiC,CAAC;IAEtC,MAAM,CAAC,WAAW,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAExD,+CAA+C;IAC/C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,sBAAsB,GAC1B,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC;QAE5E,mBAAmB,CAAC,sBAAsB,CAAC,CAAC;IAC9C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,cAAsB,EAAE,EAAE;QACzB,MAAM,YAAY,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEjE,IAAI,cAAc,EAAE;YAClB,YAAY,CAAC,GAAG,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;SACtD;aAAM;YACL,YAAY,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;SACzC;QAED,OAAO,CAAC,OAAO,CAAC;YACd,MAAM,EAAE,YAAY,CAAC,QAAQ,EAAE;SAChC,CAAC,CAAC;QACH,mBAAmB,CAAC,cAAc,CAAC,CAAC;IACtC,CAAC,EACD,CAAC,OAAO,CAAC,CACV,CAAC;IAEF,MAAM,sBAAsB,GAAG,WAAW,CACxC,CAAC,iBAAyB,EAAE,EAAE;IAC5B,4DAA4D;IAC5D,uEAAuE;IACvE,GAAG,OAAO,GACR,cACF,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,iBAAiB,CAAC,EAAE,EACnE,CAAC,OAAO,EAAE,cAAc,CAAC,CAC1B,CAAC;IAEF,OAAO;QACL,WAAW;QACX,cAAc;QACd,sBAAsB;KACvB,CAAC;AACJ,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
export { useThemeConfig, type ThemeConfig, type UserThemeConfig, type Navbar, type NavbarItem, type NavbarLogo, type MultiColumnFooter, type SimpleFooter, type Footer, type FooterLogo, type FooterLinkItem, type ColorModeConfig, } from './utils/useThemeConfig';
|
|
8
|
-
export { createStorageSlot, listStorageKeys } from './utils/storageUtils';
|
|
8
|
+
export { createStorageSlot, useStorageSlot, listStorageKeys, } from './utils/storageUtils';
|
|
9
9
|
export { useContextualSearchFilters } from './utils/searchUtils';
|
|
10
10
|
export { useCurrentSidebarCategory, filterDocCardListItems, } from './utils/docsUtils';
|
|
11
11
|
export { usePluralForm } from './utils/usePluralForm';
|
|
@@ -22,4 +22,6 @@ export { isRegexpStringMatch } from './utils/regexpUtils';
|
|
|
22
22
|
export { duplicates, uniq } from './utils/jsUtils';
|
|
23
23
|
export { usePrismTheme } from './hooks/usePrismTheme';
|
|
24
24
|
export { useDocsPreferredVersion } from './contexts/docsPreferredVersion';
|
|
25
|
+
export { processAdmonitionProps } from './utils/admonitionUtils';
|
|
26
|
+
export { SkipToContentFallbackId, SkipToContentLink, } from './utils/skipToContentUtils';
|
|
25
27
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EACL,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EACL,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,UAAU,E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CAAC;AAExE,OAAO,EAAC,sBAAsB,EAAC,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EACL,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* APIs to document
|
|
9
9
|
*/
|
|
10
10
|
export { useThemeConfig, } from './utils/useThemeConfig';
|
|
11
|
-
export { createStorageSlot, listStorageKeys } from './utils/storageUtils';
|
|
11
|
+
export { createStorageSlot, useStorageSlot, listStorageKeys, } from './utils/storageUtils';
|
|
12
12
|
export { useContextualSearchFilters } from './utils/searchUtils';
|
|
13
13
|
export { useCurrentSidebarCategory, filterDocCardListItems, } from './utils/docsUtils';
|
|
14
14
|
export { usePluralForm } from './utils/usePluralForm';
|
|
@@ -29,4 +29,6 @@ export { isRegexpStringMatch } from './utils/regexpUtils';
|
|
|
29
29
|
export { duplicates, uniq } from './utils/jsUtils';
|
|
30
30
|
export { usePrismTheme } from './hooks/usePrismTheme';
|
|
31
31
|
export { useDocsPreferredVersion } from './contexts/docsPreferredVersion';
|
|
32
|
+
export { processAdmonitionProps } from './utils/admonitionUtils';
|
|
33
|
+
export { SkipToContentFallbackId, SkipToContentLink, } from './utils/skipToContentUtils';
|
|
32
34
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AAEH,OAAO,EACL,cAAc,GAYf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AAEH,OAAO,EACL,cAAc,GAYf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,0BAA0B,EAAC,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EACL,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAC,cAAc,EAAE,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAErE,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAExD,OAAO,EACL,yBAAyB,EACzB,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAC,YAAY,EAAE,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AAE1E,OAAO,EAAC,YAAY,EAAiB,MAAM,sBAAsB,CAAC;AAElE,OAAO,EACL,yBAAyB,GAE1B,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAEpD;;;GAGG;AAEH,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAElB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,wBAAwB,EAAC,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAC,mBAAmB,EAAC,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAC,UAAU,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAC,uBAAuB,EAAC,MAAM,iCAAiC,CAAC;AAExE,OAAO,EAAC,sBAAsB,EAAC,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EACL,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC"}
|
package/lib/internal.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ export { DocProvider, useDoc, type DocContextValue } from './contexts/doc';
|
|
|
12
12
|
export { BlogPostProvider, useBlogPost, type BlogPostContextValue, } from './contexts/blogPost';
|
|
13
13
|
export { useDocsPreferredVersionByPluginId, DocsPreferredVersionContextProvider, } from './contexts/docsPreferredVersion';
|
|
14
14
|
export { AnnouncementBarProvider, useAnnouncementBar, } from './contexts/announcementBar';
|
|
15
|
-
export {
|
|
15
|
+
export { useTabs } from './utils/tabsUtils';
|
|
16
|
+
export type { TabValue, TabsProps, TabItemProps } from './utils/tabsUtils';
|
|
16
17
|
export { useNavbarMobileSidebar } from './contexts/navbarMobileSidebar';
|
|
17
18
|
export { useNavbarSecondaryMenu } from './contexts/navbarSecondaryMenu/display';
|
|
18
19
|
export { ColorModeProvider } from './contexts/colorMode';
|
|
@@ -23,7 +24,7 @@ export { isDocsPluginEnabled, useDocById, findSidebarCategory, findFirstCategory
|
|
|
23
24
|
export { useTitleFormatter } from './utils/generalUtils';
|
|
24
25
|
export { useLocationChange } from './utils/useLocationChange';
|
|
25
26
|
export { useLocalPathname } from './utils/useLocalPathname';
|
|
26
|
-
export { useHistoryPopHandler } from './utils/historyUtils';
|
|
27
|
+
export { useHistoryPopHandler, useHistorySelector, useQueryStringValue, } from './utils/historyUtils';
|
|
27
28
|
export { useFilteredAndTreeifiedTOC, useTreeifiedTOC, type TOCTreeNode, } from './utils/tocUtils';
|
|
28
29
|
export { ScrollControllerProvider, useScrollController, useScrollPosition, useScrollPositionBlocker, useSmoothScrollTo, } from './utils/scrollUtils';
|
|
29
30
|
export { useHomePageRoute, isSamePath } from './utils/routesUtils';
|
|
@@ -35,7 +36,6 @@ export { useKeyboardNavigation, keyboardFocusedClassName, } from './hooks/useKey
|
|
|
35
36
|
export { useLockBodyScroll } from './hooks/useLockBodyScroll';
|
|
36
37
|
export { useSearchPage } from './hooks/useSearchPage';
|
|
37
38
|
export { useCodeWordWrap } from './hooks/useCodeWordWrap';
|
|
38
|
-
export { useSkipToContent } from './hooks/useSkipToContent';
|
|
39
39
|
export { getPrismCssVariables } from './utils/codeBlockUtils';
|
|
40
40
|
export { useBackToTopButton } from './hooks/useBackToTopButton';
|
|
41
41
|
//# sourceMappingURL=internal.d.ts.map
|
package/lib/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,cAAc,SAAS,CAAC;AAExB,OAAO,EACL,oCAAoC,EACpC,+BAA+B,GAChC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAC,mBAAmB,EAAE,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAC,mBAAmB,EAAE,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAE3E,OAAO,EAAC,WAAW,EAAE,MAAM,EAAE,KAAK,eAAe,EAAC,MAAM,gBAAgB,CAAC;AACzE,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,KAAK,oBAAoB,GAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,iCAAiC,EACjC,mCAAmC,GACpC,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,cAAc,SAAS,CAAC;AAExB,OAAO,EACL,oCAAoC,EACpC,+BAA+B,GAChC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAC,mBAAmB,EAAE,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAC,mBAAmB,EAAE,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAE3E,OAAO,EAAC,WAAW,EAAE,MAAM,EAAE,KAAK,eAAe,EAAC,MAAM,gBAAgB,CAAC;AACzE,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,KAAK,oBAAoB,GAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAC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AC;AAE7B,OAAO,EAAC,gBAAgB,EAAE,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAEjE,OAAO,EAAC,2BAA2B,EAAC,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAC,gBAAgB,EAAE,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAErE,OAAO,EACL,eAAe,EACf,KAAK,kBAAkB,GACxB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,kBAAkB,EAAC,MAAM,4BAA4B,CAAC"}
|
package/lib/internal.js
CHANGED
|
@@ -23,7 +23,7 @@ export { DocProvider, useDoc } from './contexts/doc';
|
|
|
23
23
|
export { BlogPostProvider, useBlogPost, } from './contexts/blogPost';
|
|
24
24
|
export { useDocsPreferredVersionByPluginId, DocsPreferredVersionContextProvider, } from './contexts/docsPreferredVersion';
|
|
25
25
|
export { AnnouncementBarProvider, useAnnouncementBar, } from './contexts/announcementBar';
|
|
26
|
-
export {
|
|
26
|
+
export { useTabs } from './utils/tabsUtils';
|
|
27
27
|
export { useNavbarMobileSidebar } from './contexts/navbarMobileSidebar';
|
|
28
28
|
export { useNavbarSecondaryMenu } from './contexts/navbarSecondaryMenu/display';
|
|
29
29
|
export { ColorModeProvider } from './contexts/colorMode';
|
|
@@ -34,7 +34,7 @@ export { isDocsPluginEnabled, useDocById, findSidebarCategory, findFirstCategory
|
|
|
34
34
|
export { useTitleFormatter } from './utils/generalUtils';
|
|
35
35
|
export { useLocationChange } from './utils/useLocationChange';
|
|
36
36
|
export { useLocalPathname } from './utils/useLocalPathname';
|
|
37
|
-
export { useHistoryPopHandler } from './utils/historyUtils';
|
|
37
|
+
export { useHistoryPopHandler, useHistorySelector, useQueryStringValue, } from './utils/historyUtils';
|
|
38
38
|
export { useFilteredAndTreeifiedTOC, useTreeifiedTOC, } from './utils/tocUtils';
|
|
39
39
|
export { ScrollControllerProvider, useScrollController, useScrollPosition, useScrollPositionBlocker, useSmoothScrollTo, } from './utils/scrollUtils';
|
|
40
40
|
export { useHomePageRoute, isSamePath } from './utils/routesUtils';
|
|
@@ -46,7 +46,6 @@ export { useKeyboardNavigation, keyboardFocusedClassName, } from './hooks/useKey
|
|
|
46
46
|
export { useLockBodyScroll } from './hooks/useLockBodyScroll';
|
|
47
47
|
export { useSearchPage } from './hooks/useSearchPage';
|
|
48
48
|
export { useCodeWordWrap } from './hooks/useCodeWordWrap';
|
|
49
|
-
export { useSkipToContent } from './hooks/useSkipToContent';
|
|
50
49
|
export { getPrismCssVariables } from './utils/codeBlockUtils';
|
|
51
50
|
export { useBackToTopButton } from './hooks/useBackToTopButton';
|
|
52
51
|
//# sourceMappingURL=internal.js.map
|
package/lib/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,4EAA4E;AAC5E,6EAA6E;AAC7E,2EAA2E;AAC3E,uDAAuD;AACvD,EAAE;AACF,6DAA6D;AAC7D,gFAAgF;AAChF,yEAAyE;AACzE,oDAAoD;AACpD,EAAE;AACF,gDAAgD;AAChD,cAAc,SAAS,CAAC;AAExB,OAAO,EACL,oCAAoC,EACpC,+BAA+B,GAChC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAC,mBAAmB,EAAE,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAC,mBAAmB,EAAE,cAAc,EAAC,MAAM,wBAAwB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EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,kBAAkB,EAAC,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
import { type ReactNode } from 'react';
|
|
8
|
+
export declare function processAdmonitionProps<Props extends {
|
|
9
|
+
readonly children: ReactNode;
|
|
10
|
+
readonly title?: ReactNode;
|
|
11
|
+
}>(props: Props): Props;
|
|
12
|
+
//# sourceMappingURL=admonitionUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admonitionUtils.d.ts","sourceRoot":"","sources":["../../src/utils/admonitionUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAC,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAsB5C,wBAAgB,sBAAsB,CACpC,KAAK,SAAS;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAC,EACxE,KAAK,EAAE,KAAK,GAAG,KAAK,CAWrB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
import React from 'react';
|
|
8
|
+
// Workaround because it's difficult in MDX v1 to provide a MDX title as props
|
|
9
|
+
// See https://github.com/facebook/docusaurus/pull/7152#issuecomment-1145779682
|
|
10
|
+
function extractMDXAdmonitionTitle(children) {
|
|
11
|
+
const items = React.Children.toArray(children);
|
|
12
|
+
const mdxAdmonitionTitle = items.find((item) => React.isValidElement(item) &&
|
|
13
|
+
item.props?.mdxType ===
|
|
14
|
+
'mdxAdmonitionTitle');
|
|
15
|
+
const rest = <>{items.filter((item) => item !== mdxAdmonitionTitle)}</>;
|
|
16
|
+
return {
|
|
17
|
+
mdxAdmonitionTitle: mdxAdmonitionTitle?.props.children,
|
|
18
|
+
rest,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function processAdmonitionProps(props) {
|
|
22
|
+
const { mdxAdmonitionTitle, rest } = extractMDXAdmonitionTitle(props.children);
|
|
23
|
+
const title = props.title ?? mdxAdmonitionTitle;
|
|
24
|
+
return {
|
|
25
|
+
...props,
|
|
26
|
+
// Do not return "title: undefined" prop
|
|
27
|
+
// this might create unwanted props overrides when merging props
|
|
28
|
+
// For example: {...default,...props}
|
|
29
|
+
...(title && { title }),
|
|
30
|
+
children: rest,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=admonitionUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admonitionUtils.js","sourceRoot":"","sources":["../../src/utils/admonitionUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAuB,MAAM,OAAO,CAAC;AAE5C,8EAA8E;AAC9E,+EAA+E;AAC/E,SAAS,yBAAyB,CAAC,QAAmB;IAIpD,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,kBAAkB,GAAG,KAAK,CAAC,IAAI,CACnC,CAAC,IAAI,EAAE,EAAE,CACP,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,KAAkC,EAAE,OAAO;YAC/C,oBAAoB,CACE,CAAC;IAC7B,MAAM,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,kBAAkB,CAAC,CAAC,GAAG,CAAC;IACxE,OAAO;QACL,kBAAkB,EAAE,kBAAkB,EAAE,KAAK,CAAC,QAAQ;QACtD,IAAI;KACL,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAEpC,KAAY;IACZ,MAAM,EAAC,kBAAkB,EAAE,IAAI,EAAC,GAAG,yBAAyB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC7E,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,kBAAkB,CAAC;IAChD,OAAO;QACL,GAAG,KAAK;QACR,wCAAwC;QACxC,gEAAgE;QAChE,qCAAqC;QACrC,GAAG,CAAC,KAAK,IAAI,EAAC,KAAK,EAAC,CAAC;QACrB,QAAQ,EAAE,IAAI;KACf,CAAC;AACJ,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
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 type { Location, Action } from 'history';
|
|
7
|
+
import type { History, Location, Action } from 'history';
|
|
8
8
|
declare type HistoryBlockHandler = (location: Location, action: Action) => void | false;
|
|
9
9
|
/**
|
|
10
10
|
* Permits to register a handler that will be called on history pop navigation
|
|
@@ -13,5 +13,16 @@ declare type HistoryBlockHandler = (location: Location, action: Action) => void
|
|
|
13
13
|
* "direction" (backward/forward) of the POP event.
|
|
14
14
|
*/
|
|
15
15
|
export declare function useHistoryPopHandler(handler: HistoryBlockHandler): void;
|
|
16
|
+
/**
|
|
17
|
+
* Permits to efficiently subscribe to a slice of the history
|
|
18
|
+
* See https://thisweekinreact.com/articles/useSyncExternalStore-the-underrated-react-api
|
|
19
|
+
* @param selector
|
|
20
|
+
*/
|
|
21
|
+
export declare function useHistorySelector<Value>(selector: (history: History<unknown>) => Value): Value;
|
|
22
|
+
/**
|
|
23
|
+
* Permits to efficiently subscribe to a specific querystring value
|
|
24
|
+
* @param key
|
|
25
|
+
*/
|
|
26
|
+
export declare function useQueryStringValue(key: string | null): string | null;
|
|
16
27
|
export {};
|
|
17
28
|
//# sourceMappingURL=historyUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"historyUtils.d.ts","sourceRoot":"","sources":["../../src/utils/historyUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"historyUtils.d.ts","sourceRoot":"","sources":["../../src/utils/historyUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAC,MAAM,SAAS,CAAC;AAEvD,aAAK,mBAAmB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,KAAK,CAAC;AAiBhF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CASvE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EACtC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,KAAK,GAC7C,KAAK,CAGP;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAOrE"}
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { useEffect } from 'react';
|
|
8
8
|
import { useHistory } from '@docusaurus/router';
|
|
9
|
+
// @ts-expect-error: TODO temporary until React 18 upgrade
|
|
10
|
+
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
9
11
|
import { useEvent } from './reactUtils';
|
|
10
12
|
/**
|
|
11
13
|
* Permits to register a handler that will be called on history actions (pop,
|
|
@@ -35,4 +37,25 @@ export function useHistoryPopHandler(handler) {
|
|
|
35
37
|
return undefined;
|
|
36
38
|
});
|
|
37
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Permits to efficiently subscribe to a slice of the history
|
|
42
|
+
* See https://thisweekinreact.com/articles/useSyncExternalStore-the-underrated-react-api
|
|
43
|
+
* @param selector
|
|
44
|
+
*/
|
|
45
|
+
export function useHistorySelector(selector) {
|
|
46
|
+
const history = useHistory();
|
|
47
|
+
return useSyncExternalStore(history.listen, () => selector(history));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Permits to efficiently subscribe to a specific querystring value
|
|
51
|
+
* @param key
|
|
52
|
+
*/
|
|
53
|
+
export function useQueryStringValue(key) {
|
|
54
|
+
return useHistorySelector((history) => {
|
|
55
|
+
if (key === null) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return new URLSearchParams(history.location.search).get(key);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
38
61
|
//# sourceMappingURL=historyUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"historyUtils.js","sourceRoot":"","sources":["../../src/utils/historyUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAChC,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"historyUtils.js","sourceRoot":"","sources":["../../src/utils/historyUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAChC,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAC9C,0DAA0D;AAC1D,OAAO,EAAC,oBAAoB,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AA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|
|
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
|
+
import { type ComponentProps } from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* The id of the element that should become focused on a page
|
|
10
|
+
* that does not have a <main> html tag.
|
|
11
|
+
* Focusing the Docusaurus Layout children is a reasonable fallback.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SkipToContentFallbackId = "docusaurus_skipToContent_fallback";
|
|
14
|
+
declare type SkipToContentLinkProps = Omit<ComponentProps<'a'>, 'href' | 'onClick'>;
|
|
15
|
+
export declare function SkipToContentLink(props: SkipToContentLinkProps): JSX.Element;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=skipToContentUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skipToContentUtils.d.ts","sourceRoot":"","sources":["../../src/utils/skipToContentUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAAsB,KAAK,cAAc,EAAC,MAAM,OAAO,CAAC;AAKtE;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,sCAAsC,CAAC;AAiE3E,aAAK,sBAAsB,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAE5E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,CAkB5E"}
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
import React, { useCallback, useRef } from 'react';
|
|
8
|
+
import { useHistory } from '@docusaurus/router';
|
|
9
|
+
import { translate } from '@docusaurus/Translate';
|
|
10
|
+
import { useLocationChange } from './useLocationChange';
|
|
11
|
+
/**
|
|
12
|
+
* The id of the element that should become focused on a page
|
|
13
|
+
* that does not have a <main> html tag.
|
|
14
|
+
* Focusing the Docusaurus Layout children is a reasonable fallback.
|
|
15
|
+
*/
|
|
16
|
+
export const SkipToContentFallbackId = 'docusaurus_skipToContent_fallback';
|
|
17
|
+
/**
|
|
18
|
+
* Returns the skip to content element to focus when the link is clicked.
|
|
19
|
+
*/
|
|
20
|
+
function getSkipToContentTarget() {
|
|
21
|
+
return (
|
|
22
|
+
// Try to focus the <main> in priority
|
|
23
|
+
// Note: this will only work if JS is enabled
|
|
24
|
+
// See https://github.com/facebook/docusaurus/issues/6411#issuecomment-1284136069
|
|
25
|
+
document.querySelector('main:first-of-type') ??
|
|
26
|
+
// Then try to focus the fallback element (usually the Layout children)
|
|
27
|
+
document.getElementById(SkipToContentFallbackId));
|
|
28
|
+
}
|
|
29
|
+
function programmaticFocus(el) {
|
|
30
|
+
el.setAttribute('tabindex', '-1');
|
|
31
|
+
el.focus();
|
|
32
|
+
el.removeAttribute('tabindex');
|
|
33
|
+
}
|
|
34
|
+
/** This hook wires the logic for a skip-to-content link. */
|
|
35
|
+
function useSkipToContent() {
|
|
36
|
+
const containerRef = useRef(null);
|
|
37
|
+
const { action } = useHistory();
|
|
38
|
+
const onClick = useCallback((e) => {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
const targetElement = getSkipToContentTarget();
|
|
41
|
+
if (targetElement) {
|
|
42
|
+
programmaticFocus(targetElement);
|
|
43
|
+
}
|
|
44
|
+
}, []);
|
|
45
|
+
// "Reset" focus when navigating.
|
|
46
|
+
// See https://github.com/facebook/docusaurus/pull/8204#issuecomment-1276547558
|
|
47
|
+
useLocationChange(({ location }) => {
|
|
48
|
+
if (containerRef.current && !location.hash && action === 'PUSH') {
|
|
49
|
+
programmaticFocus(containerRef.current);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return { containerRef, onClick };
|
|
53
|
+
}
|
|
54
|
+
const DefaultSkipToContentLabel = translate({
|
|
55
|
+
id: 'theme.common.skipToMainContent',
|
|
56
|
+
description: 'The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation',
|
|
57
|
+
message: 'Skip to main content',
|
|
58
|
+
});
|
|
59
|
+
export function SkipToContentLink(props) {
|
|
60
|
+
const linkLabel = props.children ?? DefaultSkipToContentLabel;
|
|
61
|
+
const { containerRef, onClick } = useSkipToContent();
|
|
62
|
+
return (<div ref={containerRef} role="region" aria-label={DefaultSkipToContentLabel}>
|
|
63
|
+
<a {...props}
|
|
64
|
+
// Note this is a fallback href in case JS is disabled
|
|
65
|
+
// It has limitations, see https://github.com/facebook/docusaurus/issues/6411#issuecomment-1284136069
|
|
66
|
+
href={`#${SkipToContentFallbackId}`} onClick={onClick}>
|
|
67
|
+
{linkLabel}
|
|
68
|
+
</a>
|
|
69
|
+
</div>);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=skipToContentUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skipToContentUtils.js","sourceRoot":"","sources":["../../src/utils/skipToContentUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAAC,WAAW,EAAE,MAAM,EAAsB,MAAM,OAAO,CAAC;AACtE,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,mCAAmC,CAAC;AAE3E;;GAEG;AACH,SAAS,sBAAsB;IAC7B,OAAO;IACL,sCAAsC;IACtC,6CAA6C;IAC7C,iFAAiF;IACjF,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAC;QA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AM,EAAC,YAAY,EAAE,OAAO,EAAC,GAAG,gBAAgB,EAAE,CAAC;IACnD,OAAO,CACL,CAAC,GAAG,CACF,GAAG,CAAC,CAAC,YAAY,CAAC,CAClB,IAAI,CAAC,QAAQ,CACb,UAAU,CAAC,CAAC,yBAAyB,CAAC,CACtC;MAAA,CAAC,CAAC,CACA,IAAI,KAAK,CAAC;IACV,sDAAsD;IACtD,qGAAqG;IACrG,IAAI,CAAC,CAAC,IAAI,uBAAuB,EAAE,CAAC,CACpC,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB;QAAA,CAAC,SAAS,CACZ;MAAA,EAAE,CAAC,CACL;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -10,6 +10,7 @@ export declare type StorageSlot = {
|
|
|
10
10
|
get: () => string | null;
|
|
11
11
|
set: (value: string) => void;
|
|
12
12
|
del: () => void;
|
|
13
|
+
listen: (onChange: (event: StorageEvent) => void) => () => void;
|
|
13
14
|
};
|
|
14
15
|
/**
|
|
15
16
|
* Creates an interface to work on a particular key in the storage model.
|
|
@@ -24,6 +25,9 @@ export declare type StorageSlot = {
|
|
|
24
25
|
export declare function createStorageSlot(key: string, options?: {
|
|
25
26
|
persistence?: StorageType;
|
|
26
27
|
}): StorageSlot;
|
|
28
|
+
export declare function useStorageSlot(key: string | null, options?: {
|
|
29
|
+
persistence?: StorageType;
|
|
30
|
+
}): [string | null, StorageSlot];
|
|
27
31
|
/**
|
|
28
32
|
* Returns a list of all the keys currently stored in browser storage,
|
|
29
33
|
* or an empty list if browser storage can't be accessed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storageUtils.d.ts","sourceRoot":"","sources":["../../src/utils/storageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"storageUtils.d.ts","sourceRoot":"","sources":["../../src/utils/storageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,QAAA,MAAM,YAAY,qDAAsD,CAAC;AAEzE,oBAAY,WAAW,GAAG,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AA6EtD,oBAAY,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACzB,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,GAAG,EAAE,MAAM,IAAI,CAAC;IAChB,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CACjE,CAAC;AAyBF;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;IAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CAAC,GACpC,WAAW,CA6Db;AAED,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,OAAO,CAAC,EAAE;IAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CAAC,GACpC,CAAC,MAAM,GAAG,IAAI,EAAE,WAAW,CAAC,CAiC9B;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,WAAW,GAAE,WAAgC,GAC5C,MAAM,EAAE,CAcV"}
|
|
@@ -4,8 +4,21 @@
|
|
|
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 { useCallback, useRef } from 'react';
|
|
8
|
+
// @ts-expect-error: TODO temp error until React 18 upgrade
|
|
9
|
+
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
7
10
|
const StorageTypes = ['localStorage', 'sessionStorage', 'none'];
|
|
8
11
|
const DefaultStorageType = 'localStorage';
|
|
12
|
+
// window.addEventListener('storage') only works for different windows...
|
|
13
|
+
// so for current window we have to dispatch the event manually
|
|
14
|
+
// Now we can listen for both cross-window / current-window storage changes!
|
|
15
|
+
// see https://stackoverflow.com/a/71177640/82609
|
|
16
|
+
// see https://stackoverflow.com/questions/26974084/listen-for-changes-with-localstorage-on-the-same-window
|
|
17
|
+
function dispatchChangeEvent({ key, oldValue, newValue, storage, }) {
|
|
18
|
+
const event = document.createEvent('StorageEvent');
|
|
19
|
+
event.initStorageEvent('storage', false, false, key, oldValue, newValue, window.location.href, storage);
|
|
20
|
+
window.dispatchEvent(event);
|
|
21
|
+
}
|
|
9
22
|
/**
|
|
10
23
|
* Will return `null` if browser storage is unavailable (like running Docusaurus
|
|
11
24
|
* in an iframe). This should NOT be called in SSR.
|
|
@@ -44,6 +57,7 @@ const NoopStorageSlot = {
|
|
|
44
57
|
get: () => null,
|
|
45
58
|
set: () => { },
|
|
46
59
|
del: () => { },
|
|
60
|
+
listen: () => () => { },
|
|
47
61
|
};
|
|
48
62
|
// Fail-fast, as storage APIs should not be used during the SSR process
|
|
49
63
|
function createServerStorageSlot(key) {
|
|
@@ -56,6 +70,7 @@ Please only call storage APIs in effects and event handlers.`);
|
|
|
56
70
|
get: throwError,
|
|
57
71
|
set: throwError,
|
|
58
72
|
del: throwError,
|
|
73
|
+
listen: throwError,
|
|
59
74
|
};
|
|
60
75
|
}
|
|
61
76
|
/**
|
|
@@ -72,38 +87,86 @@ export function createStorageSlot(key, options) {
|
|
|
72
87
|
if (typeof window === 'undefined') {
|
|
73
88
|
return createServerStorageSlot(key);
|
|
74
89
|
}
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
90
|
+
const storage = getBrowserStorage(options?.persistence);
|
|
91
|
+
if (storage === null) {
|
|
77
92
|
return NoopStorageSlot;
|
|
78
93
|
}
|
|
79
94
|
return {
|
|
80
95
|
get: () => {
|
|
81
96
|
try {
|
|
82
|
-
return
|
|
97
|
+
return storage.getItem(key);
|
|
83
98
|
}
|
|
84
99
|
catch (err) {
|
|
85
100
|
console.error(`Docusaurus storage error, can't get key=${key}`, err);
|
|
86
101
|
return null;
|
|
87
102
|
}
|
|
88
103
|
},
|
|
89
|
-
set: (
|
|
104
|
+
set: (newValue) => {
|
|
90
105
|
try {
|
|
91
|
-
|
|
106
|
+
const oldValue = storage.getItem(key);
|
|
107
|
+
storage.setItem(key, newValue);
|
|
108
|
+
dispatchChangeEvent({
|
|
109
|
+
key,
|
|
110
|
+
oldValue,
|
|
111
|
+
newValue,
|
|
112
|
+
storage,
|
|
113
|
+
});
|
|
92
114
|
}
|
|
93
115
|
catch (err) {
|
|
94
|
-
console.error(`Docusaurus storage error, can't set ${key}=${
|
|
116
|
+
console.error(`Docusaurus storage error, can't set ${key}=${newValue}`, err);
|
|
95
117
|
}
|
|
96
118
|
},
|
|
97
119
|
del: () => {
|
|
98
120
|
try {
|
|
99
|
-
|
|
121
|
+
const oldValue = storage.getItem(key);
|
|
122
|
+
storage.removeItem(key);
|
|
123
|
+
dispatchChangeEvent({ key, oldValue, newValue: null, storage });
|
|
100
124
|
}
|
|
101
125
|
catch (err) {
|
|
102
126
|
console.error(`Docusaurus storage error, can't delete key=${key}`, err);
|
|
103
127
|
}
|
|
104
128
|
},
|
|
129
|
+
listen: (onChange) => {
|
|
130
|
+
try {
|
|
131
|
+
const listener = (event) => {
|
|
132
|
+
if (event.storageArea === storage && event.key === key) {
|
|
133
|
+
onChange(event);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
window.addEventListener('storage', listener);
|
|
137
|
+
return () => window.removeEventListener('storage', listener);
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
console.error(`Docusaurus storage error, can't listen for changes of key=${key}`, err);
|
|
141
|
+
return () => { };
|
|
142
|
+
}
|
|
143
|
+
},
|
|
105
144
|
};
|
|
106
145
|
}
|
|
146
|
+
export function useStorageSlot(key, options) {
|
|
147
|
+
// Not ideal but good enough: assumes storage slot config is constant
|
|
148
|
+
const storageSlot = useRef(() => {
|
|
149
|
+
if (key === null) {
|
|
150
|
+
return NoopStorageSlot;
|
|
151
|
+
}
|
|
152
|
+
return createStorageSlot(key, options);
|
|
153
|
+
}).current();
|
|
154
|
+
const listen = useCallback((onChange) => {
|
|
155
|
+
// Do not try to add a listener during SSR
|
|
156
|
+
if (typeof window === 'undefined') {
|
|
157
|
+
return () => { };
|
|
158
|
+
}
|
|
159
|
+
return storageSlot.listen(onChange);
|
|
160
|
+
}, [storageSlot]);
|
|
161
|
+
const currentValue = useSyncExternalStore(listen, () => {
|
|
162
|
+
// TODO this check should be useless after React 18
|
|
163
|
+
if (typeof window === 'undefined') {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
return storageSlot.get();
|
|
167
|
+
}, () => null);
|
|
168
|
+
return [currentValue, storageSlot];
|
|
169
|
+
}
|
|
107
170
|
/**
|
|
108
171
|
* Returns a list of all the keys currently stored in browser storage,
|
|
109
172
|
* or an empty list if browser storage can't be accessed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storageUtils.js","sourceRoot":"","sources":["../../src/utils/storageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,YAAY,GAAG,CAAC,cAAc,EAAE,gBAAgB,EAAE,MAAM,CAAU,CAAC;AAIzE,MAAM,kBAAkB,GAAgB,cAAc,CAAC;AAEvD;;;;;GAKG;AACH,SAAS,iBAAiB,CACxB,cAA2B,kBAAkB;IAE7C,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;KACH;IACD,IAAI,WAAW,KAAK,MAAM,EAAE;QAC1B,OAAO,IAAI,CAAC;KACb;IACD,IAAI;QACF,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC;KAC5B;IAAC,OAAO,GAAG,EAAE;QACZ,wCAAwC,CAAC,GAAY,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAED,IAAI,0CAA0C,GAAG,KAAK,CAAC;AACvD;;;;GAIG;AACH,SAAS,wCAAwC,CAAC,KAAY;IAC5D,IAAI,CAAC,0CAA0C,EAAE;QAC/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