@capillarytech/creatives-library 8.0.292-alpha.12 → 8.0.292-alpha.14
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
|
@@ -324,7 +324,7 @@ const HTMLEditor = forwardRef(({
|
|
|
324
324
|
: countIssuesBySeverity(validation.getAllIssues()),
|
|
325
325
|
})
|
|
326
326
|
,
|
|
327
|
-
}), [validation, currentContent, apiValidationErrors]);
|
|
327
|
+
}), [validation, currentContent, apiValidationErrors]);
|
|
328
328
|
|
|
329
329
|
// Use ref to store callback to avoid infinite loops (callback in deps would cause re-runs)
|
|
330
330
|
const onValidationChangeRef = useRef(onValidationChange);
|
|
@@ -832,5 +832,5 @@ HTMLEditor.defaultProps = {
|
|
|
832
832
|
apiValidationErrors: null, // API validation errors from validateLiquidTemplateContent
|
|
833
833
|
};
|
|
834
834
|
|
|
835
|
-
// Export with injectIntl - HTMLEditor
|
|
835
|
+
// Export with injectIntl - HTMLEditor uses forwardRef internally
|
|
836
836
|
export default injectIntl(HTMLEditor);
|
|
@@ -142,9 +142,13 @@ export const InApp = (props) => {
|
|
|
142
142
|
const [isHTMLTemplate, setIsHTMLTemplate] = useState(false);
|
|
143
143
|
// Version to force HTMLEditor remount on layout changes
|
|
144
144
|
const [htmlEditorContentVersion, setHtmlEditorContentVersion] = useState(0);
|
|
145
|
-
// Refs to store latest content
|
|
145
|
+
// Refs to store latest content (kept in sync in handleHtmlContentChange so Test and Preview reads fresh content in library mode)
|
|
146
146
|
const htmlContentAndroidRef = useRef(htmlContentAndroid);
|
|
147
147
|
const htmlContentIosRef = useRef(htmlContentIos);
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
htmlContentAndroidRef.current = htmlContentAndroid;
|
|
150
|
+
htmlContentIosRef.current = htmlContentIos;
|
|
151
|
+
}, [htmlContentAndroid, htmlContentIos]);
|
|
148
152
|
const [accountId, setAccountId] = useState("");
|
|
149
153
|
const [accessToken, setAccessToken] = useState("");
|
|
150
154
|
const [accountName, setAccountName] = useState("");
|
|
@@ -172,14 +176,15 @@ export const InApp = (props) => {
|
|
|
172
176
|
// TestAndPreviewSlidebox state
|
|
173
177
|
const [showTestAndPreviewSlidebox, setShowTestAndPreviewSlidebox] = useState(false);
|
|
174
178
|
|
|
175
|
-
// Get template content for TestAndPreviewSlidebox
|
|
176
|
-
//
|
|
177
|
-
// Transformation to payload structure happens in prepareTestMessagePayload
|
|
178
|
-
// Reference: Based on getPreviewSection() function (lines 490-530) which prepares content for TemplatePreview
|
|
179
|
+
// Get template content for TestAndPreviewSlidebox (same pattern as Mobile Push: read current content for preview)
|
|
180
|
+
// State is updated on every keystroke via onContentChange; refs are synced so we read fresh content in library mode too.
|
|
179
181
|
const getTemplateContent = useCallback(() => {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
182
|
+
const androidMsg = isHTMLTemplate
|
|
183
|
+
? (htmlContentAndroidRef.current ?? htmlContentAndroid ?? '')
|
|
184
|
+
: templateMessageAndroid;
|
|
185
|
+
const iosMsg = isHTMLTemplate
|
|
186
|
+
? (htmlContentIosRef.current ?? htmlContentIos ?? '')
|
|
187
|
+
: templateMessageIos;
|
|
183
188
|
|
|
184
189
|
// Prepare Android content
|
|
185
190
|
const androidMediaPreview = {};
|
|
@@ -1008,11 +1013,12 @@ export const InApp = (props) => {
|
|
|
1008
1013
|
);
|
|
1009
1014
|
};
|
|
1010
1015
|
|
|
1011
|
-
// Handle HTML content changes from HTMLEditor
|
|
1016
|
+
// Handle HTML content changes from HTMLEditor - update state and refs so Test and Preview has fresh content (full + library mode)
|
|
1012
1017
|
const handleHtmlContentChange = useCallback((deviceContent, changedDevice) => {
|
|
1013
1018
|
// When "keep content same" is on, useInAppContent passes full deviceContent with both
|
|
1014
1019
|
// android and ios set to the same value. We must update both states so preview shows
|
|
1015
1020
|
// the synced content for each device. Otherwise only update the device that changed.
|
|
1021
|
+
// Refs are updated synchronously so getTemplateContent() reads latest when opening the slidebox.
|
|
1016
1022
|
|
|
1017
1023
|
// Clear validation errors when content changes (similar to Bee Editor)
|
|
1018
1024
|
if (changedDevice) {
|
|
@@ -1035,33 +1041,36 @@ export const InApp = (props) => {
|
|
|
1035
1041
|
const isSyncUpdate = hasAndroid && hasIos;
|
|
1036
1042
|
|
|
1037
1043
|
if (isSyncUpdate) {
|
|
1038
|
-
// Sync mode: update both so preview shows same content for Android and iOS
|
|
1039
1044
|
if (hasAndroid) {
|
|
1040
|
-
|
|
1045
|
+
const v = deviceContent.android || '';
|
|
1046
|
+
htmlContentAndroidRef.current = v;
|
|
1047
|
+
setHtmlContentAndroid(v);
|
|
1041
1048
|
}
|
|
1042
1049
|
if (hasIos) {
|
|
1043
|
-
|
|
1050
|
+
const v = deviceContent.ios || '';
|
|
1051
|
+
htmlContentIosRef.current = v;
|
|
1052
|
+
setHtmlContentIos(v);
|
|
1044
1053
|
}
|
|
1045
1054
|
} else if (changedDevice) {
|
|
1046
|
-
// Only one device changed
|
|
1047
1055
|
if (changedDevice.toUpperCase() === ANDROID && hasAndroid) {
|
|
1048
|
-
|
|
1056
|
+
const v = deviceContent.android || '';
|
|
1057
|
+
htmlContentAndroidRef.current = v;
|
|
1058
|
+
setHtmlContentAndroid(v);
|
|
1049
1059
|
} else if (changedDevice.toUpperCase() === IOS_CAPITAL && hasIos) {
|
|
1050
|
-
|
|
1060
|
+
const v = deviceContent.ios || '';
|
|
1061
|
+
htmlContentIosRef.current = v;
|
|
1062
|
+
setHtmlContentIos(v);
|
|
1051
1063
|
}
|
|
1052
1064
|
} else {
|
|
1053
|
-
// Fallback: update both if changedDevice not provided
|
|
1054
1065
|
if (hasAndroid) {
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
});
|
|
1066
|
+
const newValue = deviceContent.android || '';
|
|
1067
|
+
htmlContentAndroidRef.current = newValue;
|
|
1068
|
+
setHtmlContentAndroid((prev) => (prev !== newValue ? newValue : prev));
|
|
1059
1069
|
}
|
|
1060
1070
|
if (hasIos) {
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
});
|
|
1071
|
+
const newValue = deviceContent.ios || '';
|
|
1072
|
+
htmlContentIosRef.current = newValue;
|
|
1073
|
+
setHtmlContentIos((prev) => (prev !== newValue ? newValue : prev));
|
|
1065
1074
|
}
|
|
1066
1075
|
}
|
|
1067
1076
|
}, [ANDROID, IOS_CAPITAL, setErrorMessage]);
|