From 0056180a1ecc7a14418eeb7ca11df90567cdab28 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Tue, 2 Oct 2018 23:50:00 +0200 Subject: [PATCH] Append external styles inside head instead of body. Closes #1473 --- src/canvas/view/CanvasView.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/canvas/view/CanvasView.js b/src/canvas/view/CanvasView.js index 7ade2b587..90423e647 100644 --- a/src/canvas/view/CanvasView.js +++ b/src/canvas/view/CanvasView.js @@ -80,19 +80,20 @@ module.exports = Backbone.View.extend({ * @private */ renderBody() { - var wrap = this.model.get('frame').get('wrapper'); - var em = this.config.em; + const { config, model } = this; + const wrap = this.model.get('frame').get('wrapper'); + const em = config.em; + if (wrap) { - var ppfx = this.ppfx; - //var body = this.frame.$el.contents().find('body'); - var body = $(this.frame.el.contentWindow.document.body); - var cssc = em.get('CssComposer'); - var conf = em.get('Config'); - var confCanvas = this.config; - var protCss = conf.protectedCss; - var externalStyles = ''; - - confCanvas.styles.forEach(style => { + const Canvas = em.get('Canvas'); + const ppfx = this.ppfx; + const body = $(Canvas.getBody()); + const head = $(Canvas.getDocument().head); + const cssc = em.get('CssComposer'); + const conf = em.get('Config'); + let externalStyles = ''; + + config.styles.forEach(style => { externalStyles += ``; }); @@ -155,11 +156,11 @@ module.exports = Backbone.View.extend({ } ${conf.canvasCss || ''} - ${protCss || ''} + ${conf.protectedCss || ''} `; if (externalStyles) { - body.append(externalStyles); + head.append(externalStyles); } body.append('');