@forge/bridge 5.16.3-next.0 → 5.17.0-next.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/CHANGELOG.md +13 -0
- package/out/modal/modal.d.ts +10 -2
- package/out/modal/modal.d.ts.map +1 -1
- package/out/modal/modal.js +16 -0
- package/out/view/adf-renderer.d.ts +12 -0
- package/out/view/adf-renderer.d.ts.map +1 -1
- package/out/view/adf-renderer.js +24 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @forge/bridge
|
|
2
2
|
|
|
3
|
+
## 5.17.0-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [ccdcfc3]
|
|
8
|
+
- @forge/manifest@12.8.1-next.0
|
|
9
|
+
|
|
10
|
+
## 5.17.0-next.1
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 3cf97c3: Extend forge/bridge modal types with custom dimensions
|
|
15
|
+
|
|
3
16
|
## 5.16.3-next.0
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/out/modal/modal.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
declare const NAMED_MODAL_SIZES: readonly ["small", "medium", "large", "xlarge", "max", "fullscreen"];
|
|
2
|
+
declare type NamedModalSize = (typeof NAMED_MODAL_SIZES)[number];
|
|
3
|
+
declare type CustomModalSize = {
|
|
4
|
+
width: string;
|
|
5
|
+
height?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare type ModalSizes = NamedModalSize | CustomModalSize;
|
|
1
8
|
export interface ModalOptions {
|
|
2
9
|
resource?: string | null;
|
|
3
10
|
onClose?: (payload: any) => any;
|
|
4
|
-
size?:
|
|
11
|
+
size?: ModalSizes;
|
|
5
12
|
context?: any;
|
|
6
13
|
closeOnEscape?: boolean;
|
|
7
14
|
closeOnOverlayClick?: boolean;
|
|
@@ -11,7 +18,7 @@ export interface ModalOptions {
|
|
|
11
18
|
export declare class Modal {
|
|
12
19
|
resource: string | null;
|
|
13
20
|
onClose: NonNullable<ModalOptions['onClose']>;
|
|
14
|
-
size:
|
|
21
|
+
size: ModalSizes;
|
|
15
22
|
context: any;
|
|
16
23
|
closeOnEscape: boolean;
|
|
17
24
|
closeOnOverlayClick: boolean;
|
|
@@ -20,4 +27,5 @@ export declare class Modal {
|
|
|
20
27
|
constructor(opts?: ModalOptions);
|
|
21
28
|
open(): Promise<void>;
|
|
22
29
|
}
|
|
30
|
+
export {};
|
|
23
31
|
//# sourceMappingURL=modal.d.ts.map
|
package/out/modal/modal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../src/modal/modal.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,GAAG,CAAC;IAChC,IAAI,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../src/modal/modal.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,iBAAiB,sEAAuE,CAAC;AAC/F,aAAK,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,aAAK,eAAe,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,UAAU,GAAG,cAAc,GAAG,eAAe,CAAC;AAE1D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,GAAG,CAAC;IAChC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAmBD,qBAAa,KAAK;IAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;IAC9C,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC;IACb,aAAa,EAAE,OAAO,CAAC;IACvB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;gBACD,IAAI,CAAC,EAAE,YAAY;IAWzB,IAAI;CA0BX"}
|
package/out/modal/modal.js
CHANGED
|
@@ -4,8 +4,21 @@ exports.Modal = void 0;
|
|
|
4
4
|
const bridge_1 = require("../bridge");
|
|
5
5
|
const errors_1 = require("../errors");
|
|
6
6
|
const callBridge = (0, bridge_1.getCallBridge)();
|
|
7
|
+
const NAMED_MODAL_SIZES = ['small', 'medium', 'large', 'xlarge', 'max', 'fullscreen'];
|
|
7
8
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
8
9
|
const noop = () => { };
|
|
10
|
+
function isNamedModalSize(size) {
|
|
11
|
+
return typeof size === 'string' && NAMED_MODAL_SIZES.includes(size);
|
|
12
|
+
}
|
|
13
|
+
function isCustomModalSize(size) {
|
|
14
|
+
if (typeof size !== 'object' || size === null)
|
|
15
|
+
return false;
|
|
16
|
+
const s = size;
|
|
17
|
+
return typeof s.width === 'string' && (s.height === undefined || typeof s.height === 'string');
|
|
18
|
+
}
|
|
19
|
+
function isValidModalSize(size) {
|
|
20
|
+
return isNamedModalSize(size) || isCustomModalSize(size);
|
|
21
|
+
}
|
|
9
22
|
class Modal {
|
|
10
23
|
constructor(opts) {
|
|
11
24
|
var _a, _b;
|
|
@@ -19,6 +32,9 @@ class Modal {
|
|
|
19
32
|
this.icon = (opts === null || opts === void 0 ? void 0 : opts.icon) || '';
|
|
20
33
|
}
|
|
21
34
|
async open() {
|
|
35
|
+
if (!isValidModalSize(this.size)) {
|
|
36
|
+
throw new errors_1.BridgeAPIError(`Invalid modal size: ${JSON.stringify(this.size)}. Must be one of the named sizes (${NAMED_MODAL_SIZES.join(', ')}) or a custom dimensions object with a "width" string property and an optional "height" string property.`);
|
|
37
|
+
}
|
|
22
38
|
try {
|
|
23
39
|
const success = await callBridge('openModal', {
|
|
24
40
|
resource: this.resource,
|
|
@@ -1,7 +1,19 @@
|
|
|
1
|
+
import { DocNode } from '@atlaskit/adf-schema';
|
|
1
2
|
import type { FullContext } from '../types';
|
|
3
|
+
interface AdfPostMessageData {
|
|
4
|
+
type: 'adf-document';
|
|
5
|
+
document: DocNode;
|
|
6
|
+
timestamp: number;
|
|
7
|
+
source: 'forge-adf-renderer';
|
|
8
|
+
localId: string;
|
|
9
|
+
isEditing: boolean;
|
|
10
|
+
contentId: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const sendMessageWhenReady: (iframe: HTMLIFrameElement | null, message: AdfPostMessageData, origin: string) => void;
|
|
2
13
|
export declare const createAdfRendererIframeProps: (context: FullContext, iframeId?: string) => Promise<{
|
|
3
14
|
id: string;
|
|
4
15
|
src: string;
|
|
5
16
|
onLoad: () => void;
|
|
6
17
|
}>;
|
|
18
|
+
export {};
|
|
7
19
|
//# sourceMappingURL=adf-renderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adf-renderer.d.ts","sourceRoot":"","sources":["../../src/view/adf-renderer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adf-renderer.d.ts","sourceRoot":"","sources":["../../src/view/adf-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,UAAU,kBAAkB;IAC1B,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,oBAAoB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAOD,eAAO,MAAM,oBAAoB,WACvB,iBAAiB,GAAG,IAAI,WACvB,kBAAkB,UACnB,MAAM,KACb,IAgBF,CAAC;AAEF,eAAO,MAAM,4BAA4B,YAAmB,WAAW,aAAa,MAAM;;;;EA0CzF,CAAC"}
|
package/out/view/adf-renderer.js
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAdfRendererIframeProps = void 0;
|
|
3
|
+
exports.createAdfRendererIframeProps = exports.sendMessageWhenReady = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Sends the ADF document message to the adf-renderer iframe once it signals readiness.
|
|
6
|
+
*/
|
|
7
|
+
const READY_SIGNAL_FALLBACK_DELAY_MS = 10000;
|
|
8
|
+
const sendMessageWhenReady = (iframe, message, origin) => {
|
|
9
|
+
const sendMessage = () => { var _a; return (_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(message, origin); };
|
|
10
|
+
const timeoutId = setTimeout(() => {
|
|
11
|
+
window.removeEventListener('message', handleReady);
|
|
12
|
+
sendMessage();
|
|
13
|
+
}, READY_SIGNAL_FALLBACK_DELAY_MS);
|
|
14
|
+
const handleReady = (event) => {
|
|
15
|
+
var _a;
|
|
16
|
+
if (event.source === (iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) && ((_a = event.data) === null || _a === void 0 ? void 0 : _a.source) === 'forge-adf-renderer-ready') {
|
|
17
|
+
clearTimeout(timeoutId);
|
|
18
|
+
window.removeEventListener('message', handleReady);
|
|
19
|
+
sendMessage();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
window.addEventListener('message', handleReady);
|
|
23
|
+
};
|
|
24
|
+
exports.sendMessageWhenReady = sendMessageWhenReady;
|
|
4
25
|
const createAdfRendererIframeProps = async (context, iframeId) => {
|
|
5
26
|
const IframeResizer = await import('iframe-resizer');
|
|
6
27
|
const IframeResizerModule = IframeResizer.default || IframeResizer;
|
|
@@ -8,7 +29,7 @@ const createAdfRendererIframeProps = async (context, iframeId) => {
|
|
|
8
29
|
const src = `${origin}/forge-apps/adf-renderer`;
|
|
9
30
|
const id = iframeId || `forge-adf-renderer-iframe-${crypto.randomUUID()}`;
|
|
10
31
|
const onLoad = () => {
|
|
11
|
-
var _a, _b, _c, _d, _e
|
|
32
|
+
var _a, _b, _c, _d, _e;
|
|
12
33
|
const iframe = document.getElementById(id);
|
|
13
34
|
const message = {
|
|
14
35
|
type: 'adf-document',
|
|
@@ -27,7 +48,7 @@ const createAdfRendererIframeProps = async (context, iframeId) => {
|
|
|
27
48
|
(_a = iframe === null || iframe === void 0 ? void 0 : iframe.iFrameResizer) === null || _a === void 0 ? void 0 : _a.resize();
|
|
28
49
|
}
|
|
29
50
|
}, iframe || '');
|
|
30
|
-
(
|
|
51
|
+
(0, exports.sendMessageWhenReady)(iframe, message, origin);
|
|
31
52
|
};
|
|
32
53
|
setTimeout(() => {
|
|
33
54
|
document.documentElement.style.height = 'auto';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/bridge",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.17.0-next.2",
|
|
4
4
|
"description": "Forge bridge API for custom UI apps",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@forge/i18n": "0.0.7",
|
|
20
20
|
"@forge/resolver": "1.8.0",
|
|
21
21
|
"@types/history": "^4.7.11",
|
|
22
|
-
"@forge/manifest": "12.8.0",
|
|
22
|
+
"@forge/manifest": "12.8.1-next.0",
|
|
23
23
|
"@types/iframe-resizer": "^3.5.8",
|
|
24
24
|
"iframe-resizer": "^4.4.5"
|
|
25
25
|
},
|