@atlaskit/native-embeds-common 2.0.5 → 2.0.6

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/native-embeds-common
2
2
 
3
+ ## 2.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`07226ab3fad50`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/07226ab3fad50) -
8
+ [ux] Reserve native embed first-paint layout
9
+ - Updated dependencies
10
+
3
11
  ## 2.0.5
4
12
 
5
13
  ### Patch Changes
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveNativeEmbedInitialLayout = exports.NATIVE_EMBED_INITIAL_LAYOUT_FALLBACK_ASPECT_RATIO = void 0;
7
+ var _utils = require("../utils/utils");
8
+ var NATIVE_EMBED_INITIAL_LAYOUT_FALLBACK_ASPECT_RATIO = exports.NATIVE_EMBED_INITIAL_LAYOUT_FALLBACK_ASPECT_RATIO = '760 / 600';
9
+ /**
10
+ * Resolve the dimensions needed to reserve native embed layout before the full iframe UI is ready.
11
+ *
12
+ * This intentionally depends only on ADF parameters and optional manifest-like metadata so it can be
13
+ * reused by React, DOMOutputSpec, SSR, and renderer placeholders without importing iframe UI code.
14
+ */
15
+ var resolveNativeEmbedInitialLayout = exports.resolveNativeEmbedInitialLayout = function resolveNativeEmbedInitialLayout(_ref) {
16
+ var _manifest$parameterDe, _manifest$parameterDe2, _manifest$parameterDe3, _manifest$lockResizeA, _manifest$uiConfig$sh, _manifest$uiConfig;
17
+ var manifest = _ref.manifest,
18
+ parameters = _ref.parameters,
19
+ placeholderId = _ref.placeholderId;
20
+ var _getParameters = (0, _utils.getParameters)(parameters),
21
+ alignment = _getParameters.alignment,
22
+ aspectRatio = _getParameters.aspectRatio,
23
+ height = _getParameters.height,
24
+ width = _getParameters.width;
25
+ var effectiveWidth = width !== null && width !== void 0 ? width : manifest === null || manifest === void 0 || (_manifest$parameterDe = manifest.parameterDefaults) === null || _manifest$parameterDe === void 0 ? void 0 : _manifest$parameterDe.width;
26
+
27
+ // `getParameters` always supplies default values, so inspect raw macroParams to distinguish
28
+ // stored dimensions from package defaults. This prevents the default aspectRatio from affecting
29
+ // older embeds that never persisted original dimensions.
30
+ var macroParams = parameters === null || parameters === void 0 ? void 0 : parameters.macroParams;
31
+ var heightExplicitlyStored = !!(macroParams !== null && macroParams !== void 0 && macroParams.height);
32
+ var aspectRatioExplicitlyStored = !!(macroParams !== null && macroParams !== void 0 && macroParams.aspectRatio);
33
+ var effectiveHeightRaw = heightExplicitlyStored ? height : (_manifest$parameterDe2 = manifest === null || manifest === void 0 || (_manifest$parameterDe3 = manifest.parameterDefaults) === null || _manifest$parameterDe3 === void 0 ? void 0 : _manifest$parameterDe3.height) !== null && _manifest$parameterDe2 !== void 0 ? _manifest$parameterDe2 : null;
34
+ var effectiveHeight = aspectRatioExplicitlyStored && aspectRatio != null && aspectRatio > 0 && effectiveWidth != null && !heightExplicitlyStored ? Math.round(effectiveWidth / aspectRatio) : effectiveHeightRaw !== null && effectiveHeightRaw !== void 0 ? effectiveHeightRaw : height;
35
+ var lockAspectRatio = typeof (manifest === null || manifest === void 0 ? void 0 : manifest.lockResizeAspectRatio) === 'function' ? manifest.lockResizeAspectRatio() : (_manifest$lockResizeA = manifest === null || manifest === void 0 ? void 0 : manifest.lockResizeAspectRatio) !== null && _manifest$lockResizeA !== void 0 ? _manifest$lockResizeA : true;
36
+ return {
37
+ alignment: alignment,
38
+ effectiveHeight: effectiveHeight,
39
+ effectiveWidth: effectiveWidth,
40
+ hasEmbedBorder: (_manifest$uiConfig$sh = manifest === null || manifest === void 0 || (_manifest$uiConfig = manifest.uiConfig) === null || _manifest$uiConfig === void 0 ? void 0 : _manifest$uiConfig.showBorder) !== null && _manifest$uiConfig$sh !== void 0 ? _manifest$uiConfig$sh : true,
41
+ lockAspectRatio: lockAspectRatio,
42
+ placeholderId: placeholderId
43
+ };
44
+ };
@@ -0,0 +1,40 @@
1
+ import { getParameters } from '../utils/utils';
2
+ export const NATIVE_EMBED_INITIAL_LAYOUT_FALLBACK_ASPECT_RATIO = '760 / 600';
3
+ /**
4
+ * Resolve the dimensions needed to reserve native embed layout before the full iframe UI is ready.
5
+ *
6
+ * This intentionally depends only on ADF parameters and optional manifest-like metadata so it can be
7
+ * reused by React, DOMOutputSpec, SSR, and renderer placeholders without importing iframe UI code.
8
+ */
9
+ export const resolveNativeEmbedInitialLayout = ({
10
+ manifest,
11
+ parameters,
12
+ placeholderId
13
+ }) => {
14
+ var _manifest$parameterDe, _manifest$parameterDe2, _manifest$parameterDe3, _manifest$lockResizeA, _manifest$uiConfig$sh, _manifest$uiConfig;
15
+ const {
16
+ alignment,
17
+ aspectRatio,
18
+ height,
19
+ width
20
+ } = getParameters(parameters);
21
+ const effectiveWidth = width !== null && width !== void 0 ? width : manifest === null || manifest === void 0 ? void 0 : (_manifest$parameterDe = manifest.parameterDefaults) === null || _manifest$parameterDe === void 0 ? void 0 : _manifest$parameterDe.width;
22
+
23
+ // `getParameters` always supplies default values, so inspect raw macroParams to distinguish
24
+ // stored dimensions from package defaults. This prevents the default aspectRatio from affecting
25
+ // older embeds that never persisted original dimensions.
26
+ const macroParams = parameters === null || parameters === void 0 ? void 0 : parameters.macroParams;
27
+ const heightExplicitlyStored = !!(macroParams !== null && macroParams !== void 0 && macroParams.height);
28
+ const aspectRatioExplicitlyStored = !!(macroParams !== null && macroParams !== void 0 && macroParams.aspectRatio);
29
+ const effectiveHeightRaw = heightExplicitlyStored ? height : (_manifest$parameterDe2 = manifest === null || manifest === void 0 ? void 0 : (_manifest$parameterDe3 = manifest.parameterDefaults) === null || _manifest$parameterDe3 === void 0 ? void 0 : _manifest$parameterDe3.height) !== null && _manifest$parameterDe2 !== void 0 ? _manifest$parameterDe2 : null;
30
+ const effectiveHeight = aspectRatioExplicitlyStored && aspectRatio != null && aspectRatio > 0 && effectiveWidth != null && !heightExplicitlyStored ? Math.round(effectiveWidth / aspectRatio) : effectiveHeightRaw !== null && effectiveHeightRaw !== void 0 ? effectiveHeightRaw : height;
31
+ const lockAspectRatio = typeof (manifest === null || manifest === void 0 ? void 0 : manifest.lockResizeAspectRatio) === 'function' ? manifest.lockResizeAspectRatio() : (_manifest$lockResizeA = manifest === null || manifest === void 0 ? void 0 : manifest.lockResizeAspectRatio) !== null && _manifest$lockResizeA !== void 0 ? _manifest$lockResizeA : true;
32
+ return {
33
+ alignment,
34
+ effectiveHeight,
35
+ effectiveWidth,
36
+ hasEmbedBorder: (_manifest$uiConfig$sh = manifest === null || manifest === void 0 ? void 0 : (_manifest$uiConfig = manifest.uiConfig) === null || _manifest$uiConfig === void 0 ? void 0 : _manifest$uiConfig.showBorder) !== null && _manifest$uiConfig$sh !== void 0 ? _manifest$uiConfig$sh : true,
37
+ lockAspectRatio,
38
+ placeholderId
39
+ };
40
+ };
@@ -1,6 +1,5 @@
1
1
  // Re-export constants
2
2
  export { ALIGNMENT_VALUES, DEFAULT_ALIGNMENT, BUILTIN_TOOLBAR_KEYS, EDITOR_TOOLBAR_HANDLER_KEYS, NATIVE_EMBED_PARAMETER_DEFAULTS } from './utils/constants';
3
-
4
3
  // Re-export types
5
4
 
6
5
  // Plugin actions types
@@ -0,0 +1,38 @@
1
+ import { getParameters } from '../utils/utils';
2
+ export var NATIVE_EMBED_INITIAL_LAYOUT_FALLBACK_ASPECT_RATIO = '760 / 600';
3
+ /**
4
+ * Resolve the dimensions needed to reserve native embed layout before the full iframe UI is ready.
5
+ *
6
+ * This intentionally depends only on ADF parameters and optional manifest-like metadata so it can be
7
+ * reused by React, DOMOutputSpec, SSR, and renderer placeholders without importing iframe UI code.
8
+ */
9
+ export var resolveNativeEmbedInitialLayout = function resolveNativeEmbedInitialLayout(_ref) {
10
+ var _manifest$parameterDe, _manifest$parameterDe2, _manifest$parameterDe3, _manifest$lockResizeA, _manifest$uiConfig$sh, _manifest$uiConfig;
11
+ var manifest = _ref.manifest,
12
+ parameters = _ref.parameters,
13
+ placeholderId = _ref.placeholderId;
14
+ var _getParameters = getParameters(parameters),
15
+ alignment = _getParameters.alignment,
16
+ aspectRatio = _getParameters.aspectRatio,
17
+ height = _getParameters.height,
18
+ width = _getParameters.width;
19
+ var effectiveWidth = width !== null && width !== void 0 ? width : manifest === null || manifest === void 0 || (_manifest$parameterDe = manifest.parameterDefaults) === null || _manifest$parameterDe === void 0 ? void 0 : _manifest$parameterDe.width;
20
+
21
+ // `getParameters` always supplies default values, so inspect raw macroParams to distinguish
22
+ // stored dimensions from package defaults. This prevents the default aspectRatio from affecting
23
+ // older embeds that never persisted original dimensions.
24
+ var macroParams = parameters === null || parameters === void 0 ? void 0 : parameters.macroParams;
25
+ var heightExplicitlyStored = !!(macroParams !== null && macroParams !== void 0 && macroParams.height);
26
+ var aspectRatioExplicitlyStored = !!(macroParams !== null && macroParams !== void 0 && macroParams.aspectRatio);
27
+ var effectiveHeightRaw = heightExplicitlyStored ? height : (_manifest$parameterDe2 = manifest === null || manifest === void 0 || (_manifest$parameterDe3 = manifest.parameterDefaults) === null || _manifest$parameterDe3 === void 0 ? void 0 : _manifest$parameterDe3.height) !== null && _manifest$parameterDe2 !== void 0 ? _manifest$parameterDe2 : null;
28
+ var effectiveHeight = aspectRatioExplicitlyStored && aspectRatio != null && aspectRatio > 0 && effectiveWidth != null && !heightExplicitlyStored ? Math.round(effectiveWidth / aspectRatio) : effectiveHeightRaw !== null && effectiveHeightRaw !== void 0 ? effectiveHeightRaw : height;
29
+ var lockAspectRatio = typeof (manifest === null || manifest === void 0 ? void 0 : manifest.lockResizeAspectRatio) === 'function' ? manifest.lockResizeAspectRatio() : (_manifest$lockResizeA = manifest === null || manifest === void 0 ? void 0 : manifest.lockResizeAspectRatio) !== null && _manifest$lockResizeA !== void 0 ? _manifest$lockResizeA : true;
30
+ return {
31
+ alignment: alignment,
32
+ effectiveHeight: effectiveHeight,
33
+ effectiveWidth: effectiveWidth,
34
+ hasEmbedBorder: (_manifest$uiConfig$sh = manifest === null || manifest === void 0 || (_manifest$uiConfig = manifest.uiConfig) === null || _manifest$uiConfig === void 0 ? void 0 : _manifest$uiConfig.showBorder) !== null && _manifest$uiConfig$sh !== void 0 ? _manifest$uiConfig$sh : true,
35
+ lockAspectRatio: lockAspectRatio,
36
+ placeholderId: placeholderId
37
+ };
38
+ };
package/dist/esm/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  // Re-export constants
2
2
  export { ALIGNMENT_VALUES, DEFAULT_ALIGNMENT, BUILTIN_TOOLBAR_KEYS, EDITOR_TOOLBAR_HANDLER_KEYS, NATIVE_EMBED_PARAMETER_DEFAULTS } from './utils/constants';
