notion-to-jsx 1.2.13 → 1.2.15

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
@@ -105,7 +105,7 @@ var RichTexts = ({ richTexts }) => {
105
105
  var RichTexts_default = RichTexts;
106
106
 
107
107
  // src/components/Renderer/components/Image/Image.tsx
108
- import { useState } from "react";
108
+ import { useState, useRef, useEffect } from "react";
109
109
 
110
110
  // src/components/Renderer/components/Image/styles.css.ts
111
111
  import { createRuntimeFn as _7a4683 } from "@vanilla-extract/recipes/createRuntimeFn";
@@ -171,12 +171,23 @@ var Image = ({
171
171
  isColumn = false
172
172
  }) => {
173
173
  const [isLoaded, setIsLoaded] = useState(false);
174
+ const imgRef = useRef(null);
175
+ useEffect(() => {
176
+ const img = imgRef.current;
177
+ if (img && img.complete && img.naturalHeight !== 0) {
178
+ setIsLoaded(true);
179
+ }
180
+ }, [src]);
181
+ const handleLoad = () => {
182
+ setIsLoaded(true);
183
+ };
174
184
  return /* @__PURE__ */ jsxs("div", { className: imageContainer, children: [
175
185
  /* @__PURE__ */ jsxs("div", { className: imageWrapper, style: getImageStyles(format, isColumn), children: [
176
186
  /* @__PURE__ */ jsx4("div", { className: skeletonWrapper({ isLoaded }), children: /* @__PURE__ */ jsx4(Skeleton_default, { variant: "image", isLoading: !isLoaded }) }),
177
187
  /* @__PURE__ */ jsx4(
178
188
  "img",
179
189
  {
190
+ ref: imgRef,
180
191
  className: imageStyle({
181
192
  loaded: isLoaded,
182
193
  hasAspectRatio: !!format?.block_aspect_ratio
@@ -184,7 +195,7 @@ var Image = ({
184
195
  src,
185
196
  alt,
186
197
  loading: "lazy",
187
- onLoad: () => setIsLoaded(true),
198
+ onLoad: handleLoad,
188
199
  width: format?.block_width,
189
200
  height: format?.block_height,
190
201
  style: getImageTagStyle(format)
@@ -258,7 +269,7 @@ var Bookmark = ({ url, metadata }) => {
258
269
  var Bookmark_default = Bookmark;
259
270
 
260
271
  // src/components/Renderer/components/LinkPreview/LinkPreview.tsx
261
- import { useState as useState2, useEffect } from "react";
272
+ import { useState as useState2, useEffect as useEffect2 } from "react";
262
273
 
263
274
  // src/components/Renderer/components/LinkPreview/styles.css.ts
264
275
  var content2 = "styles_content__o1p3m12";
@@ -398,7 +409,7 @@ var LinkPreview = ({ url }) => {
398
409
  const [linkType, setLinkType] = useState2(
399
410
  "unknown"
400
411
  );
401
- useEffect(() => {
412
+ useEffect2(() => {
402
413
  const loadLinkData = async () => {
403
414
  setLoading(true);
404
415
  const type = getLinkType(url);
@@ -916,7 +927,7 @@ var Title = ({ title: title3 }) => {
916
927
  var Title_default = Title;
917
928
 
918
929
  // src/components/Cover/index.tsx
919
- import { useState as useState4 } from "react";
930
+ import { useState as useState4, useRef as useRef2, useEffect as useEffect3 } from "react";
920
931
 
921
932
  // src/components/Cover/styles.css.ts
922
933
  import { createRuntimeFn as _7a4684 } from "@vanilla-extract/recipes/createRuntimeFn";
@@ -928,15 +939,26 @@ var skeletonWrapper2 = _7a4684({ defaultClassName: "styles_skeletonWrapper__p0cp
928
939
  import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
929
940
  var Cover = ({ src, alt }) => {
930
941
  const [isLoaded, setIsLoaded] = useState4(false);
942
+ const imgRef = useRef2(null);
943
+ useEffect3(() => {
944
+ const img = imgRef.current;
945
+ if (img && img.complete && img.naturalHeight !== 0) {
946
+ setIsLoaded(true);
947
+ }
948
+ }, [src]);
949
+ const handleLoad = () => {
950
+ setIsLoaded(true);
951
+ };
931
952
  return /* @__PURE__ */ jsxs9("div", { className: coverContainer, children: [
932
953
  /* @__PURE__ */ jsx19("div", { className: skeletonWrapper2({ isLoaded }), children: /* @__PURE__ */ jsx19(Skeleton_default, { variant: "image", isLoading: !isLoaded }) }),
933
954
  /* @__PURE__ */ jsx19(
934
955
  "img",
935
956
  {
957
+ ref: imgRef,
936
958
  src,
937
959
  alt,
938
960
  className: imageStyle2({ isLoaded }),
939
- onLoad: () => setIsLoaded(true),
961
+ onLoad: handleLoad,
940
962
  loading: "lazy"
941
963
  }
942
964
  )