Skip to content

Commit 18173b5

Browse files
committed
Bump v0.14.52
1 parent d8eb094 commit 18173b5

File tree

5 files changed

+182
-25
lines changed

5 files changed

+182
-25
lines changed

dist/grapes.js

Lines changed: 175 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26239,7 +26239,7 @@ module.exports = _backbone2.default.Model.extend({
2623926239
// If the component has scripts we need to expose his ID
2624026240
var attr = model.get('attributes');
2624126241
attr = (0, _underscore.extend)({}, attr, { id: id });
26242-
model.set('attributes', attr);
26242+
model.set('attributes', attr, { silent: 1 });
2624326243
var scrStr = model.getScriptString();
2624426244

2624526245
// If the script was updated, I'll put its code in a separate container
@@ -29129,7 +29129,9 @@ module.exports = {
2912929129
* @private
2913029130
*/
2913129131
initResize: function initResize(elem) {
29132-
var em = this.em;
29132+
var em = this.em,
29133+
canvas = this.canvas;
29134+
2913329135
var editor = em ? em.get('Editor') : '';
2913429136
var config = em ? em.get('Config') : '';
2913529137
var pfx = config.stylePrefix || '';
@@ -29223,7 +29225,10 @@ module.exports = {
2922329225
var style = modelToStyle.getStyle();
2922429226

2922529227
if (!onlyHeight) {
29226-
style[keyWidth] = autoWidth ? 'auto' : '' + rect.w + unitWidth;
29228+
var padding = 10;
29229+
var frameOffset = canvas.getCanvasView().getFrameOffset();
29230+
var width = rect.w < frameOffset.width - padding ? rect.w : frameOffset.width - padding;
29231+
style[keyWidth] = autoWidth ? 'auto' : '' + width + unitWidth;
2922729232
}
2922829233

2922929234
if (!onlyWidth) {
@@ -36789,6 +36794,10 @@ module.exports = {
3678936794
name: 'General',
3679036795
open: false,
3679136796
buildProps: ['float', 'display', 'position', 'top', 'right', 'left', 'bottom']
36797+
}, {
36798+
name: 'Flex',
36799+
open: false,
36800+
buildProps: ['flex-direction', 'flex-wrap', 'justify-content', 'align-items', 'align-content', 'order', 'flex-basis', 'flex-grow', 'flex-shrink', 'align-self']
3679236801
}, {
3679336802
name: 'Dimension',
3679436803
open: false,
@@ -38480,7 +38489,7 @@ module.exports = function () {
3848038489
plugins: plugins,
3848138490

3848238491
// Will be replaced on build
38483-
version: '0.14.51',
38492+
version: '0.14.52',
3848438493

3848538494
/**
3848638495
* Initialize the editor with passed options
@@ -44948,7 +44957,19 @@ var Property = __webpack_require__(/*! backbone */ "./node_modules/backbone/back
4494844957
// Use case:
4494944958
// you can add all SVG CSS properties with toRequire as true
4495044959
// and then require them on SVG Components
44951-
toRequire: 0
44960+
toRequire: 0,
44961+
44962+
// Specifies dependency on other properties of the selected object.
44963+
// Property is shown only when all conditions are matched.
44964+
//
44965+
// example: { display: ['flex', 'block'], position: ['absolute'] };
44966+
// in this case the property is only shown when display is
44967+
// of value 'flex' or 'block' AND position is 'absolute'
44968+
requires: null,
44969+
44970+
// Specifies dependency on properties of the parent of the selected object.
44971+
// Property is shown only when all conditions are matched.
44972+
requiresParent: null
4495244973
},
4495344974

4495444975
initialize: function initialize() {
@@ -45298,6 +45319,7 @@ module.exports = function () {
4529845319
case 'height':
4529945320
case 'max-height':
4530045321
case 'min-height':
45322+
case 'flex-basis':
4530145323
obj.fixedValues = ['initial', 'inherit', 'auto'];
4530245324
break;
4530345325
case 'font-size':
@@ -45317,6 +45339,12 @@ module.exports = function () {
4531745339
obj.type = 'radio';
4531845340
break;
4531945341
case 'display':
45342+
case 'flex-direction':
45343+
case 'flex-wrap':
45344+
case 'justify-content':
45345+
case 'align-items':
45346+
case 'align-content':
45347+
case 'align-self':
4532045348
case 'font-family':
4532145349
case 'font-weight':
4532245350
case 'border-style':
@@ -45329,6 +45357,8 @@ module.exports = function () {
4532945357
case 'transition-timing-function':
4533045358
case 'cursor':
4533145359
case 'overflow':
45360+
case 'overflow-x':
45361+
case 'overflow-y':
4533245362
obj.type = 'select';
4533345363
break;
4533445364
case 'top':
@@ -45373,6 +45403,10 @@ module.exports = function () {
4537345403
case 'transform-scale-x':
4537445404
case 'transform-scale-y':
4537545405
case 'transform-scale-z':
45406+
case 'order':
45407+
case 'flex-grow':
45408+
case 'flex-shrink':
45409+
case 'flex-basis':
4537645410
obj.type = 'integer';
4537745411
break;
4537845412
case 'margin':
@@ -45411,6 +45445,24 @@ module.exports = function () {
4541145445
case 'display':
4541245446
obj.defaults = 'block';
4541345447
break;
45448+
case 'flex-direction':
45449+
obj.defaults = 'row';
45450+
break;
45451+
case 'flex-wrap':
45452+
obj.defaults = 'nowrap';
45453+
break;
45454+
case 'justify-content':
45455+
obj.defaults = 'flex-start';
45456+
break;
45457+
case 'align-items':
45458+
obj.defaults = 'stretch';
45459+
break;
45460+
case 'align-content':
45461+
obj.defaults = 'stretch';
45462+
break;
45463+
case 'align-self':
45464+
obj.defaults = 'auto';
45465+
break;
4541445466
case 'position':
4541545467
obj.defaults = 'static';
4541645468
break;
@@ -45437,6 +45489,8 @@ module.exports = function () {
4543745489
case 'transform-rotate-x':
4543845490
case 'transform-rotate-y':
4543945491
case 'transform-rotate-z':
45492+
case 'order':
45493+
case 'flex-grow':
4544045494
obj.defaults = 0;
4544145495
break;
4544245496
case 'border-top-left-radius':
@@ -45448,6 +45502,7 @@ module.exports = function () {
4544845502
case 'transform-scale-x':
4544945503
case 'transform-scale-y':
4545045504
case 'transform-scale-z':
45505+
case 'flex-shrink':
4545145506
obj.defaults = 1;
4545245507
break;
4545345508
case 'box-shadow-blur':
@@ -45461,6 +45516,7 @@ module.exports = function () {
4546145516
case 'height':
4546245517
case 'background-size':
4546345518
case 'cursor':
45519+
case 'flex-basis':
4546445520
obj.defaults = 'auto';
4546545521
break;
4546645522
case 'font-family':
@@ -45511,10 +45567,36 @@ module.exports = function () {
4551145567
obj.defaults = 'ease';
4551245568
break;
4551345569
case 'overflow':
45570+
case 'overflow-x':
45571+
case 'overflow-y':
4551445572
obj.defaults = 'visible';
4551545573
break;
4551645574
}
4551745575

45576+
/*
45577+
* Add styleable dependency on other properties. Allows properties to be
45578+
* dynamically hidden or shown based on values of other properties.
45579+
*
45580+
* Property will be styleable if all of the properties (keys) in the
45581+
* requires object have any of the values specified in the array.
45582+
*/
45583+
switch (prop) {
45584+
case 'flex-direction':
45585+
case 'flex-wrap':
45586+
case 'justify-content':
45587+
case 'align-items':
45588+
case 'align-content':
45589+
obj.requires = { display: ['flex'] };
45590+
break;
45591+
case 'order':
45592+
case 'flex-basis':
45593+
case 'flex-grow':
45594+
case 'flex-shrink':
45595+
case 'align-self':
45596+
obj.requiresParent = { display: ['flex'] };
45597+
break;
45598+
}
45599+
4551845600
// Units
4551945601
switch (prop) {
4552045602
case 'top':
@@ -45539,6 +45621,9 @@ module.exports = function () {
4553945621
case 'width':
4554045622
obj.units = ['px', '%', 'vw'];
4554145623
break;
45624+
case 'flex-basis':
45625+
obj.units = ['px', '%', 'vw', 'vh'];
45626+
break;
4554245627
case 'text-shadow-v':
4554345628
case 'text-shadow-h':
4554445629
case 'text-shadow-blur':
@@ -45597,6 +45682,7 @@ module.exports = function () {
4559745682
case 'box-shadow-blur':
4559845683
case 'transition-duration':
4559945684
case 'perspective':
45685+
case 'flex-basis':
4560045686
obj.min = 0;
4560145687
break;
4560245688
}
@@ -45648,7 +45734,25 @@ module.exports = function () {
4564845734
obj.list = [{ value: 'none' }, { value: 'left' }, { value: 'right' }];
4564945735
break;
4565045736
case 'display':
45651-
obj.list = [{ value: 'block' }, { value: 'inline' }, { value: 'inline-block' }, { value: 'none' }];
45737+
obj.list = [{ value: 'block' }, { value: 'inline' }, { value: 'inline-block' }, { value: 'flex' }, { value: 'none' }];
45738+
break;
45739+
case 'flex-direction':
45740+
obj.list = [{ value: 'row' }, { value: 'row-reverse' }, { value: 'column' }, { value: 'column-reverse' }];
45741+
break;
45742+
case 'flex-wrap':
45743+
obj.list = [{ value: 'nowrap' }, { value: 'wrap' }, { value: 'wrap-reverse' }];
45744+
break;
45745+
case 'justify-content':
45746+
obj.list = [{ value: 'flex-start' }, { value: 'flex-end' }, { value: 'center' }, { value: 'space-between' }, { value: 'space-around' }, { value: 'space-evenly' }];
45747+
break;
45748+
case 'align-items':
45749+
obj.list = [{ value: 'flex-start' }, { value: 'flex-end' }, { value: 'center' }, { value: 'baseline' }, { value: 'stretch' }];
45750+
break;
45751+
case 'align-content':
45752+
obj.list = [{ value: 'flex-start' }, { value: 'flex-end' }, { value: 'center' }, { value: 'space-between' }, { value: 'space-around' }, { value: 'stretch' }];
45753+
break;
45754+
case 'align-self':
45755+
obj.list = [{ value: 'auto' }, { value: 'flex-start' }, { value: 'flex-end' }, { value: 'center' }, { value: 'baseline' }, { value: 'stretch' }];
4565245756
break;
4565345757
case 'position':
4565445758
obj.list = [{ value: 'static' }, { value: 'relative' }, { value: 'absolute' }, { value: 'fixed' }];
@@ -45698,6 +45802,8 @@ module.exports = function () {
4569845802
obj.list = [{ value: 'auto' }, { value: 'pointer' }, { value: 'copy' }, { value: 'crosshair' }, { value: 'grab' }, { value: 'grabbing' }, { value: 'help' }, { value: 'move' }, { value: 'text' }];
4569945803
break;
4570045804
case 'overflow':
45805+
case 'overflow-x':
45806+
case 'overflow-y':
4570145807
obj.list = [{ value: 'visible' }, { value: 'hidden' }, { value: 'scroll' }, { value: 'auto' }];
4570245808
break;
4570345809
}
@@ -46030,9 +46136,10 @@ module.exports = Backbone.Model.extend({
4603046136

4603146137
initialize: function initialize(opts) {
4603246138
var o = opts || {};
46033-
var props = [];
4603446139
var builded = this.buildProperties(o.buildProps);
46035-
!this.get('id') && this.set('id', this.get('name'));
46140+
var name = this.get('name') || '';
46141+
var props = [];
46142+
!this.get('id') && this.set('id', name.replace(/ /g, '_').toLowerCase());
4603646143

4603746144
if (!builded) props = this.get('properties');else props = this.extendProperties(builded);
4603846145

@@ -47370,6 +47477,8 @@ module.exports = _backbone2.default.View.extend({
4737047477
}, 'click [' + clearProp + ']', 'clear'),
4737147478

4737247479
initialize: function initialize() {
47480+
var _this = this;
47481+
4737347482
var o = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4737447483

4737547484
(0, _underscore.bindAll)(this, 'targetUpdated');
@@ -47397,6 +47506,14 @@ module.exports = _backbone2.default.View.extend({
4739747506

4739847507
em && em.on('update:component:style:' + this.property, this.targetUpdated);
4739947508
//em && em.on(`styleable:change:${this.property}`, this.targetUpdated);
47509+
47510+
// Listening to changes of properties in this.requires, so that styleable
47511+
// changes based on other properties are propagated
47512+
var requires = model.get('requires');
47513+
requires && Object.keys(requires).forEach(function (property) {
47514+
em && em.on('component:styleUpdate:' + property, _this.targetUpdated);
47515+
});
47516+
4740047517
this.listenTo(this.propTarget, 'update styleManager:update', this.targetUpdated);
4740147518
this.listenTo(model, 'destroy remove', this.remove);
4740247519
this.listenTo(model, 'change:value', this.modelValueChanged);
@@ -47449,13 +47566,13 @@ module.exports = _backbone2.default.View.extend({
4744947566
* Clear the property from the target
4745047567
*/
4745147568
clear: function clear(e) {
47452-
var _this = this;
47569+
var _this2 = this;
4745347570

4745447571
e && e.stopPropagation();
4745547572
this.model.clearValue();
4745647573
// Skip one stack with setTimeout to avoid inconsistencies
4745747574
setTimeout(function () {
47458-
return _this.targetUpdated();
47575+
return _this2.targetUpdated();
4745947576
});
4746047577
},
4746147578

@@ -47750,6 +47867,10 @@ module.exports = _backbone2.default.View.extend({
4775047867
var toRequire = model.get('toRequire');
4775147868
var unstylable = trg.get('unstylable');
4775247869
var stylableReq = trg.get('stylable-require');
47870+
var requires = model.get('requires');
47871+
var requiresParent = model.get('requiresParent');
47872+
var sectors = this.sector ? this.sector.collection : null;
47873+
var selected = this.em ? this.em.getSelected() : null;
4775347874
var stylable = trg.get('stylable');
4775447875

4775547876
// Stylable could also be an array indicating with which property
@@ -47768,6 +47889,33 @@ module.exports = _backbone2.default.View.extend({
4776847889
stylable = !target || stylableReq && (stylableReq.indexOf(id) >= 0 || stylableReq.indexOf(property) >= 0);
4776947890
}
4777047891

47892+
// Check if the property is available based on other property's values
47893+
if (sectors && requires) {
47894+
var properties = Object.keys(requires);
47895+
sectors.each(function (sector) {
47896+
sector.get('properties').each(function (model) {
47897+
if ((0, _underscore.includes)(properties, model.id)) {
47898+
var values = requires[model.id];
47899+
stylable = stylable && (0, _underscore.includes)(values, model.get('value'));
47900+
}
47901+
});
47902+
});
47903+
}
47904+
47905+
// Check if the property is available based on parent's property values
47906+
if (requiresParent) {
47907+
var parent = selected && selected.parent();
47908+
var parentEl = parent && parent.getEl();
47909+
if (parentEl) {
47910+
var styles = window.getComputedStyle(parentEl);
47911+
(0, _underscore.each)(requiresParent, function (values, property) {
47912+
stylable = stylable && styles[property] && (0, _underscore.includes)(values, styles[property]);
47913+
});
47914+
} else {
47915+
stylable = false;
47916+
}
47917+
}
47918+
4777147919
return stylable;
4777247920
},
4777347921

@@ -47959,13 +48107,17 @@ module.exports = _backbone2.default.View.extend({
4795948107
this.model.set('open', v);
4796048108
},
4796148109
render: function render() {
48110+
var pfx = this.pfx,
48111+
model = this.model;
48112+
var id = model.attributes.id;
48113+
4796248114
this.$el.html(this.template({
47963-
pfx: this.pfx,
47964-
label: this.model.get('name')
48115+
pfx: pfx,
48116+
label: model.get('name')
4796548117
}));
47966-
this.$caret = this.$el.find('#' + this.pfx + 'caret');
48118+
this.$caret = this.$el.find('#' + pfx + 'caret');
4796748119
this.renderProperties();
47968-
this.$el.attr('class', this.pfx + 'sector no-select');
48120+
this.$el.attr('class', pfx + 'sector ' + pfx + 'sector__' + id + ' no-select');
4796948121
this.updateOpen();
4797048122
return this;
4797148123
},
@@ -48152,15 +48304,20 @@ module.exports = _backbone2.default.View.extend({
4815248304
* @private
4815348305
* */
4815448306
addToCollection: function addToCollection(model, fragmentEl) {
48307+
var pfx = this.pfx,
48308+
target = this.target,
48309+
propTarget = this.propTarget,
48310+
config = this.config;
48311+
4815548312
var fragment = fragmentEl || null;
4815648313
var view = new SectorView({
4815748314
model: model,
48158-
id: this.pfx + model.get('name').replace(' ', '_').toLowerCase(),
48315+
id: '' + pfx + model.get('id'),
4815948316
name: model.get('name'),
4816048317
properties: model.get('properties'),
48161-
target: this.target,
48162-
propTarget: this.propTarget,
48163-
config: this.config
48318+
target: target,
48319+
propTarget: propTarget,
48320+
config: config
4816448321
});
4816548322
var rendered = view.render().el;
4816648323

0 commit comments

Comments
 (0)