@atlaskit/native-embeds-common 1.0.2 → 1.1.1

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,41 @@
1
1
  # @atlaskit/native-embeds-common
2
2
 
3
+ ## 1.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9e964a88958bd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9e964a88958bd) -
8
+ Fix resize overlay placeholder height and aspect ratio calculation to use the stored `aspectRatio`
9
+ node parameter (set from originalWidth/originalHeight during card-to-native-embed conversion)
10
+ rather than relying solely on live DOM measurements. This ensures resize handles and the overlay
11
+ placeholder reflect the correct proportions from the very first selection, before a resize has
12
+ occurred. Applies to both `EmbedResizeOverlay` and `ResizableNativeEmbedLegacy`.
13
+
14
+ Add `aspectRatio` to `NativeEmbedParameters` macroParams type so that `getParameters` and
15
+ `setParameters` correctly serialize and deserialize the stored width-to-height ratio. This enables
16
+ native embed containers to derive their height from the original embed dimensions without
17
+ requiring a resize interaction.
18
+
19
+ Fix native embed containers incorrectly defaulting to a 1:1 or 1200/600 aspect ratio on initial
20
+ render when `aspectRatio` (originalWidth/originalHeight) is stored in the node parameters. The
21
+ container now derives the correct height from the stored `aspectRatio` on the very first render,
22
+ before any resize interaction occurs.
23
+
24
+ - Updated dependencies
25
+
26
+ ## 1.1.0
27
+
28
+ ### Minor Changes
29
+
30
+ - [`7fe1914f87802`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7fe1914f87802) -
31
+ MAUI-463: Add expand (fullscreen preview) button to native embed editor floating toolbar. Removes
32
+ expand button from embed header for MAUI embeds (Infographic, Chart, Visualization) since it is
33
+ now in the editor toolbar.
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies
38
+
3
39
  ## 1.0.2
4
40
 
5
41
  ### Patch Changes
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "EMBED_DEPTH_QUERY_PARAM", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _constants.EMBED_DEPTH_QUERY_PARAM;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "MAX_EMBED_DEPTH", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _constants.MAX_EMBED_DEPTH;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "getCurrentEmbedDepth", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _constants.getCurrentEmbedDepth;
22
+ }
23
+ });
24
+ var _constants = require("./utils/constants");
@@ -3,7 +3,40 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.NATIVE_EMBED_PARAMETER_DEFAULTS = exports.EDITOR_TOOLBAR_HANDLER_KEYS = exports.DEFAULT_ALIGNMENT = exports.BUILTIN_TOOLBAR_KEYS = exports.ALIGNMENT_VALUES = void 0;
6
+ exports.getCurrentEmbedDepth = exports.NATIVE_EMBED_PARAMETER_DEFAULTS = exports.MAX_EMBED_DEPTH = exports.EMBED_DEPTH_QUERY_PARAM = exports.EDITOR_TOOLBAR_HANDLER_KEYS = exports.DEFAULT_ALIGNMENT = exports.BUILTIN_TOOLBAR_KEYS = exports.ALIGNMENT_VALUES = void 0;
7
+ // ─── Embed depth constants ──────────────────────────────────────────────────
8
+
9
+ /**
10
+ * URL query-parameter key used to track the current embedding depth.
11
+ * Each nested native-embed iframe increments this value by 1.
12
+ */
13
+ var EMBED_DEPTH_QUERY_PARAM = exports.EMBED_DEPTH_QUERY_PARAM = 'nativeEmbedDepth';
14
+
15
+ /**
16
+ * Maximum allowed embedding depth. When `getCurrentEmbedDepth()` returns a
17
+ * value **≥** this limit the extension renderer should display a fallback
18
+ * instead of another iframe to prevent infinite recursion.
19
+ */
20
+ var MAX_EMBED_DEPTH = exports.MAX_EMBED_DEPTH = 2;
21
+
22
+ /**
23
+ * Read the current embedding depth from `window.location.search`.
24
+ *
25
+ * Returns `0` when the parameter is absent or cannot be parsed as a
26
+ * non-negative integer, which is the expected case for top-level pages.
27
+ */
28
+ var getCurrentEmbedDepth = exports.getCurrentEmbedDepth = function getCurrentEmbedDepth() {
29
+ if (typeof window === 'undefined') {
30
+ return 0;
31
+ }
32
+ var raw = new URLSearchParams(window.location.search).get(EMBED_DEPTH_QUERY_PARAM);
33
+ if (raw === null) {
34
+ return 0;
35
+ }
36
+ var parsed = Number(raw);
37
+ return Number.isFinite(parsed) && parsed >= 0 ? Math.floor(parsed) : 0;
38
+ };
39
+
7
40
  // Alignment constants
