@innovastudio/contentbuilder 1.1.3 → 1.1.6
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 +1 -1
- package/public/contentbuilder/config.js +1 -2
- package/public/contentbuilder/contentbuilder.css +2 -2
- package/public/contentbuilder/contentbuilder.esm.js +165 -70
- package/public/contentbuilder/contentbuilder.min.js +6 -6
- package/public/contentbuilder/plugins/buttoneditor/plugin.js +18 -12
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
//PLUGINS
|
|
2
|
-
// _cb.settings.plugins = ['preview','wordcount',
|
|
2
|
+
// _cb.settings.plugins = ['preview','wordcount', 'symbols']; // old way
|
|
3
3
|
_cb.settings.plugins = [
|
|
4
4
|
{ name: 'preview', showInMainToolbar: true, showInElementToolbar: true },
|
|
5
5
|
{ name: 'wordcount', showInMainToolbar: true, showInElementToolbar: true },
|
|
6
6
|
{ name: 'symbols', showInMainToolbar: true, showInElementToolbar: false },
|
|
7
|
-
{ name: 'buttoneditor', showInMainToolbar: false, showInElementToolbar: false },
|
|
8
7
|
];
|
|
@@ -2093,11 +2093,11 @@ button:focus {
|
|
|
2093
2093
|
position: fixed;
|
|
2094
2094
|
overflow: hidden;
|
|
2095
2095
|
width: 520px;
|
|
2096
|
-
height:
|
|
2096
|
+
height: 686px;
|
|
2097
2097
|
top: 50%;
|
|
2098
2098
|
left: auto;
|
|
2099
2099
|
right: 30%;
|
|
2100
|
-
margin-top: -
|
|
2100
|
+
margin-top: -383px;
|
|
2101
2101
|
box-sizing: content-box;
|
|
2102
2102
|
flex-direction: row;
|
|
2103
2103
|
align-items: flex-start;
|
|
@@ -4513,6 +4513,11 @@ class Util {
|
|
|
4513
4513
|
} // LATER: auto scroll
|
|
4514
4514
|
// LATER: If image, then it needs time to load (resulting incorrect position), so hide element tool.
|
|
4515
4515
|
|
|
4516
|
+
}
|
|
4517
|
+
|
|
4518
|
+
if (this.builder.useCssClasses) {
|
|
4519
|
+
let builderActive = document.querySelector('.builder-active');
|
|
4520
|
+
if (builderActive) dom.contentReformat(builderActive, this.builder.cssClasses);
|
|
4516
4521
|
} // Call onChange
|
|
4517
4522
|
|
|
4518
4523
|
|
|
@@ -4741,6 +4746,11 @@ class Util {
|
|
|
4741
4746
|
|
|
4742
4747
|
columnTool = document.querySelector('.is-column-tool');
|
|
4743
4748
|
columnTool.className = columnTool.className.replace('active', '');
|
|
4749
|
+
}
|
|
4750
|
+
|
|
4751
|
+
if (this.builder.useCssClasses) {
|
|
4752
|
+
let builderActive = document.querySelector('.builder-active');
|
|
4753
|
+
if (builderActive) dom.contentReformat(builderActive, this.builder.cssClasses);
|
|
4744
4754
|
} // Call onChange
|
|
4745
4755
|
|
|
4746
4756
|
|
|
@@ -7734,39 +7744,6 @@ class Dom {
|
|
|
7734
7744
|
if (!removeEmptyStyleChildren || removeEmptyStyleChildren.length <= 0) {
|
|
7735
7745
|
return;
|
|
7736
7746
|
}
|
|
7737
|
-
}
|
|
7738
|
-
|
|
7739
|
-
cleanEmptySpans(area) {
|
|
7740
|
-
let spans = area.querySelectorAll('span');
|
|
7741
|
-
const filter = Array.prototype.filter;
|
|
7742
|
-
let children = filter.call(spans, element => {
|
|
7743
|
-
return element.attributes.length === 0;
|
|
7744
|
-
}); // Remove empty spans
|
|
7745
|
-
|
|
7746
|
-
if (children && children.length > 0) {
|
|
7747
|
-
children.forEach(element => {
|
|
7748
|
-
element.outerHTML = element.innerHTML;
|
|
7749
|
-
});
|
|
7750
|
-
} // Remove spans which have empty content
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
spans = area.querySelectorAll('span');
|
|
7754
|
-
filter.call(spans, element => {
|
|
7755
|
-
if (element.innerHTML === '') {
|
|
7756
|
-
element.parentNode.removeChild(element);
|
|
7757
|
-
}
|
|
7758
|
-
}); // Recheck
|
|
7759
|
-
|
|
7760
|
-
spans = area.querySelectorAll('span');
|
|
7761
|
-
children = filter.call(spans, element => {
|
|
7762
|
-
return element.attributes.length === 0;
|
|
7763
|
-
});
|
|
7764
|
-
|
|
7765
|
-
if (children && children.length > 0) {
|
|
7766
|
-
this.cleanEmptySpans(area);
|
|
7767
|
-
} else {
|
|
7768
|
-
return;
|
|
7769
|
-
}
|
|
7770
7747
|
} // Font Size stuff
|
|
7771
7748
|
|
|
7772
7749
|
|
|
@@ -7843,7 +7820,7 @@ class Dom {
|
|
|
7843
7820
|
}
|
|
7844
7821
|
});
|
|
7845
7822
|
});
|
|
7846
|
-
this.cleanUnusedSpan(elm); // causes lost selection
|
|
7823
|
+
this.cleanUnusedSpan(elm); // REVIEW (causes lost selection)
|
|
7847
7824
|
}
|
|
7848
7825
|
|
|
7849
7826
|
cleanSelection(selection) {
|
|
@@ -7855,40 +7832,135 @@ class Dom {
|
|
|
7855
7832
|
selection.selectAllChildren(span);
|
|
7856
7833
|
this.cleanElement(span);
|
|
7857
7834
|
}
|
|
7858
|
-
|
|
7835
|
+
/*
|
|
7859
7836
|
cleanUnusedSpan(span) {
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
} // Direct children with no style
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
const children = Array.from(span.children).filter(element => {
|
|
7866
|
-
if (element.getAttribute('style') === '' || element.style === null) {
|
|
7867
|
-
element.removeAttribute('style');
|
|
7837
|
+
if (!span.hasChildNodes()) {
|
|
7838
|
+
return;
|
|
7868
7839
|
}
|
|
7840
|
+
// Direct children with no style
|
|
7841
|
+
const children = Array.from(span.children).filter((element) => {
|
|
7842
|
+
if (element.getAttribute('style') === '' || element.style === null) {
|
|
7843
|
+
element.removeAttribute('style');
|
|
7844
|
+
}
|
|
7845
|
+
let unused = ( element.attributes.length === 0 || (element.attributes.length === 1 && element.hasAttribute('data-keep')));
|
|
7846
|
+
return (element.nodeName.toLowerCase() === 'span' && unused);
|
|
7847
|
+
});
|
|
7848
|
+
if (children && children.length > 0) {
|
|
7849
|
+
children.forEach((element) => {
|
|
7850
|
+
const text = document.createTextNode(element.textContent);
|
|
7851
|
+
element.parentElement.replaceChild(text, element);
|
|
7852
|
+
});
|
|
7853
|
+
return;
|
|
7854
|
+
}
|
|
7855
|
+
// Deeper childrens
|
|
7856
|
+
const cleanUnusedSpanChildren = Array.from(span.children).map((element) => {
|
|
7857
|
+
return this.cleanUnusedSpan(element);
|
|
7858
|
+
});
|
|
7859
|
+
if (!cleanUnusedSpanChildren || cleanUnusedSpanChildren.length <= 0) {
|
|
7860
|
+
return;
|
|
7861
|
+
}
|
|
7862
|
+
}
|
|
7863
|
+
*/
|
|
7869
7864
|
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7865
|
+
|
|
7866
|
+
cleanUnusedSpan(area) {
|
|
7867
|
+
let spans = area.querySelectorAll('span');
|
|
7868
|
+
const filter = Array.prototype.filter;
|
|
7869
|
+
let children = filter.call(spans, element => {
|
|
7870
|
+
return element.attributes.length === 0;
|
|
7871
|
+
}); // Remove empty spans
|
|
7873
7872
|
|
|
7874
7873
|
if (children && children.length > 0) {
|
|
7875
7874
|
children.forEach(element => {
|
|
7876
|
-
|
|
7877
|
-
element.parentElement.replaceChild(text, element);
|
|
7875
|
+
element.outerHTML = element.innerHTML;
|
|
7878
7876
|
});
|
|
7879
|
-
|
|
7880
|
-
} // Deeper childrens
|
|
7877
|
+
} // Remove spans which have empty content
|
|
7881
7878
|
|
|
7882
7879
|
|
|
7883
|
-
|
|
7884
|
-
|
|
7880
|
+
spans = area.querySelectorAll('span');
|
|
7881
|
+
filter.call(spans, element => {
|
|
7882
|
+
if (element.innerHTML === '') {
|
|
7883
|
+
element.parentNode.removeChild(element);
|
|
7884
|
+
}
|
|
7885
|
+
}); // Recheck
|
|
7886
|
+
|
|
7887
|
+
spans = area.querySelectorAll('span');
|
|
7888
|
+
children = filter.call(spans, element => {
|
|
7889
|
+
return element.attributes.length === 0;
|
|
7885
7890
|
});
|
|
7886
7891
|
|
|
7887
|
-
if (
|
|
7892
|
+
if (children && children.length > 0) {
|
|
7893
|
+
this.cleanUnusedSpan(area);
|
|
7894
|
+
} else {
|
|
7888
7895
|
return;
|
|
7889
7896
|
}
|
|
7890
7897
|
}
|
|
7891
7898
|
|
|
7899
|
+
contentReformat(area, cssClasses) {
|
|
7900
|
+
this.replaceTag(area, 'b', cssClasses.fontWeight.defaultBold);
|
|
7901
|
+
this.replaceTag(area, 'i', cssClasses.fontStyle.italic);
|
|
7902
|
+
this.replaceTag(area, 'u', cssClasses.textDecoration.underline);
|
|
7903
|
+
this.replaceTag(area, 'strike', cssClasses.textDecoration.linethrough);
|
|
7904
|
+
this.replaceInline(area, 'font-weight', 'bold', cssClasses.fontWeight.defaultBold);
|
|
7905
|
+
this.replaceInline(area, 'text-align', 'left', 'text-left');
|
|
7906
|
+
this.replaceInline(area, 'text-align', 'right', 'text-right');
|
|
7907
|
+
this.replaceInline(area, 'text-align', 'center', 'text-center');
|
|
7908
|
+
this.replaceInline(area, 'text-align', 'justify', 'text-justify');
|
|
7909
|
+
this.replaceInline(area, 'display', 'flex', 'flex');
|
|
7910
|
+
this.replaceInline(area, 'justiify-content', 'flex-start', 'justify-start');
|
|
7911
|
+
this.replaceInline(area, 'justiify-content', 'flex-end', 'justify-end');
|
|
7912
|
+
this.replaceInline(area, 'justiify-content', 'center', 'justify-center');
|
|
7913
|
+
this.replaceInline(area, 'justiify-content', 'space-between', 'justify-between');
|
|
7914
|
+
this.replaceInline(area, 'align-items', 'flex-start', 'items-start');
|
|
7915
|
+
this.replaceInline(area, 'align-items', 'flex-end', 'items-end');
|
|
7916
|
+
this.replaceInline(area, 'align-items', 'center', 'items-center');
|
|
7917
|
+
this.replaceInline(area, 'text-transform', 'uppercase', 'uppercase');
|
|
7918
|
+
this.replaceInline(area, 'text-transform', 'lowercase', 'lowercase');
|
|
7919
|
+
this.replaceInline(area, 'line-height', '1', 'leading-none');
|
|
7920
|
+
this.replaceInline(area, 'line-height', '1.1', 'leading-11');
|
|
7921
|
+
this.replaceInline(area, 'line-height', '1.2', 'leading-12');
|
|
7922
|
+
this.replaceInline(area, 'line-height', '1.25', 'leading-tight');
|
|
7923
|
+
this.replaceInline(area, 'line-height', '1.3', 'leading-13');
|
|
7924
|
+
this.replaceInline(area, 'line-height', '1.375', 'leading-snug');
|
|
7925
|
+
this.replaceInline(area, 'line-height', '1.4', 'leading-14');
|
|
7926
|
+
this.replaceInline(area, 'line-height', '1.5', 'leading-15');
|
|
7927
|
+
this.replaceInline(area, 'line-height', '1.6', 'leading-16');
|
|
7928
|
+
this.replaceInline(area, 'line-height', '1.625', 'leading-relaxed');
|
|
7929
|
+
this.replaceInline(area, 'line-height', '1.7', 'leading-17');
|
|
7930
|
+
this.replaceInline(area, 'line-height', '1.8', 'leading-18');
|
|
7931
|
+
this.replaceInline(area, 'line-height', '1.9', 'leading-19');
|
|
7932
|
+
this.replaceInline(area, 'line-height', '2', 'leading-loose');
|
|
7933
|
+
this.replaceInline(area, 'line-height', '2.1', 'leading-21');
|
|
7934
|
+
this.replaceInline(area, 'line-height', '2.2', 'leading-22');
|
|
7935
|
+
}
|
|
7936
|
+
|
|
7937
|
+
replaceTag(area, tag, className) {
|
|
7938
|
+
let elms = area.querySelectorAll(tag);
|
|
7939
|
+
const filter = Array.prototype.filter;
|
|
7940
|
+
let children = filter.call(elms, element => {
|
|
7941
|
+
return element.attributes.length === 0;
|
|
7942
|
+
});
|
|
7943
|
+
|
|
7944
|
+
if (children && children.length > 0) {
|
|
7945
|
+
children.forEach(element => {
|
|
7946
|
+
const span = document.createElement('span');
|
|
7947
|
+
span.setAttribute('class', className);
|
|
7948
|
+
span.innerHTML = element.innerHTML;
|
|
7949
|
+
element.outerHTML = span.outerHTML;
|
|
7950
|
+
});
|
|
7951
|
+
}
|
|
7952
|
+
}
|
|
7953
|
+
|
|
7954
|
+
replaceInline(builder, css, value, className) {
|
|
7955
|
+
let elms = builder.querySelectorAll('*');
|
|
7956
|
+
elms.forEach(elm => {
|
|
7957
|
+
if (elm.style[css] === `${value}`) {
|
|
7958
|
+
this.addClass(elm, className);
|
|
7959
|
+
elm.style[css] = '';
|
|
7960
|
+
}
|
|
7961
|
+
});
|
|
7962
|
+
}
|
|
7963
|
+
|
|
7892
7964
|
}
|
|
7893
7965
|
|
|
7894
7966
|
var js$1 = {exports: {}};
|
|
@@ -13458,7 +13530,7 @@ class HtmlUtil {
|
|
|
13458
13530
|
} // Clean unused spans
|
|
13459
13531
|
|
|
13460
13532
|
|
|
13461
|
-
dom$I.cleanUnusedSpan(content);
|
|
13533
|
+
dom$I.cleanUnusedSpan(content); // REVIEW
|
|
13462
13534
|
}
|
|
13463
13535
|
|
|
13464
13536
|
const util = this.builder.util;
|
|
@@ -15642,18 +15714,31 @@ const renderQuickAdd = builder => {
|
|
|
15642
15714
|
elm = quickadd.querySelector('.add-button');
|
|
15643
15715
|
if (elm) dom$F.addEventListener(elm, 'click', () => {
|
|
15644
15716
|
const mode = quickadd.getAttribute('data-mode');
|
|
15645
|
-
|
|
15717
|
+
let html = `<div>
|
|
15646
15718
|
<a href="#" class="transition-all inline-block cursor-pointer no-underline border-2 border-solid border-transparent ml-1 mr-1 hover:border-transparent rounded bg-gray-200 hover:bg-gray-300 tracking-75 uppercase py-2 size-14 px-8 font-semibold text-gray-600">Read More</a>
|
|
15647
15719
|
</div>`;
|
|
15720
|
+
|
|
15721
|
+
if (builder.opts.emailMode) {
|
|
15722
|
+
html = '<div><a href="#" style="margin-top: ;margin-right: ;margin-bottom: ;margin-left: ;display: inline-block; text-decoration: none; transition: all 0.16s ease 0s; border-style: solid; cursor: pointer; background-color: rgb(220, 220, 220); color: rgb(0, 0, 0); border-color: rgb(220, 220, 220); border-width: 2px; border-radius: 0px; padding: 13px 28px; line-height: 21px; text-transform: uppercase; font-weight: 400; font-size: 14px; letter-spacing: 3px;">Read More</a></div>';
|
|
15723
|
+
}
|
|
15724
|
+
|
|
15648
15725
|
util.addContent(html, mode);
|
|
15649
15726
|
});
|
|
15650
15727
|
elm = quickadd.querySelector('.add-twobutton');
|
|
15651
15728
|
if (elm) dom$F.addEventListener(elm, 'click', () => {
|
|
15652
15729
|
const mode = quickadd.getAttribute('data-mode');
|
|
15653
|
-
|
|
15730
|
+
let html = `<div>
|
|
15654
15731
|
<a href="#" class="transition-all inline-block cursor-pointer no-underline border-2 border-solid border-transparent ml-1 mr-1 hover:border-transparent rounded bg-gray-200 hover:bg-gray-300 tracking-75 uppercase py-2 size-14 px-8 font-semibold text-gray-600">Read More</a>
|
|
15655
15732
|
<a href="#" class="transition-all inline-block cursor-pointer no-underline border-2 border-solid ml-1 mr-1 rounded tracking-75 uppercase py-2 size-14 px-8 border-current hover:border-transparent hover:text-white font-semibold text-indigo-500 hover:bg-indigo-500">Get Started</a>
|
|
15656
15733
|
</div>`;
|
|
15734
|
+
|
|
15735
|
+
if (builder.opts.emailMode) {
|
|
15736
|
+
html = `<div>
|
|
15737
|
+
<a href="#" style="margin-top: ;margin-right: ;margin-bottom: ;margin-left: ;display: inline-block; text-decoration: none; transition: all 0.16s ease 0s; border-style: solid; cursor: pointer; background-color: rgb(220, 220, 220); color: rgb(0, 0, 0); border-color: rgb(220, 220, 220); border-width: 2px; border-radius: 0px; padding: 13px 28px; line-height: 21px; text-transform: uppercase; font-weight: 400; font-size: 14px; letter-spacing: 3px;">Read More</a>
|
|
15738
|
+
<a href="#" style="display: inline-block; text-decoration: none; transition: all 0.16s ease 0s; border-style: solid; cursor: pointer; background-color: rgba(0, 0, 0, 0); border-color: rgb(53, 53, 53); border-width: 2px; border-radius: 0px; padding: 13px 28px; line-height: 21px; text-transform: uppercase; font-weight: 600; font-size: 14px; letter-spacing: 3px; color: rgb(53, 53, 53);">Get Started</a>
|
|
15739
|
+
</div>`;
|
|
15740
|
+
}
|
|
15741
|
+
|
|
15657
15742
|
util.addContent(html, mode);
|
|
15658
15743
|
});
|
|
15659
15744
|
elm = quickadd.querySelector('.add-spacer');
|
|
@@ -66100,12 +66185,6 @@ class ContentBuilder {
|
|
|
66100
66185
|
defaultBold: 'font-semibold',
|
|
66101
66186
|
defaultNormal: 'font-light'
|
|
66102
66187
|
},
|
|
66103
|
-
textAlign: {
|
|
66104
|
-
left: 'text-left',
|
|
66105
|
-
center: 'text-center',
|
|
66106
|
-
right: 'text-right',
|
|
66107
|
-
justify: 'text-justify'
|
|
66108
|
-
},
|
|
66109
66188
|
fontStyle: {
|
|
66110
66189
|
italic: 'italic',
|
|
66111
66190
|
normal: 'not-italic'
|
|
@@ -66311,6 +66390,12 @@ class ContentBuilder {
|
|
|
66311
66390
|
superscript: 'sup',
|
|
66312
66391
|
subscript: 'sub'
|
|
66313
66392
|
},
|
|
66393
|
+
textAlign: {
|
|
66394
|
+
left: 'text-left',
|
|
66395
|
+
center: 'text-center',
|
|
66396
|
+
right: 'text-right',
|
|
66397
|
+
justify: 'text-justify'
|
|
66398
|
+
},
|
|
66314
66399
|
display: {
|
|
66315
66400
|
flex: 'flex',
|
|
66316
66401
|
block: 'block',
|
|
@@ -66344,7 +66429,8 @@ class ContentBuilder {
|
|
|
66344
66429
|
stretch: 'items-stretch'
|
|
66345
66430
|
}
|
|
66346
66431
|
},
|
|
66347
|
-
useCssClasses:
|
|
66432
|
+
useCssClasses: true,
|
|
66433
|
+
useButtonPlugin: false
|
|
66348
66434
|
}; // obj.preserveSelection = true; (can be set programmatically) to prevent click that clears selection on external custom modal.
|
|
66349
66435
|
|
|
66350
66436
|
this.opts = Object.assign(this, defaults, opts);
|
|
@@ -66407,16 +66493,19 @@ class ContentBuilder {
|
|
|
66407
66493
|
this.opts.onMediaUpload = this.opts.onLargerImageUpload;
|
|
66408
66494
|
} else if (this.opts.onMediaUpload) {
|
|
66409
66495
|
this.opts.onLargerImageUpload = this.opts.onMediaUpload;
|
|
66410
|
-
} //
|
|
66496
|
+
} // useButtonPlugin
|
|
66497
|
+
|
|
66411
66498
|
|
|
66499
|
+
if (this.opts.emailMode) {
|
|
66500
|
+
this.useButtonPlugin = true;
|
|
66501
|
+
}
|
|
66412
66502
|
|
|
66413
|
-
|
|
66414
|
-
|
|
66503
|
+
if (!this.useButtonPlugin) {
|
|
66504
|
+
let _arr = this.plugins.filter(item => {
|
|
66505
|
+
return item.name !== 'buttoneditor';
|
|
66506
|
+
});
|
|
66415
66507
|
|
|
66416
|
-
|
|
66417
|
-
if (plugins[i].name === 'buttoneditor') {
|
|
66418
|
-
this.useButtonPlugin = true;
|
|
66419
|
-
}
|
|
66508
|
+
this.plugins = [..._arr];
|
|
66420
66509
|
} // Alternative settions to define css grid frameworks
|
|
66421
66510
|
|
|
66422
66511
|
|
|
@@ -66838,6 +66927,8 @@ class ContentBuilder {
|
|
|
66838
66927
|
const builders = document.querySelectorAll(this.opts.container);
|
|
66839
66928
|
Array.prototype.forEach.call(builders, builder => {
|
|
66840
66929
|
this.applyBehaviorOn(builder); // includes setZoomOnControl
|
|
66930
|
+
|
|
66931
|
+
this.contentReformatOn(builder);
|
|
66841
66932
|
}); // Call onRender to indicate content is ready for editing (applyBehavior has been applied)
|
|
66842
66933
|
|
|
66843
66934
|
this.opts.onRender();
|
|
@@ -66845,6 +66936,10 @@ class ContentBuilder {
|
|
|
66845
66936
|
} // applyBehavior
|
|
66846
66937
|
|
|
66847
66938
|
|
|
66939
|
+
contentReformatOn(builder) {
|
|
66940
|
+
if (this.opts.useCssClasses) dom.contentReformat(builder, this.opts.cssClasses);
|
|
66941
|
+
}
|
|
66942
|
+
|
|
66848
66943
|
applyBehaviorOn(builder) {
|
|
66849
66944
|
const util = this.util; //Make absolute
|
|
66850
66945
|
|