@innovastudio/contentbuilder 1.5.22 → 1.5.23

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/contentbuilder",
3
3
  "type": "module",
4
- "version": "1.5.22",
4
+ "version": "1.5.23",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "files": [
@@ -17685,6 +17685,7 @@ const renderSnippetPanel = (builder, snippetOpen) => {
17685
17685
  obj.destroy();
17686
17686
  }
17687
17687
  });
17688
+ builder.sortableOnCanvas = [];
17688
17689
  }
17689
17690
  if (builder.sortableOnPage) builder.sortableOnPage.destroy();
17690
17691
  let dummies = builder.doc.querySelectorAll('.block-dummy');
@@ -83219,6 +83220,8 @@ class Resizable {
83219
83220
  this.doc.addEventListener('mouseup', this.handleResizeEnd);
83220
83221
  this.doc.addEventListener('touchmove', this.handleResizeMove);
83221
83222
  this.doc.addEventListener('touchend', this.handleResizeEnd);
83223
+ document.addEventListener('mouseup', this.handleResizeEnd); // in iframe, mouseup can be triggered outside the iframe (during resizing)
83224
+ document.addEventListener('touchend', this.handleResizeEnd);
83222
83225
  }
83223
83226
  handleResizeMove(event) {
83224
83227
  if (this.isResizing) {
@@ -83269,6 +83272,8 @@ class Resizable {
83269
83272
  this.doc.removeEventListener('mouseup', this.handleResizeEnd);
83270
83273
  this.doc.removeEventListener('touchmove', this.handleResizeMove);
83271
83274
  this.doc.removeEventListener('touchend', this.handleResizeEnd);
83275
+ document.removeEventListener('mouseup', this.handleResizeEnd); // in iframe, mouseup can be triggered outside the iframe (during resizing)
83276
+ document.removeEventListener('touchend', this.handleResizeEnd);
83272
83277
  this.ruler.hideRulers();
83273
83278
  }
83274
83279
  resizeTopLeft(deltaX, deltaY) {
@@ -88093,6 +88098,59 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
88093
88098
  }
88094
88099
  });
88095
88100
 
88101
+ // Canvas Mode
88102
+ const copyBlock = e => {
88103
+ const docContainer = this.doc.querySelector(this.docContainer);
88104
+ if ((e.ctrlKey || e.metaKey) && e.which === 67) {
88105
+ //CTRL-C
88106
+ const activeBlock = docContainer.querySelector('.is-block.active'); // always get .cloned
88107
+ if (activeBlock) {
88108
+ this.copyBlock = activeBlock;
88109
+ }
88110
+ }
88111
+ };
88112
+ const pasteBlock = e => {
88113
+ const docContainer = this.doc.querySelector(this.docContainer);
88114
+ if ((e.ctrlKey || e.metaKey) && e.which === 86) {
88115
+ //CTRL-V
88116
+
88117
+ const box = docContainer.querySelector('.is-box.box-select'); // always get .cloned
88118
+ let block = this.copyBlock;
88119
+ if (box && block) {
88120
+ if (document.querySelector('.is-modal.active:not(.is-modal-content)')) return;
88121
+ const focusedElement = e.target;
88122
+ const isEditable = focusedElement.tagName === 'INPUT' || focusedElement.tagName === 'TEXTAREA' || focusedElement.hasAttribute('contenteditable');
88123
+ if (isEditable) return;
88124
+ this.uo.saveForUndo();
88125
+ let block = this.copyBlock;
88126
+ const builder = block.querySelector(this.container);
88127
+ let html = '';
88128
+ if (builder) {
88129
+ html = this.readHtml(builder);
88130
+ }
88131
+ let clonedDiv = block.cloneNode(true);
88132
+ clonedDiv.style.top = '20%';
88133
+ clonedDiv.style.left = '20%';
88134
+ if (builder) {
88135
+ const cloneBuilder = clonedDiv.querySelector(this.container);
88136
+ cloneBuilder.innerHTML = '';
88137
+ box.appendChild(clonedDiv);
88138
+ const range = document.createRange();
88139
+ cloneBuilder.appendChild(range.createContextualFragment(html));
88140
+ this.applyBehaviorOn(cloneBuilder);
88141
+ cloneBuilder.click();
88142
+ } else {
88143
+ block.parentNode.appendChild(clonedDiv);
88144
+ }
88145
+ block.classList.remove('active');
88146
+ this.doc.querySelectorAll('.clone').forEach(elm => elm.parentNode.removeChild(elm));
88147
+ this.doc.querySelectorAll('.cloned').forEach(elm => elm.classList.remove('cloned'));
88148
+ this.eb.refresh();
88149
+ this.opts.onChange();
88150
+ }
88151
+ }
88152
+ };
88153
+
88096
88154
  // SHIFT + Right Clidk to Zoom In
