@nuucognition/ncm-ui 0.1.0-dev.1 → 0.1.1-beta.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/README.md +90 -0
- package/dist/blocks/admonition/index.d.ts +2 -3
- package/dist/blocks/admonition/index.js +79 -23
- package/dist/blocks/aside/index.d.ts +2 -3
- package/dist/blocks/aside/index.js +79 -23
- package/dist/blocks/attribution/index.d.ts +2 -3
- package/dist/blocks/blockquote/index.d.ts +5 -4
- package/dist/blocks/blockquote/index.js +52 -7
- package/dist/blocks/chart/index.d.ts +2 -3
- package/dist/blocks/chart/index.js +2 -1
- package/dist/blocks/code/index.d.ts +2 -3
- package/dist/blocks/code/index.js +2 -2
- package/dist/blocks/container/index.d.ts +2 -3
- package/dist/blocks/container/index.js +50 -5
- package/dist/blocks/custom-code/index.d.ts +2 -3
- package/dist/blocks/custom-code/index.js +1 -1
- package/dist/blocks/dataview/index.d.ts +2 -3
- package/dist/blocks/dataview/index.js +2 -1
- package/dist/blocks/definition/index.d.ts +2 -3
- package/dist/blocks/definition/index.js +79 -23
- package/dist/blocks/embed/index.d.ts +2 -3
- package/dist/blocks/embedding/index.d.ts +2 -3
- package/dist/blocks/embedding/index.js +50 -5
- package/dist/blocks/figure/index.d.ts +2 -3
- package/dist/blocks/figure/index.js +50 -5
- package/dist/blocks/footnote/index.d.ts +2 -3
- package/dist/blocks/footnote/index.js +79 -23
- package/dist/blocks/frontmatter/index.d.ts +2 -3
- package/dist/blocks/header/index.d.ts +2 -3
- package/dist/blocks/header/index.js +50 -5
- package/dist/blocks/horizontal-rule/index.d.ts +2 -3
- package/dist/blocks/html/index.d.ts +3 -4
- package/dist/blocks/html/index.js +2 -1
- package/dist/blocks/index.d.ts +1 -2
- package/dist/blocks/index.js +79 -23
- package/dist/blocks/latex/index.d.ts +2 -3
- package/dist/blocks/latex/index.js +2 -2
- package/dist/blocks/link/index.d.ts +2 -3
- package/dist/blocks/list/index.d.ts +2 -3
- package/dist/blocks/list/index.js +57 -7
- package/dist/blocks/math/index.d.ts +2 -3
- package/dist/blocks/math/index.js +3 -2
- package/dist/blocks/mermaid/index.d.ts +2 -3
- package/dist/blocks/mermaid/index.js +2 -1
- package/dist/blocks/page-breaker/index.d.ts +2 -3
- package/dist/blocks/paragraph/index.d.ts +2 -3
- package/dist/blocks/paragraph/index.js +50 -5
- package/dist/blocks/spoiler/index.d.ts +2 -3
- package/dist/blocks/spoiler/index.js +79 -23
- package/dist/blocks/table/index.d.ts +2 -3
- package/dist/blocks/table/index.js +51 -6
- package/dist/blocks/task-list/index.d.ts +2 -3
- package/dist/blocks/task-list/index.js +52 -6
- package/dist/components/index.d.ts +34 -4
- package/dist/components/index.js +117 -25
- package/dist/components/ncm-block.d.ts +2 -3
- package/dist/components/ncm-block.js +79 -23
- package/dist/components/ncm-document.d.ts +4 -4
- package/dist/components/ncm-document.js +79 -23
- package/dist/context/index.d.ts +2 -3
- package/dist/hooks/index.d.ts +1 -2
- package/dist/hooks/index.js +79 -23
- package/dist/hooks/use-block-renderer.js +79 -23
- package/dist/hooks/use-ncm-config.d.ts +1 -2
- package/dist/index.d.ts +3 -4
- package/dist/index.js +118 -26
- package/dist/inline/index.d.ts +4 -4
- package/dist/inline/index.js +51 -6
- package/dist/lib/defaults.js +79 -23
- package/dist/{references-Bs5wJybr.d.ts → references-BYW5pnj_.d.ts} +4 -4
- package/dist/styles/nuu.css +329 -44
- package/dist/styles/paper.css +62 -1
- package/dist/{use-ncm-config-D0doMYTH.d.ts → use-ncm-config-CnntcShj.d.ts} +55 -4
- package/package.json +5 -5
|
@@ -646,9 +646,10 @@ function TokenRenderer({ token, disableBionic, disableBeeline }) {
|
|
|
646
646
|
case "image": {
|
|
647
647
|
const src = config.inline?.resolveAssetPath?.(token.src) ?? token.src;
|
|
648
648
|
return /* @__PURE__ */ jsx(
|
|
649
|
-
|
|
649
|
+
EmbedImage,
|
|
650
650
|
{
|
|
651
|
-
"data-ncm-token": "image",
|
|
651
|
+
attrs: { "data-ncm-token": "image" },
|
|
652
|
+
target: token.src,
|
|
652
653
|
src,
|
|
653
654
|
alt: token.alt,
|
|
654
655
|
title: token.title
|
|
@@ -682,10 +683,13 @@ function TokenRenderer({ token, disableBionic, disableBeeline }) {
|
|
|
682
683
|
}
|
|
683
684
|
if (embedType === "image") {
|
|
684
685
|
return /* @__PURE__ */ jsx(
|
|
685
|
-
|
|
686
|
+
EmbedImage,
|
|
686
687
|
{
|
|
687
|
-
|
|
688
|
-
|
|
688
|
+
attrs: {
|
|
689
|
+
"data-ncm-token": "wiki_embed",
|
|
690
|
+
"data-ncm-wikiembed-type": embedType
|
|
691
|
+
},
|
|
692
|
+
target: token.target,
|
|
689
693
|
src: url,
|
|
690
694
|
alt: token.display ?? token.target,
|
|
691
695
|
className: config.embeddings?.imageClassName
|
|
@@ -716,6 +720,22 @@ function TokenRenderer({ token, disableBionic, disableBeeline }) {
|
|
|
716
720
|
}
|
|
717
721
|
);
|
|
718
722
|
}
|
|
723
|
+
const onEmbedClick = config.embeddings?.onEmbedClick;
|
|
724
|
+
if (onEmbedClick) {
|
|
725
|
+
const handleClick = (e) => {
|
|
726
|
+
onEmbedClick(token.target, result, e);
|
|
727
|
+
};
|
|
728
|
+
return /* @__PURE__ */ jsx(
|
|
729
|
+
"button",
|
|
730
|
+
{
|
|
731
|
+
type: "button",
|
|
732
|
+
"data-ncm-token": "wiki_embed",
|
|
733
|
+
"data-ncm-wikiembed-type": embedType,
|
|
734
|
+
onClick: handleClick,
|
|
735
|
+
children: token.display ?? token.target
|
|
736
|
+
}
|
|
737
|
+
);
|
|
738
|
+
}
|
|
719
739
|
return /* @__PURE__ */ jsx(
|
|
720
740
|
"a",
|
|
721
741
|
{
|
|
@@ -734,6 +754,31 @@ function TokenRenderer({ token, disableBionic, disableBeeline }) {
|
|
|
734
754
|
return null;
|
|
735
755
|
}
|
|
736
756
|
}
|
|
757
|
+
function EmbedImage({ attrs, target, src, alt, title, className }) {
|
|
758
|
+
const config = useNcmConfig();
|
|
759
|
+
const Fallback = config.embeddings?.renderImageError;
|
|
760
|
+
const [failedSrc, setFailedSrc] = useState(null);
|
|
761
|
+
useEffect(() => {
|
|
762
|
+
setFailedSrc(null);
|
|
763
|
+
}, [src]);
|
|
764
|
+
if (!Fallback) {
|
|
765
|
+
return /* @__PURE__ */ jsx("img", { ...attrs, src, alt, title, className });
|
|
766
|
+
}
|
|
767
|
+
if (failedSrc === src) {
|
|
768
|
+
return /* @__PURE__ */ jsx(Fallback, { target, src, alt, retry: () => setFailedSrc(null) });
|
|
769
|
+
}
|
|
770
|
+
return /* @__PURE__ */ jsx(
|
|
771
|
+
"img",
|
|
772
|
+
{
|
|
773
|
+
...attrs,
|
|
774
|
+
src,
|
|
775
|
+
alt,
|
|
776
|
+
title,
|
|
777
|
+
className,
|
|
778
|
+
onError: () => setFailedSrc(src)
|
|
779
|
+
}
|
|
780
|
+
);
|
|
781
|
+
}
|
|
737
782
|
function renderReadingText(content, opts) {
|
|
738
783
|
if (!content) return /* @__PURE__ */ jsx(Fragment, { children: content });
|
|
739
784
|
const { bionic = false, beeline = false } = opts;
|
|
@@ -769,7 +814,7 @@ function renderReadingText(content, opts) {
|
|
|
769
814
|
return /* @__PURE__ */ jsx(Fragment, { children: pieces });
|
|
770
815
|
}
|
|
771
816
|
function BlockquoteBlock({ block, className }) {
|
|
772
|
-
const lines = block.content.split("\n")
|
|
817
|
+
const lines = block.content.split("\n");
|
|
773
818
|
return /* @__PURE__ */ jsx(
|
|
774
819
|
"blockquote",
|
|
775
820
|
{
|
|
@@ -779,7 +824,7 @@ function BlockquoteBlock({ block, className }) {
|
|
|
779
824
|
"data-block-id": block.id,
|
|
780
825
|
"data-ncm-blockquote": "",
|
|
781
826
|
className,
|
|
782
|
-
children: lines.length <= 1 ? /* @__PURE__ */ jsx(InlineContent, { content: block.content }) : lines.map((line, index) => /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(InlineContent, { content: line }) }, index))
|
|
827
|
+
children: lines.length <= 1 ? /* @__PURE__ */ jsx(InlineContent, { content: block.content }) : lines.map((line, index) => /* @__PURE__ */ jsx("p", { children: line.trim().length > 0 ? /* @__PURE__ */ jsx(InlineContent, { content: line }) : /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\xA0" }) }, index))
|
|
783
828
|
}
|
|
784
829
|
);
|
|
785
830
|
}
|
|
@@ -794,7 +839,8 @@ function ChartBlock({ block, className }) {
|
|
|
794
839
|
"data-ncm-chart": "",
|
|
795
840
|
"data-ncm-chart-type": block.chartType ?? "unknown",
|
|
796
841
|
className: cn(
|
|
797
|
-
|
|
842
|
+
// `overflow-y-hidden` pairs with `overflow-x-auto` on purpose — see the note in `lib/defaults.ts`.
|
|
843
|
+
"overflow-x-auto overflow-y-hidden rounded-lg border border-border bg-muted p-4 font-mono text-sm",
|
|
798
844
|
className
|
|
799
845
|
),
|
|
800
846
|
children: /* @__PURE__ */ jsx("code", { children: block.content })
|
|
@@ -919,7 +965,7 @@ function CodeBlock({ block, className }) {
|
|
|
919
965
|
"data-ncm-language": block.language,
|
|
920
966
|
className: cn("relative", className),
|
|
921
967
|
children: [
|
|
922
|
-
codeConfig.copyButton
|
|
968
|
+
codeConfig.copyButton === true && /* @__PURE__ */ jsx(CopyButton, { content: block.content }),
|
|
923
969
|
/* @__PURE__ */ jsx(CustomRenderer, { code: block.content, language: block.language }),
|
|
924
970
|
languageLabel
|
|
925
971
|
]
|
|
@@ -938,7 +984,7 @@ function CodeBlock({ block, className }) {
|
|
|
938
984
|
"data-ncm-language": block.language,
|
|
939
985
|
className: cn("relative", className),
|
|
940
986
|
children: [
|
|
941
|
-
codeConfig?.copyButton
|
|
987
|
+
codeConfig?.copyButton === true && /* @__PURE__ */ jsx(CopyButton, { content: block.content }),
|
|
942
988
|
/* @__PURE__ */ jsx("pre", { "data-ncm-code-pre": "", children: /* @__PURE__ */ jsxs("div", { className: "flex", children: [
|
|
943
989
|
codeConfig?.lineNumbers && /* @__PURE__ */ jsx(LineNumbers, { count: lineCount }),
|
|
944
990
|
/* @__PURE__ */ jsx("code", { "data-ncm-code": "", className: "flex-1", children: /* @__PURE__ */ jsx(DefaultShikiRenderer, { code: block.content, language: block.language }) })
|
|
@@ -974,7 +1020,8 @@ function DataviewBlock({ block, className }) {
|
|
|
974
1020
|
"data-ncm-dataview": "",
|
|
975
1021
|
"data-ncm-query-type": block.queryType,
|
|
976
1022
|
className: cn(
|
|
977
|
-
|
|
1023
|
+
// `overflow-y-hidden` pairs with `overflow-x-auto` on purpose — see the note in `lib/defaults.ts`.
|
|
1024
|
+
"overflow-x-auto overflow-y-hidden rounded-lg border border-border bg-muted p-4 font-mono text-sm",
|
|
978
1025
|
className
|
|
979
1026
|
),
|
|
980
1027
|
children: /* @__PURE__ */ jsx("code", { children: block.query })
|
|
@@ -1313,7 +1360,8 @@ function HtmlBlock({ block, className }) {
|
|
|
1313
1360
|
"data-block-id": block.id,
|
|
1314
1361
|
"data-ncm-html": "",
|
|
1315
1362
|
className: cn(
|
|
1316
|
-
|
|
1363
|
+
// `overflow-y-hidden` pairs with `overflow-x-auto` on purpose — see the note in `lib/defaults.ts`.
|
|
1364
|
+
"overflow-x-auto overflow-y-hidden rounded-lg border border-border bg-muted p-4 font-mono text-sm",
|
|
1317
1365
|
className
|
|
1318
1366
|
),
|
|
1319
1367
|
children: /* @__PURE__ */ jsx("code", { children: block.content })
|
|
@@ -1351,7 +1399,7 @@ function LatexDisplayBlock({ block, className }) {
|
|
|
1351
1399
|
"data-ncm-type": block.type,
|
|
1352
1400
|
"data-block-id": block.id,
|
|
1353
1401
|
"data-ncm-latex-display": "",
|
|
1354
|
-
className: cn("overflow-x-auto", className),
|
|
1402
|
+
className: cn("overflow-x-auto overflow-y-hidden", className),
|
|
1355
1403
|
dangerouslySetInnerHTML: { __html: html }
|
|
1356
1404
|
}
|
|
1357
1405
|
);
|
|
@@ -1366,7 +1414,7 @@ function LatexDisplayBlock({ block, className }) {
|
|
|
1366
1414
|
"data-ncm-type": block.type,
|
|
1367
1415
|
"data-block-id": block.id,
|
|
1368
1416
|
"data-ncm-latex-display": "",
|
|
1369
|
-
className: cn("overflow-x-auto rounded-lg border border-border bg-muted p-4 font-mono text-sm", className),
|
|
1417
|
+
className: cn("overflow-x-auto overflow-y-hidden rounded-lg border border-border bg-muted p-4 font-mono text-sm", className),
|
|
1370
1418
|
children: /* @__PURE__ */ jsx("code", { children: block.content })
|
|
1371
1419
|
}
|
|
1372
1420
|
);
|
|
@@ -1390,10 +1438,12 @@ function LinkBlock({ block, className }) {
|
|
|
1390
1438
|
function ListBlock({ block, className }) {
|
|
1391
1439
|
const isOrdered = block.type === "list_ordered";
|
|
1392
1440
|
const Tag = isOrdered ? "ol" : "ul";
|
|
1441
|
+
const start = isOrdered && typeof block.marker === "number" && block.marker !== 1 ? block.marker : void 0;
|
|
1393
1442
|
return /* @__PURE__ */ jsx(
|
|
1394
1443
|
Tag,
|
|
1395
1444
|
{
|
|
1396
1445
|
role: "list",
|
|
1446
|
+
start,
|
|
1397
1447
|
"data-ncm-block": block.id,
|
|
1398
1448
|
"data-ncm-stable": block.stableId,
|
|
1399
1449
|
"data-ncm-type": block.type,
|
|
@@ -1405,6 +1455,9 @@ function ListBlock({ block, className }) {
|
|
|
1405
1455
|
}
|
|
1406
1456
|
);
|
|
1407
1457
|
}
|
|
1458
|
+
function ItemContent({ content }) {
|
|
1459
|
+
return content.length > 0 ? /* @__PURE__ */ jsx(InlineContent, { content }) : /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\xA0" });
|
|
1460
|
+
}
|
|
1408
1461
|
function nestedItemIdKey(id) {
|
|
1409
1462
|
if (!id) {
|
|
1410
1463
|
return void 0;
|
|
@@ -1421,7 +1474,7 @@ function ListItems({ items, itemIds, ordered }) {
|
|
|
1421
1474
|
return /* @__PURE__ */ jsx(Fragment, { children: items.map((item, index) => {
|
|
1422
1475
|
const key = nestedItemIdKey(itemIds?.[index]) ?? `item-${index}`;
|
|
1423
1476
|
if (typeof item === "string") {
|
|
1424
|
-
return /* @__PURE__ */ jsx("li", { "data-ncm-list-item": "", children: /* @__PURE__ */ jsx(
|
|
1477
|
+
return /* @__PURE__ */ jsx("li", { "data-ncm-list-item": "", children: /* @__PURE__ */ jsx(ItemContent, { content: item }) }, key);
|
|
1425
1478
|
}
|
|
1426
1479
|
if (isTypedNestedList(item)) {
|
|
1427
1480
|
return /* @__PURE__ */ jsx(NestedTypedList, { list: item }, key);
|
|
@@ -1431,7 +1484,7 @@ function ListItems({ items, itemIds, ordered }) {
|
|
|
1431
1484
|
const content = typeof first === "string" ? first : "";
|
|
1432
1485
|
const nestedContent = processNestedItems(rest, ordered);
|
|
1433
1486
|
return /* @__PURE__ */ jsxs("li", { "data-ncm-list-item": "", children: [
|
|
1434
|
-
/* @__PURE__ */ jsx(
|
|
1487
|
+
/* @__PURE__ */ jsx(ItemContent, { content }),
|
|
1435
1488
|
nestedContent
|
|
1436
1489
|
] }, key);
|
|
1437
1490
|
}
|
|
@@ -1481,7 +1534,7 @@ function MathBlock({ block, className }) {
|
|
|
1481
1534
|
"data-ncm-type": block.type,
|
|
1482
1535
|
"data-block-id": block.id,
|
|
1483
1536
|
"data-ncm-math": "",
|
|
1484
|
-
className: cn("overflow-x-auto", className),
|
|
1537
|
+
className: cn("overflow-x-auto overflow-y-hidden", className),
|
|
1485
1538
|
dangerouslySetInnerHTML: { __html: html }
|
|
1486
1539
|
}
|
|
1487
1540
|
);
|
|
@@ -1497,7 +1550,8 @@ function MathBlock({ block, className }) {
|
|
|
1497
1550
|
"data-block-id": block.id,
|
|
1498
1551
|
"data-ncm-math": "",
|
|
1499
1552
|
className: cn(
|
|
1500
|
-
|
|
1553
|
+
// `overflow-y-hidden` pairs with `overflow-x-auto` on purpose — see the note in `lib/defaults.ts`.
|
|
1554
|
+
"overflow-x-auto overflow-y-hidden rounded-lg border border-border bg-muted p-4 font-mono text-sm",
|
|
1501
1555
|
className
|
|
1502
1556
|
),
|
|
1503
1557
|
children: /* @__PURE__ */ jsx("code", { children: block.content })
|
|
@@ -1515,7 +1569,8 @@ function MermaidBlock({ block, className }) {
|
|
|
1515
1569
|
"data-ncm-mermaid": "",
|
|
1516
1570
|
"data-ncm-diagram-type": block.diagramType,
|
|
1517
1571
|
className: cn(
|
|
1518
|
-
|
|
1572
|
+
// `overflow-y-hidden` pairs with `overflow-x-auto` on purpose — see the note in `lib/defaults.ts`.
|
|
1573
|
+
"overflow-x-auto overflow-y-hidden rounded-lg border border-border bg-muted p-4 font-mono text-sm",
|
|
1519
1574
|
className
|
|
1520
1575
|
),
|
|
1521
1576
|
children: /* @__PURE__ */ jsx("code", { children: block.content })
|
|
@@ -1576,7 +1631,7 @@ function TableBlock({ block, className }) {
|
|
|
1576
1631
|
"data-ncm-type": block.type,
|
|
1577
1632
|
"data-block-id": block.id,
|
|
1578
1633
|
"data-ncm-table": "",
|
|
1579
|
-
className: cn("w-full overflow-x-auto", className),
|
|
1634
|
+
className: cn("w-full overflow-x-auto overflow-y-hidden", className),
|
|
1580
1635
|
children: /* @__PURE__ */ jsxs("table", { role: "table", "data-ncm-table-element": "", children: [
|
|
1581
1636
|
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { "data-ncm-table-row": "", children: block.headers.map((header, index) => /* @__PURE__ */ jsx("th", { "data-ncm-table-header": "", children: /* @__PURE__ */ jsx(InlineContent, { content: header }) }, index)) }) }),
|
|
1582
1637
|
/* @__PURE__ */ jsx("tbody", { children: block.rows.map((row, rowIndex) => {
|
|
@@ -1590,6 +1645,7 @@ function TableBlock({ block, className }) {
|
|
|
1590
1645
|
function TaskItems({ items }) {
|
|
1591
1646
|
return /* @__PURE__ */ jsx(Fragment, { children: items.map((item) => {
|
|
1592
1647
|
const status = item.checked ? "Completed" : "Incomplete";
|
|
1648
|
+
const text = serializeInlineContent(item.content);
|
|
1593
1649
|
return /* @__PURE__ */ jsxs(
|
|
1594
1650
|
"li",
|
|
1595
1651
|
{
|
|
@@ -1616,7 +1672,7 @@ function TaskItems({ items }) {
|
|
|
1616
1672
|
":",
|
|
1617
1673
|
" "
|
|
1618
1674
|
] }),
|
|
1619
|
-
/* @__PURE__ */ jsx(InlineContent, { content:
|
|
1675
|
+
text.length > 0 ? /* @__PURE__ */ jsx(InlineContent, { content: text }) : /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\xA0" })
|
|
1620
1676
|
] })
|
|
1621
1677
|
] }),
|
|
1622
1678
|
item.children ? /* @__PURE__ */ jsx("ul", { role: "list", "data-ncm-list-nested": "", className: "ml-6 list-none", children: /* @__PURE__ */ jsx(TaskItems, { items: item.children.items }) }) : null
|
|
@@ -1661,7 +1717,7 @@ function FallbackBlock({ block, className }) {
|
|
|
1661
1717
|
"data-block-id": block.id,
|
|
1662
1718
|
"data-ncm-fallback": "",
|
|
1663
1719
|
className: cn(
|
|
1664
|
-
"overflow-x-auto rounded-lg border border-border bg-muted p-4 font-mono text-sm",
|
|
1720
|
+
"overflow-x-auto overflow-y-hidden rounded-lg border border-border bg-muted p-4 font-mono text-sm",
|
|
1665
1721
|
className
|
|
1666
1722
|
)
|
|
1667
1723
|
},
|
|
@@ -1717,7 +1773,7 @@ function CustomCodeBlock({ block, className }) {
|
|
|
1717
1773
|
"data-block-id": block.id,
|
|
1718
1774
|
"data-ncm-custom-code": "",
|
|
1719
1775
|
"data-ncm-language": block.language,
|
|
1720
|
-
className: cn("overflow-x-auto", className),
|
|
1776
|
+
className: cn("overflow-x-auto overflow-y-hidden", className),
|
|
1721
1777
|
children: [
|
|
1722
1778
|
/* @__PURE__ */ jsx("div", { className: "mb-2 text-xs font-medium text-muted-foreground", children: block.language }),
|
|
1723
1779
|
/* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { children: block.content }) })
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { C as CodeConfig, E as EmbeddingsConfig, I as InlineConfig, N as NcmConfig,
|
|
2
|
-
export { B as BlockReferenceScope, a as BlockReferenceScopeProps, b as BlockReferenceScopeValue, I as InertReferenceScope, N as NcmReferencesProvider, c as NcmReferencesProviderProps, R as ReferenceCounts, d as ReferenceKind, e as computeReferenceBases, u as useBlockReferenceScope } from '../references-
|
|
3
|
-
import 'react/jsx-runtime';
|
|
1
|
+
export { C as CodeConfig, E as EmbeddingsConfig, I as ImageErrorProps, a as InlineConfig, N as NcmConfig, b as NcmProvider, c as NcmProviderProps, u as useNcmConfig } from '../use-ncm-config-CnntcShj.js';
|
|
2
|
+
export { B as BlockReferenceScope, a as BlockReferenceScopeProps, b as BlockReferenceScopeValue, I as InertReferenceScope, N as NcmReferencesProvider, c as NcmReferencesProviderProps, R as ReferenceCounts, d as ReferenceKind, e as computeReferenceBases, u as useBlockReferenceScope } from '../references-BYW5pnj_.js';
|
|
4
3
|
import 'react';
|
|
5
4
|
import '@nuucognition/mesh-core';
|
|
6
5
|
import '@nuucognition/ncm';
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { u as useNcmConfig } from '../use-ncm-config-
|
|
1
|
+
export { u as useNcmConfig } from '../use-ncm-config-CnntcShj.js';
|
|
2
2
|
export { useBlockRenderer, useCustomCodeRenderer } from './use-block-renderer.js';
|
|
3
|
-
import 'react/jsx-runtime';
|
|
4
3
|
import 'react';
|
|
5
4
|
import '@nuucognition/mesh-core';
|
|
6
5
|
import '@nuucognition/ncm';
|
package/dist/hooks/index.js
CHANGED
|
@@ -26,7 +26,7 @@ function CustomCodeBlock({ block, className }) {
|
|
|
26
26
|
"data-block-id": block.id,
|
|
27
27
|
"data-ncm-custom-code": "",
|
|
28
28
|
"data-ncm-language": block.language,
|
|
29
|
-
className: cn("overflow-x-auto", className),
|
|
29
|
+
className: cn("overflow-x-auto overflow-y-hidden", className),
|
|
30
30
|
children: [
|
|
31
31
|
/* @__PURE__ */ jsx("div", { className: "mb-2 text-xs font-medium text-muted-foreground", children: block.language }),
|
|
32
32
|
/* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { children: block.content }) })
|
|
@@ -650,9 +650,10 @@ function TokenRenderer({ token, disableBionic, disableBeeline }) {
|
|
|
650
650
|
case "image": {
|
|
651
651
|
const src = config.inline?.resolveAssetPath?.(token.src) ?? token.src;
|
|
652
652
|
return /* @__PURE__ */ jsx(
|
|
653
|
-
|
|
653
|
+
EmbedImage,
|
|
654
654
|
{
|
|
655
|
-
"data-ncm-token": "image",
|
|
655
|
+
attrs: { "data-ncm-token": "image" },
|
|
656
|
+
target: token.src,
|
|
656
657
|
src,
|
|
657
658
|
alt: token.alt,
|
|
658
659
|
title: token.title
|
|
@@ -686,10 +687,13 @@ function TokenRenderer({ token, disableBionic, disableBeeline }) {
|
|
|
686
687
|
}
|
|
687
688
|
if (embedType === "image") {
|
|
688
689
|
return /* @__PURE__ */ jsx(
|
|
689
|
-
|
|
690
|
+
EmbedImage,
|
|
690
691
|
{
|
|
691
|
-
|
|
692
|
-
|
|
692
|
+
attrs: {
|
|
693
|
+
"data-ncm-token": "wiki_embed",
|
|
694
|
+
"data-ncm-wikiembed-type": embedType
|
|
695
|
+
},
|
|
696
|
+
target: token.target,
|
|
693
697
|
src: url,
|
|
694
698
|
alt: token.display ?? token.target,
|
|
695
699
|
className: config.embeddings?.imageClassName
|
|
@@ -720,6 +724,22 @@ function TokenRenderer({ token, disableBionic, disableBeeline }) {
|
|
|
720
724
|
}
|
|
721
725
|
);
|
|
722
726
|
}
|
|
727
|
+
const onEmbedClick = config.embeddings?.onEmbedClick;
|
|
728
|
+
if (onEmbedClick) {
|
|
729
|
+
const handleClick = (e) => {
|
|
730
|
+
onEmbedClick(token.target, result, e);
|
|
731
|
+
};
|
|
732
|
+
return /* @__PURE__ */ jsx(
|
|
733
|
+
"button",
|
|
734
|
+
{
|
|
735
|
+
type: "button",
|
|
736
|
+
"data-ncm-token": "wiki_embed",
|
|
737
|
+
"data-ncm-wikiembed-type": embedType,
|
|
738
|
+
onClick: handleClick,
|
|
739
|
+
children: token.display ?? token.target
|
|
740
|
+
}
|
|
741
|
+
);
|
|
742
|
+
}
|
|
723
743
|
return /* @__PURE__ */ jsx(
|
|
724
744
|
"a",
|
|
725
745
|
{
|
|
@@ -738,6 +758,31 @@ function TokenRenderer({ token, disableBionic, disableBeeline }) {
|
|
|
738
758
|
return null;
|
|
739
759
|
}
|
|
740
760
|
}
|
|
761
|
+
function EmbedImage({ attrs, target, src, alt, title, className }) {
|
|
762
|
+
const config = useNcmConfig();
|
|
763
|
+
const Fallback = config.embeddings?.renderImageError;
|
|
764
|
+
const [failedSrc, setFailedSrc] = useState(null);
|
|
765
|
+
useEffect(() => {
|
|
766
|
+
setFailedSrc(null);
|
|
767
|
+
}, [src]);
|
|
768
|
+
if (!Fallback) {
|
|
769
|
+
return /* @__PURE__ */ jsx("img", { ...attrs, src, alt, title, className });
|
|
770
|
+
}
|
|
771
|
+
if (failedSrc === src) {
|
|
772
|
+
return /* @__PURE__ */ jsx(Fallback, { target, src, alt, retry: () => setFailedSrc(null) });
|
|
773
|
+
}
|
|
774
|
+
return /* @__PURE__ */ jsx(
|
|
775
|
+
"img",
|
|
776
|
+
{
|
|
777
|
+
...attrs,
|
|
778
|
+
src,
|
|
779
|
+
alt,
|
|
780
|
+
title,
|
|
781
|
+
className,
|
|
782
|
+
onError: () => setFailedSrc(src)
|
|
783
|
+
}
|
|
784
|
+
);
|
|
785
|
+
}
|
|
741
786
|
function renderReadingText(content, opts) {
|
|
742
787
|
if (!content) return /* @__PURE__ */ jsx(Fragment, { children: content });
|
|
743
788
|
const { bionic = false, beeline = false } = opts;
|
|
@@ -773,7 +818,7 @@ function renderReadingText(content, opts) {
|
|
|
773
818
|
return /* @__PURE__ */ jsx(Fragment, { children: pieces });
|
|
774
819
|
}
|
|
775
820
|
function BlockquoteBlock({ block, className }) {
|
|
776
|
-
const lines = block.content.split("\n")
|
|
821
|
+
const lines = block.content.split("\n");
|
|
777
822
|
return /* @__PURE__ */ jsx(
|
|
778
823
|
"blockquote",
|
|
779
824
|
{
|
|
@@ -783,7 +828,7 @@ function BlockquoteBlock({ block, className }) {
|
|
|
783
828
|
"data-block-id": block.id,
|
|
784
829
|
"data-ncm-blockquote": "",
|
|
785
830
|
className,
|
|
786
|
-
children: lines.length <= 1 ? /* @__PURE__ */ jsx(InlineContent, { content: block.content }) : lines.map((line, index) => /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(InlineContent, { content: line }) }, index))
|
|
831
|
+
children: lines.length <= 1 ? /* @__PURE__ */ jsx(InlineContent, { content: block.content }) : lines.map((line, index) => /* @__PURE__ */ jsx("p", { children: line.trim().length > 0 ? /* @__PURE__ */ jsx(InlineContent, { content: line }) : /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\xA0" }) }, index))
|
|
787
832
|
}
|
|
788
833
|
);
|
|
789
834
|
}
|
|
@@ -798,7 +843,8 @@ function ChartBlock({ block, className }) {
|
|
|
798
843
|
"data-ncm-chart": "",
|
|
799
844
|
"data-ncm-chart-type": block.chartType ?? "unknown",
|
|
800
845
|
className: cn(
|
|
801
|
-
|
|
846
|
+
// `overflow-y-hidden` pairs with `overflow-x-auto` on purpose — see the note in `lib/defaults.ts`.
|
|
847
|
+
"overflow-x-auto overflow-y-hidden rounded-lg border border-border bg-muted p-4 font-mono text-sm",
|
|
802
848
|
className
|
|
803
849
|
),
|
|
804
850
|
children: /* @__PURE__ */ jsx("code", { children: block.content })
|
|
@@ -923,7 +969,7 @@ function CodeBlock({ block, className }) {
|
|
|
923
969
|
"data-ncm-language": block.language,
|
|
924
970
|
className: cn("relative", className),
|
|
925
971
|
children: [
|
|
926
|
-
codeConfig.copyButton
|
|
972
|
+
codeConfig.copyButton === true && /* @__PURE__ */ jsx(CopyButton, { content: block.content }),
|
|
927
973
|
/* @__PURE__ */ jsx(CustomRenderer, { code: block.content, language: block.language }),
|
|
928
974
|
languageLabel
|
|
929
975
|
]
|
|
@@ -942,7 +988,7 @@ function CodeBlock({ block, className }) {
|
|
|
942
988
|
"data-ncm-language": block.language,
|
|
943
989
|
className: cn("relative", className),
|
|
944
990
|
children: [
|
|
945
|
-
codeConfig?.copyButton
|
|
991
|
+
codeConfig?.copyButton === true && /* @__PURE__ */ jsx(CopyButton, { content: block.content }),
|
|
946
992
|
/* @__PURE__ */ jsx("pre", { "data-ncm-code-pre": "", children: /* @__PURE__ */ jsxs("div", { className: "flex", children: [
|
|
947
993
|
codeConfig?.lineNumbers && /* @__PURE__ */ jsx(LineNumbers, { count: lineCount }),
|
|
948
994
|
/* @__PURE__ */ jsx("code", { "data-ncm-code": "", className: "flex-1", children: /* @__PURE__ */ jsx(DefaultShikiRenderer, { code: block.content, language: block.language }) })
|
|
@@ -978,7 +1024,8 @@ function DataviewBlock({ block, className }) {
|
|
|
978
1024
|
"data-ncm-dataview": "",
|
|
979
1025
|
"data-ncm-query-type": block.queryType,
|
|
980
1026
|
className: cn(
|
|
981
|
-
|
|
1027
|
+
// `overflow-y-hidden` pairs with `overflow-x-auto` on purpose — see the note in `lib/defaults.ts`.
|
|
1028
|
+
"overflow-x-auto overflow-y-hidden rounded-lg border border-border bg-muted p-4 font-mono text-sm",
|
|
982
1029
|
className
|
|
983
1030
|
),
|
|
984
1031
|
children: /* @__PURE__ */ jsx("code", { children: block.query })
|
|
@@ -1317,7 +1364,8 @@ function HtmlBlock({ block, className }) {
|
|
|
1317
1364
|
"data-block-id": block.id,
|
|
1318
1365
|
"data-ncm-html": "",
|
|
1319
1366
|
className: cn(
|
|
1320
|
-
|
|
1367
|
+
// `overflow-y-hidden` pairs with `overflow-x-auto` on purpose — see the note in `lib/defaults.ts`.
|
|
1368
|
+
"overflow-x-auto overflow-y-hidden rounded-lg border border-border bg-muted p-4 font-mono text-sm",
|
|
1321
1369
|
className
|
|
1322
1370
|
),
|
|
1323
1371
|
children: /* @__PURE__ */ jsx("code", { children: block.content })
|
|
@@ -1355,7 +1403,7 @@ function LatexDisplayBlock({ block, className }) {
|
|
|
1355
1403
|
"data-ncm-type": block.type,
|
|
1356
1404
|
"data-block-id": block.id,
|
|
1357
1405
|
"data-ncm-latex-display": "",
|
|
1358
|
-
className: cn("overflow-x-auto", className),
|
|
1406
|
+
className: cn("overflow-x-auto overflow-y-hidden", className),
|
|
1359
1407
|
dangerouslySetInnerHTML: { __html: html }
|
|
1360
1408
|
}
|
|
1361
1409
|
);
|
|
@@ -1370,7 +1418,7 @@ function LatexDisplayBlock({ block, className }) {
|
|
|
1370
1418
|
"data-ncm-type": block.type,
|
|
1371
1419
|
"data-block-id": block.id,
|
|
1372
1420
|
"data-ncm-latex-display": "",
|
|
1373
|
-
className: cn("overflow-x-auto rounded-lg border border-border bg-muted p-4 font-mono text-sm", className),
|
|
1421
|
+
className: cn("overflow-x-auto overflow-y-hidden rounded-lg border border-border bg-muted p-4 font-mono text-sm", className),
|
|
1374
1422
|
children: /* @__PURE__ */ jsx("code", { children: block.content })
|
|
1375
1423
|
}
|
|
1376
1424
|
);
|
|
@@ -1394,10 +1442,12 @@ function LinkBlock({ block, className }) {
|
|
|
1394
1442
|
function ListBlock({ block, className }) {
|
|
1395
1443
|
const isOrdered = block.type === "list_ordered";
|
|
1396
1444
|
const Tag = isOrdered ? "ol" : "ul";
|
|
1445
|
+
const start = isOrdered && typeof block.marker === "number" && block.marker !== 1 ? block.marker : void 0;
|
|
1397
1446
|
return /* @__PURE__ */ jsx(
|
|
1398
1447
|
Tag,
|
|
1399
1448
|
{
|
|
1400
1449
|
role: "list",
|
|
1450
|
+
start,
|
|
1401
1451
|
"data-ncm-block": block.id,
|
|
1402
1452
|
"data-ncm-stable": block.stableId,
|
|
1403
1453
|
"data-ncm-type": block.type,
|
|
@@ -1409,6 +1459,9 @@ function ListBlock({ block, className }) {
|
|
|
1409
1459
|
}
|
|
1410
1460
|
);
|
|
1411
1461
|
}
|
|
1462
|
+
function ItemContent({ content }) {
|
|
1463
|
+
return content.length > 0 ? /* @__PURE__ */ jsx(InlineContent, { content }) : /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\xA0" });
|
|
1464
|
+
}
|
|
1412
1465
|
function nestedItemIdKey(id) {
|
|
1413
1466
|
if (!id) {
|
|
1414
1467
|
return void 0;
|
|
@@ -1425,7 +1478,7 @@ function ListItems({ items, itemIds, ordered }) {
|
|
|
1425
1478
|
return /* @__PURE__ */ jsx(Fragment, { children: items.map((item, index) => {
|
|
1426
1479
|
const key = nestedItemIdKey(itemIds?.[index]) ?? `item-${index}`;
|
|
1427
1480
|
if (typeof item === "string") {
|
|
1428
|
-
return /* @__PURE__ */ jsx("li", { "data-ncm-list-item": "", children: /* @__PURE__ */ jsx(
|
|
1481
|
+
return /* @__PURE__ */ jsx("li", { "data-ncm-list-item": "", children: /* @__PURE__ */ jsx(ItemContent, { content: item }) }, key);
|
|
1429
1482
|
}
|
|
1430
1483
|
if (isTypedNestedList(item)) {
|
|
1431
1484
|
return /* @__PURE__ */ jsx(NestedTypedList, { list: item }, key);
|
|
@@ -1435,7 +1488,7 @@ function ListItems({ items, itemIds, ordered }) {
|
|
|
1435
1488
|
const content = typeof first === "string" ? first : "";
|
|
1436
1489
|
const nestedContent = processNestedItems(rest, ordered);
|
|
1437
1490
|
return /* @__PURE__ */ jsxs("li", { "data-ncm-list-item": "", children: [
|
|
1438
|
-
/* @__PURE__ */ jsx(
|
|
1491
|
+
/* @__PURE__ */ jsx(ItemContent, { content }),
|
|
1439
1492
|
nestedContent
|
|
1440
1493
|
] }, key);
|
|
1441
1494
|
}
|
|
@@ -1485,7 +1538,7 @@ function MathBlock({ block, className }) {
|
|
|
1485
1538
|
"data-ncm-type": block.type,
|
|
1486
1539
|
"data-block-id": block.id,
|
|
1487
1540
|
"data-ncm-math": "",
|
|
1488
|
-
className: cn("overflow-x-auto", className),
|
|
1541
|
+
className: cn("overflow-x-auto overflow-y-hidden", className),
|
|
1489
1542
|
dangerouslySetInnerHTML: { __html: html }
|
|
1490
1543
|
}
|
|
1491
1544
|
);
|
|
@@ -1501,7 +1554,8 @@ function MathBlock({ block, className }) {
|
|
|
1501
1554
|
"data-block-id": block.id,
|
|
1502
1555
|
"data-ncm-math": "",
|
|
1503
1556
|
className: cn(
|
|
1504
|
-
|
|
1557
|
+
// `overflow-y-hidden` pairs with `overflow-x-auto` on purpose — see the note in `lib/defaults.ts`.
|
|
1558
|
+
"overflow-x-auto overflow-y-hidden rounded-lg border border-border bg-muted p-4 font-mono text-sm",
|
|
1505
1559
|
className
|
|
1506
1560
|
),
|
|
1507
1561
|
children: /* @__PURE__ */ jsx("code", { children: block.content })
|
|
@@ -1519,7 +1573,8 @@ function MermaidBlock({ block, className }) {
|
|
|
1519
1573
|
"data-ncm-mermaid": "",
|
|
1520
1574
|
"data-ncm-diagram-type": block.diagramType,
|
|
1521
1575
|
className: cn(
|
|
1522
|
-
|
|
1576
|
+
// `overflow-y-hidden` pairs with `overflow-x-auto` on purpose — see the note in `lib/defaults.ts`.
|
|
1577
|
+
"overflow-x-auto overflow-y-hidden rounded-lg border border-border bg-muted p-4 font-mono text-sm",
|
|
1523
1578
|
className
|
|
1524
1579
|
),
|
|
1525
1580
|
children: /* @__PURE__ */ jsx("code", { children: block.content })
|
|
@@ -1580,7 +1635,7 @@ function TableBlock({ block, className }) {
|
|
|
1580
1635
|
"data-ncm-type": block.type,
|
|
1581
1636
|
"data-block-id": block.id,
|
|
1582
1637
|
"data-ncm-table": "",
|
|
1583
|
-
className: cn("w-full overflow-x-auto", className),
|
|
1638
|
+
className: cn("w-full overflow-x-auto overflow-y-hidden", className),
|
|
1584
1639
|
children: /* @__PURE__ */ jsxs("table", { role: "table", "data-ncm-table-element": "", children: [
|
|
1585
1640
|
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { "data-ncm-table-row": "", children: block.headers.map((header, index) => /* @__PURE__ */ jsx("th", { "data-ncm-table-header": "", children: /* @__PURE__ */ jsx(InlineContent, { content: header }) }, index)) }) }),
|
|
1586
1641
|
/* @__PURE__ */ jsx("tbody", { children: block.rows.map((row, rowIndex) => {
|
|
@@ -1594,6 +1649,7 @@ function TableBlock({ block, className }) {
|
|
|
1594
1649
|
function TaskItems({ items }) {
|
|
1595
1650
|
return /* @__PURE__ */ jsx(Fragment, { children: items.map((item) => {
|
|
1596
1651
|
const status = item.checked ? "Completed" : "Incomplete";
|
|
1652
|
+
const text = serializeInlineContent(item.content);
|
|
1597
1653
|
return /* @__PURE__ */ jsxs(
|
|
1598
1654
|
"li",
|
|
1599
1655
|
{
|
|
@@ -1620,7 +1676,7 @@ function TaskItems({ items }) {
|
|
|
1620
1676
|
":",
|
|
1621
1677
|
" "
|
|
1622
1678
|
] }),
|
|
1623
|
-
/* @__PURE__ */ jsx(InlineContent, { content:
|
|
1679
|
+
text.length > 0 ? /* @__PURE__ */ jsx(InlineContent, { content: text }) : /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\xA0" })
|
|
1624
1680
|
] })
|
|
1625
1681
|
] }),
|
|
1626
1682
|
item.children ? /* @__PURE__ */ jsx("ul", { role: "list", "data-ncm-list-nested": "", className: "ml-6 list-none", children: /* @__PURE__ */ jsx(TaskItems, { items: item.children.items }) }) : null
|
|
@@ -1665,7 +1721,7 @@ function FallbackBlock({ block, className }) {
|
|
|
1665
1721
|
"data-block-id": block.id,
|
|
1666
1722
|
"data-ncm-fallback": "",
|
|
1667
1723
|
className: cn(
|
|
1668
|
-
"overflow-x-auto rounded-lg border border-border bg-muted p-4 font-mono text-sm",
|
|
1724
|
+
"overflow-x-auto overflow-y-hidden rounded-lg border border-border bg-muted p-4 font-mono text-sm",
|
|
1669
1725
|
className
|
|
1670
1726
|
)
|
|
1671
1727
|
},
|