@@ -26239,7 +26239,7 @@ module.exports = _backbone2.default.Model.extend({
26239
26239
// If the component has scripts we need to expose his ID
26240
26240
var attr = model.get('attributes');
26241
26241
attr = (0, _underscore.extend)({}, attr, { id: id });
26242
- model.set('attributes', attr);
26242
+ model.set('attributes', attr, { silent: 1 } );
26243
26243
var scrStr = model.getScriptString();
26244
26244
26245
26245
// If the script was updated, I'll put its code in a separate container
@@ -29129,7 +29129,9 @@ module.exports = {
29129
29129
* @private
29130
29130
*/
29131
29131
initResize: function initResize(elem) {
29132
- var em = this.em;
29132
+ var em = this.em,
29133
+ canvas = this.canvas;
29134
+
29133
29135
var editor = em ? em.get('Editor') : '';
29134
29136
var config = em ? em.get('Config') : '';
29135
29137
var pfx = config.stylePrefix || '';
@@ -29223,7 +29225,10 @@ module.exports = {
29223
29225
var style = modelToStyle.getStyle();
29224
29226
29225
29227
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;
29227
29232
}
29228
29233
29229
29234
if (!onlyWidth) {
@@ -36789,6 +36794,10 @@ module.exports = {
36789
36794
name: 'General',
36790
36795
open: false,
36791
36796
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']
36792
36801
}, {
36793
36802
name: 'Dimension',
36794
36803
open: false,
@@ -38480,7 +38489,7 @@ module.exports = function () {
38480
38489
plugins: plugins,
38481
38490
38482
38491
// Will be replaced on build
38483
- version: '0.14.51 ',
38492
+ version: '0.14.52 ',
38484
38493
38485
38494
/**
38486
38495
* Initialize the editor with passed options
@@ -44948,7 +44957,19 @@ var Property = __webpack_require__(/*! backbone */ "./node_modules/backbone/back
44948
44957
// Use case:
44949
44958
// you can add all SVG CSS properties with toRequire as true
44950
44959
// 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
44952
44973
},
44953
44974
44954
44975
initialize: function initialize() {
@@ -45298,6 +45319,7 @@ module.exports = function () {
45298
45319
case 'height':
45299
45320
case 'max-height':
45300
45321
case 'min-height':
45322
+ case 'flex-basis':
45301
45323
obj.fixedValues = ['initial', 'inherit', 'auto'];
45302
45324
break;
45303
45325
case 'font-size':
@@ -45317,6 +45339,12 @@ module.exports = function () {
45317
45339
obj.type = 'radio';
45318
45340
break;
45319
45341
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':
45320
45348
case 'font-family':
45321
45349
case 'font-weight':
45322
45350
case 'border-style':
@@ -45329,6 +45357,8 @@ module.exports = function () {
45329
45357
case 'transition-timing-function':
45330
45358
case 'cursor':
45331
45359
case 'overflow':
45360
+ case 'overflow-x':
45361
+ case 'overflow-y':
45332
45362
obj.type = 'select';
45333
45363
break;
45334
45364
case 'top':
@@ -45373,6 +45403,10 @@ module.exports = function () {
45373
45403
case 'transform-scale-x':
45374
45404
case 'transform-scale-y':
45375
45405
case 'transform-scale-z':
45406
+ case 'order':
45407
+ case 'flex-grow':
45408
+ case 'flex-shrink':
45409
+ case 'flex-basis':
45376
45410
obj.type = 'integer';
45377
45411
break;
45378
45412
case 'margin':
@@ -45411,6 +45445,24 @@ module.exports = function () {
45411
45445
case 'display':
45412
45446
obj.defaults = 'block';
45413
45447
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;
45414
45466
case 'position':
45415
45467
obj.defaults = 'static';
45416
45468
break;
@@ -45437,6 +45489,8 @@ module.exports = function () {
45437
45489
case 'transform-rotate-x':
45438
45490
case 'transform-rotate-y':
45439
45491
case 'transform-rotate-z':
45492
+ case 'order':
45493
+ case 'flex-grow':
45440
45494
obj.defaults = 0;
45441
45495
break;
45442
45496
case 'border-top-left-radius':
@@ -45448,6 +45502,7 @@ module.exports = function () {
45448
45502
case 'transform-scale-x':
45449
45503
case 'transform-scale-y':
45450
45504
case 'transform-scale-z':
45505
+ case 'flex-shrink':
45451
45506
obj.defaults = 1;
45452
45507
break;
45453
45508
case 'box-shadow-blur':
@@ -45461,6 +45516,7 @@ module.exports = function () {
45461
45516
case 'height':
45462
45517
case 'background-size':
45463
45518
case 'cursor':
45519
+ case 'flex-basis':
45464
45520
obj.defaults = 'auto';
45465
45521
break;
45466
45522
case 'font-family':
@@ -45511,10 +45567,36 @@ module.exports = function () {
45511
45567
obj.defaults = 'ease';
45512
45568
break;
45513
45569
case 'overflow':
45570
+ case 'overflow-x':
45571
+ case 'overflow-y':
45514
45572
obj.defaults = 'visible';
45515
45573
break;
45516
45574
}
45517
45575
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
+
45518
45600
// Units
45519
45601
switch (prop) {
45520
45602
case 'top':
@@ -45539,6 +45621,9 @@ module.exports = function () {
45539
45621
case 'width':
45540
45622
obj.units = ['px', '%', 'vw'];
45541
45623
break;
45624
+ case 'flex-basis':
45625
+ obj.units = ['px', '%', 'vw', 'vh'];
45626
+ break;
45542
45627
case 'text-shadow-v':
45543
45628
case 'text-shadow-h':
45544
45629
case 'text-shadow-blur':
@@ -45597,6 +45682,7 @@ module.exports = function () {
45597
45682
case 'box-shadow-blur':
45598
45683
case 'transition-duration':
45599
45684
case 'perspective':
45685
+ case 'flex-basis':
45600
45686
obj.min = 0;
45601
45687
break;
45602
45688
}
@@ -45648,7 +45734,25 @@ module.exports = function () {
45648
45734
obj.list = [{ value: 'none' }, { value: 'left' }, { value: 'right' }];
45649
45735
break;
45650
45736
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' }];
45652
45756
break;
45653
45757
case 'position':
45654
45758
obj.list = [{ value: 'static' }, { value: 'relative' }, { value: 'absolute' }, { value: 'fixed' }];
@@ -45698,6 +45802,8 @@ module.exports = function () {
45698
45802
obj.list = [{ value: 'auto' }, { value: 'pointer' }, { value: 'copy' }, { value: 'crosshair' }, { value: 'grab' }, { value: 'grabbing' }, { value: 'help' }, { value: 'move' }, { value: 'text' }];
45699
45803
break;
45700
45804
case 'overflow':
45805
+ case 'overflow-x':
45806
+ case 'overflow-y':
45701
45807
obj.list = [{ value: 'visible' }, { value: 'hidden' }, { value: 'scroll' }, { value: 'auto' }];
45702
45808
break;
45703
45809
}
@@ -46030,9 +46136,10 @@ module.exports = Backbone.Model.extend({
46030
46136
46031
46137
initialize: function initialize(opts) {
46032
46138
var o = opts || {};
46033
- var props = [];
46034
46139
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());
46036
46143
46037
46144
if (!builded) props = this.get('properties');else props = this.extendProperties(builded);
46038
46145
@@ -47370,6 +47477,8 @@ module.exports = _backbone2.default.View.extend({
47370
47477
}, 'click [' + clearProp + ']', 'clear'),
47371
47478
47372
47479
initialize: function initialize() {
47480
+ var _this = this;
47481
+
47373
47482
var o = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
47374
47483
47375
47484
(0, _underscore.bindAll)(this, 'targetUpdated');
@@ -47397,6 +47506,14 @@ module.exports = _backbone2.default.View.extend({
47397
47506
47398
47507
em && em.on('update:component:style:' + this.property, this.targetUpdated);
47399
47508
//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
+
47400
47517
this.listenTo(this.propTarget, 'update styleManager:update', this.targetUpdated);
47401
47518
this.listenTo(model, 'destroy remove', this.remove);
47402
47519
this.listenTo(model, 'change:value', this.modelValueChanged);
@@ -47449,13 +47566,13 @@ module.exports = _backbone2.default.View.extend({
47449
47566
* Clear the property from the target
47450
47567
*/
47451
47568
clear: function clear(e) {
47452
- var _this = this;
47569
+ var _this2 = this;
47453
47570
47454
47571
e && e.stopPropagation();
47455
47572
this.model.clearValue();
47456
47573
// Skip one stack with setTimeout to avoid inconsistencies
47457
47574
setTimeout(function () {
47458
- return _this .targetUpdated();
47575
+ return _this2 .targetUpdated();
47459
47576
});
47460
47577
},
47461
47578
@@ -47750,6 +47867,10 @@ module.exports = _backbone2.default.View.extend({
47750
47867
var toRequire = model.get('toRequire');
47751
47868
var unstylable = trg.get('unstylable');
47752
47869
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;
47753
47874
var stylable = trg.get('stylable');
47754
47875
47755
47876
// Stylable could also be an array indicating with which property
@@ -47768,6 +47889,33 @@ module.exports = _backbone2.default.View.extend({
47768
47889
stylable = !target || stylableReq && (stylableReq.indexOf(id) >= 0 || stylableReq.indexOf(property) >= 0);
47769
47890
}
47770
47891
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
+
47771
47919
return stylable;
47772
47920
},
47773
47921
@@ -47959,13 +48107,17 @@ module.exports = _backbone2.default.View.extend({
47959
48107
this.model.set('open', v);
47960
48108
},
47961
48109
render: function render() {
48110
+ var pfx = this.pfx,
48111
+ model = this.model;
48112
+ var id = model.attributes.id;
48113
+
47962
48114
this.$el.html(this.template({
47963
- pfx: this. pfx,
47964
- label: this. model.get('name')
48115
+ pfx: pfx,
48116
+ label: model.get('name')
47965
48117
}));
47966
- this.$caret = this.$el.find('#' + this. pfx + 'caret');
48118
+ this.$caret = this.$el.find('#' + pfx + 'caret');
47967
48119
this.renderProperties();
47968
- this.$el.attr('class', this. pfx + 'sector no-select');
48120
+ this.$el.attr('class', pfx + 'sector ' + pfx + 'sector__' + id + ' no-select');
47969
48121
this.updateOpen();
47970
48122
return this;
47971
48123
},
@@ -48152,15 +48304,20 @@ module.exports = _backbone2.default.View.extend({
48152
48304
* @private
48153
48305
* */
48154
48306
addToCollection: function addToCollection(model, fragmentEl) {
48307
+ var pfx = this.pfx,
48308
+ target = this.target,
48309
+ propTarget = this.propTarget,
48310
+ config = this.config;
48311
+
48155
48312
var fragment = fragmentEl || null;
48156
48313
var view = new SectorView({
48157
48314
model: model,
48158
- id: this. pfx + model.get('name').replace(' ', '_').toLowerCase( ),
48315
+ id: '' + pfx + model.get('id' ),
48159
48316
name: model.get('name'),
48160
48317
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
48164
48321
});
48165
48322
var rendered = view.render().el;
48166
48323
0 commit comments