@docusaurus/theme-common 2.1.0 → 2.2.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/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/internal.d.ts +0 -1
- package/lib/internal.d.ts.map +1 -1
- package/lib/internal.js +0 -1
- 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/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/package.json +10 -10
- package/src/hooks/useHideableNavbar.ts +7 -1
- package/src/index.ts +7 -0
- package/src/internal.ts +0 -1
- package/src/utils/admonitionUtils.tsx +43 -0
- package/src/utils/skipToContentUtils.tsx +103 -0
- 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/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,EA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QAC/D,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC;QAExC,IAAI,aAAa,IAAI,SAAS,IAAI,aAAa,EAAE;YAC/C,kBAAkB,CAAC,KAAK,CAAC,CAAC;SAC3B;aAAM,IAAI,SAAS,GAAG,YAAY,GAAG,cAAc,EAAE;YACpD,kBAAkB,CAAC,IAAI,CAAC,CAAC;SAC1B;IACH,CAAC,CAAC,CAAC;IAEH,iBAAiB,CAAC,CAAC,mBAAmB,EAAE,EAAE;QACxC,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO;SACR;QAED,+EAA+E;QAC/E,MAAM,WAAW,GAAG,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC;QACtD,MAAM,iBAAiB,GAAG,WAAW;YACnC,CAAC,CAAC,QAAQ,CAAC,cAAc,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"}
|
package/lib/index.d.ts
CHANGED
|
@@ -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 @@
|
|
|
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AAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,KAAK,cAAc,GACpB,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/index.js
CHANGED
|
@@ -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,EAAC,iBAAiB,EAAE,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAC,0BAA0B,EAAC,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EACL,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,aAAa,EAAC,MAAM,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E,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
|
@@ -35,7 +35,6 @@ export { useKeyboardNavigation, keyboardFocusedClassName, } from './hooks/useKey
|
|
|
35
35
|
export { useLockBodyScroll } from './hooks/useLockBodyScroll';
|
|
36
36
|
export { useSearchPage } from './hooks/useSearchPage';
|
|
37
37
|
export { useCodeWordWrap } from './hooks/useCodeWordWrap';
|
|
38
|
-
export { useSkipToContent } from './hooks/useSkipToContent';
|
|
39
38
|
export { getPrismCssVariables } from './utils/codeBlockUtils';
|
|
40
39
|
export { useBackToTopButton } from './hooks/useBackToTopButton';
|
|
41
40
|
//# 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,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAC,sBAAsB,EAAC,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAC,sBAAsB,EAAC,MAAM,wCAAwC,CAAC;AAE9E,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAC,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAC,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,qBAAqB,CAAC;AAE5E,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACrB,mB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AAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,KAAK,WAAW,GACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;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
|
@@ -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,CAAC;AAE3E,OAAO,EAAC,WAAW,EAAE,MAAM,EAAuB,MAAM,gBAAgB,CAAC;AACzE,OAAO,EACL,gBAAgB,EAChB,WAAW,GAEZ,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,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAC,sBAAsB,EAAC,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAC,sBAAsB,EAAC,MAAM,wCAAwC,CAAC;AAE9E,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAC,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAC,mBAAmB,EAAE,kBAAkB,EAAC,MAA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AC;AAE3B,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EACL,0BAA0B,EAC1B,eAAe,GAEhB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;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,GAEhB,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"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 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,E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B,GAAG,SAAS,CAAC;IAC1C,EAAE,EAAE,gCAAgC;IACpC,WAAW,EACT,mIAAmI;IACrI,OAAO,EAAE,sBAAsB;CAChC,CAAC,CAAC;AAIH,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,IAAI,yBAAyB,CAAC;IAC9D,MAAM,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Common code for Docusaurus themes.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
},
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@docusaurus/mdx-loader": "2.
|
|
34
|
-
"@docusaurus/module-type-aliases": "2.
|
|
35
|
-
"@docusaurus/plugin-content-blog": "2.
|
|
36
|
-
"@docusaurus/plugin-content-docs": "2.
|
|
37
|
-
"@docusaurus/plugin-content-pages": "2.
|
|
38
|
-
"@docusaurus/utils": "2.
|
|
33
|
+
"@docusaurus/mdx-loader": "2.2.0",
|
|
34
|
+
"@docusaurus/module-type-aliases": "2.2.0",
|
|
35
|
+
"@docusaurus/plugin-content-blog": "2.2.0",
|
|
36
|
+
"@docusaurus/plugin-content-docs": "2.2.0",
|
|
37
|
+
"@docusaurus/plugin-content-pages": "2.2.0",
|
|
38
|
+
"@docusaurus/utils": "2.2.0",
|
|
39
39
|
"@types/history": "^4.7.11",
|
|
40
40
|
"@types/react": "*",
|
|
41
41
|
"@types/react-router-config": "*",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"utility-types": "^3.10.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@docusaurus/core": "2.
|
|
50
|
-
"@docusaurus/types": "2.
|
|
49
|
+
"@docusaurus/core": "2.2.0",
|
|
50
|
+
"@docusaurus/types": "2.2.0",
|
|
51
51
|
"fs-extra": "^10.1.0",
|
|
52
52
|
"lodash": "^4.17.21"
|
|
53
53
|
},
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=16.14"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "a308fb7c81832cca354192fe2984f52749441249"
|
|
62
62
|
}
|
|
@@ -62,7 +62,13 @@ export function useHideableNavbar(hideOnScroll: boolean): {
|
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
// See https://github.com/facebook/docusaurus/pull/8059#issuecomment-1239639480
|
|
66
|
+
const currentHash = locationChangeEvent.location.hash;
|
|
67
|
+
const currentHashAnchor = currentHash
|
|
68
|
+
? document.getElementById(currentHash.substring(1))
|
|
69
|
+
: undefined;
|
|
70
|
+
|
|
71
|
+
if (currentHashAnchor) {
|
|
66
72
|
isFocusedAnchor.current = true;
|
|
67
73
|
setIsNavbarVisible(false);
|
|
68
74
|
return;
|
package/src/index.ts
CHANGED
|
@@ -78,3 +78,10 @@ export {duplicates, uniq} from './utils/jsUtils';
|
|
|
78
78
|
export {usePrismTheme} from './hooks/usePrismTheme';
|
|
79
79
|
|
|
80
80
|
export {useDocsPreferredVersion} from './contexts/docsPreferredVersion';
|
|
81
|
+
|
|
82
|
+
export {processAdmonitionProps} from './utils/admonitionUtils';
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
SkipToContentFallbackId,
|
|
86
|
+
SkipToContentLink,
|
|
87
|
+
} from './utils/skipToContentUtils';
|
package/src/internal.ts
CHANGED
|
@@ -117,6 +117,5 @@ export {
|
|
|
117
117
|
export {useLockBodyScroll} from './hooks/useLockBodyScroll';
|
|
118
118
|
export {useSearchPage} from './hooks/useSearchPage';
|
|
119
119
|
export {useCodeWordWrap} from './hooks/useCodeWordWrap';
|
|
120
|
-
export {useSkipToContent} from './hooks/useSkipToContent';
|
|
121
120
|
export {getPrismCssVariables} from './utils/codeBlockUtils';
|
|
122
121
|
export {useBackToTopButton} from './hooks/useBackToTopButton';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React, {type ReactNode} from 'react';
|
|
9
|
+
|
|
10
|
+
// Workaround because it's difficult in MDX v1 to provide a MDX title as props
|
|
11
|
+
// See https://github.com/facebook/docusaurus/pull/7152#issuecomment-1145779682
|
|
12
|
+
function extractMDXAdmonitionTitle(children: ReactNode): {
|
|
13
|
+
mdxAdmonitionTitle: ReactNode | undefined;
|
|
14
|
+
rest: ReactNode;
|
|
15
|
+
} {
|
|
16
|
+
const items = React.Children.toArray(children);
|
|
17
|
+
const mdxAdmonitionTitle = items.find(
|
|
18
|
+
(item) =>
|
|
19
|
+
React.isValidElement(item) &&
|
|
20
|
+
(item.props as {mdxType: string} | null)?.mdxType ===
|
|
21
|
+
'mdxAdmonitionTitle',
|
|
22
|
+
) as JSX.Element | undefined;
|
|
23
|
+
const rest = <>{items.filter((item) => item !== mdxAdmonitionTitle)}</>;
|
|
24
|
+
return {
|
|
25
|
+
mdxAdmonitionTitle: mdxAdmonitionTitle?.props.children,
|
|
26
|
+
rest,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function processAdmonitionProps<
|
|
31
|
+
Props extends {readonly children: ReactNode; readonly title?: ReactNode},
|
|
32
|
+
>(props: Props): Props {
|
|
33
|
+
const {mdxAdmonitionTitle, rest} = extractMDXAdmonitionTitle(props.children);
|
|
34
|
+
const title = props.title ?? mdxAdmonitionTitle;
|
|
35
|
+
return {
|
|
36
|
+
...props,
|
|
37
|
+
// Do not return "title: undefined" prop
|
|
38
|
+
// this might create unwanted props overrides when merging props
|
|
39
|
+
// For example: {...default,...props}
|
|
40
|
+
...(title && {title}),
|
|
41
|
+
children: rest,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React, {useCallback, useRef, type ComponentProps} from 'react';
|
|
9
|
+
import {useHistory} from '@docusaurus/router';
|
|
10
|
+
import {translate} from '@docusaurus/Translate';
|
|
11
|
+
import {useLocationChange} from './useLocationChange';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The id of the element that should become focused on a page
|
|
15
|
+
* that does not have a <main> html tag.
|
|
16
|
+
* Focusing the Docusaurus Layout children is a reasonable fallback.
|
|
17
|
+
*/
|
|
18
|
+
export const SkipToContentFallbackId = 'docusaurus_skipToContent_fallback';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns the skip to content element to focus when the link is clicked.
|
|
22
|
+
*/
|
|
23
|
+
function getSkipToContentTarget(): HTMLElement | null {
|
|
24
|
+
return (
|
|
25
|
+
// Try to focus the <main> in priority
|
|
26
|
+
// Note: this will only work if JS is enabled
|
|
27
|
+
// See https://github.com/facebook/docusaurus/issues/6411#issuecomment-1284136069
|
|
28
|
+
document.querySelector('main:first-of-type') ??
|
|
29
|
+
// Then try to focus the fallback element (usually the Layout children)
|
|
30
|
+
document.getElementById(SkipToContentFallbackId)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function programmaticFocus(el: HTMLElement) {
|
|
35
|
+
el.setAttribute('tabindex', '-1');
|
|
36
|
+
el.focus();
|
|
37
|
+
el.removeAttribute('tabindex');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** This hook wires the logic for a skip-to-content link. */
|
|
41
|
+
function useSkipToContent(): {
|
|
42
|
+
/**
|
|
43
|
+
* The ref to the container. On page transition, the container will be focused
|
|
44
|
+
* so that keyboard navigators can instantly interact with the link and jump
|
|
45
|
+
* to content.
|
|
46
|
+
*/
|
|
47
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
48
|
+
/**
|
|
49
|
+
* Callback fired when the skip to content link has been clicked.
|
|
50
|
+
* It will programmatically focus the main content.
|
|
51
|
+
*/
|
|
52
|
+
onClick: (e: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
53
|
+
} {
|
|
54
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
55
|
+
const {action} = useHistory();
|
|
56
|
+
|
|
57
|
+
const onClick = useCallback((e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
const targetElement = getSkipToContentTarget();
|
|
60
|
+
if (targetElement) {
|
|
61
|
+
programmaticFocus(targetElement);
|
|
62
|
+
}
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
// "Reset" focus when navigating.
|
|
66
|
+
// See https://github.com/facebook/docusaurus/pull/8204#issuecomment-1276547558
|
|
67
|
+
useLocationChange(({location}) => {
|
|
68
|
+
if (containerRef.current && !location.hash && action === 'PUSH') {
|
|
69
|
+
programmaticFocus(containerRef.current);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return {containerRef, onClick};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const DefaultSkipToContentLabel = translate({
|
|
77
|
+
id: 'theme.common.skipToMainContent',
|
|
78
|
+
description:
|
|
79
|
+
'The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation',
|
|
80
|
+
message: 'Skip to main content',
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
type SkipToContentLinkProps = Omit<ComponentProps<'a'>, 'href' | 'onClick'>;
|
|
84
|
+
|
|
85
|
+
export function SkipToContentLink(props: SkipToContentLinkProps): JSX.Element {
|
|
86
|
+
const linkLabel = props.children ?? DefaultSkipToContentLabel;
|
|
87
|
+
const {containerRef, onClick} = useSkipToContent();
|
|
88
|
+
return (
|
|
89
|
+
<div
|
|
90
|
+
ref={containerRef}
|
|
91
|
+
role="region"
|
|
92
|
+
aria-label={DefaultSkipToContentLabel}>
|
|
93
|
+
<a
|
|
94
|
+
{...props}
|
|
95
|
+
// Note this is a fallback href in case JS is disabled
|
|
96
|
+
// It has limitations, see https://github.com/facebook/docusaurus/issues/6411#issuecomment-1284136069
|
|
97
|
+
href={`#${SkipToContentFallbackId}`}
|
|
98
|
+
onClick={onClick}>
|
|
99
|
+
{linkLabel}
|
|
100
|
+
</a>
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
import type React from 'react';
|
|
8
|
-
/** This hook wires the logic for a skip-to-content link. */
|
|
9
|
-
export declare function useSkipToContent(): {
|
|
10
|
-
/**
|
|
11
|
-
* The ref to the container. On page transition, the container will be focused
|
|
12
|
-
* so that keyboard navigators can instantly interact with the link and jump
|
|
13
|
-
* to content. **Note:** the type is `RefObject<HTMLDivElement>` only because
|
|
14
|
-
* the typing for refs don't reflect that the `ref` prop is contravariant, so
|
|
15
|
-
* using `HTMLElement` causes type-checking to fail. You can plug the ref into
|
|
16
|
-
* any HTML element, as long as it can be focused.
|
|
17
|
-
*/
|
|
18
|
-
containerRef: React.RefObject<HTMLDivElement>;
|
|
19
|
-
/**
|
|
20
|
-
* Callback fired when the skip to content link has been interacted with. It
|
|
21
|
-
* will programmatically focus the main content.
|
|
22
|
-
*/
|
|
23
|
-
handleSkip: (e: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=useSkipToContent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSkipToContent.d.ts","sourceRoot":"","sources":["../../src/hooks/useSkipToContent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,4DAA4D;AAC5D,wBAAgB,gBAAgB,IAAI;IAClC;;;;;;;OAOG;IACH,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC9C;;;OAGG;IACH,UAAU,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CAC9D,CAsBA"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
import { useCallback, useRef } from 'react';
|
|
8
|
-
import { useHistory } from '@docusaurus/router';
|
|
9
|
-
import { useLocationChange } from '../utils/useLocationChange';
|
|
10
|
-
import { ThemeClassNames } from '../utils/ThemeClassNames';
|
|
11
|
-
function programmaticFocus(el) {
|
|
12
|
-
el.setAttribute('tabindex', '-1');
|
|
13
|
-
el.focus();
|
|
14
|
-
el.removeAttribute('tabindex');
|
|
15
|
-
}
|
|
16
|
-
/** This hook wires the logic for a skip-to-content link. */
|
|
17
|
-
export function useSkipToContent() {
|
|
18
|
-
const containerRef = useRef(null);
|
|
19
|
-
const { action } = useHistory();
|
|
20
|
-
const handleSkip = useCallback((e) => {
|
|
21
|
-
e.preventDefault();
|
|
22
|
-
const targetElement = document.querySelector('main:first-of-type') ??
|
|
23
|
-
document.querySelector(`.${ThemeClassNames.wrapper.main}`);
|
|
24
|
-
if (targetElement) {
|
|
25
|
-
programmaticFocus(targetElement);
|
|
26
|
-
}
|
|
27
|
-
}, []);
|
|
28
|
-
useLocationChange(({ location }) => {
|
|
29
|
-
if (containerRef.current && !location.hash && action === 'PUSH') {
|
|
30
|
-
programmaticFocus(containerRef.current);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return { containerRef, handleSkip };
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=useSkipToContent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSkipToContent.js","sourceRoot":"","sources":["../../src/hooks/useSkipToContent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,WAAW,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAEzD,SAAS,iBAAiB,CAAC,EAAe;IACxC,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAClC,EAAE,CAAC,KAAK,EAAE,CAAC;IACX,EAAE,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;AACjC,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,gBAAgB;IAgB9B,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAClD,MAAM,EAAC,MAAM,EAAC,GAAG,UAAU,EAAE,CAAC;IAC9B,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,CAAsC,EAAE,EAAE;QACxE,CAAC,CAAC,cAAc,EAAE,CAAC;QAEnB,MAAM,aAAa,GACjB,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAC;YAC5C,QAAQ,CAAC,aAAa,CAAC,IAAI,eAAe,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAE7D,IAAI,aAAa,EAAE;YACjB,iBAAiB,CAAC,aAAa,CAAC,CAAC;SAClC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,iBAAiB,CAAC,CAAC,EAAC,QAAQ,EAAC,EAAE,EAAE;QAC/B,IAAI,YAAY,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,MAAM,KAAK,MAAM,EAAE;YAC/D,iBAAiB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;SACzC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,CAAC;AACpC,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type React from 'react';
|
|
9
|
-
import {useCallback, useRef} from 'react';
|
|
10
|
-
import {useHistory} from '@docusaurus/router';
|
|
11
|
-
import {useLocationChange} from '../utils/useLocationChange';
|
|
12
|
-
import {ThemeClassNames} from '../utils/ThemeClassNames';
|
|
13
|
-
|
|
14
|
-
function programmaticFocus(el: HTMLElement) {
|
|
15
|
-
el.setAttribute('tabindex', '-1');
|
|
16
|
-
el.focus();
|
|
17
|
-
el.removeAttribute('tabindex');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** This hook wires the logic for a skip-to-content link. */
|
|
21
|
-
export function useSkipToContent(): {
|
|
22
|
-
/**
|
|
23
|
-
* The ref to the container. On page transition, the container will be focused
|
|
24
|
-
* so that keyboard navigators can instantly interact with the link and jump
|
|
25
|
-
* to content. **Note:** the type is `RefObject<HTMLDivElement>` only because
|
|
26
|
-
* the typing for refs don't reflect that the `ref` prop is contravariant, so
|
|
27
|
-
* using `HTMLElement` causes type-checking to fail. You can plug the ref into
|
|
28
|
-
* any HTML element, as long as it can be focused.
|
|
29
|
-
*/
|
|
30
|
-
containerRef: React.RefObject<HTMLDivElement>;
|
|
31
|
-
/**
|
|
32
|
-
* Callback fired when the skip to content link has been interacted with. It
|
|
33
|
-
* will programmatically focus the main content.
|
|
34
|
-
*/
|
|
35
|
-
handleSkip: (e: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
36
|
-
} {
|
|
37
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
38
|
-
const {action} = useHistory();
|
|
39
|
-
const handleSkip = useCallback((e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
40
|
-
e.preventDefault();
|
|
41
|
-
|
|
42
|
-
const targetElement: HTMLElement | null =
|
|
43
|
-
document.querySelector('main:first-of-type') ??
|
|
44
|
-
document.querySelector(`.${ThemeClassNames.wrapper.main}`);
|
|
45
|
-
|
|
46
|
-
if (targetElement) {
|
|
47
|
-
programmaticFocus(targetElement);
|
|
48
|
-
}
|
|
49
|
-
}, []);
|
|
50
|
-
|
|
51
|
-
useLocationChange(({location}) => {
|
|
52
|
-
if (containerRef.current && !location.hash && action === 'PUSH') {
|
|
53
|
-
programmaticFocus(containerRef.current);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
return {containerRef, handleSkip};
|
|
58
|
-
}
|