Skip to content

Commit

Permalink
Merge pull request #24 from InteractionDesignFoundation/22-fix-loadin…
Browse files Browse the repository at this point in the history
…g-stored-design

Fix loading stored design
  • Loading branch information
lptn authored Nov 9, 2022
2 parents d7b1421 + d47d5a7 commit bcf20c0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"/js/field.js": "/js/field.js?id=a599868661464380f9b5d69375fa963f"
"/js/field.js": "/js/field.js?id=eccb11b423a3c19387a78cd92c00d6db"
}
5 changes: 2 additions & 3 deletions resources/js/components/DetailField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ export default {
props: ['index', 'resource', 'resourceName', 'resourceId', 'field'],
beforeCreate() {
const uniqueId = Math.random().toString(36).slice(-5);
this.iframeId = `previewUnlayerHtmlIframe-${uniqueId}`;
this.iframeId = `${this.field.uniqueKey}-iframe`;
},
mounted() {
let iframe = document.getElementById(this.iframeId);
this.setIframeContent(iframe, this.field.html);
this.setIframeContent(iframe, this.field.html || 'HTML is not set for preview, use <code>Unlayer::html()</code>');
this.resizeIFrameToFitContent(iframe)
},
Expand Down
12 changes: 10 additions & 2 deletions resources/js/components/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
/** Register listeners, load initial template, etc. */
editorLoaded() {
if (this.field.value !== null) {
this.$refs.editor.loadDesign(this.field.value);
this.$refs.editor.loadDesign(this.unProxy(this.field.value));
}
/** @see https://docs.unlayer.com/docs/events */
Expand All @@ -69,7 +69,15 @@
},
/**
* @param {Array} pluginsUrls
* @param {Proxy<Object>} proxyInstance
* @return {Object}
*/
unProxy(proxyInstance) {
return JSON.parse(JSON.stringify(proxyInstance));
},
/**
* @param {Array<string>} pluginsUrls
*/
loadPlugins(pluginsUrls) {
if (window.unlayer.plugins === undefined) {
Expand Down

0 comments on commit bcf20c0

Please sign in to comment.