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