@brillout/docpress 0.10.22 → 0.10.24
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/EditLink.tsx +31 -0
- package/{NavSecondaryContent.tsx → ExternalLinks.tsx} +2 -2
- package/Layout.tsx +5 -41
- package/MenuModal.tsx +20 -19
- package/components/Link.tsx +2 -0
- package/dist/components/Link.js +3 -0
- package/installSectionUrlHashs.ts +1 -1
- package/package.json +1 -1
package/EditLink.tsx
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export { EditLink }
|
|
2
|
+
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { usePageContext } from './renderer/usePageContext'
|
|
5
|
+
import { iconPencil } from './icons'
|
|
6
|
+
import { getRepoHref } from './components'
|
|
7
|
+
|
|
8
|
+
function EditLink({ className, style }: { className?: string; style: React.CSSProperties }) {
|
|
9
|
+
const pageContext = usePageContext()
|
|
10
|
+
const iconSize = 17
|
|
11
|
+
const icon = (
|
|
12
|
+
<img
|
|
13
|
+
src={iconPencil}
|
|
14
|
+
width={iconSize}
|
|
15
|
+
height={iconSize}
|
|
16
|
+
style={{
|
|
17
|
+
marginRight: 9,
|
|
18
|
+
position: 'relative',
|
|
19
|
+
top: -1,
|
|
20
|
+
}}
|
|
21
|
+
/>
|
|
22
|
+
)
|
|
23
|
+
const { urlPathname } = pageContext
|
|
24
|
+
const fsPath = urlPathname === '/' ? '/index/+Page.tsx' : `${urlPathname}/+Page.mdx`
|
|
25
|
+
const editLink = getRepoHref(`/docs/pages${fsPath}`, true)
|
|
26
|
+
return (
|
|
27
|
+
<a href={editLink} className={className} style={{ display: 'flex', alignItems: 'center', ...style }}>
|
|
28
|
+
{icon} Edit this page
|
|
29
|
+
</a>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ExternalLinks }
|
|
2
2
|
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import iconGithub from './icons/github.svg'
|
|
@@ -10,7 +10,7 @@ import iconLanguages from './icons/languages.svg'
|
|
|
10
10
|
import { usePageContext } from './renderer/usePageContext'
|
|
11
11
|
import '@docsearch/css'
|
|
12
12
|
|
|
13
|
-
function
|
|
13
|
+
function ExternalLinks(props: { style?: React.CSSProperties }) {
|
|
14
14
|
const pageContext = usePageContext()
|
|
15
15
|
const { projectInfo, i18n } = pageContext.config
|
|
16
16
|
const iconI18n = !i18n ? null : (
|
package/Layout.tsx
CHANGED
|
@@ -11,7 +11,7 @@ import React from 'react'
|
|
|
11
11
|
import { getNavItemsWithComputed, NavItem, NavItemComponent } from './NavItemComponent'
|
|
12
12
|
import { parseMarkdownMini } from './parseMarkdownMini'
|
|
13
13
|
import { usePageContext, usePageContext2 } from './renderer/usePageContext'
|
|
14
|
-
import {
|
|
14
|
+
import { ExternalLinks } from './ExternalLinks'
|
|
15
15
|
import { coseMenuModalOnMouseLeave, openMenuModal, toggleMenuModal } from './MenuModal/toggleMenuModal'
|
|
16
16
|
import { MenuModal } from './MenuModal'
|
|
17
17
|
import { autoScrollNav_SSR } from './autoScrollNav'
|
|
@@ -21,8 +21,8 @@ import { css } from './utils/css'
|
|
|
21
21
|
import { PassThrough } from './utils/PassTrough'
|
|
22
22
|
import { Style } from './utils/Style'
|
|
23
23
|
import { cls } from './utils/cls'
|
|
24
|
-
import { iconBooks
|
|
25
|
-
import {
|
|
24
|
+
import { iconBooks } from './icons'
|
|
25
|
+
import { EditLink } from './EditLink'
|
|
26
26
|
|
|
27
27
|
const blockMargin = 3
|
|
28
28
|
const mainViewPadding = 20
|
|
@@ -185,7 +185,7 @@ function PageContent({ children }: { children: React.ReactNode }) {
|
|
|
185
185
|
{globalNote}
|
|
186
186
|
{pageTitleParsed && (
|
|
187
187
|
<div>
|
|
188
|
-
<
|
|
188
|
+
<EditLink className="show-only-on-desktop" style={{ float: 'right', marginTop: 6, padding: 10 }} />
|
|
189
189
|
<h1 id={`${pageContext.urlPathname.replace('/', '')}`}>{pageTitleParsed}</h1>
|
|
190
190
|
</div>
|
|
191
191
|
)}
|
|
@@ -302,7 +302,7 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
|
302
302
|
>
|
|
303
303
|
<TopNavigation />
|
|
304
304
|
{!isNavLeft && <div className="desktop-grow" />}
|
|
305
|
-
<
|
|
305
|
+
<ExternalLinks
|
|
306
306
|
style={{
|
|
307
307
|
display: 'inline-flex',
|
|
308
308
|
fontSize: '1.06em',
|
|
@@ -640,39 +640,3 @@ function MenuIcon() {
|
|
|
640
640
|
</svg>
|
|
641
641
|
)
|
|
642
642
|
}
|
|
643
|
-
|
|
644
|
-
function EditPageNote() {
|
|
645
|
-
const pageContext = usePageContext()
|
|
646
|
-
const iconSize = 17
|
|
647
|
-
const icon = (
|
|
648
|
-
<img
|
|
649
|
-
src={iconPencil}
|
|
650
|
-
width={iconSize}
|
|
651
|
-
height={iconSize}
|
|
652
|
-
style={{
|
|
653
|
-
marginRight: 9,
|
|
654
|
-
position: 'relative',
|
|
655
|
-
top: -1,
|
|
656
|
-
}}
|
|
657
|
-
/>
|
|
658
|
-
)
|
|
659
|
-
const editLink = getRepoHref('/docs/pages' + pageContext.urlPathname + '/+Page.mdx', true)
|
|
660
|
-
return (
|
|
661
|
-
<a
|
|
662
|
-
href={editLink}
|
|
663
|
-
id="edit-link"
|
|
664
|
-
style={{ float: 'right', marginTop: 6, padding: 10, display: 'flex', alignItems: 'center' }}
|
|
665
|
-
>
|
|
666
|
-
{icon} Edit this page
|
|
667
|
-
<Style>{getStyle()}</Style>
|
|
668
|
-
</a>
|
|
669
|
-
)
|
|
670
|
-
function getStyle() {
|
|
671
|
-
return css`
|
|
672
|
-
@container container-viewport (max-width: 800px) {
|
|
673
|
-
#edit-link {
|
|
674
|
-
display: none !important;
|
|
675
|
-
}
|
|
676
|
-
}`
|
|
677
|
-
}
|
|
678
|
-
}
|
package/MenuModal.tsx
CHANGED
|
@@ -4,10 +4,11 @@ import React from 'react'
|
|
|
4
4
|
import { usePageContext } from './renderer/usePageContext'
|
|
5
5
|
import { css } from './utils/css'
|
|
6
6
|
import { containerQueryMobileLayout, containerQueryMobileMenu } from './Layout'
|
|
7
|
-
import {
|
|
7
|
+
import { ExternalLinks } from './ExternalLinks'
|
|
8
8
|
import { Style } from './utils/Style'
|
|
9
9
|
import { NavigationWithColumnLayout } from './MenuModal/NavigationWithColumnLayout'
|
|
10
10
|
import { closeMenuModal, keepMenuModalOpen } from './MenuModal/toggleMenuModal'
|
|
11
|
+
import { EditLink } from './EditLink'
|
|
11
12
|
|
|
12
13
|
function MenuModal({ isTopNav }: { isTopNav: boolean }) {
|
|
13
14
|
return (
|
|
@@ -39,9 +40,20 @@ function MenuModal({ isTopNav }: { isTopNav: boolean }) {
|
|
|
39
40
|
}}
|
|
40
41
|
>
|
|
41
42
|
<Nav />
|
|
42
|
-
<
|
|
43
|
+
<div className="show-only-on-mobile">
|
|
44
|
+
<div
|
|
45
|
+
style={{
|
|
46
|
+
display: 'flex',
|
|
47
|
+
justifyContent: 'center',
|
|
48
|
+
marginTop: 10,
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
<ExternalLinks style={{ height: 50 }} />
|
|
52
|
+
</div>
|
|
53
|
+
<EditLink style={{ justifyContent: 'center', padding: 10, marginTop: 0, marginBottom: 13 }} />
|
|
54
|
+
</div>
|
|
43
55
|
</div>
|
|
44
|
-
<CloseButton className="show-only-
|
|
56
|
+
<CloseButton className="show-only-on-mobile" />
|
|
45
57
|
<BorderBottom />
|
|
46
58
|
</div>
|
|
47
59
|
</>
|
|
@@ -64,20 +76,6 @@ function Nav() {
|
|
|
64
76
|
const navItems = pageContext.navItemsAll
|
|
65
77
|
return <NavigationWithColumnLayout navItems={navItems} />
|
|
66
78
|
}
|
|
67
|
-
function NavSecondary({ className }: { className: string }) {
|
|
68
|
-
return (
|
|
69
|
-
<div
|
|
70
|
-
className={className}
|
|
71
|
-
style={{
|
|
72
|
-
display: 'flex',
|
|
73
|
-
justifyContent: 'center',
|
|
74
|
-
marginTop: 10,
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
77
|
-
<NavSecondaryContent style={{ height: 70 }} />
|
|
78
|
-
</div>
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
79
|
|
|
82
80
|
function getStyle() {
|
|
83
81
|
return css`
|
|
@@ -97,7 +95,7 @@ function getStyle() {
|
|
|
97
95
|
pointer-events: none;
|
|
98
96
|
}
|
|
99
97
|
}
|
|
100
|
-
.show-only-
|
|
98
|
+
.show-only-on-mobile {
|
|
101
99
|
display: none !important;
|
|
102
100
|
}
|
|
103
101
|
}
|
|
@@ -109,7 +107,7 @@ function getStyle() {
|
|
|
109
107
|
${/* We use dvh because of mobile */ ''}
|
|
110
108
|
${/* https://stackoverflow.com/questions/37112218/css3-100vh-not-constant-in-mobile-browser/72245072#72245072 */ ''}
|
|
111
109
|
height: calc(100dvh) !important;
|
|
112
|
-
${/* Place <
|
|
110
|
+
${/* Place <ExternalLinks> and <EditLink> to the bottom */ ''}
|
|
113
111
|
display: flex;
|
|
114
112
|
flex-direction: column;
|
|
115
113
|
justify-content: space-between;
|
|
@@ -131,6 +129,9 @@ function getStyle() {
|
|
|
131
129
|
#menu-navigation-container {
|
|
132
130
|
height: auto !important;
|
|
133
131
|
}
|
|
132
|
+
.show-only-on-desktop {
|
|
133
|
+
display: none !important;
|
|
134
|
+
}
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
${/* Hide same-page headings navigation */ ''}
|
package/components/Link.tsx
CHANGED
|
@@ -167,5 +167,7 @@ function parseHref(href: string) {
|
|
|
167
167
|
}
|
|
168
168
|
assert(hrefPathname !== null || hrefHash !== null)
|
|
169
169
|
assert(hrefPathname || hrefHash)
|
|
170
|
+
// Text highlight links e,g. #metadata:~:text=global%20or%20local.-,Global%20metadata,-.
|
|
171
|
+
if (hrefHash) hrefHash = hrefHash.split(':~:text')[0]!
|
|
170
172
|
return { hrefPathname, hrefHash }
|
|
171
173
|
}
|
package/dist/components/Link.js
CHANGED
|
@@ -132,5 +132,8 @@ function parseHref(href) {
|
|
|
132
132
|
}
|
|
133
133
|
assert(hrefPathname !== null || hrefHash !== null);
|
|
134
134
|
assert(hrefPathname || hrefHash);
|
|
135
|
+
// Text highlight links e,g. #metadata:~:text=global%20or%20local.-,Global%20metadata,-.
|
|
136
|
+
if (hrefHash)
|
|
137
|
+
hrefHash = hrefHash.split(':~:text')[0];
|
|
135
138
|
return { hrefPathname: hrefPathname, hrefHash: hrefHash };
|
|
136
139
|
}
|
|
@@ -31,7 +31,7 @@ function assertNavLink(urlHash: string, heading: HTMLHeadingElement) {
|
|
|
31
31
|
{
|
|
32
32
|
const { pathname } = window.location
|
|
33
33
|
const parentNavLinkMatch = Array.from(navigationEl.querySelectorAll(`a[href="${pathname}"]`))
|
|
34
|
-
assert(parentNavLinkMatch.length === 1)
|
|
34
|
+
assert(parentNavLinkMatch.length === 1, { parentNavLinkMatch, pathname })
|
|
35
35
|
}
|
|
36
36
|
{
|
|
37
37
|
const navLinks: HTMLElement[] = Array.from(navigationEl.querySelectorAll(`a[href="${urlHash}"]`))
|