notion-to-jsx 1.2.1 → 1.2.3

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
@@ -33,15 +33,15 @@ import React4 from "react";
33
33
 
34
34
  // src/components/Renderer/components/RichText/styles.css.ts
35
35
  import { createRuntimeFn as _7a4682 } from "@vanilla-extract/recipes/createRuntimeFn";
36
- var link = "styles_link__fdf3tw7";
37
- var richText = _7a4682({ defaultClassName: "styles_richText__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" } }, defaultVariants: {}, compoundVariants: [[{ strikethrough: true, underline: true }, "styles_richText_compound_0__fdf3tw6"]] });
36
+ var link = "styles_link__fdf3twq";
37
+ var richText = _7a4682({ defaultClassName: "styles_richText__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"]] });
38
38
 
39
39
  // src/components/Renderer/components/RichText/RichTexts.tsx
40
40
  import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
41
41
  var renderLink = (href, content3) => /* @__PURE__ */ jsx2("a", { href, target: "_blank", rel: "noopener noreferrer", className: link, children: content3 });
42
42
  var RichTexts = ({ richTexts }) => {
43
43
  return /* @__PURE__ */ jsx2(Fragment, { children: richTexts.map((text, index) => {
44
- const { bold, italic, strikethrough, underline, code } = text.annotations;
44
+ const { bold, italic, strikethrough, underline, code, color } = text.annotations;
45
45
  let content3;
46
46
  switch (text.type) {
47
47
  case "text": {
@@ -61,6 +61,28 @@ var RichTexts = ({ richTexts }) => {
61
61
  content3 = text.plain_text;
62
62
  }
63
63
  }
64
+ const notionColors = [
65
+ "default",
66
+ "gray",
67
+ "brown",
68
+ "orange",
69
+ "yellow",
70
+ "green",
71
+ "blue",
72
+ "purple",
73
+ "pink",
74
+ "red",
75
+ "gray_background",
76
+ "brown_background",
77
+ "orange_background",
78
+ "yellow_background",
79
+ "green_background",
80
+ "blue_background",
81
+ "purple_background",
82
+ "pink_background",
83
+ "red_background"
84
+ ];
85
+ const safeColor = notionColors.includes(color) ? color : void 0;
64
86
  return /* @__PURE__ */ jsx2(
65
87
  "span",
66
88
  {
@@ -69,7 +91,8 @@ var RichTexts = ({ richTexts }) => {
69
91
  italic,
70
92
  strikethrough,
71
93
  underline,
72
- code
94
+ code,
95
+ color: safeColor
73
96
  }),
74
97
  children: content3
75
98
  },
@@ -93,120 +116,71 @@ var styledImage = _7a4683({ defaultClassName: "styles_styledImage__2f3ncf6", var
93
116
  // src/components/Renderer/components/Image/Image.tsx
94
117
  import { jsx as jsx3, jsxs } from "react/jsx-runtime";
95
118
  var MAX_WIDTH = 720;
119
+ var getImageStyles = (format, isColumn = false) => {
120
+ const getWidthStyle = () => {
121
+ if (!isColumn && format?.block_aspect_ratio && format.block_aspect_ratio < 1) {
122
+ return `${format.block_aspect_ratio * 100}%`;
123
+ }
124
+ if (format?.block_width) {
125
+ return format.block_width > MAX_WIDTH ? "100%" : `${format.block_width}px`;
126
+ }
127
+ return "100%";
128
+ };
129
+ const getAspectRatioStyle = () => {
130
+ return format?.block_aspect_ratio ? `${format.block_aspect_ratio}` : "auto";
131
+ };
132
+ return {
133
+ width: getWidthStyle(),
134
+ aspectRatio: getAspectRatioStyle()
135
+ };
136
+ };
137
+ var getImageTagStyle = (format) => {
138
+ return format?.block_aspect_ratio ? { aspectRatio: `${format.block_aspect_ratio}` } : void 0;
139
+ };
96
140
  var Image = ({
97
141
  src,
98
142
  alt,
99
143
  caption: imageCaption,
100
- priority = false,
101
- format
144
+ format,
145
+ isColumn = false
102
146
  }) => {
103
147
  const [isLoaded, setIsLoaded] = useState(false);
104
- const [error, setError] = useState(false);
105
148
  useEffect(() => {
106
149
  setIsLoaded(false);
107
- setError(false);
108
150
  }, [src]);
109
- return /* @__PURE__ */ jsxs("figure", { className: imageContainer, children: [
151
+ return /* @__PURE__ */ jsxs("div", { className: imageContainer, children: [
110
152
  /* @__PURE__ */ jsxs(
111
153
  "div",
112
154
  {
113
155
  className: imageWrapper({
114
156
  hasWidth: !!format?.block_width
115
157
  }),
116
- style: format?.block_width ? {
117
- width: format.block_width > MAX_WIDTH ? "100%" : `${format.block_width}px`
118
- } : void 0,
158
+ style: getImageStyles(format, isColumn),
119
159
  children: [
120
- !isLoaded && !error && /* @__PURE__ */ jsx3(
121
- "div",
122
- {
123
- className: placeholder,
124
- style: {
125
- width: format?.block_width ? format.block_width > MAX_WIDTH ? "100%" : `${format.block_width}px` : "100%",
126
- aspectRatio: format?.block_aspect_ratio ? `${format.block_aspect_ratio}` : "auto"
127
- },
128
- children: /* @__PURE__ */ jsx3(
129
- "svg",
130
- {
131
- width: "38",
132
- height: "38",
133
- viewBox: "0 0 38 38",
134
- xmlns: "http://www.w3.org/2000/svg",
135
- stroke: "#888",
136
- children: /* @__PURE__ */ jsx3("g", { fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ jsxs("g", { transform: "translate(1 1)", strokeWidth: "2", children: [
137
- /* @__PURE__ */ jsx3("circle", { strokeOpacity: ".5", cx: "18", cy: "18", r: "18" }),
138
- /* @__PURE__ */ jsx3("path", { d: "M36 18c0-9.94-8.06-18-18-18", children: /* @__PURE__ */ jsx3(
139
- "animateTransform",
140
- {
141
- attributeName: "transform",
142
- type: "rotate",
143
- from: "0 18 18",
144
- to: "360 18 18",
145
- dur: "1s",
146
- repeatCount: "indefinite"
147
- }
148
- ) })
149
- ] }) })
150
- }
151
- )
152
- }
153
- ),
154
- error && /* @__PURE__ */ jsxs(
155
- "div",
160
+ !isLoaded && /* @__PURE__ */ jsx3("div", { className: placeholder, style: getImageStyles(format, isColumn), children: /* @__PURE__ */ jsx3(
161
+ "svg",
156
162
  {
157
- className: placeholder,
158
- style: {
159
- width: format?.block_width ? format.block_width > MAX_WIDTH ? "100%" : `${format.block_width}px` : "100%",
160
- aspectRatio: format?.block_aspect_ratio ? `${format.block_aspect_ratio}` : "auto"
161
- },
162
- children: [
163
- /* @__PURE__ */ jsxs(
164
- "svg",
163
+ width: "38",
164
+ height: "38",
165
+ viewBox: "0 0 38 38",
166
+ xmlns: "http://www.w3.org/2000/svg",
167
+ stroke: "#888",
168
+ children: /* @__PURE__ */ jsx3("g", { fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ jsxs("g", { transform: "translate(1 1)", strokeWidth: "2", children: [
169
+ /* @__PURE__ */ jsx3("circle", { strokeOpacity: ".5", cx: "18", cy: "18", r: "18" }),
170
+ /* @__PURE__ */ jsx3("path", { d: "M36 18c0-9.94-8.06-18-18-18", children: /* @__PURE__ */ jsx3(
171
+ "animateTransform",
165
172
  {
166
- width: "48",
167
- height: "48",
168
- viewBox: "0 0 24 24",
169
- fill: "none",
170
- xmlns: "http://www.w3.org/2000/svg",
171
- children: [
172
- /* @__PURE__ */ jsx3(
173
- "path",
174
- {
175
- d: "M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",
176
- stroke: "#FF6B6B",
177
- strokeWidth: "2",
178
- strokeLinecap: "round",
179
- strokeLinejoin: "round"
180
- }
181
- ),
182
- /* @__PURE__ */ jsx3(
183
- "path",
184
- {
185
- d: "M15 9L9 15",
186
- stroke: "#FF6B6B",
187
- strokeWidth: "2",
188
- strokeLinecap: "round",
189
- strokeLinejoin: "round"
190
- }
191
- ),
192
- /* @__PURE__ */ jsx3(
193
- "path",
194
- {
195
- d: "M9 9L15 15",
196
- stroke: "#FF6B6B",
197
- strokeWidth: "2",
198
- strokeLinecap: "round",
199
- strokeLinejoin: "round"
200
- }
201
- )
202
- ]
173
+ attributeName: "transform",
174
+ type: "rotate",
175
+ from: "0 18 18",
176
+ to: "360 18 18",
177
+ dur: "1s",
178
+ repeatCount: "indefinite"
203
179
  }
204
- ),
205
- /* @__PURE__ */ jsx3("div", { style: { width: "10px" } }),
206
- /* @__PURE__ */ jsx3("p", { style: { color: "#FF6B6B", fontSize: "14px" }, children: "Image Load failed" })
207
- ]
180
+ ) })
181
+ ] }) })
208
182
  }
209
- ),
183
+ ) }),
210
184
  /* @__PURE__ */ jsx3(
211
185
  "img",
212
186
  {
@@ -216,12 +190,11 @@ var Image = ({
216
190
  }),
217
191
  src,
218
192
  alt,
219
- loading: priority ? "eager" : "lazy",
193
+ loading: "lazy",
220
194
  onLoad: () => setIsLoaded(true),
221
- onError: () => setError(true),
222
195
  width: format?.block_width,
223
196
  height: format?.block_height,
224
- style: format?.block_aspect_ratio ? { aspectRatio: `${format.block_aspect_ratio}` } : void 0
197
+ style: getImageTagStyle(format)
225
198
  }
226
199
  )
227
200
  ]
@@ -702,7 +675,8 @@ var Column = ({ block, onFocus }) => {
702
675
  {
703
676
  block: childBlock,
704
677
  onFocus,
705
- index
678
+ index,
679
+ isColumn: true
706
680
  },
707
681
  childBlock.id
708
682
  )) });
@@ -859,7 +833,12 @@ var Toggle_default = Toggle;
859
833
 
860
834
  // src/components/Renderer/components/Block/BlockRenderer.tsx
861
835
  import { jsx as jsx15 } from "react/jsx-runtime";
862
- var BlockRenderer = ({ block, onFocus, index }) => {
836
+ var BlockRenderer = ({
837
+ block,
838
+ onFocus,
839
+ index,
840
+ isColumn = false
841
+ }) => {
863
842
  if (!block) return null;
864
843
  const blockProps = {
865
844
  tabIndex: 0,
@@ -892,7 +871,8 @@ var BlockRenderer = ({ block, onFocus, index }) => {
892
871
  src: block.image.file?.url || block.image.external?.url,
893
872
  alt: block.image.caption?.[0]?.plain_text || "",
894
873
  caption: block.image.caption,
895
- format: block.image.format
874
+ format: block.image.format,
875
+ isColumn
896
876
  }
897
877
  ) });
898
878
  case "bookmark":
@@ -921,8 +901,8 @@ var BlockRenderer = ({ block, onFocus, index }) => {
921
901
  var BlockRenderer_default = BlockRenderer;
922
902
 
923
903
  // src/styles/theme.css.ts
924
- var darkTheme = "theme_darkTheme__sq3jkb15";
925
- var lightTheme = "theme_lightTheme__sq3jkb14";
904
+ var darkTheme = "theme_darkTheme__sq3jkb1n";
905
+ var lightTheme = "theme_lightTheme__sq3jkb1m";
926
906
 
927
907
  // src/components/Title/index.tsx
928
908
  import { jsx as jsx16 } from "react/jsx-runtime";