@openlettermarketing/olc-react-sdk 0.0.14 → 0.0.15
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/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/TemplateBuilder/index.tsx +29 -21
- package/src/index.tsx +12 -12
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useState, useLayoutEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
// Import Polotno and third-party libraries
|
|
4
4
|
import { PolotnoContainer, WorkspaceWrap } from 'polotno';
|
|
@@ -37,6 +37,7 @@ import LexiRegularFont from "../../assets/Fonts/Lexi-Regular.ttf";
|
|
|
37
37
|
// Components
|
|
38
38
|
import TopNavigation from '../TopNavigation';
|
|
39
39
|
import SidePanel from '../SidePanel';
|
|
40
|
+
import GenericSnackbar from '../GenericUIBlocks/GenericSnackbar';
|
|
40
41
|
|
|
41
42
|
import './styles.scss';
|
|
42
43
|
|
|
@@ -112,31 +113,37 @@ const TemplateBuilder: React.FC<TemplateBuilderProps> = ({ store, styles, return
|
|
|
112
113
|
if (!product) {
|
|
113
114
|
navigate('/create-template');
|
|
114
115
|
}
|
|
116
|
+
}, []);
|
|
115
117
|
|
|
116
|
-
setGoogleFonts(fonts);
|
|
117
|
-
// remove this component from the history stack
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (product) {
|
|
121
|
+
setGoogleFonts(fonts);
|
|
122
|
+
// remove this component from the history stack
|
|
123
|
+
|
|
124
|
+
if (id) {
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
dispatch(getOneTemplate(id));
|
|
127
|
+
} else if (store.pages.length === 0) {
|
|
128
|
+
createInitialPage();
|
|
129
|
+
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
dispatch(getAllCustomFields());
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
const handleChange = () => {
|
|
134
|
+
if (!isStoreUpdated) {
|
|
135
|
+
setIsStoreUpdated(true);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
134
138
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
const off = store.on("change", handleChange);
|
|
140
|
+
|
|
141
|
+
return () => {
|
|
142
|
+
store.history.clear();
|
|
143
|
+
store.clear();
|
|
144
|
+
off();
|
|
145
|
+
};
|
|
146
|
+
}
|
|
140
147
|
}, []);
|
|
141
148
|
|
|
142
149
|
useEffect(() => {
|
|
@@ -284,6 +291,7 @@ const TemplateBuilder: React.FC<TemplateBuilderProps> = ({ store, styles, return
|
|
|
284
291
|
<ZoomButtons store={store} />
|
|
285
292
|
</WorkspaceWrap>
|
|
286
293
|
</PolotnoContainer>
|
|
294
|
+
<GenericSnackbar />
|
|
287
295
|
</div>
|
|
288
296
|
)}
|
|
289
297
|
</div>
|
package/src/index.tsx
CHANGED
|
@@ -64,17 +64,17 @@ const TemplateBuilder = ({
|
|
|
64
64
|
|
|
65
65
|
// Example to run the project locally for development. Comment out these lines when building the application
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
const rootElement = document.getElementById('root');
|
|
68
|
+
if (rootElement) {
|
|
69
|
+
TemplateBuilder({
|
|
70
|
+
container: rootElement,
|
|
71
|
+
apiKey: import.meta.env.VITE_APP_ACCESS_TOKEN,
|
|
72
|
+
mode: 'live',
|
|
73
|
+
secretKey: import.meta.env.VITE_APP_PLOTNO_API_KEY,
|
|
74
|
+
styles: {}
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
console.error("Root element '#root' not found in the document.");
|
|
78
|
+
}
|
|
79
79
|
|
|
80
80
|
export default TemplateBuilder;
|