|
1 | 1 | <template> |
2 | | - <PanelItem :field="field"> |
3 | | - <template slot="value"> |
| 2 | + <PanelItem :index="index" :field="field"> |
| 3 | + <template #value> |
4 | 4 | <div class="overflow-hidden"> |
5 | 5 | <iframe :id="iframeId" sandbox="allow-scripts allow-same-origin" importance="low" width="100%"></iframe> |
6 | 6 | </div> |
|
9 | 9 | </template> |
10 | 10 |
|
11 | 11 | <script> |
12 | | - export default { |
13 | | - props: ['resource', 'resourceName', 'resourceId', 'field'], |
| 12 | +export default { |
| 13 | + props: ['index', 'resource', 'resourceName', 'resourceId', 'field'], |
14 | 14 |
|
15 | | - beforeCreate() { |
16 | | - const uniqueId = Math.random().toString(36).slice(-5); |
17 | | - this.iframeId = `previewUnlayerHtmlIframe-${uniqueId}`; |
18 | | - }, |
| 15 | + beforeCreate() { |
| 16 | + const uniqueId = Math.random().toString(36).slice(-5); |
| 17 | + this.iframeId = `previewUnlayerHtmlIframe-${uniqueId}`; |
| 18 | + }, |
19 | 19 |
|
20 | | - mounted() { |
21 | | - let iframe = document.getElementById(this.iframeId); |
22 | | - this.setIframeContent(iframe, this.field.html); |
23 | | - this.resizeIFrameToFitContent(iframe) |
24 | | - }, |
| 20 | + mounted() { |
| 21 | + let iframe = document.getElementById(this.iframeId); |
| 22 | + this.setIframeContent(iframe, this.field.html); |
| 23 | + this.resizeIFrameToFitContent(iframe) |
| 24 | + }, |
25 | 25 |
|
26 | | - methods: { |
27 | | - /** |
28 | | - * @param {HTMLIFrameElement} iframe |
29 | | - * @param {string} htmlContent |
30 | | - */ |
31 | | - setIframeContent: function(iframe, htmlContent) { |
32 | | - const container = document.createElement('div'); |
33 | | - container.innerHTML = htmlContent; |
34 | | - iframe.contentWindow.document.body.appendChild(container); |
35 | | - }, |
36 | | - /** |
37 | | - * @param {HTMLIFrameElement} iframe |
38 | | - */ |
39 | | - resizeIFrameToFitContent: function (iframe) { |
40 | | - iframe.height = iframe.contentWindow.document.body.scrollHeight; |
41 | | - } |
| 26 | + methods: { |
| 27 | + /** |
| 28 | + * @param {HTMLIFrameElement} iframe |
| 29 | + * @param {string} htmlContent |
| 30 | + */ |
| 31 | + setIframeContent: function (iframe, htmlContent) { |
| 32 | + const container = document.createElement('div'); |
| 33 | + container.innerHTML = htmlContent; |
| 34 | + iframe.contentWindow.document.body.appendChild(container); |
42 | 35 | }, |
43 | | - } |
| 36 | +
|
| 37 | + /** |
| 38 | + * @param {HTMLIFrameElement} iframe |
| 39 | + */ |
| 40 | + resizeIFrameToFitContent: function (iframe) { |
| 41 | + iframe.height = iframe.contentWindow.document.body.scrollHeight; |
| 42 | + } |
| 43 | + }, |
| 44 | +} |
44 | 45 | </script> |
0 commit comments