@innovastudio/contentbuilder 1.0.60 → 1.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -38,7 +38,6 @@ button:focus {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
.is-builder {
|
|
41
|
-
transition: all ease 0.3s;
|
|
42
41
|
transform-origin: top;
|
|
43
42
|
}
|
|
44
43
|
.is-builder > div > div:focus {
|
|
@@ -2061,7 +2060,6 @@ button:focus {
|
|
|
2061
2060
|
#_cbhtml .is-modal.columnsettings .cell-bgimage-preview,
|
|
2062
2061
|
.is-ui .is-modal.columnsettings .cell-bgimage-preview {
|
|
2063
2062
|
max-width: 120px;
|
|
2064
|
-
max-height: 120px;
|
|
2065
2063
|
}
|
|
2066
2064
|
#_cbhtml .is-modal.columnsettings .cell-bgimage-preview img,
|
|
2067
2065
|
.is-ui .is-modal.columnsettings .cell-bgimage-preview img {
|
|
@@ -2748,6 +2746,17 @@ button:focus {
|
|
|
2748
2746
|
letter-spacing: 1px;
|
|
2749
2747
|
padding: 0;
|
|
2750
2748
|
}
|
|
2749
|
+
#_cbhtml label.label-checkbox,
|
|
2750
|
+
.is-ui label.label-checkbox {
|
|
2751
|
+
display: flex;
|
|
2752
|
+
align-items: center;
|
|
2753
|
+
line-height: 1;
|
|
2754
|
+
}
|
|
2755
|
+
#_cbhtml label.label-checkbox input,
|
|
2756
|
+
.is-ui label.label-checkbox input {
|
|
2757
|
+
margin: 0;
|
|
2758
|
+
margin-right: 5px;
|
|
2759
|
+
}
|
|
2751
2760
|
#_cbhtml .is-rangeslider,
|
|
2752
2761
|
.is-ui .is-rangeslider {
|
|
2753
2762
|
-webkit-appearance: none;
|
|
@@ -2396,6 +2396,7 @@ class Util {
|
|
|
2396
2396
|
on = true;
|
|
2397
2397
|
}
|
|
2398
2398
|
}
|
|
2399
|
+
/*
|
|
2399
2400
|
if(on) {
|
|
2400
2401
|
parent._cb.clearFont();
|
|
2401
2402
|
} else {
|
|
@@ -2406,6 +2407,13 @@ class Util {
|
|
|
2406
2407
|
//parent._cb.applyFont(fontfamily, fontstyle, provider);
|
|
2407
2408
|
parent._cb.setFont(fontfamily, fontstyle, fontdisplay, provider);
|
|
2408
2409
|
}
|
|
2410
|
+
*/
|
|
2411
|
+
var provider = elm.getAttribute('data-provider');
|
|
2412
|
+
var fontfamily = elm.getAttribute('data-font-family');
|
|
2413
|
+
var fontstyle = elm.getAttribute('data-font-style');
|
|
2414
|
+
var fontdisplay = elm.getAttribute('data-font-display');
|
|
2415
|
+
//parent._cb.applyFont(fontfamily, fontstyle, provider);
|
|
2416
|
+
parent._cb.setFont(fontfamily, fontstyle, fontdisplay, provider);
|
|
2409
2417
|
|
|
2410
2418
|
});
|
|
2411
2419
|
}
|
|
@@ -2597,6 +2605,7 @@ class Util {
|
|
|
2597
2605
|
on = true;
|
|
2598
2606
|
}
|
|
2599
2607
|
}
|
|
2608
|
+
/*
|
|
2600
2609
|
if(on) {
|
|
2601
2610
|
parent._cb.clearFont();
|
|
2602
2611
|
} else {
|
|
@@ -2607,6 +2616,13 @@ class Util {
|
|
|
2607
2616
|
//parent._cb.applyFont(fontfamily, fontstyle, provider);
|
|
2608
2617
|
parent._cb.setFont(fontfamily, fontstyle, fontdisplay, provider);
|
|
2609
2618
|
}
|
|
2619
|
+
*/
|
|
2620
|
+
var provider = elm.getAttribute('data-provider');
|
|
2621
|
+
var fontfamily = elm.getAttribute('data-font-family');
|
|
2622
|
+
var fontstyle = elm.getAttribute('data-font-style');
|
|
2623
|
+
var fontdisplay = elm.getAttribute('data-font-display');
|
|
2624
|
+
//parent._cb.applyFont(fontfamily, fontstyle, provider);
|
|
2625
|
+
parent._cb.setFont(fontfamily, fontstyle, fontdisplay, provider);
|
|
2610
2626
|
|
|
2611
2627
|
});
|
|
2612
2628
|
}
|
|
@@ -2716,6 +2732,16 @@ class Dom {
|
|
|
2716
2732
|
return children;
|
|
2717
2733
|
}
|
|
2718
2734
|
|
|
2735
|
+
getElementOffset(el) {
|
|
2736
|
+
const rect = el.getBoundingClientRect();
|
|
2737
|
+
return {
|
|
2738
|
+
top: rect.top + window.pageYOffset,
|
|
2739
|
+
left: rect.left + window.pageXOffset,
|
|
2740
|
+
width: rect.width,
|
|
2741
|
+
height: rect.height
|
|
2742
|
+
};
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2719
2745
|
parentsHasClass(element, classname) {
|
|
2720
2746
|
while (element) {
|
|
2721
2747
|
// if(classname==='is-side') console.log(element.nodeName); // NOTE: click on svg can still returns undefined in IE11
|
|
@@ -2925,40 +2951,45 @@ class Dom {
|
|
|
2925
2951
|
}
|
|
2926
2952
|
|
|
2927
2953
|
textSelection() {
|
|
2954
|
+
/*
|
|
2928
2955
|
try {
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2956
|
+
var elm;
|
|
2957
|
+
var curr = window.getSelection().getRangeAt(0).commonAncestorContainer;
|
|
2958
|
+
if (curr.nodeType === 3) { // text node
|
|
2959
|
+
elm = curr.parentNode;
|
|
2960
|
+
if(this.parentsHasClass(elm, 'is-builder')) {
|
|
2961
|
+
return elm;
|
|
2962
|
+
}
|
|
2963
|
+
else {
|
|
2964
|
+
return false;
|
|
2965
|
+
}
|
|
2938
2966
|
} else {
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2967
|
+
elm = curr;
|
|
2968
|
+
var nodeName = elm.nodeName.toLowerCase();
|
|
2969
|
+
if(nodeName === 'i' && elm.innerHTML === '') { //icon
|
|
2970
|
+
if(this.parentsHasClass(elm, 'is-builder')) {
|
|
2971
|
+
return elm;
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
// Check if a block (because when placing cursor using arrow keys on empty block, nodeType=1 not 3)
|
|
2976
|
+
if(nodeName === 'p' || nodeName === 'h1' || nodeName === 'h2'
|
|
2977
|
+
|| nodeName === 'h3' || nodeName === 'h4' || nodeName === 'h5'
|
|
2978
|
+
|| nodeName === 'h6' || nodeName === 'li' || nodeName === 'pre'
|
|
2979
|
+
|| nodeName === 'blockquote') {
|
|
2980
|
+
return elm;
|
|
2981
|
+
}
|
|
2982
|
+
return false;
|
|
2955
2983
|
}
|
|
2956
|
-
|
|
2957
|
-
return false;
|
|
2958
|
-
}
|
|
2959
2984
|
} catch (e) {
|
|
2960
|
-
|
|
2985
|
+
return false;
|
|
2961
2986
|
}
|
|
2987
|
+
*/
|
|
2988
|
+
const selection = this.getSelection();
|
|
2989
|
+
const anchorNode = selection.anchorNode;
|
|
2990
|
+
if (!anchorNode) return false;
|
|
2991
|
+
const container = anchorNode.nodeType !== Node.TEXT_NODE && anchorNode.nodeType !== Node.COMMENT_NODE ? anchorNode : anchorNode.parentElement;
|
|
2992
|
+
return container;
|
|
2962
2993
|
}
|
|
2963
2994
|
|
|
2964
2995
|
getStyle(element, property) {
|
|
@@ -3010,7 +3041,347 @@ class Dom {
|
|
|
3010
3041
|
}
|
|
3011
3042
|
}
|
|
3012
3043
|
} // ---
|
|
3044
|
+
// execCommand replacement
|
|
3045
|
+
|
|
3046
|
+
|
|
3047
|
+
execCommand(action, value, callback) {
|
|
3048
|
+
const selection = this.getSelection();
|
|
3049
|
+
if (!selection) return;
|
|
3050
|
+
const anchorNode = selection.anchorNode;
|
|
3051
|
+
|
|
3052
|
+
if (anchorNode) {
|
|
3053
|
+
const container = anchorNode.nodeType !== Node.TEXT_NODE && anchorNode.nodeType !== Node.COMMENT_NODE ? anchorNode : anchorNode.parentElement;
|
|
3054
|
+
const sameSelection = container && container.innerText === selection.toString();
|
|
3055
|
+
let newElement;
|
|
3056
|
+
|
|
3057
|
+
if (sameSelection || selection.toString().trim() === '') {
|
|
3058
|
+
newElement = this.updateSelection(action, value, container);
|
|
3059
|
+
} else {
|
|
3060
|
+
newElement = this.replaceSelection(action, value, selection, container);
|
|
3061
|
+
}
|
|
3062
|
+
|
|
3063
|
+
if (callback) callback(true, newElement);
|
|
3064
|
+
} else {
|
|
3065
|
+
if (callback) callback(false);
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
|
|
3069
|
+
updateSelection(action, value, container) {
|
|
3070
|
+
// container.style[action] = value; //APPLY => Use getStyleValue to check if toggle is needed.
|
|
3071
|
+
container.style[action] = this.getStyleValue(container, action, value); // Optional, better if used: check if the style is the same as its parent. If so, clear it.
|
|
3072
|
+
|
|
3073
|
+
this.checkStyleIfSameAsParent(container, action);
|
|
3074
|
+
this.cleanChildren(action, container); // this.cleanUnusedSpan(container);
|
|
3075
|
+
|
|
3076
|
+
return container;
|
|
3077
|
+
}
|
|
3078
|
+
|
|
3079
|
+
replaceSelection(action, value, selection, container) {
|
|
3080
|
+
const range = selection.getRangeAt(0);
|
|
3081
|
+
const fragment = range.extractContents();
|
|
3082
|
+
const span = this.createSpan(container, action, value);
|
|
3083
|
+
span.appendChild(fragment);
|
|
3084
|
+
this.cleanChildren(action, span); // this.cleanUnusedSpan(span);
|
|
3085
|
+
|
|
3086
|
+
range.insertNode(span);
|
|
3087
|
+
selection.selectAllChildren(span); // Optional, better if used: check if the style is the same as its parent. If so, clear it.
|
|
3088
|
+
|
|
3089
|
+
this.checkStyleIfSameAsParent(span, action);
|
|
3090
|
+
return span;
|
|
3091
|
+
}
|
|
3092
|
+
|
|
3093
|
+
checkStyleIfSameAsParent(element, action) {
|
|
3094
|
+
if (element.parentNode) {
|
|
3095
|
+
if (element.parentNode.style[action] === element.style[action] || window.getComputedStyle(element.parentNode, null).getPropertyValue(action) === element.style[action]) {
|
|
3096
|
+
element.style[action] = '';
|
|
3097
|
+
|
|
3098
|
+
if (element.getAttribute('style') === '' || element.style === null) {
|
|
3099
|
+
element.removeAttribute('style');
|
|
3100
|
+
} // let unused = ( element.attributes.length === 0 || (element.attributes.length === 1 && element.hasAttribute('data-keep')));
|
|
3101
|
+
// if (element.nodeName.toLowerCase() === 'span' && unused) {
|
|
3102
|
+
// const text = document.createTextNode(element.textContent);
|
|
3103
|
+
// element.parentElement.replaceChild(text, element);
|
|
3104
|
+
// }
|
|
3105
|
+
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
|
|
3110
|
+
createSpan(container, action, value) {
|
|
3111
|
+
const span = document.createElement('span'); // span.style[action] = value; //APPLY => Use getStyleValue to check if toggle is needed.
|
|
3112
|
+
|
|
3113
|
+
span.style[action] = this.getStyleValue(container, action, value);
|
|
3114
|
+
return span;
|
|
3115
|
+
}
|
|
3116
|
+
|
|
3117
|
+
findParentStyle(node, action) {
|
|
3118
|
+
if (node.nodeName.toUpperCase() === 'HTML' || node.nodeName.toUpperCase() === 'BODY') {
|
|
3119
|
+
return null;
|
|
3120
|
+
}
|
|
3121
|
+
|
|
3122
|
+
if (!node.parentNode) {
|
|
3123
|
+
return null;
|
|
3124
|
+
}
|
|
3125
|
+
|
|
3126
|
+
const hasStyle = node.style[action] !== null && node.style[action] !== undefined && node.style[action] !== '';
|
|
3127
|
+
|
|
3128
|
+
if (hasStyle) {
|
|
3129
|
+
return node;
|
|
3130
|
+
}
|
|
3131
|
+
|
|
3132
|
+
this.findParentStyle(node.parentNode, action);
|
|
3133
|
+
}
|
|
3134
|
+
|
|
3135
|
+
getStyleValue(container, action, value) {
|
|
3136
|
+
if (action === 'font-weight' || action === 'font-style' || action === 'text-decoration' || action === 'text-transform') {
|
|
3137
|
+
// Toggle
|
|
3138
|
+
// let currentValue = window.getComputedStyle(container, null).getPropertyValue(action);
|
|
3139
|
+
let parent = this.findParentStyle(container, action);
|
|
3140
|
+
let currentValue;
|
|
3141
|
+
|
|
3142
|
+
if (parent) {
|
|
3143
|
+
currentValue = parent.style[action];
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
if (value === currentValue) {
|
|
3147
|
+
//toggle here
|
|
3148
|
+
// value = 'initial'; // the problem with initial is that it is always refer to font-weight: 400 (won;t work for custom 300 for normal paragraph)
|
|
3149
|
+
// so we'll do the test first, to find the actuat initial value
|
|
3150
|
+
container.style[action] = ''; // test
|
|
3151
|
+
|
|
3152
|
+
let initialValue = window.getComputedStyle(container, null).getPropertyValue(action); // get the actual initial value
|
|
3153
|
+
// console.log('initial:' +initialValue);
|
|
3154
|
+
|
|
3155
|
+
container.style[action] = currentValue; //return back from test
|
|
3156
|
+
|
|
3157
|
+
value = initialValue;
|
|
3158
|
+
}
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3161
|
+
return value;
|
|
3162
|
+
}
|
|
3163
|
+
|
|
3164
|
+
getSelection() {
|
|
3165
|
+
if (window && window.getSelection) {
|
|
3166
|
+
return window.getSelection();
|
|
3167
|
+
} else if (document && document.getSelection) {
|
|
3168
|
+
return document.getSelection();
|
|
3169
|
+
} else if (document && document.selection) {
|
|
3170
|
+
return document.selection.createRange().text;
|
|
3171
|
+
}
|
|
3172
|
+
|
|
3173
|
+
return null;
|
|
3174
|
+
}
|
|
3175
|
+
|
|
3176
|
+
cleanChildren(action, span) {
|
|
3177
|
+
if (!span.hasChildNodes()) {
|
|
3178
|
+
return;
|
|
3179
|
+
} // Direct children with same style rule
|
|
3180
|
+
|
|
3181
|
+
|
|
3182
|
+
const children = Array.from(span.children).filter(element => {
|
|
3183
|
+
return element.style[action] !== undefined && element.style[action.style] !== '';
|
|
3184
|
+
});
|
|
3185
|
+
|
|
3186
|
+
if (children && children.length > 0) {
|
|
3187
|
+
children.forEach(element => {
|
|
3188
|
+
element.style[action] = '';
|
|
3189
|
+
|
|
3190
|
+
if (element.getAttribute('style') === '' || element.style === null) {
|
|
3191
|
+
element.removeAttribute('style');
|
|
3192
|
+
}
|
|
3193
|
+
});
|
|
3194
|
+
} // Deeper childrens
|
|
3195
|
+
|
|
3196
|
+
|
|
3197
|
+
const cleanChildrenChildren = Array.from(span.children).map(element => {
|
|
3198
|
+
return this.cleanChildren(action, element);
|
|
3199
|
+
});
|
|
3200
|
+
|
|
3201
|
+
if (!cleanChildrenChildren || cleanChildrenChildren.length <= 0) {
|
|
3202
|
+
return;
|
|
3203
|
+
}
|
|
3204
|
+
} // Clean HTML stuff
|
|
3205
|
+
|
|
3206
|
+
|
|
3207
|
+
removeEmptyStyle(area) {
|
|
3208
|
+
if (!area.hasChildNodes()) {
|
|
3209
|
+
return;
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
const children = Array.from(area.children).filter(element => {
|
|
3213
|
+
return element.getAttribute('style');
|
|
3214
|
+
});
|
|
3215
|
+
|
|
3216
|
+
if (children && children.length > 0) {
|
|
3217
|
+
children.forEach(element => {
|
|
3218
|
+
if (element.getAttribute('style').trim() === '' || element.style === null) {
|
|
3219
|
+
element.removeAttribute('style');
|
|
3220
|
+
}
|
|
3221
|
+
});
|
|
3222
|
+
} // Deeper childrens
|
|
3223
|
+
|
|
3224
|
+
|
|
3225
|
+
const removeEmptyStyleChildren = Array.from(area.children).map(element => {
|
|
3226
|
+
return this.removeEmptyStyle(element);
|
|
3227
|
+
});
|
|
3228
|
+
|
|
3229
|
+
if (!removeEmptyStyleChildren || removeEmptyStyleChildren.length <= 0) {
|
|
3230
|
+
return;
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3234
|
+
cleanEmptySpans(area) {
|
|
3235
|
+
let spans = area.querySelectorAll('span');
|
|
3236
|
+
const filter = Array.prototype.filter;
|
|
3237
|
+
let children = filter.call(spans, element => {
|
|
3238
|
+
return element.attributes.length === 0;
|
|
3239
|
+
}); // Remove empty spans
|
|
3240
|
+
|
|
3241
|
+
if (children && children.length > 0) {
|
|
3242
|
+
children.forEach(element => {
|
|
3243
|
+
element.outerHTML = element.innerHTML;
|
|
3244
|
+
});
|
|
3245
|
+
} // Remove spans which have empty content
|
|
3246
|
+
|
|
3247
|
+
|
|
3248
|
+
spans = area.querySelectorAll('span');
|
|
3249
|
+
filter.call(spans, element => {
|
|
3250
|
+
if (element.innerHTML === '') {
|
|
3251
|
+
element.parentNode.removeChild(element);
|
|
3252
|
+
}
|
|
3253
|
+
}); // Recheck
|
|
3254
|
+
|
|
3255
|
+
spans = area.querySelectorAll('span');
|
|
3256
|
+
children = filter.call(spans, element => {
|
|
3257
|
+
return element.attributes.length === 0;
|
|
3258
|
+
});
|
|
3259
|
+
|
|
3260
|
+
if (children && children.length > 0) {
|
|
3261
|
+
this.cleanEmptySpans(area);
|
|
3262
|
+
} else {
|
|
3263
|
+
return;
|
|
3264
|
+
}
|
|
3265
|
+
} // Font Size stuff
|
|
3266
|
+
|
|
3267
|
+
|
|
3268
|
+
cleanClassSize(span, className) {
|
|
3269
|
+
if (!span.hasChildNodes()) {
|
|
3270
|
+
return;
|
|
3271
|
+
} // Direct children with same style rule
|
|
3272
|
+
|
|
3273
|
+
|
|
3274
|
+
const children = Array.from(span.children).filter(element => {
|
|
3275
|
+
return this.hasClass(element, className);
|
|
3276
|
+
});
|
|
3277
|
+
|
|
3278
|
+
if (children && children.length > 0) {
|
|
3279
|
+
children.forEach(element => {
|
|
3280
|
+
this.removeClass(element, className);
|
|
3281
|
+
});
|
|
3282
|
+
} // Deeper childrens
|
|
3283
|
+
|
|
3284
|
+
|
|
3285
|
+
const cleanClassSizeChildren = Array.from(span.children).map(element => {
|
|
3286
|
+
return this.cleanClassSize(element, className);
|
|
3287
|
+
});
|
|
3288
|
+
|
|
3289
|
+
if (!cleanClassSizeChildren || cleanClassSizeChildren.length <= 0) {
|
|
3290
|
+
return;
|
|
3291
|
+
}
|
|
3292
|
+
} // Remove Format stuff
|
|
3293
|
+
|
|
3294
|
+
|
|
3295
|
+
removeFormat() {
|
|
3296
|
+
const selection = this.getSelection();
|
|
3297
|
+
if (!selection) return;
|
|
3298
|
+
const anchorNode = selection.anchorNode;
|
|
3299
|
+
if (!anchorNode) return;
|
|
3300
|
+
const container = anchorNode.nodeType !== Node.TEXT_NODE && anchorNode.nodeType !== Node.COMMENT_NODE ? anchorNode : anchorNode.parentElement;
|
|
3301
|
+
const sameSelection = container && container.innerText === selection.toString();
|
|
3302
|
+
|
|
3303
|
+
if (sameSelection || selection.toString().trim() === '') {
|
|
3304
|
+
this.cleanElement(container);
|
|
3305
|
+
} else {
|
|
3306
|
+
this.cleanSelection(selection);
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
|
|
3310
|
+
cleanElement(elm) {
|
|
3311
|
+
elm.style.fontWeight = '';
|
|
3312
|
+
elm.style.fontStyle = '';
|
|
3313
|
+
elm.style.textDecoration = '';
|
|
3314
|
+
elm.style.textTransform = '';
|
|
3315
|
+
elm.style.fontFamily = '';
|
|
3316
|
+
elm.style.fontSize = '';
|
|
3317
|
+
elm.style.color = '';
|
|
3318
|
+
elm.style.backgroundColor = '';
|
|
3319
|
+
elm.classList.forEach(item => {
|
|
3320
|
+
if (item.indexOf('size-') !== -1) {
|
|
3321
|
+
this.removeClass(elm, item);
|
|
3322
|
+
}
|
|
3323
|
+
});
|
|
3324
|
+
let elms = elm.querySelectorAll('*');
|
|
3325
|
+
elms.forEach(elm => {
|
|
3326
|
+
elm.style.fontWeight = '';
|
|
3327
|
+
elm.style.fontStyle = '';
|
|
3328
|
+
elm.style.textDecoration = '';
|
|
3329
|
+
elm.style.textTransform = '';
|
|
3330
|
+
elm.style.fontFamily = '';
|
|
3331
|
+
elm.style.fontSize = '';
|
|
3332
|
+
elm.style.color = '';
|
|
3333
|
+
elm.style.backgroundColor = '';
|
|
3334
|
+
elm.classList.forEach(item => {
|
|
3335
|
+
if (item.indexOf('size-') !== -1) {
|
|
3336
|
+
this.removeClass(elm, item);
|
|
3337
|
+
}
|
|
3338
|
+
});
|
|
3339
|
+
});
|
|
3340
|
+
this.cleanUnusedSpan(elm); // causes lost selection
|
|
3341
|
+
}
|
|
3013
3342
|
|
|
3343
|
+
cleanSelection(selection) {
|
|
3344
|
+
const range = selection.getRangeAt(0);
|
|
3345
|
+
const fragment = range.extractContents();
|
|
3346
|
+
const span = document.createElement('span');
|
|
3347
|
+
span.appendChild(fragment);
|
|
3348
|
+
range.insertNode(span);
|
|
3349
|
+
selection.selectAllChildren(span);
|
|
3350
|
+
this.cleanElement(span);
|
|
3351
|
+
}
|
|
3352
|
+
|
|
3353
|
+
cleanUnusedSpan(span) {
|
|
3354
|
+
if (!span.hasChildNodes()) {
|
|
3355
|
+
return;
|
|
3356
|
+
} // Direct children with no style
|
|
3357
|
+
|
|
3358
|
+
|
|
3359
|
+
const children = Array.from(span.children).filter(element => {
|
|
3360
|
+
if (element.getAttribute('style') === '' || element.style === null) {
|
|
3361
|
+
element.removeAttribute('style');
|
|
3362
|
+
}
|
|
3363
|
+
|
|
3364
|
+
let unused = element.attributes.length === 0 || element.attributes.length === 1 && element.hasAttribute('data-keep');
|
|
3365
|
+
return element.nodeName.toLowerCase() === 'span' && unused;
|
|
3366
|
+
});
|
|
3367
|
+
|
|
3368
|
+
if (children && children.length > 0) {
|
|
3369
|
+
children.forEach(element => {
|
|
3370
|
+
const text = document.createTextNode(element.textContent);
|
|
3371
|
+
element.parentElement.replaceChild(text, element);
|
|
3372
|
+
});
|
|
3373
|
+
return;
|
|
3374
|
+
} // Deeper childrens
|
|
3375
|
+
|
|
3376
|
+
|
|
3377
|
+
const cleanUnusedSpanChildren = Array.from(span.children).map(element => {
|
|
3378
|
+
return this.cleanUnusedSpan(element);
|
|
3379
|
+
});
|
|
3380
|
+
|
|
3381
|
+
if (!cleanUnusedSpanChildren || cleanUnusedSpanChildren.length <= 0) {
|
|
3382
|
+
return;
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3014
3385
|
|
|
3015
3386
|
}
|
|
3016
3387
|
|
|
@@ -8702,6 +9073,8 @@ class HtmlUtil {
|
|
|
8702
9073
|
dom$E.removeAttributes(elms, 'draggable');
|
|
8703
9074
|
elms = tmp.querySelectorAll('[data-animated]');
|
|
8704
9075
|
dom$E.removeAttributes(elms, 'data-animated');
|
|
9076
|
+
elms = tmp.querySelectorAll('[data-saveforundo]');
|
|
9077
|
+
dom$E.removeAttributes(elms, 'data-saveforundo');
|
|
8705
9078
|
elms = tmp.querySelectorAll('[hidesnippetaddtool]');
|
|
8706
9079
|
dom$E.removeAttributes(elms, 'hidesnippetaddtool');
|
|
8707
9080
|
elms = tmp.querySelectorAll('[gray]');
|
|
@@ -8747,6 +9120,8 @@ class HtmlUtil {
|
|
|
8747
9120
|
Array.prototype.forEach.call(emptystyles, emptystyle => {
|
|
8748
9121
|
emptystyle.removeAttribute('style');
|
|
8749
9122
|
});
|
|
9123
|
+
dom$E.removeEmptyStyle(tmp);
|
|
9124
|
+
dom$E.cleanEmptySpans(tmp);
|
|
8750
9125
|
elms = tmp.querySelectorAll('[data-keep]');
|
|
8751
9126
|
dom$E.removeAttributes(elms, 'data-keep'); //Cleanup button <span contenteditable="false"><a contenteditable="true">button</a></span>
|
|
8752
9127
|
|
|
@@ -44940,6 +45315,10 @@ class ColumnTool {
|
|
|
44940
45315
|
<button title="${util.out('Clear')}" class="input-cell-textcolor" data-command=""><svg class="is-icon-flex" style="flex:none;width:18px;height:18px;margin-top: 2px;"><use xlink:href="#ion-ios-close-empty"></use></svg></button>
|
|
44941
45316
|
</div>
|
|
44942
45317
|
|
|
45318
|
+
<div style="padding-top:20px;">
|
|
45319
|
+
<label class="label-cell-grayscale label-checkbox" for="chkCellGrayscale"><input id="chkCellGrayscale" class="chk-cell-grayscale" type="checkbox" /> ${util.out('Grayscale')}</label>
|
|
45320
|
+
</div>
|
|
45321
|
+
|
|
44943
45322
|
<div style="display:none;padding-top:20px;padding-bottom:3px;">${util.out('Enlarge Row')}:</div>
|
|
44944
45323
|
<div style="display: none;">
|
|
44945
45324
|
<button title="${util.out('Normal')}" class="input-row-enlarge" data-command="0" style="margin-right:1px;">${util.out('Normal')}</button>
|
|
@@ -45603,6 +45982,22 @@ class ColumnTool {
|
|
|
45603
45982
|
this.builder.opts.onChange();
|
|
45604
45983
|
});
|
|
45605
45984
|
});
|
|
45985
|
+
const chkCellGrayscale = cellSettings.querySelector('.chk-cell-grayscale');
|
|
45986
|
+
dom$l.addEventListener(chkCellGrayscale, 'click', () => {
|
|
45987
|
+
this.builder.uo.saveForUndo();
|
|
45988
|
+
let cell = util.cellSelected();
|
|
45989
|
+
|
|
45990
|
+
if (chkCellGrayscale.checked) {
|
|
45991
|
+
cell.style.filter = 'grayscale(1)';
|
|
45992
|
+
} else {
|
|
45993
|
+
if (cell.style.filter) {
|
|
45994
|
+
cell.style.filter = cell.style.filter.replace('grayscale(1)', '');
|
|
45995
|
+
}
|
|
45996
|
+
} //Trigger Change event
|
|
45997
|
+
|
|
45998
|
+
|
|
45999
|
+
this.builder.opts.onChange();
|
|
46000
|
+
});
|
|
45606
46001
|
elms = cellSettings.querySelectorAll('.input-cell-height');
|
|
45607
46002
|
Array.prototype.forEach.call(elms, elm => {
|
|
45608
46003
|
dom$l.addEventListener(elm, 'click', () => {
|
|
@@ -45954,6 +46349,15 @@ class ColumnTool {
|
|
|
45954
46349
|
dom$l.addClass(btn, 'on');
|
|
45955
46350
|
}
|
|
45956
46351
|
|
|
46352
|
+
const chkCellGrayscale = this.cellSettings.querySelector('.chk-cell-grayscale');
|
|
46353
|
+
chkCellGrayscale.checked = false;
|
|
46354
|
+
|
|
46355
|
+
if (cell.style.filter) {
|
|
46356
|
+
if (cell.style.filter.indexOf('grayscale') !== -1) {
|
|
46357
|
+
chkCellGrayscale.checked = true;
|
|
46358
|
+
}
|
|
46359
|
+
}
|
|
46360
|
+
|
|
45957
46361
|
elms = this.cellSettings.querySelectorAll('.input-cell-height');
|
|
45958
46362
|
Array.prototype.forEach.call(elms, elm => {
|
|
45959
46363
|
dom$l.removeClass(elm, 'on');
|
|
@@ -57332,7 +57736,8 @@ class ContentBuilder {
|
|
|
57332
57736
|
['#ed2828','dark','contentbuilder/themes/dark-red.css'],
|
|
57333
57737
|
],
|
|
57334
57738
|
*/
|
|
57335
|
-
colHeight: [300, 350, 400, 450, 500, 550, 600, 650, 700]
|
|
57739
|
+
colHeight: [300, 350, 400, 450, 500, 550, 600, 650, 700] // maxColumns: 6,
|
|
57740
|
+
|
|
57336
57741
|
}; // obj.preserveSelection = true; (can be set programmatically) to prevent click that clears selection on external custom modal.
|
|
57337
57742
|
|
|
57338
57743
|
this.opts = Object.assign(this, defaults, opts);
|
|
@@ -57427,7 +57832,7 @@ class ContentBuilder {
|
|
|
57427
57832
|
// DEFAULT: Built-in simple css grid
|
|
57428
57833
|
this.opts.row = 'row clearfix';
|
|
57429
57834
|
this.opts.cols = ['column sixth', 'column fifth', 'column fourth', 'column third', 'column half', 'column two-third', 'column two-fourth', 'column two-fifth', 'column two-sixth', 'column full'];
|
|
57430
|
-
this.opts.colequal = [['column fifth', 'column fifth', 'column fifth', 'column fifth', 'column fifth'], ['column fourth', 'column fourth', 'column fourth', 'column fourth'], ['column third', 'column third', 'column third'], ['column half', 'column half']];
|
|
57835
|
+
this.opts.colequal = [['column sixth', 'column sixth', 'column sixth', 'column sixth', 'column sixth', 'column sixth'], ['column fifth', 'column fifth', 'column fifth', 'column fifth', 'column fifth'], ['column fourth', 'column fourth', 'column fourth', 'column fourth'], ['column third', 'column third', 'column third'], ['column half', 'column half']];
|
|
57431
57836
|
this.opts.colsizes = [//needed for columns in which the size increment is not constant.
|
|
57432
57837
|
[//increment for 3 columns
|
|
57433
57838
|
['column third', 'column third', 'column third'], ['column half', 'column fourth', 'column fourth']], [//increment for 2 columns
|
|
@@ -59304,7 +59709,30 @@ class ContentBuilder {
|
|
|
59304
59709
|
} // Show Lock Indicator
|
|
59305
59710
|
|
|
59306
59711
|
|
|
59307
|
-
this.colTool.showHideLockIndicator(col);
|
|
59712
|
+
this.colTool.showHideLockIndicator(col); // Check if last row, make sure the Row Add Tool visible
|
|
59713
|
+
|
|
59714
|
+
const tool = row.querySelector('.is-rowadd-tool');
|
|
59715
|
+
const tollAddButton = tool.querySelector('button');
|
|
59716
|
+
tollAddButton.style.marginTop = '';
|
|
59717
|
+
const children = Array.from(row.parentNode.children).filter(element => {
|
|
59718
|
+
return element.nodeName.toLowerCase() === 'div';
|
|
59719
|
+
});
|
|
59720
|
+
|
|
59721
|
+
if (children && children.length > 0) {
|
|
59722
|
+
let lastChild = children[children.length - 1];
|
|
59723
|
+
|
|
59724
|
+
if (row === lastChild) {
|
|
59725
|
+
const section = row.parentNode.parentNode;
|
|
59726
|
+
const sectionOffset = dom.getElementOffset(section);
|
|
59727
|
+
let h1 = sectionOffset.top + sectionOffset.height;
|
|
59728
|
+
const rowOffset = dom.getElementOffset(row);
|
|
59729
|
+
let h2 = rowOffset.top + rowOffset.height;
|
|
59730
|
+
|
|
59731
|
+
if (h1 - h2 < 19) {
|
|
59732
|
+
tollAddButton.style.marginTop = '-14px';
|
|
59733
|
+
}
|
|
59734
|
+
}
|
|
59735
|
+
}
|
|
59308
59736
|
}
|
|
59309
59737
|
|
|
59310
59738
|
handleCellKeypress(e) {
|