@capillarytech/creatives-library 9.0.24 → 9.0.26
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
|
@@ -194,10 +194,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
194
194
|
// const formData = _.cloneDeep(this.state.formData);
|
|
195
195
|
if (this.props.params.id || (this.props.location.query.module === "library" && this.props.templateData && !_.isEmpty(this.props.templateData))) {
|
|
196
196
|
this.setState({isEdit: true}, () => {
|
|
197
|
-
|
|
198
|
-
// prop; fetching by id would pull reusable-template data and drop the
|
|
199
|
-
// inline BEE json_content. Only fetch for real reusable-template edits.
|
|
197
|
+
if (this.props.params.id) {
|
|
200
198
|
this.props.actions.getTemplateDetails(this.props.params.id, 'email');
|
|
199
|
+
}
|
|
201
200
|
});
|
|
202
201
|
}
|
|
203
202
|
// formData[0] = {
|
|
@@ -238,6 +237,39 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
238
237
|
this.props.actions.getCmsSetting(BEE_PLUGIN, dragDropId, 'create', undefined, isBEESupport, isBEEAppEnable);
|
|
239
238
|
}
|
|
240
239
|
}
|
|
240
|
+
// The <Email> direct path (SlideBoxContent routes here when
|
|
241
|
+
// templateData.base.is_drag_drop is true) bypasses EmailWrapper/useEmailWrapper,
|
|
242
|
+
// so Templates.BEETemplate is never seeded and a created/edited drag-drop would
|
|
243
|
+
// open as the HTML editor. Seed isDragDrop + the BEE plugin from the inline
|
|
244
|
+
// templateData so it opens as BEE.
|
|
245
|
+
if (_.isEmpty(this.props.Templates.BEETemplate) && !_.isEmpty(this.props.templateData)) {
|
|
246
|
+
const td = this.props.templateData;
|
|
247
|
+
const activeTab = _.get(td, 'versions.base.activeTab', 'en');
|
|
248
|
+
// This path bypasses setEditData, so seed the subject from the inline
|
|
249
|
+
// templateData too (otherwise the title is empty for a created drag-drop).
|
|
250
|
+
const inlineSubject = _.get(td, 'base.subject')
|
|
251
|
+
|| _.get(td, `versions.base.${activeTab}.subject`)
|
|
252
|
+
|| _.get(td, 'versions.base.subject')
|
|
253
|
+
|| _.get(td, 'emailSubject')
|
|
254
|
+
|| _.get(td, 'subject');
|
|
255
|
+
if (inlineSubject) {
|
|
256
|
+
formData['template-subject'] = inlineSubject;
|
|
257
|
+
}
|
|
258
|
+
const inlineIsDragDrop = _.get(td, 'base.is_drag_drop')
|
|
259
|
+
|| _.get(td, `versions.base.${activeTab}.is_drag_drop`)
|
|
260
|
+
|| _.get(td, 'versions.base.is_drag_drop')
|
|
261
|
+
|| _.get(td, 'is_drag_drop');
|
|
262
|
+
if ((inlineIsDragDrop === true || inlineIsDragDrop === 1) && isBEEAppEnable) {
|
|
263
|
+
this.setState({ isDragDrop: true });
|
|
264
|
+
const inlineDragDropId = _.get(td, 'base.drag_drop_id')
|
|
265
|
+
|| _.get(td, 'base.id')
|
|
266
|
+
|| _.get(td, `versions.base.${activeTab}.drag_drop_id`)
|
|
267
|
+
|| _.get(td, `versions.base.${activeTab}.id`)
|
|
268
|
+
|| _.get(td, 'drag_drop_id')
|
|
269
|
+
|| _.get(td, 'id');
|
|
270
|
+
this.props.actions.getCmsSetting(BEE_PLUGIN, inlineDragDropId, this.props.params.id ? 'open' : 'create', undefined, isBEESupport, isBEEAppEnable);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
241
273
|
const hasUploadedContent = !this.props.params?.id && this.props.Templates?.selectedEmailLayout && !_.isEmpty(formData);
|
|
242
274
|
this.setState({
|
|
243
275
|
content: (this.props.Templates.selectedEmailLayout ? this.props.Templates.selectedEmailLayout : ''),
|
|
@@ -471,7 +503,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
471
503
|
}
|
|
472
504
|
});
|
|
473
505
|
}
|
|
474
|
-
if (this.state.isEdit && nextProps.location.query.module === "library" && !_.isEmpty(nextProps.templateData) &&
|
|
506
|
+
if (this.state.isEdit && nextProps.location.query.module === "library" && !_.isEmpty(nextProps.templateData) && !this.props.params.id && !nextProps.isGetFormData && _.isEmpty(_.get(this, `state.formData['template-subject']`))) {
|
|
475
507
|
this.startTemplateCreation(nextProps.templateData);
|
|
476
508
|
}
|
|
477
509
|
if (nextProps.location.query.module === 'library' && nextProps.isGetFormData && (this.props.isGetFormData !== nextProps.isGetFormData)) {
|
|
@@ -554,10 +586,21 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
554
586
|
const beeToken = `BEEeditor${currentTab > 1 ? currentTab : ''}token`;
|
|
555
587
|
let beeJsonValue = '';
|
|
556
588
|
const selectedId = _.get(this.props, 'Email.templateDetails._id', '') || _.get(this.props, 'Templates.BEETemplate.versions.base.drag_drop_id', '');
|
|
557
|
-
|
|
589
|
+
|
|
590
|
+
// Embedded journey content: the inline templateData carries the user's
|
|
591
|
+
// edited BEE json (base.json_content), which is more current than the
|
|
592
|
+
// reusable template fetched via getTemplateDetails. Prefer it so a
|
|
593
|
+
// re-edit shows the saved edit instead of the original template. For
|
|
594
|
+
// the create/gallery flow this key is absent, so we fall through to the
|
|
595
|
+
// existing sources (template details / BEETemplate) unchanged.
|
|
596
|
+
beeJsonValue = _.get(nextProps, 'templateData.base.json_content', '')
|
|
597
|
+
|| _.get(nextProps, 'templateData.json_content', '');
|
|
598
|
+
|
|
558
599
|
// Get beeJsonValue from template data - check multiple sources
|
|
559
600
|
// First check if it's already in formData (from setEditData)
|
|
560
|
-
|
|
601
|
+
if (!beeJsonValue) {
|
|
602
|
+
beeJsonValue = _.get(this.state, `formData[${currentTab - 1}][${langId}].json-content`, '');
|
|
603
|
+
}
|
|
561
604
|
|
|
562
605
|
// Also check formData.base
|
|
563
606
|
if (!beeJsonValue) {
|
|
@@ -615,14 +658,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
615
658
|
'json-content': finalBeeJsonValue,
|
|
616
659
|
};
|
|
617
660
|
|
|
618
|
-
// Ensure template-subject is preserved at the top level
|
|
619
|
-
// content templateDetails isn't fetched, so also read the subject from
|
|
620
|
-
// the inline templateData prop (base.subject / subject / emailSubject).
|
|
661
|
+
// Ensure template-subject is preserved at the top level
|
|
621
662
|
if (formData['template-subject'] === undefined || formData['template-subject'] === '') {
|
|
622
|
-
const subjectFromEditData = _.get(nextProps, 'Email.templateDetails.versions.base.subject', '')
|
|
623
|
-
|| _.get(nextProps, 'templateData.base.subject', '')
|
|
624
|
-
|| _.get(nextProps, 'templateData.subject', '')
|
|
625
|
-
|| _.get(nextProps, 'templateData.emailSubject', '');
|
|
663
|
+
const subjectFromEditData = _.get(nextProps, 'Email.templateDetails.versions.base.subject', '');
|
|
626
664
|
if (subjectFromEditData) {
|
|
627
665
|
formData['template-subject'] = subjectFromEditData;
|
|
628
666
|
}
|
|
@@ -1145,7 +1183,14 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
1145
1183
|
const type = this.props.location.query.type;
|
|
1146
1184
|
|
|
1147
1185
|
formData['template-name'] = editData.name;
|
|
1148
|
-
|
|
1186
|
+
// Prefer the inline edited subject (embedded journey content: base.subject /
|
|
1187
|
+
// emailSubject) over the fetched template's subject, so subject edits persist
|
|
1188
|
+
// on re-open. setEditData runs once (guarded by editDataSet), so this is a
|
|
1189
|
+
// one-time load-time override and won't fight typing in the subject field.
|
|
1190
|
+
const inlineSubject = _.get(this.props, 'templateData.base.subject', '')
|
|
1191
|
+
|| _.get(this.props, 'templateData.emailSubject', '')
|
|
1192
|
+
|| _.get(this.props, 'templateData.subject', '');
|
|
1193
|
+
const subject = inlineSubject || _.get(editData, 'versions.base.subject', '');
|
|
1149
1194
|
formData['template-subject'] = subject;
|
|
1150
1195
|
formData.base = editData.versions.base;
|
|
1151
1196
|
|
|
@@ -2476,11 +2521,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2476
2521
|
formData[0].selectedLanguages = [];
|
|
2477
2522
|
let tabKey;
|
|
2478
2523
|
if ((this.props.location.query.isLanguageSupport === undefined || this.props.location.query.isLanguageSupport === 'false')) {
|
|
2479
|
-
//
|
|
2480
|
-
|
|
2481
|
-
// an empty subject on open for embedded content (which routes through
|
|
2482
|
-
// startTemplateCreation), dropping data.base.subject.
|
|
2483
|
-
formData['template-subject'] = data?.base?.subject || formData?.['template-subject'] || '';
|
|
2524
|
+
// If formData['template-subject'] is empty, assign an empty string; otherwise, retain its current value or use data.base.subject.
|
|
2525
|
+
formData['template-subject'] = formData?.['template-subject'] === '' ? '' : (data?.base?.subject || '');
|
|
2484
2526
|
const baseLanguage = this.props.currentOrgDetails.basic_details.base_language;
|
|
2485
2527
|
let languageIndex = _.findIndex(this.supportedLanguages, {iso_code: baseLanguage});
|
|
2486
2528
|
|
|
@@ -234,10 +234,10 @@ const useEmailWrapper = ({
|
|
|
234
234
|
// New flow: When template details are loaded and it's a BEE template, set it in Templates.BEETemplate
|
|
235
235
|
// This allows Email component to properly initialize and call getCmsSetting
|
|
236
236
|
const hasTemplateDetails = Email?.templateDetails && !isEmpty(Email.templateDetails);
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
//
|
|
240
|
-
//
|
|
237
|
+
// Inline templateData (e.g. a freshly-created drag-drop content, or a
|
|
238
|
+
// library add-creative -> select-template) is authoritative when no template
|
|
239
|
+
// details were fetched. Without seeding BEETemplate from it, setBEETemplate
|
|
240
|
+
// never fires for that flow and a BEE template opens as the HTML editor.
|
|
241
241
|
const hasTemplateDataProp = templateData && !isEmpty(templateData);
|
|
242
242
|
// Note: We check Email?.BEETemplate as a proxy, but the actual BEETemplate is in Templates reducer
|
|
243
243
|
// The Email component will detect it via this.props.Templates.BEETemplate
|
|
@@ -300,7 +300,7 @@ const useEmailWrapper = ({
|
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
// Reset ref when template changes (template details cleared
|
|
303
|
+
// Reset ref when template changes (template details cleared)
|
|
304
304
|
if (!hasTemplateDetails && !hasTemplateDataProp && beeTemplateSetRef.current) {
|
|
305
305
|
beeTemplateSetRef.current = false;
|
|
306
306
|
}
|