8
41
  var ALIGNMENT_VALUES = exports.ALIGNMENT_VALUES = ['left', 'center', 'right', 'wrap-left', 'wrap-right'];
9
42
  var DEFAULT_ALIGNMENT = exports.DEFAULT_ALIGNMENT = 'center';
@@ -13,6 +46,7 @@ var NATIVE_EMBED_PARAMETER_DEFAULTS = exports.NATIVE_EMBED_PARAMETER_DEFAULTS =
13
46
  alignment: DEFAULT_ALIGNMENT,
14
47
  displayText: undefined,
15
48
  height: 600,
49
+ aspectRatio: 1,
16
50
  width: undefined
17
51
  };
18
52
 
@@ -32,6 +66,8 @@ var BUILTIN_TOOLBAR_KEYS = exports.BUILTIN_TOOLBAR_KEYS = {
32
66
  BORDER: 'border',
33
67
  ALIGNMENT: 'alignment',
34
68
  OPEN_IN_NEW_WINDOW: 'openInNewWindow',
69
+ /** Opens the embed's fullscreen preview dialog. */
70
+ EXPAND: 'expand',
35
71
  EDIT_URL: 'editUrl',
36
72
  ALWAYS_SHOW_TITLE: 'alwaysShowTitle',
37
73
  SET_EMBED_TYPE: 'setEmbedType',
@@ -47,4 +83,4 @@ var BUILTIN_TOOLBAR_KEYS = exports.BUILTIN_TOOLBAR_KEYS = {
47
83
  DELETE: 'delete',
48
84
  SEPARATOR: 'separator'
49
85
  };
50
- var EDITOR_TOOLBAR_HANDLER_KEYS = exports.EDITOR_TOOLBAR_HANDLER_KEYS = ['onAlignmentClick', 'onAppearanceClick', 'onAskRovoClick', 'onSummariseClick', 'onChangeBorderClick', 'onCopyClick', 'onCopyLinkClick', 'onDeleteClick', 'onEditClick', 'onEditUrlClick', 'onOpenInNewWindowClick', 'onRefreshClick', 'onSetEmbedTypeClick', 'onShowTitleClick'];
86
+ var EDITOR_TOOLBAR_HANDLER_KEYS = exports.EDITOR_TOOLBAR_HANDLER_KEYS = ['onAlignmentClick', 'onAppearanceClick', 'onAskRovoClick', 'onSummariseClick', 'onChangeBorderClick', 'onCopyClick', 'onCopyLinkClick', 'onDeleteClick', 'onEditClick', 'onEditUrlClick', 'onExpandClick', 'onOpenInNewWindowClick', 'onRefreshClick', 'onSetEmbedTypeClick', 'onShowTitleClick'];
@@ -30,8 +30,24 @@ var PARAMETER_VALIDATORS = {
30
30
  return _constants.ALIGNMENT_VALUES.includes(value);
31
31
  }
32
32
  };
