notion-to-jsx 1.2.12 → 1.2.13
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/dist/index.css +5 -4
- package/dist/index.css.map +1 -1
- package/dist/index.js +81 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -30,13 +30,18 @@ import { memo } from "react";
|
|
|
30
30
|
|
|
31
31
|
// src/components/Renderer/components/RichText/styles.css.ts
|
|
32
32
|
import { createRuntimeFn as _7a4682 } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
33
|
+
var emptyRichText = "styles_emptyRichText__fdf3twr";
|
|
33
34
|
var link = "styles_link__fdf3twq";
|
|
34
35
|
var richText = _7a4682({ defaultClassName: "styles__fdf3tw0", variantClassNames: { bold: { true: "styles_richText_bold_true__fdf3tw1" }, italic: { true: "styles_richText_italic_true__fdf3tw2" }, strikethrough: { true: "styles_richText_strikethrough_true__fdf3tw3" }, underline: { true: "styles_richText_underline_true__fdf3tw4" }, code: { true: "styles_richText_code_true__fdf3tw5" }, color: { "default": "styles_richText_color_default__fdf3tw6", gray: "styles_richText_color_gray__fdf3tw7", brown: "styles_richText_color_brown__fdf3tw8", orange: "styles_richText_color_orange__fdf3tw9", yellow: "styles_richText_color_yellow__fdf3twa", green: "styles_richText_color_green__fdf3twb", blue: "styles_richText_color_blue__fdf3twc", purple: "styles_richText_color_purple__fdf3twd", pink: "styles_richText_color_pink__fdf3twe", red: "styles_richText_color_red__fdf3twf", gray_background: "styles_richText_color_gray_background__fdf3twg", brown_background: "styles_richText_color_brown_background__fdf3twh", orange_background: "styles_richText_color_orange_background__fdf3twi", yellow_background: "styles_richText_color_yellow_background__fdf3twj", green_background: "styles_richText_color_green_background__fdf3twk", blue_background: "styles_richText_color_blue_background__fdf3twl", purple_background: "styles_richText_color_purple_background__fdf3twm", pink_background: "styles_richText_color_pink_background__fdf3twn", red_background: "styles_richText_color_red_background__fdf3two" } }, defaultVariants: {}, compoundVariants: [[{ strikethrough: true, underline: true }, "styles_richText_compound_0__fdf3twp"]] });
|
|
35
36
|
|
|
36
37
|
// src/components/Renderer/components/RichText/RichTexts.tsx
|
|
37
38
|
import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
|
|
38
39
|
var renderLink = (href, content3) => /* @__PURE__ */ jsx2("a", { href, target: "_blank", rel: "noopener noreferrer", className: link, children: content3 });
|
|
40
|
+
var EmptyRichText = () => /* @__PURE__ */ jsx2("div", { className: emptyRichText });
|
|
39
41
|
var RichTexts = ({ richTexts }) => {
|
|
42
|
+
if (richTexts.length === 0) {
|
|
43
|
+
return /* @__PURE__ */ jsx2(EmptyRichText, {});
|
|
44
|
+
}
|
|
40
45
|
return /* @__PURE__ */ jsx2(Fragment, { children: richTexts.map((text, index) => {
|
|
41
46
|
const { bold, italic, strikethrough, underline, code, color } = text.annotations;
|
|
42
47
|
let content3;
|
|
@@ -479,54 +484,71 @@ var MemoizedLinkPreview = memo(
|
|
|
479
484
|
}
|
|
480
485
|
);
|
|
481
486
|
|
|
482
|
-
// src/components/Renderer/components/List/
|
|
487
|
+
// src/components/Renderer/components/List/ListItemGroup.tsx
|
|
483
488
|
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
484
|
-
var RecursiveListItem = ({ block }) => {
|
|
485
|
-
const blockType = block.type;
|
|
489
|
+
var RecursiveListItem = ({ block, renderBlock }) => {
|
|
486
490
|
let content3;
|
|
487
|
-
if (
|
|
491
|
+
if (block.type === "bulleted_list_item") {
|
|
488
492
|
content3 = block.bulleted_list_item;
|
|
489
493
|
} else {
|
|
490
494
|
content3 = block.numbered_list_item;
|
|
491
495
|
}
|
|
492
496
|
const richTexts = content3.rich_text;
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
)
|
|
497
|
+
const renderedChildren = [];
|
|
498
|
+
const children = block.children ?? [];
|
|
499
|
+
if (children.length > 0) {
|
|
500
|
+
let i = 0;
|
|
501
|
+
while (i < children.length) {
|
|
502
|
+
const currentChild = children[i];
|
|
503
|
+
if (!currentChild) {
|
|
504
|
+
i++;
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
if (currentChild.type === "bulleted_list_item" || currentChild.type === "numbered_list_item") {
|
|
508
|
+
const groupType = currentChild.type;
|
|
509
|
+
const currentGroup = [currentChild];
|
|
510
|
+
let j = i + 1;
|
|
511
|
+
while (j < children.length) {
|
|
512
|
+
const nextChildInGroup = children[j];
|
|
513
|
+
if (!nextChildInGroup) {
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
if (nextChildInGroup.type === groupType) {
|
|
517
|
+
currentGroup.push(
|
|
518
|
+
nextChildInGroup
|
|
519
|
+
);
|
|
520
|
+
j++;
|
|
521
|
+
} else {
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
renderedChildren.push(
|
|
526
|
+
/* @__PURE__ */ jsx7(
|
|
527
|
+
ListGroup,
|
|
528
|
+
{
|
|
529
|
+
blocks: currentGroup,
|
|
530
|
+
type: groupType,
|
|
531
|
+
renderBlock
|
|
532
|
+
},
|
|
533
|
+
`${currentChild.id}-group`
|
|
534
|
+
)
|
|
535
|
+
);
|
|
536
|
+
i = j;
|
|
537
|
+
} else {
|
|
538
|
+
renderedChildren.push(
|
|
539
|
+
/* @__PURE__ */ jsx7("div", { children: renderBlock(currentChild, block.id) }, currentChild.id)
|
|
540
|
+
);
|
|
541
|
+
i++;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
496
545
|
return /* @__PURE__ */ jsxs4(ListItem, { children: [
|
|
497
546
|
/* @__PURE__ */ jsx7(MemoizedRichText, { richTexts }),
|
|
498
|
-
|
|
547
|
+
renderedChildren.length > 0 && renderedChildren
|
|
499
548
|
] });
|
|
500
549
|
};
|
|
501
|
-
var
|
|
502
|
-
if (
|
|
503
|
-
return /* @__PURE__ */ jsx7(
|
|
504
|
-
List,
|
|
505
|
-
{
|
|
506
|
-
as: type === "numbered_list_item" ? "ol" : "ul",
|
|
507
|
-
type,
|
|
508
|
-
role: "list",
|
|
509
|
-
"aria-label": type,
|
|
510
|
-
children: blocks.map((block) => /* @__PURE__ */ jsx7(RecursiveListItem, { block }, block.id))
|
|
511
|
-
}
|
|
512
|
-
);
|
|
513
|
-
};
|
|
514
|
-
var ListBlocksRenderer = ({
|
|
515
|
-
blocks,
|
|
516
|
-
startIndex,
|
|
517
|
-
type
|
|
518
|
-
}) => {
|
|
519
|
-
let consecutiveItems = 0;
|
|
520
|
-
for (let i = startIndex; i < blocks.length; i++) {
|
|
521
|
-
const block = blocks[i];
|
|
522
|
-
if (!block) break;
|
|
523
|
-
if (block.type === type) {
|
|
524
|
-
consecutiveItems++;
|
|
525
|
-
} else {
|
|
526
|
-
break;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
const listItems = blocks.slice(startIndex, startIndex + consecutiveItems);
|
|
550
|
+
var ListGroup = ({ blocks, type, renderBlock }) => {
|
|
551
|
+
if (blocks.length === 0) return null;
|
|
530
552
|
return /* @__PURE__ */ jsx7(
|
|
531
553
|
List,
|
|
532
554
|
{
|
|
@@ -534,11 +556,17 @@ var ListBlocksRenderer = ({
|
|
|
534
556
|
type,
|
|
535
557
|
role: "list",
|
|
536
558
|
"aria-label": type,
|
|
537
|
-
children:
|
|
559
|
+
children: blocks.map((block) => /* @__PURE__ */ jsx7(
|
|
560
|
+
RecursiveListItem,
|
|
561
|
+
{
|
|
562
|
+
block,
|
|
563
|
+
renderBlock
|
|
564
|
+
},
|
|
565
|
+
block.id
|
|
566
|
+
))
|
|
538
567
|
}
|
|
539
568
|
);
|
|
540
569
|
};
|
|
541
|
-
var ListBlocksRenderer_default = ListBlocksRenderer;
|
|
542
570
|
|
|
543
571
|
// src/components/Renderer/components/Code/CodeBlock.tsx
|
|
544
572
|
import { useMemo } from "react";
|
|
@@ -577,7 +605,7 @@ var CodeBlock = ({ code, language, caption: caption2 }) => {
|
|
|
577
605
|
}, [code, language]);
|
|
578
606
|
return /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
579
607
|
/* @__PURE__ */ jsx8("pre", { className: `${codeBlock} language-${language}`, children: /* @__PURE__ */ jsx8("code", { className: `language-${language}`, children: tokens.map((token, i) => renderToken(token, i)) }) }),
|
|
580
|
-
caption2 && /* @__PURE__ */ jsx8("figcaption", { children: /* @__PURE__ */ jsx8(MemoizedRichText, { richTexts: caption2 }) })
|
|
608
|
+
caption2 && caption2.length > 0 && /* @__PURE__ */ jsx8("figcaption", { children: /* @__PURE__ */ jsx8(MemoizedRichText, { richTexts: caption2 }) })
|
|
581
609
|
] });
|
|
582
610
|
};
|
|
583
611
|
var CodeBlock_default = CodeBlock;
|
|
@@ -935,20 +963,26 @@ var Renderer = memo2(({ blocks, isDarkMode = false, title: title3, cover }) => {
|
|
|
935
963
|
const handleListItem = (listType) => {
|
|
936
964
|
const listItemType = `${listType}_list_item`;
|
|
937
965
|
if (block.type === listItemType && (i === 0 || blocks[i - 1]?.type !== listItemType)) {
|
|
966
|
+
const listItems = [];
|
|
967
|
+
let j = i;
|
|
968
|
+
while (j < blocks.length && blocks[j] && blocks[j]?.type === listItemType) {
|
|
969
|
+
listItems.push(
|
|
970
|
+
blocks[j]
|
|
971
|
+
);
|
|
972
|
+
j++;
|
|
973
|
+
}
|
|
938
974
|
result.push(
|
|
939
975
|
/* @__PURE__ */ jsx20(
|
|
940
|
-
|
|
976
|
+
ListGroup,
|
|
941
977
|
{
|
|
942
|
-
blocks,
|
|
943
|
-
|
|
944
|
-
|
|
978
|
+
blocks: listItems,
|
|
979
|
+
type: listItemType,
|
|
980
|
+
renderBlock: (childBlock) => /* @__PURE__ */ jsx20(BlockRenderer_default, { block: childBlock })
|
|
945
981
|
},
|
|
946
982
|
block.id
|
|
947
983
|
)
|
|
948
984
|
);
|
|
949
|
-
|
|
950
|
-
i++;
|
|
951
|
-
}
|
|
985
|
+
i = j - 1;
|
|
952
986
|
return true;
|
|
953
987
|
}
|
|
954
988
|
return false;
|