myst-to-react 0.9.7 → 0.9.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"aside.d.ts","sourceRoot":"","sources":["../src/aside.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAI1D,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAsBF,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,KAAK,CAoB7C,CAAC;AAEF,QAAA,MAAM,eAAe;;CAEpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"aside.d.ts","sourceRoot":"","sources":["../src/aside.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAK1D,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAsBF,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,KAAK,CAoB7C,CAAC;AAEF,QAAA,MAAM,eAAe;;CAEpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
package/dist/aside.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { MyST } from './MyST.js';
3
+ import classNames from 'classnames';
3
4
  function getAsideClass(kind) {
4
5
  switch (kind) {
5
6
  case 'topic':
@@ -20,11 +21,11 @@ function getAsideClass(kind) {
20
21
  }
21
22
  export const AsideRenderer = ({ node }) => {
22
23
  const [title, ...rest] = node.children;
23
- const className = getAsideClass(node.kind);
24
+ const classes = getAsideClass(node.kind);
24
25
  if (title.type !== 'admonitionTitle') {
25
- return (_jsx("aside", { className: className.container, children: _jsx(MyST, { ast: node.children }) }));
26
+ return (_jsx("aside", { className: classNames(classes.container, node.class), children: _jsx(MyST, { ast: node.children }) }));
26
27
  }
27
- return (_jsxs("aside", { className: className.container, children: [_jsx("div", { className: className.title, children: _jsx(MyST, { ast: title }) }), _jsx("div", { className: className.body, children: _jsx(MyST, { ast: rest }) })] }));
28
+ return (_jsxs("aside", { className: classNames(classes.container, node.class), children: [_jsx("div", { className: classes.title, children: _jsx(MyST, { ast: title }) }), _jsx("div", { className: classes.body, children: _jsx(MyST, { ast: rest }) })] }));
28
29
  };
29
30
  const ASIDE_RENDERERS = {
30
31
  aside: AsideRenderer,
package/dist/code.js CHANGED
@@ -44,7 +44,7 @@ export function CodeBlock(props) {
44
44
  }, customStyle: { padding: '0.8rem' }, children: value }), showCopy && (_jsx(CopyIcon, { text: value, className: classNames('absolute right-1', { 'top-[32px]': filename, 'top-1': !filename }) }))] }));
45
45
  }
46
46
  const code = ({ node }) => {
47
- return (_jsx(CodeBlock, { identifier: node.html_id, "data-mdast-node-type": node.type, "data-mdast-node-id": node.key, value: node.value || '', lang: node.lang, filename: node.filename, emphasizeLines: node.emphasizeLines, showLineNumbers: node.showLineNumbers, startingLineNumber: node.startingLineNumber, shadow: true, border: node.executable, background: !node.executable, className: classNames({ hidden: node.visibility === 'remove' }) }));
47
+ return (_jsx(CodeBlock, { identifier: node.html_id, "data-mdast-node-type": node.type, "data-mdast-node-id": node.key, value: node.value || '', lang: node.lang, filename: node.filename, emphasizeLines: node.emphasizeLines, showLineNumbers: node.showLineNumbers, startingLineNumber: node.startingLineNumber, shadow: true, border: node.executable, background: !node.executable, className: classNames({ hidden: node.visibility === 'remove' }, node.class) }));
48
48
  };