33
- var parseFromDefault = function parseFromDefault(defaultValue, value) {
34
- if (typeof defaultValue === 'boolean') {
33
+
34
+ /**
35
+ * Explicitly declares the intended primitive type for each parameter key.
36
+ * This is necessary for keys whose default value is `undefined` (e.g. `url`, `width`),
37
+ * because `typeof undefined === 'undefined'` gives no type information for deserialization.
38
+ */
39
+ var PARAMETER_TYPES = {
40
+ alignment: 'string',
41
+ alwaysShowTitle: 'boolean',
42
+ aspectRatio: 'number',
43
+ displayText: 'string',
44
+ height: 'number',
45
+ url: 'string',
46
+ width: 'number'
47
+ };
48
+ var parseFromDefault = function parseFromDefault(defaultValue, value, explicitType) {
49
+ var resolvedType = explicitType !== null && explicitType !== void 0 ? explicitType : (0, _typeof2.default)(defaultValue);
50
+ if (resolvedType === 'boolean') {
35
51
  if (typeof value === 'boolean') {
36
52
  return value;
37
53
  }
@@ -43,12 +59,12 @@ var parseFromDefault = function parseFromDefault(defaultValue, value) {
43
59
  }
44
60
  return undefined;
45
61
  }
46
- if (typeof defaultValue === 'number') {
62
+ if (resolvedType === 'number') {
47
63
  var parsed = typeof value === 'number' ? value : typeof value === 'string' ? Number(value) : NaN;
48
64
  return Number.isFinite(parsed) ? parsed : undefined;
49
65
  }
50
66
 
51
- // String-like values (including keys whose default is undefined, e.g. url/width)
67
+ // String-like values
52
68
  return typeof value === 'string' ? value : undefined;
53
69
  };
54
70
  var serializeParameterValue = function serializeParameterValue(key, value) {
@@ -59,7 +75,7 @@ var serializeParameterValue = function serializeParameterValue(key, value) {
59
75
  return value === undefined ? undefined : String(value);
60
76
  };
61
77
  var deserializeParameterValue = function deserializeParameterValue(key, value) {
62
- var parsedValue = parseFromDefault(_constants.NATIVE_EMBED_PARAMETER_DEFAULTS[key], value);
78
+ var parsedValue = parseFromDefault(_constants.NATIVE_EMBED_PARAMETER_DEFAULTS[key], value, PARAMETER_TYPES[key]);
63
79
  var validator = PARAMETER_VALIDATORS[key];
64
80
  if (parsedValue === undefined) {
65
81
  return undefined;
@@ -0,0 +1 @@
1
+ export { EMBED_DEPTH_QUERY_PARAM, getCurrentEmbedDepth, MAX_EMBED_DEPTH } from './utils/constants';
@@ -1,3 +1,36 @@
1
+ // ─── Embed depth constants ──────────────────────────────────────────────────
2
+
3
+ /**
4
+ * URL query-parameter key used to track the current embedding depth.
5
+ * Each nested native-embed iframe increments this value by 1.
6
+ */
7
+ export const EMBED_DEPTH_QUERY_PARAM = 'nativeEmbedDepth';
8
+
9
+ /**
10
+ * Maximum allowed embedding depth. When `getCurrentEmbedDepth()` returns a
11
+ * value **≥** this limit the extension renderer should display a fallback
12
+ * instead of another iframe to prevent infinite recursion.
13
+ */
14
+ export const MAX_EMBED_DEPTH = 2;
15
+
16
+ /**
17
+ * Read the current embedding depth from `window.location.search`.
18
+ *
19
+ * Returns `0` when the parameter is absent or cannot be parsed as a
20
+ * non-negative integer, which is the expected case for top-level pages.
21
+ */
22
+ export const getCurrentEmbedDepth = () => {
23
+ if (typeof window === 'undefined') {
24
+ return 0;
25
+ }
26
+ const raw = new URLSearchParams(window.location.search).get(EMBED_DEPTH_QUERY_PARAM);
27
+ if (raw === null) {
28
+ return 0;
29
+ }
30
+ const parsed = Number(raw);
31
+ return Number.isFinite(parsed) && parsed >= 0 ? Math.floor(parsed) : 0;
32
+ };
33
+
1
34
  // Alignment constants
2
35
  export const ALIGNMENT_VALUES = ['left', 'center', 'right', 'wrap-left', 'wrap-right'];
3
36
  export const DEFAULT_ALIGNMENT = 'center';
@@ -7,6 +40,7 @@ export const NATIVE_EMBED_PARAMETER_DEFAULTS = {
7
40
  alignment: DEFAULT_ALIGNMENT,
8
41
  displayText: undefined,
9
42
  height: 600,
43
+ aspectRatio: 1,
10
44
  width: undefined
11
45
  };
12
46
 
@@ -26,6 +60,8 @@ export const BUILTIN_TOOLBAR_KEYS = {
26
60
  BORDER: 'border',
27
61
  ALIGNMENT: 'alignment',
28
62
  OPEN_IN_NEW_WINDOW: 'openInNewWindow',
63
+ /** Opens the embed's fullscreen preview dialog. */
64
+ EXPAND: 'expand',
29
65
  EDIT_URL: 'editUrl',
30
66
  ALWAYS_SHOW_TITLE: 'alwaysShowTitle',
31
67
  SET_EMBED_TYPE: 'setEmbedType',
@@ -41,4 +77,4 @@ export const BUILTIN_TOOLBAR_KEYS = {
41
77
  DELETE: 'delete',
42
78
  SEPARATOR: 'separator'
43
79
  };
44
- export const EDITOR_TOOLBAR_HANDLER_KEYS = ['onAlignmentClick', 'onAppearanceClick', 'onAskRovoClick', 'onSummariseClick', 'onChangeBorderClick', 'onCopyClick', 'onCopyLinkClick', 'onDeleteClick', 'onEditClick', 'onEditUrlClick', 'onOpenInNewWindowClick', 'onRefreshClick', 'onSetEmbedTypeClick', 'onShowTitleClick'];
80
+ export const EDITOR_TOOLBAR_HANDLER_KEYS = ['onAlignmentClick', 'onAppearanceClick', 'onAskRovoClick', 'onSummariseClick', 'onChangeBorderClick', 'onCopyClick', 'onCopyLinkClick', 'onDeleteClick', 'onEditClick', 'onEditUrlClick', 'onExpandClick', 'onOpenInNewWindowClick', 'onRefreshClick', 'onSetEmbedTypeClick', 'onShowTitleClick'];
@@ -14,8 +14,24 @@ const unwrapMacroParamValue = macroParamValue => {
14
14
  const PARAMETER_VALIDATORS = {
15
15
  alignment: value => ALIGNMENT_VALUES.includes(value)
16
16
  };
17
- const parseFromDefault = (defaultValue, value) => {
18
- if (typeof defaultValue === 'boolean') {
17
+
18
+ /**
19
+ * Explicitly declares the intended primitive type for each parameter key.
20
+ * This is necessary for keys whose default value is `undefined` (e.g. `url`, `width`),
21
+ * because `typeof undefined === 'undefined'` gives no type information for deserialization.
22
+ */
23
+ const PARAMETER_TYPES = {
24
+ alignment: 'string',
25
+ alwaysShowTitle: 'boolean',
26
+ aspectRatio: 'number',
27
+ displayText: 'string',
28
+ height: 'number',
29
+ url: 'string',
30
+ width: 'number'
31
+ };
32
+ const parseFromDefault = (defaultValue, value, explicitType) => {
33
+ const resolvedType = explicitType !== null && explicitType !== void 0 ? explicitType : typeof defaultValue;
34
+ if (resolvedType === 'boolean') {
19
35
  if (typeof value === 'boolean') {
20
36
  return value;
21
37
  }
@@ -27,12 +43,12 @@ const parseFromDefault = (defaultValue, value) => {
27
43
  }
28
44
  return undefined;
29
45
  }
30
- if (typeof defaultValue === 'number') {
46
+ if (resolvedType === 'number') {
31
47
  const parsed = typeof value === 'number' ? value : typeof value === 'string' ? Number(value) : NaN;
32
48
  return Number.isFinite(parsed) ? parsed : undefined;
33
49
  }
34
50
 
35
- // String-like values (including keys whose default is undefined, e.g. url/width)
51
+ // String-like values
36
52
  return typeof value === 'string' ? value : undefined;
37
53
  };
38
54
  const serializeParameterValue = (key, value) => {
@@ -43,7 +59,7 @@ const serializeParameterValue = (key, value) => {
43
59
  return value === undefined ? undefined : String(value);
44
60
  };
45
61
  const deserializeParameterValue = (key, value) => {
46
- const parsedValue = parseFromDefault(NATIVE_EMBED_PARAMETER_DEFAULTS[key], value);
62
+ const parsedValue = parseFromDefault(NATIVE_EMBED_PARAMETER_DEFAULTS[key], value, PARAMETER_TYPES[key]);
47
63
  const validator = PARAMETER_VALIDATORS[key];
48
64
  if (parsedValue === undefined) {
49
65
  return undefined;
@@ -0,0 +1 @@
1
+ export { EMBED_DEPTH_QUERY_PARAM, getCurrentEmbedDepth, MAX_EMBED_DEPTH } from './utils/constants';
@@ -1,3 +1,36 @@
1
+ // ─── Embed depth constants ──────────────────────────────────────────────────
2
+
3
+ /**
4
+ * URL query-parameter key used to track the current embedding depth.
5
+ * Each nested native-embed iframe increments this value by 1.
6
+ */
7
+ export var EMBED_DEPTH_QUERY_PARAM = 'nativeEmbedDepth';
8
+
9
+ /**
10
+ * Maximum allowed embedding depth. When `getCurrentEmbedDepth()` returns a
11
+ * value **≥** this limit the extension renderer should display a fallback
12
+ * instead of another iframe to prevent infinite recursion.
13
+ */
14
+ export var MAX_EMBED_DEPTH = 2;
15
+
16
+ /**
17
+ * Read the current embedding depth from `window.location.search`.
18
+ *
19
+ * Returns `0` when the parameter is absent or cannot be parsed as a
20
+ * non-negative integer, which is the expected case for top-level pages.
21
+ */
22
+ export var getCurrentEmbedDepth = function getCurrentEmbedDepth() {
23
+ if (typeof window === 'undefined') {
24
+ return 0;
25
+ }
26
+ var raw = new URLSearchParams(window.location.search).get(EMBED_DEPTH_QUERY_PARAM);
27
+ if (raw === null) {
28
+ return 0;
29
+ }
30
+ var parsed = Number(raw);
31
+ return Number.isFinite(parsed) && parsed >= 0 ? Math.floor(parsed) : 0;
32
+ };
33
+
1
34
  // Alignment constants
2
35
  export var ALIGNMENT_VALUES = ['left', 'center', 'right', 'wrap-left', 'wrap-right'];
3
36
  export var DEFAULT_ALIGNMENT = 'center';
@@ -7,6 +40,7 @@ export var NATIVE_EMBED_PARAMETER_DEFAULTS = {
7
40
  alignment: DEFAULT_ALIGNMENT,
8
41
  displayText: undefined,
9
42
  height: 600,
43
+ aspectRatio: 1,
10
44
  width: undefined
11
45
  };
12
46
 
@@ -26,6 +60,8 @@ export var BUILTIN_TOOLBAR_KEYS = {
26
60
  BORDER: 'border',
27
61
  ALIGNMENT: 'alignment',
28
62
  OPEN_IN_NEW_WINDOW: 'openInNewWindow',
63
+ /** Opens the embed's fullscreen preview dialog. */
64
+ EXPAND: 'expand',
29
65
  EDIT_URL: 'editUrl',
30
66
  ALWAYS_SHOW_TITLE: 'alwaysShowTitle',
31
67
  SET_EMBED_TYPE: 'setEmbedType',
@@ -41,4 +77,4 @@ export var BUILTIN_TOOLBAR_KEYS = {
41
77
  DELETE: 'delete',
42
78
  SEPARATOR: 'separator'
43
79
  };
44
- export var EDITOR_TOOLBAR_HANDLER_KEYS = ['onAlignmentClick', 'onAppearanceClick', 'onAskRovoClick', 'onSummariseClick', 'onChangeBorderClick', 'onCopyClick', 'onCopyLinkClick', 'onDeleteClick', 'onEditClick', 'onEditUrlClick', 'onOpenInNewWindowClick', 'onRefreshClick', 'onSetEmbedTypeClick', 'onShowTitleClick'];
80
+ export var EDITOR_TOOLBAR_HANDLER_KEYS = ['onAlignmentClick', 'onAppearanceClick', 'onAskRovoClick', 'onSummariseClick', 'onChangeBorderClick', 'onCopyClick', 'onCopyLinkClick', 'onDeleteClick', 'onEditClick', 'onEditUrlClick', 'onExpandClick', 'onOpenInNewWindowClick', 'onRefreshClick', 'onSetEmbedTypeClick', 'onShowTitleClick'];
@@ -21,8 +21,24 @@ var PARAMETER_VALIDATORS = {
21
21
  return ALIGNMENT_VALUES.includes(value);
22
22
  }
23
23
  };
24
- var parseFromDefault = function parseFromDefault(defaultValue, value) {
25
- if (typeof defaultValue === 'boolean') {
24
+
25
+ /**
26
+ * Explicitly declares the intended primitive type for each parameter key.
27
+ * This is necessary for keys whose default value is `undefined` (e.g. `url`, `width`),
28
+ * because `typeof undefined === 'undefined'` gives no type information for deserialization.
29
+ */
30
+ var PARAMETER_TYPES = {
31
+ alignment: 'string',
32
+ alwaysShowTitle: 'boolean',
33
+ aspectRatio: 'number',
34
+ displayText: 'string',
35
+ height: 'number',
36
+ url: 'string',
37
+ width: 'number'
38
+ };
39
+ var parseFromDefault = function parseFromDefault(defaultValue, value, explicitType) {
40
+ var resolvedType = explicitType !== null && explicitType !== void 0 ? explicitType : _typeof(defaultValue);
41
+ if (resolvedType === 'boolean') {
26
42
  if (typeof value === 'boolean') {
27
43
  return value;
28
44
  }
@@ -34,12 +50,12 @@ var parseFromDefault = function parseFromDefault(defaultValue, value) {
34
50
  }
35
51
  return undefined;
36
52
  }
37
- if (typeof defaultValue === 'number') {
53
+ if (resolvedType === 'number') {
38
54
  var parsed = typeof value === 'number' ? value : typeof value === 'string' ? Number(value) : NaN;
39
55
  return Number.isFinite(parsed) ? parsed : undefined;
40
56
  }
41
57
 
42
- // String-like values (including keys whose default is undefined, e.g. url/width)
58
+ // String-like values
43
59
  return typeof value === 'string' ? value : undefined;
44
60
  };
45
61
  var serializeParameterValue = function serializeParameterValue(key, value) {
@@ -50,7 +66,7 @@ var serializeParameterValue = function serializeParameterValue(key, value) {
50
66
  return value === undefined ? undefined : String(value);
51
67
  };
52
68
  var deserializeParameterValue = function deserializeParameterValue(key, value) {
53
- var parsedValue = parseFromDefault(NATIVE_EMBED_PARAMETER_DEFAULTS[key], value);
69
+ var parsedValue = parseFromDefault(NATIVE_EMBED_PARAMETER_DEFAULTS[key], value, PARAMETER_TYPES[key]);
54
70
  var validator = PARAMETER_VALIDATORS[key];
55
71
  if (parsedValue === undefined) {
56
72
  return undefined;
@@ -0,0 +1 @@
1
+ export { EMBED_DEPTH_QUERY_PARAM, getCurrentEmbedDepth, MAX_EMBED_DEPTH } from './utils/constants';
@@ -1,4 +1,22 @@
1
1
  import type { NativeEmbedParameterValues } from './types';
2
+ /**
3
+ * URL query-parameter key used to track the current embedding depth.
4
+ * Each nested native-embed iframe increments this value by 1.
5
+ */
6
+ export declare const EMBED_DEPTH_QUERY_PARAM: "nativeEmbedDepth";
7
+ /**
8
+ * Maximum allowed embedding depth. When `getCurrentEmbedDepth()` returns a
9
+ * value **≥** this limit the extension renderer should display a fallback
10
+ * instead of another iframe to prevent infinite recursion.
11
+ */
12
+ export declare const MAX_EMBED_DEPTH = 2;
13
+ /**
14
+ * Read the current embedding depth from `window.location.search`.
15
+ *
16
+ * Returns `0` when the parameter is absent or cannot be parsed as a
17
+ * non-negative integer, which is the expected case for top-level pages.
18
+ */
19
+ export declare const getCurrentEmbedDepth: () => number;
2
20
  export declare const ALIGNMENT_VALUES: readonly ["left", "center", "right", "wrap-left", "wrap-right"];
3
21
  export declare const DEFAULT_ALIGNMENT: "center";
4
22
  export declare const NATIVE_EMBED_PARAMETER_DEFAULTS: NativeEmbedParameterValues;
@@ -18,6 +36,8 @@ export declare const BUILTIN_TOOLBAR_KEYS: {
18
36
  readonly BORDER: "border";
19
37
  readonly ALIGNMENT: "alignment";
20
38
  readonly OPEN_IN_NEW_WINDOW: "openInNewWindow";
39
+ /** Opens the embed's fullscreen preview dialog. */
40
+ readonly EXPAND: "expand";
21
41
  readonly EDIT_URL: "editUrl";
22
42
  readonly ALWAYS_SHOW_TITLE: "alwaysShowTitle";
23
43
  readonly SET_EMBED_TYPE: "setEmbedType";
@@ -33,4 +53,4 @@ export declare const BUILTIN_TOOLBAR_KEYS: {
33
53
  readonly DELETE: "delete";
34
54
  readonly SEPARATOR: "separator";
35
55
  };
36
- export declare const EDITOR_TOOLBAR_HANDLER_KEYS: readonly ["onAlignmentClick", "onAppearanceClick", "onAskRovoClick", "onSummariseClick", "onChangeBorderClick", "onCopyClick", "onCopyLinkClick", "onDeleteClick", "onEditClick", "onEditUrlClick", "onOpenInNewWindowClick", "onRefreshClick", "onSetEmbedTypeClick", "onShowTitleClick"];
56
+ export declare const EDITOR_TOOLBAR_HANDLER_KEYS: readonly ["onAlignmentClick", "onAppearanceClick", "onAskRovoClick", "onSummariseClick", "onChangeBorderClick", "onCopyClick", "onCopyLinkClick", "onDeleteClick", "onEditClick", "onEditUrlClick", "onExpandClick", "onOpenInNewWindowClick", "onRefreshClick", "onSetEmbedTypeClick", "onShowTitleClick"];
@@ -7,6 +7,7 @@ export type NativeEmbedAppearance = 'url' | 'inline' | 'block' | 'embed';
7
7
  export type NativeEmbedParameterValues = {
8
8
  alignment: AlignmentValue;
9
9
  alwaysShowTitle: boolean;
10
+ aspectRatio: number;
10
11
  displayText?: string;
11
12
  height: number;
12
13
  url?: string;
@@ -19,6 +20,7 @@ export type NativeEmbedParameters = {
19
20
  macroParams?: {
20
21
  alignment?: NativeEmbedParameterValue;
21
22
  alwaysShowTitle?: NativeEmbedParameterValue;
23
+ aspectRatio?: NativeEmbedParameterValue;
22
24
  displayText?: NativeEmbedParameterValue;
23
25
  height?: NativeEmbedParameterValue;
24
26
  url?: NativeEmbedParameterValue;
@@ -93,6 +95,7 @@ export type EditorToolbarHandlers = Partial<{
93
95
  onDeleteClick: EditorToolbarHandler;
94
96
  onEditClick: EditorToolbarHandler;
95
97
  onEditUrlClick: EditorToolbarHandler;
98
+ onExpandClick: EditorToolbarHandler;
96
99
  onOpenInNewWindowClick: EditorToolbarHandler;
97
100
  onRefreshClick: EditorToolbarHandler;
98
101
  onSetEmbedTypeClick: EditorToolbarHandler;
@@ -0,0 +1 @@
1
+ export { EMBED_DEPTH_QUERY_PARAM, getCurrentEmbedDepth, MAX_EMBED_DEPTH } from './utils/constants';
@@ -1,4 +1,22 @@
1
1
  import type { NativeEmbedParameterValues } from './types';
2
+ /**
3
+ * URL query-parameter key used to track the current embedding depth.
4
+ * Each nested native-embed iframe increments this value by 1.
5
+ */
6
+ export declare const EMBED_DEPTH_QUERY_PARAM: "nativeEmbedDepth";
7
+ /**
8
+ * Maximum allowed embedding depth. When `getCurrentEmbedDepth()` returns a
9
+ * value **≥** this limit the extension renderer should display a fallback
10
+ * instead of another iframe to prevent infinite recursion.
11
+ */
12
+ export declare const MAX_EMBED_DEPTH = 2;
13
+ /**
14
+ * Read the current embedding depth from `window.location.search`.
15
+ *
16
+ * Returns `0` when the parameter is absent or cannot be parsed as a
17
+ * non-negative integer, which is the expected case for top-level pages.
18
+ */
19
+ export declare const getCurrentEmbedDepth: () => number;
2
20
  export declare const ALIGNMENT_VALUES: readonly [
3
21
  "left",
4
22
  "center",
@@ -24,6 +42,8 @@ export declare const BUILTIN_TOOLBAR_KEYS: {
24
42
  readonly BORDER: "border";
25
43
  readonly ALIGNMENT: "alignment";
26
44
  readonly OPEN_IN_NEW_WINDOW: "openInNewWindow";
45
+ /** Opens the embed's fullscreen preview dialog. */
46
+ readonly EXPAND: "expand";
27
47
  readonly EDIT_URL: "editUrl";
28
48
  readonly ALWAYS_SHOW_TITLE: "alwaysShowTitle";
29
49
  readonly SET_EMBED_TYPE: "setEmbedType";
@@ -50,6 +70,7 @@ export declare const EDITOR_TOOLBAR_HANDLER_KEYS: readonly [
50
70
  "onDeleteClick",
51
71
  "onEditClick",
52
72
  "onEditUrlClick",
73
+ "onExpandClick",
53
74
  "onOpenInNewWindowClick",
54
75
  "onRefreshClick",
55
76
  "onSetEmbedTypeClick",
@@ -7,6 +7,7 @@ export type NativeEmbedAppearance = 'url' | 'inline' | 'block' | 'embed';
7
7
  export type NativeEmbedParameterValues = {
8
8
  alignment: AlignmentValue;
9
9
  alwaysShowTitle: boolean;
10
+ aspectRatio: number;
10
11
  displayText?: string;
11
12
  height: number;
12
13
  url?: string;
@@ -19,6 +20,7 @@ export type NativeEmbedParameters = {
19
20
  macroParams?: {
20
21
  alignment?: NativeEmbedParameterValue;
21
22
  alwaysShowTitle?: NativeEmbedParameterValue;
23
+ aspectRatio?: NativeEmbedParameterValue;
22
24
  displayText?: NativeEmbedParameterValue;
23
25
  height?: NativeEmbedParameterValue;
24
26
  url?: NativeEmbedParameterValue;
@@ -94,6 +96,7 @@ export type EditorToolbarHandlers = Partial<{
94
96
  onDeleteClick: EditorToolbarHandler;
95
97
  onEditClick: EditorToolbarHandler;
96
98
  onEditUrlClick: EditorToolbarHandler;
99
+ onExpandClick: EditorToolbarHandler;
97
100
  onOpenInNewWindowClick: EditorToolbarHandler;
98
101
  onRefreshClick: EditorToolbarHandler;
99
102
  onSetEmbedTypeClick: EditorToolbarHandler;
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@atlaskit/native-embeds-common/embed-depth",
3
+ "main": "../dist/cjs/embed-depth.js",
4
+ "module": "../dist/esm/embed-depth.js",
5
+ "module:es2019": "../dist/es2019/embed-depth.js",
6
+ "sideEffects": [
7
+ "*.compiled.css"
8
+ ],
9
+ "types": "../dist/types/embed-depth.d.ts",
10
+ "typesVersions": {
11
+ ">=4.5 <5.9": {
12
+ "*": [
13
+ "../dist/types-ts4.5/embed-depth.d.ts"
14
+ ]
15
+ }
16
+ }
17
+ }
package/package.json CHANGED
@@ -25,11 +25,11 @@
25
25
  "atlaskit:src": "src/index.ts",
26
26
  "dependencies": {
27
27
  "@atlaskit/button": "^23.11.0",
28
- "@atlaskit/editor-common": "^114.0.0",
28
+ "@atlaskit/editor-common": "^114.13.0",
29
29
  "@atlaskit/editor-plugin-local-id": "^8.0.0",
30
30
  "@atlaskit/editor-prosemirror": "^7.3.0",
31
31
  "@atlaskit/heading": "^5.4.0",
32
- "@atlaskit/icon": "^34.2.0",
32
+ "@atlaskit/icon": "^34.3.0",
33
33
  "@atlaskit/primitives": "^19.0.0",
34
34
  "@atlaskit/tokens": "^13.0.0",
35
35
  "@babel/runtime": "^7.0.0",
@@ -86,7 +86,7 @@
86
86
  }
87
87
  },
88
88
  "name": "@atlaskit/native-embeds-common",
89
- "version": "1.0.2",
89
+ "version": "1.1.1",
90
90
  "description": "A shared package for native embeds to be used across experiences and plugin",
91
91
  "author": "Atlassian Pty Ltd",
92
92
  "license": "Apache-2.0",