@innovastudio/contentbuilder 1.3.41 → 1.3.42
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
|
@@ -22015,12 +22015,17 @@ const renderSnippetPanel = builder => {
|
|
|
22015
22015
|
if (oldCss) oldCss.parentNode.removeChild(oldCss);
|
|
22016
22016
|
builder.builderStuff.insertAdjacentHTML('afterbegin', newCss);
|
|
22017
22017
|
}
|
|
22018
|
+
|
|
22019
|
+
builder.sectionDropSetup();
|
|
22018
22020
|
},
|
|
22019
|
-
onMove:
|
|
22021
|
+
onMove: evt => {
|
|
22020
22022
|
let emptyinfo = builder.doc.querySelector('.row-add-initial'); // if there is empty info, remove it during snippet drag drop
|
|
22021
22023
|
// if(emptyinfo) emptyinfo.parentNode.removeChild(emptyinfo);
|
|
22022
22024
|
|
|
22023
22025
|
if (emptyinfo) emptyinfo.style.display = 'none';
|
|
22026
|
+
if (builder.sortableOnPage) if (evt.related.getBoundingClientRect().top < 0 || evt.related.getBoundingClientRect().top > window.innerHeight) {
|
|
22027
|
+
return false;
|
|
22028
|
+
}
|
|
22024
22029
|
},
|
|
22025
22030
|
onStart: () => {
|
|
22026
22031
|
// Remove .builder-active during dragging (because this class makes rows have border-right/left 120px)
|
|
@@ -22049,6 +22054,8 @@ const renderSnippetPanel = builder => {
|
|
|
22049
22054
|
if (activeBuilderArea) {
|
|
22050
22055
|
dom.addClass(activeBuilderArea, 'builder-active');
|
|
22051
22056
|
}
|
|
22057
|
+
|
|
22058
|
+
if (builder.sortableOnPage) builder.sortableOnPage.destroy();
|
|
22052
22059
|
}
|
|
22053
22060
|
});
|
|
22054
22061
|
|
|
@@ -78091,6 +78098,199 @@ class ContentBuilder {
|
|
|
78091
78098
|
// return currentScript.replace(currentScriptFile, '');
|
|
78092
78099
|
}
|
|
78093
78100
|
|
|
78101
|
+
sectionDropSetup() {
|
|
78102
|
+
if (this.page) {
|
|
78103
|
+
if (this.page !== '.is-wrapper') return; // only for ContentBox
|
|
78104
|
+
|
|
78105
|
+
const wrapper = this.doc.querySelector(this.page);
|
|
78106
|
+
this.sortableOnPage = new Sortable(wrapper, {
|
|
78107
|
+
scroll: true,
|
|
78108
|
+
group: 'shared',
|
|
78109
|
+
direction: 'vertical',
|
|
78110
|
+
animation: 150,
|
|
78111
|
+
sort: true,
|
|
78112
|
+
// draggable: '.dummy',
|
|
78113
|
+
swapThreshold: 0.1,
|
|
78114
|
+
invertSwap: true,
|
|
78115
|
+
onAdd: evt => {
|
|
78116
|
+
var itemEl = evt.item;
|
|
78117
|
+
|
|
78118
|
+
if (itemEl.querySelector('.is-col-tool')) {
|
|
78119
|
+
let rowTool = itemEl.querySelector('.is-row-tool');
|
|
78120
|
+
let colTool = itemEl.querySelector('.is-col-tool');
|
|
78121
|
+
let rowAddTool = itemEl.querySelector('.is-rowadd-tool');
|
|
78122
|
+
itemEl.removeChild(rowTool);
|
|
78123
|
+
itemEl.removeChild(colTool);
|
|
78124
|
+
itemEl.removeChild(rowAddTool);
|
|
78125
|
+
let elms = itemEl.querySelectorAll('[data-click]');
|
|
78126
|
+
elms.forEach(elm => {
|
|
78127
|
+
elm.removeAttribute('data-click');
|
|
78128
|
+
});
|
|
78129
|
+
itemEl.removeAttribute('draggable');
|
|
78130
|
+
itemEl.classList.remove('row-active');
|
|
78131
|
+
itemEl.classList.remove('row-outline');
|
|
78132
|
+
elms = itemEl.querySelectorAll('.cell-active');
|
|
78133
|
+
elms.forEach(elm => {
|
|
78134
|
+
elm.classList.remove('cell-active');
|
|
78135
|
+
});
|
|
78136
|
+
elms = itemEl.querySelectorAll('*');
|
|
78137
|
+
elms.forEach(elm => {
|
|
78138
|
+
elm.style.cursor = '';
|
|
78139
|
+
});
|
|
78140
|
+
itemEl.outerHTML = `
|
|
78141
|
+
<div class="is-section is-box is-section-100 type-poppins">
|
|
78142
|
+
<div class="is-overlay"></div>
|
|
78143
|
+
<div class="is-boxes">
|
|
78144
|
+
<div class="is-box-centered">
|
|
78145
|
+
<div class="is-container is-content-900 v2 size-18 leading-14">
|
|
78146
|
+
${itemEl.outerHTML}
|
|
78147
|
+
</div>
|
|
78148
|
+
</div>
|
|
78149
|
+
</div>
|
|
78150
|
+
</div>
|
|
78151
|
+
`;
|
|
78152
|
+
if (this.opts.onSectionAdd) this.opts.onSectionAdd(); // //Trigger Change event
|
|
78153
|
+
// this.opts.onChange();
|
|
78154
|
+
// //Trigger Render event
|
|
78155
|
+
// this.opts.onRender();
|
|
78156
|
+
|
|
78157
|
+
return;
|
|
78158
|
+
}
|
|
78159
|
+
|
|
78160
|
+
if (itemEl.getAttribute('data-id')) {
|
|
78161
|
+
// If has data-id attribute, the dropped item is from snippet panel (snippetpanel.js)
|
|
78162
|
+
let snippetid = itemEl.getAttribute('data-id'); // snippetJSON is snippet's JSON (from assets/minimalist-blocks/content.js) that store all snippets' html
|
|
78163
|
+
|
|
78164
|
+
const result = this.opts.snippetJSON.snippets.filter(item => {
|
|
78165
|
+
if (item.id + '' === snippetid) return item;else return false;
|
|
78166
|
+
});
|
|
78167
|
+
var html = result[0].html;
|
|
78168
|
+
var noedit = result[0].noedit;
|
|
78169
|
+
var bSnippet;
|
|
78170
|
+
|
|
78171
|
+
if (html.indexOf('"row') === -1) {
|
|
78172
|
+
bSnippet = true; // Just snippet (without row/column grid)
|
|
78173
|
+
} else {
|
|
78174
|
+
bSnippet = false; // Snippet is wrapped in row/colum
|
|
78175
|
+
}
|
|
78176
|
+
|
|
78177
|
+
if (this.opts.emailMode) bSnippet = false; // Convert snippet into your defined 12 columns grid
|
|
78178
|
+
|
|
78179
|
+
var rowClass = this.opts.row; //row
|
|
78180
|
+
|
|
78181
|
+
var 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']
|
|
78182
|
+
|
|
78183
|
+
if (rowClass !== '' && colClass.length === 12) {
|
|
78184
|
+
// html = html.replace(new RegExp('row clearfix', 'g'), rowClass);
|
|
78185
|
+
html = html.replace(new RegExp('row clearfix', 'g'), 'row'); // backward
|
|
78186
|
+
|
|
78187
|
+
html = html.replace(new RegExp('"row', 'g'), '"' + rowClass);
|
|
78188
|
+
html = html.replace(new RegExp('column full', 'g'), colClass[11]);
|
|
78189
|
+
html = html.replace(new RegExp('column half', 'g'), colClass[5]);
|
|
78190
|
+
html = html.replace(new RegExp('column third', 'g'), colClass[3]);
|
|
78191
|
+
html = html.replace(new RegExp('column fourth', 'g'), colClass[2]);
|
|
78192
|
+
html = html.replace(new RegExp('column fifth', 'g'), colClass[1]);
|
|
78193
|
+
html = html.replace(new RegExp('column sixth', 'g'), colClass[1]);
|
|
78194
|
+
html = html.replace(new RegExp('column two-third', 'g'), colClass[7]);
|
|
78195
|
+
html = html.replace(new RegExp('column two-fourth', 'g'), colClass[8]);
|
|
78196
|
+
html = html.replace(new RegExp('column two-fifth', 'g'), colClass[9]);
|
|
78197
|
+
html = html.replace(new RegExp('column two-sixth', 'g'), colClass[9]);
|
|
78198
|
+
}
|
|
78199
|
+
|
|
78200
|
+
html = html.replace(/{id}/g, this.util.makeId());
|
|
78201
|
+
|
|
78202
|
+
if (this.opts.onAdd) {
|
|
78203
|
+
html = this.opts.onAdd(html);
|
|
78204
|
+
}
|
|
78205
|
+
|
|
78206
|
+
if (this.opts.snippetPathReplace.length > 0) {
|
|
78207
|
+
// try {
|
|
78208
|
+
if (this.opts.snippetPathReplace[0] !== '') {
|
|
78209
|
+
var regex = new RegExp(this.opts.snippetPathReplace[0], 'g');
|
|
78210
|
+
html = html.replace(regex, this.opts.snippetPathReplace[1]);
|
|
78211
|
+
var string1 = this.opts.snippetPathReplace[0].replace(/\//g, '%2F');
|
|
78212
|
+
var string2 = this.opts.snippetPathReplace[1].replace(/\//g, '%2F');
|
|
78213
|
+
var regex2 = new RegExp(string1, 'g');
|
|
78214
|
+
html = html.replace(regex2, string2);
|
|
78215
|
+
} // } catch (e) { 1; }
|
|
78216
|
+
|
|
78217
|
+
}
|
|
78218
|
+
|
|
78219
|
+
if (bSnippet) {
|
|
78220
|
+
// Just snippet (without row/column grid), ex. buttons, line, social, video, map.
|
|
78221
|
+
// Can be inserted after current row, column (cell), element, or last row.
|
|
78222
|
+
html = `<div class="${this.opts.row}"><div class="${this.opts.cols[this.opts.cols.length - 1]}"${noedit ? ' data-noedit' : ''}>${html}</div></div>`; // Clean snippet from sortable related code
|
|
78223
|
+
|
|
78224
|
+
itemEl.removeAttribute('draggable');
|
|
78225
|
+
this.dom.removeClass(itemEl, 'snippet-item'); // itemEl.outerHTML = html;
|
|
78226
|
+
|
|
78227
|
+
itemEl.outerHTML = `
|
|
78228
|
+
<div class="is-section is-box is-section-100 type-poppins">
|
|
78229
|
+
<div class="is-overlay"></div>
|
|
78230
|
+
<div class="is-boxes">
|
|
78231
|
+
<div class="is-box-centered">
|
|
78232
|
+
<div class="is-container is-content-900 v2 size-18 leading-14">${html}</div>
|
|
78233
|
+
</div>
|
|
78234
|
+
</div>
|
|
78235
|
+
</div>
|
|
78236
|
+
`;
|
|
78237
|
+
} else {
|
|
78238
|
+
// Snippet is wrapped in row/colum (may contain custom code or has [data-html] attribute)
|
|
78239
|
+
// Can only be inserted after current row or last row (not on column or element).
|
|
78240
|
+
let snippet = this.dom.createElement('div');
|
|
78241
|
+
snippet.innerHTML = html;
|
|
78242
|
+
let blocks = snippet.querySelectorAll('[data-html]');
|
|
78243
|
+
Array.prototype.forEach.call(blocks, block => {
|
|
78244
|
+
// Render custom code block
|
|
78245
|
+
html = decodeURIComponent(block.getAttribute('data-html'));
|
|
78246
|
+
html = html.replace(/{id}/g, this.util.makeId());
|
|
78247
|
+
|
|
78248
|
+
for (var i = 1; i <= 20; i++) {
|
|
78249
|
+
html = html.replace('[%HTML' + i + '%]', block.getAttribute('data-html-' + i) === undefined ? '' : decodeURIComponent(block.getAttribute('data-html-' + i))); //render editable area
|
|
78250
|
+
}
|
|
78251
|
+
|
|
78252
|
+
block.innerHTML = html;
|
|
78253
|
+
});
|
|
78254
|
+
html = snippet.innerHTML; // Clean snippet from sortable related code
|
|
78255
|
+
|
|
78256
|
+
itemEl.removeAttribute('draggable');
|
|
78257
|
+
this.dom.removeClass(itemEl, 'snippet-item');
|
|
78258
|
+
itemEl.innerHTML = ''; // Use createContextualFragment() to make embedded script executable
|
|
78259
|
+
// https://ghinda.net/article/script-tags/
|
|
78260
|
+
|
|
78261
|
+
var range = document.createRange();
|
|
78262
|
+
range.setStart(itemEl, 0);
|
|
78263
|
+
itemEl.appendChild(range.createContextualFragment(html)); // itemEl.outerHTML = itemEl.innerHTML;
|
|
78264
|
+
|
|
78265
|
+
itemEl.outerHTML = `
|
|
78266
|
+
<div class="is-section is-box is-section-100 type-poppins">
|
|
78267
|
+
<div class="is-overlay"></div>
|
|
78268
|
+
<div class="is-boxes">
|
|
78269
|
+
<div class="is-box-centered">
|
|
78270
|
+
<div class="is-container is-content-900 v2 size-18 leading-14">${itemEl.innerHTML}</div>
|
|
78271
|
+
</div>
|
|
78272
|
+
</div>
|
|
78273
|
+
</div>
|
|
78274
|
+
`;
|
|
78275
|
+
} // // After snippet has been added, re-apply behavior on builder areas
|
|
78276
|
+
// this.applyBehaviorOn(builder);
|
|
78277
|
+
|
|
78278
|
+
|
|
78279
|
+
if (this.opts.onSectionAdd) this.opts.onSectionAdd(); //Trigger Change event
|
|
78280
|
+
|
|
78281
|
+
this.opts.onChange(); //Trigger Render event
|
|
78282
|
+
|
|
78283
|
+
this.opts.onRender(); // // Hide element tool
|
|
78284
|
+
// this.elmTool.hide();
|
|
78285
|
+
} // this.sortableOnPage.option('draggable', '.dummy');
|
|
78286
|
+
|
|
78287
|
+
|
|
78288
|
+
this.sortableOnPage.destroy();
|
|
78289
|
+
}
|
|
78290
|
+
});
|
|
78291
|
+
}
|
|
78292
|
+
}
|
|
78293
|
+
|
|
78094
78294
|
}
|
|
78095
78295
|
// var run = (opts = {}) => {
|
|
78096
78296
|
// return new ContentBuilder(opts);
|