@myst-theme/jupyter 0.13.7 → 0.14.0
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/block.d.ts +21 -0
- package/dist/block.d.ts.map +1 -0
- package/dist/block.js +42 -0
- package/dist/index.d.ts +1 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -9
- package/dist/renderers.d.ts +11 -0
- package/dist/renderers.d.ts.map +1 -0
- package/dist/renderers.js +12 -0
- package/package.json +7 -7
package/dist/block.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { GenericParent } from 'myst-common';
|
|
2
|
+
import type { NodeRenderers, NodeRenderer } from '@myst-theme/providers';
|
|
3
|
+
export declare function NotebookBlock({ id, node, className, }: {
|
|
4
|
+
id: string;
|
|
5
|
+
node: GenericParent;
|
|
6
|
+
className?: string;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const NotebookBlockRenderer: NodeRenderer;
|
|
9
|
+
/**
|
|
10
|
+
* The logic for the selector is complex:
|
|
11
|
+
*
|
|
12
|
+
* - MD files have `notebook-code` and otherwise blocks with no kind.
|
|
13
|
+
* - IPyNB files have both `notebook-code` and `notebook-content` blocks.
|
|
14
|
+
* - An article may contain `notebook-code` blocks from the `code-cell` directive even though it is not considered a notebook (i.e., no frontmatter kernelspec).
|
|
15
|
+
*
|
|
16
|
+
* This component therefore only renders for `code-cells` (both ipynb and .md) and `content-cells` (ipynb).
|
|
17
|
+
*
|
|
18
|
+
* The benefit of this is that we can use the block-kind to figure out if e.g. the cell is executable.
|
|
19
|
+
*/
|
|
20
|
+
export declare const NOTEBOOK_BLOCK_RENDERERS: NodeRenderers;
|
|
21
|
+
//# sourceMappingURL=block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAQjD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEzE,wBAAgB,aAAa,CAAC,EAC5B,EAAE,EACF,IAAI,EACJ,SAAS,GACV,EAAE;IACD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAuCA;AAED,eAAO,MAAM,qBAAqB,EAAE,YASnC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,EAAE,aAItC,CAAC"}
|
package/dist/block.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Details, MyST } from 'myst-to-react';
|
|
3
|
+
import { SourceFileKind } from 'myst-spec-ext';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { NotebookClearCell, NotebookRunCell, NotebookRunCellSpinnerOnly, } from './controls/index.js';
|
|
6
|
+
import { useGridSystemProvider, usePageKind } from '@myst-theme/providers';
|
|
7
|
+
export function NotebookBlock({ id, node, className, }) {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
const pageKind = usePageKind();
|
|
10
|
+
const grid = useGridSystemProvider();
|
|
11
|
+
const subGrid = node.visibility === 'hide' ? '' : `${grid} subgrid-gap col-screen`;
|
|
12
|
+
const dataClassName = typeof ((_a = node.data) === null || _a === void 0 ? void 0 : _a.class) === 'string' ? (_b = node.data) === null || _b === void 0 ? void 0 : _b.class : undefined;
|
|
13
|
+
// Hide the subgrid if either the dataClass or the className exists and includes `col-`
|
|
14
|
+
const noSubGrid = (dataClassName && dataClassName.includes('col-')) || (className && className.includes('col-'));
|
|
15
|
+
const block = (_jsxs("div", { id: id, className: classNames('relative group/block', className, dataClassName, {
|
|
16
|
+
[subGrid]: !noSubGrid,
|
|
17
|
+
hidden: node.visibility === 'remove',
|
|
18
|
+
}), children: [pageKind === SourceFileKind.Notebook && node.kind === 'notebook-code' && (_jsxs(_Fragment, { children: [_jsx("div", { className: "flex sticky top-[80px] z-10 opacity-70 group-hover/block:opacity-100 group-hover/block:hidden", children: _jsx("div", { className: "absolute top-0 -right-[28px] flex md:flex-col", children: _jsx(NotebookRunCellSpinnerOnly, { id: id }) }) }), _jsx("div", { className: "hidden sticky top-[80px] z-10 opacity-70 group-hover/block:opacity-100 group-hover/block:flex", children: _jsxs("div", { className: "absolute top-0 -right-[28px] flex md:flex-col", children: [_jsx(NotebookRunCell, { id: id }), _jsx(NotebookClearCell, { id: id })] }) })] })), _jsx(MyST, { ast: node.children })] }, `block-${id}`));
|
|
19
|
+
if (node.visibility === 'hide') {
|
|
20
|
+
return _jsx(Details, { title: "Notebook Cell", children: block });
|
|
21
|
+
}
|
|
22
|
+
return block;
|
|
23
|
+
}
|
|
24
|
+
export const NotebookBlockRenderer = ({ node, className }) => {
|
|
25
|
+
return (_jsx(NotebookBlock, { id: node.key, node: node, className: classNames(node.class, className) }, node.key));
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The logic for the selector is complex:
|
|
29
|
+
*
|
|
30
|
+
* - MD files have `notebook-code` and otherwise blocks with no kind.
|
|
31
|
+
* - IPyNB files have both `notebook-code` and `notebook-content` blocks.
|
|
32
|
+
* - An article may contain `notebook-code` blocks from the `code-cell` directive even though it is not considered a notebook (i.e., no frontmatter kernelspec).
|
|
33
|
+
*
|
|
34
|
+
* This component therefore only renders for `code-cells` (both ipynb and .md) and `content-cells` (ipynb).
|
|
35
|
+
*
|
|
36
|
+
* The benefit of this is that we can use the block-kind to figure out if e.g. the cell is executable.
|
|
37
|
+
*/
|
|
38
|
+
export const NOTEBOOK_BLOCK_RENDERERS = {
|
|
39
|
+
block: {
|
|
40
|
+
'block[kind=notebook-code],block[kind=notebook-content]': NotebookBlockRenderer,
|
|
41
|
+
},
|
|
42
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import { Embed } from './embed.js';
|
|
2
|
-
import { Output } from './output.js';
|
|
3
|
-
import { Figure } from './figure.js';
|
|
4
|
-
declare const OUTPUT_RENDERERS: {
|
|
5
|
-
output: typeof Output;
|
|
6
|
-
embed: typeof Embed;
|
|
7
|
-
container: typeof Figure;
|
|
8
|
-
};
|
|
9
1
|
export * from './BinderBadge.js';
|
|
10
2
|
export * from './ErrorTray.js';
|
|
11
3
|
export * from './ConnectionStatusTray.js';
|
|
@@ -14,5 +6,5 @@ export * from './execute/index.js';
|
|
|
14
6
|
export * from './controls/index.js';
|
|
15
7
|
export * from './utils.js';
|
|
16
8
|
export { useLaunchBinder } from './hooks.js';
|
|
17
|
-
export
|
|
9
|
+
export { JUPYTER_RENDERERS, NOTEBOOK_BLOCK_RENDERERS, OUTPUT_RENDERERS } from './renderers.js';
|
|
18
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import { Embed } from './embed.js';
|
|
2
|
-
import { Output } from './output.js';
|
|
3
|
-
import { Figure } from './figure.js';
|
|
4
|
-
const OUTPUT_RENDERERS = {
|
|
5
|
-
output: Output,
|
|
6
|
-
embed: Embed,
|
|
7
|
-
container: Figure,
|
|
8
|
-
};
|
|
9
1
|
export * from './BinderBadge.js';
|
|
10
2
|
export * from './ErrorTray.js';
|
|
11
3
|
export * from './ConnectionStatusTray.js';
|
|
@@ -14,4 +6,4 @@ export * from './execute/index.js';
|
|
|
14
6
|
export * from './controls/index.js';
|
|
15
7
|
export * from './utils.js';
|
|
16
8
|
export { useLaunchBinder } from './hooks.js';
|
|
17
|
-
export
|
|
9
|
+
export { JUPYTER_RENDERERS, NOTEBOOK_BLOCK_RENDERERS, OUTPUT_RENDERERS } from './renderers.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Embed } from './embed.js';
|
|
2
|
+
import { Output } from './output.js';
|
|
3
|
+
import { Figure } from './figure.js';
|
|
4
|
+
export { NOTEBOOK_BLOCK_RENDERERS } from './block.js';
|
|
5
|
+
export declare const OUTPUT_RENDERERS: {
|
|
6
|
+
output: typeof Output;
|
|
7
|
+
embed: typeof Embed;
|
|
8
|
+
container: typeof Figure;
|
|
9
|
+
};
|
|
10
|
+
export declare const JUPYTER_RENDERERS: import("@myst-theme/providers").NodeRenderers;
|
|
11
|
+
//# sourceMappingURL=renderers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderers.d.ts","sourceRoot":"","sources":["../src/renderers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAC;AACF,eAAO,MAAM,iBAAiB,+CAA+D,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Embed } from './embed.js';
|
|
2
|
+
import { Output } from './output.js';
|
|
3
|
+
import { Figure } from './figure.js';
|
|
4
|
+
import { mergeRenderers } from '@myst-theme/providers';
|
|
5
|
+
import { NOTEBOOK_BLOCK_RENDERERS } from './block.js';
|
|
6
|
+
export { NOTEBOOK_BLOCK_RENDERERS } from './block.js';
|
|
7
|
+
export const OUTPUT_RENDERERS = {
|
|
8
|
+
output: Output,
|
|
9
|
+
embed: Embed,
|
|
10
|
+
container: Figure,
|
|
11
|
+
};
|
|
12
|
+
export const JUPYTER_RENDERERS = mergeRenderers([OUTPUT_RENDERERS, NOTEBOOK_BLOCK_RENDERERS]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myst-theme/jupyter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"@curvenote/ansi-to-react": "^7.0.0",
|
|
26
26
|
"@headlessui/react": "^1.7.15",
|
|
27
27
|
"@heroicons/react": "^2.0.18",
|
|
28
|
-
"@myst-theme/providers": "^0.
|
|
28
|
+
"@myst-theme/providers": "^0.14.0",
|
|
29
29
|
"@scienceicons/react": "^0.0.11",
|
|
30
30
|
"buffer": "^6.0.3",
|
|
31
31
|
"classnames": "^2.5.1",
|
|
32
32
|
"jupyterlab-plotly": "^5.24.0",
|
|
33
|
-
"myst-common": "^1.7.
|
|
34
|
-
"myst-config": "^1.7.
|
|
35
|
-
"myst-frontmatter": "^1.7.
|
|
33
|
+
"myst-common": "^1.7.9",
|
|
34
|
+
"myst-config": "^1.7.9",
|
|
35
|
+
"myst-frontmatter": "^1.7.9",
|
|
36
36
|
"myst-spec": "^0.0.5",
|
|
37
|
-
"myst-spec-ext": "^1.7.
|
|
38
|
-
"myst-to-react": "^0.
|
|
37
|
+
"myst-spec-ext": "^1.7.9",
|
|
38
|
+
"myst-to-react": "^0.14.0",
|
|
39
39
|
"nanoid": "^4.0.2",
|
|
40
40
|
"nbtx": "^0.2.3",
|
|
41
41
|
"react-syntax-highlighter": "^15.5.0",
|