notion-to-jsx 1.2.10 → 1.2.12

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.mjs CHANGED
@@ -122,7 +122,8 @@ var Skeleton = ({
122
122
  variant = "rect",
123
123
  width,
124
124
  height,
125
- className
125
+ className,
126
+ isLoading = true
126
127
  }) => {
127
128
  const getVariantClass = () => {
128
129
  switch (variant) {
@@ -135,6 +136,9 @@ var Skeleton = ({
135
136
  return rect;
136
137
  }
137
138
  };
139
+ if (!isLoading) {
140
+ return null;
141
+ }
138
142
  return /* @__PURE__ */ jsx3(
139
143
  "div",
140
144
  {
@@ -164,7 +168,7 @@ var Image = ({
164
168
  const [isLoaded, setIsLoaded] = useState(false);
165
169
  return /* @__PURE__ */ jsxs("div", { className: imageContainer, children: [
166
170
  /* @__PURE__ */ jsxs("div", { className: imageWrapper, style: getImageStyles(format, isColumn), children: [
167
- /* @__PURE__ */ jsx4("div", { className: skeletonWrapper({ isLoaded }), children: /* @__PURE__ */ jsx4(Skeleton_default, { variant: "image" }) }),
171
+ /* @__PURE__ */ jsx4("div", { className: skeletonWrapper({ isLoaded }), children: /* @__PURE__ */ jsx4(Skeleton_default, { variant: "image", isLoading: !isLoaded }) }),
168
172
  /* @__PURE__ */ jsx4(
169
173
  "img",
170
174
  {
@@ -761,23 +765,77 @@ var Toggle = ({ block }) => {
761
765
  };
762
766
  var Toggle_default = Toggle;
763
767
 
768
+ // src/components/Renderer/components/Video/styles.css.ts
769
+ var videoCaption = "styles_videoCaption__15b9vkb2";
770
+ var videoContainer = "styles_videoContainer__15b9vkb0";
771
+ var videoPlayer = "styles_videoPlayer__15b9vkb1";
772
+
773
+ // src/components/Renderer/components/Video/Video.tsx
774
+ import { jsx as jsx16, jsxs as jsxs8 } from "react/jsx-runtime";
775
+ var Video = ({ block }) => {
776
+ if (block.type !== "video" || !block.video) {
777
+ return null;
778
+ }
779
+ const { type, external, caption: caption2 } = block.video;
780
+ let videoUrl = "";
781
+ if (type === "external") {
782
+ videoUrl = getVideoEmbedUrl(external?.url);
783
+ }
784
+ if (!videoUrl) {
785
+ return /* @__PURE__ */ jsx16("p", { children: "\uBE44\uB514\uC624\uB97C \uBD88\uB7EC\uC62C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4." });
786
+ }
787
+ return /* @__PURE__ */ jsxs8("div", { className: videoContainer, children: [
788
+ videoUrl.includes("youtube.com/embed/") ? /* @__PURE__ */ jsx16(
789
+ "iframe",
790
+ {
791
+ className: videoPlayer,
792
+ src: videoUrl,
793
+ title: "YouTube video player",
794
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
795
+ allowFullScreen: true
796
+ }
797
+ ) : /* @__PURE__ */ jsxs8("p", { children: [
798
+ "\uC678\uBD80 \uBE44\uB514\uC624 \uB9C1\uD06C:",
799
+ " ",
800
+ /* @__PURE__ */ jsx16("a", { href: videoUrl, target: "_blank", rel: "noopener noreferrer", children: videoUrl })
801
+ ] }),
802
+ caption2 && caption2.length > 0 && /* @__PURE__ */ jsx16("figcaption", { className: videoCaption, children: caption2.map((c, i) => /* @__PURE__ */ jsx16("span", { children: c.plain_text }, i)) })
803
+ ] });
804
+ };
805
+ var getVideoEmbedUrl = (url) => {
806
+ if (!url) return "";
807
+ if (url.includes("youtu.be/")) {
808
+ const videoId = url.split("youtu.be/")[1]?.split("?")[0];
809
+ if (videoId) {
810
+ return `https://www.youtube.com/embed/${videoId}`;
811
+ }
812
+ } else if (url.includes("youtube.com/watch?v=")) {
813
+ const videoId = url.split("watch?v=")[1]?.split("&")[0];
814
+ if (videoId) {
815
+ return `https://www.youtube.com/embed/${videoId}`;
816
+ }
817
+ }
818
+ return url;
819
+ };
820
+ var Video_default = Video;
821
+
764
822
  // src/components/Renderer/components/Block/BlockRenderer.tsx
765
- import { jsx as jsx16 } from "react/jsx-runtime";
823
+ import { jsx as jsx17 } from "react/jsx-runtime";
766
824
  var BlockRenderer = ({ block, isColumn = false }) => {
767
825
  if (!block) return null;
768
826
  switch (block.type) {
769
827
  case "link_preview":
770
- return /* @__PURE__ */ jsx16(MemoizedLinkPreview, { url: block.link_preview.url });
828
+ return /* @__PURE__ */ jsx17(MemoizedLinkPreview, { url: block.link_preview.url });
771
829
  case "paragraph":
772
- return /* @__PURE__ */ jsx16(Paragraph, { children: /* @__PURE__ */ jsx16(MemoizedRichText, { richTexts: block.paragraph.rich_text }) });
830
+ return /* @__PURE__ */ jsx17(Paragraph, { children: /* @__PURE__ */ jsx17(MemoizedRichText, { richTexts: block.paragraph.rich_text }) });
773
831
  case "heading_1":
774
- return /* @__PURE__ */ jsx16(Heading1, { children: /* @__PURE__ */ jsx16(MemoizedRichText, { richTexts: block.heading_1.rich_text }) });
832
+ return /* @__PURE__ */ jsx17(Heading1, { children: /* @__PURE__ */ jsx17(MemoizedRichText, { richTexts: block.heading_1.rich_text }) });
775
833
  case "heading_2":
776
- return /* @__PURE__ */ jsx16(Heading2, { children: /* @__PURE__ */ jsx16(MemoizedRichText, { richTexts: block.heading_2.rich_text }) });
834
+ return /* @__PURE__ */ jsx17(Heading2, { children: /* @__PURE__ */ jsx17(MemoizedRichText, { richTexts: block.heading_2.rich_text }) });
777
835
  case "heading_3":
778
- return /* @__PURE__ */ jsx16(Heading3, { children: /* @__PURE__ */ jsx16(MemoizedRichText, { richTexts: block.heading_3.rich_text }) });
836
+ return /* @__PURE__ */ jsx17(Heading3, { children: /* @__PURE__ */ jsx17(MemoizedRichText, { richTexts: block.heading_3.rich_text }) });
779
837
  case "code":
780
- return /* @__PURE__ */ jsx16("div", { children: /* @__PURE__ */ jsx16(
838
+ return /* @__PURE__ */ jsx17("div", { children: /* @__PURE__ */ jsx17(
781
839
  CodeBlock_default,
782
840
  {
783
841
  code: block.code.rich_text[0]?.text?.content || "",
@@ -786,7 +844,7 @@ var BlockRenderer = ({ block, isColumn = false }) => {
786
844
  }
787
845
  ) });
788
846
  case "image":
789
- return /* @__PURE__ */ jsx16("figure", { children: /* @__PURE__ */ jsx16(
847
+ return /* @__PURE__ */ jsx17("figure", { children: /* @__PURE__ */ jsx17(
790
848
  MemoizedImage,
791
849
  {
792
850
  src: block.image.file?.url || block.image.external?.url || "",
@@ -797,7 +855,7 @@ var BlockRenderer = ({ block, isColumn = false }) => {
797
855
  }
798
856
  ) });
799
857
  case "bookmark":
800
- return /* @__PURE__ */ jsx16(
858
+ return /* @__PURE__ */ jsx17(
801
859
  MemoizedBookmark,
802
860
  {
803
861
  url: block.bookmark.url,
@@ -805,15 +863,17 @@ var BlockRenderer = ({ block, isColumn = false }) => {
805
863
  }
806
864
  );
807
865
  case "column_list":
808
- return /* @__PURE__ */ jsx16(ColumnList_default, { block });
866
+ return /* @__PURE__ */ jsx17(ColumnList_default, { block });
809
867
  case "column":
810
868
  return null;
811
869
  case "quote":
812
- return /* @__PURE__ */ jsx16(Quote_default, { richTexts: block.quote.rich_text });
870
+ return /* @__PURE__ */ jsx17(Quote_default, { richTexts: block.quote.rich_text });
813
871
  case "table":
814
- return /* @__PURE__ */ jsx16(Table_default2, { block });
872
+ return /* @__PURE__ */ jsx17(Table_default2, { block });
815
873
  case "toggle":
816
- return /* @__PURE__ */ jsx16(Toggle_default, { block });
874
+ return /* @__PURE__ */ jsx17(Toggle_default, { block });
875
+ case "video":
876
+ return /* @__PURE__ */ jsx17(Video_default, { block });
817
877
  default:
818
878
  return null;
819
879
  }
@@ -821,9 +881,9 @@ var BlockRenderer = ({ block, isColumn = false }) => {
821
881
  var BlockRenderer_default = BlockRenderer;
822
882
 
823
883
  // src/components/Title/index.tsx
824
- import { jsx as jsx17 } from "react/jsx-runtime";
884
+ import { jsx as jsx18 } from "react/jsx-runtime";
825
885
  var Title = ({ title: title3 }) => {
826
- return /* @__PURE__ */ jsx17(Heading1, { children: title3 });
886
+ return /* @__PURE__ */ jsx18(Heading1, { children: title3 });
827
887
  };
828
888
  var Title_default = Title;
829
889
 
@@ -837,12 +897,12 @@ var imageStyle2 = _7a4684({ defaultClassName: "styles_imageStyle__p0cp8d4", vari
837
897
  var skeletonWrapper2 = _7a4684({ defaultClassName: "styles_skeletonWrapper__p0cp8d1", variantClassNames: { isLoaded: { true: "styles_skeletonWrapper_isLoaded_true__p0cp8d2", false: "styles_skeletonWrapper_isLoaded_false__p0cp8d3" } }, defaultVariants: { isLoaded: false }, compoundVariants: [] });
838
898
 
839
899
  // src/components/Cover/index.tsx
840
- import { jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
900
+ import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
841
901
  var Cover = ({ src, alt }) => {
842
902
  const [isLoaded, setIsLoaded] = useState4(false);
843
- return /* @__PURE__ */ jsxs8("div", { className: coverContainer, children: [
844
- /* @__PURE__ */ jsx18("div", { className: skeletonWrapper2({ isLoaded }), children: /* @__PURE__ */ jsx18(Skeleton_default, { variant: "image" }) }),
845
- /* @__PURE__ */ jsx18(
903
+ return /* @__PURE__ */ jsxs9("div", { className: coverContainer, children: [
904
+ /* @__PURE__ */ jsx19("div", { className: skeletonWrapper2({ isLoaded }), children: /* @__PURE__ */ jsx19(Skeleton_default, { variant: "image", isLoading: !isLoaded }) }),
905
+ /* @__PURE__ */ jsx19(
846
906
  "img",
847
907
  {
848
908
  src,
@@ -864,7 +924,7 @@ var darkTheme = "theme_darkTheme__sq3jkb1n";
864
924
  var lightTheme = "theme_lightTheme__sq3jkb1m";
865
925
 
866
926
  // src/components/Renderer/index.tsx
867
- import { Fragment as Fragment4, jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
927
+ import { Fragment as Fragment4, jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
868
928
  var Renderer = memo2(({ blocks, isDarkMode = false, title: title3, cover }) => {
869
929
  const theme = isDarkMode ? darkTheme : lightTheme;
870
930
  const renderedBlocks = useMemo2(() => {
@@ -876,7 +936,7 @@ var Renderer = memo2(({ blocks, isDarkMode = false, title: title3, cover }) => {
876
936
  const listItemType = `${listType}_list_item`;
877
937
  if (block.type === listItemType && (i === 0 || blocks[i - 1]?.type !== listItemType)) {
878
938
  result.push(
879
- /* @__PURE__ */ jsx19(
939
+ /* @__PURE__ */ jsx20(
880
940
  ListBlocksRenderer_default,
881
941
  {
882
942
  blocks,
@@ -896,20 +956,20 @@ var Renderer = memo2(({ blocks, isDarkMode = false, title: title3, cover }) => {
896
956
  if (handleListItem("bulleted") || handleListItem("numbered")) {
897
957
  continue;
898
958
  } else {
899
- result.push(/* @__PURE__ */ jsx19(BlockRenderer_default, { block }, block.id));
959
+ result.push(/* @__PURE__ */ jsx20(BlockRenderer_default, { block }, block.id));
900
960
  }
901
961
  }
902
962
  return result;
903
963
  }, [blocks]);
904
- return /* @__PURE__ */ jsxs9(Fragment4, { children: [
905
- cover && /* @__PURE__ */ jsx19(Cover_default, { src: cover, alt: title3 || "Notion page content" }),
906
- /* @__PURE__ */ jsxs9(
964
+ return /* @__PURE__ */ jsxs10(Fragment4, { children: [
965
+ cover && /* @__PURE__ */ jsx20(Cover_default, { src: cover, alt: title3 || "Notion page content" }),
966
+ /* @__PURE__ */ jsxs10(
907
967
  "article",
908
968
  {
909
969
  className: `${theme} ${container2}`,
910
970
  "aria-label": title3 || "Notion page content",
911
971
  children: [
912
- title3 && /* @__PURE__ */ jsx19(Title_default, { title: title3 }),
972
+ title3 && /* @__PURE__ */ jsx20(Title_default, { title: title3 }),
913
973
  renderedBlocks
914
974
  ]
915
975
  }