@innovastudio/contentbuilder 1.1.5 → 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
CHANGED
|
@@ -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;
|
|
@@ -66113,12 +66185,6 @@ class ContentBuilder {
|
|
|
66113
66185
|
defaultBold: 'font-semibold',
|
|
66114
66186
|
defaultNormal: 'font-light'
|
|
66115
66187
|
},
|
|
66116
|
-
textAlign: {
|
|
66117
|
-
left: 'text-left',
|
|
66118
|
-
center: 'text-center',
|
|
66119
|
-
right: 'text-right',
|
|
66120
|
-
justify: 'text-justify'
|
|
66121
|
-
},
|
|
66122
66188
|
fontStyle: {
|
|
66123
66189
|
italic: 'italic',
|
|
66124
66190
|
normal: 'not-italic'
|
|
@@ -66324,6 +66390,12 @@ class ContentBuilder {
|
|
|
66324
66390
|
superscript: 'sup',
|
|
66325
66391
|
subscript: 'sub'
|
|
66326
66392
|
},
|
|
66393
|
+
textAlign: {
|
|
66394
|
+
left: 'text-left',
|
|
66395
|
+
center: 'text-center',
|
|
66396
|
+
right: 'text-right',
|
|
66397
|
+
justify: 'text-justify'
|
|
66398
|
+
},
|
|
66327
66399
|
display: {
|
|
66328
66400
|
flex: 'flex',
|
|
66329
66401
|
block: 'block',
|
|
@@ -66357,7 +66429,7 @@ class ContentBuilder {
|
|
|
66357
66429
|
stretch: 'items-stretch'
|
|
66358
66430
|
}
|
|
66359
66431
|
},
|
|
66360
|
-
useCssClasses:
|
|
66432
|
+
useCssClasses: true,
|
|
66361
66433
|
useButtonPlugin: false
|
|
66362
66434
|
}; // obj.preserveSelection = true; (can be set programmatically) to prevent click that clears selection on external custom modal.
|
|
66363
66435
|
|
|
@@ -66855,6 +66927,8 @@ class ContentBuilder {
|
|
|
66855
66927
|
const builders = document.querySelectorAll(this.opts.container);
|
|
66856
66928
|
Array.prototype.forEach.call(builders, builder => {
|
|
66857
66929
|
this.applyBehaviorOn(builder); // includes setZoomOnControl
|
|
66930
|
+
|
|
66931
|
+
this.contentReformatOn(builder);
|
|
66858
66932
|
}); // Call onRender to indicate content is ready for editing (applyBehavior has been applied)
|
|
66859
66933
|
|
|
66860
66934
|
this.opts.onRender();
|
|
@@ -66862,6 +66936,10 @@ class ContentBuilder {
|
|
|
66862
66936
|
} // applyBehavior
|
|
66863
66937
|
|
|
66864
66938
|
|
|
66939
|
+
contentReformatOn(builder) {
|
|
66940
|
+
if (this.opts.useCssClasses) dom.contentReformat(builder, this.opts.cssClasses);
|
|
66941
|
+
}
|
|
66942
|
+
|
|
66865
66943
|
applyBehaviorOn(builder) {
|
|
66866
66944
|
const util = this.util; //Make absolute
|
|
66867
66945
|
|