@innovastudio/contentbox 1.6.134 → 1.6.136

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
@@ -364,10 +364,23 @@ interface ContentBoxOptions {
364
364
  //---
365
365
  }
366
366
 
367
+ interface OpenModalOptions {
368
+ w?: string; // modal width (e.g. "500px", "100%")
369
+ maxW?: string; // max width
370
+ h?: string; // modal height
371
+ extraStyle?: string; // inline extra styles
372
+ ariaLabel?: string; // accessibility label
373
+ onOpen?: (modal: HTMLElement, iframe: HTMLIFrameElement) => void; // callback when opened
374
+ onClose?: (modal: HTMLElement, iframe: HTMLIFrameElement) => void; // callback when closed
375
+ }
376
+
367
377
  declare class ContentBox {
368
378
  constructor(options: ContentBoxOptions);
369
379
 
370
380
  boxImage(url: string, err?: string): void;
381
+ selectAsset(url: string): void;
382
+ hideModal(modal?: HTMLElement): void;
383
+ closeAsset(): void;
371
384
  returnUrl(s: string): void;
372
385
  htmlCheck(): void;
373
386
  loadHtml(html: string): void;
@@ -390,7 +403,7 @@ declare class ContentBox {
390
403
  viewHtml(): void;
391
404
  toggleEditPanel(): void;
392
405
  getWrapper(): HTMLElement;
393
-
406
+ openModal(url: string, options?: OpenModalOptions): void;
394
407
  screenMode: string;
395
408
  }
396
409
  export default ContentBox;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbox",
3
3
  "type": "module",
4
- "version": "1.6.134",
4
+ "version": "1.6.136",
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.125",
62
+ "@innovastudio/contentbuilder": "^1.5.126",
63
63
  "js-beautify": "^1.14.0",
64
64
  "sortablejs": "^1.15.2"
65
65
  }
@@ -3174,6 +3174,17 @@ body.fullview.topspace .is-content-view iframe {
3174
3174
  transition: none !important;
3175
3175
  }
3176
3176
 
3177
+ /* Custom Model for openModal() */
3178
+ #_cbhtml .is-modal.custom-modal button.modal-close {
3179
+ position: absolute;
3180
+ top: 4px;
3181
+ right: 10px;
3182
+ width: 30px;
3183
+ height: 30px;
3184
+ font-size: 23px;
3185
+ background: transparent !important;
3186
+ }
3187
+
3177
3188
  /* content.css */
3178
3189
  #_cbhtml {
3179
3190
  /* Text Formatting */
@@ -121360,6 +121360,7 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
121360
121360
  window.selectImage = this.selectImage.bind(this);
121361
121361
  window.selectVideo = this.selectVideo.bind(this);
121362
121362
  window.selectAsset = this.selectAsset.bind(this);
121363
+ window.closeAsset = this.closeAsset.bind(this);
121363
121364
  window.assetType = this.assetType.bind(this);
121364
121365
  window.hideModal = this.hideModal.bind(this);
121365
121366
  window.generateImage = this.generateImage.bind(this);
@@ -123865,6 +123866,20 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
123865
123866
  this.util._hideModal(modal); // this _hideModal will also trigger cancelCallback defined by showModal. This is done by programmatically click the overlay.
123866
123867
  }
123867
123868
 
123869
+ closeAsset() {
123870
+ let modal = document.querySelector('.is-modal.videoselect.active');
123871
+ if (modal) this.hideModal(modal);
123872
+ modal = document.querySelector('.is-modal.imageselect.active');
123873
+ if (modal) this.hideModal(modal);
123874
+ modal = document.querySelector('.is-modal.fileselect.active');
123875
+ if (modal) this.hideModal(modal);
123876
+ modal = document.querySelector('.is-modal.audioselect.active');
123877
+ if (modal) this.hideModal(modal);
123878
+ modal = document.querySelector('.is-modal.mediaselect.active');
123879
+ if (modal) this.hideModal(modal);
123880
+ modal = document.querySelector('.is-modal.otherselect.active');
123881
+ if (modal) this.hideModal(modal);
123882
+ }
123868
123883
  draggable(selector) {
123869
123884
  new Draggable$2({
123870
123885
  selector: selector
@@ -164124,6 +164139,14 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
164124
164139
  this.editor.hideModal(modal);
164125
164140
  }
164126
164141
 
164142
+ selectAsset(url) {
164143
+ this.editor.selectAsset(url);
164144
+ }
164145
+
164146
+ closeAsset() {
164147
+ this.editor.closeAsset();
164148
+ }
164149
+
164127
164150
  refreshModule() {
164128
164151
  this.box.refreshModule();
164129
164152
  }
@@ -164287,6 +164310,52 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
164287
164310
  }, 400);
164288
164311
  }
164289
164312
 
164313
+ openModal(url, prop = {}) {
164314
+ const defaults = {
164315
+ w: '88vw',
164316
+ maxW: '1600px',
164317
+ h: '88vh',
164318
+ extraStyle: '',
164319
+ ariaLabel: 'Modal',
164320
+ showCloseButton: false
164321
+ };
164322
+ const config = { ...defaults,
164323
+ ...prop
164324
+ };
164325
+ const html = `
164326
+ <div class="is-modal custom-modal" style="z-index:10005" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true">
164327
+ <div style="width:${config.w};max-width:${config.maxW};height:${config.h};padding:0;${config.extraStyle}">
164328
+ <iframe tabindex="0" style="width:100%;height:100%;border: none;display: block;" src="about:blank"></iframe>
164329
+ </div>
164330
+ </div>
164331
+ `;
164332
+ const oldModal = this.builderStuff.querySelector('.is-modal.custom-modal');
164333
+ if (oldModal) oldModal.remove();
164334
+ this.builderStuff.insertAdjacentHTML('beforeend', html);
164335
+ const modal = this.builderStuff.querySelector('.is-modal.custom-modal');
164336
+ modal.setAttribute('aria-label', config.ariaLabel);
164337
+ const iframe = modal.querySelector('iframe');
164338
+ iframe.src = url;
164339
+
164340
+ if (config.showCloseButton) {
164341
+ const closeBtn = document.createElement('button');
164342
+ closeBtn.innerHTML = `
164343
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-x"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M18 6l-12 12" /><path d="M6 6l12 12" /></svg>
164344
+ `;
164345
+ closeBtn.className = 'modal-close';
164346
+ closeBtn.addEventListener('click', () => {
164347
+ modal.remove();
164348
+ if (typeof config.onClose === 'function') config.onClose(modal, iframe);
164349
+ });
164350
+ modal.querySelector('div').prepend(closeBtn);
164351
+ }
164352
+
164353
+ if (typeof config.onOpen === 'function') config.onOpen(modal, iframe);
164354
+ this.editor.util.showModal(modal, false, () => {
164355
+ if (typeof config.onClose === 'function') config.onClose(modal, iframe);
164356
+ });
164357
+ }
164358
+
164290
164359
  boxImage(url, err) {
164291
164360
  if (!this.controlPanel) {
164292
164361
  this.editbox.boxImage(url, err);