@innovastudio/contentbox 1.6.166 → 1.6.168

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbox",
3
3
  "type": "module",
4
- "version": "1.6.166",
4
+ "version": "1.6.168",
5
5
  "description": "",
6
6
  "main": "public/contentbox/contentbox.esm.js",
7
7
  "types": "index.d.ts",
@@ -59,7 +59,7 @@
59
59
  "ws": "^8.13.0"
60
60
  },
61
61
  "dependencies": {
62
- "@innovastudio/contentbuilder": "^1.5.164",
62
+ "@innovastudio/contentbuilder": "^1.5.166",
63
63
  "js-beautify": "^1.14.0",
64
64
  "sortablejs": "^1.15.2"
65
65
  }
@@ -12381,7 +12381,7 @@ class SettingsUIGenerator$1 {
12381
12381
  groupElement.className = 'cb-settings-group';
12382
12382
  const groupTitle = document.createElement('h3');
12383
12383
  groupTitle.className = 'cb-settings-group-title';
12384
- groupTitle.style.cssText = 'font-size: 17px;font-weight: 500;';
12384
+ groupTitle.style.cssText = 'font-size: 16px;font-weight: 400;';
12385
12385
  groupTitle.textContent = group.label;
12386
12386
  groupElement.appendChild(groupTitle);
12387
12387
  group.fields.forEach(fieldKey => {
@@ -13812,41 +13812,43 @@ class PanelBox {
13812
13812
  </div>
13813
13813
  </div>
13814
13814
 
13815
- <div class="flex">
13816
- <div class="mr-8">
13817
- <div class="label mt-3">${out('Background Color')}:</div>
13818
- <div class="group">
13819
- <button title="${out('Color')}" class="btn-color is-btn-color"></button>
13815
+ <div class="box-bg-settings">
13816
+ <div class="flex">
13817
+ <div class="mr-8">
13818
+ <div class="label mt-3">${out('Background Color')}:</div>
13819
+ <div class="group">
13820
+ <button title="${out('Color')}" class="btn-color is-btn-color"></button>
13821
+ </div>
13820
13822
  </div>
13821
- </div>
13822
- <div>
13823
- <div class="label mt-3">${out('Gradient')}:</div>
13824
- <div class="group">
13825
- <button title="${out('Gradient')}" class="btn-gradient is-btn-color"></button>
13823
+ <div>
13824
+ <div class="label mt-3">${out('Gradient')}:</div>
13825
+ <div class="group">
13826
+ <button title="${out('Gradient')}" class="btn-gradient is-btn-color"></button>
13827
+ </div>
13826
13828
  </div>
13827
13829
  </div>
13828
- </div>
13829
13830
 
13830
- <div class="label mt-3">${out('Background Image')}:</div>
13831
+ <div class="label mt-3">${out('Background Image')}:</div>
13831
13832
 
13832
- <div class="asset-preview"></div>
13833
+ <div class="asset-preview"></div>
13833
13834
 
13834
- <div class="imagesource mt-1 mb-1">
13835
- <input type="text" class="inp-src">
13836
- </div>
13835
+ <div class="imagesource mt-1 mb-1">
13836
+ <input type="text" class="inp-src">
13837
+ </div>
13837
13838
 
13838
- <div class="group mt-2">
13839
- <input class="inp-file" type="file" accept="image/*" style="display:none"/>
13840
- <button title="${out('Upload')}" class="btn-upload"><svg><use xlink:href="#icon-upload"></use></svg></button>
13841
- <button title="${out('Select')}" class="btn-asset"><svg><use xlink:href="#icon-folder"></use></svg></button>
13842
- <button title="${out('Adjust')}" class="btn-adjust"><svg style="width:14px;height:14px;"><use xlink:href="#icon-tool"></use></svg></button>
13843
- <button title="${out('Clear')}" class="btn-clear"><svg><use xlink:href="#icon-eraser"></use></svg></button>
13844
- </div>
13839
+ <div class="group mt-2">
13840
+ <input class="inp-file" type="file" accept="image/*" style="display:none"/>
13841
+ <button title="${out('Upload')}" class="btn-upload"><svg><use xlink:href="#icon-upload"></use></svg></button>
13842
+ <button title="${out('Select')}" class="btn-asset"><svg><use xlink:href="#icon-folder"></use></svg></button>
13843
+ <button title="${out('Adjust')}" class="btn-adjust"><svg style="width:14px;height:14px;"><use xlink:href="#icon-tool"></use></svg></button>
13844
+ <button title="${out('Clear')}" class="btn-clear"><svg><use xlink:href="#icon-eraser"></use></svg></button>
13845
+ </div>
13845
13846
 
13846
- <label class="label checkbox grayscale mt-2" style="margin-bottom:16px">
13847
- <input type="checkbox" class="chk-grayscale" />
13848
- <span>${out('Grayscale')}</span>
13849
- </label>
13847
+ <label class="label checkbox grayscale mt-2" style="margin-bottom:16px">
13848
+ <input type="checkbox" class="chk-grayscale" />
13849
+ <span>${out('Grayscale')}</span>
13850
+ </label>
13851
+ </div>
13850
13852
 
13851
13853
  <div class="defaulttextcolor">
13852
13854
  <div class="label mt-3">${out('Text Color')}:</div>
@@ -13886,6 +13888,12 @@ class PanelBox {
13886
13888
 
13887
13889
  </div>
13888
13890
 
13891
+ <div class="submain box-plugin-settings panel-plugin">
13892
+
13893
+ <hr style="width: 100%;border-bottom: #ededed 2px solid;margin-top: 20px;">
13894
+
13895
+ </div>
13896
+
13889
13897
  <button class="accordion-item btn-accordion-content" aria-expanded="false" aria-controls="boxcontent1">
13890
13898
  ${out('Content')}
13891
13899
  <span><svg><use xlink:href="#icon-chevron-down"></use></svg></span>
@@ -15264,9 +15272,158 @@ class PanelBox {
15264
15272
  chkAutoLayout.checked = true;
15265
15273
  } else {
15266
15274
  chkAutoLayout.checked = false;
15275
+ } // PLUGIN SETTINGS
15276
+
15277
+
15278
+ const divPluginSettings = panel.querySelector('.box-plugin-settings');
15279
+ this.divPluginSettings = divPluginSettings;
15280
+ const runtime = this.builder.win.builderRuntime; // Reset (can be changed by renderPluginSettings)
15281
+
15282
+ const divBgSettings = this.panel.querySelector('.box-bg-settings');
15283
+ divBgSettings.style.display = '';
15284
+ this.divBgSettings = divBgSettings;
15285
+ const divPanelTitle = this.panel.parentNode.querySelector('.part-title');
15286
+ divPanelTitle.style.display = '';
15287
+ this.divPanelTitle = divPanelTitle;
15288
+
15289
+ if (overlayContent && runtime) {
15290
+ const currentElement = overlayContent.querySelector('[data-cb-type]');
15291
+
15292
+ if (currentElement) {
15293
+ divPluginSettings.style.display = '';
15294
+ this.renderPluginSettings(currentElement);
15295
+ } else {
15296
+ divPluginSettings.style.display = 'none';
15297
+ }
15298
+ } else {
15299
+ divPluginSettings.style.display = 'none';
15267
15300
  }
15268
15301
  }
15269
15302
 
15303
+ renderPluginSettings(currentElement) {
15304
+ this.currentElement = currentElement;
15305
+ this.generator = null;
15306
+ this.currentForm = null;
15307
+ const divPluginSettings = this.divPluginSettings;
15308
+ divPluginSettings.innerHTML = '';
15309
+ const runtime = this.builder.win.builderRuntime;
15310
+ const pluginName = currentElement.getAttribute('data-cb-type');
15311
+ const plugin = runtime.getPlugin(pluginName);
15312
+ if (!plugin) return;
15313
+ let displayName = out(plugin.displayName || plugin.name);
15314
+
15315
+ if (plugin.contentbox) {
15316
+ if (!plugin.contentbox.bg) {
15317
+ this.divBgSettings.style.display = 'none';
15318
+ }
15319
+
15320
+ if (!plugin.contentbox.text) {
15321
+ this.divDefaultTextColor.style.display = 'none';
15322
+ }
15323
+
15324
+ if (!plugin.contentbox.title) {
15325
+ this.divPanelTitle.style.display = 'none';
15326
+ }
15327
+ }
15328
+
15329
+ const divTitle = document.createElement('h3');
15330
+ divTitle.style.cssText = 'font-family: sans-serif;font-weight: 300;font-size: 20px;margin: 0 0 12px;';
15331
+ divTitle.innerText = displayName;
15332
+ divPluginSettings.appendChild(divTitle);
15333
+ this.generator = new SettingsUIGenerator$1(runtime, this.builder);
15334
+ const hasContentEditor = plugin && plugin.editor && plugin.editor.openContentEditor;
15335
+
15336
+ if (hasContentEditor) {
15337
+ // Get original content for the editor to work with
15338
+ const originalContent = currentElement.getAttribute('data-cb-original-content'); // Create a temporary element for editing (so editor can manipulate it)
15339
+
15340
+ let editableClone = document.querySelector('.editable-clone');
15341
+ if (editableClone) editableClone.remove(); // editableClone = document.createElement('div');
15342
+
15343
+ editableClone = currentElement.cloneNode(false);
15344
+ editableClone.innerHTML = originalContent;
15345
+ editableClone.className = 'editable-clone';
15346
+ editableClone.style.display = 'none'; // Hidden, just for editing
15347
+
15348
+ document.body.appendChild(editableClone);
15349
+ const originalElement = editableClone.cloneNode(false); // Let plugin handle everything - pass the editable clone
15350
+
15351
+ const editorUI = plugin.editor.openContentEditor(editableClone, this.builder, async () => {
15352
+ this.builder.editor.saveForUndo(); // Add index for sortable grid (for easy reorder)
15353
+
15354
+ let grid = editableClone.querySelector('.grid-sortable');
15355
+
15356
+ if (!grid) {
15357
+ if (currentElement.classList.contains('grid-sortable')) {
15358
+ grid = editableClone;
15359
+ }
15360
+ }
15361
+
15362
+ if (grid) {
15363
+ Array.from(grid.children).forEach((child, index) => {
15364
+ if (child.nodeType === 1 && child.tagName !== 'STYLE' && child.tagName !== 'SCRIPT') child.setAttribute('data-index', index);
15365
+ });
15366
+ } //----
15367
+ // Store edited content from clone
15368
+
15369
+
15370
+ currentElement.setAttribute('data-cb-original-content', editableClone.innerHTML); // Also performs similar value updates like the applyChanges()
15371
+ // currentElement.setAttribute('data-cb-content', editableClone.getAttribute('data-cb-content'));
15372
+
15373
+ const getChangedDataAttributes = (el1, el2) => {
15374
+ const changed = [];
15375
+
15376
+ for (const key of Object.keys(el1.dataset)) {
15377
+ if (key in el2.dataset && el1.dataset[key] !== el2.dataset[key]) {
15378
+ changed.push(key);
15379
+ }
15380
+ }
15381
+
15382
+ return changed;
15383
+ };
15384
+
15385
+ const changedAttributes = getChangedDataAttributes(originalElement, editableClone);
15386
+ changedAttributes.forEach(attrName => {
15387
+ // console.log(attrName)
15388
+ // console.log(editableClone.dataset[attrName])
15389
+ currentElement.dataset[attrName] = editableClone.dataset[attrName];
15390
+ }); // -------
15391
+
15392
+ currentElement.innerHTML = editableClone.innerHTML; // Update current content
15393
+ // Remove temporary clone
15394
+
15395
+ editableClone.remove(); // Reinitialize plugin with new content
15396
+
15397
+ await runtime.reinitialize(currentElement.parentElement);
15398
+ this.builder.onChange();
15399
+ this.builder.editor.hideElementTools();
15400
+ this.builder.makeSortable(currentElement.parentElement);
15401
+ });
15402
+ divPluginSettings.appendChild(editorUI);
15403
+ } // Generate form
15404
+
15405
+
15406
+ this.currentForm = this.generator.generateForm(pluginName, currentElement, () => {
15407
+ this.builder.editor.saveForUndo();
15408
+ this.applyChanges(runtime);
15409
+ });
15410
+ divPluginSettings.appendChild(this.currentForm);
15411
+ }
15412
+
15413
+ async applyChanges(runtime) {
15414
+ if (!this.currentElement || !this.currentForm) return; // 1. Get form values
15415
+
15416
+ const values = this.generator.getFormValues(this.currentForm); // 2. Apply to element attributes
15417
+
15418
+ this.generator.applyValues(this.currentElement, values); // 3. Reinitialize component
15419
+
15420
+ const container = this.currentElement.parentElement || this.currentElement.closest('.is-wrapper');
15421
+ await runtime.reinitialize(container);
15422
+ this.builder.onChange(); // console.log('Settings applied and component reinitialized');
15423
+
15424
+ this.builder.makeSortable(container);
15425
+ }
15426
+
15270
15427
  getStateTargeted() {
15271
15428
  let activeBox = this.builder.controlpanel.activeBox;
15272
15429
  if (!activeBox) return;
@@ -26224,7 +26381,8 @@ class ControlPanel {
26224
26381
  this.panelRow = controlPanel.querySelector('.panel-row');
26225
26382
  this.panelContainer = controlPanel.querySelector('.panel-container');
26226
26383
  this.panelBlock = controlPanel.querySelector('.panel-block');
26227
- this.panelBox = controlPanel.querySelector('.panel-box');
26384
+ this.panelBox = controlPanel.querySelector('.panel-box'); // also has .panel-plugin inside
26385
+
26228
26386
  this.panelSection = controlPanel.querySelector('.panel-section');
26229
26387
  this.breadcrumb = controlPanel.querySelector('.part-breadcrumb');
26230
26388
  this.title = controlPanel.querySelector('.part-title');
@@ -26271,8 +26429,14 @@ class ControlPanel {
26271
26429
 
26272
26430
  this.builder.onPageContentClick = e => {
26273
26431
  if (old) old.call(this);
26274
- if (this.builder.controlPanel && !document.body.classList.contains('controlpanel')) this.open();
26275
- if (document.body.classList.contains('controlpanel')) this.clickContent(e);
26432
+
26433
+ if (this.builder.controlPanel && !document.body.classList.contains('controlpanel')) {
26434
+ //if previously close, open
26435
+ this.open();
26436
+ } else {
26437
+ // if already open
26438
+ if (document.body.classList.contains('controlpanel')) this.clickContent(e);
26439
+ }
26276
26440
  };
26277
26441
 
26278
26442
  const btnClose = controlPanel.querySelector('.btn-close');
@@ -32371,6 +32535,7 @@ class Util$1 {
32371
32535
  }
32372
32536
 
32373
32537
  hideModal(modal) {
32538
+ if (!modal) return;
32374
32539
  this.builder.doc.activeElement.blur();
32375
32540
  document.activeElement.blur();
32376
32541
  // this.builder.doc.body.focus();
@@ -32840,7 +33005,9 @@ class Util$1 {
32840
33005
 
32841
33006
  // Reinit after drag drop block
32842
33007
  if (this.builder.win.builderRuntime) this.builder.win.builderRuntime.reinitialize();
32843
- this.builder.makeSortable(this.builder.doc);
33008
+ setTimeout(() => {
33009
+ this.builder.makeSortable(this.builder.doc);
33010
+ }, 400);
32844
33011
  }
32845
33012
 
32846
33013
  // https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro
@@ -32933,7 +33100,11 @@ class Util$1 {
32933
33100
 
32934
33101
  //Hide Column tool (new!)
32935
33102
  this.builder.util.hideColumnTool();
32936
- this.builder.makeSortable(rowElement);
33103
+
33104
+ // this.builder.makeSortable(rowElement); // cause other sortable not working
33105
+ setTimeout(() => {
33106
+ this.builder.makeSortable(this.builder.doc);
33107
+ }, 400);
32937
33108
  } else if (bSnippet) {
32938
33109
  if (noedit) {
32939
33110
  this.addContent(html, mode, 'data-noedit');
@@ -33107,7 +33278,9 @@ class Util$1 {
33107
33278
  this.builder.doc.querySelectorAll('.dummy-module').forEach(module => {
33108
33279
  module.classList.remove('dummy-module');
33109
33280
  });
33110
- this.builder.makeSortable(this.builder.doc);
33281
+ setTimeout(() => {
33282
+ this.builder.makeSortable(this.builder.doc);
33283
+ }, 400);
33111
33284
 
33112
33285
  // Change to row selection
33113
33286
  rowElement.className = rowElement.className.replace('row-outline', '');
@@ -33325,6 +33498,11 @@ class Util$1 {
33325
33498
  }
33326
33499
  }
33327
33500
 
33501
+ clearModals() {
33502
+ const builderStuff = this.builder.builderStuff;
33503
+ let modal = builderStuff.querySelector('.pluginsettings.active');
33504
+ this.hideModal(modal);
33505
+ }
33328
33506
  clearControls() {
33329
33507
  const dom = this.dom;
33330
33508
  const builderStuff = this.builder.builderStuff;
@@ -43688,6 +43866,7 @@ class Grid {
43688
43866
 
43689
43867
  // Re-init plugins
43690
43868
  if (this.builder.win.builderRuntime) this.builder.win.builderRuntime.reinitialize(cellElement);
43869
+ this.builder.makeSortable(cellElement);
43691
43870
  }
43692
43871
  removeColumn() {
43693
43872
  let util = this.util;
@@ -44470,6 +44649,7 @@ class Grid {
44470
44649
 
44471
44650
  // Re-init plugins
44472
44651
  if (this.builder.win.builderRuntime) this.builder.win.builderRuntime.reinitialize(rowElement);
44652
+ this.builder.makeSortable(rowElement);
44473
44653
  }
44474
44654
  }
44475
44655
  class RowTool$1 {
@@ -81188,6 +81368,7 @@ class RowTool {
81188
81368
  const grid = new Grid(this.builder);
81189
81369
  grid.removeColumn();
81190
81370
  util.clearControls();
81371
+ util.clearModals();
81191
81372
  if (this.builder.onSelectChange) this.builder.onSelectChange();
81192
81373
  });
81193
81374
  let btnGridEditor = rowtool.querySelector('.row-grideditor');
@@ -81298,6 +81479,7 @@ class RowTool {
81298
81479
  if (elm) dom.addEventListener(elm, 'click', () => {
81299
81480
  this.grid.removeRow();
81300
81481
  util.clearControls();
81482
+ util.clearModals();
81301
81483
  if (this.builder.onSelectChange) this.builder.onSelectChange();
81302
81484
  });
81303
81485
  }
@@ -120695,6 +120877,9 @@ class BlockModal {
120695
120877
  new Tabs({
120696
120878
  element: modal
120697
120879
  });
120880
+ new Draggable$2({
120881
+ selector: '.is-modal.editblock .is-draggable'
120882
+ });
120698
120883
  } // constructor
120699
120884
 
120700
120885
  getPage() {
@@ -125179,8 +125364,16 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
125179
125364
  let newRow = newRows[0]; // get first added row
125180
125365
  if (newRow.children.length > 0) {
125181
125366
  const newCol = newRow.children[0];
125367
+ const isPlugin = newCol.querySelector('[data-cb-type]');
125182
125368
  if (newCol.children.length > 0) {
125183
- newCol.children[0].click(); // Focus on first element
125369
+ if (isPlugin) {
125370
+ setTimeout(() => {
125371
+ // give time for plugin to render (apply style) => for correct elm tool position
125372
+ newCol.children[0].click();
125373
+ }, 400);
125374
+ } else {
125375
+ newCol.children[0].click(); // Focus on first element
125376
+ }
125184
125377
  }
125185
125378
  }
125186
125379
  }
@@ -125281,7 +125474,9 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
125281
125474
  });
125282
125475
  });
125283
125476
  });
125284
- this.makeSortable(this.doc);
125477
+ setTimeout(() => {
125478
+ this.makeSortable(this.doc);
125479
+ }, 400);
125285
125480
  this.doc.querySelectorAll('.dummy-module').forEach(module => {
125286
125481
  module.classList.remove('dummy-module');
125287
125482
  });
@@ -126946,6 +127141,7 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
126946
127141
  this.rte.viewZoom();
126947
127142
  }
126948
127143
  async loadSnippets(source, snippetOpen) {
127144
+ this.snippetUrl = source;
126949
127145
  if (this.preview) return;
126950
127146
  if (this.opts.snippetList === '#divSnippetList') {
126951
127147
  let snippetPanel = document.querySelector(this.opts.snippetList);