@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/ui",
3
- "version": "3.1.3-dev.2",
3
+ "version": "3.1.3-dev.3",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
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!.clientHeight || window.innerHeight,
93
- width: this.domContainer!.clientWidth || window.innerWidth,
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, useEffect, useContext, useCallback } from 'react';
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,