myst-to-react 0.14.0 → 0.14.2
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/README.md +1 -1
- package/dist/block.d.ts +2 -4
- package/dist/block.d.ts.map +1 -1
- package/dist/block.js +11 -15
- package/dist/hashLink.d.ts +3 -1
- package/dist/hashLink.d.ts.map +1 -1
- package/dist/hashLink.js +2 -2
- package/dist/heading.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# myst-to-react
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/myst-to-react)
|
|
4
|
-
[](https://github.com/
|
|
4
|
+
[](https://github.com/jupyter-book/myst-theme/blob/main/LICENSE)
|
|
5
5
|
|
|
6
6
|
Convert a MyST AST to React.
|
package/dist/block.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { GenericParent } from 'myst-common';
|
|
2
2
|
import type { NodeRenderer } from '@myst-theme/providers';
|
|
3
|
-
export declare function Block({
|
|
4
|
-
id: string;
|
|
3
|
+
export declare function Block({ node, className }: {
|
|
5
4
|
node: GenericParent;
|
|
6
5
|
className?: string;
|
|
7
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export declare const BlockRenderer: NodeRenderer;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
9
7
|
declare const BLOCK_RENDERERS: Record<string, NodeRenderer>;
|
|
10
8
|
export default BLOCK_RENDERERS;
|
|
11
9
|
//# sourceMappingURL=block.d.ts.map
|
package/dist/block.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,kDAoBrF;AAED,QAAA,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAEjD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
package/dist/block.js
CHANGED
|
@@ -2,27 +2,23 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Details } from './dropdown.js';
|
|
3
3
|
import { MyST } from './MyST.js';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
-
|
|
6
|
-
export function Block({ id, node, className, }) {
|
|
5
|
+
export function Block({ node, className }) {
|
|
7
6
|
var _a, _b;
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
const cn = classNames(className, node.class, {
|
|
8
|
+
[(_a = node.data) === null || _a === void 0 ? void 0 : _a.class]: typeof ((_b = node.data) === null || _b === void 0 ? void 0 : _b.class) === 'string',
|
|
9
|
+
});
|
|
10
|
+
if (node.visibility === 'remove')
|
|
11
|
+
return null;
|
|
12
|
+
// Only wrap this in a block if the block has a class name or an identifier
|
|
13
|
+
// Otherwise pass through the contents as is.
|
|
14
|
+
// This allows children (e.g. margin) access to the grid-system
|
|
15
|
+
const block = cn || node.identifier ? (_jsx("div", { id: node.identifier, className: cn, children: _jsx(MyST, { ast: node.children }) })) : (_jsx(MyST, { ast: node.children }));
|
|
17
16
|
if (node.visibility === 'hide') {
|
|
18
17
|
return _jsx(Details, { title: "Block", children: block });
|
|
19
18
|
}
|
|
20
19
|
return block;
|
|
21
20
|
}
|
|
22
|
-
export const BlockRenderer = ({ node, className }) => {
|
|
23
|
-
return (_jsx(Block, { id: node.key, node: node, className: classNames(node.class, className) }, node.key));
|
|
24
|
-
};
|
|
25
21
|
const BLOCK_RENDERERS = {
|
|
26
|
-
block:
|
|
22
|
+
block: Block,
|
|
27
23
|
};
|
|
28
24
|
export default BLOCK_RENDERERS;
|
package/dist/hashLink.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare function scrollToElement(el: HTMLElement | null, { htmlId, scroll
|
|
|
10
10
|
/** Update the URL fragment to this ID */
|
|
11
11
|
htmlId?: string;
|
|
12
12
|
} & HashLinkBehavior): void;
|
|
13
|
-
export declare function HashLink({ id, kind, title, children, canSelectText, hover, className, hideInPopup, scrollBehavior, historyState, focusTarget, }: {
|
|
13
|
+
export declare function HashLink({ id, kind, title, children, canSelectText, hover, className, hideInPopup, scrollBehavior, historyState, focusTarget, noWidth, }: {
|
|
14
14
|
id?: string;
|
|
15
15
|
kind?: string;
|
|
16
16
|
title?: string;
|
|
@@ -19,5 +19,7 @@ export declare function HashLink({ id, kind, title, children, canSelectText, hov
|
|
|
19
19
|
canSelectText?: boolean;
|
|
20
20
|
className?: string;
|
|
21
21
|
hideInPopup?: boolean;
|
|
22
|
+
/** Ensures that when centered it doesn't take up space */
|
|
23
|
+
noWidth?: boolean;
|
|
22
24
|
} & HashLinkBehavior): import("react/jsx-runtime").JSX.Element | null;
|
|
23
25
|
//# sourceMappingURL=hashLink.d.ts.map
|
package/dist/hashLink.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashLink.d.ts","sourceRoot":"","sources":["../src/hashLink.tsx"],"names":[],"mappings":"AAGA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,6DAA6D;IAC7D,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,8DAA8D;IAC9D,YAAY,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAAC;IACzC,gEAAgE;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AG,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC;IACvC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG,gBAAgB,kDAoCnB"}
|
package/dist/hashLink.js
CHANGED
|
@@ -27,7 +27,7 @@ export function scrollToElement(el, { htmlId = el === null || el === void 0 ? vo
|
|
|
27
27
|
el.focus({ preventScroll: true });
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
export function HashLink({ id, kind, title = `Link to this ${kind}`, children = '¶', canSelectText = false, hover, className = 'font-normal', hideInPopup, scrollBehavior, historyState, focusTarget, }) {
|
|
30
|
+
export function HashLink({ id, kind, title = `Link to this ${kind}`, children = '¶', canSelectText = false, hover, className = 'font-normal', hideInPopup, scrollBehavior, historyState, focusTarget, noWidth, }) {
|
|
31
31
|
const { inCrossRef } = useXRefState();
|
|
32
32
|
if (inCrossRef || !id) {
|
|
33
33
|
// If we are in a cross-reference pop-out, either hide hash link
|
|
@@ -39,7 +39,7 @@ export function HashLink({ id, kind, title = `Link to this ${kind}`, children =
|
|
|
39
39
|
const el = document.getElementById(id);
|
|
40
40
|
scrollToElement(el, { scrollBehavior, historyState, focusTarget });
|
|
41
41
|
};
|
|
42
|
-
return (_jsx("a", { className: classNames('no-underline text-inherit hover:text-inherit', className, {
|
|
42
|
+
return (_jsx("a", { className: classNames('no-underline text-inherit hover:text-inherit', { 'inline-block w-0 px-0 translate-x-[10px]': noWidth === true }, className, {
|
|
43
43
|
'select-none': !canSelectText,
|
|
44
44
|
'transition-opacity opacity-0 focus:opacity-100 group-hover:opacity-70': hover === true,
|
|
45
45
|
'[@media(hover:hover)]:transition-opacity [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:focus:opacity-100 [@media(hover:hover)]:group-hover:opacity-70': hover === 'desktop',
|
package/dist/heading.js
CHANGED
|
@@ -6,7 +6,7 @@ import classNames from 'classnames';
|
|
|
6
6
|
const Heading = ({ node, className }) => {
|
|
7
7
|
const { enumerator, depth, key, identifier, html_id } = node;
|
|
8
8
|
const id = html_id || identifier || key;
|
|
9
|
-
const textContent = (_jsxs(_Fragment, { children: [enumerator && _jsx("span", { className: "mr-3 select-none", children: enumerator }), _jsx("span", { className: "heading-text", children: _jsx(MyST, { ast: node.children }) }), _jsx(HashLink, { id: id, kind: "Section", className: "
|
|
9
|
+
const textContent = (_jsxs(_Fragment, { children: [enumerator && _jsx("span", { className: "mr-3 select-none", children: enumerator }), _jsx("span", { className: "heading-text", children: _jsx(MyST, { ast: node.children }) }), _jsx(HashLink, { id: id, kind: "Section", className: "font-normal", hover: true, hideInPopup: true, noWidth: true })] }));
|
|
10
10
|
// The `heading-text` class is picked up in the Outline to select without the enumerator and "#" link
|
|
11
11
|
return e(`h${depth}`, {
|
|
12
12
|
id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "myst-to-react",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.2",
|
|
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.14.
|
|
24
|
+
"@myst-theme/providers": "^0.14.2",
|
|
25
25
|
"@scienceicons/react": "^0.0.11",
|
|
26
26
|
"@radix-ui/react-hover-card": "^1.0.6",
|
|
27
27
|
"buffer": "^6.0.3",
|