myst-to-react 0.5.8 → 0.5.10
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/dist/cite.js +1 -1
- package/dist/code.js +2 -2
- package/dist/crossReference.js +1 -1
- package/dist/footnotes.js +1 -1
- package/dist/links/github.d.ts.map +1 -1
- package/dist/links/github.js +5 -5
- package/dist/links/rrid.d.ts.map +1 -1
- package/dist/links/rrid.js +3 -3
- package/package.json +4 -3
package/dist/cite.js
CHANGED
|
@@ -6,7 +6,7 @@ import { InlineError } from './inlineError.js';
|
|
|
6
6
|
import { HoverPopover } from './components/index.js';
|
|
7
7
|
import { MyST } from './MyST.js';
|
|
8
8
|
function CiteChild({ html }) {
|
|
9
|
-
return (_jsx("div", { className: "hover-document w-[500px] sm:max-w-[500px] p-3", dangerouslySetInnerHTML: { __html: html || '' } }));
|
|
9
|
+
return (_jsx("div", { className: "hover-document article w-[500px] sm:max-w-[500px] p-3", dangerouslySetInnerHTML: { __html: html || '' } }));
|
|
10
10
|
}
|
|
11
11
|
export const CiteGroup = ({ node }) => {
|
|
12
12
|
return (_jsx("span", { className: classNames('cite-group', {
|
package/dist/code.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useTheme } from '@myst-theme/providers';
|
|
3
3
|
import { LightAsync as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
4
|
-
import light from 'react-syntax-highlighter/dist/esm/styles/hljs/xcode';
|
|
5
|
-
import dark from 'react-syntax-highlighter/dist/esm/styles/hljs/vs2015';
|
|
4
|
+
import light from 'react-syntax-highlighter/dist/esm/styles/hljs/xcode.js';
|
|
5
|
+
import dark from 'react-syntax-highlighter/dist/esm/styles/hljs/vs2015.js';
|
|
6
6
|
import { DocumentIcon } from '@heroicons/react/24/outline';
|
|
7
7
|
import classNames from 'classnames';
|
|
8
8
|
import { CopyIcon } from './components/index.js';
|
package/dist/crossReference.js
CHANGED
|
@@ -138,7 +138,7 @@ export function CrossReferenceHover({ url: urlIn, dataUrl: dataUrlIn, remote: re
|
|
|
138
138
|
el === null || el === void 0 ? void 0 : el.scrollIntoView({ behavior: 'smooth' });
|
|
139
139
|
history.replaceState(undefined, '', `#${htmlId}`);
|
|
140
140
|
};
|
|
141
|
-
return (_jsx(HoverPopover, { card: ({ load }) => (_jsx(XRefProvider, { remote: remote, url: url, dataUrl: dataUrl, children: _jsx("div", { className: "hover-document w-[500px] sm:max-w-[500px] px-3", children: _jsx(XrefChildren, { load: load, remote: remote, url: url, dataUrl: dataUrl, identifier: identifier }) }) })), children: _jsxs("span", { children: [remote && external && (_jsx("a", { href: `${url}${htmlId ? `#${htmlId}` : ''}`, target: "_blank", className: "hover-link", children: children })), remote && !external && (_jsx(Link, { to: `${withBaseurl(url, baseurl)}${htmlId ? `#${htmlId}` : ''}`, prefetch: "intent", className: "hover-link", children: children })), !remote && (_jsx("a", { href: `#${htmlId}`, onClick: scroll, className: "hover-link", children: children }))] }) }));
|
|
141
|
+
return (_jsx(HoverPopover, { card: ({ load }) => (_jsx(XRefProvider, { remote: remote, url: url, dataUrl: dataUrl, children: _jsx("div", { className: "hover-document article w-[500px] sm:max-w-[500px] px-3", children: _jsx(XrefChildren, { load: load, remote: remote, url: url, dataUrl: dataUrl, identifier: identifier }) }) })), children: _jsxs("span", { children: [remote && external && (_jsx("a", { href: `${url}${htmlId ? `#${htmlId}` : ''}`, target: "_blank", className: "hover-link", children: children })), remote && !external && (_jsx(Link, { to: `${withBaseurl(url, baseurl)}${htmlId ? `#${htmlId}` : ''}`, prefetch: "intent", className: "hover-link", children: children })), !remote && (_jsx("a", { href: `#${htmlId}`, onClick: scroll, className: "hover-link", children: children }))] }) }));
|
|
142
142
|
}
|
|
143
143
|
export const CrossReferenceNode = ({ node }) => {
|
|
144
144
|
if (!node.children) {
|
package/dist/footnotes.js
CHANGED
|
@@ -7,7 +7,7 @@ function FootnoteDefinition({ identifier }) {
|
|
|
7
7
|
var _a, _b;
|
|
8
8
|
const references = useReferences();
|
|
9
9
|
const node = (_b = (_a = references === null || references === void 0 ? void 0 : references.footnotes) === null || _a === void 0 ? void 0 : _a[identifier]) !== null && _b !== void 0 ? _b : select(`footnoteDefinition[identifier=${identifier}]`, references === null || references === void 0 ? void 0 : references.article);
|
|
10
|
-
return (_jsx(XRefProvider, { children: _jsx("div", { className: "hover-document w-[500px] sm:max-w-[500px] px-3", children: _jsx(MyST, { ast: node.children }) }) }));
|
|
10
|
+
return (_jsx(XRefProvider, { children: _jsx("div", { className: "hover-document article w-[500px] sm:max-w-[500px] px-3", children: _jsx(MyST, { ast: node.children }) }) }));
|
|
11
11
|
}
|
|
12
12
|
export const FootnoteReference = ({ node }) => {
|
|
13
13
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/links/github.tsx"],"names":[],"mappings":"AAOA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/links/github.tsx"],"names":[],"mappings":"AAOA,OAAO,KAA8B,MAAM,OAAO,CAAC;AA8NnD,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,QAAQ,EACR,GAAG,EACH,GAAG,EACH,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,EAAE,EACF,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,2CAoCA"}
|
package/dist/links/github.js
CHANGED
|
@@ -37,7 +37,7 @@ function GithubFilePreview({ url, raw, org, repo, file, from, to, open, }) {
|
|
|
37
37
|
const { data, error } = useLoadWhenOpen(open, raw, fetcher);
|
|
38
38
|
let code = data;
|
|
39
39
|
if (error) {
|
|
40
|
-
return (_jsxs("div", { className: "hover-document w-[500px] sm:max-w-[500px]", children: [_jsx("a", { href: url, className: "block text-inherit hover:text-inherit", target: "_blank", rel: "noreferrer", children: _jsx(ExternalLinkIcon, { width: "1rem", height: "1rem", className: "float-right" }) }), _jsxs("div", { className: "mt-2", children: ["Error loading \"", file, "\" from GitHub."] })] }));
|
|
40
|
+
return (_jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px]", children: [_jsx("a", { href: url, className: "block text-inherit hover:text-inherit", target: "_blank", rel: "noreferrer", children: _jsx(ExternalLinkIcon, { width: "1rem", height: "1rem", className: "float-right" }) }), _jsxs("div", { className: "mt-2", children: ["Error loading \"", file, "\" from GitHub."] })] }));
|
|
41
41
|
}
|
|
42
42
|
const lang = extToLanguage(file === null || file === void 0 ? void 0 : file.split('.').pop());
|
|
43
43
|
let startingLineNumber = 1;
|
|
@@ -56,7 +56,7 @@ function GithubFilePreview({ url, raw, org, repo, file, from, to, open, }) {
|
|
|
56
56
|
code = code === null || code === void 0 ? void 0 : code.split('\n').slice(0, 10).join('\n');
|
|
57
57
|
}
|
|
58
58
|
const description = code ? (_jsx(_Fragment, { children: _jsx(CodeBlock, { value: code, lang: lang, filename: file, showLineNumbers: true, startingLineNumber: startingLineNumber, emphasizeLines: emphasizeLines, showCopy: false }) })) : null;
|
|
59
|
-
return (_jsx(LinkCard, { loading: !code, url: url, title: `GitHub - ${org}/${repo}`, description: description, className: "hover-document max-w-[80vw]" }));
|
|
59
|
+
return (_jsx(LinkCard, { loading: !code, url: url, title: `GitHub - ${org}/${repo}`, description: description, className: "hover-document article max-w-[80vw]" }));
|
|
60
60
|
}
|
|
61
61
|
// https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color
|
|
62
62
|
function useWhiteTextColor(bgColor) {
|
|
@@ -70,18 +70,18 @@ function GithubIssuePreview({ url, org, repo, issue_number, open, }) {
|
|
|
70
70
|
var _a, _b;
|
|
71
71
|
const { data, error } = useLoadWhenOpen(open, `https://api.github.com/repos/${org}/${repo}/issues/${issue_number}`, jsonFetcher);
|
|
72
72
|
if (!data && !error) {
|
|
73
|
-
return (_jsx("div", { className: "hover-document w-[500px] sm:max-w-[500px] animate-pulse", children: "Loading..." }));
|
|
73
|
+
return (_jsx("div", { className: "hover-document article w-[500px] sm:max-w-[500px] animate-pulse", children: "Loading..." }));
|
|
74
74
|
}
|
|
75
75
|
const resp = data;
|
|
76
76
|
if (error) {
|
|
77
|
-
return (_jsxs("div", { className: "hover-document", children: [_jsx("a", { href: url, className: "block text-inherit hover:text-inherit", target: "_blank", rel: "noreferrer", children: _jsx(ExternalLinkIcon, { className: "float-right w-4 h-4" }) }), _jsx("div", { className: "mt-2", children: "Error loading from GitHub." })] }));
|
|
77
|
+
return (_jsxs("div", { className: "hover-document article", children: [_jsx("a", { href: url, className: "block text-inherit hover:text-inherit", target: "_blank", rel: "noreferrer", children: _jsx(ExternalLinkIcon, { className: "float-right w-4 h-4" }) }), _jsx("div", { className: "mt-2", children: "Error loading from GitHub." })] }));
|
|
78
78
|
}
|
|
79
79
|
const dateString = new Date(resp.created_at).toLocaleDateString('en-US', {
|
|
80
80
|
year: 'numeric',
|
|
81
81
|
month: 'long',
|
|
82
82
|
day: 'numeric',
|
|
83
83
|
});
|
|
84
|
-
return (_jsxs("div", { className: "hover-document w-[400px] sm:max-w-[400px] p-3", children: [_jsxs("div", { className: "text-xs font-light", children: [org, "/", repo] }), _jsxs("div", { className: "my-2 text-lg font-bold dark:text-white", children: [resp.state === 'open' && (_jsx(PlusCircleIcon, { width: "1.5rem", height: "1.5rem", className: "inline-block mr-2 text-green-700 -translate-y-px dark:text-green-500" })), resp.state === 'closed' && (_jsx(CheckCircleIcon, { width: "1.5rem", height: "1.5rem", className: "inline-block mr-2 text-purple-700 -translate-y-px dark:text-purple-500" })), resp.title] }), _jsxs("div", { className: "text-xs font-light", children: ["#", issue_number, " opened on ", dateString, " by", ' ', _jsxs("span", { className: "font-normal", children: ["@", resp.user.login] })] }), _jsx("p", { className: "text-md max-h-[4rem] overflow-hidden", children: resp.body }), ((_a = resp.labels) === null || _a === void 0 ? void 0 : _a.length) > 0 && (_jsx("div", { className: "flex flex-wrap", children: (_b = resp.labels) === null || _b === void 0 ? void 0 : _b.map((label) => (_jsx("span", { className: classNames('mr-1 text-xs inline-flex items-center px-2 py-0.5 rounded-full', {
|
|
84
|
+
return (_jsxs("div", { className: "hover-document article w-[400px] sm:max-w-[400px] p-3", children: [_jsxs("div", { className: "text-xs font-light", children: [org, "/", repo] }), _jsxs("div", { className: "my-2 text-lg font-bold dark:text-white", children: [resp.state === 'open' && (_jsx(PlusCircleIcon, { width: "1.5rem", height: "1.5rem", className: "inline-block mr-2 text-green-700 -translate-y-px dark:text-green-500" })), resp.state === 'closed' && (_jsx(CheckCircleIcon, { width: "1.5rem", height: "1.5rem", className: "inline-block mr-2 text-purple-700 -translate-y-px dark:text-purple-500" })), resp.title] }), _jsxs("div", { className: "text-xs font-light", children: ["#", issue_number, " opened on ", dateString, " by", ' ', _jsxs("span", { className: "font-normal", children: ["@", resp.user.login] })] }), _jsx("p", { className: "text-md max-h-[4rem] overflow-hidden", children: resp.body }), ((_a = resp.labels) === null || _a === void 0 ? void 0 : _a.length) > 0 && (_jsx("div", { className: "flex flex-wrap", children: (_b = resp.labels) === null || _b === void 0 ? void 0 : _b.map((label) => (_jsx("span", { className: classNames('mr-1 text-xs inline-flex items-center px-2 py-0.5 rounded-full', {
|
|
85
85
|
'text-white': useWhiteTextColor(label.color),
|
|
86
86
|
}), style: { backgroundColor: `#${label.color}` }, children: label.name }, label.id))) }))] }));
|
|
87
87
|
}
|
package/dist/links/rrid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rrid.d.ts","sourceRoot":"","sources":["../../src/links/rrid.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rrid.d.ts","sourceRoot":"","sources":["../../src/links/rrid.tsx"],"names":[],"mappings":"AAsEA,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,2CAQlD"}
|
package/dist/links/rrid.js
CHANGED
|
@@ -10,17 +10,17 @@ function RRIDChild({ rrid }) {
|
|
|
10
10
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
11
11
|
const { data, error } = useSWR(`https://scicrunch.org/resolver/${rrid}.json`, fetcher);
|
|
12
12
|
if (!data && !error) {
|
|
13
|
-
return (_jsx("div", { className: "hover-document w-[500px] sm:max-w-[500px] animate-pulse", children: "Loading..." }));
|
|
13
|
+
return (_jsx("div", { className: "hover-document article w-[500px] sm:max-w-[500px] animate-pulse", children: "Loading..." }));
|
|
14
14
|
}
|
|
15
15
|
const hit = (_b = (_a = data === null || data === void 0 ? void 0 : data.hits) === null || _a === void 0 ? void 0 : _a.hits) === null || _b === void 0 ? void 0 : _b[0];
|
|
16
16
|
if (error || !hit) {
|
|
17
|
-
return _jsxs("div", { className: "hover-document w-[500px] sm:max-w-[500px]", children: ["Error loading ", rrid, "."] });
|
|
17
|
+
return (_jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px]", children: ["Error loading ", rrid, "."] }));
|
|
18
18
|
}
|
|
19
19
|
const { name: title, curie, description, supercategory, keywords, types: categories, } = (_d = (_c = hit === null || hit === void 0 ? void 0 : hit._source) === null || _c === void 0 ? void 0 : _c.item) !== null && _d !== void 0 ? _d : {};
|
|
20
20
|
const category = (_e = supercategory === null || supercategory === void 0 ? void 0 : supercategory[0]) === null || _e === void 0 ? void 0 : _e.name;
|
|
21
21
|
const types = (_f = categories === null || categories === void 0 ? void 0 : categories.map(({ name }) => name)) !== null && _f !== void 0 ? _f : [];
|
|
22
22
|
const tags = (_g = keywords === null || keywords === void 0 ? void 0 : keywords.map(({ keyword }) => keyword)) !== null && _g !== void 0 ? _g : [];
|
|
23
|
-
return (_jsxs("div", { className: "hover-document w-[500px] sm:max-w-[500px] p-3", children: [_jsxs("p", { className: "text-sm font-light", children: ["RRID: ", category] }), _jsxs("div", { className: "mb-4 text-xl font-bold", children: [title, " ", _jsx("code", { children: curie })] }), _jsx("p", { className: "text-md", children: description }), types.length > 0 && (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-2 text-xs font-thin", children: "Categories" }), _jsx("div", { className: "flex flex-wrap ml-1", children: types === null || types === void 0 ? void 0 : types.map((tag) => (_jsx("span", { className: "inline-flex items-center px-3 py-1 ml-1 text-xs uppercase border rounded-full", children: tag }))) })] })), tags.length > 0 && (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-2 text-xs font-thin", children: "Tags" }), _jsx("div", { className: "flex flex-wrap ml-1", children: tags === null || tags === void 0 ? void 0 : tags.map((tag) => (_jsx("span", { className: "inline-flex items-center px-3 py-1 ml-1 text-xs uppercase border rounded-full", children: tag }))) })] }))] }));
|
|
23
|
+
return (_jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px] p-3", children: [_jsxs("p", { className: "text-sm font-light", children: ["RRID: ", category] }), _jsxs("div", { className: "mb-4 text-xl font-bold", children: [title, " ", _jsx("code", { children: curie })] }), _jsx("p", { className: "text-md", children: description }), types.length > 0 && (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-2 text-xs font-thin", children: "Categories" }), _jsx("div", { className: "flex flex-wrap ml-1", children: types === null || types === void 0 ? void 0 : types.map((tag) => (_jsx("span", { className: "inline-flex items-center px-3 py-1 ml-1 text-xs uppercase border rounded-full", children: tag }))) })] })), tags.length > 0 && (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-2 text-xs font-thin", children: "Tags" }), _jsx("div", { className: "flex flex-wrap ml-1", children: tags === null || tags === void 0 ? void 0 : tags.map((tag) => (_jsx("span", { className: "inline-flex items-center px-3 py-1 ml-1 text-xs uppercase border rounded-full", children: tag }))) })] }))] }));
|
|
24
24
|
}
|
|
25
25
|
export function RRIDLink({ rrid }) {
|
|
26
26
|
return (_jsx(HoverPopover, { card: _jsx(RRIDChild, { rrid: rrid }), children: _jsxs("a", { href: `https://scicrunch.org/resolver/${rrid}`, target: "_blank", rel: "noopener noreferrer", children: ["RRID: ", _jsx("cite", { className: "italic", children: rrid })] }) }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "myst-to-react",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@heroicons/react": "^2.0.18",
|
|
24
|
-
"@myst-theme/providers": "^0.5.
|
|
24
|
+
"@myst-theme/providers": "^0.5.10",
|
|
25
25
|
"@radix-ui/react-hover-card": "^1.0.6",
|
|
26
26
|
"buffer": "^6.0.3",
|
|
27
27
|
"classnames": "^2.3.2",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"nanoid": "^4.0.2",
|
|
32
32
|
"react-syntax-highlighter": "^15.5.0",
|
|
33
33
|
"swr": "^2.1.5",
|
|
34
|
-
"unist-util-select": "^4.0.3"
|
|
34
|
+
"unist-util-select": "^4.0.3",
|
|
35
|
+
"unist-util-visit": "^4.1.2"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
38
|
"@types/react": "^16.8 || ^17.0 || ^18.0",
|