@capillarytech/creatives-library 8.0.292-alpha.13 → 8.0.292-alpha.15
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
|
@@ -191,7 +191,7 @@ const HTMLEditor = forwardRef(({
|
|
|
191
191
|
inAppContent.updateContent(newContent, true);
|
|
192
192
|
inAppLastAppliedInitialRef.current = { android: newAndroid, ios: newIos };
|
|
193
193
|
}
|
|
194
|
-
}, [initialContent, isEmailVariant, isInAppVariant
|
|
194
|
+
}, [initialContent, isEmailVariant, isInAppVariant]);
|
|
195
195
|
// Handle context change for tag API calls
|
|
196
196
|
// If variant is INAPP, use SMS layout; otherwise use the channel (EMAIL)
|
|
197
197
|
const handleContextChange = useCallback((contextData) => {
|
|
@@ -305,13 +305,10 @@ const HTMLEditor = forwardRef(({
|
|
|
305
305
|
apiValidationErrors, // Pass API validation errors to merge with client-side validation
|
|
306
306
|
}, formatSanitizerMessage, formatValidatorMessage);
|
|
307
307
|
|
|
308
|
-
// Expose validation and content state via ref
|
|
308
|
+
// Expose validation and content state via ref
|
|
309
309
|
useImperativeHandle(ref, () => ({
|
|
310
310
|
getValidation: () => validation,
|
|
311
311
|
getContent: () => currentContent,
|
|
312
|
-
getDeviceContent: variant === HTML_EDITOR_VARIANTS.INAPP && typeof getDeviceContent === 'function'
|
|
313
|
-
? getDeviceContent
|
|
314
|
-
: undefined,
|
|
315
312
|
isContentEmpty: () => !currentContent || currentContent.trim() === '',
|
|
316
313
|
getIssueCounts: () => {
|
|
317
314
|
if (!validation || typeof validation.getAllIssues !== 'function') {
|
|
@@ -327,7 +324,7 @@ const HTMLEditor = forwardRef(({
|
|
|
327
324
|
: countIssuesBySeverity(validation.getAllIssues()),
|
|
328
325
|
})
|
|
329
326
|
,
|
|
330
|
-
}), [validation, currentContent, apiValidationErrors
|
|
327
|
+
}), [validation, currentContent, apiValidationErrors]); // Include apiValidationErrors so ref methods return updated counts
|
|
331
328
|
|
|
332
329
|
// Use ref to store callback to avoid infinite loops (callback in deps would cause re-runs)
|
|
333
330
|
const onValidationChangeRef = useRef(onValidationChange);
|
|
@@ -835,5 +832,5 @@ HTMLEditor.defaultProps = {
|
|
|
835
832
|
apiValidationErrors: null, // API validation errors from validateLiquidTemplateContent
|
|
836
833
|
};
|
|
837
834
|
|
|
838
|
-
// Export with injectIntl -
|
|
839
|
-
export default injectIntl(HTMLEditor
|
|
835
|
+
// Export with injectIntl - HTMLEditor now uses forwardRef internally
|
|
836
|
+
export default injectIntl(HTMLEditor);
|
|
@@ -40,14 +40,14 @@ const LazyHTMLEditor = React.lazy(() =>
|
|
|
40
40
|
*
|
|
41
41
|
* This component wraps the HTMLEditor with React.lazy() and Suspense
|
|
42
42
|
* to enable code splitting and reduce initial bundle size.
|
|
43
|
-
* Forwards ref so parent (e.g. InApp) can call getDeviceContent for Test and Preview.
|
|
44
43
|
*/
|
|
45
|
-
const HTMLEditorLazy =
|
|
46
|
-
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
const HTMLEditorLazy = (props) => {
|
|
45
|
+
return (
|
|
46
|
+
<Suspense fallback={<HTMLEditorFallback />}>
|
|
47
|
+
<LazyHTMLEditor {...props} />
|
|
48
|
+
</Suspense>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
51
|
|
|
52
52
|
// Forward all prop types from the original component
|
|
53
53
|
HTMLEditorLazy.propTypes = {
|
|
@@ -61,7 +61,7 @@ import { validateInAppContent } from "../../utils/commonUtils";
|
|
|
61
61
|
import { hasLiquidSupportFeature } from "../../utils/common";
|
|
62
62
|
import formBuilderMessages from "../../v2Components/FormBuilder/messages";
|
|
63
63
|
import HTMLEditor from "../../v2Components/HtmlEditor";
|
|
64
|
-
import { HTML_EDITOR_VARIANTS
|
|
64
|
+
import { HTML_EDITOR_VARIANTS } from "../../v2Components/HtmlEditor/constants";
|
|
65
65
|
import { INAPP_EDITOR_TYPES } from "../InAppWrapper/constants";
|
|
66
66
|
import InappAdvanced from "../InappAdvance/index";
|
|
67
67
|
import { ErrorInfoNote } from "../../v2Components/ErrorInfoNote";
|
|
@@ -145,7 +145,6 @@ export const InApp = (props) => {
|
|
|
145
145
|
// Refs to store latest content before layout changes
|
|
146
146
|
const htmlContentAndroidRef = useRef(htmlContentAndroid);
|
|
147
147
|
const htmlContentIosRef = useRef(htmlContentIos);
|
|
148
|
-
const htmlEditorRef = useRef(null);
|
|
149
148
|
const [accountId, setAccountId] = useState("");
|
|
150
149
|
const [accessToken, setAccessToken] = useState("");
|
|
151
150
|
const [accountName, setAccountName] = useState("");
|
|
@@ -178,19 +177,9 @@ export const InApp = (props) => {
|
|
|
178
177
|
// Transformation to payload structure happens in prepareTestMessagePayload
|
|
179
178
|
// Reference: Based on getPreviewSection() function (lines 490-530) which prepares content for TemplatePreview
|
|
180
179
|
const getTemplateContent = useCallback(() => {
|
|
181
|
-
// For HTML template
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
if (isHTMLTemplate) {
|
|
185
|
-
const getDeviceContentFromEditor = htmlEditorRef.current?.getDeviceContent;
|
|
186
|
-
if (typeof getDeviceContentFromEditor === 'function') {
|
|
187
|
-
androidMsg = getDeviceContentFromEditor(HTML_DEVICE_TYPES.ANDROID) ?? '';
|
|
188
|
-
iosMsg = getDeviceContentFromEditor(HTML_DEVICE_TYPES.IOS) ?? '';
|
|
189
|
-
} else {
|
|
190
|
-
androidMsg = htmlContentAndroidRef.current ?? htmlContentAndroid ?? '';
|
|
191
|
-
iosMsg = htmlContentIosRef.current ?? htmlContentIos ?? '';
|
|
192
|
-
}
|
|
193
|
-
}
|
|
180
|
+
// For HTML template, use HTML editor content so preview stays in sync with typing
|
|
181
|
+
const androidMsg = isHTMLTemplate ? (htmlContentAndroid ?? '') : templateMessageAndroid;
|
|
182
|
+
const iosMsg = isHTMLTemplate ? (htmlContentIos ?? '') : templateMessageIos;
|
|
194
183
|
|
|
195
184
|
// Prepare Android content
|
|
196
185
|
const androidMediaPreview = {};
|
|
@@ -518,11 +507,40 @@ export const InApp = (props) => {
|
|
|
518
507
|
}
|
|
519
508
|
}, [editData.templateDetails || templateData]);
|
|
520
509
|
|
|
521
|
-
// Extract editor type from defaultData
|
|
510
|
+
// Extract editor type: from defaultData (create flow) or derive from template content (edit flow)
|
|
522
511
|
const editorType = useMemo(() => {
|
|
523
|
-
const
|
|
524
|
-
return
|
|
525
|
-
|
|
512
|
+
const fromDefault = defaultData?.['editor-type'];
|
|
513
|
+
if (fromDefault) return fromDefault;
|
|
514
|
+
|
|
515
|
+
// Edit flow: derive from template content when editor-type wasn't passed from wrapper
|
|
516
|
+
const source = isFullMode ? editData?.templateDetails : templateData;
|
|
517
|
+
const versions = source?.versions;
|
|
518
|
+
const content = get(versions, 'base.content', {});
|
|
519
|
+
if (!content || isEmpty(content)) return undefined;
|
|
520
|
+
|
|
521
|
+
const androidContent = content?.ANDROID;
|
|
522
|
+
const iosContent = content?.IOS;
|
|
523
|
+
const androidTitle = (androidContent?.title ?? '').toString();
|
|
524
|
+
const iosTitle = (iosContent?.title ?? '').toString();
|
|
525
|
+
const androidType = androidContent?.type ?? '';
|
|
526
|
+
const iosType = iosContent?.type ?? '';
|
|
527
|
+
const androidStyle = get(androidContent, 'expandableDetails.style');
|
|
528
|
+
const iosStyle = get(iosContent, 'expandableDetails.style');
|
|
529
|
+
const isBEEeditorAndroid = get(androidContent, 'isBEEeditor');
|
|
530
|
+
const isBEEeditorIos = get(iosContent, 'isBEEeditor');
|
|
531
|
+
const isBeeFreeAndroid = !isEmpty(androidTitle) && androidTitle.toLowerCase() === 'bee free template';
|
|
532
|
+
const isBeeFreeIos = !isEmpty(iosTitle) && iosTitle.toLowerCase() === 'bee free template';
|
|
533
|
+
const isHTMLEditorAndroid = !isEmpty(androidTitle) && androidTitle.toLowerCase() === 'html editor template';
|
|
534
|
+
const isHTMLEditorIos = !isEmpty(iosTitle) && iosTitle.toLowerCase() === 'html editor template';
|
|
535
|
+
|
|
536
|
+
const androidIsHTML = isHTMLEditorAndroid
|
|
537
|
+
|| ((androidType === INAPP_MEDIA_TYPES.HTML || androidStyle === BIG_HTML) && !isBEEeditorAndroid && !isBeeFreeAndroid);
|
|
538
|
+
const iosIsHTML = isHTMLEditorIos
|
|
539
|
+
|| ((iosType === INAPP_MEDIA_TYPES.HTML || iosStyle === BIG_HTML) && !isBEEeditorIos && !isBeeFreeIos);
|
|
540
|
+
|
|
541
|
+
if (androidIsHTML || iosIsHTML) return INAPP_EDITOR_TYPES.HTML_EDITOR;
|
|
542
|
+
return INAPP_EDITOR_TYPES.DRAG_DROP_EDITOR;
|
|
543
|
+
}, [defaultData, isFullMode, editData?.templateDetails, templateData]);
|
|
526
544
|
|
|
527
545
|
// Separate effect for handling editor type from wrapper in create mode
|
|
528
546
|
useEffect(() => {
|
|
@@ -1334,7 +1352,6 @@ export const InApp = (props) => {
|
|
|
1334
1352
|
)}
|
|
1335
1353
|
{shouldUseHTMLEditor ? (
|
|
1336
1354
|
<HTMLEditor
|
|
1337
|
-
ref={htmlEditorRef}
|
|
1338
1355
|
key={`inapp-html-editor-v${htmlEditorContentVersion}`}
|
|
1339
1356
|
variant={HTML_EDITOR_VARIANTS.INAPP}
|
|
1340
1357
|
layoutType={templateLayoutType}
|