@bizapps/design-system-testing 1.8.0 → 1.8.1

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/editor.cjs CHANGED
@@ -868,20 +868,21 @@ function ResizableImageView({ node, updateAttributes, selected, extension }) {
868
868
  if (sizeRef.current.width > 0 || fittedSrcRef.current === src) return;
869
869
  const fit = () => {
870
870
  const available = img.closest(".ProseMirror")?.clientWidth ?? 0;
871
- if (!img.naturalWidth || !img.naturalHeight || available <= 0) return;
871
+ if (!img.naturalWidth || !img.naturalHeight || available <= 0) return false;
872
872
  fittedSrcRef.current = src;
873
873
  const nextWidth = Math.min(img.naturalWidth, available);
874
874
  updateAttributes({
875
875
  width: nextWidth,
876
876
  height: Math.round(nextWidth / (img.naturalWidth / img.naturalHeight))
877
877
  });
878
+ return true;
878
879
  };
879
- if (img.complete) {
880
- fit();
881
- return;
882
- }
883
- img.addEventListener("load", fit, { once: true });
884
- return () => img.removeEventListener("load", fit);
880
+ if (img.complete && fit()) return;
881
+ const onLoad = () => {
882
+ if (fit()) img.removeEventListener("load", onLoad);
883
+ };
884
+ img.addEventListener("load", onLoad);
885
+ return () => img.removeEventListener("load", onLoad);
885
886
  }, [src, updateAttributes]);
886
887
  const onPointerDown = react.useCallback(
887
888
  (event) => {