755febc4 by acetousk

Implement variable injection for global variables in the mjml editor for loading…

… and saving, handle parsing regex in groovy, ftl, and mjml, find the correct variables to update, replace non updated variables with a ftl version of the variables that won't error but return the variable expression for saving, and handle other problems
1 parent 768cad19
...@@ -181,11 +181,13 @@ along with this software (see the LICENSE.md file). If not, see ...@@ -181,11 +181,13 @@ along with this software (see the LICENSE.md file). If not, see
181 // console.log('response ', response) 181 // console.log('response ', response)
182 window.htmlLocation = response.htmlLocation; 182 window.htmlLocation = response.htmlLocation;
183 window.grapesLocation = response.grapesLocation; 183 window.grapesLocation = response.grapesLocation;
184 const url = new URL(window.location.href) 184 // const url = new URL(window.location.href)
185 url.searchParams.set('htmlLocation', response.htmlLocation); 185 // url.searchParams.set('htmlLocation', response.htmlLocation);
186 url.searchParams.set('grapesLocation', response.grapesLocation); 186 // url.searchParams.set('grapesLocation', response.grapesLocation);
187 window.history.pushState({}, '', url) 187 // window.history.pushState({}, '', url)
188 188
189 window.moquiVars = response.moquiVars;
190 // console.log('init window.moquiVars ', window.moquiVars)
189 const projectData = JSON.parse(response.data); 191 const projectData = JSON.parse(response.data);
190 // console.log('window.projectData ', window.projectData) 192 // console.log('window.projectData ', window.projectData)
191 193
...@@ -215,18 +217,20 @@ along with this software (see the LICENSE.md file). If not, see ...@@ -215,18 +217,20 @@ along with this software (see the LICENSE.md file). If not, see
215 // we have to properly update the body before the store and extract the 217 // we have to properly update the body before the store and extract the
216 // project data from the response result. 218 // project data from the response result.
217 onStore: data => { 219 onStore: data => {
218 return { id: window.grapesLocation, data, html:window.editor.runCommand('mjml-code-to-html')?.html } 220 return { id: window.grapesLocation, data, moquiVars:window.moquiVars, html:window.editor.runCommand('mjml-code-to-html')?.html }
219 }, 221 },
220 onLoad: result => { 222 onLoad: result => {
221 if (result.resourceId !== null) { 223 if (result.resourceId !== null) {
222 const url = new URL(window.location.href) 224 const url = new URL(window.location.href)
223 url.searchParams.set('grapesLocation', result.grapesLocation); 225 url.searchParams.set('grapesLocation', result.grapesLocation);
224 url.searchParams.set('htmlLocation', result.htmlLocation); 226 // url.searchParams.set('htmlLocation', result.htmlLocation);
225 url.searchParams.set('emailTemplateId', result.emailTemplateId); 227 // url.searchParams.set('emailTemplateId', result.emailTemplateId);
226 window.history.pushState({}, '', url) 228 window.history.pushState({}, '', url)
227 window.grapesLocation = result.grapesLocation; 229 window.grapesLocation = result.grapesLocation;
228 window.htmlLocation = result.htmlLocation; 230 window.htmlLocation = result.htmlLocation;
229 window.emailTemplateId = result.emailTemplateId; 231 window.emailTemplateId = result.emailTemplateId;
232 window.moquiVars = result.moquiVars;
233 // console.log('onLoad window.moquiVars ', window.moquiVars)
230 } 234 }
231 // console.log('onLoad ', result) 235 // console.log('onLoad ', result)
232 return result.data 236 return result.data
......