@innovastudio/contentbox 1.6.189 → 1.6.191

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/index.d.ts CHANGED
@@ -404,7 +404,7 @@ interface ContentBoxOptions {
404
404
  activeStyleOffset?: number;
405
405
  contentStylesVersion?: number;
406
406
 
407
- getInlineTypographyStyle?: (scope: string) => void;
407
+ getInlineTypographyStyle?: (classname: string) => void;
408
408
  }
409
409
 
410
410
  interface OpenModalOptions {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbox",
3
3
  "type": "module",
4
- "version": "1.6.189",
4
+ "version": "1.6.191",
5
5
  "description": "",
6
6
  "main": "public/contentbox/contentbox.esm.js",
7
7
  "types": "index.d.ts",
@@ -158970,7 +158970,8 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
158970
158970
  };
158971
158971
  this.settings = Object.assign(this, defaults, settings);
158972
158972
  this.screenMode = this.settings.screenMode; // Expose as direct property
158973
- // this.activeBox = null;
158973
+
158974
+ this.onLoadHtml = null; // this.activeBox = null;
158974
158975
  // this.activeSection = null;
158975
158976
 
158976
158977
  if (this.contentStylesVersion === 2) {
@@ -162716,18 +162717,33 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
162716
162717
  section.classList.forEach(item => {
162717
162718
  if (item.indexOf('type-') !== -1) {
162718
162719
  const contentClass = item;
162719
- const contentCss = item + '.css'; //Add css
162720
+ const contentCss = item + '.css'; // Check if it's an inline style or external CSS file
162720
162721
 
162721
- let exist = false;
162722
- let links = this.doc.getElementsByTagName('link');
162722
+ const cssText = this.getInlineTypographyStyle && this.getInlineTypographyStyle(contentClass);
162723
162723
 
162724
- for (let i = 0; i < links.length; i++) {
162725
- let src = links[i].href.toLowerCase();
162726
- if (src.indexOf(contentCss.toLowerCase()) !== -1) exist = true;
162727
- }
162724
+ if (cssText) {
162725
+ // Add inline style
162726
+ const styleExists = [...this.doc.querySelectorAll('style[data-class]')].some(style => style.dataset.class === contentClass);
162728
162727
 
162729
- if (!exist) {
162730
- this.wrapperEl.insertAdjacentHTML('beforeend', '<link data-name="contentstyle" data-class="' + contentClass + '" href="' + contentStylePath + contentCss + '" rel="stylesheet">');
162728
+ if (!styleExists) {
162729
+ const styleEl = this.doc.createElement('style');
162730
+ styleEl.dataset.class = contentClass;
162731
+ styleEl.textContent = cssText;
162732
+ this.doc.head.appendChild(styleEl);
162733
+ }
162734
+ } else {
162735
+ // Add external CSS file
162736
+ let exist = false;
162737
+ let links = this.doc.getElementsByTagName('link');
162738
+
162739
+ for (let i = 0; i < links.length; i++) {
162740
+ let src = links[i].href.toLowerCase();
162741
+ if (src.indexOf(contentCss.toLowerCase()) !== -1) exist = true;
162742
+ }
162743
+
162744
+ if (!exist) {
162745
+ this.wrapperEl.insertAdjacentHTML('beforeend', '<link data-name="contentstyle" data-class="' + contentClass + '" href="' + contentStylePath + contentCss + '" rel="stylesheet">');
162746
+ }
162731
162747
  }
162732
162748
  }
162733
162749
  }); // Code Blocks Handling
@@ -163566,6 +163582,26 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
163566
163582
  }
163567
163583
  }
163568
163584
 
163585
+ loadStyles_BAK(mainCss, sectionCss) {
163586
+ // Wait for IFRAME loaded
163587
+ const wrapper = this.wrapperEl;
163588
+
163589
+ if (!wrapper) {
163590
+ setTimeout(() => {
163591
+ this.loadStyles(mainCss, sectionCss);
163592
+ }, 100);
163593
+ return;
163594
+ }
163595
+
163596
+ if (mainCss && mainCss !== '') {
163597
+ this.doc.head.insertAdjacentHTML('beforeend', mainCss); // add the style on the head
163598
+ }
163599
+
163600
+ if (sectionCss && sectionCss !== '') {
163601
+ this.doc.head.insertAdjacentHTML('beforeend', sectionCss); // add the style on the head
163602
+ }
163603
+ }
163604
+
163569
163605
  getWrapper() {
163570
163606
  return this.wrapperEl;
163571
163607
  }