Browse Source

Append external styles inside head instead of body. Closes #1473

pull/1518/head
Artur Arseniev 8 years ago
parent
commit
0056180a1e
  1. 29
      src/canvas/view/CanvasView.js

29
src/canvas/view/CanvasView.js

@ -80,19 +80,20 @@ module.exports = Backbone.View.extend({
* @private * @private
*/ */
renderBody() { renderBody() {
var wrap = this.model.get('frame').get('wrapper'); const { config, model } = this;
var em = this.config.em; const wrap = this.model.get('frame').get('wrapper');
const em = config.em;
if (wrap) { if (wrap) {
var ppfx = this.ppfx; const Canvas = em.get('Canvas');
//var body = this.frame.$el.contents().find('body'); const ppfx = this.ppfx;
var body = $(this.frame.el.contentWindow.document.body); const body = $(Canvas.getBody());
var cssc = em.get('CssComposer'); const head = $(Canvas.getDocument().head);
var conf = em.get('Config'); const cssc = em.get('CssComposer');
var confCanvas = this.config; const conf = em.get('Config');
var protCss = conf.protectedCss; let externalStyles = '';
var externalStyles = '';
config.styles.forEach(style => {
confCanvas.styles.forEach(style => {
externalStyles += `<link rel="stylesheet" href="${style}"/>`; externalStyles += `<link rel="stylesheet" href="${style}"/>`;
}); });
@ -155,11 +156,11 @@ module.exports = Backbone.View.extend({
} }
${conf.canvasCss || ''} ${conf.canvasCss || ''}
${protCss || ''} ${conf.protectedCss || ''}
`; `;
if (externalStyles) { if (externalStyles) {
body.append(externalStyles); head.append(externalStyles);
} }
body.append('<style>' + frameCss + '</style>'); body.append('<style>' + frameCss + '</style>');

Loading…
Cancel
Save