From 98285f9136f3788baa59a240831f369ac02d7b5c Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Tue, 22 Jun 2021 00:40:29 +0200 Subject: [PATCH] Allow editing iframe content before load. Closes #3285 --- src/canvas/view/FrameView.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/canvas/view/FrameView.js b/src/canvas/view/FrameView.js index 79731c54f..d390031aa 100644 --- a/src/canvas/view/FrameView.js +++ b/src/canvas/view/FrameView.js @@ -256,7 +256,9 @@ export default Backbone.View.extend({ }, renderScripts() { - const { el } = this; + const { el, model, em } = this; + const evLoad = 'frame:load'; + const evOpts = { el, model, view: this }; const canvas = this.getCanvasModel(); const appendScript = scripts => { if (scripts.length > 0) { @@ -269,10 +271,14 @@ export default Backbone.View.extend({ el.contentDocument.head.appendChild(scriptEl); } else { this.renderBody(); + em && em.trigger(evLoad, evOpts); } }; - el.onload = () => appendScript([...canvas.get('scripts')]); + el.onload = () => { + em && em.trigger(`${evLoad}:before`, evOpts); + appendScript([...canvas.get('scripts')]); + }; }, renderStyles(opts = {}) {