@capillarytech/creatives-library 8.0.236-beta.0 → 8.0.236

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.
Files changed (38) hide show
  1. package/constants/unified.js +0 -1
  2. package/package.json +1 -1
  3. package/services/api.js +0 -5
  4. package/utils/common.js +1 -6
  5. package/v2Components/CapTagList/index.js +1 -2
  6. package/v2Components/CapTagListWithInput/index.js +1 -5
  7. package/v2Components/CapTagListWithInput/messages.js +1 -1
  8. package/v2Components/ErrorInfoNote/style.scss +1 -1
  9. package/v2Components/HtmlEditor/HTMLEditor.js +14 -86
  10. package/v2Components/HtmlEditor/_htmlEditor.scss +4 -0
  11. package/v2Components/HtmlEditor/_index.lazy.scss +1 -1
  12. package/v2Components/HtmlEditor/components/CodeEditorPane/_codeEditorPane.scss +98 -11
  13. package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +115 -174
  14. package/v2Components/HtmlEditor/components/SplitContainer/_splitContainer.scss +1 -1
  15. package/v2Components/HtmlEditor/hooks/useEditorContent.js +2 -5
  16. package/v2Components/TestAndPreviewSlidebox/index.js +25 -31
  17. package/v2Containers/CreativesContainer/SlideBoxContent.js +35 -83
  18. package/v2Containers/CreativesContainer/SlideBoxFooter.js +3 -9
  19. package/v2Containers/CreativesContainer/index.js +11 -83
  20. package/v2Containers/CreativesContainer/messages.js +0 -4
  21. package/v2Containers/Email/actions.js +0 -7
  22. package/v2Containers/Email/constants.js +1 -5
  23. package/v2Containers/Email/index.js +0 -13
  24. package/v2Containers/Email/messages.js +0 -32
  25. package/v2Containers/Email/reducer.js +1 -12
  26. package/v2Containers/Email/sagas.js +0 -17
  27. package/v2Containers/EmailWrapper/components/EmailWrapperView.js +7 -193
  28. package/v2Containers/EmailWrapper/constants.js +0 -2
  29. package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +67 -436
  30. package/v2Containers/EmailWrapper/index.js +23 -99
  31. package/v2Containers/EmailWrapper/messages.js +1 -61
  32. package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +49 -49
  33. package/v2Containers/TagList/index.js +0 -2
  34. package/v2Containers/Templates/index.js +0 -5
  35. package/HOW_BEE_EDITOR_WORKS.md +0 -375
  36. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +0 -1034
  37. package/v2Containers/EmailWrapper/tests/EmailHTMLEditor.test.js +0 -177
  38. package/v2Containers/EmailWrapper/tests/EmailHTMLEditorValidation.test.js +0 -90
@@ -1,4 +1,4 @@
1
- import React, { useRef, useCallback } from 'react';
1
+ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { FormattedMessage } from 'react-intl';
4
4
  import styled from 'styled-components';
@@ -11,15 +11,10 @@ import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
11
11
  import CapButton from '@capillarytech/cap-ui-library/CapButton';
12
12
  import CapError from '@capillarytech/cap-ui-library/CapError';
13
13
  import ComponentWithLabelHOC from '@capillarytech/cap-ui-library/assets/HOCs/ComponentWithLabelHOC';
14
- import { CAP_COLOR_06, CAP_WHITE } from '@capillarytech/cap-ui-library/styled/variables';
15
- import { EmailWithoutSaga } from '../../Email';
14
+ import Email from '../../Email';
16
15
  import CmsTemplatesComponent from '../../../v2Components/CmsTemplatesComponent';
17
- import EmailHTMLEditor from './EmailHTMLEditor';
18
- import TestAndPreviewSlidebox from '../../../v2Components/TestAndPreviewSlidebox';
19
- import { EMAIL } from '../../CreativesContainer/constants';
20
16
  import messages from '../messages';
21
17
  import { EMAIL_CREATE_MODES, STEPS } from '../constants';
