@innovastudio/contentbuilder 1.2.1 → 1.2.2

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/contentbuilder",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
@@ -4068,6 +4068,10 @@ class Util {
4068
4068
  return document.querySelector('.cell-active');
4069
4069
  }
4070
4070
 
4071
+ rowSelected() {
4072
+ return document.querySelector('.row-active');
4073
+ }
4074
+
4071
4075
  builderStuff() {
4072
4076
  return document.querySelector('#_cbhtml');
4073
4077
  }
@@ -13961,8 +13965,16 @@ class HtmlUtil {
13961
13965
  }
13962
13966
 
13963
13967
  if (mode === 'row') {
13964
- const cell = util.cellSelected();
13965
- const row = cell.parentNode;
13968
+ let row;
13969
+ let cell = util.cellSelected();
13970
+
13971
+ if (cell) {
13972
+ row = cell.parentNode;
13973
+ } else {
13974
+ row = util.rowSelected();
13975
+ }
13976
+
13977
+ if (!row) return;
13966
13978
  row.innerHTML = html;
13967
13979
  let builderActive = document.querySelector('.builder-active');
13968
13980
  if (builderActive) this.builder.applyBehaviorOn(builderActive); //Trigger Change event
@@ -14000,14 +14012,60 @@ class HtmlUtil {
14000
14012
  const builderStuff = this.builder.builderStuff;
14001
14013
  const viewhtmlexternal = builderStuff.querySelector('.viewhtmlexternal');
14002
14014
  let codeEditor = viewhtmlexternal.querySelector('.input-code-editor');
14003
- console.log(codeEditor.innerHTML);
14004
14015
 
14005
- if (codeEditor.innerHTML === '') {
14016
+ if (!codeEditor.querySelector('.monaco-editor')) {
14006
14017
  // First time code editor load
14007
- try {
14018
+ loader.init().then(monaco => {
14019
+ this.builder.monaco = monaco;
14020
+ if (!codeEditor.getAttribute('data-mode-id')) this.builder.codeEditorExternal = monaco.editor.create(codeEditor, {
14021
+ value: '',
14022
+ minimap: {
14023
+ enabled: false
14024
+ },
14025
+ automaticLayout: true,
14026
+ contextmenu: false,
14027
+ fontSize: 13,
14028
+ scrollbar: {
14029
+ useShadows: false,
14030
+ vertical: 'visible',
14031
+ horizontal: 'visible',
14032
+ horizontalScrollbarSize: 12,
14033
+ verticalScrollbarSize: 12
14034
+ },
14035
+ language: 'html',
14036
+ theme: this.builder.styleDark || this.builder.styleColoredDark ? 'vs-dark' : ''
14037
+ });
14038
+ this.builder.codeEditorExternal.onKeyUp(() => {
14039
+ const source = document.querySelector('textarea[data-source-active]');
14040
+ source.value = this.builder.codeEditorExternal.getModel().getValue();
14041
+ });
14042
+ });
14043
+ setTimeout(() => {
14044
+ this.viewHtmlExternal();
14045
+ }, 100);
14046
+ return;
14047
+ }
14048
+
14049
+ util.showModal(viewhtmlexternal, true, null, false); // code editor
14050
+
14051
+ const model = this.builder.monaco.editor.createModel(source.value, 'html');
14052
+ this.builder.codeEditorExternal.setModel(model);
14053
+ }
14054
+
14055
+ view(mode, area) {
14056
+ const util = this.builder.util;
14057
+ const builderStuff = this.builder.builderStuff;
14058
+ let viewhtml;
14059
+
14060
+ if (this.builder.opts.htmlSyntaxHighlighting) {
14061
+ viewhtml = builderStuff.querySelector('.viewhtmlmonaco');
14062
+ let codeEditor = viewhtml.querySelector('.input-code-editor');
14063
+
14064
+ if (!codeEditor.querySelector('.monaco-editor')) {
14065
+ // First time code editor load
14008
14066
  loader.init().then(monaco => {
14009
14067
  this.builder.monaco = monaco;
14010
- this.builder.codeEditorExternal = monaco.editor.create(codeEditor, {
14068
+ if (!codeEditor.getAttribute('data-mode-id')) this.builder.codeEditor = monaco.editor.create(codeEditor, {
14011
14069
  value: '',
14012
14070
  minimap: {
14013
14071
  enabled: false
@@ -14025,69 +14083,15 @@ class HtmlUtil {
14025
14083
  language: 'html',
14026
14084
  theme: this.builder.styleDark || this.builder.styleColoredDark ? 'vs-dark' : ''
14027
14085
  });
14028
- this.builder.codeEditorExternal.onKeyUp(() => {
14029
- console.log(source);
14030
- source.value = this.builder.codeEditorExternal.getModel().getValue();
14031
- console.log(this.builder.codeEditorExternal.getModel().getValue());
14086
+ let textarea = viewhtml.querySelector('textarea');
14087
+ this.builder.codeEditor.onKeyUp(() => {
14088
+ textarea.value = this.builder.codeEditor.getModel().getValue();
14032
14089
  });
14033
14090
  });
14034
14091
  setTimeout(() => {
14035
- this.viewHtmlExternal();
14092
+ this.view(mode, area);
14036
14093
  }, 100);
14037
14094
  return;
14038
- } catch (e) {// Do Nothing
14039
- }
14040
- }
14041
-
14042
- util.showModal(viewhtmlexternal, true, null, false); // code editor
14043
-
14044
- const model = this.builder.monaco.editor.createModel(source.value, 'html');
14045
- this.builder.codeEditorExternal.setModel(model);
14046
- }
14047
-
14048
- view(mode, area) {
14049
- const util = this.builder.util;
14050
- const builderStuff = this.builder.builderStuff;
14051
- let viewhtml;
14052
-
14053
- if (this.builder.opts.htmlSyntaxHighlighting) {
14054
- viewhtml = builderStuff.querySelector('.viewhtmlmonaco');
14055
- let codeEditor = viewhtml.querySelector('.input-code-editor');
14056
-
14057
- if (codeEditor.innerHTML === '') {
14058
- // First time code editor load
14059
- try {
14060
- loader.init().then(monaco => {
14061
- this.builder.monaco = monaco;
14062
- this.builder.codeEditor = monaco.editor.create(codeEditor, {
14063
- value: '',
14064
- minimap: {
14065
- enabled: false
14066
- },
14067
- automaticLayout: true,
14068
- contextmenu: false,
14069
- fontSize: 13,
14070
- scrollbar: {
14071
- useShadows: false,
14072
- vertical: 'visible',
14073
- horizontal: 'visible',
14074
- horizontalScrollbarSize: 12,
14075
- verticalScrollbarSize: 12
14076
- },
14077
- language: 'html',
14078
- theme: this.builder.styleDark || this.builder.styleColoredDark ? 'vs-dark' : ''
14079
- });
14080
- let textarea = viewhtml.querySelector('textarea');
14081
- this.builder.codeEditor.onKeyUp(() => {
14082
- textarea.value = this.builder.codeEditor.getModel().getValue();
14083
- });
14084
- });
14085
- setTimeout(() => {
14086
- this.view(mode, area);
14087
- }, 100);
14088
- return;
14089
- } catch (e) {// Do Nothing
14090
- }
14091
14095
  }
14092
14096
  } else {
14093
14097
  viewhtml = builderStuff.querySelector('.viewhtml');
@@ -16927,18 +16931,38 @@ class Grid {
16927
16931
  removeRow() {
16928
16932
  // let builder = this.builder;
16929
16933
  // let columnTool = this.columnTool;
16930
- let util = this.util;
16931
- const cell = util.cellSelected();
16932
- if (!cell) return;
16933
- const row = cell.parentNode; //Change to row selection
16934
+ let util = this.util; // const cell = util.cellSelected();
16935
+ // if(!cell) return;
16936
+ // const row = cell.parentNode;
16937
+
16938
+ let row;
16939
+ let cell = util.cellSelected();
16940
+
16941
+ if (cell) {
16942
+ row = cell.parentNode;
16943
+ } else {
16944
+ row = util.rowSelected();
16945
+ }
16946
+
16947
+ if (!row) return; //Change to row selection
16934
16948
 
16935
16949
  dom$E.removeClass(row, 'row-outline');
16936
16950
  this.columnTool.hide(); //Hide Column tool
16937
16951
 
16938
16952
  util.confirm(util.out('Are you sure you want to delete this block?'), ok => {
16939
- const cell = util.cellSelected();
16940
- if (!cell) return;
16941
- const row = cell.parentNode;
16953
+ // const cell = util.cellSelected();
16954
+ // if(!cell) return;
16955
+ // const row = cell.parentNode;
16956
+ let row;
16957
+ let cell = util.cellSelected();
16958
+
16959
+ if (cell) {
16960
+ row = cell.parentNode;
16961
+ } else {
16962
+ row = util.rowSelected();
16963
+ }
16964
+
16965
+ if (!row) return;
16942
16966
 
16943
16967
  if (ok) {
16944
16968
  this.builder.uo.saveForUndo();
@@ -16952,10 +16976,20 @@ class Grid {
16952
16976
  moveRowUp() {
16953
16977
  // let builder = this.builder;
16954
16978
  let columnTool = this.columnTool;
16955
- let util = this.util;
16956
- const cell = util.cellSelected();
16957
- if (!cell) return;
16958
- let row = cell.parentNode; //Change to row selection
16979
+ let util = this.util; // const cell = util.cellSelected();
16980
+ // if(!cell) return;
16981
+ // let row = cell.parentNode;
16982
+
16983
+ let row;
16984
+ let cell = util.cellSelected();
16985
+
16986
+ if (cell) {
16987
+ row = cell.parentNode;
16988
+ } else {
16989
+ row = util.rowSelected();
16990
+ }
16991
+
16992
+ if (!row) return; //Change to row selection
16959
16993
 
16960
16994
  dom$E.removeClass(row, 'row-outline');
16961
16995
  columnTool.hide(); //Hide Column tool
@@ -16989,10 +17023,20 @@ class Grid {
16989
17023
  moveRowDown() {
16990
17024
  // let builder = this.builder;
16991
17025
  let columnTool = this.columnTool;
16992
- let util = this.util;
16993
- const cell = util.cellSelected();
16994
- if (!cell) return;
16995
- let row = cell.parentNode; //Change to row selection
17026
+ let util = this.util; // const cell = util.cellSelected();
17027
+ // if(!cell) return;
17028
+ // let row = cell.parentNode;
17029
+
17030
+ let row;
17031
+ let cell = util.cellSelected();
17032
+
17033
+ if (cell) {
17034
+ row = cell.parentNode;
17035
+ } else {
17036
+ row = util.rowSelected();
17037
+ }
17038
+
17039
+ if (!row) return; //Change to row selection
16996
17040
 
16997
17041
  dom$E.removeClass(row, 'row-outline');
16998
17042
  columnTool.hide(); //Hide Column tool
@@ -17026,10 +17070,20 @@ class Grid {
17026
17070
  duplicateRow() {
17027
17071
  let builder = this.builder;
17028
17072
  let columnTool = this.columnTool;
17029
- let util = this.util;
17030
- const cell = util.cellSelected();
17031
- if (!cell) return;
17032
- let row = cell.parentNode; //Change to row selection
17073
+ let util = this.util; // const cell = util.cellSelected();
17074
+ // if(!cell) return;
17075
+ // let row = cell.parentNode;
17076
+
17077
+ let row;
17078
+ let cell = util.cellSelected();
17079
+
17080
+ if (cell) {
17081
+ row = cell.parentNode;
17082
+ } else {
17083
+ row = util.rowSelected();
17084
+ }
17085
+
17086
+ if (!row) return; //Change to row selection
17033
17087
 
17034
17088
  dom$E.removeClass(row, 'row-outline');
17035
17089
  columnTool.hide(); //Hide Column tool
@@ -51365,8 +51419,18 @@ class RowTool {
51365
51419
  });
51366
51420
  elm = rowMore.querySelector('.row-html');
51367
51421
  if (elm) dom$o.addEventListener(elm, 'click', () => {
51368
- const cell = util.cellSelected();
51369
- if (!cell) return;
51422
+ // const cell = util.cellSelected();
51423
+ // if(!cell) return;
51424
+ let row;
51425
+ let cell = util.cellSelected();
51426
+
51427
+ if (cell) {
51428
+ row = cell.parentNode;
51429
+ } else {
51430
+ row = util.rowSelected();
51431
+ }
51432
+
51433
+ if (!row) return;
51370
51434
  htmlutil.view('row');
51371
51435
  });
51372
51436
  }
@@ -51455,9 +51519,16 @@ class RowTool {
51455
51519
  });
51456
51520
  elm = rowtool.querySelector('.row-more');
51457
51521
  if (elm) dom$o.addEventListener(elm, 'click', () => {
51522
+ let row;
51458
51523
  let cell = util.cellSelected();
51459
- if (!cell) return;
51460
- let row = cell.parentNode; //Change to row selection
51524
+
51525
+ if (cell) {
51526
+ row = cell.parentNode;
51527
+ } else {
51528
+ row = util.rowSelected();
51529
+ }
51530
+
51531
+ if (!row) return; //Change to row selection
51461
51532
 
51462
51533
  dom$o.removeClass(row, 'row-outline'); //Hide Column tool
51463
51534
 
@@ -51490,7 +51561,7 @@ class RowTool {
51490
51561
  let btnRowHtml = rowMore.querySelector('.row-html');
51491
51562
  let btnRowDuplicate = rowMore.querySelector('.row-duplicate');
51492
51563
 
51493
- if (cell.getAttribute('data-html')) {
51564
+ if (row.querySelector('[data-html]')) {
51494
51565
  if (btnRowHtml) btnRowHtml.style.display = 'none';
51495
51566
  if (btnRowDuplicate) btnRowDuplicate.style.display = 'none';
51496
51567
  } else {