notion-to-jsx 1.1.1 → 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/dist/index.css +121 -11
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +28 -8
- package/dist/index.d.ts +28 -8
- package/dist/index.js +349 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +347 -67
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/components/Renderer/index.tsx
|
|
2
|
-
import
|
|
2
|
+
import React7, { useState as useState5, useMemo as useMemo2, useCallback } from "react";
|
|
3
3
|
|
|
4
4
|
// src/components/Renderer/styles.css.ts
|
|
5
5
|
var container = "styles_container__epva5u0";
|
|
@@ -38,19 +38,29 @@ var richText = _7a4682({ defaultClassName: "styles_richText__fdf3tw0", variantCl
|
|
|
38
38
|
|
|
39
39
|
// src/components/Renderer/components/RichText/RichTexts.tsx
|
|
40
40
|
import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
|
|
41
|
+
var renderLink = (href, content3) => /* @__PURE__ */ jsx2("a", { href, target: "_blank", rel: "noopener noreferrer", className: link, children: content3 });
|
|
41
42
|
var RichTexts = ({ richTexts }) => {
|
|
42
43
|
return /* @__PURE__ */ jsx2(Fragment, { children: richTexts.map((text, index) => {
|
|
43
|
-
const { bold, italic, strikethrough, underline, code
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
const { bold, italic, strikethrough, underline, code } = text.annotations;
|
|
45
|
+
let content3;
|
|
46
|
+
switch (text.type) {
|
|
47
|
+
case "text": {
|
|
48
|
+
if (text.text) {
|
|
49
|
+
const { text: textData } = text;
|
|
50
|
+
content3 = textData.link ? renderLink(textData.link, textData.content) : textData.content;
|
|
51
|
+
} else {
|
|
52
|
+
content3 = text.plain_text;
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
case "mention": {
|
|
57
|
+
content3 = text.href ? renderLink(text.href, text.plain_text) : text.plain_text;
|
|
58
|
+
break;
|
|
52
59
|
}
|
|
53
|
-
|
|
60
|
+
default: {
|
|
61
|
+
content3 = text.plain_text;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
54
64
|
return /* @__PURE__ */ jsx2(
|
|
55
65
|
"span",
|
|
56
66
|
{
|
|
@@ -247,8 +257,8 @@ var fetchOpenGraphData = async (url) => {
|
|
|
247
257
|
if (!response.ok) {
|
|
248
258
|
throw new Error("Failed to fetch metadata");
|
|
249
259
|
}
|
|
250
|
-
const { status, data: metaData } = data;
|
|
251
|
-
if (status !== "success") {
|
|
260
|
+
const { status, data: metaData, statusCode } = data;
|
|
261
|
+
if (status !== "success" || statusCode !== 200) {
|
|
252
262
|
throw new Error("API returned error status");
|
|
253
263
|
}
|
|
254
264
|
const parsedUrl = new URL(url);
|
|
@@ -321,13 +331,15 @@ var Bookmark_default = Bookmark;
|
|
|
321
331
|
import { useState as useState3, useEffect as useEffect3 } from "react";
|
|
322
332
|
|
|
323
333
|
// src/components/Renderer/components/LinkPreview/styles.css.ts
|
|
324
|
-
var card2 = "styles_card__o1p3m11";
|
|
325
334
|
var content2 = "styles_content__o1p3m12";
|
|
335
|
+
var description2 = "styles_description__o1p3m16";
|
|
336
|
+
var githubContent = "styles_githubContent__o1p3m18";
|
|
337
|
+
var githubPreview = "styles_githubPreview__o1p3m17";
|
|
326
338
|
var icon = "styles_icon__o1p3m14";
|
|
327
339
|
var iconContainer = "styles_iconContainer__o1p3m13";
|
|
328
340
|
var link3 = "styles_link__o1p3m10";
|
|
341
|
+
var preview = "styles_preview__o1p3m11";
|
|
329
342
|
var title2 = "styles_title__o1p3m15";
|
|
330
|
-
var updatedText = "styles_updatedText__o1p3m16";
|
|
331
343
|
|
|
332
344
|
// src/components/Renderer/components/LinkPreview/LinkPreview.tsx
|
|
333
345
|
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
@@ -345,6 +357,48 @@ var fetchGitHubRepoData = async (repoPath) => {
|
|
|
345
357
|
return null;
|
|
346
358
|
}
|
|
347
359
|
};
|
|
360
|
+
var extractFigmaData = (url) => {
|
|
361
|
+
try {
|
|
362
|
+
const parsedUrl = new URL(url);
|
|
363
|
+
if (parsedUrl.hostname.includes("figma.com")) {
|
|
364
|
+
const pathSegments = parsedUrl.pathname.split("/");
|
|
365
|
+
const fileSegment = pathSegments.find(
|
|
366
|
+
(segment) => segment.includes("file")
|
|
367
|
+
);
|
|
368
|
+
if (!fileSegment) return null;
|
|
369
|
+
const fileIdMatch = fileSegment.match(/file\/([^/]+)/);
|
|
370
|
+
const fileId = fileIdMatch ? fileIdMatch[1] : "";
|
|
371
|
+
let fileName = "";
|
|
372
|
+
let mode = "";
|
|
373
|
+
if (pathSegments.length > 3) {
|
|
374
|
+
const encodedName = pathSegments[3];
|
|
375
|
+
if (encodedName) {
|
|
376
|
+
fileName = decodeURIComponent(encodedName).replace(/-/g, " ");
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (!fileName && parsedUrl.pathname.includes("-")) {
|
|
380
|
+
const nameMatch = parsedUrl.pathname.match(/\/([^/]+)(?:\?|$)/);
|
|
381
|
+
if (nameMatch && nameMatch[1]) {
|
|
382
|
+
fileName = decodeURIComponent(nameMatch[1].replace(/-/g, " "));
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (parsedUrl.search) {
|
|
386
|
+
const searchParams = new URLSearchParams(parsedUrl.search);
|
|
387
|
+
mode = searchParams.get("mode") || "";
|
|
388
|
+
}
|
|
389
|
+
fileName = fileName || "Figma Design";
|
|
390
|
+
return {
|
|
391
|
+
name: fileName,
|
|
392
|
+
url,
|
|
393
|
+
thumbnailUrl: "https://static.figma.com/app/icon/1/favicon.svg"
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
return null;
|
|
397
|
+
} catch (error) {
|
|
398
|
+
console.error("Error parsing Figma URL:", error);
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
};
|
|
348
402
|
var extractRepoPathFromUrl = (url) => {
|
|
349
403
|
try {
|
|
350
404
|
const parsedUrl = new URL(url);
|
|
@@ -361,6 +415,19 @@ var extractRepoPathFromUrl = (url) => {
|
|
|
361
415
|
return null;
|
|
362
416
|
}
|
|
363
417
|
};
|
|
418
|
+
var getLinkType = (url) => {
|
|
419
|
+
try {
|
|
420
|
+
const parsedUrl = new URL(url);
|
|
421
|
+
if (parsedUrl.hostname === "github.com") {
|
|
422
|
+
return "github";
|
|
423
|
+
} else if (parsedUrl.hostname.includes("figma.com")) {
|
|
424
|
+
return "figma";
|
|
425
|
+
}
|
|
426
|
+
return "unknown";
|
|
427
|
+
} catch {
|
|
428
|
+
return "unknown";
|
|
429
|
+
}
|
|
430
|
+
};
|
|
364
431
|
var formatUpdatedTime = (dateString) => {
|
|
365
432
|
const date = new Date(dateString);
|
|
366
433
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -396,35 +463,77 @@ var formatUpdatedTime = (dateString) => {
|
|
|
396
463
|
};
|
|
397
464
|
var LinkPreview = ({ url }) => {
|
|
398
465
|
const [repoData, setRepoData] = useState3(null);
|
|
466
|
+
const [figmaData, setFigmaData] = useState3(null);
|
|
399
467
|
const [loading, setLoading] = useState3(true);
|
|
468
|
+
const [linkType, setLinkType] = useState3(
|
|
469
|
+
"unknown"
|
|
470
|
+
);
|
|
400
471
|
useEffect3(() => {
|
|
401
|
-
const
|
|
472
|
+
const loadLinkData = async () => {
|
|
402
473
|
setLoading(true);
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
474
|
+
const type = getLinkType(url);
|
|
475
|
+
setLinkType(type);
|
|
476
|
+
if (type === "github") {
|
|
477
|
+
const repoPath = extractRepoPathFromUrl(url);
|
|
478
|
+
if (repoPath) {
|
|
479
|
+
const data = await fetchGitHubRepoData(repoPath);
|
|
480
|
+
setRepoData(data);
|
|
481
|
+
}
|
|
482
|
+
} else if (type === "figma") {
|
|
483
|
+
const data = extractFigmaData(url);
|
|
484
|
+
setFigmaData(data);
|
|
407
485
|
}
|
|
408
486
|
setLoading(false);
|
|
409
487
|
};
|
|
410
|
-
|
|
488
|
+
loadLinkData();
|
|
411
489
|
}, [url]);
|
|
412
490
|
const repoName = repoData?.name || extractRepoPathFromUrl(url)?.split("/")[1] || "Repository";
|
|
413
491
|
const updatedTimeText = repoData?.updated_at ? formatUpdatedTime(repoData.updated_at) : "";
|
|
414
|
-
return /* @__PURE__ */ jsx5(
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
492
|
+
return /* @__PURE__ */ jsx5(
|
|
493
|
+
"a",
|
|
494
|
+
{
|
|
495
|
+
href: url,
|
|
496
|
+
target: "_blank",
|
|
497
|
+
rel: "noopener noreferrer",
|
|
498
|
+
className: link3,
|
|
499
|
+
children: linkType === "figma" && figmaData ? (
|
|
500
|
+
// Figma 프리뷰 렌더링
|
|
501
|
+
/* @__PURE__ */ jsxs3("div", { className: preview, children: [
|
|
502
|
+
/* @__PURE__ */ jsx5("div", { className: iconContainer, children: /* @__PURE__ */ jsx5(
|
|
503
|
+
"img",
|
|
504
|
+
{
|
|
505
|
+
src: figmaData.thumbnailUrl || "https://static.figma.com/app/icon/1/favicon.svg",
|
|
506
|
+
alt: "Figma icon",
|
|
507
|
+
className: icon
|
|
508
|
+
}
|
|
509
|
+
) }),
|
|
510
|
+
/* @__PURE__ */ jsxs3("div", { className: content2, children: [
|
|
511
|
+
/* @__PURE__ */ jsx5("div", { className: title2, children: figmaData.name }),
|
|
512
|
+
/* @__PURE__ */ jsx5("div", { className: description2, children: "www.figma.com" })
|
|
513
|
+
] })
|
|
514
|
+
] })
|
|
515
|
+
) : linkType === "github" ? (
|
|
516
|
+
// GitHub 프리뷰 렌더링
|
|
517
|
+
/* @__PURE__ */ jsxs3("div", { className: `${preview} ${githubPreview}`, children: [
|
|
518
|
+
/* @__PURE__ */ jsx5("div", { className: iconContainer, children: /* @__PURE__ */ jsx5(
|
|
519
|
+
"img",
|
|
520
|
+
{
|
|
521
|
+
src: repoData?.owner?.avatar_url || "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
|
|
522
|
+
alt: "Repository icon",
|
|
523
|
+
className: icon
|
|
524
|
+
}
|
|
525
|
+
) }),
|
|
526
|
+
/* @__PURE__ */ jsxs3("div", { className: `${content2} ${githubContent}`, children: [
|
|
527
|
+
/* @__PURE__ */ jsx5("div", { className: title2, children: repoName }),
|
|
528
|
+
/* @__PURE__ */ jsx5("div", { className: description2, children: loading ? "Loading..." : `${repoName} \u2022 ${updatedTimeText}` })
|
|
529
|
+
] })
|
|
530
|
+
] })
|
|
531
|
+
) : (
|
|
532
|
+
// 기본 링크 프리뷰 렌더링
|
|
533
|
+
/* @__PURE__ */ jsx5("div", { className: preview, children: /* @__PURE__ */ jsx5("div", { className: content2, children: /* @__PURE__ */ jsx5("div", { className: title2, children: url }) }) })
|
|
534
|
+
)
|
|
535
|
+
}
|
|
536
|
+
);
|
|
428
537
|
};
|
|
429
538
|
var LinkPreview_default = LinkPreview;
|
|
430
539
|
|
|
@@ -455,8 +564,7 @@ var MemoizedLinkPreview = React4.memo(
|
|
|
455
564
|
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
456
565
|
var RecursiveListItem = ({ block, index }) => {
|
|
457
566
|
const blockProps = {
|
|
458
|
-
tabIndex: 0
|
|
459
|
-
"data-block-id": block.id
|
|
567
|
+
tabIndex: 0
|
|
460
568
|
};
|
|
461
569
|
const blockType = block.type;
|
|
462
570
|
const richTexts = block[blockType]?.rich_text;
|
|
@@ -581,34 +689,195 @@ var Heading3 = ({
|
|
|
581
689
|
return /* @__PURE__ */ jsx8("h3", { className: heading3, ...props, children });
|
|
582
690
|
};
|
|
583
691
|
|
|
584
|
-
// src/components/Renderer/components/
|
|
692
|
+
// src/components/Renderer/components/Column/styles.css.ts
|
|
693
|
+
var columnContainer = "styles_columnContainer__wle6we0";
|
|
694
|
+
var columnListContainer = "styles_columnListContainer__wle6we1";
|
|
695
|
+
|
|
696
|
+
// src/components/Renderer/components/Column/Column.tsx
|
|
585
697
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
698
|
+
var Column = ({ block, onFocus }) => {
|
|
699
|
+
if (!block || !block.children) return null;
|
|
700
|
+
return /* @__PURE__ */ jsx9("div", { className: columnContainer, children: block.children.map((childBlock, index) => /* @__PURE__ */ jsx9(
|
|
701
|
+
BlockRenderer_default,
|
|
702
|
+
{
|
|
703
|
+
block: childBlock,
|
|
704
|
+
onFocus,
|
|
705
|
+
index
|
|
706
|
+
},
|
|
707
|
+
childBlock.id
|
|
708
|
+
)) });
|
|
709
|
+
};
|
|
710
|
+
var Column_default = Column;
|
|
711
|
+
|
|
712
|
+
// src/components/Renderer/components/Column/ColumnList.tsx
|
|
713
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
714
|
+
var ColumnList = ({ block, onFocus }) => {
|
|
715
|
+
if (!block || !block.children) return null;
|
|
716
|
+
return /* @__PURE__ */ jsx10("div", { className: columnListContainer, children: block.children.map((column) => /* @__PURE__ */ jsx10(Column_default, { block: column, onFocus }, column.id)) });
|
|
717
|
+
};
|
|
718
|
+
var ColumnList_default = ColumnList;
|
|
719
|
+
|
|
720
|
+
// src/components/Renderer/components/Quote/styles.css.ts
|
|
721
|
+
var container2 = "styles_container__mra9n0";
|
|
722
|
+
|
|
723
|
+
// src/components/Renderer/components/Quote/Quote.tsx
|
|
724
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
725
|
+
var Quote = ({ richTexts, tabIndex }) => {
|
|
726
|
+
return /* @__PURE__ */ jsx11("blockquote", { className: container2, tabIndex, children: /* @__PURE__ */ jsx11(MemoizedRichText, { richTexts }) });
|
|
727
|
+
};
|
|
728
|
+
var Quote_default = Quote;
|
|
729
|
+
|
|
730
|
+
// src/components/Renderer/components/Table/styles.css.ts
|
|
731
|
+
var firstCell = "styles_firstCell__1rvbzfo4";
|
|
732
|
+
var hasRowHeader = "styles_hasRowHeader__1rvbzfo6";
|
|
733
|
+
var headerCell = "styles_headerCell__1rvbzfo2";
|
|
734
|
+
var lastCell = "styles_lastCell__1rvbzfo5";
|
|
735
|
+
var table = "styles_table__1rvbzfo1";
|
|
736
|
+
var tableCell = "styles_tableCell__1rvbzfo3";
|
|
737
|
+
var tableContainer = "styles_tableContainer__1rvbzfo0";
|
|
738
|
+
|
|
739
|
+
// src/components/Renderer/components/Table/TableRow.tsx
|
|
740
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
741
|
+
var TableRow = ({
|
|
742
|
+
rowBlock,
|
|
743
|
+
cellClassName = "",
|
|
744
|
+
rowHeaderIndex = -1
|
|
745
|
+
}) => {
|
|
746
|
+
if (!rowBlock.table_row?.cells) {
|
|
747
|
+
return null;
|
|
748
|
+
}
|
|
749
|
+
const { cells } = rowBlock.table_row;
|
|
750
|
+
return /* @__PURE__ */ jsx12("tr", { children: cells.map((cell, index) => {
|
|
751
|
+
const isFirstCell = index === 0;
|
|
752
|
+
const isLastCell = index === cells.length - 1;
|
|
753
|
+
const isRowHeader = index === rowHeaderIndex;
|
|
754
|
+
let cellClasses = [tableCell, cellClassName];
|
|
755
|
+
if (isFirstCell) cellClasses.push(firstCell);
|
|
756
|
+
if (isLastCell) cellClasses.push(lastCell);
|
|
757
|
+
if (isRowHeader) cellClasses.push(hasRowHeader);
|
|
758
|
+
return /* @__PURE__ */ jsx12(
|
|
759
|
+
"td",
|
|
760
|
+
{
|
|
761
|
+
className: cellClasses.filter(Boolean).join(" "),
|
|
762
|
+
children: /* @__PURE__ */ jsx12(MemoizedRichText, { richTexts: cell })
|
|
763
|
+
},
|
|
764
|
+
`${rowBlock.id}-cell-${index}`
|
|
765
|
+
);
|
|
766
|
+
}) });
|
|
767
|
+
};
|
|
768
|
+
var TableRow_default = TableRow;
|
|
769
|
+
|
|
770
|
+
// src/components/Renderer/components/Table/Table.tsx
|
|
771
|
+
import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
772
|
+
var Table = ({ block, tabIndex = 0 }) => {
|
|
773
|
+
if (!block.table || !block.children) {
|
|
774
|
+
return null;
|
|
775
|
+
}
|
|
776
|
+
const { table_width, has_column_header, has_row_header } = block.table;
|
|
777
|
+
const rows = block.children?.filter(
|
|
778
|
+
(child) => child.type === "table_row"
|
|
779
|
+
) || [];
|
|
780
|
+
return /* @__PURE__ */ jsx13("div", { className: tableContainer, children: /* @__PURE__ */ jsx13("table", { className: table, tabIndex, children: rows.length > 0 && /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
781
|
+
has_column_header && rows[0] && /* @__PURE__ */ jsx13("thead", { children: /* @__PURE__ */ jsx13(TableRow_default, { rowBlock: rows[0], cellClassName: headerCell }) }),
|
|
782
|
+
/* @__PURE__ */ jsx13("tbody", { children: rows.filter(
|
|
783
|
+
(row) => row !== void 0 && row.type === "table_row"
|
|
784
|
+
).map((row, rowIndex) => {
|
|
785
|
+
if (has_column_header && rowIndex === 0) {
|
|
786
|
+
return null;
|
|
787
|
+
}
|
|
788
|
+
const actualRowIndex = has_column_header ? rowIndex - 1 : rowIndex;
|
|
789
|
+
return /* @__PURE__ */ jsx13(
|
|
790
|
+
TableRow_default,
|
|
791
|
+
{
|
|
792
|
+
rowBlock: row,
|
|
793
|
+
rowHeaderIndex: has_row_header ? 0 : -1
|
|
794
|
+
},
|
|
795
|
+
row.id
|
|
796
|
+
);
|
|
797
|
+
}) })
|
|
798
|
+
] }) }) });
|
|
799
|
+
};
|
|
800
|
+
var Table_default = Table;
|
|
801
|
+
|
|
802
|
+
// src/components/Renderer/components/Table/index.ts
|
|
803
|
+
var Table_default2 = Table_default;
|
|
804
|
+
|
|
805
|
+
// src/components/Renderer/components/Toggle/Toggle.tsx
|
|
806
|
+
import { useState as useState4 } from "react";
|
|
807
|
+
|
|
808
|
+
// src/components/Renderer/components/Toggle/styles.css.ts
|
|
809
|
+
var toggleContainer = "styles_toggleContainer__p7ue1z0";
|
|
810
|
+
var toggleContent = "styles_toggleContent__p7ue1z4";
|
|
811
|
+
var toggleHeader = "styles_toggleHeader__p7ue1z1";
|
|
812
|
+
var toggleIcon = "styles_toggleIcon__p7ue1z2";
|
|
813
|
+
var toggleIconOpen = "styles_toggleIconOpen__p7ue1z3";
|
|
814
|
+
|
|
815
|
+
// src/components/Renderer/components/Toggle/Toggle.tsx
|
|
816
|
+
import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
817
|
+
var Toggle = ({ block, tabIndex = 0, onFocus }) => {
|
|
818
|
+
const [isOpen, setIsOpen] = useState4(false);
|
|
819
|
+
if (!block.toggle || !block.children) {
|
|
820
|
+
return null;
|
|
821
|
+
}
|
|
822
|
+
const handleToggle = () => {
|
|
823
|
+
setIsOpen(!isOpen);
|
|
824
|
+
};
|
|
825
|
+
const handleKeyDown = (e) => {
|
|
826
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
827
|
+
e.preventDefault();
|
|
828
|
+
handleToggle();
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
return /* @__PURE__ */ jsxs7("div", { className: toggleContainer, children: [
|
|
832
|
+
/* @__PURE__ */ jsxs7(
|
|
833
|
+
"div",
|
|
834
|
+
{
|
|
835
|
+
className: toggleHeader,
|
|
836
|
+
onClick: handleToggle,
|
|
837
|
+
onKeyDown: handleKeyDown,
|
|
838
|
+
tabIndex,
|
|
839
|
+
onFocus,
|
|
840
|
+
role: "button",
|
|
841
|
+
"aria-expanded": isOpen,
|
|
842
|
+
children: [
|
|
843
|
+
/* @__PURE__ */ jsx14("span", { className: `${toggleIcon} ${isOpen ? toggleIconOpen : ""}`, children: "\u25B6" }),
|
|
844
|
+
/* @__PURE__ */ jsx14(RichTexts_default, { richTexts: block.toggle.rich_text })
|
|
845
|
+
]
|
|
846
|
+
}
|
|
847
|
+
),
|
|
848
|
+
isOpen && block.children && /* @__PURE__ */ jsx14("div", { className: toggleContent, children: block.children.map((childBlock, index) => /* @__PURE__ */ jsx14(
|
|
849
|
+
BlockRenderer_default,
|
|
850
|
+
{
|
|
851
|
+
block: childBlock,
|
|
852
|
+
index
|
|
853
|
+
},
|
|
854
|
+
childBlock.id
|
|
855
|
+
)) })
|
|
856
|
+
] });
|
|
857
|
+
};
|
|
858
|
+
var Toggle_default = Toggle;
|
|
859
|
+
|
|
860
|
+
// src/components/Renderer/components/Block/BlockRenderer.tsx
|
|
861
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
586
862
|
var BlockRenderer = ({ block, onFocus, index }) => {
|
|
587
863
|
if (!block) return null;
|
|
588
864
|
const blockProps = {
|
|
589
865
|
tabIndex: 0,
|
|
590
|
-
onFocus
|
|
591
|
-
"data-block-id": block.id
|
|
866
|
+
onFocus
|
|
592
867
|
};
|
|
593
868
|
switch (block.type) {
|
|
594
869
|
case "link_preview":
|
|
595
|
-
return /* @__PURE__ */
|
|
596
|
-
MemoizedLinkPreview,
|
|
597
|
-
{
|
|
598
|
-
url: block.link_preview.url,
|
|
599
|
-
...blockProps
|
|
600
|
-
}
|
|
601
|
-
);
|
|
870
|
+
return /* @__PURE__ */ jsx15(MemoizedLinkPreview, { url: block.link_preview.url, ...blockProps });
|
|
602
871
|
case "paragraph":
|
|
603
|
-
return /* @__PURE__ */
|
|
872
|
+
return /* @__PURE__ */ jsx15(Paragraph, { ...blockProps, children: /* @__PURE__ */ jsx15(MemoizedRichText, { richTexts: block.paragraph.rich_text }) });
|
|
604
873
|
case "heading_1":
|
|
605
|
-
return /* @__PURE__ */
|
|
874
|
+
return /* @__PURE__ */ jsx15(Heading1, { ...blockProps, children: /* @__PURE__ */ jsx15(MemoizedRichText, { richTexts: block.heading_1.rich_text }) });
|
|
606
875
|
case "heading_2":
|
|
607
|
-
return /* @__PURE__ */
|
|
876
|
+
return /* @__PURE__ */ jsx15(Heading2, { ...blockProps, children: /* @__PURE__ */ jsx15(MemoizedRichText, { richTexts: block.heading_2.rich_text }) });
|
|
608
877
|
case "heading_3":
|
|
609
|
-
return /* @__PURE__ */
|
|
878
|
+
return /* @__PURE__ */ jsx15(Heading3, { ...blockProps, children: /* @__PURE__ */ jsx15(MemoizedRichText, { richTexts: block.heading_3.rich_text }) });
|
|
610
879
|
case "code":
|
|
611
|
-
return /* @__PURE__ */
|
|
880
|
+
return /* @__PURE__ */ jsx15("div", { ...blockProps, children: /* @__PURE__ */ jsx15(
|
|
612
881
|
CodeBlock_default,
|
|
613
882
|
{
|
|
614
883
|
code: block.code.rich_text[0].text.content,
|
|
@@ -617,7 +886,7 @@ var BlockRenderer = ({ block, onFocus, index }) => {
|
|
|
617
886
|
}
|
|
618
887
|
) });
|
|
619
888
|
case "image":
|
|
620
|
-
return /* @__PURE__ */
|
|
889
|
+
return /* @__PURE__ */ jsx15("figure", { ...blockProps, children: /* @__PURE__ */ jsx15(
|
|
621
890
|
MemoizedImage,
|
|
622
891
|
{
|
|
623
892
|
src: block.image.file?.url || block.image.external?.url,
|
|
@@ -627,8 +896,19 @@ var BlockRenderer = ({ block, onFocus, index }) => {
|
|
|
627
896
|
}
|
|
628
897
|
) });
|
|
629
898
|
case "bookmark":
|
|
630
|
-
return /* @__PURE__ */
|
|
899
|
+
return /* @__PURE__ */ jsx15(MemoizedBookmark, { url: block.bookmark.url });
|
|
900
|
+
case "column_list":
|
|
901
|
+
return /* @__PURE__ */ jsx15(ColumnList_default, { block, onFocus });
|
|
902
|
+
case "column":
|
|
903
|
+
return null;
|
|
904
|
+
case "quote":
|
|
905
|
+
return /* @__PURE__ */ jsx15(Quote_default, { richTexts: block.quote.rich_text, ...blockProps });
|
|
906
|
+
case "table":
|
|
907
|
+
return /* @__PURE__ */ jsx15(Table_default2, { block, tabIndex: blockProps.tabIndex });
|
|
908
|
+
case "toggle":
|
|
909
|
+
return /* @__PURE__ */ jsx15(Toggle_default, { block, tabIndex: blockProps.tabIndex, onFocus });
|
|
631
910
|
default:
|
|
911
|
+
console.log(`\uC9C0\uC6D0\uB418\uC9C0 \uC54A\uB294 \uBE14\uB85D \uD0C0\uC785: ${block.type}`, block);
|
|
632
912
|
return null;
|
|
633
913
|
}
|
|
634
914
|
};
|
|
@@ -639,9 +919,9 @@ var darkTheme = "theme_darkTheme__sq3jkb15";
|
|
|
639
919
|
var lightTheme = "theme_lightTheme__sq3jkb14";
|
|
640
920
|
|
|
641
921
|
// src/components/Title/index.tsx
|
|
642
|
-
import { jsx as
|
|
922
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
643
923
|
var Title = ({ title: title3 }) => {
|
|
644
|
-
return /* @__PURE__ */
|
|
924
|
+
return /* @__PURE__ */ jsx16(Heading1, { children: title3 });
|
|
645
925
|
};
|
|
646
926
|
var Title_default = Title;
|
|
647
927
|
|
|
@@ -649,18 +929,18 @@ var Title_default = Title;
|
|
|
649
929
|
var cover = "styles_cover__p0cp8d0";
|
|
650
930
|
|
|
651
931
|
// src/components/Cover/index.tsx
|
|
652
|
-
import { jsx as
|
|
932
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
653
933
|
var Cover = ({ src, alt }) => {
|
|
654
|
-
return /* @__PURE__ */
|
|
934
|
+
return /* @__PURE__ */ jsx17("img", { src, alt, className: cover });
|
|
655
935
|
};
|
|
656
936
|
var Cover_default = Cover;
|
|
657
937
|
|
|
658
938
|
// src/components/Renderer/index.tsx
|
|
659
|
-
import { Fragment as
|
|
660
|
-
var Renderer =
|
|
939
|
+
import { Fragment as Fragment4, jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
940
|
+
var Renderer = React7.memo(
|
|
661
941
|
({ blocks, isDarkMode = false, title: title3, cover: cover2, onBlockFocus }) => {
|
|
662
942
|
const theme = isDarkMode ? darkTheme : lightTheme;
|
|
663
|
-
const [focusedIndex, setFocusedIndex] =
|
|
943
|
+
const [focusedIndex, setFocusedIndex] = useState5(-1);
|
|
664
944
|
const handleBlockFocus = useCallback(
|
|
665
945
|
(index) => {
|
|
666
946
|
setFocusedIndex(index);
|
|
@@ -677,7 +957,7 @@ var Renderer = React6.memo(
|
|
|
677
957
|
const listItemType = `${listType}_list_item`;
|
|
678
958
|
if (block.type === listItemType && (i === 0 || blocks[i - 1]?.type !== listItemType)) {
|
|
679
959
|
result.push(
|
|
680
|
-
/* @__PURE__ */
|
|
960
|
+
/* @__PURE__ */ jsx18(
|
|
681
961
|
ListBlocksRenderer_default,
|
|
682
962
|
{
|
|
683
963
|
blocks,
|
|
@@ -698,7 +978,7 @@ var Renderer = React6.memo(
|
|
|
698
978
|
continue;
|
|
699
979
|
} else {
|
|
700
980
|
result.push(
|
|
701
|
-
/* @__PURE__ */
|
|
981
|
+
/* @__PURE__ */ jsx18(
|
|
702
982
|
BlockRenderer_default,
|
|
703
983
|
{
|
|
704
984
|
block,
|
|
@@ -712,15 +992,15 @@ var Renderer = React6.memo(
|
|
|
712
992
|
}
|
|
713
993
|
return result;
|
|
714
994
|
}, [blocks, handleBlockFocus]);
|
|
715
|
-
return /* @__PURE__ */
|
|
716
|
-
cover2 && /* @__PURE__ */
|
|
717
|
-
/* @__PURE__ */
|
|
995
|
+
return /* @__PURE__ */ jsxs8(Fragment4, { children: [
|
|
996
|
+
cover2 && /* @__PURE__ */ jsx18(Cover_default, { src: cover2, alt: title3 || "Notion page content" }),
|
|
997
|
+
/* @__PURE__ */ jsxs8(
|
|
718
998
|
"article",
|
|
719
999
|
{
|
|
720
1000
|
className: `${theme} ${container}`,
|
|
721
1001
|
"aria-label": title3 || "Notion page content",
|
|
722
1002
|
children: [
|
|
723
|
-
title3 && /* @__PURE__ */
|
|
1003
|
+
title3 && /* @__PURE__ */ jsx18(Title_default, { title: title3 }),
|
|
724
1004
|
renderedBlocks
|
|
725
1005
|
]
|
|
726
1006
|
}
|