@contentgrowth/content-emailing 0.8.3 → 0.8.4
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/dist/frontend/index.cjs +7 -2
- package/dist/frontend/index.cjs.map +1 -1
- package/dist/frontend/index.js +10 -5
- package/dist/frontend/index.js.map +1 -1
- package/dist/index.cjs +7 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2031,6 +2031,11 @@ var TemplateTester = ({
|
|
|
2031
2031
|
const [detectedVariables, setDetectedVariables] = (0, import_react2.useState)([]);
|
|
2032
2032
|
const [error, setError] = (0, import_react2.useState)(null);
|
|
2033
2033
|
const [success, setSuccess] = (0, import_react2.useState)(null);
|
|
2034
|
+
const defaultValuesRef = (0, import_react2.useRef)(defaultValues);
|
|
2035
|
+
const defaultValuesJson = JSON.stringify(defaultValues);
|
|
2036
|
+
(0, import_react2.useEffect)(() => {
|
|
2037
|
+
defaultValuesRef.current = defaultValues;
|
|
2038
|
+
}, [defaultValuesJson]);
|
|
2034
2039
|
(0, import_react2.useEffect)(() => {
|
|
2035
2040
|
const regex = /\{\{(\w+)\}\}/g;
|
|
2036
2041
|
const subjectVars = Array.from(template.subject_template.matchAll(regex)).map((m) => m[1]);
|
|
@@ -2038,7 +2043,7 @@ var TemplateTester = ({
|
|
|
2038
2043
|
const uniqueVars = Array.from(/* @__PURE__ */ new Set([...subjectVars, ...bodyVars]));
|
|
2039
2044
|
setDetectedVariables(uniqueVars);
|
|
2040
2045
|
const initialValues = {};
|
|
2041
|
-
const defaults =
|
|
2046
|
+
const defaults = defaultValuesRef.current.variables || {};
|
|
2042
2047
|
uniqueVars.forEach((v) => {
|
|
2043
2048
|
if (defaults[v]) {
|
|
2044
2049
|
initialValues[v] = defaults[v];
|
|
@@ -2049,7 +2054,7 @@ var TemplateTester = ({
|
|
|
2049
2054
|
}
|
|
2050
2055
|
});
|
|
2051
2056
|
setVariables(initialValues);
|
|
2052
|
-
}, [template,
|
|
2057
|
+
}, [template.template_id, template.subject_template, template.body_markdown, defaultValuesJson]);
|
|
2053
2058
|
const handleSubmit = async (e) => {
|
|
2054
2059
|
e.preventDefault();
|
|
2055
2060
|
setError(null);
|