@innovastudio/contentbuilder 1.2.21 → 1.2.22
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 +2 -2
- package/public/contentbuilder/contentbuilder.css +40 -29
- package/public/contentbuilder/contentbuilder.esm.js +13599 -10117
- package/public/contentbuilder/contentbuilder.min.js +50 -22
- package/public/contentbuilder/plugins/preview/plugin.js +19 -2
- package/public/contentbuilder/plugins/searchreplace/plugin.js +98 -34
- package/public/contentbuilder/plugins/showgrid/plugin.js +1 -1
|
@@ -205,6 +205,7 @@ function showPreviewWindow() {
|
|
|
205
205
|
scripts[i].src.indexOf("plugin.js") == -1 &&
|
|
206
206
|
scripts[i].src.indexOf("config.js") == -1 &&
|
|
207
207
|
scripts[i].src.indexOf("en.js") == -1 &&
|
|
208
|
+
scripts[i].src.indexOf("rangy") == -1 &&
|
|
208
209
|
scripts[i].src.indexOf("minimalist-blocks") == -1
|
|
209
210
|
) {
|
|
210
211
|
jsincludes1 +=
|
|
@@ -213,9 +214,11 @@ function showPreviewWindow() {
|
|
|
213
214
|
'" type="text/javascript"></script>';
|
|
214
215
|
}
|
|
215
216
|
}
|
|
217
|
+
|
|
216
218
|
var jsincludes2 = "";
|
|
217
219
|
var scripts = doc.body.querySelectorAll("script[src]");
|
|
218
220
|
for (var i = 0; i < scripts.length; i++) {
|
|
221
|
+
console.log(scripts[i].src)
|
|
219
222
|
if (
|
|
220
223
|
scripts[i].src.indexOf(".js") != -1 &&
|
|
221
224
|
scripts[i].src.indexOf("_next/") == -1 && //next
|
|
@@ -229,6 +232,7 @@ function showPreviewWindow() {
|
|
|
229
232
|
scripts[i].src.indexOf("plugin.js") == -1 &&
|
|
230
233
|
scripts[i].src.indexOf("config.js") == -1 &&
|
|
231
234
|
scripts[i].src.indexOf("en.js") == -1 &&
|
|
235
|
+
scripts[i].src.indexOf("rangy") == -1 &&
|
|
232
236
|
scripts[i].src.indexOf("minimalist-blocks") == -1
|
|
233
237
|
) {
|
|
234
238
|
jsincludes2 +=
|
|
@@ -238,10 +242,21 @@ function showPreviewWindow() {
|
|
|
238
242
|
}
|
|
239
243
|
}
|
|
240
244
|
|
|
245
|
+
var escHtml = `
|
|
246
|
+
<script>
|
|
247
|
+
document.addEventListener('keydown', (e)=>{
|
|
248
|
+
if(e.keyCode === 27) { // escape key
|
|
249
|
+
|
|
250
|
+
var modal = parent.document.querySelector(".is-modal.previewcontent");
|
|
251
|
+
parent._cb.hideModal(modal);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
</script>`;
|
|
255
|
+
|
|
241
256
|
/* Get Page */
|
|
242
|
-
if (!
|
|
257
|
+
if (!this._cb.doc.querySelector(".is-wrapper")) {
|
|
243
258
|
var maxwidth = "800px";
|
|
244
|
-
var maxw = window.getComputedStyle(
|
|
259
|
+
var maxw = window.getComputedStyle(this._cb.doc.querySelector(".is-builder")).getPropertyValue('max-width');
|
|
245
260
|
if (!isNaN(parseInt(maxw))) maxwidth = maxw;
|
|
246
261
|
|
|
247
262
|
var content = _cb.html();
|
|
@@ -272,6 +287,7 @@ function showPreviewWindow() {
|
|
|
272
287
|
"</div>" +
|
|
273
288
|
jsincludes2 +
|
|
274
289
|
(_cb.useLightbox? '<script src="'+_cb.assetPath+'scripts/lightbox/lightbox.js"></script><script>window.lightbox.init();</script>':'') +
|
|
290
|
+
escHtml +
|
|
275
291
|
"</body>" +
|
|
276
292
|
"</html>"
|
|
277
293
|
);
|
|
@@ -314,6 +330,7 @@ function showPreviewWindow() {
|
|
|
314
330
|
content +
|
|
315
331
|
"</div>" +
|
|
316
332
|
jsincludes2 +
|
|
333
|
+
escHtml +
|
|
317
334
|
"</body>" +
|
|
318
335
|
"</html>"
|
|
319
336
|
);
|
|
@@ -39,9 +39,8 @@
|
|
|
39
39
|
|
|
40
40
|
_cb.addButton('searchreplace', button, '.searchreplace-button', function () {
|
|
41
41
|
|
|
42
|
-
|
|
43
42
|
var modal = document.querySelector(".is-modal.searchreplace");
|
|
44
|
-
|
|
43
|
+
_cb.showModal(modal);
|
|
45
44
|
|
|
46
45
|
var btnClose = modal.querySelector('.is-modal-close');
|
|
47
46
|
btnClose.addEventListener('click', function(e){
|
|
@@ -61,6 +60,58 @@
|
|
|
61
60
|
doc.close();
|
|
62
61
|
|
|
63
62
|
});
|
|
63
|
+
|
|
64
|
+
if(_cb.iframe) {
|
|
65
|
+
var iframeHtml = `
|
|
66
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/rangy/1.3.0/rangy-core.min.js"></script>
|
|
67
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/rangy/1.3.0/rangy-textrange.min.js"></script>
|
|
68
|
+
<script>
|
|
69
|
+
window.findOne = (target, caseSensitive, within, startNode, startPos)=>{
|
|
70
|
+
|
|
71
|
+
if (rangy.supported) {
|
|
72
|
+
var range = rangy.createRange();
|
|
73
|
+
var searchScopeRange = rangy.createRange();
|
|
74
|
+
|
|
75
|
+
searchScopeRange.selectNodeContents(within);
|
|
76
|
+
|
|
77
|
+
if (startNode != null && startPos != null) {
|
|
78
|
+
searchScopeRange.setStart(startNode, startPos);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
var options = {
|
|
82
|
+
caseSensitive: caseSensitive,
|
|
83
|
+
wholeWordsOnly: true,
|
|
84
|
+
withinRange: searchScopeRange
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
if (target !== "") {
|
|
88
|
+
let result = (range.findText(target, options));
|
|
89
|
+
|
|
90
|
+
selectRange(range.startContainer, range.endContainer, range.startOffset, range.endOffset);
|
|
91
|
+
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function selectRange(startNode, endNode, startPos, endPos) {
|
|
97
|
+
var range = document.createRange()
|
|
98
|
+
range.setStart(startNode, startPos);
|
|
99
|
+
range.setEnd(endNode, endPos);
|
|
100
|
+
|
|
101
|
+
var sel = window.getSelection();
|
|
102
|
+
sel.removeAllRanges();
|
|
103
|
+
sel.addRange(range);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
</script>
|
|
107
|
+
`;
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
const contentStuff = _cb.doc.querySelector('#_cbhtml');
|
|
111
|
+
const range = _cb.doc.createRange();
|
|
112
|
+
range.setStart(contentStuff, 0);
|
|
113
|
+
contentStuff.appendChild(range.createContextualFragment(iframeHtml) );
|
|
114
|
+
}
|
|
64
115
|
/*
|
|
65
116
|
_cb.addButton2('searchreplace', button, '.searchreplace-button', function () {
|
|
66
117
|
|
|
@@ -219,34 +270,34 @@
|
|
|
219
270
|
|
|
220
271
|
var within = parent._cb.getScope();
|
|
221
272
|
|
|
222
|
-
var sel = parent.getSelection();
|
|
273
|
+
var sel = parent._cb.win.getSelection();
|
|
223
274
|
|
|
224
275
|
var r1 = parent.document.createRange();
|
|
225
276
|
r1.selectNodeContents(within);
|
|
226
277
|
|
|
227
278
|
// https://stackoverflow.com/questions/32192664/how-to-select-a-given-string-repeatedly-within-the-text-of-a-contenteditable-ele
|
|
228
279
|
if (sel.toString().search(target) > -1) {
|
|
229
|
-
var ok = parent.findOne(target, bMatchCase, within, sel.focusNode, sel.focusOffset);
|
|
280
|
+
var ok = parent._cb.win.findOne(target, bMatchCase, within, sel.focusNode, sel.focusOffset);
|
|
230
281
|
if (ok) {
|
|
231
|
-
var rng = parent.getSelection().getRangeAt(0);
|
|
282
|
+
var rng = parent._cb.win.getSelection().getRangeAt(0);
|
|
232
283
|
rng.deleteContents();
|
|
233
284
|
rng.insertNode(document.createTextNode(replaceWith));
|
|
234
285
|
nReplaceCount++;
|
|
235
286
|
}
|
|
236
287
|
jQuery('.input-replaceall').trigger('click');
|
|
237
288
|
} else if (sel.toString().length > 0) {
|
|
238
|
-
var ok = parent.findOne(target, bMatchCase, within, sel.focusNode, sel.focusOffset);
|
|
289
|
+
var ok = parent._cb.win.findOne(target, bMatchCase, within, sel.focusNode, sel.focusOffset);
|
|
239
290
|
if (ok) {
|
|
240
|
-
var rng = parent.getSelection().getRangeAt(0);
|
|
291
|
+
var rng = parent._cb.win.getSelection().getRangeAt(0);
|
|
241
292
|
rng.deleteContents();
|
|
242
293
|
rng.insertNode(document.createTextNode(replaceWith));
|
|
243
294
|
nReplaceCount++;
|
|
244
295
|
}
|
|
245
296
|
jQuery('.input-replaceall').trigger('click');
|
|
246
297
|
} else if (sel.rangeCount) {
|
|
247
|
-
var ok = parent.findOne(target, bMatchCase, within, r1.commonAncestorContainer, r1.startOffset);
|
|
298
|
+
var ok = parent._cb.win.findOne(target, bMatchCase, within, r1.commonAncestorContainer, r1.startOffset);
|
|
248
299
|
if (ok) {
|
|
249
|
-
var rng = parent.getSelection().getRangeAt(0);
|
|
300
|
+
var rng = parent._cb.win.getSelection().getRangeAt(0);
|
|
250
301
|
rng.deleteContents();
|
|
251
302
|
rng.insertNode(document.createTextNode(replaceWith));
|
|
252
303
|
nReplaceCount++;
|
|
@@ -272,25 +323,27 @@
|
|
|
272
323
|
|
|
273
324
|
var within = parent._cb.getScope();
|
|
274
325
|
|
|
275
|
-
var sel = parent.getSelection();
|
|
326
|
+
var sel = parent._cb.win.getSelection();
|
|
276
327
|
|
|
277
|
-
var r1 = parent.
|
|
328
|
+
var r1 = parent._cb.doc.createRange();
|
|
278
329
|
r1.selectNodeContents(within);
|
|
279
330
|
|
|
331
|
+
jQuery('#divStatus').html('');
|
|
332
|
+
|
|
280
333
|
if (sel.toString().search(target) > -1) {
|
|
281
|
-
var ok = parent.findOne(target, bMatchCase, within, sel.focusNode, sel.focusOffset);
|
|
334
|
+
var ok = parent._cb.win.findOne(target, bMatchCase, within, sel.focusNode, sel.focusOffset);
|
|
282
335
|
if (ok) {
|
|
283
336
|
jQuery('#divStatus').html('');
|
|
284
337
|
} else {
|
|
285
338
|
|
|
286
339
|
}
|
|
287
340
|
} else if (sel.toString().length > 0) {
|
|
288
|
-
var ok = parent.findOne(target, bMatchCase, within, sel.focusNode, sel.focusOffset);
|
|
341
|
+
var ok = parent._cb.win.findOne(target, bMatchCase, within, sel.focusNode, sel.focusOffset);
|
|
289
342
|
if (ok) {
|
|
290
343
|
jQuery('#divStatus').html('');
|
|
291
344
|
} else {
|
|
292
345
|
jQuery('#divStatus').html('Passed the end of the content.');
|
|
293
|
-
var ok = parent.findOne(target, bMatchCase, within, r1.commonAncestorContainer, r1.startOffset);
|
|
346
|
+
var ok = parent._cb.win.findOne(target, bMatchCase, within, r1.commonAncestorContainer, r1.startOffset);
|
|
294
347
|
if (ok) {
|
|
295
348
|
jQuery('#divStatus').html('');
|
|
296
349
|
} else {
|
|
@@ -298,11 +351,11 @@
|
|
|
298
351
|
}
|
|
299
352
|
}
|
|
300
353
|
} else if (sel.rangeCount) {
|
|
301
|
-
var ok = parent.findOne(target, bMatchCase, within, sel.anchorNode, sel.anchorOffset);
|
|
354
|
+
var ok = parent._cb.win.findOne(target, bMatchCase, within, sel.anchorNode, sel.anchorOffset);
|
|
302
355
|
if (ok) {
|
|
303
356
|
jQuery('#divStatus').html('');
|
|
304
357
|
} else {
|
|
305
|
-
var ok = parent.findOne(target, bMatchCase, within, r1.commonAncestorContainer, r1.startOffset);
|
|
358
|
+
var ok = parent._cb.win.findOne(target, bMatchCase, within, r1.commonAncestorContainer, r1.startOffset);
|
|
306
359
|
if (ok) {
|
|
307
360
|
jQuery('#divStatus').html('');
|
|
308
361
|
} else {
|
|
@@ -310,7 +363,7 @@
|
|
|
310
363
|
}
|
|
311
364
|
}
|
|
312
365
|
}
|
|
313
|
-
|
|
366
|
+
|
|
314
367
|
});
|
|
315
368
|
|
|
316
369
|
jQuery('.input-replace').click(function (e) {
|
|
@@ -327,32 +380,32 @@
|
|
|
327
380
|
|
|
328
381
|
var within = parent._cb.getScope();
|
|
329
382
|
|
|
330
|
-
var sel = parent.getSelection();
|
|
383
|
+
var sel = parent._cb.win.getSelection();
|
|
331
384
|
|
|
332
385
|
var r1 = parent.document.createRange();
|
|
333
386
|
r1.selectNodeContents(within);
|
|
334
387
|
|
|
335
|
-
var text = getSelected(parent);
|
|
388
|
+
var text = getSelected(parent._cb.win);
|
|
336
389
|
if (text) {
|
|
337
390
|
if ((((text + '').toLowerCase() == target.toLowerCase()) && bMatchCase==false) ||
|
|
338
391
|
((text == target) && bMatchCase == true)) {
|
|
339
|
-
var rng = parent.getSelection().getRangeAt(0);
|
|
392
|
+
var rng = parent._cb.win.getSelection().getRangeAt(0);
|
|
340
393
|
rng.deleteContents();
|
|
341
394
|
rng.insertNode(document.createTextNode(replaceWith));
|
|
342
395
|
}
|
|
343
396
|
}
|
|
344
397
|
|
|
345
398
|
if (sel.rangeCount) {
|
|
346
|
-
var ok = parent.findOne(target, bMatchCase, within, sel.anchorNode, sel.anchorOffset);
|
|
399
|
+
var ok = parent._cb.win.findOne(target, bMatchCase, within, sel.anchorNode, sel.anchorOffset);
|
|
347
400
|
if (ok) {
|
|
348
401
|
jQuery('#divStatus').html('');
|
|
349
402
|
} else {
|
|
350
|
-
var ok = parent.findOne(target, bMatchCase, within, r1.commonAncestorContainer, r1.startOffset);
|
|
351
|
-
if (ok) {
|
|
352
|
-
|
|
353
|
-
} else {
|
|
354
|
-
|
|
355
|
-
}
|
|
403
|
+
var ok = parent._cb.win.findOne(target, bMatchCase, within, r1.commonAncestorContainer, r1.startOffset);
|
|
404
|
+
// if (ok) {
|
|
405
|
+
// jQuery('#divStatus').html('');
|
|
406
|
+
// } else {
|
|
407
|
+
// jQuery('#divStatus').html('The specified text was not found.');
|
|
408
|
+
// }
|
|
356
409
|
}
|
|
357
410
|
}
|
|
358
411
|
});
|
|
@@ -369,6 +422,14 @@
|
|
|
369
422
|
}
|
|
370
423
|
return false;
|
|
371
424
|
}
|
|
425
|
+
|
|
426
|
+
document.addEventListener('keydown', (e)=>{
|
|
427
|
+
if(e.keyCode === 27) { // escape key
|
|
428
|
+
|
|
429
|
+
var modal = parent.document.querySelector(".is-modal.searchreplace");
|
|
430
|
+
parent._cb.hideModal(modal);
|
|
431
|
+
}
|
|
432
|
+
});
|
|
372
433
|
|
|
373
434
|
</script>
|
|
374
435
|
</body>
|
|
@@ -381,8 +442,10 @@
|
|
|
381
442
|
|
|
382
443
|
})();
|
|
383
444
|
|
|
445
|
+
|
|
384
446
|
// https://stackoverflow.com/questions/32192664/how-to-select-a-given-string-repeatedly-within-the-text-of-a-contenteditable-ele
|
|
385
447
|
function findOne(target, caseSensitive, within, startNode, startPos) {
|
|
448
|
+
|
|
386
449
|
if (rangy.supported) {
|
|
387
450
|
var range = rangy.createRange();
|
|
388
451
|
var searchScopeRange = rangy.createRange();
|
|
@@ -400,16 +463,17 @@ function findOne(target, caseSensitive, within, startNode, startPos) {
|
|
|
400
463
|
};
|
|
401
464
|
|
|
402
465
|
if (target !== "") {
|
|
403
|
-
range.findText(target, options);
|
|
466
|
+
let result = (range.findText(target, options));
|
|
404
467
|
|
|
405
468
|
selectRange(range.startContainer, range.endContainer, range.startOffset, range.endOffset);
|
|
406
469
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
470
|
+
return result;
|
|
471
|
+
// var text = getSelected(parent);
|
|
472
|
+
// if (text != '') {
|
|
473
|
+
// return true;
|
|
474
|
+
// } else {
|
|
475
|
+
// return false;
|
|
476
|
+
// }
|
|
413
477
|
}
|
|
414
478
|
}
|
|
415
479
|
|
|
@@ -38,7 +38,7 @@ Show Grid Plugin
|
|
|
38
38
|
function showGrid() {
|
|
39
39
|
|
|
40
40
|
// Get all editable areas
|
|
41
|
-
const areas =
|
|
41
|
+
const areas = parent._cb.doc.querySelectorAll('.is-builder');
|
|
42
42
|
Array.prototype.forEach.call(areas, function(area){
|
|
43
43
|
|
|
44
44
|
if(hasClass(area,'showgrid')){
|