@capillarytech/creatives-library 9.0.18 → 9.0.23

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "9.0.18",
4
+ "version": "9.0.23",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -617,9 +617,14 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
617
617
  'json-content': finalBeeJsonValue,
618
618
  };
619
619
 
620
- // Ensure template-subject is preserved at the top level
620
+ // Ensure template-subject is preserved at the top level. For embedded
621
+ // content templateDetails isn't fetched, so also read the subject from
622
+ // the inline templateData prop (base.subject / subject / emailSubject).
621
623
  if (formData['template-subject'] === undefined || formData['template-subject'] === '') {
622
- const subjectFromEditData = _.get(nextProps, 'Email.templateDetails.versions.base.subject', '');
624
+ const subjectFromEditData = _.get(nextProps, 'Email.templateDetails.versions.base.subject', '')
625
+ || _.get(nextProps, 'templateData.base.subject', '')
626
+ || _.get(nextProps, 'templateData.subject', '')
627
+ || _.get(nextProps, 'templateData.emailSubject', '');
623
628
  if (subjectFromEditData) {
624
629
  formData['template-subject'] = subjectFromEditData;
625
630
  }
@@ -2473,8 +2478,11 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2473
2478
  formData[0].selectedLanguages = [];
2474
2479
  let tabKey;
2475
2480
  if ((this.props.location.query.isLanguageSupport === undefined || this.props.location.query.isLanguageSupport === 'false')) {
2476
- // If formData['template-subject'] is empty, assign an empty string; otherwise, retain its current value or use data.base.subject.
2477
- formData['template-subject'] = formData?.['template-subject'] === '' ? '' : (data?.base?.subject || '');
2481
+ // Prefer the saved subject from the inline templateData (base.subject);
2482
+ // fall back to any existing value. The previous `=== '' ? '' :` guard kept
2483
+ // an empty subject on open for embedded content (which routes through
2484
+ // startTemplateCreation), dropping data.base.subject.
2485
+ formData['template-subject'] = data?.base?.subject || formData?.['template-subject'] || '';
2478
2486
  const baseLanguage = this.props.currentOrgDetails.basic_details.base_language;
2479
2487
  let languageIndex = _.findIndex(this.supportedLanguages, {iso_code: baseLanguage});
2480
2488
 
@@ -234,13 +234,18 @@ 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
+ // An inline templateData prop (e.g. library add-creative -> select template)
238
+ // is authoritative when template details weren't fetched (the by-id fetch is
239
+ // skipped whenever a templateData prop is present). Without seeding from it,
240
+ // setBEETemplate never fires for that flow and a BEE template opens as HTML.
241
+ const hasTemplateDataProp = templateData && !isEmpty(templateData);
237
242
  // Note: We check Email?.BEETemplate as a proxy, but the actual BEETemplate is in Templates reducer
238
243
  // The Email component will detect it via this.props.Templates.BEETemplate
239
244
  const hasBEETemplate = Email?.BEETemplate && !isEmpty(Email.BEETemplate);
240
245
 
241
- if (hasTemplateDetails && !hasBEETemplate && templatesActions?.setBEETemplate && !beeTemplateSetRef.current) {
246
+ if ((hasTemplateDetails || hasTemplateDataProp) && !hasBEETemplate && templatesActions?.setBEETemplate && !beeTemplateSetRef.current) {
242
247
  // Check if it's a BEE template
243
- const editTemplateData = Email.templateDetails;
248
+ const editTemplateData = hasTemplateDetails ? Email.templateDetails : templateData;
244
249
  const getIsDragDrop = (data) => {
245
250
  if (!data) return false;
246
251
  const baseDragDrop = get(data, 'versions.base.is_drag_drop', false);
@@ -295,11 +300,11 @@ const useEmailWrapper = ({
295
300
  }
296
301
  }
297
302
 
298
- // Reset ref when template changes (template details cleared)
299
- if (!hasTemplateDetails && beeTemplateSetRef.current) {
303
+ // Reset ref when template changes (template details cleared and no inline prop)
304
+ if (!hasTemplateDetails && !hasTemplateDataProp && beeTemplateSetRef.current) {
300
305
  beeTemplateSetRef.current = false;
301
306
  }
302
- }, [Email?.templateDetails, Email?.BEETemplate, Email?.getTemplateDetailsInProgress, Email?.fetchingCmsSettings, templatesActions, emailActions, params?.id, location?.query, checkBeeEditorEnabled, isFullMode]);
307
+ }, [Email?.templateDetails, Email?.BEETemplate, Email?.getTemplateDetailsInProgress, Email?.fetchingCmsSettings, templatesActions, emailActions, params?.id, location?.query, checkBeeEditorEnabled, isFullMode, templateData]);
303
308
 
304
309
  const onChange = useCallback((e) => {
305
310
  const { target: { value } } = e;
@@ -744,7 +744,11 @@ export const Whatsapp = (props) => {
744
744
  carouselIndex,
745
745
  } = tagSelectData;
746
746
  if (mapData && updatedData) {
747
- const numId = Number(areaId?.slice(areaId?.indexOf("_") + 1));
747
+ const underscoreIdx = areaId ? areaId.indexOf("_") : -1;
748
+ if (underscoreIdx < 0) {
749
+ return;
750
+ }
751
+ const numId = Number(areaId.slice(underscoreIdx + 1));
748
752
  if (!isNaN(numId)) {
749
753
  const arr = [...updatedData];
750
754
  //when trying to insert tag in empty textarea,{#var#} is replaced with "" and then tag is added