@innovastudio/contentbox 1.6.134 → 1.6.135
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,6 +364,16 @@ 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
|
|
@@ -390,7 +400,7 @@ declare class ContentBox {
|
|
390
400
|
viewHtml(): void;
|
391
401
|
toggleEditPanel(): void;
|
392
402
|
getWrapper(): HTMLElement;
|
393
|
-
|
403
|
+
openModal(url: string, options?: OpenModalOptions): void;
|
394
404
|
screenMode: string;
|
395
405
|
}
|
396
406
|
export default ContentBox;
|
package/package.json
CHANGED
@@ -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 */
|
@@ -164287,6 +164287,52 @@ Add an image for each feature.`, 'Create a new block showcasing a photo gallery
|
|
164287
164287
|
}, 400);
|
164288
164288
|
}
|
164289
164289
|
|
164290
|
+
openModal(url, prop = {}) {
|
164291
|
+
const defaults = {
|
164292
|
+
w: '88vw',
|
164293
|
+
maxW: '1600px',
|
164294
|
+
h: '88vh',
|
164295
|
+
extraStyle: '',
|
164296
|
+
ariaLabel: 'Modal',
|
164297
|
+
showCloseButton: false
|
164298
|
+
};
|
164299
|
+
const config = { ...defaults,
|
164300
|
+
...prop
|
164301
|
+
};
|
164302
|
+
const html = `
|
164303
|
+
<div class="is-modal custom-modal" style="z-index:10005" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true">
|
164304
|
+
<div style="width:${config.w};max-width:${config.maxW};height:${config.h};padding:0;${config.extraStyle}">
|
164305
|
+
<iframe tabindex="0" style="width:100%;height:100%;border: none;display: block;" src="about:blank"></iframe>
|
164306
|
+
</div>
|
164307
|
+
</div>
|
164308
|
+
`;
|
164309
|
+
const oldModal = this.builderStuff.querySelector('.is-modal.custom-modal');
|
164310
|
+
if (oldModal) oldModal.remove();
|
164311
|
+
this.builderStuff.insertAdjacentHTML('beforeend', html);
|
164312
|
+
const modal = this.builderStuff.querySelector('.is-modal.custom-modal');
|
164313
|
+
modal.setAttribute('aria-label', config.ariaLabel);
|
164314
|
+
const iframe = modal.querySelector('iframe');
|
164315
|
+
iframe.src = url;
|
164316
|
+
|
164317
|
+
if (config.showCloseButton) {
|
164318
|
+
const closeBtn = document.createElement('button');
|
164319
|
+
closeBtn.innerHTML = `
|
164320
|
+
<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>
|
164321
|
+
`;
|
164322
|
+
closeBtn.className = 'modal-close';
|
164323
|
+
closeBtn.addEventListener('click', () => {
|
164324
|
+
modal.remove();
|
164325
|
+
if (typeof config.onClose === 'function') config.onClose(modal, iframe);
|
164326
|
+
});
|
164327
|
+
modal.querySelector('div').prepend(closeBtn);
|
164328
|
+
}
|
164329
|
+
|
164330
|
+
if (typeof config.onOpen === 'function') config.onOpen(modal, iframe);
|
164331
|
+
this.editor.util.showModal(modal, false, () => {
|
164332
|
+
if (typeof config.onClose === 'function') config.onClose(modal, iframe);
|
164333
|
+
});
|
164334
|
+
}
|
164335
|
+
|
164290
164336
|
boxImage(url, err) {
|
164291
164337
|
if (!this.controlPanel) {
|
164292
164338
|
this.editbox.boxImage(url, err);
|