49
49
  function isColor(maybeColorHash) {
50
50
  if (!maybeColorHash || maybeColorHash.length > 9)
@@ -1 +1 @@
1
- {"version":3,"file":"iframe.d.ts","sourceRoot":"","sources":["../src/iframe.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAuB1D,eAAO,MAAM,MAAM,EAAE,YAiCpB,CAAC;AAEF,QAAA,MAAM,gBAAgB;;CAErB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"iframe.d.ts","sourceRoot":"","sources":["../src/iframe.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAwB1D,eAAO,MAAM,MAAM,EAAE,YAiCpB,CAAC;AAEF,QAAA,MAAM,gBAAgB;;CAErB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
package/dist/iframe.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import classNames from 'classnames';
2
3
  /** This is duplicated in image, but a bit different logic */
3
4
  function getStyleValue(width) {
4
5
  if (typeof width === 'number' && Number.isNaN(width)) {
@@ -23,7 +24,7 @@ function getStyleValue(width) {
23
24
  }
24
25
  export const IFrame = ({ node }) => {
25
26
  const width = getStyleValue(node.width) || 70;
26
- return (_jsx("div", { id: node.label || undefined, style: { textAlign: node.align || 'center' }, className: "leading-[0]", children: _jsx("div", { className: "relative inline-block", style: {
27
+ return (_jsx("div", { id: node.label || undefined, style: { textAlign: node.align || 'center' }, className: classNames('leading-[0]', node.class), children: _jsx("div", { className: "relative inline-block", style: {
27
28
  paddingBottom: '60%',
28
29
  width: `min(max(${width}%, 500px), 100%)`,
29
30
  }, children: _jsx("iframe", { width: "100%", height: "100%", src: node.src, allowFullScreen: true, allow: "autoplay", style: {
@@ -1 +1 @@
1
- {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../src/image.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,IAAI,aAAa,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAI1D,KAAK,SAAS,GAAG,aAAa,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAmHrD,eAAO,MAAM,KAAK,EAAE,YAAY,CAAC,SAAS,CAczC,CAAC;AAEF,QAAA,MAAM,eAAe;;CAEpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../src/image.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,IAAI,aAAa,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAI1D,KAAK,SAAS,GAAG,aAAa,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAgIrD,eAAO,MAAM,KAAK,EAAE,YAAY,CAAC,SAAS,CAezC,CAAC;AAEF,QAAA,MAAM,eAAe;;CAEpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
package/dist/image.js CHANGED
@@ -31,22 +31,24 @@ function alignToMargin(align) {
31
31
  return {};
32
32
  }
33
33
  }
34
- function Video({ id, src, urlSource, align = 'center', width, height, }) {
35
- return (_jsx("video", { id: id, style: Object.assign({ width: getStyleValue(width), height: getStyleValue(height) }, alignToMargin(align)), src: src, "data-canonical-url": urlSource, autoPlay: true,
34
+ function Video({ className, id, src, urlSource, align = 'center', width, height, }) {
35
+ return (_jsx("video", {
36
+ // className={className}
37
+ id: id, style: Object.assign({ width: getStyleValue(width), height: getStyleValue(height) }, alignToMargin(align)), src: src, "data-canonical-url": urlSource, autoPlay: true,
36
38
  // For autoplay, the element needs to be muted to actually start!
37
39
  muted: true, "webkit-playsinline": "true", playsInline: true, loop: true }));
38
40
  }
39
- function Picture({ id, src, srcOptimized, urlSource, align = 'center', alt, width, height, }) {
41
+ function Picture({ className, id, src, srcOptimized, urlSource, align = 'center', alt, width, height, }) {
40
42
  if (src.endsWith('.mp4') || (urlSource === null || urlSource === void 0 ? void 0 : urlSource.endsWith('.mp4'))) {
41
- return (_jsx(Video, { id: id, width: width, height: height, align: align, src: src, urlSource: urlSource }));
43
+ return (_jsx(Video, { className: className, id: id, width: width, height: height, align: align, src: src, urlSource: urlSource }));
42
44
  }
43
45
  const image = (_jsx("img", { id: id, style: Object.assign({ width: getStyleValue(width), height: getStyleValue(height) }, alignToMargin(align)), src: src, alt: alt, "data-canonical-url": urlSource }));
44
46
  if (!srcOptimized)
45
47
  return image;
46
- return (_jsxs("picture", { children: [_jsx("source", { srcSet: srcOptimized, type: "image/webp" }), image] }));
48
+ return (_jsxs("picture", { className: className, children: [_jsx("source", { srcSet: srcOptimized, type: "image/webp" }), image] }));
47
49
  }
48
50
  export const Image = ({ node }) => {
49
- return (_jsx(Picture, { id: node.html_id || node.identifier || node.key, src: node.url, srcOptimized: node.urlOptimized, alt: node.alt || node.title, width: node.width || undefined, height: node.height || undefined, align: node.align,
51
+ return (_jsx(Picture, { className: node.class, id: node.html_id || node.identifier || node.key, src: node.url, srcOptimized: node.urlOptimized, alt: node.alt || node.title, width: node.width || undefined, height: node.height || undefined, align: node.align,
50
52
  // Note that sourceUrl is for backwards compatibility
51
53
  urlSource: node.urlSource || node.sourceUrl }));
52
54
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myst-to-react",
3
- "version": "0.9.7",
3
+ "version": "0.9.9",
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.9.7",
24
+ "@myst-theme/providers": "^0.9.9",
25
25
  "@scienceicons/react": "^0.0.6",
26
26
  "@radix-ui/react-hover-card": "^1.0.6",
27
27
  "buffer": "^6.0.3",