@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
package/dist/inline/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { b as InlineToken } from '../inline-DwUYUmk4.js';
|
|
2
|
-
import * as
|
|
2
|
+
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { d as ReferenceKind } from '../references-
|
|
4
|
+
import { d as ReferenceKind } from '../references-BYW5pnj_.js';
|
|
5
5
|
import '@nuucognition/ncm';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -41,7 +41,7 @@ interface InlineContentProps {
|
|
|
41
41
|
* Emits semantic HTML and `data-ncm-token` attributes; visual styling is owned
|
|
42
42
|
* by the parent document's stylesheet (nuu.css or paper.css).
|
|
43
43
|
*/
|
|
44
|
-
declare function InlineContent({ content, className, disableBionic, disableBeeline, }: InlineContentProps):
|
|
44
|
+
declare function InlineContent({ content, className, disableBionic, disableBeeline, }: InlineContentProps): react.JSX.Element;
|
|
45
45
|
interface RenderReadingTextOptions {
|
|
46
46
|
bionic?: boolean;
|
|
47
47
|
bionicRatio?: number;
|
|
@@ -103,6 +103,6 @@ interface ReferenceMarkerProps {
|
|
|
103
103
|
* so it never spills outside the reading pane — measured lazily, only for the
|
|
104
104
|
* marker actually being hovered/focused, so the common case stays JS-free.
|
|
105
105
|
*/
|
|
106
|
-
declare function ReferenceMarker({ kind, number, children }: ReferenceMarkerProps):
|
|
106
|
+
declare function ReferenceMarker({ kind, number, children }: ReferenceMarkerProps): react.JSX.Element;
|
|
107
107
|
|
|
108
108
|
export { InlineContent, type InlineContentProps, ReferenceMarker, type ReferenceMarkerProps, type RenderReadingTextOptions, parseInline, renderBeelineText, renderBionicText, renderReadingText };
|
package/dist/inline/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createContext, useId, useRef, useCallback, useMemo,
|
|
2
|
+
import { createContext, useId, useRef, useCallback, useMemo, useState, useEffect, useContext } from 'react';
|
|
3
3
|
import { extractExtension, embedTypeFromExtension } from '@nuucognition/mesh-core';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import '@nuucognition/ncm';
|
|
@@ -466,9 +466,10 @@ function TokenRenderer({ token, disableBionic, disableBeeline }) {
|
|
|
466
466
|
case "image": {
|
|
467
467
|
const src = config.inline?.resolveAssetPath?.(token.src) ?? token.src;
|
|
468
468
|
return /* @__PURE__ */ jsx(
|
|
469
|
-
|
|
469
|
+
EmbedImage,
|
|
470
470
|
{
|
|
471
|
-
"data-ncm-token": "image",
|
|
471
|
+
attrs: { "data-ncm-token": "image" },
|
|
472
|
+
target: token.src,
|
|
472
473
|
src,
|
|
473
474
|
alt: token.alt,
|
|
474
475
|
title: token.title
|
|
@@ -502,10 +503,13 @@ function TokenRenderer({ token, disableBionic, disableBeeline }) {
|
|
|
502
503
|
}
|
|
503
504
|
if (embedType === "image") {
|
|
504
505
|
return /* @__PURE__ */ jsx(
|
|
505
|
-
|
|
506
|
+
EmbedImage,
|
|
506
507
|
{
|
|
507
|
-
|
|
508
|
-
|
|
508
|
+
attrs: {
|
|
509
|
+
"data-ncm-token": "wiki_embed",
|
|
510
|
+
"data-ncm-wikiembed-type": embedType
|
|
511
|
+
},
|
|
512
|
+
target: token.target,
|
|
509
513
|
src: url,
|
|
510
514
|
alt: token.display ?? token.target,
|
|
511
515
|
className: config.embeddings?.imageClassName
|
|
@@ -536,6 +540,22 @@ function TokenRenderer({ token, disableBionic, disableBeeline }) {
|
|
|
536
540
|
}
|
|
537
541
|
);
|
|
538
542
|
}
|
|
543
|
+
const onEmbedClick = config.embeddings?.onEmbedClick;
|
|
544
|
+
if (onEmbedClick) {
|
|
545
|
+
const handleClick = (e) => {
|
|
546
|
+
onEmbedClick(token.target, result, e);
|
|
547
|
+
};
|
|
548
|
+
return /* @__PURE__ */ jsx(
|
|
549
|
+
"button",
|
|
550
|
+
{
|
|
551
|
+
type: "button",
|
|
552
|
+
"data-ncm-token": "wiki_embed",
|
|
553
|
+
"data-ncm-wikiembed-type": embedType,
|
|
554
|
+
onClick: handleClick,
|
|
555
|
+
children: token.display ?? token.target
|
|
556
|
+
}
|
|
557
|
+
);
|
|
558
|
+
}
|
|
539
559
|
return /* @__PURE__ */ jsx(
|
|
540
560
|
"a",
|
|
541
561
|
{
|
|
@@ -554,6 +574,31 @@ function TokenRenderer({ token, disableBionic, disableBeeline }) {
|
|
|
554
574
|
return null;
|
|
555
575
|
}
|
|
556
576
|
}
|
|
577
|
+
function EmbedImage({ attrs, target, src, alt, title, className }) {
|
|
578
|
+
const config = useNcmConfig();
|
|
579
|
+
const Fallback = config.embeddings?.renderImageError;
|
|
580
|
+
const [failedSrc, setFailedSrc] = useState(null);
|
|
581
|
+
useEffect(() => {
|
|
582
|
+
setFailedSrc(null);
|
|
583
|
+
}, [src]);
|
|
584
|
+
if (!Fallback) {
|
|
585
|
+
return /* @__PURE__ */ jsx("img", { ...attrs, src, alt, title, className });
|
|
586
|
+
}
|
|
587
|
+
if (failedSrc === src) {
|
|
588
|
+
return /* @__PURE__ */ jsx(Fallback, { target, src, alt, retry: () => setFailedSrc(null) });
|
|
589
|
+
}
|
|
590
|
+
return /* @__PURE__ */ jsx(
|
|
591
|
+
"img",
|
|
592
|
+
{
|
|
593
|
+
...attrs,
|
|
594
|
+
src,
|
|
595
|
+
alt,
|
|
596
|
+
title,
|
|
597
|
+
className,
|
|
598
|
+
onError: () => setFailedSrc(src)
|
|
599
|
+
}
|
|
600
|
+
);
|
|
601
|
+
}
|
|
557
602
|
function renderReadingText(content, opts) {
|
|
558
603
|
if (!content) return /* @__PURE__ */ jsx(Fragment, { children: content });
|
|
559
604
|
const { bionic = false, beeline = false } = opts;
|
package/dist/lib/defaults.js
CHANGED
|
@@ -22,7 +22,7 @@ function CustomCodeBlock({ block, className }) {
|
|
|
22
22
|
"data-block-id": block.id,
|
|
23
23
|
"data-ncm-custom-code": "",
|
|
24
24
|
"data-ncm-language": block.language,
|
|
25
|
-
className: cn("overflow-x-auto", className),
|
|
25
|
+
className: cn("overflow-x-auto overflow-y-hidden", className),
|
|
26
26
|
children: [
|
|
27
27
|
/* @__PURE__ */ jsx("div", { className: "mb-2 text-xs font-medium text-muted-foreground", children: block.language }),
|
|
28
28
|
/* @__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
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { Block } from '@nuucognition/ncm';
|
|
4
4
|
|
|
@@ -37,7 +37,7 @@ interface NcmReferencesProviderProps {
|
|
|
37
37
|
children: ReactNode;
|
|
38
38
|
}
|
|
39
39
|
/** Document-root provider — runs the numbering pre-pass over `blocks`. */
|
|
40
|
-
declare function NcmReferencesProvider({ blocks, children }: NcmReferencesProviderProps):
|
|
40
|
+
declare function NcmReferencesProvider({ blocks, children }: NcmReferencesProviderProps): react.JSX.Element;
|
|
41
41
|
interface BlockReferenceScopeProps {
|
|
42
42
|
/** Block id; resolves the base offset from the document pre-pass. */
|
|
43
43
|
blockId?: string;
|
|
@@ -48,7 +48,7 @@ interface BlockReferenceScopeProps {
|
|
|
48
48
|
* on every render and hands out sequential numbers as markers render. Resetting
|
|
49
49
|
* each render keeps numbering idempotent under React re-renders / StrictMode.
|
|
50
50
|
*/
|
|
51
|
-
declare function BlockReferenceScope({ blockId, children }: BlockReferenceScopeProps):
|
|
51
|
+
declare function BlockReferenceScope({ blockId, children }: BlockReferenceScopeProps): react.JSX.Element;
|
|
52
52
|
/** Read the active per-block reference scope, if any. */
|
|
53
53
|
declare function useBlockReferenceScope(): BlockReferenceScopeValue | null;
|
|
54
54
|
/**
|
|
@@ -58,6 +58,6 @@ declare function useBlockReferenceScope(): BlockReferenceScopeValue | null;
|
|
|
58
58
|
*/
|
|
59
59
|
declare function InertReferenceScope({ children }: {
|
|
60
60
|
children: ReactNode;
|
|
61
|
-
}):
|
|
61
|
+
}): react.JSX.Element;
|
|
62
62
|
|
|
63
63
|
export { BlockReferenceScope as B, InertReferenceScope as I, NcmReferencesProvider as N, type ReferenceCounts as R, type BlockReferenceScopeProps as a, type BlockReferenceScopeValue as b, type NcmReferencesProviderProps as c, type ReferenceKind as d, computeReferenceBases as e, useBlockReferenceScope as u };
|