@innovastudio/contentbuilder 1.3.23 → 1.3.25
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
|
@@ -70555,7 +70555,7 @@ class Rte {
|
|
|
70555
70555
|
|
|
70556
70556
|
if (count < 3) {
|
|
70557
70557
|
//not used
|
|
70558
|
-
|
|
70558
|
+
let attr = links[i].getAttribute('data-protect');
|
|
70559
70559
|
|
|
70560
70560
|
if (!attr) {
|
|
70561
70561
|
links[i].setAttribute('data-rel', '_del');
|
|
@@ -70686,17 +70686,11 @@ class Rte {
|
|
|
70686
70686
|
fontname = fontname.replace(/'/g, ''); // NEW 4.0.5 (replace quotes in font family)
|
|
70687
70687
|
|
|
70688
70688
|
if (provider === 'google') {
|
|
70689
|
-
|
|
70690
|
-
|
|
70691
|
-
|
|
70692
|
-
for (i = 0; i < links.length; i++) {
|
|
70693
|
-
var sSrc = links[i].href.toLowerCase();
|
|
70694
|
-
sSrc = sSrc.replace(/\+/g, ' ').replace(/%20/g, ' ');
|
|
70695
|
-
if (sSrc.indexOf(fontname.toLowerCase()) !== -1) bExist = true;
|
|
70696
|
-
}
|
|
70689
|
+
let bExist = false;
|
|
70690
|
+
bExist = this.checkIfFontCssLinkExists(fontfamily);
|
|
70697
70691
|
|
|
70698
70692
|
if (!bExist) {
|
|
70699
|
-
|
|
70693
|
+
let element = elm;
|
|
70700
70694
|
|
|
70701
70695
|
while (!dom.hasClass(element, 'is-builder')) {
|
|
70702
70696
|
element = element.parentNode;
|
|
@@ -70704,16 +70698,37 @@ class Rte {
|
|
|
70704
70698
|
|
|
70705
70699
|
let cssUrl = '';
|
|
70706
70700
|
|
|
70707
|
-
if (this.builder.
|
|
70708
|
-
const cssFileName = fontfamily.split(',')[0].toLowerCase().replace(/\s/g, '-') + '.css';
|
|
70709
|
-
cssUrl = this.builder.
|
|
70710
|
-
dom.appendHtml(element, `<link href="${cssUrl}" rel="stylesheet" property="stylesheet" type="text/css">`);
|
|
70701
|
+
if (this.builder.fontPath) {
|
|
70702
|
+
const cssFileName = fontfamily.split(',')[0].toLowerCase().replace(/'/g, '').replace(/"/g, '').replace(/\s/g, '-') + '.css';
|
|
70703
|
+
cssUrl = this.builder.fontPath + cssFileName;
|
|
70704
|
+
dom.appendHtml(element, `<link data-name="fontfamily" href="${cssUrl}" rel="stylesheet" property="stylesheet" type="text/css">`);
|
|
70711
70705
|
} else {
|
|
70712
70706
|
dom.appendHtml(element, '<link href="//fonts.googleapis.com/css?family=' + fontname + d + o + '" rel="stylesheet" property="stylesheet" type="text/css">');
|
|
70713
70707
|
}
|
|
70714
70708
|
}
|
|
70715
70709
|
}
|
|
70716
70710
|
|
|
70711
|
+
if (provider === 'others') {
|
|
70712
|
+
let bExist = false;
|
|
70713
|
+
bExist = this.checkIfFontCssLinkExists(fontfamily);
|
|
70714
|
+
|
|
70715
|
+
if (!bExist) {
|
|
70716
|
+
let element = elm;
|
|
70717
|
+
|
|
70718
|
+
while (!dom.hasClass(element, 'is-builder')) {
|
|
70719
|
+
element = element.parentNode;
|
|
70720
|
+
}
|
|
70721
|
+
|
|
70722
|
+
let cssUrl = '';
|
|
70723
|
+
|
|
70724
|
+
if (this.builder.fontPath) {
|
|
70725
|
+
const cssFileName = fontfamily.split(',')[0].toLowerCase().replace(/'/g, '').replace(/"/g, '').replace(/\s/g, '-') + '.css';
|
|
70726
|
+
cssUrl = this.builder.fontPath + cssFileName;
|
|
70727
|
+
dom.appendHtml(element, `<link data-name="fontfamily" href="${cssUrl}" rel="stylesheet" property="stylesheet" type="text/css">`);
|
|
70728
|
+
}
|
|
70729
|
+
}
|
|
70730
|
+
}
|
|
70731
|
+
|
|
70717
70732
|
if (!this.builder.inspectedElement) {
|
|
70718
70733
|
//save selection
|
|
70719
70734
|
this.util.saveSelection(); //Needed because after format, a tag is added (ex. <span>), so, make selection again.
|
|
@@ -70728,9 +70743,12 @@ class Rte {
|
|
|
70728
70743
|
} //Trigger Change event
|
|
70729
70744
|
|
|
70730
70745
|
|
|
70731
|
-
this.builder.opts.onChange(); //
|
|
70732
|
-
|
|
70746
|
+
this.builder.opts.onChange(); //Cleanup Google font css link
|
|
70747
|
+
|
|
70748
|
+
this.cleanupFontCssLink();
|
|
70749
|
+
}
|
|
70733
70750
|
|
|
70751
|
+
cleanupFontCssLink() {
|
|
70734
70752
|
const fonts = [];
|
|
70735
70753
|
|
|
70736
70754
|
if (this.builder.opts.page !== '') {
|
|
@@ -70747,54 +70765,64 @@ class Rte {
|
|
|
70747
70765
|
if (fonts.indexOf(fontFamily) === -1) fonts.push(fontFamily);
|
|
70748
70766
|
});
|
|
70749
70767
|
});
|
|
70750
|
-
}
|
|
70768
|
+
} // Cleanup
|
|
70751
70769
|
|
|
70752
|
-
links = this.builder.doc.getElementsByTagName('link');
|
|
70753
70770
|
|
|
70754
|
-
|
|
70755
|
-
|
|
70771
|
+
let links = this.builder.doc.getElementsByTagName('link');
|
|
70772
|
+
|
|
70773
|
+
for (let i = 0; i < links.length; i++) {
|
|
70774
|
+
let sSrc = links[i].href.toLowerCase();
|
|
70756
70775
|
|
|
70757
70776
|
if (sSrc.indexOf('googleapis') !== -1) {
|
|
70758
70777
|
//get fontname
|
|
70759
70778
|
sSrc = sSrc.replace(/\+/g, ' ').replace(/%20/g, ' ');
|
|
70760
|
-
|
|
70779
|
+
let linkFontName = sSrc.substr(sSrc.indexOf('family=') + 7);
|
|
70761
70780
|
|
|
70762
|
-
if (
|
|
70763
|
-
|
|
70781
|
+
if (linkFontName.indexOf(':') !== -1) {
|
|
70782
|
+
linkFontName = linkFontName.split(':')[0];
|
|
70764
70783
|
}
|
|
70765
70784
|
|
|
70766
|
-
if (
|
|
70767
|
-
|
|
70785
|
+
if (linkFontName.indexOf('|') !== -1) {
|
|
70786
|
+
linkFontName = linkFontName.split('|')[0];
|
|
70768
70787
|
}
|
|
70769
70788
|
|
|
70770
|
-
|
|
70771
|
-
//console.log(
|
|
70772
|
-
//check if fontname used in content
|
|
70773
|
-
// let tmp = this.builder.doc.body.innerHTML.toLowerCase();
|
|
70789
|
+
linkFontName = linkFontName.replace('&display=swap', ''); // NEW 4.0.5
|
|
70790
|
+
// console.log(linkFontName);
|
|
70791
|
+
// check if fontname used in content
|
|
70774
70792
|
|
|
70775
70793
|
let used = false;
|
|
70776
70794
|
fonts.forEach(item => {
|
|
70777
|
-
if (item.toLowerCase().indexOf(
|
|
70795
|
+
if (item.toLowerCase().indexOf(linkFontName.toLowerCase()) === -1) ; else {
|
|
70778
70796
|
used = true;
|
|
70779
70797
|
}
|
|
70780
70798
|
});
|
|
70781
70799
|
|
|
70782
70800
|
if (!used) {
|
|
70783
70801
|
//not used
|
|
70784
|
-
|
|
70802
|
+
let attr = links[i].getAttribute('data-protect');
|
|
70785
70803
|
|
|
70786
70804
|
if (!attr) {
|
|
70787
70805
|
links[i].setAttribute('data-rel', '_del');
|
|
70788
70806
|
}
|
|
70789
|
-
}
|
|
70790
|
-
|
|
70791
|
-
|
|
70792
|
-
|
|
70793
|
-
|
|
70794
|
-
// links[i].setAttribute('data-rel','_del');
|
|
70795
|
-
// }
|
|
70796
|
-
// }
|
|
70807
|
+
}
|
|
70808
|
+
} else if (links[i].getAttribute('data-name') === 'fontfamily') {
|
|
70809
|
+
let used = false;
|
|
70810
|
+
fonts.forEach(item => {
|
|
70811
|
+
const cssFileName = item.split(',')[0].replace(/'/g, '').replace(/"/g, '').replace(/\s/g, '-').toLowerCase() + '.css';
|
|
70797
70812
|
|
|
70813
|
+
if (sSrc.toLowerCase().indexOf('/' + cssFileName) === -1) ; else {
|
|
70814
|
+
used = true;
|
|
70815
|
+
}
|
|
70816
|
+
});
|
|
70817
|
+
|
|
70818
|
+
if (!used) {
|
|
70819
|
+
//not used
|
|
70820
|
+
let attr = links[i].getAttribute('data-protect');
|
|
70821
|
+
|
|
70822
|
+
if (!attr) {
|
|
70823
|
+
links[i].setAttribute('data-rel', '_del');
|
|
70824
|
+
}
|
|
70825
|
+
}
|
|
70798
70826
|
}
|
|
70799
70827
|
}
|
|
70800
70828
|
|
|
@@ -70803,6 +70831,54 @@ class Rte {
|
|
|
70803
70831
|
});
|
|
70804
70832
|
}
|
|
70805
70833
|
|
|
70834
|
+
checkIfFontCssLinkExists(fontfamily) {
|
|
70835
|
+
let bExist = false;
|
|
70836
|
+
let fontname = fontfamily.split(',')[0];
|
|
70837
|
+
fontname = fontname.replace(/'/g, '');
|
|
70838
|
+
fontname = fontname.replace(/"/g, ''); // (replace double quotes in font family)
|
|
70839
|
+
|
|
70840
|
+
fontname = fontname.toLowerCase();
|
|
70841
|
+
let links = this.builder.doc.getElementsByTagName('link');
|
|
70842
|
+
|
|
70843
|
+
for (let i = 0; i < links.length; i++) {
|
|
70844
|
+
let sSrc = links[i].href.toLowerCase();
|
|
70845
|
+
|
|
70846
|
+
if (sSrc.indexOf('googleapis') !== -1) {
|
|
70847
|
+
if (!this.builder.fontPath) {
|
|
70848
|
+
//get fontname
|
|
70849
|
+
sSrc = sSrc.replace(/\+/g, ' ').replace(/%20/g, ' ');
|
|
70850
|
+
let linkFontName = sSrc.substr(sSrc.indexOf('family=') + 7);
|
|
70851
|
+
|
|
70852
|
+
if (linkFontName.indexOf(':') !== -1) {
|
|
70853
|
+
linkFontName = linkFontName.split(':')[0];
|
|
70854
|
+
}
|
|
70855
|
+
|
|
70856
|
+
if (linkFontName.indexOf('|') !== -1) {
|
|
70857
|
+
linkFontName = linkFontName.split('|')[0];
|
|
70858
|
+
}
|
|
70859
|
+
|
|
70860
|
+
linkFontName = linkFontName.replace('&display=swap', ''); // NEW 4.0.5
|
|
70861
|
+
//check if fontname used in content
|
|
70862
|
+
// let tmp = this.builder.doc.body.innerHTML.toLowerCase();
|
|
70863
|
+
|
|
70864
|
+
if (linkFontName === fontname.toLowerCase()) {
|
|
70865
|
+
bExist = true; // console.log(fontname.toLowerCase() + '-' +linkFontName);
|
|
70866
|
+
}
|
|
70867
|
+
}
|
|
70868
|
+
} else if (links[i].getAttribute('data-name') === 'fontfamily') {
|
|
70869
|
+
if (this.builder.fontPath) {
|
|
70870
|
+
let cssFile = fontname.replace(/\s/g, '-').toLowerCase() + '.css';
|
|
70871
|
+
|
|
70872
|
+
if (sSrc.toLowerCase().indexOf('/' + cssFile) !== -1) {
|
|
70873
|
+
bExist = true;
|
|
70874
|
+
}
|
|
70875
|
+
}
|
|
70876
|
+
}
|
|
70877
|
+
}
|
|
70878
|
+
|
|
70879
|
+
return bExist;
|
|
70880
|
+
}
|
|
70881
|
+
|
|
70806
70882
|
positionToolbar() {
|
|
70807
70883
|
const viewportWidth = document.body.clientWidth; //window.innerWidth;
|
|
70808
70884
|
|
|
@@ -73899,7 +73975,7 @@ class ContentBuilder {
|
|
|
73899
73975
|
// Used for the location of ionicons/ (see rte.js 2788) & scripts/ (see plugins/preview/plugin.js 237)
|
|
73900
73976
|
fontAssetPath: 'assets/fonts/',
|
|
73901
73977
|
// Option for self-hosted fonts:
|
|
73902
|
-
//
|
|
73978
|
+
// fontPath: 'assets/cssfonts/', // If set, will be used
|
|
73903
73979
|
snippetData: 'assets/minimalist-blocks/snippetlist.html',
|
|
73904
73980
|
// Deprecated
|
|
73905
73981
|
snippetUrl: 'assets/minimalist-blocks/content.js',
|