@rasenganjs/mdx 1.2.0-beta.7 → 1.2.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/CHANGELOG.md +4 -0
- package/dist/chunk-U2MZHTHK.js +89 -0
- package/dist/index.cjs +922 -0
- package/dist/index.d.cts +150 -0
- package/dist/index.d.ts +150 -0
- package/dist/index.js +798 -0
- package/dist/plugin.cjs +289 -0
- package/dist/plugin.d.cts +20 -0
- package/dist/plugin.d.ts +20 -0
- package/dist/plugin.js +174 -0
- package/package.json +15 -15
- package/tsup.config.ts +11 -0
- package/types/client.d.ts +1 -1
- package/lib/components/codeblock.d.ts +0 -15
- package/lib/components/codeblock.js +0 -62
- package/lib/components/codeblock.js.map +0 -1
- package/lib/components/codeblock2.d.ts +0 -14
- package/lib/components/codeblock2.js +0 -47
- package/lib/components/codeblock2.js.map +0 -1
- package/lib/components/heading.d.ts +0 -2
- package/lib/components/heading.js +0 -27
- package/lib/components/heading.js.map +0 -1
- package/lib/components/index.d.ts +0 -5
- package/lib/components/index.js +0 -8
- package/lib/components/index.js.map +0 -1
- package/lib/components/markdown.d.ts +0 -7
- package/lib/components/markdown.js +0 -28
- package/lib/components/markdown.js.map +0 -1
- package/lib/components/renderer.d.ts +0 -12
- package/lib/components/renderer.js +0 -45
- package/lib/components/renderer.js.map +0 -1
- package/lib/components/table.d.ts +0 -3
- package/lib/components/table.js +0 -5
- package/lib/components/table.js.map +0 -1
- package/lib/components/toc.d.ts +0 -7
- package/lib/components/toc.js +0 -26
- package/lib/components/toc.js.map +0 -1
- package/lib/hooks/use-toc-observer.d.ts +0 -8
- package/lib/hooks/use-toc-observer.js +0 -60
- package/lib/hooks/use-toc-observer.js.map +0 -1
- package/lib/index.d.ts +0 -13
- package/lib/index.js +0 -16
- package/lib/index.js.map +0 -1
- package/lib/styles/rasengan-mdx.min.css +0 -1
- package/lib/types/index.d.ts +0 -67
- package/lib/types/index.js +0 -2
- package/lib/types/index.js.map +0 -1
- package/lib/utils/create-filter.d.ts +0 -8
- package/lib/utils/create-filter.js +0 -23
- package/lib/utils/create-filter.js.map +0 -1
- package/lib/utils/create-heading.d.ts +0 -4
- package/lib/utils/create-heading.js +0 -19
- package/lib/utils/create-heading.js.map +0 -1
- package/lib/utils/define-mdx-config.d.ts +0 -2
- package/lib/utils/define-mdx-config.js +0 -4
- package/lib/utils/define-mdx-config.js.map +0 -1
- package/lib/utils/extract-toc.d.ts +0 -23
- package/lib/utils/extract-toc.js +0 -113
- package/lib/utils/extract-toc.js.map +0 -1
- package/lib/utils/generate-navigation.d.ts +0 -0
- package/lib/utils/generate-navigation.js +0 -75
- package/lib/utils/generate-navigation.js.map +0 -1
- package/lib/utils/index.d.ts +0 -15
- package/lib/utils/index.js +0 -4
- package/lib/utils/index.js.map +0 -1
- package/lib/utils/mark-to-html.d.ts +0 -1
- package/lib/utils/mark-to-html.js +0 -15
- package/lib/utils/mark-to-html.js.map +0 -1
- package/lib/utils/plugin.d.ts +0 -26
- package/lib/utils/plugin.js +0 -149
- package/lib/utils/plugin.js.map +0 -1
- package/lib/utils/polyfill.d.ts +0 -10
- package/lib/utils/polyfill.js +0 -15
- package/lib/utils/polyfill.js.map +0 -1
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { CodeBlockProps } from '../types/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* A React component that renders a code block with syntax highlighting and a copy button.
|
|
5
|
-
*
|
|
6
|
-
* The component uses the `prism-react-renderer` library to provide syntax highlighting for the code block.
|
|
7
|
-
* It also includes a copy button that allows the user to copy the code to their clipboard.
|
|
8
|
-
*
|
|
9
|
-
* @param {object} props - The component props.
|
|
10
|
-
* @param {string} props.children - The code content to be displayed in the code block.
|
|
11
|
-
* @param {string} [props.className] - The CSS class name to apply to the code block.
|
|
12
|
-
* @returns {React.ReactElement} - The rendered code block component.
|
|
13
|
-
*/
|
|
14
|
-
export declare const CodeBlock2: ({ children, className, ...rest }: CodeBlockProps) => React.ReactElement;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { themes, Highlight } from 'prism-react-renderer';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { SimpleBlock } from './codeblock.js';
|
|
5
|
-
/**
|
|
6
|
-
* A React component that renders a code block with syntax highlighting and a copy button.
|
|
7
|
-
*
|
|
8
|
-
* The component uses the `prism-react-renderer` library to provide syntax highlighting for the code block.
|
|
9
|
-
* It also includes a copy button that allows the user to copy the code to their clipboard.
|
|
10
|
-
*
|
|
11
|
-
* @param {object} props - The component props.
|
|
12
|
-
* @param {string} props.children - The code content to be displayed in the code block.
|
|
13
|
-
* @param {string} [props.className] - The CSS class name to apply to the code block.
|
|
14
|
-
* @returns {React.ReactElement} - The rendered code block component.
|
|
15
|
-
*/
|
|
16
|
-
export const CodeBlock2 = ({ children = '', className = '', ...rest }) => {
|
|
17
|
-
const language = className.replace(/language-/, '');
|
|
18
|
-
const [hover, setHover] = React.useState(false);
|
|
19
|
-
if (!language) {
|
|
20
|
-
return _jsx(SimpleBlock, { children: children });
|
|
21
|
-
}
|
|
22
|
-
console.log({ children, className, rest });
|
|
23
|
-
return (_jsx(Highlight, { theme: themes.oneDark, code: children.toString().trim(), language: language, children: ({ className, tokens, getLineProps, getTokenProps, ...rest }) => {
|
|
24
|
-
const [copied, setCopied] = React.useState(false);
|
|
25
|
-
React.useEffect(() => {
|
|
26
|
-
/**
|
|
27
|
-
* Sets the `copied` state to `false` after 2 seconds, effectively hiding the "copied" indicator.
|
|
28
|
-
* This function is called after the user's clipboard is updated with the code content.
|
|
29
|
-
*/
|
|
30
|
-
const timer = setTimeout(() => {
|
|
31
|
-
setCopied(false);
|
|
32
|
-
}, 2000);
|
|
33
|
-
return () => clearTimeout(timer);
|
|
34
|
-
}, [copied]);
|
|
35
|
-
/**
|
|
36
|
-
* Copies the trimmed text content of the `children` prop to the user's clipboard.
|
|
37
|
-
* This function is called when the "Copy" button is clicked in the code block component.
|
|
38
|
-
* It sets the `copied` state to `true` for 2 seconds to display a "copied" indicator.
|
|
39
|
-
*/
|
|
40
|
-
const handleCopy = () => {
|
|
41
|
-
navigator.clipboard.writeText((children ?? '').toString().trim());
|
|
42
|
-
setCopied(true);
|
|
43
|
-
};
|
|
44
|
-
return (_jsx("figure", { children: _jsx("pre", { onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), "data-language": language, children: _jsxs("div", { children: [hover ? (_jsx("button", { className: "copy-button", onClick: handleCopy, children: copied ? (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "20", height: "20", color: "#f0f0f0", fill: "none", children: [_jsx("path", { d: "M22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12Z", stroke: "currentColor", strokeWidth: "1.5" }), _jsx("path", { d: "M8 12.5L10.5 15L16 9", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] })) : (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "20", height: "20", color: "#f0f0f0", fill: "none", children: [_jsx("path", { d: "M9 15C9 12.1716 9 10.7574 9.87868 9.87868C10.7574 9 12.1716 9 15 9L16 9C18.8284 9 20.2426 9 21.1213 9.87868C22 10.7574 22 12.1716 22 15V16C22 18.8284 22 20.2426 21.1213 21.1213C20.2426 22 18.8284 22 16 22H15C12.1716 22 10.7574 22 9.87868 21.1213C9 20.2426 9 18.8284 9 16L9 15Z", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), _jsx("path", { d: "M16.9999 9C16.9975 6.04291 16.9528 4.51121 16.092 3.46243C15.9258 3.25989 15.7401 3.07418 15.5376 2.90796C14.4312 2 12.7875 2 9.5 2C6.21252 2 4.56878 2 3.46243 2.90796C3.25989 3.07417 3.07418 3.25989 2.90796 3.46243C2 4.56878 2 6.21252 2 9.5C2 12.7875 2 14.4312 2.90796 15.5376C3.07417 15.7401 3.25989 15.9258 3.46243 16.092C4.51121 16.9528 6.04291 16.9975 9 16.9999", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] })) })) : (_jsx("span", { className: "lang", children: language })), _jsx("code", { className: `${className} code-block`, "data-line-numbers": true, children: tokens.map((line, i) => (_jsxs("span", { "data-line": true, ...getLineProps({ line }), children: [_jsx("span", { children: " " }), line.map((token, key) => (_jsx("span", { ...getTokenProps({ token }) }, key)))] }, i))) })] }) }) }));
|
|
45
|
-
} }));
|
|
46
|
-
};
|
|
47
|
-
//# sourceMappingURL=codeblock2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codeblock2.js","sourceRoot":"","sources":["../../src/components/codeblock2.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,QAAQ,GAAG,EAAE,EACb,SAAS,GAAG,EAAE,EACd,GAAG,IAAI,EACQ,EAAsB,EAAE;IACvC,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACpD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,KAAC,WAAW,cAAE,QAAQ,GAAe,CAAC;IAC/C,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CA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C;AACJ,CAAC,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { createElement, useMemo } from 'react';
|
|
3
|
-
import { generateAnchor } from '../utils/extract-toc.js';
|
|
4
|
-
export const Heading = ({ variant }) => {
|
|
5
|
-
return ({ children }) => {
|
|
6
|
-
const { text, id } = useMemo(() => {
|
|
7
|
-
const { id, text } = generateAnchor(children);
|
|
8
|
-
return {
|
|
9
|
-
id: variant === 'h1' ? undefined : id,
|
|
10
|
-
text,
|
|
11
|
-
};
|
|
12
|
-
}, [children]);
|
|
13
|
-
const heading = createElement(variant, {
|
|
14
|
-
id,
|
|
15
|
-
className: 'heading',
|
|
16
|
-
children: text,
|
|
17
|
-
});
|
|
18
|
-
const handleClick = (e, id) => {
|
|
19
|
-
e.preventDefault();
|
|
20
|
-
const element = document.getElementById(id);
|
|
21
|
-
element?.scrollIntoView({ behavior: 'smooth' });
|
|
22
|
-
history.pushState(null, '', `#${id}`); // Update the URL
|
|
23
|
-
};
|
|
24
|
-
return (_jsxs("div", { className: "ra-heading-wrapper", children: [heading, id && (_jsx("a", { href: `#${id}`, onClick: (e) => handleClick(e, id), children: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", color: "#ffffff", fill: "none", children: [_jsx("path", { d: "M10 13.229C10.1416 13.4609 10.3097 13.6804 10.5042 13.8828C11.7117 15.1395 13.5522 15.336 14.9576 14.4722C15.218 14.3121 15.4634 14.1157 15.6872 13.8828L18.9266 10.5114C20.3578 9.02184 20.3578 6.60676 18.9266 5.11718C17.4953 3.6276 15.1748 3.62761 13.7435 5.11718L13.03 5.85978", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }), _jsx("path", { d: "M10.9703 18.14L10.2565 18.8828C8.82526 20.3724 6.50471 20.3724 5.07345 18.8828C3.64218 17.3932 3.64218 14.9782 5.07345 13.4886L8.31287 10.1172C9.74413 8.62761 12.0647 8.6276 13.4959 10.1172C13.6904 10.3195 13.8584 10.539 14 10.7708", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })] }) }))] }));
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=heading.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"heading.js","sourceRoot":"","sources":["../../src/components/heading.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EAAE,OAAO,EAAgB,EAAE,EAAE;IACnD,OAAO,CAAC,EAAE,QAAQ,EAAiB,EAAE,EAAE;QACrC,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE;YAChC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;YAE9C,OAAO;gBACL,EAAE,EAAE,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;gBACrC,IAAI;aACL,CAAC;QACJ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;QAEf,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,EAAE;YACrC,EAAE;YACF,SAAS,EAAE,SAAS;YACpB,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,CAClB,CAAkD,EAClD,EAAU,EACV,EAAE;YACF,CAAC,CAAC,cAAc,EAAE,CAAC;YAEnB,MAAM,OAAO,GAAG,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;YAC5C,OAAO,EAAE,cAAc,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YAEhD,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB;QAC1D,CAAC,CAAC;QAEF,OAAO,CACL,eAAK,SAAS,EAAC,oBAAoB,aAChC,OAAO,EACP,EAAE,IAAI,CACL,YAAG,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE,EAAE,CAAC,YACnD,eACE,KAAK,EAAC,4BAA4B,EAClC,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,KAAK,EAAC,SAAS,EACf,IAAI,EAAC,MAAM,aAEX,eACE,CAAC,EAAC,uRAAuR,EACzR,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EACjB,aAAa,EAAC,OAAO,GACrB,EACF,eACE,CAAC,EAAC,yOAAyO,EAC3O,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EACjB,aAAa,EAAC,OAAO,GACrB,IACE,GACJ,CACL,IACG,CACP,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/lib/components/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Import statements
|
|
2
|
-
import { MDXRenderer } from './renderer.js';
|
|
3
|
-
import { Markdown } from './markdown.js';
|
|
4
|
-
import { TableOfContents } from './toc.js';
|
|
5
|
-
import { CodeBlock } from './codeblock.js';
|
|
6
|
-
// Export statements
|
|
7
|
-
export { Markdown, MDXRenderer, TableOfContents, CodeBlock };
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,oBAAoB;AACpB,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
declare function Markdown({ content, className, overwriteStyle, }: {
|
|
3
|
-
content: string;
|
|
4
|
-
className?: React.ComponentProps<'section'>['className'];
|
|
5
|
-
overwriteStyle?: boolean;
|
|
6
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export { Markdown };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Table } from './table.js';
|
|
3
|
-
import { Heading } from './heading.js';
|
|
4
|
-
import MarkdownComponent from 'react-markdown';
|
|
5
|
-
import remarkGfm from 'remark-gfm';
|
|
6
|
-
import rehypeStringify from 'rehype-stringify';
|
|
7
|
-
import remarkParse from 'remark-parse';
|
|
8
|
-
import remarkRehype from 'remark-rehype';
|
|
9
|
-
// import rehypePrettyCode from "rehype-pretty-code";
|
|
10
|
-
import { CodeBlock2 } from './codeblock2.js';
|
|
11
|
-
function Markdown({ content, className, overwriteStyle, }) {
|
|
12
|
-
return (_jsx("section", { className: `${className} ${overwriteStyle ? '' : 'rasengan-markdown-body'}`, children: _jsx(MarkdownComponent, { children: content, remarkPlugins: [remarkParse, remarkGfm], rehypePlugins: [
|
|
13
|
-
remarkRehype,
|
|
14
|
-
rehypeStringify,
|
|
15
|
-
// rehypePrettyCode
|
|
16
|
-
], components: {
|
|
17
|
-
code: CodeBlock2,
|
|
18
|
-
table: Table,
|
|
19
|
-
h1: Heading({ variant: 'h1' }),
|
|
20
|
-
h2: Heading({ variant: 'h2' }),
|
|
21
|
-
h3: Heading({ variant: 'h3' }),
|
|
22
|
-
h4: Heading({ variant: 'h4' }),
|
|
23
|
-
h5: Heading({ variant: 'h5' }),
|
|
24
|
-
h6: Heading({ variant: 'h6' }),
|
|
25
|
-
} }) }));
|
|
26
|
-
}
|
|
27
|
-
export { Markdown };
|
|
28
|
-
//# sourceMappingURL=markdown.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/components/markdown.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,iBAAiB,MAAM,gBAAgB,CAAC;AAC/C,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,qDAAqD;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,SAAS,QAAQ,CAAC,EAChB,OAAO,EACP,SAAS,EACT,cAAc,GAKf;IACC,OAAO,CACL,kBACE,SAAS,EAAE,GAAG,SAAS,IAAI,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,wBAAwB,EAAE,YAE3E,KAAC,iBAAiB,IAChB,QAAQ,EAAE,OAAO,EACjB,aAAa,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,EACvC,aAAa,EAAE;gBACb,YAAY;gBACZ,eAAe;gBACf,mBAAmB;aACpB,EACD,UAAU,EAAE;gBACV,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,KAAK;gBACZ,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBAC9B,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBAC9B,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBAC9B,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBAC9B,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBAC9B,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;aAC/B,GACD,GACM,CACX,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { MDXRendererProps } from '../types/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Renders an MDX content component with a custom code block component.
|
|
5
|
-
*
|
|
6
|
-
* @param {MDXRendererProps} props - The props for the MDX renderer.
|
|
7
|
-
* @param {React.ReactNode} props.children - The MDX content to render.
|
|
8
|
-
* @param {string} [props.className] - An optional CSS class name to apply to the rendered section.
|
|
9
|
-
* @returns {React.ReactElement} - The rendered MDX content with the custom code block component.
|
|
10
|
-
*/
|
|
11
|
-
declare const MDXRenderer: ({ children: MDXContent, className, config, toc: originalTocData, }: MDXRendererProps) => React.ReactElement;
|
|
12
|
-
export { MDXRenderer };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { CodeBlock } from './codeblock.js';
|
|
3
|
-
import { Table } from './table.js';
|
|
4
|
-
import { Heading } from './heading.js';
|
|
5
|
-
import TableOfContents from './toc.js';
|
|
6
|
-
import createHeading from '../utils/create-heading.js';
|
|
7
|
-
/**
|
|
8
|
-
* Renders an MDX content component with a custom code block component.
|
|
9
|
-
*
|
|
10
|
-
* @param {MDXRendererProps} props - The props for the MDX renderer.
|
|
11
|
-
* @param {React.ReactNode} props.children - The MDX content to render.
|
|
12
|
-
* @param {string} [props.className] - An optional CSS class name to apply to the rendered section.
|
|
13
|
-
* @returns {React.ReactElement} - The rendered MDX content with the custom code block component.
|
|
14
|
-
*/
|
|
15
|
-
const MDXRenderer = ({ children: MDXContent, className, config,
|
|
16
|
-
// TOC Extracted from the original MDX file
|
|
17
|
-
toc: originalTocData, }) => {
|
|
18
|
-
const { components = {}, toc: customTocFunction = undefined } = config;
|
|
19
|
-
return (_jsxs("section", { className: originalTocData ? 'rasengan-wrapper-with-toc' : 'rasengan-wrapper', children: [_jsx("section", { className: 'rasengan-markdown-body ' + className, children: _jsx(MDXContent, { components: {
|
|
20
|
-
...components,
|
|
21
|
-
code: components.code ? components.code : CodeBlock,
|
|
22
|
-
table: components.table ? components.table : Table,
|
|
23
|
-
h1: components.h1
|
|
24
|
-
? createHeading(components.h1)
|
|
25
|
-
: Heading({ variant: 'h1' }),
|
|
26
|
-
h2: components.h2
|
|
27
|
-
? createHeading(components.h2)
|
|
28
|
-
: Heading({ variant: 'h2' }),
|
|
29
|
-
h3: components.h3
|
|
30
|
-
? createHeading(components.h3)
|
|
31
|
-
: Heading({ variant: 'h3' }),
|
|
32
|
-
h4: components.h4
|
|
33
|
-
? createHeading(components.h4)
|
|
34
|
-
: Heading({ variant: 'h4' }),
|
|
35
|
-
h5: components.h5
|
|
36
|
-
? createHeading(components.h5)
|
|
37
|
-
: Heading({ variant: 'h5' }),
|
|
38
|
-
h6: components.h6
|
|
39
|
-
? createHeading(components.h6)
|
|
40
|
-
: Heading({ variant: 'h6' }),
|
|
41
|
-
} }) }), originalTocData &&
|
|
42
|
-
(customTocFunction ? (customTocFunction(originalTocData)) : (_jsx(TableOfContents, { items: originalTocData })))] }));
|
|
43
|
-
};
|
|
44
|
-
export { MDXRenderer };
|
|
45
|
-
//# sourceMappingURL=renderer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../src/components/renderer.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY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AE,IAAI,EAAE,CAAC;wBAC9B,EAAE,EAAE,UAAU,CAAC,EAAE;4BACf,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;4BAC9B,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wBAC9B,EAAE,EAAE,UAAU,CAAC,EAAE;4BACf,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;4BAC9B,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wBAC9B,EAAE,EAAE,UAAU,CAAC,EAAE;4BACf,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;4BAC9B,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qBAC/B,GACD,GACM,EAET,eAAe;gBACd,CAAC,iBAAiB,CAAC,CAAC,CAAC,CACnB,iBAAiB,CAAC,eAAe,CAAC,CACnC,CAAC,CAAC,CAAC,CACF,KAAC,eAAe,IAAC,KAAK,EAAE,eAAe,GAAI,CAC5C,CAAC,IACI,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
package/lib/components/table.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../src/components/table.tsx"],"names":[],"mappings":";AAGA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EACpB,QAAQ,GACuB,EAAsB,EAAE;IACvD,OAAO,CACL,cAAK,SAAS,EAAC,kBAAkB,YAC/B,0BAAQ,QAAQ,GAAS,GACrB,CACP,CAAC;AACJ,CAAC,CAAC"}
|
package/lib/components/toc.d.ts
DELETED
package/lib/components/toc.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { useCallback } from 'react';
|
|
3
|
-
import { useActiveTocItem } from '../hooks/use-toc-observer.js';
|
|
4
|
-
export const TableOfContents = ({ items }) => {
|
|
5
|
-
const [activeId, setActiveId] = useActiveTocItem(items);
|
|
6
|
-
const renderTOCItems = useCallback((items) => {
|
|
7
|
-
return items.map((item, index) => (_jsxs(React.Fragment, { children: [_jsx(Item, { item: item, activeId: activeId, onActive: setActiveId }), item.children && item.children.length > 0 && (_jsx("div", { className: "toc-item--children", children: renderTOCItems(item.children) }))] }, index)));
|
|
8
|
-
}, [items, activeId]);
|
|
9
|
-
return (_jsx("aside", { className: "rasengan-toc", children: _jsxs("div", { className: "table-of-contents", children: [_jsx("h2", { className: "title", children: "ON THIS PAGE" }), _jsx("div", { className: "items-container", children: renderTOCItems(items) })] }) }));
|
|
10
|
-
};
|
|
11
|
-
const Item = ({ item, activeId, onActive }) => {
|
|
12
|
-
const handleClick = (e, id) => {
|
|
13
|
-
e.preventDefault();
|
|
14
|
-
onActive(id);
|
|
15
|
-
const element = document.getElementById(id);
|
|
16
|
-
element?.scrollIntoView({ behavior: 'smooth' });
|
|
17
|
-
history.pushState(null, '', `#${id}`); // Update the URL
|
|
18
|
-
};
|
|
19
|
-
return (_jsx("div", { className: `
|
|
20
|
-
toc-item
|
|
21
|
-
${item.level === 2 ? 'level2' : 'level3'}
|
|
22
|
-
${activeId === item.anchor.id ? 'active' : ''}
|
|
23
|
-
`, children: _jsx("a", { href: `#${item.anchor.id}`, onClick: (e) => handleClick(e, item.anchor.id), children: _jsx("div", { className: "toc-item--title", children: item.anchor.text }) }) }, item.anchor.id));
|
|
24
|
-
};
|
|
25
|
-
export default TableOfContents;
|
|
26
|
-
//# sourceMappingURL=toc.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toc.js","sourceRoot":"","sources":["../../src/components/toc.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAA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,EAAE,cAAc,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEhD,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB;IAC1D,CAAC,CAAC;IAEF,OAAO,CACL,cAEE,SAAS,EAAE;;YAEL,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;YACtC,QAAQ,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;SAC9C,YAEH,YACE,IAAI,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,EAC1B,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,YAE9C,cAAK,SAAS,EAAC,iBAAiB,YAAE,IAAI,CAAC,MAAM,CAAC,IAAI,GAAO,GACvD,IAZC,IAAI,CAAC,MAAM,CAAC,EAAE,CAaf,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { TOCItem } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Custom hook that tracks which TOC item is currently active based on scroll position
|
|
4
|
-
* @param items - Array of TOC items to observe
|
|
5
|
-
* @param options - IntersectionObserver options
|
|
6
|
-
* @returns The ID of the currently active TOC item
|
|
7
|
-
*/
|
|
8
|
-
export declare function useActiveTocItem(items: TOCItem[], options?: IntersectionObserverInit): [string | null, (id: string | null) => void];
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect, useRef } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Custom hook that tracks which TOC item is currently active based on scroll position
|
|
4
|
-
* @param items - Array of TOC items to observe
|
|
5
|
-
* @param options - IntersectionObserver options
|
|
6
|
-
* @returns The ID of the currently active TOC item
|
|
7
|
-
*/
|
|
8
|
-
export function useActiveTocItem(items, options = {
|
|
9
|
-
root: null,
|
|
10
|
-
rootMargin: '0px',
|
|
11
|
-
threshold: 0.4, // Trigger when 40% of the section is visible
|
|
12
|
-
}) {
|
|
13
|
-
const [activeId, setActiveId] = useState(null);
|
|
14
|
-
const observerRef = useRef(null);
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
observerRef.current = new IntersectionObserver((entries) => {
|
|
17
|
-
entries.forEach((entry) => {
|
|
18
|
-
if (entry.isIntersecting) {
|
|
19
|
-
const rect = entry.boundingClientRect;
|
|
20
|
-
if (rect.top >= 0) {
|
|
21
|
-
setActiveId(entry.target.id);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
// Sort entries by bottom position when scrolling down
|
|
26
|
-
const sortedEntries = entries
|
|
27
|
-
.filter((entry) => entry.isIntersecting)
|
|
28
|
-
.sort((a, b) => b.boundingClientRect.top - a.boundingClientRect.top);
|
|
29
|
-
if (sortedEntries.length > 0) {
|
|
30
|
-
setActiveId(sortedEntries[0].target.id);
|
|
31
|
-
}
|
|
32
|
-
}, options);
|
|
33
|
-
// Observe all sections with IDs matching TOC anchors
|
|
34
|
-
const observeElements = () => {
|
|
35
|
-
items.forEach((item) => {
|
|
36
|
-
// Observe items of level 2
|
|
37
|
-
const element = document.getElementById(item.anchor.id);
|
|
38
|
-
if (element && observerRef.current) {
|
|
39
|
-
observerRef.current.observe(element);
|
|
40
|
-
}
|
|
41
|
-
// Observe items of level 3
|
|
42
|
-
item.children?.forEach((child) => {
|
|
43
|
-
const childElement = document.getElementById(child.anchor.id);
|
|
44
|
-
if (childElement && observerRef.current) {
|
|
45
|
-
observerRef.current.observe(childElement);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
observeElements();
|
|
51
|
-
// Cleanup observer on unmount
|
|
52
|
-
return () => {
|
|
53
|
-
if (observerRef.current) {
|
|
54
|
-
observerRef.current.disconnect();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}, [items, options]);
|
|
58
|
-
return [activeId, setActiveId];
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=use-toc-observer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-toc-observer.js","sourceRoot":"","sources":["../../src/hooks/use-toc-observer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGpD;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAgB,EAChB,UAAoC;IAClC,IAAI,EAAE,IAAI;IACV,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,GAAG,EAAE,6CAA6C;CAC9D;IAED,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,MAAM,CAA8B,IAAI,CAAC,CAAC;IAE9D,SAAS,CAAC,GAAG,EAAE;QACb,WAAW,CAAC,OAAO,GAAG,IAAI,oBAAoB,CAAC,CAAC,OAAO,EAAE,EAAE;YACzD,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;gBACxB,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;oBACzB,MAAM,IAAI,GAAG,KAAK,CAAC,kBAAkB,CAAC;oBACtC,IAAI,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;wBAClB,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;oBAC/B,CAAC;gBACH,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,sDAAsD;YACtD,MAAM,aAAa,GAAG,OAAO;iBAC1B,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC;iBACvC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CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IAErB,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AACjC,CAAC"}
|
package/lib/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* License: MIT
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2024 Dilane Kombou
|
|
5
|
-
*
|
|
6
|
-
* This package is inspired by @mdx-js/rollup to provide a custom implement of the MDX plugin for RasenganJs.
|
|
7
|
-
*/
|
|
8
|
-
import { extractTOC } from './utils/extract-toc.js';
|
|
9
|
-
import { defineMDXConfig } from './utils/define-mdx-config.js';
|
|
10
|
-
export * from './types/index.js';
|
|
11
|
-
export * from './components/index.js';
|
|
12
|
-
export { extractTOC, defineMDXConfig };
|
|
13
|
-
export { useActiveTocItem } from './hooks/use-toc-observer.js';
|
package/lib/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* License: MIT
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2024 Dilane Kombou
|
|
5
|
-
*
|
|
6
|
-
* This package is inspired by @mdx-js/rollup to provide a custom implement of the MDX plugin for RasenganJs.
|
|
7
|
-
*/
|
|
8
|
-
// Import statements
|
|
9
|
-
import { extractTOC } from './utils/extract-toc.js';
|
|
10
|
-
import { defineMDXConfig } from './utils/define-mdx-config.js';
|
|
11
|
-
// Export statements
|
|
12
|
-
export * from './types/index.js';
|
|
13
|
-
export * from './components/index.js';
|
|
14
|
-
export { extractTOC, defineMDXConfig };
|
|
15
|
-
export { useActiveTocItem } from './hooks/use-toc-observer.js';
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oBAAoB;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,oBAAoB;AACpB,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
:root{--bg:transparent;--bg-light:#f5f5f5;--bg-code:#282c34;--bg-code-highlight:#30313e;--bg-code-highlight-2:#494c54;--fg:#333;--fg-code:#adbac7;--fg-light:#666;--fg-dark:#000;--fg-accent:#007bff;--border:#eee;--border-dark:#494c54;--table-border:#d1d5dc;--container-2xs:18rem;--text-3xl:1.875rem;--text-2xl:1.5rem;--text-xl:1.25rem;--text-lg:1.125rem;--text-md:1rem;--text-sm:0.875rem;--ra-spacing:0.25;--mb-3xl:calc(var(--text-3xl) * var(--ra-spacing));--mb-2xl:calc(var(--text-2xl) * var(--ra-spacing));--mb-xl:calc(var(--text-xl) * var(--ra-spacing));--mb-lg:calc(var(--text-lg) * var(--ra-spacing));--mb-md:calc(var(--text-md) * var(--ra-spacing));--mb-sm:calc(var(--text-sm) * var(--ra-spacing))}.dark{--bg:#212121;--bg-light:#30313e55;--bg-code:#282c34;--bg-code-highlight:#30313e;--fg:#eee;--fg-code:#abb2bf;--fg-light:#ccc;--fg-dark:#fff;--fg-accent:#007bff;--border:#2f2f2f;--border-dark:#494c54;--table-border:#4b5563}.rasengan-wrapper,.rasengan-wrapper-with-toc{position:relative}.rasengan-wrapper-with-toc{margin-left:auto;margin-right:auto;display:grid;width:100%;grid-template-columns:1fr;gap:2.5rem;padding-left:2.5rem}.rasengan-markdown-body{width:100%;position:relative;box-sizing:border-box;margin:0;font-weight:400;padding-left:1rem;padding-right:1rem;padding-top:2.5rem;padding-bottom:6rem}.rasengan-toc>.table-of-contents{position:sticky;top:3.5rem;max-height:calc(100vh - 3.5rem);overflow-x:hidden;padding-left:1.5rem;padding-right:1.5rem;padding-top:2.5rem;padding-bottom:6rem}.rasengan-toc>.table-of-contents .title{font-size:.675rem;margin-bottom:1rem;color:var(--fg-dark)}.rasengan-toc>.table-of-contents .items-container{display:flex;flex-direction:column}.rasengan-toc>.table-of-contents .toc-item{cursor:pointer;padding-left:.5rem;border-left:1px solid var(--border);transition:all .2s ease;color:var(--fg)}.rasengan-toc>.table-of-contents .toc-item:hover{border-left-color:var(--fg-accent);color:var(--fg-accent)}.rasengan-toc>.table-of-contents .toc-item.active{border-left-color:var(--fg-accent);color:var(--fg-accent)}.rasengan-toc>.table-of-contents .toc-item.active .toc-item--title{font-weight:700}.rasengan-toc>.table-of-contents .toc-item--title{font-size:.875rem;padding-top:.25rem;padding-bottom:.25rem}.rasengan-toc>.table-of-contents .level2{padding-left:1rem}.rasengan-toc>.table-of-contents .level3{padding-left:2rem}.rasengan-markdown-body .ra-heading-wrapper{display:flex;align-items:center;justify-content:start}.rasengan-markdown-body .ra-heading-wrapper:has(h1){margin-bottom:1rem;font-size:var(--text-3xl);font-weight:700}.rasengan-markdown-body .ra-heading-wrapper:has(h2){font-size:var(--text-2xl);border-bottom:1px solid var(--border);margin-bottom:1rem;margin-top:2rem;font-weight:700}.rasengan-markdown-body .ra-heading-wrapper:has(h3){font-size:var(--text-xl);margin-bottom:var(--mb-xl);margin-top:2rem;font-weight:700}.rasengan-markdown-body .ra-heading-wrapper:has(h4){font-size:var(--text-lg);margin-bottom:var(--mb-lg);margin-top:2rem;font-weight:700}.rasengan-markdown-body .ra-heading-wrapper:has(h5){font-size:var(--text-md);margin-bottom:var(--mb-md);margin-top:2rem;font-weight:700}.rasengan-markdown-body .ra-heading-wrapper:has(h6){font-size:var(--text-sm);margin-bottom:var(--mb-sm);margin-top:2rem;font-weight:700}.rasengan-markdown-body .ra-heading-wrapper a{margin:.67em 0;margin-left:.5em;color:var(--border);opacity:0;transition:all .3s}.rasengan-markdown-body .ra-heading-wrapper a>svg{color:var(--fg)}.rasengan-markdown-body .ra-heading-wrapper a:hover>svg{color:var(--fg-accent)}.rasengan-markdown-body .ra-heading-wrapper:has(h2) a{font-size:2em;text-decoration:none}.rasengan-markdown-body .ra-heading-wrapper:has(h3) a{font-size:1.5em;text-decoration:none}.rasengan-markdown-body .ra-heading-wrapper:has(h4) a{font-size:1em;text-decoration:none}.rasengan-markdown-body .ra-heading-wrapper:hover a{opacity:1;cursor:pointer}.rasengan-markdown-body .ra-heading-wrapper:hover a:hover{transform:scale(1.1)}.rasengan-markdown-body h2:hover::after,.rasengan-markdown-body h3:hover::after,.rasengan-markdown-body h4:hover::after{opacity:1;cursor:pointer}.rasengan-markdown-body hr{color:var(--border);margin:var(--mb-sm) 0}.rasengan-markdown-body code.simple-block{font-size:.8em;font-family:'JetBrains Mono',monospace;border-radius:5px;padding:2px 3.6px;margin:auto 0;background-color:var(--bg-light);border:1px solid var(--border)}.rasengan-markdown-body figure:has(pre[data-language]){background-color:var(--bg-code);border-radius:8px;margin:10px 0;color:var(--fg-code);border:1px solid var(--border);overflow:hidden}.rasengan-markdown-body figure:has(pre[data-language]) figcaption{padding:10px 20px;font-size:14px;font-weight:400;background-color:var(--bg-code-highlight);border-bottom:1px solid var(--border-dark)}.rasengan-markdown-body code[data-line-numbers]{counter-reset:line}.rasengan-markdown-body pre[data-language]{position:relative;border-radius:8px;border:none;margin:0}.rasengan-markdown-body pre[data-language] code{font-family:'JetBrains Mono',monospace;font-size:14px;overflow-x:auto}.rasengan-markdown-body pre[data-language]>div code{display:grid;grid-template-columns:1fr;line-height:1.6;word-wrap:break-word;padding:16px 0}.rasengan-markdown-body pre[data-language] code>span{padding:0 16px;border-left:4px solid transparent}.rasengan-markdown-body pre[data-language] code[data-line-numbers]>span{padding:0 5px}.rasengan-markdown-body pre[data-language] mark[data-highlighted-chars]{background-color:var(--bg-code-highlight-2);border-radius:5px;padding:0 5px}.rasengan-markdown-body pre[data-language] span[data-highlighted-line]{background-color:var(--bg-code-highlight);border-left:4px solid var(--fg-accent)}.rasengan-markdown-body code[data-line-numbers] span[data-line]:before{counter-increment:line;content:counter(line);display:inline-block;width:2ch;color:#6a737d;text-align:right;margin-right:16px;opacity:.9}.rasengan-markdown-body code.code-block{position:relative;display:block;padding:20px 0;font-size:14px;max-height:800px;overflow:auto}.rasengan-markdown-body pre[data-language] button,.rasengan-markdown-body pre[data-language] span.lang{position:absolute;top:15px;right:15px;transition:all .2s;z-index:10}.rasengan-markdown-body pre[data-language] span.lang{font-size:12px;opacity:.8;color:var(--fg-code);padding:2px 5px;border-radius:5px;background-color:var(--bg-code-highlight);border:1px solid var(--border-dark)}.rasengan-markdown-body pre[data-language] code{font-family:'JetBrains Mono',monospace}.rasengan-markdown-body pre[data-language] button{opacity:.6;cursor:pointer;width:24px;height:24px;border-radius:5px;border:1px solid var(--border-dark);background-color:var(--bg-code-highlight);display:flex;align-items:center;justify-content:center}.rasengan-markdown-body pre[data-language]:hover>div button:hover{opacity:1}.rasengan-markdown-body .ra-table-wrapper{overflow-x:auto}.rasengan-markdown-body .ra-table-wrapper table{border-collapse:collapse;color:var(--fg);margin:.67em 0;width:100%;min-width:600px;overflow-x:auto}.rasengan-markdown-body .ra-table-wrapper th{background-color:transparent;color:var(--fg);font-weight:700}.rasengan-markdown-body .ra-table-wrapper td,.rasengan-markdown-body .ra-table-wrapper th{padding:10px 20px;border:1px solid var(--border);transition:all .3s;cursor:pointer}.rasengan-markdown-body .ra-table-wrapper tr:nth-child(2n){background-color:var(--bg-light)}.rasengan-markdown-body .ra-table-wrapper tr:nth-child(odd){background-color:transparent}.rasengan-markdown-body .ra-table-wrapper tr:hover{background-color:var(--bg-light)}.rasengan-markdown-body ul{list-style:disc}.rasengan-markdown-body ul:has(li > input){list-style:none}.rasengan-markdown-body ol li input,.rasengan-markdown-body ul li input{margin-right:.3em}.rasengan-markdown-body ol li input:checked,.rasengan-markdown-body ul li input{background-color:var(--fg-accent);color:var(--bg)}.rasengan-markdown-body blockquote{border-left:4px solid var(--border);padding-left:1em;margin:1em 0}.rasengan-markdown-body blockquote p{margin:0}@media (min-width:1280px){.rasengan-wrapper-with-toc{grid-template-columns:minmax(0,1fr) var(--container-2xs)}.rasengan-markdown-body{padding-right:0;max-width:50rem;margin:0 auto}}@media (max-width:1279px){.rasengan-wrapper-with-toc>.rasengan-toc{display:none}.rasengan-wrapper-with-toc{display:block;padding-left:0}}@media (min-width:640px){.rasengan-markdown-body{padding-left:1.5rem;padding-right:1.5rem}}
|
package/lib/types/index.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { type Metadata } from 'rasengan';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
/**
|
|
4
|
-
* A React functional component that represents an MDX page.
|
|
5
|
-
*
|
|
6
|
-
* The `MDXPageComponent` type extends the `React.FC<ReactComponentProps>` type, which means it is a React functional component that accepts the standard props for a React component.
|
|
7
|
-
*
|
|
8
|
-
* The `MDXPageComponent` type also has an optional `metadata` property of type `Metadata`, which can be used to store metadata about the page.
|
|
9
|
-
*/
|
|
10
|
-
export type MDXPageComponent = React.FC<any> & {
|
|
11
|
-
metadata?: {
|
|
12
|
-
path: string;
|
|
13
|
-
metadata: Metadata;
|
|
14
|
-
};
|
|
15
|
-
toc?: Array<TOCItem>;
|
|
16
|
-
};
|
|
17
|
-
export type TOCItem = {
|
|
18
|
-
title: string;
|
|
19
|
-
anchor: {
|
|
20
|
-
id: string;
|
|
21
|
-
text: React.ReactNode;
|
|
22
|
-
};
|
|
23
|
-
level: 2 | 3;
|
|
24
|
-
children: Array<Omit<TOCItem, 'children'>>;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* A React functional component that represents a simple block element.
|
|
28
|
-
*/
|
|
29
|
-
export type ComponentWithTextChildrenProps = {
|
|
30
|
-
children: React.ReactNode;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* A React functional component that represents a simple block element.
|
|
34
|
-
*/
|
|
35
|
-
export type MDXRendererProps = {
|
|
36
|
-
children: MDXPageComponent;
|
|
37
|
-
className?: string;
|
|
38
|
-
config?: MDXConfigProps;
|
|
39
|
-
toc?: Array<TOCItem>;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* A React functional component that represents a simple block element.
|
|
43
|
-
*/
|
|
44
|
-
export type CodeBlockProps = ComponentWithTextChildrenProps & {
|
|
45
|
-
className?: string;
|
|
46
|
-
};
|
|
47
|
-
export type HeadingProps = {
|
|
48
|
-
variant: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
49
|
-
};
|
|
50
|
-
export type HeadingProps2 = ComponentWithTextChildrenProps & {
|
|
51
|
-
className?: string;
|
|
52
|
-
};
|
|
53
|
-
export type NavigationStructure = {
|
|
54
|
-
title: string;
|
|
55
|
-
link: string;
|
|
56
|
-
level: number;
|
|
57
|
-
children?: NavigationStructure[];
|
|
58
|
-
};
|
|
59
|
-
type TOCConfig = (toc: Array<TOCItem>) => React.ReactNode;
|
|
60
|
-
type ComponentConfig = {
|
|
61
|
-
[Key in Extract<React.ElementType, string>]?: React.ElementType<React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement>>;
|
|
62
|
-
};
|
|
63
|
-
export type MDXConfigProps = {
|
|
64
|
-
components?: ComponentConfig;
|
|
65
|
-
toc?: TOCConfig;
|
|
66
|
-
};
|
|
67
|
-
export {};
|
package/lib/types/index.js
DELETED
package/lib/types/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a filter function that can be used to filter a list of IDs based on include and exclude patterns.
|
|
3
|
-
*
|
|
4
|
-
* @param include - A string or array of strings representing the patterns to include.
|
|
5
|
-
* @param exclude - A string or array of strings representing the patterns to exclude.
|
|
6
|
-
* @returns A function that takes an ID string and returns `true` if the ID should be included, `false` otherwise.
|
|
7
|
-
*/
|
|
8
|
-
export default function createFilter(include: string, exclude?: string): (id: string) => boolean;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import micromatch from 'micromatch';
|
|
2
|
-
/**
|
|
3
|
-
* Creates a filter function that can be used to filter a list of IDs based on include and exclude patterns.
|
|
4
|
-
*
|
|
5
|
-
* @param include - A string or array of strings representing the patterns to include.
|
|
6
|
-
* @param exclude - A string or array of strings representing the patterns to exclude.
|
|
7
|
-
* @returns A function that takes an ID string and returns `true` if the ID should be included, `false` otherwise.
|
|
8
|
-
*/
|
|
9
|
-
export default function createFilter(include, exclude) {
|
|
10
|
-
return function (id) {
|
|
11
|
-
if (typeof id !== 'string')
|
|
12
|
-
return false;
|
|
13
|
-
const matcher = micromatch.matcher(include);
|
|
14
|
-
if (exclude) {
|
|
15
|
-
const excluder = micromatch.matcher(exclude);
|
|
16
|
-
return matcher(id) && !excluder(id);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return matcher(id);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=create-filter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-filter.js","sourceRoot":"","sources":["../../src/utils/create-filter.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,OAAe,EAAE,OAAgB;IACpE,OAAO,UAAU,EAAU;QACzB,IAAI,OAAO,EAAE,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAEzC,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAE5C,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC7C,OAAO,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,OAAO,OAAO,CAAC,EAAE,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { generateAnchor } from './extract-toc.js';
|
|
3
|
-
export default function createHeading(CustomHeading) {
|
|
4
|
-
return ({ children }) => {
|
|
5
|
-
const { id, text } = generateAnchor(children);
|
|
6
|
-
// const handleClick = (
|
|
7
|
-
// e: React.MouseEvent<HTMLAnchorElement, MouseEvent>,
|
|
8
|
-
// id: string
|
|
9
|
-
// ) => {
|
|
10
|
-
// e.preventDefault();
|
|
11
|
-
// const element = document.getElementById(id);
|
|
12
|
-
// element?.scrollIntoView({ behavior: 'smooth' });
|
|
13
|
-
// history.pushState(null, '', `#${id}`); // Update the URL
|
|
14
|
-
// };
|
|
15
|
-
// return <CustomHeading id={id} onClickAnchor={handleClick}>{text}</CustomHeading>;
|
|
16
|
-
return _jsx(CustomHeading, { id: id, children: text });
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=create-heading.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-heading.js","sourceRoot":"","sources":["../../src/utils/create-heading.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,aAAiD;IAEjD,OAAO,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;QACtB,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;QAE9C,wBAAwB;QACxB,wDAAwD;QACxD,eAAe;QACf,SAAS;QACT,wBAAwB;QAExB,iDAAiD;QACjD,qDAAqD;QAErD,6DAA6D;QAC7D,KAAK;QAEL,oFAAoF;QACpF,OAAO,KAAC,aAAa,IAAC,EAAE,EAAE,EAAE,YAAG,IAAI,GAAiB,CAAC;IACvD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-mdx-config.js","sourceRoot":"","sources":["../../src/utils/define-mdx-config.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,MAAsB;IACpD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TOCItem } from '../types/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* This function is used to extract TOC (Table Of Content) from markdown text
|
|
5
|
-
* @param markdown
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export declare function extractTOC(markdown: string): TOCItem[];
|
|
9
|
-
/**
|
|
10
|
-
* This function is used to extract the link from a heading text coming from a markdown
|
|
11
|
-
* @param title
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
export declare const generateAnchor: (title: React.ReactNode) => {
|
|
15
|
-
id: string;
|
|
16
|
-
text: any[];
|
|
17
|
-
} | {
|
|
18
|
-
id: any;
|
|
19
|
-
text: React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal;
|
|
20
|
-
} | {
|
|
21
|
-
id: string;
|
|
22
|
-
text: string;
|
|
23
|
-
};
|