@capillarytech/creatives-library 9.0.18 → 9.0.21

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.21",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -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