3
-
4
3
  // Re-export types
5
4
 
6
5
  // Plugin actions types
@@ -0,0 +1,32 @@
1
+ import type { AlignmentValue, NativeEmbedParameters } from '../utils/types';
2
+ export declare const NATIVE_EMBED_INITIAL_LAYOUT_FALLBACK_ASPECT_RATIO = "760 / 600";
3
+ export type NativeEmbedInitialLayoutManifest = {
4
+ lockResizeAspectRatio?: boolean | (() => boolean);
5
+ parameterDefaults?: {
6
+ height?: number;
7
+ width?: number;
8
+ };
9
+ uiConfig?: {
10
+ showBorder?: boolean;
11
+ };
12
+ };
13
+ export type NativeEmbedInitialLayout = {
14
+ alignment: AlignmentValue;
15
+ effectiveHeight: number;
16
+ effectiveWidth: number | undefined;
17
+ hasEmbedBorder: boolean;
18
+ lockAspectRatio: boolean;
19
+ placeholderId?: string;
20
+ };
21
+ export type ResolveNativeEmbedInitialLayoutInput = {
22
+ manifest?: NativeEmbedInitialLayoutManifest;
23
+ parameters?: NativeEmbedParameters;
24
+ placeholderId?: string;
25
+ };
26
+ /**
27
+ * Resolve the dimensions needed to reserve native embed layout before the full iframe UI is ready.
28
+ *
29
+ * This intentionally depends only on ADF parameters and optional manifest-like metadata so it can be
30
+ * reused by React, DOMOutputSpec, SSR, and renderer placeholders without importing iframe UI code.
31
+ */
32
+ export declare const resolveNativeEmbedInitialLayout: ({ manifest, parameters, placeholderId, }: ResolveNativeEmbedInitialLayoutInput) => NativeEmbedInitialLayout;
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@atlaskit/native-embeds-common/initial-layout",
3
+ "main": "../dist/cjs/entry-points/initial-layout.js",
4
+ "module": "../dist/esm/entry-points/initial-layout.js",
5
+ "module:es2019": "../dist/es2019/entry-points/initial-layout.js",
6
+ "sideEffects": [
7
+ "*.compiled.css"
8
+ ],
9
+ "types": "../dist/types/entry-points/initial-layout.d.ts"
10
+ }
package/package.json CHANGED
@@ -17,13 +17,13 @@
17
17
  "atlaskit:src": "src/index.ts",
