@openlettermarketing/olc-react-sdk 0.0.17 → 0.0.18
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/build/types/components/SidePanel/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/SidePanel/customFields/customFieldSection.tsx +17 -6
- package/src/components/SidePanel/index.tsx +18 -6
- package/src/components/TemplateBuilder/index.tsx +1 -3
- package/src/components/TopNavigation/index.tsx +25 -8
- package/src/index.tsx +7 -6
- package/src/utils/templateRestrictedArea/realPenned.ts +5 -44
package/package.json
CHANGED
|
@@ -52,12 +52,23 @@ const customFieldSection: SideSection = {
|
|
|
52
52
|
dispatch(fetchCustomFields());
|
|
53
53
|
}, [dispatch]);
|
|
54
54
|
|
|
55
|
-
const handleAddElementOnScreen = (event: any, value: any, type: any) => {
|
|
56
|
-
event.preventDefault();
|
|
57
55
|
|
|
58
|
-
|
|
56
|
+
const copyCustomFieldText = (value: string) => {
|
|
57
|
+
if (currentTemplateType === "Real Penned Letter") {
|
|
58
|
+
let modifiedString = value.replace(/{{/g, "((").replace(/}}/g, "))");
|
|
59
|
+
copyToClipboard(modifiedString);
|
|
60
|
+
dispatch(success(`${modifiedString} Copied`));
|
|
61
|
+
} else {
|
|
59
62
|
copyToClipboard(value);
|
|
60
63
|
dispatch(success(`${value} Copied`));
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const handleAddElementOnScreen = (event: any, value: any, type: any) => {
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
|
|
70
|
+
if (currentTemplateType === "Real Penned Letter") {
|
|
71
|
+
copyCustomFieldText(value);
|
|
61
72
|
return;
|
|
62
73
|
}
|
|
63
74
|
|
|
@@ -111,7 +122,7 @@ const customFieldSection: SideSection = {
|
|
|
111
122
|
</span>
|
|
112
123
|
<Button
|
|
113
124
|
style={iconButtonStyles}
|
|
114
|
-
onClick={() =>
|
|
125
|
+
onClick={() => copyCustomFieldText(key)}
|
|
115
126
|
>
|
|
116
127
|
<ContentCopyIcon className="copy" />
|
|
117
128
|
</Button>
|
|
@@ -132,7 +143,7 @@ const customFieldSection: SideSection = {
|
|
|
132
143
|
</div>
|
|
133
144
|
<Button onClick={handleShowDialog}></Button>
|
|
134
145
|
</div>
|
|
135
|
-
{customFields
|
|
146
|
+
{customFields?.data?.map(
|
|
136
147
|
({key, value}: {key: string; value: string}, i: number) => (
|
|
137
148
|
<div style={{display: 'flex', alignItems: 'center'}} key={i}>
|
|
138
149
|
<span
|
|
@@ -145,7 +156,7 @@ const customFieldSection: SideSection = {
|
|
|
145
156
|
</span>
|
|
146
157
|
<Button
|
|
147
158
|
style={iconButtonStyles}
|
|
148
|
-
onClick={() =>
|
|
159
|
+
onClick={() => copyCustomFieldText(key)}
|
|
149
160
|
>
|
|
150
161
|
<ContentCopyIcon
|
|
151
162
|
className="copy"
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
// Polotno Imports
|
|
4
4
|
import { SidePanelWrap } from 'polotno';
|
|
5
5
|
import type { StoreType } from 'polotno/model/store';
|
|
6
|
-
import {SidePanel as PolotnoSidePanel, DEFAULT_SECTIONS} from 'polotno/side-panel';
|
|
6
|
+
import { SidePanel as PolotnoSidePanel, DEFAULT_SECTIONS } from 'polotno/side-panel';
|
|
7
7
|
|
|
8
8
|
// Custom Sections
|
|
9
9
|
import customTemplateSection from './templates/customTemplateSection';
|
|
@@ -12,16 +12,28 @@ import customFieldSection from './customFields/customFieldSection';
|
|
|
12
12
|
|
|
13
13
|
interface Props {
|
|
14
14
|
store: StoreType;
|
|
15
|
+
currentTemplateType: string;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
const SidePanel: React.FC<Props> = (props) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const sections =
|
|
20
|
+
props.currentTemplateType === "Real Penned Letter"
|
|
21
|
+
? DEFAULT_SECTIONS.filter((section) => section.name === "")
|
|
22
|
+
: DEFAULT_SECTIONS.filter(
|
|
23
|
+
(section) => !["photos", "size", "templates"].includes(section.name)
|
|
24
|
+
);
|
|
25
|
+
|
|
22
26
|
return (
|
|
23
27
|
<SidePanelWrap>
|
|
24
|
-
<PolotnoSidePanel store={props.store}
|
|
28
|
+
<PolotnoSidePanel store={props.store}
|
|
29
|
+
sections={[
|
|
30
|
+
...(props.currentTemplateType !== "Real Penned Letter"
|
|
31
|
+
? [customTemplateSection]
|
|
32
|
+
: []),
|
|
33
|
+
...sections,
|
|
34
|
+
customFieldSection,
|
|
35
|
+
]}
|
|
36
|
+
defaultSection="text" />
|
|
25
37
|
</SidePanelWrap>
|
|
26
38
|
);
|
|
27
39
|
};
|
|
@@ -272,9 +272,7 @@ const TemplateBuilder: React.FC<TemplateBuilderProps> = ({ store, styles, return
|
|
|
272
272
|
<PolotnoContainer
|
|
273
273
|
style={containerStyle}
|
|
274
274
|
>
|
|
275
|
-
{currentTemplateType
|
|
276
|
-
<SidePanel store={store} />
|
|
277
|
-
}
|
|
275
|
+
<SidePanel store={store} currentTemplateType={currentTemplateType} />
|
|
278
276
|
<WorkspaceWrap>
|
|
279
277
|
{currentTemplateType !== "Real Penned Letter" && (
|
|
280
278
|
<Toolbar store={store} downloadButtonEnabled={false} />
|
|
@@ -130,7 +130,7 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
|
|
|
130
130
|
setItem('formData', JSON.stringify(data));
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
-
const handleBackPress = () => {
|
|
133
|
+
const handleBackPress = () => {
|
|
134
134
|
if (isStoreUpdated) {
|
|
135
135
|
setShowNavigateDialog(!showNavigateDialog);
|
|
136
136
|
} else {
|
|
@@ -140,7 +140,7 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
|
|
|
140
140
|
|
|
141
141
|
const handleNavigation = async (route = '/') => {
|
|
142
142
|
handleClearFilters();
|
|
143
|
-
if (templateType === 'json') {
|
|
143
|
+
if (templateType === 'json' && product?.productType !== 'Real Penned Letter') {
|
|
144
144
|
await store.history.clear();
|
|
145
145
|
}
|
|
146
146
|
navigate(route);
|
|
@@ -152,7 +152,13 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
|
|
|
152
152
|
try {
|
|
153
153
|
setDownloaingProof(true);
|
|
154
154
|
const fields = [...defaultFields, ...Object.values(dynamicFields)];
|
|
155
|
-
|
|
155
|
+
let json = store.toJSON();
|
|
156
|
+
if (product?.productType === "Real Penned Letter") {
|
|
157
|
+
let clonedJson = JSON.stringify(json)
|
|
158
|
+
.replace(/\(\(/g, "{{")
|
|
159
|
+
.replace(/\)\)/g, "}}");
|
|
160
|
+
json = JSON.parse(clonedJson);
|
|
161
|
+
}
|
|
156
162
|
let jsonString = JSON.stringify(json);
|
|
157
163
|
fields.forEach(({ key, defaultValue, value }) => {
|
|
158
164
|
const regex = new RegExp(key, 'g');
|
|
@@ -200,7 +206,14 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
|
|
|
200
206
|
let selectedFields: typeof allFields = [];
|
|
201
207
|
if (templateType === 'json') {
|
|
202
208
|
const blob = await store.toBlob();
|
|
203
|
-
|
|
209
|
+
let jsonData = store.toJSON();
|
|
210
|
+
|
|
211
|
+
if (product?.productType === "Real Penned Letter") {
|
|
212
|
+
let clonedJson = JSON.stringify(jsonData)
|
|
213
|
+
.replace(/\(\(/g, "{{")
|
|
214
|
+
.replace(/\)\)/g, "}}");
|
|
215
|
+
jsonData = JSON.parse(clonedJson);
|
|
216
|
+
}
|
|
204
217
|
|
|
205
218
|
// get all fonts family from json
|
|
206
219
|
const fontFamilies = extractFontFamilies(jsonData?.pages);
|
|
@@ -270,7 +283,9 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
|
|
|
270
283
|
});
|
|
271
284
|
if (response.status === 200) {
|
|
272
285
|
dispatch(success(response.data.message));
|
|
273
|
-
|
|
286
|
+
setTimeout(() => {
|
|
287
|
+
handleNavigation();
|
|
288
|
+
}, 2000);
|
|
274
289
|
} else if (response.status == 418) {
|
|
275
290
|
// nothing to do
|
|
276
291
|
} else {
|
|
@@ -279,7 +294,9 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
|
|
|
279
294
|
} catch (error) {
|
|
280
295
|
handleChangeModel('', 'false');
|
|
281
296
|
} finally {
|
|
282
|
-
|
|
297
|
+
setTimeout(() => {
|
|
298
|
+
setIsShowModel((prev) => ({ ...prev, loading: false }));
|
|
299
|
+
}, 2000);
|
|
283
300
|
}
|
|
284
301
|
};
|
|
285
302
|
|
|
@@ -335,7 +352,7 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
|
|
|
335
352
|
handleSave={handleSave}
|
|
336
353
|
/>
|
|
337
354
|
)}
|
|
338
|
-
<GridContainer style={{alignItems: 'center'}}>
|
|
355
|
+
<GridContainer style={{ alignItems: 'center' }}>
|
|
339
356
|
<GridItem lg={4} md={4} sm={2} xs={12}></GridItem>
|
|
340
357
|
<GridItem lg={4} md={2} sm={2} xs={12}>
|
|
341
358
|
<div className="middle">
|
|
@@ -348,7 +365,7 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
|
|
|
348
365
|
<GridItem lg={4} md={6} sm={8} xs={12}>
|
|
349
366
|
<div className="actionsBtnWrapper right">
|
|
350
367
|
<Button
|
|
351
|
-
style={{...buttonStyles, maxWidth: 'auto', minWidth: '100px'}}
|
|
368
|
+
style={{ ...buttonStyles, maxWidth: 'auto', minWidth: '100px' }}
|
|
352
369
|
onClick={handleViewProofWithLamda}
|
|
353
370
|
>
|
|
354
371
|
{downloadingProof ? (
|
package/src/index.tsx
CHANGED
|
@@ -48,16 +48,17 @@ const TemplateBuilder = ({
|
|
|
48
48
|
setMode(mode);
|
|
49
49
|
const root = ReactDOM.createRoot(container);
|
|
50
50
|
root.render(
|
|
51
|
-
|
|
52
|
-
<
|
|
53
|
-
<
|
|
51
|
+
<>
|
|
52
|
+
<Provider store={store}>
|
|
53
|
+
<Router>
|
|
54
|
+
|
|
54
55
|
<App
|
|
55
56
|
secretKey={secretKey}
|
|
56
57
|
styles={styles}
|
|
57
58
|
returnRoute={returnRoute} />
|
|
58
|
-
</
|
|
59
|
-
</
|
|
60
|
-
|
|
59
|
+
</Router>
|
|
60
|
+
</Provider>
|
|
61
|
+
</>
|
|
61
62
|
);
|
|
62
63
|
};
|
|
63
64
|
|
|
@@ -84,45 +84,6 @@ export const addElementsforRealPennedLetters = (store: Store): void => {
|
|
|
84
84
|
const page = store.pages[0];
|
|
85
85
|
|
|
86
86
|
const elements: Element[] = [
|
|
87
|
-
{
|
|
88
|
-
id: "blocked",
|
|
89
|
-
type: "figure",
|
|
90
|
-
name: "",
|
|
91
|
-
opacity: 1,
|
|
92
|
-
visible: true,
|
|
93
|
-
selectable: false,
|
|
94
|
-
removable: false,
|
|
95
|
-
alwaysOnTop: true,
|
|
96
|
-
showInExport: true,
|
|
97
|
-
x: -1.850472230905276e-12,
|
|
98
|
-
y: -2.9487523534043754e-13,
|
|
99
|
-
width: 528,
|
|
100
|
-
height: 80.739,
|
|
101
|
-
rotation: 0,
|
|
102
|
-
animations: [],
|
|
103
|
-
blurEnabled: false,
|
|
104
|
-
blurRadius: 10,
|
|
105
|
-
brightnessEnabled: false,
|
|
106
|
-
brightness: 0,
|
|
107
|
-
sepiaEnabled: false,
|
|
108
|
-
grayscaleEnabled: false,
|
|
109
|
-
shadowEnabled: false,
|
|
110
|
-
shadowBlur: 5,
|
|
111
|
-
shadowOffsetX: 0,
|
|
112
|
-
shadowOffsetY: 0,
|
|
113
|
-
shadowColor: "black",
|
|
114
|
-
shadowOpacity: 1,
|
|
115
|
-
draggable: false,
|
|
116
|
-
resizable: false,
|
|
117
|
-
contentEditable: false,
|
|
118
|
-
styleEditable: true,
|
|
119
|
-
subType: "rect",
|
|
120
|
-
fill: "rgba(208,0,0,1)",
|
|
121
|
-
dash: [],
|
|
122
|
-
strokeWidth: 0,
|
|
123
|
-
stroke: "#0c0c0c",
|
|
124
|
-
cornerRadius: 0,
|
|
125
|
-
},
|
|
126
87
|
{
|
|
127
88
|
id: 'header',
|
|
128
89
|
type: 'text',
|
|
@@ -135,7 +96,7 @@ export const addElementsforRealPennedLetters = (store: Store): void => {
|
|
|
135
96
|
showInExport: true,
|
|
136
97
|
x: 25,
|
|
137
98
|
y: 130,
|
|
138
|
-
width:
|
|
99
|
+
width: 480,
|
|
139
100
|
height: 40,
|
|
140
101
|
rotation: 0,
|
|
141
102
|
animations: [],
|
|
@@ -155,7 +116,7 @@ export const addElementsforRealPennedLetters = (store: Store): void => {
|
|
|
155
116
|
resizable: false,
|
|
156
117
|
contentEditable: true,
|
|
157
118
|
styleEditable: false,
|
|
158
|
-
text: "Hi
|
|
119
|
+
text: "Hi ((C.FIRST_NAME)),",
|
|
159
120
|
fontSize: 20,
|
|
160
121
|
fontFamily: 'lexi Regular',
|
|
161
122
|
fontStyle: 'normal',
|
|
@@ -235,9 +196,9 @@ export const addElementsforRealPennedLetters = (store: Store): void => {
|
|
|
235
196
|
removable: false,
|
|
236
197
|
alwaysOnTop: true,
|
|
237
198
|
showInExport: true,
|
|
238
|
-
x:
|
|
199
|
+
x: 165.49999999499846,
|
|
239
200
|
y: 651.7346179851188,
|
|
240
|
-
width:
|
|
201
|
+
width: 335,
|
|
241
202
|
height: 75,
|
|
242
203
|
rotation: 0,
|
|
243
204
|
animations: [],
|
|
@@ -275,7 +236,7 @@ export const addElementsforRealPennedLetters = (store: Store): void => {
|
|
|
275
236
|
backgroundOpacity: 1,
|
|
276
237
|
backgroundCornerRadius: 0.5,
|
|
277
238
|
backgroundPadding: 0.5,
|
|
278
|
-
}
|
|
239
|
+
},
|
|
279
240
|
]
|
|
280
241
|
|
|
281
242
|
elements.forEach(element => page.addElement(element));
|