@brillout/docpress 0.15.10 → 0.15.11-commit-e615832
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/Layout.tsx +3 -0
- package/autoScrollNav.ts +3 -3
- package/code-blocks/components/CodeSnippets.css +74 -0
- package/code-blocks/components/CodeSnippets.tsx +51 -0
- package/code-blocks/components/Pre.css +51 -0
- package/code-blocks/components/Pre.tsx +70 -0
- package/code-blocks/hooks/useMDXComponents.tsx +13 -0
- package/code-blocks/hooks/useSelectCodeLang.ts +74 -0
- package/code-blocks/rehypeMetaToProps.ts +69 -0
- package/code-blocks/remarkDetype.ts +192 -0
- package/code-blocks/shikiTransformerAutoLinks.ts +61 -0
- package/css/button.css +23 -0
- package/css/code.css +3 -21
- package/css/tooltip.css +10 -2
- package/dist/+config.js +1 -1
- package/dist/NavItemComponent.js +38 -46
- package/dist/code-blocks/rehypeMetaToProps.d.ts +35 -0
- package/dist/code-blocks/rehypeMetaToProps.js +62 -0
- package/dist/code-blocks/remarkDetype.d.ts +4 -0
- package/dist/code-blocks/remarkDetype.js +164 -0
- package/dist/code-blocks/shikiTransformerAutoLinks.d.ts +8 -0
- package/dist/code-blocks/shikiTransformerAutoLinks.js +51 -0
- package/dist/components/CodeBlockTransformer.js +2 -3
- package/dist/components/Comment.js +1 -2
- package/dist/components/FileRemoved.js +4 -6
- package/dist/components/HorizontalLine.js +1 -2
- package/dist/components/ImportMeta.js +2 -3
- package/dist/components/Link.js +34 -50
- package/dist/components/Note.js +17 -29
- package/dist/components/P.js +1 -12
- package/dist/components/RepoLink.js +7 -9
- package/dist/determineNavItemsColumnLayout.js +48 -63
- package/dist/parseMarkdownMini.js +5 -17
- package/dist/parsePageSections.js +41 -82
- package/dist/renderer/usePageContext.js +6 -7
- package/dist/resolvePageContext.js +103 -110
- package/dist/utils/Emoji/Emoji.js +13 -21
- package/dist/utils/assert.js +14 -16
- package/dist/utils/cls.js +1 -1
- package/dist/utils/determineSectionUrlHash.js +5 -5
- package/dist/utils/filter.js +2 -2
- package/dist/utils/getGlobalObject.js +3 -3
- package/dist/vite.config.js +17 -7
- package/index.ts +16 -14
- package/package.json +7 -2
- package/resolvePageContext.ts +19 -15
- package/tsconfig.json +2 -1
- package/vite.config.ts +14 -4
package/dist/components/Link.js
CHANGED
|
@@ -1,31 +1,22 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
export { Link };
|
|
13
2
|
import React from 'react';
|
|
14
3
|
import { usePageContext } from '../renderer/usePageContext';
|
|
15
4
|
import { assert, assertUsage, assertWarning, determineSectionTitle, determineSectionUrlHash } from '../utils/server';
|
|
16
5
|
import { parseMarkdownMini } from '../parseMarkdownMini';
|
|
17
6
|
import pc from '@brillout/picocolors';
|
|
18
|
-
function Link(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
assertUsage(href.startsWith('/') || href.startsWith('#'), "<Link href /> prop `href==='".concat(href, "'` but should start with '/' or '#'"));
|
|
7
|
+
function Link({ href, text, noBreadcrumb, doNotInferSectionTitle, noWarning, children, }) {
|
|
8
|
+
const pageContext = usePageContext();
|
|
9
|
+
assertUsage(href.startsWith('/') || href.startsWith('#'), `<Link href /> prop \`href==='${href}'\` but should start with '/' or '#'`);
|
|
22
10
|
assertUsage(!text || !children, 'Cannot use both `text` or `children`');
|
|
23
11
|
// assertWarning(!text, 'prop `text` is deprecated')
|
|
24
|
-
text = text
|
|
25
|
-
|
|
12
|
+
text = text ?? children;
|
|
13
|
+
const linkTextData = getLinkTextData({ href, pageContext, doNotInferSectionTitle, noWarning });
|
|
26
14
|
if (!text) {
|
|
27
15
|
if (linkTextData) {
|
|
28
|
-
text = getLinkText(
|
|
16
|
+
text = getLinkText({
|
|
17
|
+
noBreadcrumb,
|
|
18
|
+
...linkTextData,
|
|
19
|
+
});
|
|
29
20
|
}
|
|
30
21
|
else {
|
|
31
22
|
text = 'LINK-TARGET-NOT-FOUND';
|
|
@@ -33,12 +24,10 @@ function Link(_a) {
|
|
|
33
24
|
}
|
|
34
25
|
return React.createElement("a", { href: href }, text);
|
|
35
26
|
}
|
|
36
|
-
function getLinkText(
|
|
37
|
-
|
|
38
|
-
var noBreadcrumb = _a.noBreadcrumb, linkData = _a.linkData, sectionTitle = _a.sectionTitle, isLinkOnSamePage = _a.isLinkOnSamePage;
|
|
39
|
-
var breadcrumbParts = [];
|
|
27
|
+
function getLinkText({ noBreadcrumb, linkData, sectionTitle, isLinkOnSamePage, }) {
|
|
28
|
+
const breadcrumbParts = [];
|
|
40
29
|
if (linkData.linkBreadcrumb) {
|
|
41
|
-
breadcrumbParts.push
|
|
30
|
+
breadcrumbParts.push(...(linkData.linkBreadcrumb ?? []).slice().reverse().map(parseMarkdownMini));
|
|
42
31
|
}
|
|
43
32
|
breadcrumbParts.push(parseMarkdownMini(linkData.title));
|
|
44
33
|
if (sectionTitle)
|
|
@@ -46,33 +35,32 @@ function getLinkText(_a) {
|
|
|
46
35
|
if (noBreadcrumb || isLinkOnSamePage) {
|
|
47
36
|
return breadcrumbParts[breadcrumbParts.length - 1];
|
|
48
37
|
}
|
|
49
|
-
return (React.createElement(React.Fragment, null, breadcrumbParts.map(
|
|
50
|
-
|
|
38
|
+
return (React.createElement(React.Fragment, null, breadcrumbParts.map((title, i) => {
|
|
39
|
+
const seperator = i === 0 ? React.createElement(React.Fragment, null) : ' > ';
|
|
51
40
|
return (React.createElement(React.Fragment, { key: i },
|
|
52
41
|
seperator,
|
|
53
42
|
title));
|
|
54
43
|
})));
|
|
55
44
|
}
|
|
56
|
-
function getLinkTextData(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var linkData = findLinkData(hrefPathname || pageContext.urlPathname, { pageContext: pageContext, noWarning: noWarning });
|
|
45
|
+
function getLinkTextData({ href, pageContext, doNotInferSectionTitle, noWarning, }) {
|
|
46
|
+
const { hrefPathname, hrefHash } = parseHref(href);
|
|
47
|
+
const linkData = findLinkData(hrefPathname || pageContext.urlPathname, { pageContext, noWarning });
|
|
60
48
|
if (!linkData)
|
|
61
49
|
return null;
|
|
62
|
-
|
|
50
|
+
const isLinkOnSamePage = linkData.url === pageContext.urlPathname;
|
|
63
51
|
if (!hrefPathname)
|
|
64
52
|
assert(isLinkOnSamePage);
|
|
65
|
-
|
|
53
|
+
let sectionTitle = null;
|
|
66
54
|
if (hrefHash) {
|
|
67
55
|
assert(!hrefHash.startsWith('#'));
|
|
68
56
|
if (isLinkOnSamePage) {
|
|
69
|
-
|
|
57
|
+
const linkDataPageSection = findLinkData(`#${hrefHash}`, { pageContext, noWarning });
|
|
70
58
|
if (!linkDataPageSection)
|
|
71
59
|
return null;
|
|
72
60
|
sectionTitle = parseMarkdownMini(linkDataPageSection.title);
|
|
73
61
|
}
|
|
74
62
|
else if ('sectionTitles' in linkData && linkData.sectionTitles) {
|
|
75
|
-
linkData.sectionTitles.forEach(
|
|
63
|
+
linkData.sectionTitles.forEach((title) => {
|
|
76
64
|
if (determineSectionUrlHash(title) === hrefHash) {
|
|
77
65
|
sectionTitle = parseMarkdownMini(title);
|
|
78
66
|
}
|
|
@@ -80,32 +68,28 @@ function getLinkTextData(_a) {
|
|
|
80
68
|
}
|
|
81
69
|
if (!sectionTitle) {
|
|
82
70
|
if (doNotInferSectionTitle) {
|
|
83
|
-
assertWarning(false,
|
|
71
|
+
assertWarning(false, `Page section title not found for <Link href="\`${href}\`" doNotInferSectionTitle={true} />.`);
|
|
84
72
|
return null;
|
|
85
73
|
}
|
|
86
74
|
sectionTitle = React.createElement(React.Fragment, null, determineSectionTitle(href));
|
|
87
75
|
}
|
|
88
76
|
}
|
|
89
|
-
return { linkData
|
|
77
|
+
return { linkData, sectionTitle, isLinkOnSamePage };
|
|
90
78
|
}
|
|
91
|
-
function findLinkData(href,
|
|
92
|
-
var pageContext = _a.pageContext, noWarning = _a.noWarning;
|
|
79
|
+
function findLinkData(href, { pageContext, noWarning }) {
|
|
93
80
|
assert(href.startsWith('/') || href.startsWith('#'));
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
var url = _a.url;
|
|
97
|
-
return href === url;
|
|
98
|
-
});
|
|
81
|
+
const { linksAll } = pageContext.resolved;
|
|
82
|
+
const linkData = linksAll.find(({ url }) => href === url);
|
|
99
83
|
if (href.startsWith('#')) {
|
|
100
84
|
if (!noWarning) {
|
|
101
|
-
assertWarning(linkData,
|
|
85
|
+
assertWarning(linkData, `Couldn't find ${href} in ${pageContext.urlPathname}, does it exist?`);
|
|
102
86
|
}
|
|
103
87
|
}
|
|
104
88
|
else {
|
|
105
89
|
if (!noWarning) {
|
|
106
90
|
assertWarning(linkData, [
|
|
107
|
-
|
|
108
|
-
|
|
91
|
+
`Couldn't find page with URL ${pc.bold(href)}`,
|
|
92
|
+
`— did you define it in`,
|
|
109
93
|
[
|
|
110
94
|
pc.cyan('docpress.config.js'),
|
|
111
95
|
pc.dim('#{'),
|
|
@@ -118,16 +102,16 @@ function findLinkData(href, _a) {
|
|
|
118
102
|
].join(' '));
|
|
119
103
|
}
|
|
120
104
|
}
|
|
121
|
-
return linkData
|
|
105
|
+
return linkData ?? null;
|
|
122
106
|
}
|
|
123
107
|
function parseHref(href) {
|
|
124
|
-
|
|
125
|
-
|
|
108
|
+
let hrefHash = null;
|
|
109
|
+
let hrefPathname = null;
|
|
126
110
|
if (!href.includes('#')) {
|
|
127
111
|
hrefPathname = href;
|
|
128
112
|
}
|
|
129
113
|
else {
|
|
130
|
-
|
|
114
|
+
const [partsFirst, ...partsRest] = href.split('#');
|
|
131
115
|
if (partsFirst) {
|
|
132
116
|
hrefPathname = partsFirst;
|
|
133
117
|
}
|
|
@@ -138,5 +122,5 @@ function parseHref(href) {
|
|
|
138
122
|
// Text highlight links e,g. #metadata:~:text=global%20or%20local.-,Global%20metadata,-.
|
|
139
123
|
if (hrefHash)
|
|
140
124
|
hrefHash = hrefHash.split(':~:text')[0];
|
|
141
|
-
return { hrefPathname
|
|
125
|
+
return { hrefPathname, hrefHash };
|
|
142
126
|
}
|
package/dist/components/Note.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
export { Warning };
|
|
13
2
|
export { Advanced };
|
|
14
3
|
export { Construction };
|
|
@@ -27,39 +16,38 @@ import React from 'react';
|
|
|
27
16
|
import { assert } from '../utils/assert';
|
|
28
17
|
import './Note.css';
|
|
29
18
|
function Warning(props) {
|
|
30
|
-
return React.createElement(NoteGeneric,
|
|
19
|
+
return React.createElement(NoteGeneric, { type: "warning", ...props });
|
|
31
20
|
}
|
|
32
21
|
function Advanced(props) {
|
|
33
|
-
return React.createElement(NoteGeneric,
|
|
22
|
+
return React.createElement(NoteGeneric, { type: "advanced", ...props });
|
|
34
23
|
}
|
|
35
24
|
function Construction(props) {
|
|
36
|
-
return React.createElement(NoteGeneric,
|
|
25
|
+
return React.createElement(NoteGeneric, { type: "construction", ...props });
|
|
37
26
|
}
|
|
38
27
|
function Contribution(props) {
|
|
39
|
-
return React.createElement(NoteGeneric,
|
|
28
|
+
return React.createElement(NoteGeneric, { type: "contribution", ...props });
|
|
40
29
|
}
|
|
41
30
|
function Danger(props) {
|
|
42
|
-
return React.createElement(NoteGeneric,
|
|
31
|
+
return React.createElement(NoteGeneric, { type: "danger", ...props });
|
|
43
32
|
}
|
|
44
33
|
function NoteWithoutIcon(props) {
|
|
45
|
-
return React.createElement(NoteGeneric,
|
|
34
|
+
return React.createElement(NoteGeneric, { icon: null, ...props });
|
|
46
35
|
}
|
|
47
36
|
function NoteWithCustomIcon(props) {
|
|
48
|
-
|
|
37
|
+
const { icon } = props;
|
|
49
38
|
if (!icon)
|
|
50
|
-
throw new Error(
|
|
51
|
-
return React.createElement(NoteGeneric,
|
|
39
|
+
throw new Error(`<NoteWithCustomIcon icon={/*...*/}> property 'icon' is \`${icon}\` which is forbidden`);
|
|
40
|
+
return React.createElement(NoteGeneric, { ...props });
|
|
52
41
|
}
|
|
53
|
-
function NoteGeneric(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var className = 'custom-icon';
|
|
42
|
+
function NoteGeneric({ type, icon, iconMargin, children, style, }) {
|
|
43
|
+
assert(icon === null || icon || type, { icon, type });
|
|
44
|
+
iconMargin ??= 2;
|
|
45
|
+
let className = 'custom-icon';
|
|
58
46
|
if (type) {
|
|
59
|
-
className =
|
|
47
|
+
className = `${className} type-${type}`;
|
|
60
48
|
}
|
|
61
49
|
if (!icon && type) {
|
|
62
|
-
|
|
50
|
+
let classColor = '';
|
|
63
51
|
if (type === 'danger') {
|
|
64
52
|
icon = '⛔';
|
|
65
53
|
classColor = 'note-color-red';
|
|
@@ -82,13 +70,13 @@ function NoteGeneric(_a) {
|
|
|
82
70
|
}
|
|
83
71
|
assert(icon);
|
|
84
72
|
assert(classColor);
|
|
85
|
-
className =
|
|
73
|
+
className = `${className} ${classColor}`;
|
|
86
74
|
}
|
|
87
75
|
return (React.createElement("blockquote", { className: className, style: style },
|
|
88
76
|
React.createElement("div", { style: { marginBottom: 20 } }),
|
|
89
77
|
icon && (React.createElement(React.Fragment, null,
|
|
90
78
|
React.createElement("span", { style: { fontFamily: 'emoji' } }, icon),
|
|
91
|
-
React.createElement("span", { style: { width: iconMargin
|
|
79
|
+
React.createElement("span", { style: { width: iconMargin ?? undefined, display: 'inline-block' } }),
|
|
92
80
|
' ')),
|
|
93
81
|
React.createElement("div", { className: "blockquote-content" }, children),
|
|
94
82
|
React.createElement("div", { style: { marginTop: 20 } })));
|
package/dist/components/P.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import React from 'react';
|
|
13
2
|
import './P.css';
|
|
14
3
|
export { P };
|
|
15
4
|
function P(props) {
|
|
16
|
-
return React.createElement("div",
|
|
5
|
+
return React.createElement("div", { ...props, className: 'paragraph' });
|
|
17
6
|
}
|
|
@@ -2,21 +2,19 @@ export { RepoLink };
|
|
|
2
2
|
export { getRepoHref };
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { usePageContext } from '../renderer/usePageContext';
|
|
5
|
-
function RepoLink(
|
|
6
|
-
var path = _a.path, text = _a.text;
|
|
5
|
+
function RepoLink({ path, text }) {
|
|
7
6
|
text = text || path;
|
|
8
|
-
|
|
7
|
+
const href = getRepoHref(path);
|
|
9
8
|
return React.createElement("a", { href: href }, text);
|
|
10
9
|
}
|
|
11
|
-
function getRepoHref(path, editMode) {
|
|
12
|
-
|
|
13
|
-
var pageContext = usePageContext();
|
|
10
|
+
function getRepoHref(path, editMode = false) {
|
|
11
|
+
const pageContext = usePageContext();
|
|
14
12
|
if (!path.startsWith('/')) {
|
|
15
13
|
path = '/' + path;
|
|
16
14
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const viewMode = path.endsWith('/') && !editMode ? 'tree' : 'blob';
|
|
16
|
+
const { github } = pageContext.globalContext.config.docpress;
|
|
17
|
+
let href = `${github}/${viewMode}/main${path}`;
|
|
20
18
|
if (editMode)
|
|
21
19
|
href += '?plain=1';
|
|
22
20
|
return href;
|
|
@@ -1,47 +1,25 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
-
if (ar || !(i in from)) {
|
|
15
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
-
ar[i] = from[i];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
-
};
|
|
21
1
|
export { determineNavItemsColumnLayout };
|
|
22
2
|
import { assert, assertUsage } from './utils/assert';
|
|
23
3
|
function determineNavItemsColumnLayout(navItems) {
|
|
24
|
-
|
|
25
|
-
columnLayouts.forEach(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
columnEntries.forEach(
|
|
29
|
-
|
|
30
|
-
var _b;
|
|
31
|
-
(_a = (_b = columnEntry.navItemLeader).isColumnEntry) !== null && _a !== void 0 ? _a : (_b.isColumnEntry = {});
|
|
4
|
+
const columnLayouts = getColumnEntries(navItems);
|
|
5
|
+
columnLayouts.forEach((columnEntries) => {
|
|
6
|
+
for (let numberOfColumns = columnEntries.length; numberOfColumns >= 1; numberOfColumns--) {
|
|
7
|
+
const columnMapping = determineColumnLayout(columnEntries.map((columnEntry) => columnEntry.numberOfEntries), numberOfColumns);
|
|
8
|
+
columnEntries.forEach((columnEntry, i) => {
|
|
9
|
+
columnEntry.navItemLeader.isColumnEntry ??= {};
|
|
32
10
|
columnEntry.navItemLeader.isColumnEntry[numberOfColumns] = columnMapping[i];
|
|
33
11
|
});
|
|
34
|
-
};
|
|
35
|
-
for (var numberOfColumns = columnEntries.length; numberOfColumns >= 1; numberOfColumns--) {
|
|
36
|
-
_loop_1(numberOfColumns);
|
|
37
12
|
}
|
|
38
13
|
});
|
|
39
14
|
}
|
|
40
15
|
function getColumnEntries(navItems) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
16
|
+
const navItemsWithLength = navItems.map((navItem) => ({
|
|
17
|
+
...navItem,
|
|
18
|
+
numberOfHeadings: navItem.level === 1 || navItem.level === 4 ? 0 : null,
|
|
19
|
+
}));
|
|
20
|
+
let navItemLevel1;
|
|
21
|
+
let navItemLevel4;
|
|
22
|
+
navItemsWithLength.forEach((navItem) => {
|
|
45
23
|
if (navItem.level === 1) {
|
|
46
24
|
navItemLevel1 = navItem;
|
|
47
25
|
navItemLevel4 = undefined;
|
|
@@ -51,7 +29,7 @@ function getColumnEntries(navItems) {
|
|
|
51
29
|
navItemLevel4 = navItem;
|
|
52
30
|
return;
|
|
53
31
|
}
|
|
54
|
-
|
|
32
|
+
const bumpNavItemLength = (navItem) => {
|
|
55
33
|
assert(navItem.numberOfHeadings !== null);
|
|
56
34
|
navItem.numberOfHeadings++;
|
|
57
35
|
};
|
|
@@ -61,13 +39,13 @@ function getColumnEntries(navItems) {
|
|
|
61
39
|
bumpNavItemLength(navItemLevel4);
|
|
62
40
|
}
|
|
63
41
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
navItemsWithLength.forEach(
|
|
68
|
-
|
|
42
|
+
const columnLayouts = [];
|
|
43
|
+
let columnEntries = [];
|
|
44
|
+
let isFullWidthCategory;
|
|
45
|
+
navItemsWithLength.forEach((navItem, i) => {
|
|
46
|
+
let isFullWidthCategoryBegin = false;
|
|
69
47
|
if (navItem.level === 1) {
|
|
70
|
-
|
|
48
|
+
const isFullWidthCategoryPrevious = isFullWidthCategory;
|
|
71
49
|
isFullWidthCategory = !!navItem.menuModalFullWidth;
|
|
72
50
|
if (isFullWidthCategory)
|
|
73
51
|
isFullWidthCategoryBegin = true;
|
|
@@ -76,8 +54,8 @@ function getColumnEntries(navItems) {
|
|
|
76
54
|
columnEntries = [];
|
|
77
55
|
}
|
|
78
56
|
}
|
|
79
|
-
|
|
80
|
-
|
|
57
|
+
const navItemPrevious = navItemsWithLength[i - 1];
|
|
58
|
+
const navItemNext = navItemsWithLength[i + 1];
|
|
81
59
|
if (!isFullWidthCategory
|
|
82
60
|
? navItem.level === 1
|
|
83
61
|
: (navItem.level === 4 && navItemPrevious.level !== 1) || isFullWidthCategoryBegin) {
|
|
@@ -87,7 +65,7 @@ function getColumnEntries(navItems) {
|
|
|
87
65
|
else {
|
|
88
66
|
assert(navItem.level === 1);
|
|
89
67
|
}
|
|
90
|
-
|
|
68
|
+
let { numberOfHeadings } = navItem;
|
|
91
69
|
assert(numberOfHeadings !== null);
|
|
92
70
|
if (isFullWidthCategoryBegin) {
|
|
93
71
|
assert(navItem.level === 1);
|
|
@@ -106,15 +84,15 @@ function getColumnEntries(navItems) {
|
|
|
106
84
|
}
|
|
107
85
|
function determineColumnLayout(columnsUnmerged, numberOfColumns) {
|
|
108
86
|
assert(numberOfColumns <= columnsUnmerged.length);
|
|
109
|
-
|
|
87
|
+
const columnsMergingInit = columnsUnmerged.map((columnHeight, i) => ({
|
|
110
88
|
columnIdsMerged: [i],
|
|
111
89
|
heightTotal: columnHeight,
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
|
|
90
|
+
}));
|
|
91
|
+
const columnsMerged = mergeColumns(columnsMergingInit, numberOfColumns);
|
|
92
|
+
const columnsIdMap = new Array(columnsUnmerged.length);
|
|
115
93
|
assert(columnsMerged.length === numberOfColumns);
|
|
116
|
-
columnsMerged.forEach(
|
|
117
|
-
columnMerged.columnIdsMerged.forEach(
|
|
94
|
+
columnsMerged.forEach((columnMerged, columnMergedId) => {
|
|
95
|
+
columnMerged.columnIdsMerged.forEach((columnId) => {
|
|
118
96
|
columnsIdMap[columnId] = columnMergedId;
|
|
119
97
|
});
|
|
120
98
|
});
|
|
@@ -124,25 +102,32 @@ function determineColumnLayout(columnsUnmerged, numberOfColumns) {
|
|
|
124
102
|
function mergeColumns(columnsMerging, numberOfColumns) {
|
|
125
103
|
if (columnsMerging.length <= numberOfColumns)
|
|
126
104
|
return columnsMerging;
|
|
127
|
-
|
|
128
|
-
for (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
105
|
+
let mergeCandidate = null;
|
|
106
|
+
for (let i = 0; i <= columnsMerging.length - 2; i++) {
|
|
107
|
+
const column1 = columnsMerging[i + 0];
|
|
108
|
+
const column2 = columnsMerging[i + 1];
|
|
109
|
+
const heightTotal = column1.heightTotal + column2.heightTotal;
|
|
132
110
|
if (!mergeCandidate || mergeCandidate.heightTotal > heightTotal) {
|
|
133
111
|
mergeCandidate = {
|
|
134
|
-
i
|
|
135
|
-
columnIdsMerged:
|
|
136
|
-
|
|
112
|
+
i,
|
|
113
|
+
columnIdsMerged: [
|
|
114
|
+
//
|
|
115
|
+
...column1.columnIdsMerged,
|
|
116
|
+
...column2.columnIdsMerged,
|
|
117
|
+
],
|
|
118
|
+
heightTotal,
|
|
137
119
|
};
|
|
138
120
|
}
|
|
139
121
|
}
|
|
140
122
|
assert(mergeCandidate);
|
|
141
|
-
|
|
123
|
+
const { i } = mergeCandidate;
|
|
142
124
|
assert(-1 < i && i < columnsMerging.length - 1);
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
125
|
+
const columnsMergingMod = [
|
|
126
|
+
//
|
|
127
|
+
...columnsMerging.slice(0, i),
|
|
128
|
+
mergeCandidate,
|
|
129
|
+
...columnsMerging.slice(i + 2),
|
|
130
|
+
];
|
|
146
131
|
assert(columnsMergingMod.length === columnsMerging.length - 1);
|
|
147
132
|
return mergeColumns(columnsMergingMod, numberOfColumns);
|
|
148
133
|
}
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
-
if (ar || !(i in from)) {
|
|
4
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
-
ar[i] = from[i];
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
-
};
|
|
10
1
|
export { parseMarkdownMini };
|
|
11
2
|
import React from 'react';
|
|
12
3
|
function parseMarkdownMini(markdown) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
markdown.split('').forEach(
|
|
4
|
+
const parts = [];
|
|
5
|
+
let current;
|
|
6
|
+
markdown.split('').forEach((letter) => {
|
|
16
7
|
if (letter === '`') {
|
|
17
|
-
if (
|
|
8
|
+
if (current?.nodeType === 'code') {
|
|
18
9
|
// </code>
|
|
19
10
|
parts.push(current);
|
|
20
11
|
current = undefined;
|
|
@@ -37,9 +28,6 @@ function parseMarkdownMini(markdown) {
|
|
|
37
28
|
if (current) {
|
|
38
29
|
parts.push(current);
|
|
39
30
|
}
|
|
40
|
-
|
|
41
|
-
{}], parts.map(function (part, i) {
|
|
42
|
-
return React.createElement(part.nodeType === 'code' ? 'code' : React.Fragment, { key: i }, part.content);
|
|
43
|
-
}), false));
|
|
31
|
+
const parsed = React.createElement(React.Fragment, {}, ...parts.map((part, i) => React.createElement(part.nodeType === 'code' ? 'code' : React.Fragment, { key: i }, part.content)));
|
|
44
32
|
return parsed;
|
|
45
33
|
}
|