forked from GrapesJS/grapesjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed image 'ghosts' on drag - Fixed unit select inside composite properties - Added new way to manage default components
- Loading branch information
Showing
30 changed files
with
638 additions
and
385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,50 @@ | ||
define(['backbone'], | ||
define(['backbone'], | ||
function (Backbone) { | ||
/** | ||
* @class HtmlGenerator | ||
* */ | ||
return Backbone.Model.extend({ | ||
|
||
/** @inheritdoc */ | ||
getId : function(){ | ||
return 'html'; | ||
getId : function(){ | ||
return 'html'; | ||
}, | ||
|
||
/** @inheritdoc */ | ||
build: function(model){ | ||
var coll = model.get('components') || model, | ||
code = ''; | ||
|
||
coll.each(function(m){ | ||
var tag = m.get('tagName'), // Tag name | ||
attr = '', // Attributes string | ||
cln = m.get('components'); // Children | ||
|
||
var tag = m.get('tagName'), // Tag name | ||
sTag = 0, // Single tag | ||
attr = '', // Attributes string | ||
cln = m.get('components'); // Children | ||
|
||
_.each(m.get('attributes'),function(value, prop){ | ||
if(prop == 'onmousedown') | ||
return; | ||
attr += value && prop!='style' ? ' ' + prop + '="' + value + '" ' : ''; | ||
}); | ||
|
||
code += '<'+tag+' id="'+m.cid+'"' + attr + '>' + m.get('content'); | ||
|
||
|
||
if(m.get('type') == 'image'){ | ||
tag = 'img'; | ||
sTag = 1; | ||
attr += 'src="' + m.get('src') + '"'; | ||
} | ||
|
||
code += '<'+tag+' id="'+m.cid+'"' + attr + (sTag ? '/' : '') + '>' + m.get('content'); | ||
|
||
if(cln.length) | ||
code += this.build(cln); | ||
|
||
code += '</'+tag+'>'; | ||
|
||
if(!sTag) | ||
code += '</'+tag+'>'; | ||
|
||
}, this); | ||
|
||
return code; | ||
}, | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,40 @@ | ||
define(['backbone', './InsertCustom'], | ||
function(Backbone, InsertCustom) { | ||
/** | ||
/** | ||
* @class ImageComponent | ||
* */ | ||
return _.extend({}, InsertCustom, { | ||
|
||
/** | ||
* Trigger before insert | ||
* @param {Object} object | ||
* | ||
* | ||
* */ | ||
beforeInsert: function(object){ | ||
object.type = 'image'; | ||
object.style = {}; | ||
object.attributes = {}; | ||
if (!this.nearToFloat()) { | ||
object.style.display = 'block'; | ||
} | ||
// This allow to avoid 'ghosts' on drag | ||
object.attributes.onmousedown = 'return false'; | ||
if (this.config.firstCentered && (this.$wp.get(0) == this.posTargetEl.get(0)) ) { | ||
object.style.margin = '0 auto'; | ||
} | ||
}, | ||
|
||
/** | ||
* Trigger after insert | ||
* @param {Object} model Model created after insert | ||
* | ||
* | ||
* */ | ||
afterInsert: function(model){ | ||
model.trigger('dblclick'); | ||
if(this.sender) | ||
this.sender.set('active', false); | ||
}, | ||
|
||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.