@innovastudio/contentbuilder 1.2.15 → 1.2.16
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
|
@@ -121,29 +121,40 @@ button:focus {
|
|
|
121
121
|
display: flex;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
+
/*
|
|
124
125
|
.sortable-drag {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
background: transparent; // background:rgba(0,0,0,0.04);
|
|
127
|
+
outline:none !important;
|
|
128
|
+
* {
|
|
129
|
+
opacity:0;
|
|
130
|
+
}
|
|
131
|
+
.is-row-tool {
|
|
132
|
+
opacity:0;
|
|
133
|
+
}
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
.sortable-ghost {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
137
|
+
background: $ui-sortable-ghost-color;
|
|
138
|
+
width: 100%;
|
|
139
|
+
outline: none !important;
|
|
140
|
+
* {
|
|
141
|
+
outline: none !important;
|
|
142
|
+
}
|
|
143
|
+
.is-row-tool {
|
|
144
|
+
display:none !important;
|
|
145
|
+
}
|
|
145
146
|
}
|
|
146
147
|
|
|
148
|
+
.sortable-drag::before {
|
|
149
|
+
content: ' ';
|
|
150
|
+
width: 100%;
|
|
151
|
+
height: 100%;
|
|
152
|
+
position: absolute;
|
|
153
|
+
top: 0; left:0;
|
|
154
|
+
background: rgba(0, 0, 0 , 0.03);
|
|
155
|
+
transform-origin: top left;
|
|
156
|
+
}
|
|
157
|
+
*/
|
|
147
158
|
#_cbhtml .snippet-item {
|
|
148
159
|
cursor: move !important;
|
|
149
160
|
}
|
|
@@ -4196,8 +4196,19 @@ class Util {
|
|
|
4196
4196
|
dom.addClass(pop, 'deactive');
|
|
4197
4197
|
}
|
|
4198
4198
|
|
|
4199
|
+
clearAllEventListener(pop) {
|
|
4200
|
+
for (let i = 0; i < 10; i++) {
|
|
4201
|
+
pop.removeEventListener('keydown', this.handlePopKeyDown);
|
|
4202
|
+
document.removeEventListener('click', this.handlePopClickOut);
|
|
4203
|
+
}
|
|
4204
|
+
}
|
|
4205
|
+
|
|
4199
4206
|
showPop(pop, cancelCallback, btn) {
|
|
4200
4207
|
const dom = this.dom;
|
|
4208
|
+
if (pop.style.display === 'flex') return; // important
|
|
4209
|
+
|
|
4210
|
+
this.clearAllEventListener(pop); // for safety of uncleared events as a result of closing without hidePop()
|
|
4211
|
+
|
|
4201
4212
|
pop.style.display = 'flex';
|
|
4202
4213
|
dom.addClass(pop, 'active');
|
|
4203
4214
|
pop.setAttribute('aria-hidden', false);
|
|
@@ -4206,37 +4217,40 @@ class Util {
|
|
|
4206
4217
|
preventScroll: true
|
|
4207
4218
|
});
|
|
4208
4219
|
|
|
4209
|
-
|
|
4220
|
+
this.handlePopClickOut = e => {
|
|
4210
4221
|
if (!pop.contains(e.target) && !btn.contains(e.target)) {
|
|
4211
4222
|
// click outside
|
|
4212
4223
|
// hide
|
|
4213
|
-
this.hidePop(pop);
|
|
4214
|
-
|
|
4215
|
-
|
|
4224
|
+
this.hidePop(pop); // pop.removeEventListener('keydown', this.handlePopKeyDown);
|
|
4225
|
+
// document.removeEventListener('click', this.handlePopClickOut);
|
|
4226
|
+
|
|
4216
4227
|
if (cancelCallback) cancelCallback();
|
|
4217
4228
|
}
|
|
4218
4229
|
};
|
|
4219
4230
|
|
|
4220
|
-
|
|
4231
|
+
this.handlePopKeyDown = e => {
|
|
4221
4232
|
if (e.keyCode === 27) {
|
|
4222
4233
|
// escape key
|
|
4223
4234
|
// hide
|
|
4224
|
-
this.hidePop(pop);
|
|
4225
|
-
|
|
4226
|
-
|
|
4235
|
+
this.hidePop(pop); // pop.removeEventListener('keydown', this.handlePopKeyDown);
|
|
4236
|
+
// document.removeEventListener('click', this.handlePopClickOut);
|
|
4237
|
+
|
|
4227
4238
|
if (cancelCallback) cancelCallback();
|
|
4228
4239
|
}
|
|
4229
4240
|
};
|
|
4230
4241
|
|
|
4231
|
-
pop.addEventListener('keydown',
|
|
4232
|
-
document.addEventListener('click',
|
|
4242
|
+
pop.addEventListener('keydown', this.handlePopKeyDown);
|
|
4243
|
+
document.addEventListener('click', this.handlePopClickOut);
|
|
4233
4244
|
}
|
|
4234
4245
|
|
|
4235
4246
|
hidePop(pop) {
|
|
4236
4247
|
const dom = this.dom;
|
|
4237
4248
|
pop.style.display = '';
|
|
4238
4249
|
dom.removeClass(pop, 'active');
|
|
4239
|
-
pop.setAttribute('aria-hidden', true);
|
|
4250
|
+
pop.setAttribute('aria-hidden', true); // pop.removeEventListener('keydown', this.handlePopKeyDown);
|
|
4251
|
+
// document.removeEventListener('click', this.handlePopClickOut);
|
|
4252
|
+
|
|
4253
|
+
this.clearAllEventListener(pop);
|
|
4240
4254
|
}
|
|
4241
4255
|
|
|
4242
4256
|
setupTabKeys(div) {
|
|
@@ -6844,6 +6858,17 @@ class Util {
|
|
|
6844
6858
|
|
|
6845
6859
|
}
|
|
6846
6860
|
class Dom {
|
|
6861
|
+
getScale(container) {
|
|
6862
|
+
let matrix = window.getComputedStyle(container).transform;
|
|
6863
|
+
let values = matrix.split('(')[1];
|
|
6864
|
+
values = values.split(')')[0];
|
|
6865
|
+
values = values.split(',');
|
|
6866
|
+
let a = values[0];
|
|
6867
|
+
let b = values[1];
|
|
6868
|
+
let scale = Math.sqrt(a * a + b * b);
|
|
6869
|
+
return scale;
|
|
6870
|
+
}
|
|
6871
|
+
|
|
6847
6872
|
createElement(tag) {
|
|
6848
6873
|
return document.createElement(tag);
|
|
6849
6874
|
}
|
|
@@ -21575,12 +21600,12 @@ const renderSnippetPanel = builder => {
|
|
|
21575
21600
|
let chromeAgent = userAgentString.indexOf('Chrome') > -1;
|
|
21576
21601
|
if ((chromeAgent) && (safariAgent)) safariAgent = false;
|
|
21577
21602
|
*/
|
|
21603
|
+
// let safariAgent = false;
|
|
21578
21604
|
|
|
21579
21605
|
|
|
21580
|
-
let safariAgent = false;
|
|
21581
21606
|
let activeBuilderArea;
|
|
21582
21607
|
new Sortable(snippetlist, {
|
|
21583
|
-
forceFallback: safariAgent,
|
|
21608
|
+
// forceFallback: safariAgent,
|
|
21584
21609
|
group: {
|
|
21585
21610
|
name: 'shared',
|
|
21586
21611
|
pull: 'clone',
|
|
@@ -21589,6 +21614,19 @@ const renderSnippetPanel = builder => {
|
|
|
21589
21614
|
},
|
|
21590
21615
|
sort: false,
|
|
21591
21616
|
animation: 150,
|
|
21617
|
+
onChoose: () => {
|
|
21618
|
+
// Make moving draggable item scaled & positioned correctly (due to zoom value)
|
|
21619
|
+
const newCss = `
|
|
21620
|
+
<style id="css-scale">
|
|
21621
|
+
.sortable-drag::before {
|
|
21622
|
+
transform: scale(1);
|
|
21623
|
+
}
|
|
21624
|
+
</style>
|
|
21625
|
+
`;
|
|
21626
|
+
const oldCss = builder.contentStuff.querySelector('#css-scale');
|
|
21627
|
+
if (oldCss) oldCss.parentNode.removeChild(oldCss);
|
|
21628
|
+
builder.contentStuff.insertAdjacentHTML('afterbegin', newCss);
|
|
21629
|
+
},
|
|
21592
21630
|
onMove: () => {
|
|
21593
21631
|
let emptyinfo = document.querySelector('.row-add-initial'); // if there is empty info, remove it during snippet drag drop
|
|
21594
21632
|
// if(emptyinfo) emptyinfo.parentNode.removeChild(emptyinfo);
|
|
@@ -69600,8 +69638,23 @@ class ContentBuilder {
|
|
|
69600
69638
|
['column sixth', 'column two-sixth'], ['column fifth', 'column two-fifth'], ['column fourth', 'column two-fourth'], ['column third', 'column two-third'], ['column half', 'column half'], ['column two-third', 'column third'], ['column two-fourth', 'column fourth'], ['column two-fifth', 'column fifth'], ['column two-sixth', 'column sixth']]];
|
|
69601
69639
|
}
|
|
69602
69640
|
}
|
|
69641
|
+
} // Experimental for iframe
|
|
69642
|
+
|
|
69643
|
+
|
|
69644
|
+
let doc;
|
|
69645
|
+
if (this.iframeDocument) doc = this.iframeDocument;else doc = document;
|
|
69646
|
+
this.doc = doc; // Content stuff
|
|
69647
|
+
|
|
69648
|
+
let contentStuff = doc.querySelector('.content-stuff');
|
|
69649
|
+
|
|
69650
|
+
if (!contentStuff) {
|
|
69651
|
+
contentStuff = document.createElement('div');
|
|
69652
|
+
contentStuff.className = 'content-stuff is-ui';
|
|
69653
|
+
doc.body.appendChild(contentStuff);
|
|
69603
69654
|
}
|
|
69604
69655
|
|
|
69656
|
+
this.contentStuff = contentStuff;
|
|
69657
|
+
this.addStuff();
|
|
69605
69658
|
this.sortableObjects = [];
|
|
69606
69659
|
const util = new Util(this); // General utilities
|
|
69607
69660
|
|
|
@@ -70139,12 +70192,32 @@ class ContentBuilder {
|
|
|
70139
70192
|
scroll: true,
|
|
70140
70193
|
// invertSwap: true, /* https://github.com/SortableJS/Sortable/wiki/Swap-Thresholds-and-Direction#swap-threshold */
|
|
70141
70194
|
group: 'shared',
|
|
70142
|
-
direction: 'dummy',
|
|
70195
|
+
// direction: 'dummy',
|
|
70143
70196
|
animation: 300,
|
|
70144
70197
|
handle: '.row-handle',
|
|
70145
70198
|
// swapThreshold: 0.1, // this cause drag drop snippet sometimes difficult
|
|
70146
70199
|
// invertedSwapThreshold: 0.1,
|
|
70147
70200
|
sort: true,
|
|
70201
|
+
//new
|
|
70202
|
+
swapThreshold: 0.5,
|
|
70203
|
+
// & comment the direction setting above
|
|
70204
|
+
onChoose: () => {
|
|
70205
|
+
// Get zoom (scale) value
|
|
70206
|
+
const area = this.doc.querySelector('.is-builder'); // get one of the builder area
|
|
70207
|
+
|
|
70208
|
+
const scale = dom.getScale(area); // Make moving draggable item scaled & positioned correctly (due to zoom value)
|
|
70209
|
+
|
|
70210
|
+
const newCss = `
|
|
70211
|
+
<style id="css-scale">
|
|
70212
|
+
.sortable-drag::before {
|
|
70213
|
+
transform: scale(${scale});
|
|
70214
|
+
}
|
|
70215
|
+
</style>
|
|
70216
|
+
`;
|
|
70217
|
+
const oldCss = this.contentStuff.querySelector('#css-scale');
|
|
70218
|
+
if (oldCss) oldCss.parentNode.removeChild(oldCss);
|
|
70219
|
+
this.contentStuff.insertAdjacentHTML('afterbegin', newCss);
|
|
70220
|
+
},
|
|
70148
70221
|
onStart: () => {
|
|
70149
70222
|
this.uo.saveForUndo(); // Even if cancelled, saveForUndo will make sure not to save if there is no change
|
|
70150
70223
|
|
|
@@ -72466,6 +72539,45 @@ class ContentBuilder {
|
|
|
72466
72539
|
// return currentScript.replace(currentScriptFile, '');
|
|
72467
72540
|
}
|
|
72468
72541
|
|
|
72542
|
+
addStuff() {
|
|
72543
|
+
const css = `
|
|
72544
|
+
<style>
|
|
72545
|
+
/* sortable */
|
|
72546
|
+
.sortable-drag {
|
|
72547
|
+
background: transparent;
|
|
72548
|
+
outline:none !important;
|
|
72549
|
+
}
|
|
72550
|
+
.sortable-drag * {
|
|
72551
|
+
opacity:0;
|
|
72552
|
+
}
|
|
72553
|
+
|
|
72554
|
+
.sortable-ghost {
|
|
72555
|
+
background: rgba(0, 0, 0 , 0.03);
|
|
72556
|
+
width: 100%;
|
|
72557
|
+
outline: none !important;
|
|
72558
|
+
}
|
|
72559
|
+
.sortable-ghost * {
|
|
72560
|
+
outline: none !important;
|
|
72561
|
+
|
|
72562
|
+
}
|
|
72563
|
+
.sortable-ghost .is-row-tool {
|
|
72564
|
+
display:none !important;
|
|
72565
|
+
}
|
|
72566
|
+
|
|
72567
|
+
.sortable-drag::before {
|
|
72568
|
+
content: ' ';
|
|
72569
|
+
width: 100%;
|
|
72570
|
+
height: 100%;
|
|
72571
|
+
position: absolute;
|
|
72572
|
+
top: 0; left:0;
|
|
72573
|
+
background: rgba(0, 0, 0 , 0.03);
|
|
72574
|
+
transform-origin: top left;
|
|
72575
|
+
}
|
|
72576
|
+
</style>
|
|
72577
|
+
`;
|
|
72578
|
+
this.contentStuff.insertAdjacentHTML('afterbegin', css);
|
|
72579
|
+
}
|
|
72580
|
+
|
|
72469
72581
|
}
|
|
72470
72582
|
// var run = (opts = {}) => {
|
|
72471
72583
|
// return new ContentBuilder(opts);
|