Browse Source

Adjust export template command

pull/261/head
Artur Arseniev 9 years ago
parent
commit
1dde7a3450
  1. 5
      src/code_manager/model/CssGenerator.js
  2. 28
      src/commands/view/ExportTemplate.js
  3. 4
      src/editor/model/Editor.js

5
src/code_manager/model/CssGenerator.js

@ -58,13 +58,14 @@ module.exports = Backbone.Model.extend({
}, },
/** @inheritdoc */ /** @inheritdoc */
build(model, cssc) { build(model, opts = {}) {
const cssc = opts.cssc;
this.compCls = []; this.compCls = [];
var code = this.buildFromModel(model); var code = this.buildFromModel(model);
code += this.buildFromComp(model); code += this.buildFromComp(model);
var compCls = this.compCls; var compCls = this.compCls;
if(cssc){ if (cssc) {
var rules = cssc.getAll(); var rules = cssc.getAll();
var mediaRules = {}; var mediaRules = {};
rules.each(function(rule) { rules.each(function(rule) {

28
src/commands/view/ExportTemplate.js

@ -25,18 +25,18 @@ module.exports = {
if(!this.codeMirror) if(!this.codeMirror)
this.codeMirror = this.cm.getViewer('CodeMirror'); this.codeMirror = this.cm.getViewer('CodeMirror');
var $input = $('<textarea>'), var $input = $('<textarea>'),
editor = this.codeMirror.clone().set({ editor = this.codeMirror.clone().set({
label, label,
codeName, codeName,
theme, theme,
input : $input[0], input: $input[0],
}), }),
$editor = new this.cm.EditorView({ $editor = new this.cm.EditorView({
model : editor, model: editor,
config : this.cm.getConfig() config: this.cm.getConfig()
}).render().$el; }).render().$el;
editor.init( $input[0] ); editor.init( $input[0] );
@ -46,11 +46,11 @@ module.exports = {
enable() { enable() {
if(!this.$editors){ if(!this.$editors){
var oHtmlEd = this.buildEditor('htmlmixed', 'hopscotch', 'HTML'), var oHtmlEd = this.buildEditor('htmlmixed', 'hopscotch', 'HTML');
oCsslEd = this.buildEditor('css', 'hopscotch', 'CSS'); var oCsslEd = this.buildEditor('css', 'hopscotch', 'CSS');
this.htmlEditor = oHtmlEd.el; this.htmlEditor = oHtmlEd.el;
this.cssEditor = oCsslEd.el; this.cssEditor = oCsslEd.el;
this.$editors = $('<div>', {class: this.pfx + 'export-dl'}); this.$editors = $('<div>', {class: this.pfx + 'export-dl'});
this.$editors.append(oHtmlEd.$el).append(oCsslEd.$el); this.$editors.append(oHtmlEd.$el).append(oCsslEd.$el);
} }
@ -59,10 +59,10 @@ module.exports = {
this.modal.setContent(this.$editors); this.modal.setContent(this.$editors);
this.modal.open(); this.modal.open();
} }
const em = this.em;
var addCss = this.protCss || ''; var addCss = this.protCss || '';
//this.htmlEditor.setContent(this.cm.getCode(this.components, 'html', this.cssc)); this.htmlEditor.setContent(em.getHtml());
this.htmlEditor.setContent(this.em.getHtml()); this.cssEditor.setContent(em.getCss());
this.cssEditor.setContent(addCss + this.cm.getCode(this.wrapper, 'css', this.cssc));
if(this.sender) if(this.sender)
this.sender.set('active',false); this.sender.set('active',false);

4
src/editor/model/Editor.js

@ -428,7 +428,9 @@ module.exports = Backbone.Model.extend({
var wrp = this.get('DomComponents').getComponent(); var wrp = this.get('DomComponents').getComponent();
var protCss = this.config.protectedCss; var protCss = this.config.protectedCss;
return protCss + this.get('CodeManager').getCode(wrp, 'css', cssc); return protCss + this.get('CodeManager').getCode(wrp, 'css', {
cssc
});
}, },
/** /**

Loading…
Cancel
Save