@pixldocs/canvas-renderer 0.5.11 → 0.5.12
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.cjs +25 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11823,10 +11823,12 @@ function PixldocsPreview(props) {
|
|
|
11823
11823
|
const [isLoading, setIsLoading] = useState(false);
|
|
11824
11824
|
const [fontsReady, setFontsReady] = useState(false);
|
|
11825
11825
|
const [fontsReadyVersion, setFontsReadyVersion] = useState(0);
|
|
11826
|
+
const [canvasSettled, setCanvasSettled] = useState(false);
|
|
11826
11827
|
const isResolveMode = !("config" in props && props.config);
|
|
11827
11828
|
useEffect(() => {
|
|
11828
11829
|
if (!isResolveMode) {
|
|
11829
11830
|
setResolvedConfig(null);
|
|
11831
|
+
setCanvasSettled(false);
|
|
11830
11832
|
return;
|
|
11831
11833
|
}
|
|
11832
11834
|
const p = props;
|
|
@@ -11834,6 +11836,7 @@ function PixldocsPreview(props) {
|
|
|
11834
11836
|
let cancelled = false;
|
|
11835
11837
|
setIsLoading(true);
|
|
11836
11838
|
setFontsReady(false);
|
|
11839
|
+
setCanvasSettled(false);
|
|
11837
11840
|
resolveFromForm({
|
|
11838
11841
|
templateId: p.templateId,
|
|
11839
11842
|
formSchemaId: p.formSchemaId,
|
|
@@ -11878,6 +11881,7 @@ function PixldocsPreview(props) {
|
|
|
11878
11881
|
var _a, _b;
|
|
11879
11882
|
if (!config) return;
|
|
11880
11883
|
let cancelled = false;
|
|
11884
|
+
setCanvasSettled(false);
|
|
11881
11885
|
const bump = () => {
|
|
11882
11886
|
if (cancelled) return;
|
|
11883
11887
|
clearMeasurementCache();
|
|
@@ -11895,11 +11899,17 @@ function PixldocsPreview(props) {
|
|
|
11895
11899
|
if (isResolveMode) return;
|
|
11896
11900
|
if (!config) {
|
|
11897
11901
|
setFontsReady(false);
|
|
11902
|
+
setCanvasSettled(false);
|
|
11898
11903
|
return;
|
|
11899
11904
|
}
|
|
11900
11905
|
setFontsReady(false);
|
|
11906
|
+
setCanvasSettled(false);
|
|
11901
11907
|
ensureFontsForResolvedConfig(config).then(() => setFontsReady(true)).catch(() => setFontsReady(true));
|
|
11902
11908
|
}, [isResolveMode, config]);
|
|
11909
|
+
const handleCanvasReady = useCallback(() => {
|
|
11910
|
+
setCanvasSettled(true);
|
|
11911
|
+
onReady == null ? void 0 : onReady();
|
|
11912
|
+
}, [onReady]);
|
|
11903
11913
|
if (isLoading) {
|
|
11904
11914
|
return /* @__PURE__ */ jsx("div", { className, style: { ...style, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) });
|
|
11905
11915
|
}
|
|
@@ -11907,18 +11917,21 @@ function PixldocsPreview(props) {
|
|
|
11907
11917
|
if (!fontsReady) {
|
|
11908
11918
|
return /* @__PURE__ */ jsx("div", { className, style: { ...style, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) });
|
|
11909
11919
|
}
|
|
11910
|
-
return /* @__PURE__ */
|
|
11911
|
-
|
|
11912
|
-
|
|
11913
|
-
|
|
11914
|
-
|
|
11915
|
-
|
|
11916
|
-
|
|
11917
|
-
|
|
11918
|
-
|
|
11919
|
-
|
|
11920
|
-
|
|
11921
|
-
|
|
11920
|
+
return /* @__PURE__ */ jsxs("div", { className, style: { ...style, position: "relative" }, children: [
|
|
11921
|
+
/* @__PURE__ */ jsx("div", { style: { visibility: canvasSettled ? "visible" : "hidden" }, children: /* @__PURE__ */ jsx(
|
|
11922
|
+
PreviewCanvas,
|
|
11923
|
+
{
|
|
11924
|
+
config,
|
|
11925
|
+
pageIndex,
|
|
11926
|
+
zoom,
|
|
11927
|
+
absoluteZoom,
|
|
11928
|
+
onDynamicFieldClick,
|
|
11929
|
+
onReady: handleCanvasReady
|
|
11930
|
+
},
|
|
11931
|
+
previewKey
|
|
11932
|
+
) }),
|
|
11933
|
+
!canvasSettled && /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
|
|
11934
|
+
] });
|
|
11922
11935
|
}
|
|
11923
11936
|
class PixldocsRenderer {
|
|
11924
11937
|
constructor(config) {
|