88097
88155
  if (this.canvas && !this.isContentBox && this.docContainer && !this.iframe) {
88098
88156
  //--- see loadHtml ---
@@ -88164,52 +88222,40 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
88164
88222
  document.addEventListener('keydown', e => {
88165
88223
  if ((e.ctrlKey || e.metaKey) && e.which === 67) {
88166
88224
  //CTRL-C
88167
- const activeBlock = docContainer.querySelector('.is-block.active'); // always get .cloned
88168
- if (activeBlock) {
88169
- this.copyBlock = activeBlock;
88170
- }
88225
+ copyBlock(e);
88171
88226
  }
88172
88227
  });
88173
88228
  document.addEventListener('keydown', e => {
88174
88229
  if ((e.ctrlKey || e.metaKey) && e.which === 86) {
88175
88230
  //CTRL-V
88176
-
88177
- const box = docContainer.querySelector('.is-box.box-select'); // always get .cloned
88178
- let block = this.copyBlock;
88179
- if (box && block) {
88180
- if (document.querySelector('.is-modal.active:not(.is-modal-content)')) return;
88181
- const focusedElement = e.target;
88182
- const isEditable = focusedElement.tagName === 'INPUT' || focusedElement.tagName === 'TEXTAREA' || focusedElement.hasAttribute('contenteditable');
88183
- if (isEditable) return;
88184
- this.uo.saveForUndo();
88185
- let block = this.copyBlock;
88186
- const builder = block.querySelector(this.container);
88187
- let html = '';
88188
- if (builder) {
88189
- html = this.readHtml(builder);
88190
- }
88191
- let clonedDiv = block.cloneNode(true);
88192
- clonedDiv.style.top = '20%';
88193
- clonedDiv.style.left = '20%';
88194
- if (builder) {
88195
- const cloneBuilder = clonedDiv.querySelector(this.container);
88196
- cloneBuilder.innerHTML = '';
88197
- box.appendChild(clonedDiv);
88198
- const range = document.createRange();
88199
- cloneBuilder.appendChild(range.createContextualFragment(html));
88200
- this.applyBehaviorOn(cloneBuilder);
88201
- cloneBuilder.click();
88202
- } else {
88203
- block.parentNode.appendChild(clonedDiv);
88204
- }
88205
- block.classList.remove('active');
88206
- this.doc.querySelectorAll('.clone').forEach(elm => elm.parentNode.removeChild(elm));
88207
- this.doc.querySelectorAll('.cloned').forEach(elm => elm.classList.remove('cloned'));
88208
- this.eb.refresh();
88209
- this.opts.onChange();
88210
- }
88231
+ pasteBlock(e);
88232
+ }
88233
+ });
88234
+ }
88235
+ if (this.canvas && this.isContentBox) {
88236
+ // Copy & Paste Block
88237
+ document.addEventListener('keydown', e => {
88238
+ if ((e.ctrlKey || e.metaKey) && e.which === 67) {
88239
+ copyBlock(e);
88240
+ }
88241
+ });
88242
+ document.addEventListener('keydown', e => {
88243
+ if ((e.ctrlKey || e.metaKey) && e.which === 86) {
88244
+ pasteBlock(e);
88211
88245
  }
88212
88246
  });
88247
+ if (this.iframe) {
88248
+ this.doc.addEventListener('keydown', e => {
88249
+ if ((e.ctrlKey || e.metaKey) && e.which === 67) {
88250
+ copyBlock(e);
88251
+ }
88252
+ });
88253
+ this.doc.addEventListener('keydown', e => {
88254
+ if ((e.ctrlKey || e.metaKey) && e.which === 86) {
88255
+ pasteBlock(e);
88256
+ }
88257
+ });
88258
+ }
88213
88259
  }
88214
88260
  let previousWidth = this.win.innerWidth;
88215
88261
  let timer;
@@ -92722,6 +92768,7 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
92722
92768
  });
92723
92769
  let dummies = this.doc.querySelectorAll('.block-dummy');
92724
92770
  dummies.forEach(elm => elm.parentNode.removeChild(elm));
92771
+ this.sortableOnCanvas = [];
92725
92772
  }
92726
92773
  if (this.sortableOnPage) this.sortableOnPage.destroy();
92727
92774
  }
@@ -92939,6 +92986,7 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
92939
92986
  });
92940
92987
  let dummies = this.doc.querySelectorAll('.block-dummy');
92941
92988
  dummies.forEach(elm => elm.parentNode.removeChild(elm));
92989
+ this.sortableOnCanvas = [];
92942
92990
  }
92943
92991
  if (this.sortableOnPage) this.sortableOnPage.destroy();
92944
92992
  }