@innovastudio/contentbox 1.6.57 → 1.6.59
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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@innovastudio/contentbox",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.59",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "public/contentbox/contentbox.esm.js",
|
|
7
7
|
"files": [
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"ws": "^8.13.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@innovastudio/contentbuilder": "^1.5.
|
|
55
|
+
"@innovastudio/contentbuilder": "^1.5.51",
|
|
56
56
|
"js-beautify": "^1.14.0"
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -30000,6 +30000,24 @@ class Dom {
|
|
|
30000
30000
|
constructor(builder) {
|
|
30001
30001
|
this.builder = builder;
|
|
30002
30002
|
}
|
|
30003
|
+
detectMobileOrTablet() {
|
|
30004
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
30005
|
+
const isIOS = /ipad|iphone|ipod/.test(userAgent) && !window.MSStream;
|
|
30006
|
+
const isAndroid = /android/.test(userAgent);
|
|
30007
|
+
const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
|
|
30008
|
+
const screenWidth = window.innerWidth <= 1600;
|
|
30009
|
+
if (isIOS || isAndroid) {
|
|
30010
|
+
return true; // Definitely a mobile or tablet
|
|
30011
|
+
}
|
|
30012
|
+
|
|
30013
|
+
// Additional check for other touch devices with screen width under 1600px
|
|
30014
|
+
if (isTouchDevice && screenWidth) {
|
|
30015
|
+
return true; // Likely a mobile or tablet
|
|
30016
|
+
}
|
|
30017
|
+
|
|
30018
|
+
return false; // Likely not a mobile or tablet
|
|
30019
|
+
}
|
|
30020
|
+
|
|
30003
30021
|
getScale(container) {
|
|
30004
30022
|
let matrix = window.getComputedStyle(container).transform;
|
|
30005
30023
|
if (matrix === 'none') return 1;
|
|
@@ -43393,6 +43411,24 @@ const renderSnippetPanel = (builder, snippetOpen) => {
|
|
|
43393
43411
|
}
|
|
43394
43412
|
});
|
|
43395
43413
|
}
|
|
43414
|
+
let snippetid;
|
|
43415
|
+
if (isMobile && builder.isContentBox) {
|
|
43416
|
+
const items = snippetlist.querySelectorAll('.snippet-item');
|
|
43417
|
+
items.forEach(item => {
|
|
43418
|
+
if (item.classList.contains('data-click')) return;
|
|
43419
|
+
item.addEventListener('touchstart', () => {
|
|
43420
|
+
snippetid = item.getAttribute('data-id');
|
|
43421
|
+
}, {
|
|
43422
|
+
passive: false
|
|
43423
|
+
});
|
|
43424
|
+
item.addEventListener('touchend', () => {
|
|
43425
|
+
builder.dropSnippet(snippetid);
|
|
43426
|
+
}, {
|
|
43427
|
+
passive: false
|
|
43428
|
+
});
|
|
43429
|
+
item.classList.add('data-click');
|
|
43430
|
+
});
|
|
43431
|
+
}
|
|
43396
43432
|
}
|
|
43397
43433
|
});
|
|
43398
43434
|
inpSnippet.setValue(defaultcatval + '');
|
|
@@ -43512,7 +43548,28 @@ const renderSnippetPanel = (builder, snippetOpen) => {
|
|
|
43512
43548
|
|
|
43513
43549
|
let activeBuilderArea;
|
|
43514
43550
|
let itemHeight;
|
|
43515
|
-
|
|
43551
|
+
const isMobile = dom.detectMobileOrTablet();
|
|
43552
|
+
let snippetid;
|
|
43553
|
+
let useClick = false;
|
|
43554
|
+
if (isMobile && builder.isContentBox) {
|
|
43555
|
+
const items = snippetlist.querySelectorAll('.snippet-item');
|
|
43556
|
+
items.forEach(item => {
|
|
43557
|
+
if (item.classList.contains('data-click')) return;
|
|
43558
|
+
item.addEventListener('touchstart', () => {
|
|
43559
|
+
snippetid = item.getAttribute('data-id');
|
|
43560
|
+
}, {
|
|
43561
|
+
passive: false
|
|
43562
|
+
});
|
|
43563
|
+
item.addEventListener('touchend', () => {
|
|
43564
|
+
builder.dropSnippet(snippetid);
|
|
43565
|
+
}, {
|
|
43566
|
+
passive: false
|
|
43567
|
+
});
|
|
43568
|
+
item.classList.add('data-click');
|
|
43569
|
+
});
|
|
43570
|
+
useClick = true;
|
|
43571
|
+
}
|
|
43572
|
+
if (!useClick) new Sortable(snippetlist, {
|
|
43516
43573
|
// forceFallback: safariAgent,
|
|
43517
43574
|
group: {
|
|
43518
43575
|
name: 'shared',
|
|
@@ -92968,6 +93025,7 @@ class Rte {
|
|
|
92968
93025
|
btnFront.forEach(btn => {
|
|
92969
93026
|
btn.addEventListener('click', () => {
|
|
92970
93027
|
let activeBlock = this.builder.doc.querySelector('.is-block.cloned');
|
|
93028
|
+
if (!activeBlock) activeBlock = this.builder.doc.querySelector('.is-block.active');
|
|
92971
93029
|
if (!activeBlock) return;
|
|
92972
93030
|
this.builder.forward(activeBlock);
|
|
92973
93031
|
});
|
|
@@ -92976,6 +93034,7 @@ class Rte {
|
|
|
92976
93034
|
btnBackward.forEach(btn => {
|
|
92977
93035
|
btn.addEventListener('click', () => {
|
|
92978
93036
|
let activeBlock = this.builder.doc.querySelector('.is-block.cloned');
|
|
93037
|
+
if (!activeBlock) activeBlock = this.builder.doc.querySelector('.is-block.active');
|
|
92979
93038
|
if (!activeBlock) return;
|
|
92980
93039
|
if (activeBlock.style.zIndex === '0') {
|
|
92981
93040
|
this.builder.moveUp(activeBlock);
|
|
@@ -93003,6 +93062,7 @@ class Rte {
|
|
|
93003
93062
|
btnDuplicate.forEach(btn => {
|
|
93004
93063
|
btn.addEventListener('click', () => {
|
|
93005
93064
|
let activeBlock = this.builder.doc.querySelector('.is-block.cloned');
|
|
93065
|
+
if (!activeBlock) activeBlock = this.builder.doc.querySelector('.is-block.active');
|
|
93006
93066
|
if (!activeBlock) return;
|
|
93007
93067
|
this.builder.duplicate(activeBlock);
|
|
93008
93068
|
});
|
|
@@ -99119,15 +99179,19 @@ class Resizeable {
|
|
|
99119
99179
|
resizing();
|
|
99120
99180
|
}
|
|
99121
99181
|
getScale(container) {
|
|
99122
|
-
|
|
99123
|
-
|
|
99124
|
-
|
|
99125
|
-
|
|
99126
|
-
|
|
99127
|
-
|
|
99128
|
-
|
|
99129
|
-
|
|
99130
|
-
|
|
99182
|
+
try {
|
|
99183
|
+
let matrix = window.getComputedStyle(container).transform;
|
|
99184
|
+
if (matrix === 'none') return false;
|
|
99185
|
+
let values = matrix.split('(')[1];
|
|
99186
|
+
values = values.split(')')[0];
|
|
99187
|
+
values = values.split(',');
|
|
99188
|
+
let a = values[0];
|
|
99189
|
+
let b = values[1];
|
|
99190
|
+
let scale = Math.sqrt(a * a + b * b);
|
|
99191
|
+
return scale;
|
|
99192
|
+
} catch (e) {
|
|
99193
|
+
return 1;
|
|
99194
|
+
}
|
|
99131
99195
|
}
|
|
99132
99196
|
destroy() {
|
|
99133
99197
|
const pane = this.pane;
|
|
@@ -109566,6 +109630,7 @@ class Draggable {
|
|
|
109566
109630
|
passive: false
|
|
109567
109631
|
});
|
|
109568
109632
|
this.doc.addEventListener('keydown', this.handleKeyDown);
|
|
109633
|
+
if (this.doc !== document) document.addEventListener('keydown', this.handleKeyDown);
|
|
109569
109634
|
}
|
|
109570
109635
|
refresh() {
|
|
109571
109636
|
this.elements = this.doc.querySelectorAll(this.selector);
|
|
@@ -109591,6 +109656,7 @@ class Draggable {
|
|
|
109591
109656
|
this.doc.removeEventListener('mousedown', this.handleSelect);
|
|
109592
109657
|
this.doc.removeEventListener('touchstart', this.handleSelect);
|
|
109593
109658
|
this.doc.removeEventListener('keydown', this.handleKeyDown);
|
|
109659
|
+
if (this.doc !== document) document.removeEventListener('keydown', this.handleKeyDown);
|
|
109594
109660
|
const blocks = this.doc.querySelectorAll(this.selector);
|
|
109595
109661
|
blocks.forEach(elm => elm.classList.remove('active'));
|
|
109596
109662
|
}
|
|
@@ -109901,14 +109967,18 @@ class Draggable {
|
|
|
109901
109967
|
let blocks = Array.from(this.doc.querySelectorAll(this.selector)).filter(elm => elm.classList.contains('active') && elm.classList.contains('editable'));
|
|
109902
109968
|
if (blocks.length > 0) return;
|
|
109903
109969
|
if (this.onBeforeChange) this.onBeforeChange();
|
|
109970
|
+
let isDeleted = false;
|
|
109904
109971
|
blocks = Array.from(this.doc.querySelectorAll(this.selector)).filter(elm => elm.classList.contains('active'));
|
|
109905
109972
|
blocks.forEach(element => {
|
|
109906
109973
|
element.removeEventListener('mousedown', this.handleDragStart);
|
|
109907
109974
|
element.removeEventListener('touchstart', this.handleDragStart);
|
|
109908
109975
|
if (this.onDelete) this.onDelete(element);
|
|
109909
109976
|
element.parentNode.removeChild(element);
|
|
109977
|
+
isDeleted = true;
|
|
109910
109978
|
});
|
|
109911
|
-
if (this.onChange)
|
|
109979
|
+
if (isDeleted && this.onChange) {
|
|
109980
|
+
this.onChange();
|
|
109981
|
+
}
|
|
109912
109982
|
}
|
|
109913
109983
|
handleKeyDown(event) {
|
|
109914
109984
|
if (event.key === 'Delete' || event.key === 'Backspace' || event.keyCode === 46) {
|
|
@@ -110284,7 +110354,8 @@ class EditableBlocks {
|
|
|
110284
110354
|
}
|
|
110285
110355
|
if (block.classList.contains('is-group')) return; // do not clone if block is shape
|
|
110286
110356
|
|
|
110287
|
-
|
|
110357
|
+
const isMobileOrTablet = this.detectMobileOrTablet();
|
|
110358
|
+
if (!block.classList.contains('clone') & !isMobileOrTablet) {
|
|
110288
110359
|
let clonedDiv = block.cloneNode(true);
|
|
110289
110360
|
clonedDiv.classList.add('clone');
|
|
110290
110361
|
block.parentNode.appendChild(clonedDiv);
|
|
@@ -110292,6 +110363,24 @@ class EditableBlocks {
|
|
|
110292
110363
|
this.refresh();
|
|
110293
110364
|
}
|
|
110294
110365
|
}
|
|
110366
|
+
detectMobileOrTablet() {
|
|
110367
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
110368
|
+
const isIOS = /ipad|iphone|ipod/.test(userAgent) && !window.MSStream;
|
|
110369
|
+
const isAndroid = /android/.test(userAgent);
|
|
110370
|
+
const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
|
|
110371
|
+
const screenWidth = window.innerWidth <= 1600;
|
|
110372
|
+
if (isIOS || isAndroid) {
|
|
110373
|
+
return true; // Definitely a mobile or tablet
|
|
110374
|
+
}
|
|
110375
|
+
|
|
110376
|
+
// Additional check for other touch devices with screen width under 1600px
|
|
110377
|
+
if (isTouchDevice && screenWidth) {
|
|
110378
|
+
return true; // Likely a mobile or tablet
|
|
110379
|
+
}
|
|
110380
|
+
|
|
110381
|
+
return false; // Likely not a mobile or tablet
|
|
110382
|
+
}
|
|
110383
|
+
|
|
110295
110384
|
selectClear() {
|
|
110296
110385
|
this.doc.querySelectorAll('.clone').forEach(elm => elm.parentNode.removeChild(elm));
|
|
110297
110386
|
this.doc.querySelectorAll('.cloned').forEach(elm => elm.classList.remove('cloned'));
|
|
@@ -118605,6 +118694,259 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
|
|
|
118605
118694
|
// return currentScript.replace(currentScriptFile, '');
|
|
118606
118695
|
}
|
|
118607
118696
|
|
|
118697
|
+
dropSnippet(snippetid) {
|
|
118698
|
+
// snippetJSON is snippet's JSON (from assets/minimalist-blocks/content.js) that store all snippets' html
|
|
118699
|
+
const result = this.opts.snippetJSON.snippets.filter(item => {
|
|
118700
|
+
if (item.id + '' === snippetid) return item;else return false;
|
|
118701
|
+
});
|
|
118702
|
+
let html = result[0].html;
|
|
118703
|
+
let noedit = result[0].noedit;
|
|
118704
|
+
let html2 = '';
|
|
118705
|
+
if (result[0].mode === 'canvas') {
|
|
118706
|
+
html2 = result[0].html2;
|
|
118707
|
+
if (!html2) {
|
|
118708
|
+
html2 = `
|
|
118709
|
+
<div class="row">
|
|
118710
|
+
<div class="column pt-0 pb-0 pl-0 pr-0 flex flex-col justify-center">
|
|
118711
|
+
<img src="${this.opts.snippetPath}images/img-2400x1350.png" alt="">
|
|
118712
|
+
</div>
|
|
118713
|
+
</div>
|
|
118714
|
+
`;
|
|
118715
|
+
}
|
|
118716
|
+
}
|
|
118717
|
+
let bSnippet;
|
|
118718
|
+
if (html.indexOf('"row') === -1) {
|
|
118719
|
+
bSnippet = true; // Just snippet (without row/column grid)
|
|
118720
|
+
} else {
|
|
118721
|
+
bSnippet = false; // Snippet is wrapped in row/colum
|
|
118722
|
+
}
|
|
118723
|
+
|
|
118724
|
+
if (this.opts.emailMode) bSnippet = false;
|
|
118725
|
+
|
|
118726
|
+
// check if is block
|
|
118727
|
+
let isBlock = false;
|
|
118728
|
+
if (html.includes('"is-block')) {
|
|
118729
|
+
isBlock = true;
|
|
118730
|
+
bSnippet = false;
|
|
118731
|
+
}
|
|
118732
|
+
|
|
118733
|
+
// Convert snippet into your defined 12 columns grid
|
|
118734
|
+
let rowClass = this.opts.row; //row
|
|
118735
|
+
let colClass = this.opts.cols; //['col s1', 'col s2', 'col s3', 'col s4', 'col s5', 'col s6', 'col s7', 'col s8', 'col s9', 'col s10', 'col s11', 'col s12']
|
|
118736
|
+
if (rowClass !== '' && colClass.length === 12) {
|
|
118737
|
+
// html = html.replace(new RegExp('row clearfix', 'g'), rowClass);
|
|
118738
|
+
html = html.replace(new RegExp('row clearfix', 'g'), 'row'); // backward
|
|
118739
|
+
html = html.replace(new RegExp('"row', 'g'), '"' + rowClass);
|
|
118740
|
+
html = html.replace(new RegExp('column full', 'g'), colClass[11]);
|
|
118741
|
+
html = html.replace(new RegExp('column half', 'g'), colClass[5]);
|
|
118742
|
+
html = html.replace(new RegExp('column third', 'g'), colClass[3]);
|
|
118743
|
+
html = html.replace(new RegExp('column fourth', 'g'), colClass[2]);
|
|
118744
|
+
html = html.replace(new RegExp('column fifth', 'g'), colClass[1]);
|
|
118745
|
+
html = html.replace(new RegExp('column sixth', 'g'), colClass[1]);
|
|
118746
|
+
html = html.replace(new RegExp('column two-third', 'g'), colClass[7]);
|
|
118747
|
+
html = html.replace(new RegExp('column two-fourth', 'g'), colClass[8]);
|
|
118748
|
+
html = html.replace(new RegExp('column two-fifth', 'g'), colClass[9]);
|
|
118749
|
+
html = html.replace(new RegExp('column two-sixth', 'g'), colClass[9]);
|
|
118750
|
+
}
|
|
118751
|
+
html = html.replace(/{id}/g, this.util.makeId());
|
|
118752
|
+
if (this.opts.onAdd) {
|
|
118753
|
+
html = this.opts.onAdd(html);
|
|
118754
|
+
}
|
|
118755
|
+
if (this.opts.snippetPathReplace.length > 0) {
|
|
118756
|
+
// try {
|
|
118757
|
+
if (this.opts.snippetPathReplace[0] !== '') {
|
|
118758
|
+
let regex = new RegExp(this.opts.snippetPathReplace[0], 'g');
|
|
118759
|
+
html = html.replace(regex, this.opts.snippetPathReplace[1]);
|
|
118760
|
+
let string1 = this.opts.snippetPathReplace[0].replace(/\//g, '%2F');
|
|
118761
|
+
let string2 = this.opts.snippetPathReplace[1].replace(/\//g, '%2F');
|
|
118762
|
+
let regex2 = new RegExp(string1, 'g');
|
|
118763
|
+
html = html.replace(regex2, string2);
|
|
118764
|
+
}
|
|
118765
|
+
// } catch (e) { 1; }
|
|
118766
|
+
}
|
|
118767
|
+
|
|
118768
|
+
// this.addSnippet(html, bSnippet, noedit);
|
|
118769
|
+
|
|
118770
|
+
if (bSnippet) {
|
|
118771
|
+
// Just snippet (without row/column grid), ex. buttons, line, social, video, map.
|
|
118772
|
+
// Can be inserted after current row, column (cell), element, or last row.
|
|
118773
|
+
|
|
118774
|
+
html = `<div class="${this.opts.row}"><div class="${this.opts.cols[this.opts.cols.length - 1]}"${noedit ? ' data-noedit' : ''}>${html}</div></div>`;
|
|
118775
|
+
} else if (isBlock) ; else {
|
|
118776
|
+
// Snippet is wrapped in row/colum (may contain custom code or has [data-html] attribute)
|
|
118777
|
+
// Can only be inserted after current row or last row (not on column or element).
|
|
118778
|
+
|
|
118779
|
+
let snippet = this.dom.createElement('div');
|
|
118780
|
+
snippet.innerHTML = html;
|
|
118781
|
+
let blocks = snippet.querySelectorAll('[data-html]');
|
|
118782
|
+
Array.prototype.forEach.call(blocks, block => {
|
|
118783
|
+
// Render custom code block
|
|
118784
|
+
html = decodeURIComponent(block.getAttribute('data-html'));
|
|
118785
|
+
html = html.replace(/{id}/g, this.util.makeId());
|
|
118786
|
+
html = html.replace(/<script>/g, `${this.nonce ? `<script nonce="${this.nonce}">` : '<script>'}`);
|
|
118787
|
+
for (var i = 1; i <= 20; i++) {
|
|
118788
|
+
html = html.replace('[%HTML' + i + '%]', block.getAttribute('data-html-' + i) === undefined ? '' : decodeURIComponent(block.getAttribute('data-html-' + i))); //render editable area
|
|
118789
|
+
}
|
|
118790
|
+
|
|
118791
|
+
block.innerHTML = html;
|
|
118792
|
+
});
|
|
118793
|
+
html = snippet.innerHTML;
|
|
118794
|
+
}
|
|
118795
|
+
let activeBox = this.doc.querySelector('.box-select');
|
|
118796
|
+
if (!activeBox) {
|
|
118797
|
+
activeBox = this.activeBox;
|
|
118798
|
+
if (!this.doc.body.contains(activeBox)) activeBox = null; // box deleted
|
|
118799
|
+
}
|
|
118800
|
+
|
|
118801
|
+
if (!activeBox) {
|
|
118802
|
+
this.doc.querySelectorAll('.is-box').forEach(box => {
|
|
118803
|
+
if (this.isMoreThan50PercentVisible(box)) {
|
|
118804
|
+
activeBox = box;
|
|
118805
|
+
}
|
|
118806
|
+
});
|
|
118807
|
+
}
|
|
118808
|
+
const activeRow = this.doc.querySelector('.row-active');
|
|
118809
|
+
if (activeRow) {
|
|
118810
|
+
if (html2) html = html2; // if it is canvas block, change it to normal using html2
|
|
118811
|
+
this.addRow(html, activeBox);
|
|
118812
|
+
} else {
|
|
118813
|
+
if (activeBox) {
|
|
118814
|
+
if (activeBox.classList.contains('box-canvas')) {
|
|
118815
|
+
// Canvas Mode
|
|
118816
|
+
|
|
118817
|
+
let snippet = this.dom.createElement('div');
|
|
118818
|
+
snippet.innerHTML = html;
|
|
118819
|
+
let blocks = snippet.querySelectorAll('[data-html]');
|
|
118820
|
+
Array.prototype.forEach.call(blocks, block => {
|
|
118821
|
+
// Render custom code block
|
|
118822
|
+
html = decodeURIComponent(block.getAttribute('data-html'));
|
|
118823
|
+
html = html.replace(/{id}/g, this.util.makeId());
|
|
118824
|
+
html = html.replace(/<script>/g, `${this.nonce ? `<script nonce="${this.nonce}">` : '<script>'}`);
|
|
118825
|
+
for (var i = 1; i <= 20; i++) {
|
|
118826
|
+
html = html.replace('[%HTML' + i + '%]', block.getAttribute('data-html-' + i) === undefined ? '' : decodeURIComponent(block.getAttribute('data-html-' + i))); //render editable area
|
|
118827
|
+
}
|
|
118828
|
+
|
|
118829
|
+
block.innerHTML = html;
|
|
118830
|
+
});
|
|
118831
|
+
html = snippet.innerHTML;
|
|
118832
|
+
this.uo.saveForUndo();
|
|
118833
|
+
activeBox.querySelectorAll('.is-container.container-new').forEach(elm => elm.classList.remove('container-new'));
|
|
118834
|
+
if (isBlock) {
|
|
118835
|
+
this.eb.addBlock(html, activeBox);
|
|
118836
|
+
} else {
|
|
118837
|
+
const blockTemplate = `
|
|
118838
|
+
<div class="is-block block-steady height-auto" data-new-dummy="1" style="top: 20%; left: 20%; width: 760px;">
|
|
118839
|
+
<div class="is-container container-new size-18 leading-14">
|
|
118840
|
+
[%CONTENT%]
|
|
118841
|
+
</div>
|
|
118842
|
+
</div>
|
|
118843
|
+
`; // data-new-dummy will be used by onSort to apply top/left position (snippetpanel.js)
|
|
118844
|
+
// html = blockTemplate.replace('[%CONTENT%]', html);
|
|
118845
|
+
|
|
118846
|
+
this.eb.addBlock(blockTemplate, activeBox);
|
|
118847
|
+
const builders = activeBox.querySelectorAll('.is-container.container-new');
|
|
118848
|
+
builders.forEach(builder => {
|
|
118849
|
+
// After snippet has been added, re-apply behavior on builder areas
|
|
118850
|
+
|
|
118851
|
+
var range = document.createRange();
|
|
118852
|
+
range.setStart(builder, 0);
|
|
118853
|
+
builder.appendChild(range.createContextualFragment(html));
|
|
118854
|
+
this.applyBehaviorOn(builder);
|
|
118855
|
+
builder.classList.remove('container-new');
|
|
118856
|
+
});
|
|
118857
|
+
}
|
|
118858
|
+
this.opts.onChange();
|
|
118859
|
+
this.opts.onRender();
|
|
118860
|
+
if (this.opts.onBlockCanvasAdd) this.opts.onBlockCanvasAdd();
|
|
118861
|
+
} else {
|
|
118862
|
+
let container = activeBox.querySelector('.builder-active');
|
|
118863
|
+
if (container) {
|
|
118864
|
+
if (html2) html = html2;
|
|
118865
|
+
this.addRow(html, activeBox);
|
|
118866
|
+
} else {
|
|
118867
|
+
container = activeBox.querySelector('.is-container');
|
|
118868
|
+
if (container) {
|
|
118869
|
+
if (html2) html = html2;
|
|
118870
|
+
this.addRow(html, activeBox);
|
|
118871
|
+
}
|
|
118872
|
+
}
|
|
118873
|
+
}
|
|
118874
|
+
} else {
|
|
118875
|
+
// No Active Box => Add Section
|
|
118876
|
+
|
|
118877
|
+
let sectionTemplate = this.settings.sectionTemplate;
|
|
118878
|
+
const occurrences = this.dom.countOccurrences(html, 'column');
|
|
118879
|
+
if (occurrences === 1) {
|
|
118880
|
+
sectionTemplate = sectionTemplate.replace('is-content-1000', 'is-content-700');
|
|
118881
|
+
}
|
|
118882
|
+
html = sectionTemplate.replace('[%CONTENT%]', html);
|
|
118883
|
+
const wrapper = this.doc.querySelector(this.page);
|
|
118884
|
+
wrapper.insertAdjacentHTML('afterbegin', html);
|
|
118885
|
+
this.activeBox = wrapper.querySelector('.is-box');
|
|
118886
|
+
if (this.opts.onBlockSectionAdd) this.opts.onBlockSectionAdd();
|
|
118887
|
+
}
|
|
118888
|
+
}
|
|
118889
|
+
this.activeCol = null;
|
|
118890
|
+
}
|
|
118891
|
+
addRow(html, box) {
|
|
118892
|
+
this.uo.saveForUndo();
|
|
118893
|
+
let rowElement;
|
|
118894
|
+
let bAddLast = false;
|
|
118895
|
+
|
|
118896
|
+
// Add after selected row
|
|
118897
|
+
let cell = this.activeCol;
|
|
118898
|
+
let row;
|
|
118899
|
+
if (cell) {
|
|
118900
|
+
row = cell.parentNode; // in email mode, cell active is also under row active (incorrect, but cell active is not needed in email mode. So this line works!)
|
|
118901
|
+
} else {
|
|
118902
|
+
// If no active cell, check if it is from .row-add-initial (empty info)
|
|
118903
|
+
row = this.doc.querySelector('.row-active');
|
|
118904
|
+
if (!row) {
|
|
118905
|
+
bAddLast = true;
|
|
118906
|
+
}
|
|
118907
|
+
}
|
|
118908
|
+
// Add after last row
|
|
118909
|
+
if (bAddLast) {
|
|
118910
|
+
const container = box.querySelector('.is-builder');
|
|
118911
|
+
const rows = this.dom.elementChildren(container);
|
|
118912
|
+
const lastrow = rows[rows.length - 1];
|
|
118913
|
+
row = lastrow;
|
|
118914
|
+
}
|
|
118915
|
+
|
|
118916
|
+
// Use createContextualFragment() to make embedded script executable
|
|
118917
|
+
let range = document.createRange();
|
|
118918
|
+
row.parentNode.insertBefore(range.createContextualFragment(html), row.nextSibling);
|
|
118919
|
+
// rowElement = snippet.childNodes[0];
|
|
118920
|
+
|
|
118921
|
+
rowElement = row.nextElementSibling; // a must. Must be before applyBehavior to prevent element delete during fixLayout
|
|
118922
|
+
|
|
118923
|
+
// checkEmpty & onRender called here
|
|
118924
|
+
let builderActive = box.querySelector('.builder-active');
|
|
118925
|
+
if (builderActive) this.applyBehaviorOn(builderActive);else {
|
|
118926
|
+
builderActive = box.querySelector('.is-builder');
|
|
118927
|
+
if (builderActive) this.applyBehaviorOn(builderActive);
|
|
118928
|
+
}
|
|
118929
|
+
let cellElement = rowElement.querySelector('div');
|
|
118930
|
+
if (cellElement) cellElement.click(); //change active block to the newly created
|
|
118931
|
+
|
|
118932
|
+
// Change to row selection
|
|
118933
|
+
rowElement.className = rowElement.className.replace('row-outline', '');
|
|
118934
|
+
|
|
118935
|
+
//Hide Column tool (new!)
|
|
118936
|
+
this.util.hideColumnTool();
|
|
118937
|
+
this.opts.onChange();
|
|
118938
|
+
this.opts.onRender();
|
|
118939
|
+
}
|
|
118940
|
+
isMoreThan50PercentVisible(el) {
|
|
118941
|
+
const rect = el.getBoundingClientRect();
|
|
118942
|
+
const windowHeight = this.win.innerHeight || this.doc.documentElement.clientHeight;
|
|
118943
|
+
|
|
118944
|
+
// Calculate the visible part of the element in the viewport
|
|
118945
|
+
const visibleHeight = Math.min(rect.bottom, windowHeight) - Math.max(rect.top, 0);
|
|
118946
|
+
|
|
118947
|
+
// Check if more than 50% of the element is visible
|
|
118948
|
+
return visibleHeight / rect.height > 0.5;
|
|
118949
|
+
}
|
|
118608
118950
|
sectionDropSetup() {
|
|
118609
118951
|
if (this.blockContainer) {
|
|
118610
118952
|
this.sortableOnCanvas = [];
|
|
@@ -151393,6 +151735,7 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
|
|
|
151393
151735
|
|
|
151394
151736
|
box.classList.add('box-select');
|
|
151395
151737
|
this.activeBox = box;
|
|
151738
|
+
if (this.editor) this.editor.activeBox = box;
|
|
151396
151739
|
this.wrapperEl.classList.add('hard-select');
|
|
151397
151740
|
}
|
|
151398
151741
|
|
|
@@ -151421,6 +151764,8 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
|
|
|
151421
151764
|
// Unselect (do not unselect if anim panel or modal box/section settings is opened)
|
|
151422
151765
|
this.activeBox = box; // also needed
|
|
151423
151766
|
|
|
151767
|
+
if (this.editor) this.editor.activeBox = box;
|
|
151768
|
+
|
|
151424
151769
|
if (this.controlPanel) {
|
|
151425
151770
|
if (!this.timeline.modalTimeline.classList.contains('active') && !this.animateScroll.modalAnimateScroll.classList.contains('active')) {
|
|
151426
151771
|
// Remove Hard Select
|
|
@@ -151454,6 +151799,7 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
|
|
|
151454
151799
|
if (prevSection) prevSection.classList.remove('section-select');
|
|
151455
151800
|
box.classList.add('box-select');
|
|
151456
151801
|
this.activeBox = box;
|
|
151802
|
+
if (this.editor) this.editor.activeBox = box;
|
|
151457
151803
|
const section = box.closest('.is-section');
|
|
151458
151804
|
if (this.activeSection && section !== this.activeSection) this.prevSection = this.activeSection; // Save previous selected section
|
|
151459
151805
|
|
|
@@ -151778,6 +152124,7 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
|
|
|
151778
152124
|
if (box) {
|
|
151779
152125
|
box.classList.add('box-select');
|
|
151780
152126
|
this.activeBox = box;
|
|
152127
|
+
if (this.editor) this.editor.activeBox = box;
|
|
151781
152128
|
}
|
|
151782
152129
|
|
|
151783
152130
|
if (section) {
|
|
@@ -152203,6 +152550,7 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
|
|
|
152203
152550
|
if (this.activeSection && section !== this.activeSection) this.prevSection = this.activeSection; // Save previous selected section
|
|
152204
152551
|
|
|
152205
152552
|
this.activeBox = box;
|
|
152553
|
+
if (this.editor) this.editor.activeBox = box;
|
|
152206
152554
|
this.activeSection = section; //selectType
|
|
152207
152555
|
|
|
152208
152556
|
const typePanel = document.querySelector('#divSidebarTypography');
|
|
@@ -152283,6 +152631,7 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
|
|
|
152283
152631
|
elm.classList.remove('section-select');
|
|
152284
152632
|
});
|
|
152285
152633
|
this.activeBox = null;
|
|
152634
|
+
if (this.editor) this.editor.activeBox = null;
|
|
152286
152635
|
this.activeSection = null;
|
|
152287
152636
|
this.wrapperEl.classList.remove('is-container-edit');
|
|
152288
152637
|
this.wrapperEl.classList.remove('is-clean-edit');
|
|
@@ -152729,6 +153078,7 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
|
|
|
152729
153078
|
// select box
|
|
152730
153079
|
newSection.classList.add('box-select');
|
|
152731
153080
|
this.activeBox = newSection;
|
|
153081
|
+
if (this.editor) this.editor.activeBox = newSection;
|
|
152732
153082
|
this.wrapperEl.classList.add('hard-select'); // select section
|
|
152733
153083
|
|
|
152734
153084
|
newSection.classList.add('section-select');
|
|
@@ -152742,6 +153092,7 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
|
|
|
152742
153092
|
if (box) {
|
|
152743
153093
|
box.classList.add('box-select');
|
|
152744
153094
|
this.activeBox = box;
|
|
153095
|
+
if (this.editor) this.editor.activeBox = box;
|
|
152745
153096
|
}
|
|
152746
153097
|
|
|
152747
153098
|
this.wrapperEl.classList.add('hard-select'); // select section
|
|
@@ -153232,6 +153583,7 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
|
|
|
153232
153583
|
loadHtml(html) {
|
|
153233
153584
|
// Reset
|
|
153234
153585
|
this.activeBox = null;
|
|
153586
|
+
if (this.editor) this.editor.activeBox = null;
|
|
153235
153587
|
this.activeSection = null; // Wait for IFRAME loaded
|
|
153236
153588
|
|
|
153237
153589
|
const wrapper = this.wrapperEl;
|
|
@@ -153702,7 +154054,8 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
|
|
|
153702
154054
|
if (sectionBox) {
|
|
153703
154055
|
// section
|
|
153704
154056
|
// select box
|
|
153705
|
-
this.activeBox = activeSection;
|
|
154057
|
+
this.activeBox = activeSection;
|
|
154058
|
+
if (this.editor) this.editor.activeBox = activeSection; // select section
|
|
153706
154059
|
|
|
153707
154060
|
activeSection.classList.add('section-select');
|
|
153708
154061
|
this.activeSection = activeSection;
|
|
@@ -153713,6 +154066,7 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
|
|
|
153713
154066
|
if (box) {
|
|
153714
154067
|
box.classList.add('box-select');
|
|
153715
154068
|
this.activeBox = box;
|
|
154069
|
+
if (this.editor) this.editor.activeBox = box;
|
|
153716
154070
|
} // select section
|
|
153717
154071
|
|
|
153718
154072
|
|