Skip to content

Commit bcf20c0

Browse files
authored
Merge pull request #24 from InteractionDesignFoundation/22-fix-loading-stored-design
Fix loading stored design
2 parents d7b1421 + d47d5a7 commit bcf20c0

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

dist/js/field.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"/js/field.js": "/js/field.js?id=a599868661464380f9b5d69375fa963f"
2+
"/js/field.js": "/js/field.js?id=eccb11b423a3c19387a78cd92c00d6db"
33
}

resources/js/components/DetailField.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ export default {
1313
props: ['index', 'resource', 'resourceName', 'resourceId', 'field'],
1414
1515
beforeCreate() {
16-
const uniqueId = Math.random().toString(36).slice(-5);
17-
this.iframeId = `previewUnlayerHtmlIframe-${uniqueId}`;
16+
this.iframeId = `${this.field.uniqueKey}-iframe`;
1817
},
1918
2019
mounted() {
2120
let iframe = document.getElementById(this.iframeId);
22-
this.setIframeContent(iframe, this.field.html);
21+
this.setIframeContent(iframe, this.field.html || 'HTML is not set for preview, use <code>Unlayer::html()</code>');
2322
this.resizeIFrameToFitContent(iframe)
2423
},
2524

resources/js/components/FormField.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
/** Register listeners, load initial template, etc. */
5858
editorLoaded() {
5959
if (this.field.value !== null) {
60-
this.$refs.editor.loadDesign(this.field.value);
60+
this.$refs.editor.loadDesign(this.unProxy(this.field.value));
6161
}
6262
6363
/** @see https://docs.unlayer.com/docs/events */
@@ -69,7 +69,15 @@
6969
},
7070
7171
/**
72-
* @param {Array} pluginsUrls
72+
* @param {Proxy<Object>} proxyInstance
73+
* @return {Object}
74+
*/
75+
unProxy(proxyInstance) {
76+
return JSON.parse(JSON.stringify(proxyInstance));
77+
},
78+
79+
/**
80+
* @param {Array<string>} pluginsUrls
7381
*/
7482
loadPlugins(pluginsUrls) {
7583
if (window.unlayer.plugins === undefined) {

0 commit comments

Comments
 (0)