18
18
  "dependencies": {
19
19
  "@atlaskit/button": "^24.3.0",
20
- "@atlaskit/editor-common": "^116.19.0",
20
+ "@atlaskit/editor-common": "^116.24.0",
21
21
  "@atlaskit/editor-plugin-local-id": "^10.1.0",
22
22
  "@atlaskit/editor-prosemirror": "^8.0.0",
23
- "@atlaskit/heading": "^6.1.0",
24
- "@atlaskit/icon": "^36.1.0",
25
- "@atlaskit/primitives": "^20.3.0",
26
- "@atlaskit/tokens": "^15.3.0",
23
+ "@atlaskit/heading": "^6.2.0",
24
+ "@atlaskit/icon": "^36.2.0",
25
+ "@atlaskit/primitives": "^20.5.0",
26
+ "@atlaskit/tokens": "^15.5.0",
27
27
  "@atlassian/afm-i18n-platform-native-embeds-native-embeds-common": "1.7.0",
28
28
  "@babel/runtime": "^7.0.0",
29
29
  "@compiled/react": "^0.20.0"
@@ -80,7 +80,7 @@
80
80
  }
81
81
  },
82
82
  "name": "@atlaskit/native-embeds-common",
83
- "version": "2.0.5",
83
+ "version": "2.0.6",
84
84
  "description": "A shared package for native embeds to be used across experiences and plugin",
85
85
  "author": "Atlassian Pty Ltd",
86
86
  "license": "Apache-2.0",