Open ghost opened 1 year ago
Here's the full content of my save
function which is called by the onClickSave
function referenced in my code above:
function save(template, data) {
// setSaving(true);
setReady(false);
const { emailInfo, editorInfo, specInfo } = data;
const email = { ...emailInfo };
const editor = { ...editorInfo };
const spec = { ...specInfo };
return new Promise((resolve, _reject) => {
window.StripoApi.getTemplate(function saveTemplate(
emailEditHtml,
emailEditCss,
width,
height,
) {
email.height = height;
email.width = width;
const minimizeCompiledEmail = true;
window.StripoApi.compileEmail(async function compileTemplate(
error,
emailHtml,
emailAmp,
// ampErrors,
) {
if (error) {
console.error("Error compiling email", error);
await alertAsync({
title: "Error",
text:
"There was an error saving the email. " +
"Please try again or contact support.",
});
// setSaving(false);
setReady(true);
resolve(false);
return;
}
let success = true;
await saveEmailEdit(template, {
email,
emailHtml,
emailAmp,
emailEditHtml,
emailEditCss,
editor,
spec,
})
.then(() => {
setChanged(false);
})
.catch(async error => {
console.error("Error saving email", error);
success = false;
await alertAsync({
title: "Error",
text:
"There was an error saving the email. " +
"Please try again or contact support.",
});
});
// console.log("Saved email", result);
// setSaving(false);
setReady(true);
resolve(success);
}, minimizeCompiledEmail);
});
});
}
Whenever my
onClickSave
function callswindow.StripoApi.getTemplate()
andwindow.StripoApi.compileEmail()
, the Stripo plugin removes the current CKEditor. This prevents the user from continuing to type after hitting theCtrl+S
hotkey.Here is my code to attempt a workaround of this, but it doesn't work: