@pixldocs/canvas-renderer 0.4.7 → 0.4.9

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.js CHANGED
@@ -4861,6 +4861,7 @@ const PageCanvas = forwardRef(
4861
4861
  const prevCanvasUpdateVersionRef = useRef(canvasUpdateVersion);
4862
4862
  const syncTriggeredByPanelRef = useRef(false);
4863
4863
  const hasRunPostReadyReflowForPageRef = useRef(null);
4864
+ const hasNotifiedReadyForPageRef = useRef(null);
4864
4865
  const hasClearedCachesBeforeFirstSyncRef = useRef(false);
4865
4866
  const [guides, setGuides] = useState([]);
4866
4867
  const [gridResizeLabel, setGridResizeLabel] = useState(null);
@@ -5123,10 +5124,8 @@ const PageCanvas = forwardRef(
5123
5124
  clearFabricCharCache();
5124
5125
  clearMeasurementCache();
5125
5126
  setReady(true);
5126
- if (onReady) onReady();
5127
5127
  } catch (e) {
5128
5128
  setReady(true);
5129
- if (onReady) onReady();
5130
5129
  }
5131
5130
  };
5132
5131
  initFonts();
@@ -7098,6 +7097,11 @@ const PageCanvas = forwardRef(
7098
7097
  if (!ready || hasRunPostReadyReflowForPageRef.current === pageId) return;
7099
7098
  hasRunPostReadyReflowForPageRef.current = pageId;
7100
7099
  let cancelled = false;
7100
+ const notifyReady = () => {
7101
+ if (cancelled || hasNotifiedReadyForPageRef.current === pageId) return;
7102
+ hasNotifiedReadyForPageRef.current = pageId;
7103
+ onReady == null ? void 0 : onReady();
7104
+ };
7101
7105
  const runReflowAndPersist = () => {
7102
7106
  const fc = fabricRef.current;
7103
7107
  if (!fc || cancelled) return;
@@ -7139,6 +7143,7 @@ const PageCanvas = forwardRef(
7139
7143
  requestAnimationFrame(() => {
7140
7144
  if (cancelled) return;
7141
7145
  runReflowAndPersist();
7146
+ notifyReady();
7142
7147
  });
7143
7148
  });
7144
7149
  });
@@ -7147,7 +7152,7 @@ const PageCanvas = forwardRef(
7147
7152
  cancelled = true;
7148
7153
  cancelAnimationFrame(raf1);
7149
7154
  };
7150
- }, [ready, pageId]);
7155
+ }, [ready, pageId, onReady]);
7151
7156
  useEffect(() => {
7152
7157
  const fc = fabricRef.current;
7153
7158
  if (!fc || isRebuildingRef.current || !isActive) return;
@@ -10221,7 +10226,12 @@ function setInTree(nodes, elementId, targetProperty, value) {
10221
10226
  } else {
10222
10227
  node[targetProperty] = value;
10223
10228
  }
10224
- if (targetProperty === "text" && node.type === "text") delete node.height;
10229
+ if (targetProperty === "text" && node.type === "text") {
10230
+ const overflowPolicy = String(node.overflowPolicy ?? "grow-and-push");
10231
+ if (overflowPolicy !== "auto-shrink") {
10232
+ delete node.height;
10233
+ }
10234
+ }
10225
10235
  return true;
10226
10236
  }
10227
10237
  if (node.children && Array.isArray(node.children)) {