@innovastudio/contentbuilder 1.0.82 → 1.0.83
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/contentbuilder",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.83",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "public/contentbuilder/contentbuilder.esm.js",
|
|
6
6
|
"files": [
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"express-session": "^1.17.2",
|
|
49
49
|
"js-beautify": "^1.14.0",
|
|
50
50
|
"moveable": "^0.26.0",
|
|
51
|
+
"nodemailer": "^6.7.2",
|
|
51
52
|
"serve-static": "^1.14.1",
|
|
52
53
|
"sortablejs": "^1.14.0"
|
|
53
54
|
}
|
|
@@ -39949,7 +39949,7 @@ class Image {
|
|
|
39949
39949
|
// if(initialWidth <200 && initialHeight<200) {
|
|
39950
39950
|
|
|
39951
39951
|
|
|
39952
|
-
if (initialWidth <= 1600 && initialHeight <= 1600) {
|
|
39952
|
+
if (initialWidth <= 1600 && initialHeight <= 1600 && this.builder.opts.maxEmbedImageWidth >= 1600) {
|
|
39953
39953
|
let reader = new FileReader();
|
|
39954
39954
|
reader.addEventListener('load', e => {
|
|
39955
39955
|
if (!document.getElementById('__preview')) {
|
|
@@ -60320,12 +60320,6 @@ class ContentBuilder {
|
|
|
60320
60320
|
for (let n = 0; n < elm.attributes.length; n++) {
|
|
60321
60321
|
if (elm.attributes[n].name !== 'style') elm.removeAttribute(elm.attributes[n].name);
|
|
60322
60322
|
}
|
|
60323
|
-
}); // Extra:
|
|
60324
|
-
// Remove li with white-space: pre;
|
|
60325
|
-
|
|
60326
|
-
elms = contentword.querySelectorAll('li');
|
|
60327
|
-
Array.prototype.forEach.call(elms, elm => {
|
|
60328
|
-
elm.style.whiteSpace = '';
|
|
60329
60323
|
});
|
|
60330
60324
|
} else {
|
|
60331
60325
|
//html-without-styles (default)
|
|
@@ -60339,14 +60333,26 @@ class ContentBuilder {
|
|
|
60339
60333
|
Array.prototype.forEach.call(elms, elm => {
|
|
60340
60334
|
removeAttributes(elm);
|
|
60341
60335
|
});
|
|
60342
|
-
}
|
|
60343
|
-
|
|
60344
|
-
|
|
60345
|
-
|
|
60346
|
-
|
|
60347
|
-
|
|
60348
|
-
|
|
60349
|
-
|
|
60336
|
+
}
|
|
60337
|
+
/*
|
|
60338
|
+
Additional Cleanup:
|
|
60339
|
+
- Remove p inside li
|
|
60340
|
+
- Remove li with white-space: pre
|
|
60341
|
+
*/
|
|
60342
|
+
|
|
60343
|
+
|
|
60344
|
+
let elms = contentword.querySelectorAll('li');
|
|
60345
|
+
Array.prototype.forEach.call(elms, elm => {
|
|
60346
|
+
elm.style.whiteSpace = '';
|
|
60347
|
+
const childNodes = elm.childNodes;
|
|
60348
|
+
let i = childNodes.length;
|
|
60349
|
+
|
|
60350
|
+
while (i--) {
|
|
60351
|
+
if (childNodes[i].tagName === 'P') {
|
|
60352
|
+
childNodes[i].outerHTML = childNodes[i].innerHTML;
|
|
60353
|
+
}
|
|
60354
|
+
}
|
|
60355
|
+
}); // NOTE: paste <h1><p> jadi nempel
|
|
60350
60356
|
// // Source: https://gist.github.com/sbrin/6801034
|
|
60351
60357
|
// jQuery('p', $editor).each(function(){
|
|
60352
60358
|
// var str = jQuery(this).attr('style');
|
|
@@ -60399,16 +60405,12 @@ class ContentBuilder {
|
|
|
60399
60405
|
// //jQuery("[class^='Mso']", $editor).removeAttr('class'); //done (see cleanHTML)
|
|
60400
60406
|
// jQuery('p:empty', $editor).remove();
|
|
60401
60407
|
|
|
60402
|
-
|
|
60403
60408
|
sPastedText = contentword.innerHTML;
|
|
60404
60409
|
}
|
|
60405
60410
|
}
|
|
60406
60411
|
|
|
60407
60412
|
contentword = document.querySelector('#idContentWord');
|
|
60408
|
-
if (contentword) contentword.parentNode.removeChild(contentword);
|
|
60409
|
-
// jQuery('.cell-active').find('.elm-active').removeClass('elm-active');
|
|
60410
|
-
// jQuery("#divElementTool").css("display", "none"); //force hide ellement tool
|
|
60411
|
-
|
|
60413
|
+
if (contentword) contentword.parentNode.removeChild(contentword);
|
|
60412
60414
|
util.restoreSelection();
|
|
60413
60415
|
var oSel = window.getSelection();
|
|
60414
60416
|
var range = oSel.getRangeAt(0);
|
|
@@ -60416,16 +60418,80 @@ class ContentBuilder {
|
|
|
60416
60418
|
range.collapse(true);
|
|
60417
60419
|
var docFrag = range.createContextualFragment(sPastedText);
|
|
60418
60420
|
var lastNode = docFrag.lastChild;
|
|
60419
|
-
range.insertNode(docFrag);
|
|
60420
|
-
|
|
60421
|
-
|
|
60422
|
-
|
|
60423
|
-
|
|
60424
|
-
|
|
60425
|
-
|
|
60426
|
-
|
|
60427
|
-
|
|
60428
|
-
|
|
60421
|
+
range.insertNode(docFrag);
|
|
60422
|
+
|
|
60423
|
+
if (this.activeCol) {
|
|
60424
|
+
/*
|
|
60425
|
+
Additional Cleanup:
|
|
60426
|
+
- Remove empty elements (empty p, etc)
|
|
60427
|
+
*/
|
|
60428
|
+
// $block.find('h1:empty,h2:empty,h3:empty,h4:empty,h5:empty,h6:empty,p:empty').remove();
|
|
60429
|
+
this.activeCol.querySelectorAll('*:empty').forEach(x => {
|
|
60430
|
+
x.remove();
|
|
60431
|
+
});
|
|
60432
|
+
/*
|
|
60433
|
+
Additional Cleanup:
|
|
60434
|
+
Fix HTML structure. The problem:
|
|
60435
|
+
<p class="elm-active">
|
|
60436
|
+
...Sometimes h1, h2, p can be pasted here..
|
|
60437
|
+
</p>
|
|
60438
|
+
*/
|
|
60439
|
+
|
|
60440
|
+
let elmActive = this.activeCol.querySelector('p.elm-active,h1.elm-active,h2.elm-active,h3.elm-active,h4.elm-active,h5.elm-active,h6.elm-active');
|
|
60441
|
+
|
|
60442
|
+
if (elmActive) {
|
|
60443
|
+
let elms = elmActive.querySelectorAll('p,h1,h2,h3,h4,h5,h6');
|
|
60444
|
+
|
|
60445
|
+
if (elms.length > 0) {
|
|
60446
|
+
let elmClosestElement = elmActive.nextElementSibling; //Fix text that doesn't have paragraph
|
|
60447
|
+
|
|
60448
|
+
let textNodes = Array.from(elmActive.childNodes).filter(node => node.nodeType === 3 && node.textContent.trim().length > 1);
|
|
60449
|
+
textNodes.forEach(node => {
|
|
60450
|
+
const span = document.createElement('p');
|
|
60451
|
+
node.after(span);
|
|
60452
|
+
span.appendChild(node);
|
|
60453
|
+
});
|
|
60454
|
+
|
|
60455
|
+
if (elmActive.firstElementChild && elmActive.childNodes.length === 1) {
|
|
60456
|
+
if (elmActive.firstElementChild.tagName === 'SPAN') {
|
|
60457
|
+
// Paste HTML with styles
|
|
60458
|
+
elmActive.outerHTML = elmActive.firstElementChild.innerHTML; //fix
|
|
60459
|
+
// Re-clean empty elements
|
|
60460
|
+
|
|
60461
|
+
this.activeCol.querySelectorAll('*:empty').forEach(x => {
|
|
60462
|
+
x.remove();
|
|
60463
|
+
}); //place cursor
|
|
60464
|
+
|
|
60465
|
+
if (elmClosestElement) dom.moveCursorToElement(elmClosestElement.previousElementSibling);else dom.moveCursorToElement(this.activeCol);
|
|
60466
|
+
let builderActive = document.querySelector('.builder-active');
|
|
60467
|
+
if (builderActive) this.applyBehaviorOn(builderActive); //Trigger Change event
|
|
60468
|
+
|
|
60469
|
+
this.opts.onChange(); //Trigger Render event
|
|
60470
|
+
|
|
60471
|
+
this.opts.onRender();
|
|
60472
|
+
return;
|
|
60473
|
+
}
|
|
60474
|
+
} // Paste HTML without styles
|
|
60475
|
+
|
|
60476
|
+
|
|
60477
|
+
elmActive.outerHTML = elmActive.innerHTML; //fix
|
|
60478
|
+
// Re-clean empty elements
|
|
60479
|
+
|
|
60480
|
+
this.activeCol.querySelectorAll('*:empty').forEach(x => {
|
|
60481
|
+
x.remove();
|
|
60482
|
+
}); //place cursor
|
|
60483
|
+
|
|
60484
|
+
if (elmClosestElement) dom.moveCursorToElement(elmClosestElement.previousElementSibling);else dom.moveCursorToElement(this.activeCol);
|
|
60485
|
+
let builderActive = document.querySelector('.builder-active');
|
|
60486
|
+
if (builderActive) this.applyBehaviorOn(builderActive); //Trigger Change event
|
|
60487
|
+
|
|
60488
|
+
this.opts.onChange(); //Trigger Render event
|
|
60489
|
+
|
|
60490
|
+
this.opts.onRender();
|
|
60491
|
+
return;
|
|
60492
|
+
}
|
|
60493
|
+
}
|
|
60494
|
+
}
|
|
60429
60495
|
|
|
60430
60496
|
range.setStartAfter(lastNode);
|
|
60431
60497
|
range.setEndAfter(lastNode);
|