@pdfme/ui 3.1.3-dev.2 → 3.1.3-dev.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.js +158 -158
- package/package.json +1 -1
- package/src/class.ts +3 -3
- package/src/components/Designer/index.tsx +7 -5
package/package.json
CHANGED
package/src/class.ts
CHANGED
@@ -89,10 +89,10 @@ export abstract class BaseUIClass {
|
|
89
89
|
this.template = generateColumnsAndSampledataIfNeeded(cloneDeep(template));
|
90
90
|
this.options = options;
|
91
91
|
this.size = {
|
92
|
-
height: this.domContainer
|
93
|
-
width: this.domContainer
|
92
|
+
height: this.domContainer.clientHeight || window.innerHeight,
|
93
|
+
width: this.domContainer.clientWidth || window.innerWidth,
|
94
94
|
};
|
95
|
-
this.resizeObserver.observe(this.domContainer
|
95
|
+
this.resizeObserver.observe(this.domContainer);
|
96
96
|
|
97
97
|
const { lang, font } = options;
|
98
98
|
if (lang) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useRef, useState,
|
1
|
+
import React, { useRef, useState, useContext, useCallback } from 'react';
|
2
2
|
import {
|
3
3
|
ZOOM,
|
4
4
|
Template,
|
@@ -49,6 +49,7 @@ const TemplateEditor = ({
|
|
49
49
|
const [pageCursor, setPageCursor] = useState(0);
|
50
50
|
const [zoomLevel, setZoomLevel] = useState(1);
|
51
51
|
const [sidebarOpen, setSidebarOpen] = useState(true);
|
52
|
+
const [prevTemplate, setPrevTemplate] = useState<Template | null>(null);
|
52
53
|
|
53
54
|
const { backgrounds, pageSizes, scale, error } = useUIPreProcessor({ template, size, zoomLevel });
|
54
55
|
|
@@ -148,10 +149,6 @@ const TemplateEditor = ({
|
|
148
149
|
}
|
149
150
|
}, []);
|
150
151
|
|
151
|
-
useEffect(() => {
|
152
|
-
updateTemplate(template);
|
153
|
-
}, [template, updateTemplate]);
|
154
|
-
|
155
152
|
const addSchema = () => {
|
156
153
|
const propPanel = (Object.values(pluginsRegistry)[0] as Plugin<Schema>)?.propPanel;
|
157
154
|
|
@@ -183,6 +180,11 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
183
180
|
setHoveringSchemaId(id);
|
184
181
|
};
|
185
182
|
|
183
|
+
if (prevTemplate !== template) {
|
184
|
+
setPrevTemplate(template);
|
185
|
+
void updateTemplate(template);
|
186
|
+
}
|
187
|
+
|
186
188
|
const sizeExcSidebar = {
|
187
189
|
width: sidebarOpen ? size.width - SIDEBAR_WIDTH : size.width,
|
188
190
|
height: size.height,
|