@innovastudio/contentbox 1.3.18 → 1.3.21
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.21",
|
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.18",
|
50
50
|
"js-beautify": "^1.14.0"
|
51
51
|
}
|
52
52
|
}
|
@@ -10114,8 +10114,9 @@ class EditBox {
|
|
10114
10114
|
});
|
10115
10115
|
const btnModuleOk = modalEditModule.querySelector('.input-ok');
|
10116
10116
|
btnModuleOk.addEventListener('click', () => {
|
10117
|
-
let activeBox = this.builder.activeBox;
|
10118
|
-
let activeModule = activeBox.querySelector('.is-overlay-content[data-module]');
|
10117
|
+
// let activeBox = this.builder.activeBox;
|
10118
|
+
// let activeModule = activeBox.querySelector('.is-overlay-content[data-module]');
|
10119
|
+
let activeModule = document.querySelector('[data-module-active="1"]');
|
10119
10120
|
this.builder.editor.saveForUndo();
|
10120
10121
|
let modalIframe = modalEditModule.querySelector('iframe');
|
10121
10122
|
if (modalIframe.contentWindow.construct) modalIframe.contentWindow.construct();
|
@@ -10667,9 +10668,10 @@ class EditBox {
|
|
10667
10668
|
|
10668
10669
|
refreshModule() {
|
10669
10670
|
const modalEditModule = document.querySelector('.is-modal.editmodule');
|
10670
|
-
const builderStuff = this.builderStuff;
|
10671
|
-
let
|
10672
|
-
|
10671
|
+
const builderStuff = this.builderStuff; // let activeBox = this.builder.activeBox;
|
10672
|
+
// let activeModule = activeBox.querySelector('.is-overlay-content[data-module]');
|
10673
|
+
|
10674
|
+
let activeModule = document.querySelector('[data-module-active="1"]');
|
10673
10675
|
let modalIframe = modalEditModule.querySelector('iframe');
|
10674
10676
|
if (modalIframe.contentWindow.construct) modalIframe.contentWindow.construct();
|
10675
10677
|
const hidModuleCode = builderStuff.querySelector('#hidModuleCode');
|
@@ -15429,7 +15431,7 @@ class Util {
|
|
15429
15431
|
let html = '';
|
15430
15432
|
html = `<div class="is-modal is-confirm" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true">
|
15431
15433
|
<div class="is-modal-content" style="padding-bottom:20px;">
|
15432
|
-
<
|
15434
|
+
<div style="margin: 20px 0 30px;font-size: 14px;">${message}</div>
|
15433
15435
|
<button title="${this.out('Delete')}" class="input-ok classic focus-warning">${this.out('Delete')}</button>
|
15434
15436
|
</div>
|
15435
15437
|
</div>`;
|
@@ -15437,7 +15439,7 @@ class Util {
|
|
15437
15439
|
if (yesno) {
|
15438
15440
|
html = `<div class="is-modal is-confirm" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true">
|
15439
15441
|
<div class="is-modal-content" style="padding-bottom:20px;">
|
15440
|
-
<
|
15442
|
+
<div style="margin: 20px 0 30px;font-size: 14px;">${message}</div>
|
15441
15443
|
<button title="${this.out('Cancel')}" class="input-cancel classic-secondary">${this.out('Cancel')}</button>
|
15442
15444
|
<button title="${yestext}" class="input-ok classic-primary">${yestext}</button>
|
15443
15445
|
</div>
|
@@ -15517,8 +15519,19 @@ class Util {
|
|
15517
15519
|
dom.addClass(pop, 'deactive');
|
15518
15520
|
}
|
15519
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
|
+
|
15520
15529
|
showPop(pop, cancelCallback, btn) {
|
15521
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
|
+
|
15522
15535
|
pop.style.display = 'flex';
|
15523
15536
|
dom.addClass(pop, 'active');
|
15524
15537
|
pop.setAttribute('aria-hidden', false);
|
@@ -15527,37 +15540,40 @@ class Util {
|
|
15527
15540
|
preventScroll: true
|
15528
15541
|
});
|
15529
15542
|
|
15530
|
-
|
15543
|
+
this.handlePopClickOut = e => {
|
15531
15544
|
if (!pop.contains(e.target) && !btn.contains(e.target)) {
|
15532
15545
|
// click outside
|
15533
15546
|
// hide
|
15534
|
-
this.hidePop(pop);
|
15535
|
-
|
15536
|
-
|
15547
|
+
this.hidePop(pop); // pop.removeEventListener('keydown', this.handlePopKeyDown);
|
15548
|
+
// document.removeEventListener('click', this.handlePopClickOut);
|
15549
|
+
|
15537
15550
|
if (cancelCallback) cancelCallback();
|
15538
15551
|
}
|
15539
15552
|
};
|
15540
15553
|
|
15541
|
-
|
15554
|
+
this.handlePopKeyDown = e => {
|
15542
15555
|
if (e.keyCode === 27) {
|
15543
15556
|
// escape key
|
15544
15557
|
// hide
|
15545
|
-
this.hidePop(pop);
|
15546
|
-
|
15547
|
-
|
15558
|
+
this.hidePop(pop); // pop.removeEventListener('keydown', this.handlePopKeyDown);
|
15559
|
+
// document.removeEventListener('click', this.handlePopClickOut);
|
15560
|
+
|
15548
15561
|
if (cancelCallback) cancelCallback();
|
15549
15562
|
}
|
15550
15563
|
};
|
15551
15564
|
|
15552
|
-
pop.addEventListener('keydown',
|
15553
|
-
document.addEventListener('click',
|
15565
|
+
pop.addEventListener('keydown', this.handlePopKeyDown);
|
15566
|
+
document.addEventListener('click', this.handlePopClickOut);
|
15554
15567
|
}
|
15555
15568
|
|
15556
15569
|
hidePop(pop) {
|
15557
15570
|
const dom = this.dom;
|
15558
15571
|
pop.style.display = '';
|
15559
15572
|
dom.removeClass(pop, 'active');
|
15560
|
-
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);
|
15561
15577
|
}
|
15562
15578
|
|
15563
15579
|
setupTabKeys(div) {
|
@@ -18165,6 +18181,17 @@ class Util {
|
|
18165
18181
|
|
18166
18182
|
}
|
18167
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
|
+
|
18168
18195
|
createElement(tag) {
|
18169
18196
|
return document.createElement(tag);
|
18170
18197
|
}
|
@@ -32896,12 +32923,12 @@ const renderSnippetPanel = builder => {
|
|
32896
32923
|
let chromeAgent = userAgentString.indexOf('Chrome') > -1;
|
32897
32924
|
if ((chromeAgent) && (safariAgent)) safariAgent = false;
|
32898
32925
|
*/
|
32926
|
+
// let safariAgent = false;
|
32899
32927
|
|
32900
32928
|
|
32901
|
-
let safariAgent = false;
|
32902
32929
|
let activeBuilderArea;
|
32903
32930
|
new Sortable(snippetlist, {
|
32904
|
-
forceFallback: safariAgent,
|
32931
|
+
// forceFallback: safariAgent,
|
32905
32932
|
group: {
|
32906
32933
|
name: 'shared',
|
32907
32934
|
pull: 'clone',
|
@@ -32910,6 +32937,18 @@ const renderSnippetPanel = builder => {
|
|
32910
32937
|
},
|
32911
32938
|
sort: false,
|
32912
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
|
+
},
|
32913
32952
|
onMove: () => {
|
32914
32953
|
let emptyinfo = document.querySelector('.row-add-initial'); // if there is empty info, remove it during snippet drag drop
|
32915
32954
|
// if(emptyinfo) emptyinfo.parentNode.removeChild(emptyinfo);
|
@@ -64209,7 +64248,7 @@ class Modal {
|
|
64209
64248
|
confirm(message, callback, animated) {
|
64210
64249
|
let html = `<div class="is-modal is-confirm" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true">
|
64211
64250
|
<div class="is-modal-content" style="padding-bottom:20px;">
|
64212
|
-
<
|
64251
|
+
<div style="margin: 20px 0 30px;font-size: 14px;">${message}</div>
|
64213
64252
|
<button title="${this.out('Delete')}" class="input-ok classic">${this.out('Delete')}</button>
|
64214
64253
|
</div>
|
64215
64254
|
</div>`;
|
@@ -80921,8 +80960,23 @@ class ContentBuilder {
|
|
80921
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']]];
|
80922
80961
|
}
|
80923
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);
|
80924
80976
|
}
|
80925
80977
|
|
80978
|
+
this.contentStuff = contentStuff;
|
80979
|
+
this.addStuff();
|
80926
80980
|
this.sortableObjects = [];
|
80927
80981
|
const util = new Util(this); // General utilities
|
80928
80982
|
|
@@ -81460,12 +81514,40 @@ class ContentBuilder {
|
|
81460
81514
|
scroll: true,
|
81461
81515
|
// invertSwap: true, /* https://github.com/SortableJS/Sortable/wiki/Swap-Thresholds-and-Direction#swap-threshold */
|
81462
81516
|
group: 'shared',
|
81463
|
-
direction: 'dummy',
|
81517
|
+
// direction: 'dummy',
|
81464
81518
|
animation: 300,
|
81465
81519
|
handle: '.row-handle',
|
81466
81520
|
// swapThreshold: 0.1, // this cause drag drop snippet sometimes difficult
|
81467
81521
|
// invertedSwapThreshold: 0.1,
|
81468
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
|
+
},
|
81469
81551
|
onStart: () => {
|
81470
81552
|
this.uo.saveForUndo(); // Even if cancelled, saveForUndo will make sure not to save if there is no change
|
81471
81553
|
|
@@ -83787,6 +83869,45 @@ class ContentBuilder {
|
|
83787
83869
|
// return currentScript.replace(currentScriptFile, '');
|
83788
83870
|
}
|
83789
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
|
+
|
83790
83911
|
}
|
83791
83912
|
|
83792
83913
|
var pace = {exports: {}};
|