22
- import { hasSupportCKEditor } from '../../../utils/common';
23
18
 
24
19
  const CapRadioCardWithLabel = ComponentWithLabelHOC(CapRadioCard);
25
20
 
@@ -32,23 +27,9 @@ const CardContainer = styled.div`
32
27
  }
33
28
  }
34
29
  }
35
-
36
- .ant-radio-group.cap-radioCard-v2 {
37
- .ant-radio-button-wrapper {
38
- &.ant-radio-button-wrapper-checked {
39
- .icon-container {
40
- background-color: ${CAP_COLOR_06};
41
- .anticon,
42
- .cap-icon {
43
- color: ${CAP_WHITE};
44
- }
45
- }
46
- }
47
- }
48
- }
49
30
  `;
50
31
 
51
- // Mode selection component
32
+ // Mode selection component that handles the creation mode selection UI
52
33
  const ModeSelectionUI = ({
53
34
  isFullMode,
54
35
  templateName,
@@ -70,7 +51,7 @@ const ModeSelectionUI = ({
70
51
  value={templateName}
71
52
  labelPosition="top"
72
53
  size="default"
73
- style={{ width: '68%' }}
54
+ style={{ width: '68%'}}
74
55
  />
75
56
  )}
76
57
  <CardContainer>
@@ -117,21 +98,15 @@ ModeSelectionUI.propTypes = {
117
98
  uploadButtonLabel: PropTypes.node.isRequired,
118
99
  };
119
100
 
120
- // Content creation component
101
+ // Content creation component that handles the email or template selection UI
121
102
  const ContentCreationUI = ({
122
103
  isShowEmailCreate,
123
104
  emailProps,
124
105
  cmsTemplatesProps,
125
- isHTMLEditorMode,
126
- htmlEditorProps,
127
106
  }) => (
128
107
  <>
129
108
  {isShowEmailCreate ? (
130
- isHTMLEditorMode ? (
131
- <EmailHTMLEditor {...htmlEditorProps} />
132
- ) : (
133
- <EmailWithoutSaga {...emailProps} />
134
- )
109
+ <Email {...emailProps} />
135
110
  ) : (
136
111
  <CmsTemplatesComponent {...cmsTemplatesProps} />
137
112
  )}
@@ -142,8 +117,6 @@ ContentCreationUI.propTypes = {
142
117
  isShowEmailCreate: PropTypes.bool.isRequired,
143
118
  emailProps: PropTypes.object.isRequired,
144
119
  cmsTemplatesProps: PropTypes.object.isRequired,
145
- isHTMLEditorMode: PropTypes.bool,
146
- htmlEditorProps: PropTypes.object,
147
120
  };
148
121
 
149
122
  // Main EmailWrapper presentational component
@@ -164,130 +137,9 @@ const EmailWrapperView = ({
164
137
  isShowEmailCreate,
165
138
  emailProps,
166
139
  cmsTemplatesProps,
167
- metaEntities,
168
- loadingTags,
169
- injectedTags,
170
- globalActions,
171
- supportedTags,
172
- getDefaultTags,
173
- location,
174
- currentOrgDetails,
175
- forwardedTags,
176
- selectedOfferDetails,
177
- eventContextTags,
178
- getFormdata,
179
- isGetFormData,
180
- getLiquidTags,
181
- showLiquidErrorInFooter,
182
- onValidationFail,
183
- emailActions,
184
- Email,
185
- templateData: templateDataProp,
186
- params,
187
- fetchingLiquidTags,
188
- createTemplateInProgress,
189
- fetchingCmsData,
190
- setIsLoadingContent,
191
- showTestAndPreviewSlidebox,
192
- handleCloseTestAndPreview,
193
- showTemplateName,
194
140
  }) => {
195
- const htmlEditorRef = useRef(null);
196
- const supportCKEditor = hasSupportCKEditor();
197
- const hasParamsIdForEditor = params?.id || location?.query?.id || location?.params?.id || location?.pathname?.includes('/edit/');
198
- const isEditModeForEditor = hasParamsIdForEditor;
199
- const isBEEFromProps = emailProps?.editor === 'BEE' && emailProps?.selectedEditorMode === null;
200
- const isDragDropFromCreateMode = emailCreateMode === EMAIL_CREATE_MODES.DRAG_DROP;
201
- const isExplicitlyBEEEditor = isBEEFromProps || isDragDropFromCreateMode;
202
- let isHTMLEditorMode = false;
203
141
 
204
- if (supportCKEditor) {
205
- isHTMLEditorMode = false; // Legacy flow: use Email component
206
- } else if (isEditModeForEditor) {
207
- isHTMLEditorMode = !isExplicitlyBEEEditor;
208
- } else {
209
- if (isExplicitlyBEEEditor || isBEEFromProps || isDragDropFromCreateMode) {
210
- isHTMLEditorMode = false;
211
- } else {
212
- isHTMLEditorMode = emailProps?.selectedEditorMode === EMAIL_CREATE_MODES.HTML_EDITOR ||
213
- emailCreateMode === EMAIL_CREATE_MODES.HTML_EDITOR;
214
- }
215
- }
216
-
217
- const isShowTemplateSelection = step === STEPS.MODE_SELECTION;
218
-
219
- // Create onFormDataChange callback for template name updates (similar to Email component)
220
- // This allows CreativesContainer to update the template name when user clicks "Edit name"
221
- // When user edits the name in CreativesContainer header, it calls this callback
222
- // which updates the template name in EmailWrapper, and then CreativesContainer
223
- // will call showTemplateName again with the updated formData
224
- const handleFormDataChange = useCallback((updatedFormData) => {
225
- const newTemplateName = updatedFormData?.['template-name'] || templateName;
226
- if (newTemplateName !== templateName && onTemplateNameChange) {
227
- // Update template name in parent (useEmailWrapper hook)
228
- onTemplateNameChange({ target: { value: newTemplateName } });
229
- }
230
- // Note: CreativesContainer will call showTemplateName again after this callback
231
- // (it stores the callback in templateContainerDetails and calls it after state updates)
232
- }, [templateName, onTemplateNameChange]);
233
-
234
- const htmlEditorProps = isHTMLEditorMode ? {
235
- // Location and params
236
- location,
237
- params,
238
- // Tag-related props
239
- getDefaultTags,
240
- supportedTags,
241
- metaEntities,
242
- injectedTags,
243
- globalActions,
244
- loadingTags,
245
- eventContextTags,
246
- forwardedTags,
247
- selectedOfferDetails,
248
- currentOrgDetails,
249
- // Email Redux state and actions
250
- Email,
251
- emailActions,
252
- // Full mode props
253
- isFullMode,
254
- templateName,
255
- isGetFormData,
256
- getFormdata,
257
- // Library mode props
258
- templateData: templateDataProp,
259
- // Uploaded content from zip file
260
- EmailLayout,
261
- // Liquid validation
262
- getLiquidTags,
263
- showLiquidErrorInFooter,
264
- onValidationFail,
265
- // Template name
266
- showTemplateName,
267
- onFormDataChange: handleFormDataChange,
268
- // Loading states
269
- fetchingLiquidTags: fetchingLiquidTags || false,
270
- createTemplateInProgress: createTemplateInProgress || false,
271
- fetchingCmsData: fetchingCmsData || false,
272
- // Parent loading control
273
- setIsLoadingContent,
274
- ref: htmlEditorRef,
275
- } : {};
276
-
277
- // Get formData for TestAndPreviewSlidebox when needed
278
- const getFormDataForPreview = () => {
279
- if (htmlEditorRef.current && htmlEditorRef.current.getFormDataForPreview) {
280
- return htmlEditorRef.current.getFormDataForPreview();
281
- }
282
- return {};
283
- };
284
-
285
- const getContentForPreview = () => {
286
- if (htmlEditorRef.current && htmlEditorRef.current.getContentForPreview) {
287
- return htmlEditorRef.current.getContentForPreview();
288
- }
289
- return '';
290
- };
142
+ const isShowTemplateSelection = step === STEPS.MODE_SELECTION || (step === STEPS.TEMPLATE_SELECTION && emailCreateMode === EMAIL_CREATE_MODES.UPLOAD);
291
143
 
292
144
  return (
293
145
  <>
@@ -311,22 +163,9 @@ const EmailWrapperView = ({
311
163
  isShowEmailCreate={isShowEmailCreate}
312
164
  emailProps={emailProps}
313
165
  cmsTemplatesProps={cmsTemplatesProps}
314
- isHTMLEditorMode={isHTMLEditorMode}
315
- htmlEditorProps={htmlEditorProps}
316
166
  />
317
167
  )}
318
168
  </CapSpin>
319
- {/* Render TestAndPreviewSlidebox for HTML Editor (similar to legacy Email component) */}
320
- {isHTMLEditorMode && showTestAndPreviewSlidebox && (
321
- <TestAndPreviewSlidebox
322
- show={showTestAndPreviewSlidebox}
323
- onClose={handleCloseTestAndPreview}
324
- formData={getFormDataForPreview()}
325
- content={getContentForPreview()}
326
- currentChannel={EMAIL}
327
- currentTab={1}
328
- />
329
- )}
330
169
  </>
331
170
  );
332
171
  };
@@ -336,10 +175,6 @@ EmailWrapperView.propTypes = {
336
175
  emailCreateMode: PropTypes.string,
337
176
  step: PropTypes.string,
338
177
  isFullMode: PropTypes.bool,
339
- getFormdata: PropTypes.func,
340
- isGetFormData: PropTypes.bool,
341
- getLiquidTags: PropTypes.func,
342
- showLiquidErrorInFooter: PropTypes.func,
343
178
  templateName: PropTypes.string,
344
179
  onTemplateNameChange: PropTypes.func.isRequired,
345
180
  isTemplateNameEmpty: PropTypes.bool,
@@ -352,27 +187,6 @@ EmailWrapperView.propTypes = {
352
187
  isShowEmailCreate: PropTypes.bool.isRequired,
353
188
  emailProps: PropTypes.object.isRequired,
354
189
  cmsTemplatesProps: PropTypes.object.isRequired,
355
- metaEntities: PropTypes.object,
356
- loadingTags: PropTypes.bool,
357
- injectedTags: PropTypes.object,
358
- globalActions: PropTypes.object,
359
- supportedTags: PropTypes.array,
360
- getDefaultTags: PropTypes.string,
361
- location: PropTypes.object,
362
- currentOrgDetails: PropTypes.object,
363
- forwardedTags: PropTypes.object,
364
- selectedOfferDetails: PropTypes.array,
365
- eventContextTags: PropTypes.array,
366
- emailActions: PropTypes.object,
367
- Email: PropTypes.object,
368
- templateData: PropTypes.object,
369
- params: PropTypes.object,
370
- fetchingLiquidTags: PropTypes.bool,
371
- createTemplateInProgress: PropTypes.bool,
372
- fetchingCmsData: PropTypes.bool,
373
- setIsLoadingContent: PropTypes.func,
374
- showTestAndPreviewSlidebox: PropTypes.bool,
375
- handleCloseTestAndPreview: PropTypes.func,
376
190
  };
377
191
 
378
192
  export default EmailWrapperView;
@@ -8,8 +8,6 @@ export const DEFAULT_ACTION = "app/EmailWrapper/DEFAULT_ACTION";
8
8
  export const EMAIL_CREATE_MODES = {
9
9
  UPLOAD: "upload",
10
10
  EDITOR: "editor",
11
- HTML_EDITOR: "html_editor",
12
- DRAG_DROP: "drag_drop",
13
11
  };
14
12
 
15
13
  export const STEPS = {