@brillout/docpress 0.4.13 → 0.4.14
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.
|
@@ -36,29 +36,39 @@ iframe {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/* src/css/heading.css */
|
|
39
|
+
.doc-page h2,
|
|
40
|
+
.doc-page h3 {
|
|
41
|
+
margin-bottom: 16px;
|
|
42
|
+
}
|
|
39
43
|
.doc-page h2 {
|
|
40
44
|
margin-top: 50px;
|
|
45
|
+
}
|
|
46
|
+
.doc-page h3 {
|
|
47
|
+
margin-top: 40px;
|
|
48
|
+
}
|
|
49
|
+
.doc-page h1 + h2,
|
|
50
|
+
.doc-page h1 + h3,
|
|
51
|
+
.doc-page h2 + h3 {
|
|
52
|
+
margin-top: 0;
|
|
53
|
+
}
|
|
54
|
+
.doc-page h4 {
|
|
55
|
+
margin-top: 32px;
|
|
41
56
|
margin-bottom: 16px;
|
|
42
57
|
}
|
|
43
|
-
.doc-page h2[id]
|
|
58
|
+
.doc-page h2[id],
|
|
59
|
+
.doc-page h3[id] {
|
|
44
60
|
cursor: pointer;
|
|
45
61
|
position: relative;
|
|
46
|
-
padding-left:
|
|
47
|
-
margin-left: -
|
|
62
|
+
padding-left: 26px;
|
|
63
|
+
margin-left: -26px;
|
|
48
64
|
}
|
|
49
|
-
.doc-page h2[id]:hover::before
|
|
65
|
+
.doc-page h2[id]:hover::before,
|
|
66
|
+
.doc-page h3[id]:hover::before {
|
|
50
67
|
content: "#";
|
|
51
68
|
position: absolute;
|
|
52
|
-
left: calc(-1 * (0.75em -
|
|
69
|
+
left: calc(-1 * (0.75em - 23px));
|
|
53
70
|
color: #aaa;
|
|
54
71
|
}
|
|
55
|
-
.doc-page h1 + h2 {
|
|
56
|
-
margin-top: 0;
|
|
57
|
-
}
|
|
58
|
-
.doc-page h4 {
|
|
59
|
-
margin-top: 32px;
|
|
60
|
-
margin-bottom: 16px;
|
|
61
|
-
}
|
|
62
72
|
|
|
63
73
|
/* src/css/button.css */
|
|
64
74
|
button,
|
|
@@ -29,29 +29,31 @@ function installSectionUrlHashs() {
|
|
|
29
29
|
assert(window.location.pathname === "/");
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
window.location.hash = urlHash;
|
|
43
|
-
jumpToSection();
|
|
44
|
-
};
|
|
45
|
-
});
|
|
32
|
+
const headings = [...Array.from(document.querySelectorAll("h2")), ...Array.from(document.querySelectorAll("h3"))];
|
|
33
|
+
headings.forEach((heading) => {
|
|
34
|
+
if (!heading.id)
|
|
35
|
+
return;
|
|
36
|
+
const urlHash = "#" + heading.id;
|
|
37
|
+
assertNavLink(urlHash, heading);
|
|
38
|
+
heading.onclick = () => {
|
|
39
|
+
window.location.hash = urlHash;
|
|
40
|
+
jumpToSection();
|
|
41
|
+
};
|
|
46
42
|
});
|
|
47
43
|
}
|
|
48
|
-
function assertNavLink(
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
function assertNavLink(urlHash, heading) {
|
|
45
|
+
const navigationEl = getNavigationEl();
|
|
46
|
+
{
|
|
47
|
+
const parentNavLinkMatch = Array.from(navigationEl.querySelectorAll(`a[href="${window.location.pathname}"]`));
|
|
48
|
+
assert(parentNavLinkMatch.length === 1);
|
|
49
|
+
}
|
|
50
|
+
{
|
|
51
|
+
const navLinks = Array.from(navigationEl.querySelectorAll(`a[href="${urlHash}"]`));
|
|
52
|
+
const { tagName } = heading;
|
|
53
|
+
assert(tagName.startsWith("H"));
|
|
54
|
+
const lengthExpected = tagName === "H2" ? 1 : 0;
|
|
55
|
+
assert(navLinks.length === lengthExpected, { urlHash });
|
|
56
|
+
}
|
|
55
57
|
}
|
|
56
58
|
function jumpToSection() {
|
|
57
59
|
const { hash } = window.location;
|
|
@@ -65,6 +67,12 @@ function jumpToSection() {
|
|
|
65
67
|
}
|
|
66
68
|
target.scrollIntoView();
|
|
67
69
|
}
|
|
70
|
+
function getNavigationEl() {
|
|
71
|
+
const elems = Array.from(document.querySelectorAll("#navigation-container"));
|
|
72
|
+
assert(elems.length === 1);
|
|
73
|
+
const navigationEl = elems[0];
|
|
74
|
+
return navigationEl;
|
|
75
|
+
}
|
|
68
76
|
|
|
69
77
|
// src/navigation/navigation-fullscreen/initNavigationFullscreen.ts
|
|
70
78
|
var scrollPositionBeforeToggle = 0;
|