@innovastudio/contentbox 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbox",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "",
5
5
  "main": "public/contentbox/contentbox.esm.js",
6
6
  "files": [
@@ -829,7 +829,13 @@ class SideBar {
829
829
  if (src.indexOf(contentCss.toLowerCase()) != -1) exist = true;
830
830
  }
831
831
 
832
- if (!exist) dom$J.appendHtml(document.head, '<link data-name="contentstyle" data-class="' + className + '" href="' + contentStylePath + contentCss + '" rel="stylesheet">');
832
+ if (!exist) {
833
+ if (this.builder.settings.cssInBody) {
834
+ this.builder.wrapperEl.insertAdjacentHTML('beforebegin', '<link data-name="contentstyle" data-class="' + className + '" href="' + contentStylePath + contentCss + '" rel="stylesheet">');
835
+ } else {
836
+ dom$J.appendHtml(document.head, '<link data-name="contentstyle" data-class="' + className + '" href="' + contentStylePath + contentCss + '" rel="stylesheet">');
837
+ }
838
+ }
833
839
  } //Cleanup unused
834
840
 
835
841
 
@@ -888,7 +894,11 @@ class SideBar {
888
894
  }); //Add new page css
889
895
 
890
896
  if (pageCss != '') {
891
- dom$J.appendHtml(document.head, '<link href="' + contentStylePath + pageCss + '" rel="stylesheet">');
897
+ if (this.builder.settings.cssInBody) {
898
+ this.builder.wrapperEl.insertAdjacentHTML('beforebegin', '<link href="' + contentStylePath + pageCss + '" rel="stylesheet">');
899
+ } else {
900
+ dom$J.appendHtml(document.head, '<link href="' + contentStylePath + pageCss + '" rel="stylesheet">');
901
+ }
892
902
  }
893
903
  } else if (mode === 'container') {
894
904
  let builderActive = document.querySelector('.builder-active');
@@ -913,7 +923,13 @@ class SideBar {
913
923
  if (src.indexOf(contentCss.toLowerCase()) != -1) exist = true;
914
924
  }
915
925
 
916
- if (!exist) dom$J.appendHtml(document.head, '<link data-name="contentstyle" data-class="' + className + '" href="' + contentStylePath + contentCss + '" rel="stylesheet">');
926
+ if (!exist) {
927
+ if (this.builder.settings.cssInBody) {
928
+ this.builder.wrapperEl.insertAdjacentHTML('beforebegin', '<link data-name="contentstyle" data-class="' + className + '" href="' + contentStylePath + contentCss + '" rel="stylesheet">');
929
+ } else {
930
+ dom$J.appendHtml(document.head, '<link data-name="contentstyle" data-class="' + className + '" href="' + contentStylePath + contentCss + '" rel="stylesheet">');
931
+ }
932
+ }
917
933
  } //Cleanup unused
918
934
 
919
935
 
@@ -959,7 +975,13 @@ class SideBar {
959
975
  if (src.indexOf(contentCss.toLowerCase()) != -1) exist = true;
960
976
  }
961
977
 
962
- if (!exist) dom$J.appendHtml(document.head, '<link data-name="contentstyle" data-class="' + className + '" href="' + contentStylePath + contentCss + '" rel="stylesheet">');
978
+ if (!exist) {
979
+ if (this.builder.settings.cssInBody) {
980
+ this.builder.wrapperEl.insertAdjacentHTML('beforebegin', '<link data-name="contentstyle" data-class="' + className + '" href="' + contentStylePath + contentCss + '" rel="stylesheet">');
981
+ } else {
982
+ dom$J.appendHtml(document.head, '<link data-name="contentstyle" data-class="' + className + '" href="' + contentStylePath + contentCss + '" rel="stylesheet">');
983
+ }
984
+ }
963
985
  } //Cleanup unused
964
986
 
965
987
 
@@ -78904,6 +78926,7 @@ class ContentBox {
78904
78926
  }]
78905
78927
  }
78906
78928
  },
78929
+ cssInBody: false,
78907
78930
 
78908
78931
  /* Old Version (backward compatible) */
78909
78932
  onAddSectionOpen: function () {},
@@ -79931,6 +79954,7 @@ class ContentBox {
79931
79954
 
79932
79955
  loadStyles(mainCss, sectionCss) {
79933
79956
  let links = document.getElementsByTagName('link');
79957
+ let boxCssInBody;
79934
79958
 
79935
79959
  for (let i = 0; i < links.length; i++) {
79936
79960
  if (links[i].getAttribute('data-name') === 'contentstyle') {
@@ -79939,9 +79963,21 @@ class ContentBox {
79939
79963
 
79940
79964
  if (links[i].getAttribute('href').indexOf('basetype-') !== -1) {
79941
79965
  links[i].setAttribute('data-rel', '_del');
79966
+ } // Check if main css (box.css in inside body)
79967
+
79968
+
79969
+ if (links[i].getAttribute('href').indexOf('/box.css') !== -1 || links[i].getAttribute('href').indexOf('/box-flex.css') !== -1) {
79970
+ if (links[i].parentNode === document.body) {
79971
+ boxCssInBody = true;
79972
+ this.settings.cssInBody = true;
79973
+ }
79942
79974
  }
79943
79975
  }
79944
79976
 
79977
+ if (this.settings.cssInBody) {
79978
+ boxCssInBody = true;
79979
+ }
79980
+
79945
79981
  let elms = document.querySelectorAll('[data-rel="_del"]');
79946
79982
  elms.forEach(elm => {
79947
79983
  elm.parentNode.removeChild(elm);
@@ -79949,10 +79985,18 @@ class ContentBox {
79949
79985
  let page = document.head;
79950
79986
  if (!page) page = document.body;
79951
79987
  if (mainCss) if (mainCss !== '') {
79952
- page.insertAdjacentHTML('beforeend', mainCss); // add the style on the head
79988
+ if (boxCssInBody) {
79989
+ this.wrapperEl.insertAdjacentHTML('beforebegin', mainCss);
79990
+ } else {
79991
+ page.insertAdjacentHTML('beforeend', mainCss); // add the style on the head
79992
+ }
79953
79993
  }
79954
79994
  if (sectionCss) if (sectionCss !== '') {
79955
- page.insertAdjacentHTML('beforeend', sectionCss); // add the style on the head
79995
+ if (boxCssInBody) {
79996
+ this.wrapperEl.insertAdjacentHTML('beforebegin', sectionCss);
79997
+ } else {
79998
+ page.insertAdjacentHTML('beforeend', sectionCss); // add the style on the head
79999
+ }
79956
80000
  }
79957
80001
  }
79958
80002