Skip to content

Commit 80cd042

Browse files
committed
Bump v0.14.50
1 parent 01c07f3 commit 80cd042

File tree

5 files changed

+121
-32
lines changed

5 files changed

+121
-32
lines changed

dist/grapes.js

Lines changed: 114 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31121,6 +31121,8 @@ module.exports = {
3112131121
"use strict";
3112231122

3112331123

31124+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
31125+
3112431126
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /**
3112531127
* With this module is possible to manage components inside the canvas. You can customize the initial state of the module from the editor initialization, by passing the following [Configuration Object](https://github.com/artf/grapesjs/blob/master/src/dom_components/config/config.js)
3112631128
* ```js
@@ -31143,6 +31145,9 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
3114331145
* * [clear](#clear)
3114431146
* * [load](#load)
3114531147
* * [store](#store)
31148+
* * [addType](#addtype)
31149+
* * [getType](#gettype)
31150+
* * [getTypes](#gettypes)
3114631151
* * [render](#render)
3114731152
*
3114831153
* @module DomComponents
@@ -31637,27 +31642,60 @@ module.exports = function () {
3163731642

3163831643

3163931644
/**
31640-
* Add new component type
31641-
* @param {string} type
31642-
* @param {Object} methods
31643-
* @private
31645+
* Add new component type.
31646+
* Read more about this in [Define New Component](https://grapesjs.com/docs/modules/Components.html#define-new-component)
31647+
* @param {string} type Component ID
31648+
* @param {Object} methods Component methods
31649+
* @return {this}
3164431650
*/
3164531651
addType: function addType(type, methods) {
31652+
var _methods$model = methods.model,
31653+
model = _methods$model === undefined ? {} : _methods$model,
31654+
_methods$view = methods.view,
31655+
view = _methods$view === undefined ? {} : _methods$view,
31656+
isComponent = methods.isComponent,
31657+
extend = methods.extend,
31658+
extendView = methods.extendView;
31659+
3164631660
var compType = this.getType(type);
31661+
var extendType = this.getType(extend);
31662+
var extendViewType = this.getType(extendView);
31663+
var typeToExtend = extendType ? extendType : compType ? compType : this.getType('default');
31664+
var modelToExt = typeToExtend.model;
31665+
var viewToExt = extendViewType ? extendViewType.view : typeToExtend.view;
31666+
31667+
// If the model/view is a simple object I need to extend it
31668+
if ((typeof model === 'undefined' ? 'undefined' : _typeof(model)) === 'object') {
31669+
methods.model = modelToExt.extend(_extends({}, model, {
31670+
defaults: _extends({}, modelToExt.prototype.defaults, model.defaults || {})
31671+
}), {
31672+
isComponent: compType && !extendType && !isComponent ? modelToExt.isComponent : isComponent || function () {
31673+
return 0;
31674+
}
31675+
});
31676+
}
31677+
31678+
if ((typeof view === 'undefined' ? 'undefined' : _typeof(view)) === 'object') {
31679+
methods.view = viewToExt.extend(_extends({}, view));
31680+
}
31681+
3164731682
if (compType) {
3164831683
compType.model = methods.model;
3164931684
compType.view = methods.view;
3165031685
} else {
3165131686
methods.id = type;
3165231687
componentTypes.unshift(methods);
3165331688
}
31689+
31690+
return this;
3165431691
},
3165531692

3165631693

3165731694
/**
31658-
* Get component type
31659-
* @param {string} type
31660-
* @private
31695+
* Get component type.
31696+
* Read more about this in [Define New Component](https://grapesjs.com/docs/modules/Components.html#define-new-component)
31697+
* @param {string} type Component ID
31698+
* @return {Object} Component type defintion, eg. `{ model: ..., view: ... }`
3166131699
*/
3166231700
getType: function getType(type) {
3166331701
var df = componentTypes;
@@ -31670,6 +31708,15 @@ module.exports = function () {
3167031708
}
3167131709
return;
3167231710
},
31711+
31712+
31713+
/**
31714+
* Return the array of all types
31715+
* @return {Array}
31716+
*/
31717+
getTypes: function getTypes() {
31718+
return componentTypes;
31719+
},
3167331720
selectAdd: function selectAdd(component) {
3167431721
var _this3 = this;
3167531722

@@ -31909,7 +31956,7 @@ var Component = Backbone.Model.extend(_Styleable2.default).extend({
3190931956
this.em = em;
3191031957
this.config = opt.config || {};
3191131958
this.ccid = Component.createId(this);
31912-
this.set('attributes', this.get('attributes') || {});
31959+
this.set('attributes', _extends({}, this.defaults.attributes || {}, this.get('attributes') || {}));
3191331960
this.initClasses();
3191431961
this.initTraits();
3191531962
this.initComponents();
@@ -31930,8 +31977,11 @@ var Component = Backbone.Model.extend(_Styleable2.default).extend({
3193031977
return _this.emitUpdate.apply(_this, [name].concat(args));
3193131978
});
3193231979
});
31933-
this.init();
31934-
em && em.trigger('component:create', this);
31980+
31981+
if (!opt.temporary) {
31982+
this.init();
31983+
em && em.trigger('component:create', this);
31984+
}
3193531985
},
3193631986

3193731987

@@ -32514,7 +32564,9 @@ var Component = Backbone.Model.extend(_Styleable2.default).extend({
3251432564
}
3251532565

3251632566
var cloned = new this.constructor(attr, opts);
32517-
em && em.trigger('component:clone', cloned);
32567+
var event = 'component:clone';
32568+
em && em.trigger(event, cloned);
32569+
this.trigger(event, cloned);
3251832570

3251932571
return cloned;
3252032572
},
@@ -32761,7 +32813,7 @@ var Component = Backbone.Model.extend(_Styleable2.default).extend({
3276132813
args[_key3 - 1] = arguments[_key3];
3276232814
}
3276332815

32764-
this.updated.apply(this, [property, property && this.get(property), property && this.previous(property)].concat(_toConsumableArray(args)));
32816+
property && this.updated.apply(this, [property, property && this.get(property), property && this.previous(property)].concat(_toConsumableArray(args)));
3276532817
this.trigger.apply(this, [event].concat(_toConsumableArray(args)));
3276632818
em && em.trigger.apply(em, [event, this].concat(_toConsumableArray(args)));
3276732819
},
@@ -34253,7 +34305,6 @@ module.exports = __webpack_require__(/*! ./ComponentLinkView */ "./src/dom_compo
3425334305
"use strict";
3425434306

3425534307

34256-
var Backbone = __webpack_require__(/*! backbone */ "./node_modules/backbone/backbone.js");
3425734308
var ComponentView = __webpack_require__(/*! ./ComponentTextView */ "./src/dom_components/view/ComponentTextView.js");
3425834309

3425934310
module.exports = ComponentView.extend({
@@ -34852,7 +34903,9 @@ module.exports = _backbone2.default.View.extend({
3485234903
var model = this.model;
3485334904
var config = opt.config || {};
3485434905
var em = config.em;
34906+
var modelOpt = model.opt || {};
3485534907
this.opts = opt;
34908+
this.modelOpt = modelOpt;
3485634909
this.config = config;
3485734910
this.em = em || '';
3485834911
this.pfx = config.stylePrefix || '';
@@ -34873,7 +34926,7 @@ module.exports = _backbone2.default.View.extend({
3487334926
model.view = this;
3487434927
this.initClasses();
3487534928
this.initComponents({ avoidRender: 1 });
34876-
this.init();
34929+
!modelOpt.temporary && this.init();
3487734930
},
3487834931

3487934932

@@ -35080,14 +35133,32 @@ module.exports = _backbone2.default.View.extend({
3508035133
* @private
3508135134
* */
3508235135
updateAttributes: function updateAttributes() {
35083-
var model = this.model;
35136+
var attrs = [];
35137+
var model = this.model,
35138+
$el = this.$el,
35139+
el = this.el;
35140+
3508435141
var defaultAttr = { 'data-gjs-type': model.get('type') || 'default' };
3508535142

3508635143
if (model.get('highlightable')) {
3508735144
defaultAttr['data-highlightable'] = 1;
3508835145
}
3508935146

35090-
this.$el.attr(_extends({}, defaultAttr, model.getAttributes()));
35147+
// Remove all current attributes
35148+
(0, _underscore.each)(el.attributes, function (attr) {
35149+
return attrs.push(attr.nodeName);
35150+
});
35151+
attrs.forEach(function (attr) {
35152+
return $el.removeAttr(attr);
35153+
});
35154+
var attr = _extends({}, defaultAttr, model.getAttributes());
35155+
35156+
// Remove all `false` attributes
35157+
(0, _underscore.keys)(attr).forEach(function (key) {
35158+
return attr[key] === false && delete attr[key];
35159+
});
35160+
35161+
$el.attr(attr);
3509135162
this.updateStyle();
3509235163
},
3509335164

@@ -35200,10 +35271,14 @@ module.exports = _backbone2.default.View.extend({
3520035271
},
3520135272
postRender: function postRender() {
3520235273
var em = this.em,
35203-
model = this.model;
35274+
model = this.model,
35275+
modelOpt = this.modelOpt;
3520435276

35205-
this.onRender();
35206-
em && em.trigger('component:mount', model);
35277+
35278+
if (!modelOpt.temporary) {
35279+
this.onRender();
35280+
em && em.trigger('component:mount', model);
35281+
}
3520735282
},
3520835283
onRender: function onRender() {}
3520935284
});
@@ -35240,15 +35315,16 @@ module.exports = _backbone2.default.View.extend({
3524035315
removeChildren: function removeChildren(removed) {
3524135316
var em = this.config.em;
3524235317
var view = removed.view;
35318+
var temp = removed.opt.temporary;
3524335319
if (!view) return;
3524435320
view.remove.apply(view);
3524535321
var children = view.childrenView;
3524635322
children && children.stopListening();
3524735323
removed.components().forEach(this.removeChildren.bind(this));
35248-
removed.removed();
35324+
!temp && removed.removed();
3524935325
if (em) {
3525035326
removed.get('style-signature') && em.get('Commands').run('core:component-style-clear', { target: removed });
35251-
em.trigger('component:remove', removed);
35327+
!temp && em.trigger('component:remove', removed);
3525235328
}
3525335329
},
3525435330

@@ -38247,7 +38323,7 @@ module.exports = function () {
3824738323
plugins: plugins,
3824838324

3824938325
// Will be replaced on build
38250-
version: '0.14.49',
38326+
version: '0.14.50',
3825138327

3825238328
/**
3825338329
* Initialize the editor with passed options
@@ -40799,6 +40875,7 @@ module.exports = function () {
4079940875
conf.Parser = this;
4080040876
pHtml = new parserHtml(conf);
4080140877
pCss = new parserCss(conf);
40878+
this.em = conf.em;
4080240879
return this;
4080340880
},
4080440881

@@ -40809,7 +40886,10 @@ module.exports = function () {
4080940886
* @return {Object}
4081040887
*/
4081140888
parseHtml: function parseHtml(str) {
40812-
pHtml.compTypes = this.compTypes;
40889+
var em = this.em,
40890+
compTypes = this.compTypes;
40891+
40892+
pHtml.compTypes = em ? em.get('DomComponents').getTypes() : compTypes;
4081340893
return pHtml.parse(str, pCss);
4081440894
},
4081540895

@@ -41164,6 +41244,8 @@ module.exports = function () {
4116441244
"use strict";
4116541245

4116641246

41247+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
41248+
4116741249
module.exports = function (config) {
4116841250
var TEXT_NODE = 'span';
4116941251
var c = config;
@@ -41245,8 +41327,15 @@ module.exports = function (config) {
4124541327
// Iterate over all available Component Types and
4124641328
// the first with a valid result will be that component
4124741329
for (var it = 0; it < ct.length; it++) {
41248-
obj = ct[it].model.isComponent(node);
41249-
if (obj) break;
41330+
var compType = ct[it];
41331+
obj = compType.model.isComponent(node);
41332+
41333+
if (obj) {
41334+
if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object') {
41335+
obj = { type: compType.id };
41336+
}
41337+
break;
41338+
}
4125041339
}
4125141340

4125241341
model = obj;

dist/grapes.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/grapes.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "grapesjs",
33
"description": "Free and Open Source Web Builder Framework",
4-
"version": "0.14.49",
4+
"version": "0.14.50",
55
"author": "Artur Arseniev",
66
"license": "BSD-3-Clause",
77
"homepage": "http://grapesjs.com",

0 commit comments

Comments
 (0)