@nuucognition/ncm-ui 0.1.0-dev.1
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/LICENSE +21 -0
- package/README.md +129 -0
- package/dist/blocks/admonition/index.d.ts +13 -0
- package/dist/blocks/admonition/index.js +1713 -0
- package/dist/blocks/aside/index.d.ts +13 -0
- package/dist/blocks/aside/index.js +1713 -0
- package/dist/blocks/attribution/index.d.ts +13 -0
- package/dist/blocks/attribution/index.js +32 -0
- package/dist/blocks/blockquote/index.d.ts +15 -0
- package/dist/blocks/blockquote/index.js +609 -0
- package/dist/blocks/chart/index.d.ts +14 -0
- package/dist/blocks/chart/index.js +29 -0
- package/dist/blocks/code/index.d.ts +15 -0
- package/dist/blocks/code/index.js +163 -0
- package/dist/blocks/container/index.d.ts +17 -0
- package/dist/blocks/container/index.js +633 -0
- package/dist/blocks/custom-code/index.d.ts +15 -0
- package/dist/blocks/custom-code/index.js +31 -0
- package/dist/blocks/dataview/index.d.ts +14 -0
- package/dist/blocks/dataview/index.js +29 -0
- package/dist/blocks/definition/index.d.ts +13 -0
- package/dist/blocks/definition/index.js +1713 -0
- package/dist/blocks/embed/index.d.ts +12 -0
- package/dist/blocks/embed/index.js +46 -0
- package/dist/blocks/embedding/index.d.ts +13 -0
- package/dist/blocks/embedding/index.js +763 -0
- package/dist/blocks/figure/index.d.ts +13 -0
- package/dist/blocks/figure/index.js +656 -0
- package/dist/blocks/footnote/index.d.ts +13 -0
- package/dist/blocks/footnote/index.js +1713 -0
- package/dist/blocks/frontmatter/index.d.ts +16 -0
- package/dist/blocks/frontmatter/index.js +38 -0
- package/dist/blocks/header/index.d.ts +9 -0
- package/dist/blocks/header/index.js +610 -0
- package/dist/blocks/horizontal-rule/index.d.ts +9 -0
- package/dist/blocks/horizontal-rule/index.js +19 -0
- package/dist/blocks/html/index.d.ts +31 -0
- package/dist/blocks/html/index.js +52 -0
- package/dist/blocks/index.d.ts +32 -0
- package/dist/blocks/index.js +1736 -0
- package/dist/blocks/latex/index.d.ts +9 -0
- package/dist/blocks/latex/index.js +107 -0
- package/dist/blocks/link/index.d.ts +14 -0
- package/dist/blocks/link/index.js +27 -0
- package/dist/blocks/list/index.d.ts +9 -0
- package/dist/blocks/list/index.js +675 -0
- package/dist/blocks/math/index.d.ts +13 -0
- package/dist/blocks/math/index.js +88 -0
- package/dist/blocks/mermaid/index.d.ts +14 -0
- package/dist/blocks/mermaid/index.js +29 -0
- package/dist/blocks/page-breaker/index.d.ts +16 -0
- package/dist/blocks/page-breaker/index.js +21 -0
- package/dist/blocks/paragraph/index.d.ts +9 -0
- package/dist/blocks/paragraph/index.js +608 -0
- package/dist/blocks/spoiler/index.d.ts +13 -0
- package/dist/blocks/spoiler/index.js +1713 -0
- package/dist/blocks/table/index.d.ts +9 -0
- package/dist/blocks/table/index.js +619 -0
- package/dist/blocks/task-list/index.d.ts +13 -0
- package/dist/blocks/task-list/index.js +670 -0
- package/dist/components/index.d.ts +599 -0
- package/dist/components/index.js +1840 -0
- package/dist/components/ncm-block.d.ts +28 -0
- package/dist/components/ncm-block.js +1712 -0
- package/dist/components/ncm-document.d.ts +48 -0
- package/dist/components/ncm-document.js +1839 -0
- package/dist/context/index.d.ts +7 -0
- package/dist/context/index.js +284 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.js +1731 -0
- package/dist/hooks/use-block-renderer.d.ts +28 -0
- package/dist/hooks/use-block-renderer.js +1731 -0
- package/dist/hooks/use-ncm-config.d.ts +6 -0
- package/dist/hooks/use-ncm-config.js +11 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +1887 -0
- package/dist/inline/index.d.ts +108 -0
- package/dist/inline/index.js +598 -0
- package/dist/inline-DwUYUmk4.d.ts +75 -0
- package/dist/lib/defaults.d.ts +24 -0
- package/dist/lib/defaults.js +1713 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +10 -0
- package/dist/lib/katex.d.ts +3 -0
- package/dist/lib/katex.js +45 -0
- package/dist/lib/utils.d.ts +8 -0
- package/dist/lib/utils.js +10 -0
- package/dist/references-Bs5wJybr.d.ts +63 -0
- package/dist/renderers-C5f41FCy.d.ts +99 -0
- package/dist/styles/fonts/OpenDyslexic3-Bold.woff +0 -0
- package/dist/styles/fonts/OpenDyslexic3-Bold.woff2 +0 -0
- package/dist/styles/fonts/OpenDyslexic3-Regular.woff +0 -0
- package/dist/styles/fonts/OpenDyslexic3-Regular.woff2 +0 -0
- package/dist/styles/nuu.css +364 -0
- package/dist/styles/paper.css +332 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +2 -0
- package/dist/use-ncm-config-D0doMYTH.d.ts +114 -0
- package/package.json +99 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { LatexDisplayBlock as LatexDisplayBlock$1 } from '@nuucognition/ncm';
|
|
3
|
+
import { a as BlockRendererProps } from '../../renderers-C5f41FCy.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
|
|
6
|
+
type LatexDisplayBlockProps = BlockRendererProps<LatexDisplayBlock$1>;
|
|
7
|
+
declare function LatexDisplayBlock({ block, className }: LatexDisplayBlockProps): react_jsx_runtime.JSX.Element;
|
|
8
|
+
|
|
9
|
+
export { LatexDisplayBlock, type LatexDisplayBlockProps };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext, useState, useEffect, useMemo } from 'react';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import { twMerge } from 'tailwind-merge';
|
|
6
|
+
|
|
7
|
+
// src/context/ncm-context.tsx
|
|
8
|
+
var NcmContext = createContext(null);
|
|
9
|
+
function useNcmConfig() {
|
|
10
|
+
return useContext(NcmContext) ?? {};
|
|
11
|
+
}
|
|
12
|
+
var katexPromise = null;
|
|
13
|
+
function loadKatex() {
|
|
14
|
+
if (!katexPromise) {
|
|
15
|
+
katexPromise = Promise.all([
|
|
16
|
+
import('katex'),
|
|
17
|
+
import('katex/dist/katex.min.css')
|
|
18
|
+
]).then(([module]) => module.default).catch(() => null);
|
|
19
|
+
}
|
|
20
|
+
return katexPromise;
|
|
21
|
+
}
|
|
22
|
+
function useKatexHtml(content, displayMode, enabled = true) {
|
|
23
|
+
const [katexModule, setKatexModule] = useState(null);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!enabled) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
let active = true;
|
|
29
|
+
loadKatex().then((loaded) => {
|
|
30
|
+
if (active) {
|
|
31
|
+
setKatexModule(loaded);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return () => {
|
|
35
|
+
active = false;
|
|
36
|
+
};
|
|
37
|
+
}, [enabled]);
|
|
38
|
+
return useMemo(() => {
|
|
39
|
+
if (!enabled || !katexModule) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
return katexModule.renderToString(content, {
|
|
44
|
+
throwOnError: false,
|
|
45
|
+
displayMode
|
|
46
|
+
});
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}, [content, displayMode, enabled, katexModule]);
|
|
51
|
+
}
|
|
52
|
+
function cn(...inputs) {
|
|
53
|
+
return twMerge(clsx(inputs));
|
|
54
|
+
}
|
|
55
|
+
function LatexDisplayBlock({ block, className }) {
|
|
56
|
+
const config = useNcmConfig();
|
|
57
|
+
const CustomRenderer = config.inline?.customLatexRenderer;
|
|
58
|
+
const html = useKatexHtml(block.content, true, !CustomRenderer);
|
|
59
|
+
if (CustomRenderer) {
|
|
60
|
+
return /* @__PURE__ */ jsx(
|
|
61
|
+
"div",
|
|
62
|
+
{
|
|
63
|
+
role: "region",
|
|
64
|
+
"aria-label": "Mathematical expression",
|
|
65
|
+
"data-ncm-block": block.id,
|
|
66
|
+
"data-ncm-stable": block.stableId,
|
|
67
|
+
"data-ncm-type": block.type,
|
|
68
|
+
"data-block-id": block.id,
|
|
69
|
+
"data-ncm-latex-display": "",
|
|
70
|
+
className,
|
|
71
|
+
children: /* @__PURE__ */ jsx(CustomRenderer, { content: block.content, display: true })
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
if (html) {
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
"div",
|
|
78
|
+
{
|
|
79
|
+
role: "region",
|
|
80
|
+
"aria-label": "Mathematical expression",
|
|
81
|
+
"data-ncm-block": block.id,
|
|
82
|
+
"data-ncm-stable": block.stableId,
|
|
83
|
+
"data-ncm-type": block.type,
|
|
84
|
+
"data-block-id": block.id,
|
|
85
|
+
"data-ncm-latex-display": "",
|
|
86
|
+
className: cn("overflow-x-auto", className),
|
|
87
|
+
dangerouslySetInnerHTML: { __html: html }
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
return /* @__PURE__ */ jsx(
|
|
92
|
+
"pre",
|
|
93
|
+
{
|
|
94
|
+
role: "region",
|
|
95
|
+
"aria-label": "Mathematical expression (source)",
|
|
96
|
+
"data-ncm-block": block.id,
|
|
97
|
+
"data-ncm-stable": block.stableId,
|
|
98
|
+
"data-ncm-type": block.type,
|
|
99
|
+
"data-block-id": block.id,
|
|
100
|
+
"data-ncm-latex-display": "",
|
|
101
|
+
className: cn("overflow-x-auto rounded-lg border border-border bg-muted p-4 font-mono text-sm", className),
|
|
102
|
+
children: /* @__PURE__ */ jsx("code", { children: block.content })
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { LatexDisplayBlock };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { LinkBlock as LinkBlock$1 } from '@nuucognition/ncm';
|
|
3
|
+
import { a as BlockRendererProps } from '../../renderers-C5f41FCy.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
|
|
6
|
+
type LinkBlockProps = BlockRendererProps<LinkBlock$1>;
|
|
7
|
+
/**
|
|
8
|
+
* Link-block renderer — a paragraph that contained only a single link, promoted
|
|
9
|
+
* for card-style rendering. Default is a block-level anchor; override the `link`
|
|
10
|
+
* renderer key for rich link previews.
|
|
11
|
+
*/
|
|
12
|
+
declare function LinkBlock({ block, className }: LinkBlockProps): react_jsx_runtime.JSX.Element;
|
|
13
|
+
|
|
14
|
+
export { LinkBlock, type LinkBlockProps };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { twMerge } from 'tailwind-merge';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// src/lib/utils.ts
|
|
7
|
+
function cn(...inputs) {
|
|
8
|
+
return twMerge(clsx(inputs));
|
|
9
|
+
}
|
|
10
|
+
function LinkBlock({ block, className }) {
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"a",
|
|
13
|
+
{
|
|
14
|
+
"data-ncm-block": block.id,
|
|
15
|
+
"data-ncm-stable": block.stableId,
|
|
16
|
+
"data-ncm-type": block.type,
|
|
17
|
+
"data-block-id": block.id,
|
|
18
|
+
"data-ncm-link": "",
|
|
19
|
+
href: block.url,
|
|
20
|
+
title: block.title ?? void 0,
|
|
21
|
+
className: cn("block text-primary hover:underline", className),
|
|
22
|
+
children: block.text || block.url
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { LinkBlock };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ListBlock as ListBlock$1 } from '@nuucognition/ncm';
|
|
3
|
+
import { a as BlockRendererProps } from '../../renderers-C5f41FCy.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
|
|
6
|
+
type ListBlockProps = BlockRendererProps<ListBlock$1>;
|
|
7
|
+
declare function ListBlock({ block, className }: ListBlockProps): react_jsx_runtime.JSX.Element;
|
|
8
|
+
|
|
9
|
+
export { ListBlock, type ListBlockProps };
|