@innovastudio/contentbox 1.3.19 → 1.3.20
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
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@innovastudio/contentbox",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.20",
|
4
4
|
"type": "module",
|
5
5
|
"description": "",
|
6
6
|
"main": "public/contentbox/contentbox.esm.js",
|
@@ -46,7 +46,7 @@
|
|
46
46
|
"webpack-dev-server": "^4.0.0"
|
47
47
|
},
|
48
48
|
"dependencies": {
|
49
|
-
"@innovastudio/contentbuilder": "^1.2.
|
49
|
+
"@innovastudio/contentbuilder": "^1.2.17",
|
50
50
|
"js-beautify": "^1.14.0"
|
51
51
|
}
|
52
52
|
}
|
@@ -15519,8 +15519,19 @@ class Util {
|
|
15519
15519
|
dom.addClass(pop, 'deactive');
|
15520
15520
|
}
|
15521
15521
|
|
15522
|
+
clearAllEventListener(pop) {
|
15523
|
+
for (let i = 0; i < 10; i++) {
|
15524
|
+
pop.removeEventListener('keydown', this.handlePopKeyDown);
|
15525
|
+
document.removeEventListener('click', this.handlePopClickOut);
|
15526
|
+
}
|
15527
|
+
}
|
15528
|
+
|
15522
15529
|
showPop(pop, cancelCallback, btn) {
|
15523
15530
|
const dom = this.dom;
|
15531
|
+
if (pop.style.display === 'flex') return; // important
|
15532
|
+
|
15533
|
+
this.clearAllEventListener(pop); // for safety of uncleared events as a result of closing without hidePop()
|
15534
|
+
|
15524
15535
|
pop.style.display = 'flex';
|
15525
15536
|
dom.addClass(pop, 'active');
|
15526
15537
|
pop.setAttribute('aria-hidden', false);
|
@@ -15529,37 +15540,40 @@ class Util {
|
|
15529
15540
|
preventScroll: true
|
15530
15541
|
});
|
15531
15542
|
|
15532
|
-
|
15543
|
+
this.handlePopClickOut = e => {
|
15533
15544
|
if (!pop.contains(e.target) && !btn.contains(e.target)) {
|
15534
15545
|
// click outside
|
15535
15546
|
// hide
|
15536
|
-
this.hidePop(pop);
|
15537
|
-
|
15538
|
-
|
15547
|
+
this.hidePop(pop); // pop.removeEventListener('keydown', this.handlePopKeyDown);
|
15548
|
+
// document.removeEventListener('click', this.handlePopClickOut);
|
15549
|
+
|
15539
15550
|
if (cancelCallback) cancelCallback();
|
15540
15551
|
}
|
15541
15552
|
};
|
15542
15553
|
|
15543
|
-
|
15554
|
+
this.handlePopKeyDown = e => {
|
15544
15555
|
if (e.keyCode === 27) {
|
15545
15556
|
// escape key
|
15546
15557
|
// hide
|
15547
|
-
this.hidePop(pop);
|
15548
|
-
|
15549
|
-
|
15558
|
+
this.hidePop(pop); // pop.removeEventListener('keydown', this.handlePopKeyDown);
|
15559
|
+
// document.removeEventListener('click', this.handlePopClickOut);
|
15560
|
+
|
15550
15561
|
if (cancelCallback) cancelCallback();
|
15551
15562
|
}
|
15552
15563
|
};
|
15553
15564
|
|
15554
|
-
pop.addEventListener('keydown',
|
15555
|
-
document.addEventListener('click',
|
15565
|
+
pop.addEventListener('keydown', this.handlePopKeyDown);
|
15566
|
+
document.addEventListener('click', this.handlePopClickOut);
|
15556
15567
|
}
|
15557
15568
|
|
15558
15569
|
hidePop(pop) {
|
15559
15570
|
const dom = this.dom;
|
15560
15571
|
pop.style.display = '';
|
15561
15572
|
dom.removeClass(pop, 'active');
|
15562
|
-
pop.setAttribute('aria-hidden', true);
|
15573
|
+
pop.setAttribute('aria-hidden', true); // pop.removeEventListener('keydown', this.handlePopKeyDown);
|
15574
|
+
// document.removeEventListener('click', this.handlePopClickOut);
|
15575
|
+
|
15576
|
+
this.clearAllEventListener(pop);
|
15563
15577
|
}
|
15564
15578
|
|
15565
15579
|
setupTabKeys(div) {
|
@@ -18167,6 +18181,17 @@ class Util {
|
|
18167
18181
|
|
18168
18182
|
}
|
18169
18183
|
class Dom {
|
18184
|
+
getScale(container) {
|
18185
|
+
let matrix = window.getComputedStyle(container).transform;
|
18186
|
+
let values = matrix.split('(')[1];
|
18187
|
+
values = values.split(')')[0];
|
18188
|
+
values = values.split(',');
|
18189
|
+
let a = values[0];
|
18190
|
+
let b = values[1];
|
18191
|
+
let scale = Math.sqrt(a * a + b * b);
|
18192
|
+
return scale;
|
18193
|
+
}
|
18194
|
+
|
18170
18195
|
createElement(tag) {
|
18171
18196
|
return document.createElement(tag);
|
18172
18197
|
}
|
@@ -32898,12 +32923,12 @@ const renderSnippetPanel = builder => {
|
|
32898
32923
|
let chromeAgent = userAgentString.indexOf('Chrome') > -1;
|
32899
32924
|
if ((chromeAgent) && (safariAgent)) safariAgent = false;
|
32900
32925
|
*/
|
32926
|
+
// let safariAgent = false;
|
32901
32927
|
|
32902
32928
|
|
32903
|
-
let safariAgent = false;
|
32904
32929
|
let activeBuilderArea;
|
32905
32930
|
new Sortable(snippetlist, {
|
32906
|
-
forceFallback: safariAgent,
|
32931
|
+
// forceFallback: safariAgent,
|
32907
32932
|
group: {
|
32908
32933
|
name: 'shared',
|
32909
32934
|
pull: 'clone',
|
@@ -32912,6 +32937,18 @@ const renderSnippetPanel = builder => {
|
|
32912
32937
|
},
|
32913
32938
|
sort: false,
|
32914
32939
|
animation: 150,
|
32940
|
+
onChoose: () => {
|
32941
|
+
// Make moving draggable item scaled & positioned correctly (due to zoom value)
|
32942
|
+
// const newCss = `
|
32943
|
+
// <style id="css-scale">
|
32944
|
+
// .sortable-drag::before {
|
32945
|
+
// transform: scale(1);
|
32946
|
+
// }
|
32947
|
+
// </style>
|
32948
|
+
// `;
|
32949
|
+
const oldCss = builder.contentStuff.querySelector('#css-scale');
|
32950
|
+
if (oldCss) oldCss.parentNode.removeChild(oldCss); // builder.contentStuff.insertAdjacentHTML('afterbegin', newCss);
|
32951
|
+
},
|
32915
32952
|
onMove: () => {
|
32916
32953
|
let emptyinfo = document.querySelector('.row-add-initial'); // if there is empty info, remove it during snippet drag drop
|
32917
32954
|
// if(emptyinfo) emptyinfo.parentNode.removeChild(emptyinfo);
|
@@ -80923,8 +80960,23 @@ class ContentBuilder {
|
|
80923
80960
|
['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']]];
|
80924
80961
|
}
|
80925
80962
|
}
|
80963
|
+
} // Experimental for iframe
|
80964
|
+
|
80965
|
+
|
80966
|
+
let doc;
|
80967
|
+
if (this.iframeDocument) doc = this.iframeDocument;else doc = document;
|
80968
|
+
this.doc = doc; // Content stuff
|
80969
|
+
|
80970
|
+
let contentStuff = doc.querySelector('.content-stuff');
|
80971
|
+
|
80972
|
+
if (!contentStuff) {
|
80973
|
+
contentStuff = document.createElement('div');
|
80974
|
+
contentStuff.className = 'content-stuff is-ui';
|
80975
|
+
doc.body.appendChild(contentStuff);
|
80926
80976
|
}
|
80927
80977
|
|
80978
|
+
this.contentStuff = contentStuff;
|
80979
|
+
this.addStuff();
|
80928
80980
|
this.sortableObjects = [];
|
80929
80981
|
const util = new Util(this); // General utilities
|
80930
80982
|
|
@@ -81462,12 +81514,40 @@ class ContentBuilder {
|
|
81462
81514
|
scroll: true,
|
81463
81515
|
// invertSwap: true, /* https://github.com/SortableJS/Sortable/wiki/Swap-Thresholds-and-Direction#swap-threshold */
|
81464
81516
|
group: 'shared',
|
81465
|
-
direction: 'dummy',
|
81517
|
+
// direction: 'dummy',
|
81466
81518
|
animation: 300,
|
81467
81519
|
handle: '.row-handle',
|
81468
81520
|
// swapThreshold: 0.1, // this cause drag drop snippet sometimes difficult
|
81469
81521
|
// invertedSwapThreshold: 0.1,
|
81470
81522
|
sort: true,
|
81523
|
+
//new
|
81524
|
+
swapThreshold: 0.5,
|
81525
|
+
// & comment the direction setting above
|
81526
|
+
onChoose: () => {
|
81527
|
+
// Get zoom (scale) value
|
81528
|
+
let scale;
|
81529
|
+
|
81530
|
+
if (this.opts.page !== '') {
|
81531
|
+
const wrapper = this.doc.querySelector(this.opts.page);
|
81532
|
+
scale = dom$L.getScale(wrapper);
|
81533
|
+
} else {
|
81534
|
+
const area = this.doc.querySelector('.is-builder'); // get one of the builder area
|
81535
|
+
|
81536
|
+
scale = dom$L.getScale(area);
|
81537
|
+
} // Make moving draggable item scaled & positioned correctly (due to zoom value)
|
81538
|
+
|
81539
|
+
|
81540
|
+
const newCss = `
|
81541
|
+
<style id="css-scale">
|
81542
|
+
.sortable-drag::before {
|
81543
|
+
transform: scale(${scale});
|
81544
|
+
}
|
81545
|
+
</style>
|
81546
|
+
`;
|
81547
|
+
const oldCss = this.contentStuff.querySelector('#css-scale');
|
81548
|
+
if (oldCss) oldCss.parentNode.removeChild(oldCss);
|
81549
|
+
this.contentStuff.insertAdjacentHTML('afterbegin', newCss);
|
81550
|
+
},
|
81471
81551
|
onStart: () => {
|
81472
81552
|
this.uo.saveForUndo(); // Even if cancelled, saveForUndo will make sure not to save if there is no change
|
81473
81553
|
|
@@ -83789,6 +83869,45 @@ class ContentBuilder {
|
|
83789
83869
|
// return currentScript.replace(currentScriptFile, '');
|
83790
83870
|
}
|
83791
83871
|
|
83872
|
+
addStuff() {
|
83873
|
+
const css = `
|
83874
|
+
<style>
|
83875
|
+
/* sortable */
|
83876
|
+
.sortable-drag {
|
83877
|
+
background: transparent;
|
83878
|
+
outline:none !important;
|
83879
|
+
}
|
83880
|
+
.sortable-drag * {
|
83881
|
+
opacity:0;
|
83882
|
+
}
|
83883
|
+
|
83884
|
+
.sortable-ghost {
|
83885
|
+
background: rgba(0, 0, 0 , 0.03);
|
83886
|
+
width: 100%;
|
83887
|
+
outline: none !important;
|
83888
|
+
}
|
83889
|
+
.sortable-ghost * {
|
83890
|
+
outline: none !important;
|
83891
|
+
|
83892
|
+
}
|
83893
|
+
.sortable-ghost .is-row-tool {
|
83894
|
+
display:none !important;
|
83895
|
+
}
|
83896
|
+
|
83897
|
+
.sortable-drag::before {
|
83898
|
+
content: ' ';
|
83899
|
+
width: 100%;
|
83900
|
+
height: 100%;
|
83901
|
+
position: absolute;
|
83902
|
+
top: 0; left:0;
|
83903
|
+
background: rgba(0, 0, 0 , 0.03);
|
83904
|
+
transform-origin: top left;
|
83905
|
+
}
|
83906
|
+
</style>
|
83907
|
+
`;
|
83908
|
+
this.contentStuff.insertAdjacentHTML('afterbegin', css);
|
83909
|
+
}
|
83910
|
+
|
83792
83911
|
}
|
83793
83912
|
|
83794
83913
|
var pace = {exports: {}};
|