Commit 936e92d5 authored by Alex Hoyau's avatar Alex Hoyau

remove current page style when saving

parent 6cbb8673
......@@ -344,6 +344,7 @@ silex.model.File.prototype.getHtml = function() {
this.model.property.updateStylesInDom(/** @type {Document} */ (cleanFile));
this.model.property.saveProperties(this.contentDocument_);
// cleanup
this.model.head.removeCurrentPageStyleTag(/** @type {Document} */ (cleanFile).head);
this.model.head.removeTempTags(/** @type {Document} */ (cleanFile).head);
this.model.body.removeEditableClasses(/** @type {!Element} */ (cleanFile));
silex.utils.Style.removeInternalClasses(/** @type {!Element} */ (cleanFile), false, true);
......@@ -409,6 +410,7 @@ silex.model.File.prototype.getHtmlGenerator = function* () {
styleTag.innerHTML = updatedStyles;
yield;
// cleanup
this.model.head.removeCurrentPageStyleTag(/** @type {Document} */ (cleanFile).head);
this.model.head.removeTempTags(/** @type {Document} */ (cleanFile).head);
yield;
this.model.body.removeEditableClasses(/** @type {!Element} */ (cleanFile));
......
......@@ -46,6 +46,13 @@ silex.model.Head = function(model, view) {
};
/**
* id of the style element which holds current page style
* e.g. <style id="current-page-style">.page-page-1 {display: inherit;}</style>
*/
silex.model.Head.SILEX_CURRENT_PAGE_CSS_CLASS = 'current-page-style';
/**
* id of the style element which holds silex editable css styles
*/
......@@ -661,6 +668,20 @@ silex.model.Head.prototype.getHeadElement = function() {
};
/**
* @param {?Element=} opt_headElement
*
*/
silex.model.Head.prototype.removeCurrentPageStyleTag = function(opt_headElement) {
if (!opt_headElement) {
opt_headElement = this.getHeadElement();
}
const tag = opt_headElement.querySelector('#' + silex.model.Head.SILEX_CURRENT_PAGE_CSS_CLASS);
goog.dom.removeNode(tag);
}
/**
* load temp tags (js and css) to be removed later
* @param {Array.<Element>|Element} tags the tag(s) to add
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment