@capillarytech/creatives-library 9.0.24 → 9.0.28
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,41 @@ 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
|
+
const inlineIsDragDrop = _.get(td, 'base.is_drag_drop')
|
|
249
|
+
|| _.get(td, `versions.base.${activeTab}.is_drag_drop`)
|
|
250
|
+
|| _.get(td, 'versions.base.is_drag_drop')
|
|
251
|
+
|| _.get(td, 'is_drag_drop');
|
|
252
|
+
// BEE-ONLY: everything below is gated on is_drag_drop so this fallback
|
|
253
|
+
// never touches the HTML/CKEditor flow (which also has an empty BEETemplate).
|
|
254
|
+
if ((inlineIsDragDrop === true || inlineIsDragDrop === 1) && isBEEAppEnable) {
|
|
255
|
+
this.setState({ isDragDrop: true });
|
|
256
|
+
// This path bypasses setEditData, so seed the subject from the inline
|
|
257
|
+
// templateData too (otherwise the title is empty for a created drag-drop).
|
|
258
|
+
const inlineSubject = _.get(td, 'base.subject')
|
|
259
|
+
|| _.get(td, `versions.base.${activeTab}.subject`)
|
|
260
|
+
|| _.get(td, 'versions.base.subject')
|
|
261
|
+
|| _.get(td, 'emailSubject')
|
|
262
|
+
|| _.get(td, 'subject');
|
|
263
|
+
if (inlineSubject) {
|
|
264
|
+
formData['template-subject'] = inlineSubject;
|
|
265
|
+
}
|
|
266
|
+
const inlineDragDropId = _.get(td, 'base.drag_drop_id')
|
|
267
|
+
|| _.get(td, 'base.id')
|
|
268
|
+
|| _.get(td, `versions.base.${activeTab}.drag_drop_id`)
|
|
269
|
+
|| _.get(td, `versions.base.${activeTab}.id`)
|
|
270
|
+
|| _.get(td, 'drag_drop_id')
|
|
271
|
+
|| _.get(td, 'id');
|
|
272
|
+
this.props.actions.getCmsSetting(BEE_PLUGIN, inlineDragDropId, this.props.params.id ? 'open' : 'create', undefined, isBEESupport, isBEEAppEnable);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
241
275
|
const hasUploadedContent = !this.props.params?.id && this.props.Templates?.selectedEmailLayout && !_.isEmpty(formData);
|
|
242
276
|
this.setState({
|
|
243
277
|
content: (this.props.Templates.selectedEmailLayout ? this.props.Templates.selectedEmailLayout : ''),
|
|
@@ -471,7 +505,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
471
505
|
}
|
|
472
506
|
});
|
|
473
507
|
}
|
|
474
|
-
if (this.state.isEdit && nextProps.location.query.module === "library" && !_.isEmpty(nextProps.templateData) &&
|
|
508
|
+
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
509
|
this.startTemplateCreation(nextProps.templateData);
|
|
476
510
|
}
|
|
477
511
|
if (nextProps.location.query.module === 'library' && nextProps.isGetFormData && (this.props.isGetFormData !== nextProps.isGetFormData)) {
|
|
@@ -554,10 +588,21 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
554
588
|
const beeToken = `BEEeditor${currentTab > 1 ? currentTab : ''}token`;
|
|
555
589
|
let beeJsonValue = '';
|
|
556
590
|
const selectedId = _.get(this.props, 'Email.templateDetails._id', '') || _.get(this.props, 'Templates.BEETemplate.versions.base.drag_drop_id', '');
|
|
557
|
-
|
|
591
|
+
|
|
592
|
+
// Embedded journey content: the inline templateData carries the user's
|
|
593
|
+
// edited BEE json (base.json_content), which is more current than the
|
|
594
|
+
// reusable template fetched via getTemplateDetails. Prefer it so a
|
|
595
|
+
// re-edit shows the saved edit instead of the original template. For
|
|
596
|
+
// the create/gallery flow this key is absent, so we fall through to the
|
|
597
|
+
// existing sources (template details / BEETemplate) unchanged.
|
|
598
|
+
beeJsonValue = _.get(nextProps, 'templateData.base.json_content', '')
|
|
599
|
+
|| _.get(nextProps, 'templateData.json_content', '');
|
|
600
|
+
|
|
558
601
|
// Get beeJsonValue from template data - check multiple sources
|
|
559
602
|
// First check if it's already in formData (from setEditData)
|
|
560
|
-
|
|
603
|
+
if (!beeJsonValue) {
|
|
604
|
+
beeJsonValue = _.get(this.state, `formData[${currentTab - 1}][${langId}].json-content`, '');
|
|
605
|
+
}
|
|
561
606
|
|
|
562
607
|
// Also check formData.base
|
|
563
608
|
if (!beeJsonValue) {
|
|
@@ -615,14 +660,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
615
660
|
'json-content': finalBeeJsonValue,
|
|
616
661
|
};
|
|
617
662
|
|
|
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).
|
|
663
|
+
// Ensure template-subject is preserved at the top level
|
|
621
664
|
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', '');
|
|
665
|
+
const subjectFromEditData = _.get(nextProps, 'Email.templateDetails.versions.base.subject', '');
|
|
626
666
|
if (subjectFromEditData) {
|
|
627
667
|
formData['template-subject'] = subjectFromEditData;
|
|
628
668
|
}
|
|
@@ -1145,7 +1185,21 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
1145
1185
|
const type = this.props.location.query.type;
|
|
1146
1186
|
|
|
1147
1187
|
formData['template-name'] = editData.name;
|
|
1148
|
-
|
|
1188
|
+
// BEE-ONLY: for embedded drag-drop content, prefer the inline edited subject
|
|
1189
|
+
// (base.subject / emailSubject) over the fetched template's subject so subject
|
|
1190
|
+
// edits persist on re-open. Gated on is_drag_drop so the HTML/CKEditor flow is
|
|
1191
|
+
// untouched (it keeps using editData.versions.base.subject as before).
|
|
1192
|
+
// setEditData runs once (editDataSet), so this is a one-time load-time override.
|
|
1193
|
+
const tdIsDragDrop = _.get(this.props, 'templateData.base.is_drag_drop') === true
|
|
1194
|
+
|| _.get(this.props, 'templateData.base.is_drag_drop') === 1
|
|
1195
|
+
|| _.get(this.props, 'templateData.is_drag_drop') === true
|
|
1196
|
+
|| _.get(this.props, 'templateData.is_drag_drop') === 1;
|
|
1197
|
+
const inlineSubject = tdIsDragDrop
|
|
1198
|
+
? (_.get(this.props, 'templateData.base.subject', '')
|
|
1199
|
+
|| _.get(this.props, 'templateData.emailSubject', '')
|
|
1200
|
+
|| _.get(this.props, 'templateData.subject', ''))
|
|
1201
|
+
: '';
|
|
1202
|
+
const subject = inlineSubject || _.get(editData, 'versions.base.subject', '');
|
|
1149
1203
|
formData['template-subject'] = subject;
|
|
1150
1204
|
formData.base = editData.versions.base;
|
|
1151
1205
|
|
|
@@ -2476,11 +2530,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2476
2530
|
formData[0].selectedLanguages = [];
|
|
2477
2531
|
let tabKey;
|
|
2478
2532
|
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'] || '';
|
|
2533
|
+
// If formData['template-subject'] is empty, assign an empty string; otherwise, retain its current value or use data.base.subject.
|
|
2534
|
+
formData['template-subject'] = formData?.['template-subject'] === '' ? '' : (data?.base?.subject || '');
|
|
2484
2535
|
const baseLanguage = this.props.currentOrgDetails.basic_details.base_language;
|
|
2485
2536
|
let languageIndex = _.findIndex(this.supportedLanguages, {iso_code: baseLanguage});
|
|
2486
2537
|
|
|
@@ -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
|
}
|