notion-to-jsx 1.2.2 → 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
@@ -116,62 +116,71 @@ var styledImage = _7a4683({ defaultClassName: "styles_styledImage__2f3ncf6", var
116
116
  // src/components/Renderer/components/Image/Image.tsx
117
117
  import { jsx as jsx3, jsxs } from "react/jsx-runtime";
118
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
+ };
119
140
  var Image = ({
120
141
  src,
121
142
  alt,
122
143
  caption: imageCaption,
123
- priority = false,
124
- format
144
+ format,
145
+ isColumn = false
125
146
  }) => {
126
147
  const [isLoaded, setIsLoaded] = useState(false);
127
148
  useEffect(() => {
128
149
  setIsLoaded(false);
129
150
  }, [src]);
130
- return /* @__PURE__ */ jsxs("figure", { className: imageContainer, children: [
151
+ return /* @__PURE__ */ jsxs("div", { className: imageContainer, children: [
131
152
  /* @__PURE__ */ jsxs(
132
153
  "div",
133
154
  {
134
155
  className: imageWrapper({
135
156
  hasWidth: !!format?.block_width
136
157
  }),
137
- style: {
138
- width: format?.block_aspect_ratio && format.block_aspect_ratio < 1 ? `${format.block_aspect_ratio * 100}%` : format?.block_width ? format.block_width > MAX_WIDTH ? "100%" : `${format.block_width}px` : "100%"
139
- },
158
+ style: getImageStyles(format, isColumn),
140
159
  children: [
141
- !isLoaded && /* @__PURE__ */ jsx3(
142
- "div",
160
+ !isLoaded && /* @__PURE__ */ jsx3("div", { className: placeholder, style: getImageStyles(format, isColumn), children: /* @__PURE__ */ jsx3(
161
+ "svg",
143
162
  {
144
- className: placeholder,
145
- style: {
146
- width: format?.block_aspect_ratio && format.block_aspect_ratio < 1 ? `${format.block_aspect_ratio * 100}%` : format?.block_width ? format.block_width > MAX_WIDTH ? "100%" : `${format.block_width}px` : "100%",
147
- aspectRatio: format?.block_aspect_ratio ? `${format.block_aspect_ratio}` : "auto"
148
- },
149
- children: /* @__PURE__ */ jsx3(
150
- "svg",
151
- {
152
- width: "38",
153
- height: "38",
154
- viewBox: "0 0 38 38",
155
- xmlns: "http://www.w3.org/2000/svg",
156
- stroke: "#888",
157
- children: /* @__PURE__ */ jsx3("g", { fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ jsxs("g", { transform: "translate(1 1)", strokeWidth: "2", children: [
158
- /* @__PURE__ */ jsx3("circle", { strokeOpacity: ".5", cx: "18", cy: "18", r: "18" }),
159
- /* @__PURE__ */ jsx3("path", { d: "M36 18c0-9.94-8.06-18-18-18", children: /* @__PURE__ */ jsx3(
160
- "animateTransform",
161
- {
162
- attributeName: "transform",
163
- type: "rotate",
164
- from: "0 18 18",
165
- to: "360 18 18",
166
- dur: "1s",
167
- repeatCount: "indefinite"
168
- }
169
- ) })
170
- ] }) })
171
- }
172
- )
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",
172
+ {
173
+ attributeName: "transform",
174
+ type: "rotate",
175
+ from: "0 18 18",
176
+ to: "360 18 18",
177
+ dur: "1s",
178
+ repeatCount: "indefinite"
179
+ }
180
+ ) })
181
+ ] }) })
173
182
  }
174
- ),
183
+ ) }),
175
184
  /* @__PURE__ */ jsx3(
176
185
  "img",
177
186
  {
@@ -181,11 +190,11 @@ var Image = ({
181
190
  }),
182
191
  src,
183
192
  alt,
184
- loading: priority ? "eager" : "lazy",
193
+ loading: "lazy",
185
194
  onLoad: () => setIsLoaded(true),
186
195
  width: format?.block_width,
187
196
  height: format?.block_height,
188
- style: format?.block_aspect_ratio ? { aspectRatio: `${format.block_aspect_ratio}` } : void 0
197
+ style: getImageTagStyle(format)
189
198
  }
190
199
  )
191
200
  ]
@@ -666,7 +675,8 @@ var Column = ({ block, onFocus }) => {
666
675
  {
667
676
  block: childBlock,
668
677
  onFocus,
669
- index
678
+ index,
679
+ isColumn: true
670
680
  },
671
681
  childBlock.id
672
682
  )) });
@@ -823,7 +833,12 @@ var Toggle_default = Toggle;
823
833
 
824
834
  // src/components/Renderer/components/Block/BlockRenderer.tsx
825
835
  import { jsx as jsx15 } from "react/jsx-runtime";
826
- var BlockRenderer = ({ block, onFocus, index }) => {
836
+ var BlockRenderer = ({
837
+ block,
838
+ onFocus,
839
+ index,
840
+ isColumn = false
841
+ }) => {
827
842
  if (!block) return null;
828
843
  const blockProps = {
829
844
  tabIndex: 0,
@@ -856,7 +871,8 @@ var BlockRenderer = ({ block, onFocus, index }) => {
856
871
  src: block.image.file?.url || block.image.external?.url,
857
872
  alt: block.image.caption?.[0]?.plain_text || "",
858
873
  caption: block.image.caption,
859
- format: block.image.format
874
+ format: block.image.format,
875
+ isColumn
860
876
  }
861
877
  ) });
862
878
  case "bookmark":