@innovastudio/contentbox 1.1.0 → 1.1.3
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/contentbox",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "public/contentbox/contentbox.esm.js",
|
|
6
6
|
"files": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"webpack-dev-server": "^4.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@innovastudio/contentbuilder": "^1.0.
|
|
41
|
+
"@innovastudio/contentbuilder": "^1.0.83",
|
|
42
42
|
"axios": "^0.21.4",
|
|
43
43
|
"cors": "^2.8.5",
|
|
44
44
|
"express": "^4.17.1",
|
|
@@ -699,8 +699,8 @@ class SideBar {
|
|
|
699
699
|
}
|
|
700
700
|
|
|
701
701
|
viewHtml2() {
|
|
702
|
-
const builderStuff = this.builderStuff;
|
|
703
|
-
|
|
702
|
+
const builderStuff = this.builderStuff; //document.body.style.overflow = 'hidden';
|
|
703
|
+
|
|
704
704
|
let html = this.builder.html(true); //For View
|
|
705
705
|
|
|
706
706
|
builderStuff.querySelector('#inpViewHtml').value = html;
|
|
@@ -50298,7 +50298,7 @@ class Image {
|
|
|
50298
50298
|
// if(initialWidth <200 && initialHeight<200) {
|
|
50299
50299
|
|
|
50300
50300
|
|
|
50301
|
-
if (initialWidth <= 1600 && initialHeight <= 1600) {
|
|
50301
|
+
if (initialWidth <= 1600 && initialHeight <= 1600 && this.builder.opts.maxEmbedImageWidth >= 1600) {
|
|
50302
50302
|
let reader = new FileReader();
|
|
50303
50303
|
reader.addEventListener('load', e => {
|
|
50304
50304
|
if (!document.getElementById('__preview')) {
|
|
@@ -70660,14 +70660,48 @@ class ContentBuilder {
|
|
|
70660
70660
|
sPastedText = util.cleanHTML(sPastedText, true);
|
|
70661
70661
|
}
|
|
70662
70662
|
|
|
70663
|
-
contentword.innerHTML = sPastedText;
|
|
70664
|
-
|
|
70665
|
-
|
|
70666
|
-
|
|
70667
|
-
|
|
70668
|
-
|
|
70669
|
-
|
|
70670
|
-
|
|
70663
|
+
contentword.innerHTML = sPastedText;
|
|
70664
|
+
|
|
70665
|
+
if (this.opts.paste === 'html') {
|
|
70666
|
+
//with styles
|
|
70667
|
+
let elms = contentword.querySelectorAll('*');
|
|
70668
|
+
Array.prototype.forEach.call(elms, elm => {
|
|
70669
|
+
for (let n = 0; n < elm.attributes.length; n++) {
|
|
70670
|
+
if (elm.attributes[n].name !== 'style') elm.removeAttribute(elm.attributes[n].name);
|
|
70671
|
+
}
|
|
70672
|
+
});
|
|
70673
|
+
} else {
|
|
70674
|
+
//html-without-styles (default)
|
|
70675
|
+
const removeAttributes = element => {
|
|
70676
|
+
while (element.attributes.length > 0) {
|
|
70677
|
+
element.removeAttribute(element.attributes[0].name);
|
|
70678
|
+
}
|
|
70679
|
+
};
|
|
70680
|
+
|
|
70681
|
+
let elms = contentword.querySelectorAll('*');
|
|
70682
|
+
Array.prototype.forEach.call(elms, elm => {
|
|
70683
|
+
removeAttributes(elm);
|
|
70684
|
+
});
|
|
70685
|
+
}
|
|
70686
|
+
/*
|
|
70687
|
+
Additional Cleanup:
|
|
70688
|
+
- Remove p inside li
|
|
70689
|
+
- Remove li with white-space: pre
|
|
70690
|
+
*/
|
|
70691
|
+
|
|
70692
|
+
|
|
70693
|
+
let elms = contentword.querySelectorAll('li');
|
|
70694
|
+
Array.prototype.forEach.call(elms, elm => {
|
|
70695
|
+
elm.style.whiteSpace = '';
|
|
70696
|
+
const childNodes = elm.childNodes;
|
|
70697
|
+
let i = childNodes.length;
|
|
70698
|
+
|
|
70699
|
+
while (i--) {
|
|
70700
|
+
if (childNodes[i].tagName === 'P') {
|
|
70701
|
+
childNodes[i].outerHTML = childNodes[i].innerHTML;
|
|
70702
|
+
}
|
|
70703
|
+
}
|
|
70704
|
+
}); // NOTE: paste <h1><p> jadi nempel
|
|
70671
70705
|
// // Source: https://gist.github.com/sbrin/6801034
|
|
70672
70706
|
// jQuery('p', $editor).each(function(){
|
|
70673
70707
|
// var str = jQuery(this).attr('style');
|
|
@@ -70725,10 +70759,7 @@ class ContentBuilder {
|
|
|
70725
70759
|
}
|
|
70726
70760
|
|
|
70727
70761
|
contentword = document.querySelector('#idContentWord');
|
|
70728
|
-
if (contentword) contentword.parentNode.removeChild(contentword);
|
|
70729
|
-
// jQuery('.cell-active').find('.elm-active').removeClass('elm-active');
|
|
70730
|
-
// jQuery("#divElementTool").css("display", "none"); //force hide ellement tool
|
|
70731
|
-
|
|
70762
|
+
if (contentword) contentword.parentNode.removeChild(contentword);
|
|
70732
70763
|
util.restoreSelection();
|
|
70733
70764
|
var oSel = window.getSelection();
|
|
70734
70765
|
var range = oSel.getRangeAt(0);
|
|
@@ -70736,16 +70767,80 @@ class ContentBuilder {
|
|
|
70736
70767
|
range.collapse(true);
|
|
70737
70768
|
var docFrag = range.createContextualFragment(sPastedText);
|
|
70738
70769
|
var lastNode = docFrag.lastChild;
|
|
70739
|
-
range.insertNode(docFrag);
|
|
70740
|
-
|
|
70741
|
-
|
|
70742
|
-
|
|
70743
|
-
|
|
70744
|
-
|
|
70745
|
-
|
|
70746
|
-
|
|
70747
|
-
|
|
70748
|
-
|
|
70770
|
+
range.insertNode(docFrag);
|
|
70771
|
+
|
|
70772
|
+
if (this.activeCol) {
|
|
70773
|
+
/*
|
|
70774
|
+
Additional Cleanup:
|
|
70775
|
+
- Remove empty elements (empty p, etc)
|
|
70776
|
+
*/
|
|
70777
|
+
// $block.find('h1:empty,h2:empty,h3:empty,h4:empty,h5:empty,h6:empty,p:empty').remove();
|
|
70778
|
+
this.activeCol.querySelectorAll('*:empty').forEach(x => {
|
|
70779
|
+
x.remove();
|
|
70780
|
+
});
|
|
70781
|
+
/*
|
|
70782
|
+
Additional Cleanup:
|
|
70783
|
+
Fix HTML structure. The problem:
|
|
70784
|
+
<p class="elm-active">
|
|
70785
|
+
...Sometimes h1, h2, p can be pasted here..
|
|
70786
|
+
</p>
|
|
70787
|
+
*/
|
|
70788
|
+
|
|
70789
|
+
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');
|
|
70790
|
+
|
|
70791
|
+
if (elmActive) {
|
|
70792
|
+
let elms = elmActive.querySelectorAll('p,h1,h2,h3,h4,h5,h6');
|
|
70793
|
+
|
|
70794
|
+
if (elms.length > 0) {
|
|
70795
|
+
let elmClosestElement = elmActive.nextElementSibling; //Fix text that doesn't have paragraph
|
|
70796
|
+
|
|
70797
|
+
let textNodes = Array.from(elmActive.childNodes).filter(node => node.nodeType === 3 && node.textContent.trim().length > 1);
|
|
70798
|
+
textNodes.forEach(node => {
|
|
70799
|
+
const span = document.createElement('p');
|
|
70800
|
+
node.after(span);
|
|
70801
|
+
span.appendChild(node);
|
|
70802
|
+
});
|
|
70803
|
+
|
|
70804
|
+
if (elmActive.firstElementChild && elmActive.childNodes.length === 1) {
|
|
70805
|
+
if (elmActive.firstElementChild.tagName === 'SPAN') {
|
|
70806
|
+
// Paste HTML with styles
|
|
70807
|
+
elmActive.outerHTML = elmActive.firstElementChild.innerHTML; //fix
|
|
70808
|
+
// Re-clean empty elements
|
|
70809
|
+
|
|
70810
|
+
this.activeCol.querySelectorAll('*:empty').forEach(x => {
|
|
70811
|
+
x.remove();
|
|
70812
|
+
}); //place cursor
|
|
70813
|
+
|
|
70814
|
+
if (elmClosestElement) dom$F.moveCursorToElement(elmClosestElement.previousElementSibling);else dom$F.moveCursorToElement(this.activeCol);
|
|
70815
|
+
let builderActive = document.querySelector('.builder-active');
|
|
70816
|
+
if (builderActive) this.applyBehaviorOn(builderActive); //Trigger Change event
|
|
70817
|
+
|
|
70818
|
+
this.opts.onChange(); //Trigger Render event
|
|
70819
|
+
|
|
70820
|
+
this.opts.onRender();
|
|
70821
|
+
return;
|
|
70822
|
+
}
|
|
70823
|
+
} // Paste HTML without styles
|
|
70824
|
+
|
|
70825
|
+
|
|
70826
|
+
elmActive.outerHTML = elmActive.innerHTML; //fix
|
|
70827
|
+
// Re-clean empty elements
|
|
70828
|
+
|
|
70829
|
+
this.activeCol.querySelectorAll('*:empty').forEach(x => {
|
|
70830
|
+
x.remove();
|
|
70831
|
+
}); //place cursor
|
|
70832
|
+
|
|
70833
|
+
if (elmClosestElement) dom$F.moveCursorToElement(elmClosestElement.previousElementSibling);else dom$F.moveCursorToElement(this.activeCol);
|
|
70834
|
+
let builderActive = document.querySelector('.builder-active');
|
|
70835
|
+
if (builderActive) this.applyBehaviorOn(builderActive); //Trigger Change event
|
|
70836
|
+
|
|
70837
|
+
this.opts.onChange(); //Trigger Render event
|
|
70838
|
+
|
|
70839
|
+
this.opts.onRender();
|
|
70840
|
+
return;
|
|
70841
|
+
}
|
|
70842
|
+
}
|
|
70843
|
+
}
|
|
70749
70844
|
|
|
70750
70845
|
range.setStartAfter(lastNode);
|
|
70751
70846
|
range.setEndAfter(lastNode);
|
|
@@ -72155,11 +72250,11 @@ class ContentBox {
|
|
|
72155
72250
|
columnTool: true,
|
|
72156
72251
|
elementTool: true,
|
|
72157
72252
|
buttons: ['bold', 'italic', 'underline', 'formatting', 'color', 'align', 'textsettings', 'createLink', 'tags', '|', 'undo', 'redo', 'zoom', 'more'],
|
|
72158
|
-
buttonsMore: ['icon', 'image', '|', 'list', 'font', 'formatPara', '|', '
|
|
72253
|
+
buttonsMore: ['icon', 'image', '|', 'list', 'font', 'formatPara', '|', 'preferences'],
|
|
72159
72254
|
elementButtons: ['left', 'center', 'right', 'full', 'undo', 'redo', 'zoom', 'more'],
|
|
72160
|
-
elementButtonsMore: ['|', '
|
|
72255
|
+
elementButtonsMore: ['|', 'preferences'],
|
|
72161
72256
|
iconButtons: ['icon', 'color', 'textsettings', 'createLink', '|', 'undo', 'redo', 'zoom', 'more'],
|
|
72162
|
-
iconButtonsMore: ['|', '
|
|
72257
|
+
iconButtonsMore: ['|', 'preferences'],
|
|
72163
72258
|
customTags: [],
|
|
72164
72259
|
animateModal: false,
|
|
72165
72260
|
elementAnimate: true,
|
|
@@ -72196,6 +72291,7 @@ class ContentBox {
|
|
|
72196
72291
|
undoRedoStyles: true,
|
|
72197
72292
|
undoContainerOnly: false,
|
|
72198
72293
|
absolutePath: false,
|
|
72294
|
+
maxEmbedImageWidth: 1600,
|
|
72199
72295
|
zoom: 0.6,
|
|
72200
72296
|
contentStyleWithSample: false,
|
|
72201
72297
|
contentStyles: {
|
|
@@ -74283,6 +74379,7 @@ class ContentBox {
|
|
|
74283
74379
|
snippetJSON: window.data_basic,
|
|
74284
74380
|
snippetPathReplace: this.settings.snippetPathReplace,
|
|
74285
74381
|
maxColumns: 6,
|
|
74382
|
+
maxEmbedImageWidth: this.settings.maxEmbedImageWidth,
|
|
74286
74383
|
slider: this.settings.slider,
|
|
74287
74384
|
onRender: this.settings.onRender,
|
|
74288
74385
|
onChange: this.settings.onChange,
|
|
@@ -74743,6 +74840,7 @@ class ContentBox {
|
|
|
74743
74840
|
|
|
74744
74841
|
dom.appendHtml(this.wrapperEl, newArea, 'afterbegin');
|
|
74745
74842
|
newSection = this.wrapperEl.querySelector('.is-section');
|
|
74843
|
+
arrSections.push(newSection);
|
|
74746
74844
|
} else if (newArea.indexOf('is-static') !== -1) {
|
|
74747
74845
|
// Insert last
|
|
74748
74846
|
let lastSection = dom.getLastElement(this.wrapperEl, '.is-section');
|
|
@@ -74771,6 +74869,10 @@ class ContentBox {
|
|
|
74771
74869
|
}
|
|
74772
74870
|
}
|
|
74773
74871
|
}
|
|
74872
|
+
} else {
|
|
74873
|
+
dom.appendHtml(this.wrapperEl, newArea, 'afterbegin');
|
|
74874
|
+
newSection = this.wrapperEl.querySelector('.is-section');
|
|
74875
|
+
arrSections.push(newSection);
|
|
74774
74876
|
}
|
|
74775
74877
|
} else {
|
|
74776
74878
|
if (this.activeSection) {
|
|
@@ -74852,9 +74954,9 @@ class ContentBox {
|
|
|
74852
74954
|
}
|
|
74853
74955
|
}
|
|
74854
74956
|
}
|
|
74855
|
-
}
|
|
74957
|
+
} // arrSections.push(newSection);
|
|
74958
|
+
// Check up to 3 sections (in case a template has up to 3 sections)
|
|
74856
74959
|
|
|
74857
|
-
arrSections.push(newSection); // Check up to 3 sections (in case a template has up to 3 sections)
|
|
74858
74960
|
|
|
74859
74961
|
let prevSection = newSection.previousElementSibling;
|
|
74860
74962
|
|