@atlaskit/native-embeds-common 0.0.0 → 0.1.0

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 +1 @@
1
- # @atlaskit/native-embeds-common
1
+ # @atlaskit/native-embeds-common
package/dist/cjs/index.js CHANGED
@@ -9,10 +9,29 @@ Object.defineProperty(exports, "ALIGNMENT_VALUES", {
9
9
  return _constants.ALIGNMENT_VALUES;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "BUILTIN_TOOLBAR_KEYS", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _constants.BUILTIN_TOOLBAR_KEYS;
16
+ }
17
+ });
12
18
  Object.defineProperty(exports, "DEFAULT_ALIGNMENT", {
13
19
  enumerable: true,
14
20
  get: function get() {
15
21
  return _constants.DEFAULT_ALIGNMENT;
16
22
  }
17
23
  });
18
- var _constants = require("./constants");
24
+ Object.defineProperty(exports, "createEditorToolbarActions", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _utils.createEditorToolbarActions;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "updateParameters", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _utils.updateParameters;
34
+ }
35
+ });
36
+ var _constants = require("./utils/constants");
37
+ var _utils = require("./utils/utils");
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DEFAULT_ALIGNMENT = exports.BUILTIN_TOOLBAR_KEYS = exports.ALIGNMENT_VALUES = void 0;
7
+ // Alignment constants
8
+ var ALIGNMENT_VALUES = exports.ALIGNMENT_VALUES = ['left', 'center', 'right', 'wrap-left', 'wrap-right'];
9
+ var DEFAULT_ALIGNMENT = exports.DEFAULT_ALIGNMENT = 'center';
10
+
11
+ /**
12
+ * Built-in keys that can be referenced in the `items` and `moreItems` arrays.
13
+ *
14
+ * Toolbar keys: REFRESH, EMBED, BORDER, ALIGNMENT, OPEN_IN_NEW_WINDOW
15
+ * More Options dropdown keys: ALWAYS_SHOW_TITLE, SET_EMBED_TYPE, COPY_LINK, DELETE
16
+ * Shared: SEPARATOR (usable in both)
17
+ */
18
+ var BUILTIN_TOOLBAR_KEYS = exports.BUILTIN_TOOLBAR_KEYS = {
19
+ REFRESH: 'refresh',
20
+ EMBED: 'embed',
21
+ BORDER: 'border',
22
+ ALIGNMENT: 'alignment',
23
+ OPEN_IN_NEW_WINDOW: 'openInNewWindow',
24
+ ALWAYS_SHOW_TITLE: 'alwaysShowTitle',
25
+ SET_EMBED_TYPE: 'setEmbedType',
26
+ COPY_LINK: 'copyLink',
27
+ DELETE: 'delete',
28
+ SEPARATOR: 'separator'
29
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createEditorToolbarActions = void 0;
8
+ exports.updateParameters = updateParameters;
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
+ /**
14
+ * Generic utility to update parameters on a native embed extension node.
15
+ * Preserves existing parameters and merges in the new ones.
16
+ */
17
+ function updateParameters(current, parameterUpdates) {
18
+ var existingParams = current.attrs && 'parameters' in current.attrs && (0, _typeof2.default)(current.attrs.parameters) === 'object' ? current.attrs.parameters : {};
19
+ return {
20
+ attrs: _objectSpread(_objectSpread({}, current.attrs), {}, {
21
+ parameters: _objectSpread(_objectSpread({}, existingParams), parameterUpdates)
22
+ })
23
+ };
24
+ }
25
+
26
+ /**
27
+ * Helper function to create a type-safe ManifestEditorToolbarActions config.
28
+ * Automatically infers custom action keys from the customActions object.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const config = createEditorToolbarActions({
33
+ * customActions: {
34
+ * myAction: { type: 'button', key: 'myAction', ... },
35
+ * },
36
+ * items: ['refresh', 'myAction', 'separator'], // 'myAction' is type-checked
37
+ * moreItems: ['copyLink', 'myAction', 'separator', 'delete'], // 'myAction' is type-checked
38
+ * });
39
+ * ```
40
+ */
41
+ var createEditorToolbarActions = exports.createEditorToolbarActions = function createEditorToolbarActions(config) {
42
+ return config;
43
+ };
@@ -1 +1,7 @@
1
- export { DEFAULT_ALIGNMENT, ALIGNMENT_VALUES } from './constants';
1
+ // Re-export constants
2
+ export { ALIGNMENT_VALUES, DEFAULT_ALIGNMENT, BUILTIN_TOOLBAR_KEYS } from './utils/constants';
3
+
4
+ // Re-export types
5
+
6
+ // Re-export utilities
7
+ export { updateParameters, createEditorToolbarActions } from './utils/utils';
@@ -0,0 +1,23 @@
1
+ // Alignment constants
2
+ export const ALIGNMENT_VALUES = ['left', 'center', 'right', 'wrap-left', 'wrap-right'];
3
+ export const DEFAULT_ALIGNMENT = 'center';
4
+
5
+ /**
6
+ * Built-in keys that can be referenced in the `items` and `moreItems` arrays.
7
+ *
8
+ * Toolbar keys: REFRESH, EMBED, BORDER, ALIGNMENT, OPEN_IN_NEW_WINDOW
9
+ * More Options dropdown keys: ALWAYS_SHOW_TITLE, SET_EMBED_TYPE, COPY_LINK, DELETE
10
+ * Shared: SEPARATOR (usable in both)
11
+ */
12
+ export const BUILTIN_TOOLBAR_KEYS = {
13
+ REFRESH: 'refresh',
14
+ EMBED: 'embed',
15
+ BORDER: 'border',
16
+ ALIGNMENT: 'alignment',
17
+ OPEN_IN_NEW_WINDOW: 'openInNewWindow',
18
+ ALWAYS_SHOW_TITLE: 'alwaysShowTitle',
19
+ SET_EMBED_TYPE: 'setEmbedType',
20
+ COPY_LINK: 'copyLink',
21
+ DELETE: 'delete',
22
+ SEPARATOR: 'separator'
23
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Generic utility to update parameters on a native embed extension node.
3
+ * Preserves existing parameters and merges in the new ones.
4
+ */
5
+ export function updateParameters(current, parameterUpdates) {
6
+ const existingParams = current.attrs && 'parameters' in current.attrs && typeof current.attrs.parameters === 'object' ? current.attrs.parameters : {};
7
+ return {
8
+ attrs: {
9
+ ...current.attrs,
10
+ parameters: {
11
+ ...existingParams,
12
+ ...parameterUpdates
13
+ }
14
+ }
15
+ };
16
+ }
17
+
18
+ /**
19
+ * Helper function to create a type-safe ManifestEditorToolbarActions config.
20
+ * Automatically infers custom action keys from the customActions object.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const config = createEditorToolbarActions({
25
+ * customActions: {
26
+ * myAction: { type: 'button', key: 'myAction', ... },
27
+ * },
28
+ * items: ['refresh', 'myAction', 'separator'], // 'myAction' is type-checked
29
+ * moreItems: ['copyLink', 'myAction', 'separator', 'delete'], // 'myAction' is type-checked
30
+ * });
31
+ * ```
32
+ */
33
+ export const createEditorToolbarActions = config => config;
package/dist/esm/index.js CHANGED
@@ -1 +1,7 @@
1
- export { DEFAULT_ALIGNMENT, ALIGNMENT_VALUES } from './constants';
1
+ // Re-export constants
2
+ export { ALIGNMENT_VALUES, DEFAULT_ALIGNMENT, BUILTIN_TOOLBAR_KEYS } from './utils/constants';
3
+
4
+ // Re-export types
5
+
6
+ // Re-export utilities
7
+ export { updateParameters, createEditorToolbarActions } from './utils/utils';
@@ -0,0 +1,23 @@
1
+ // Alignment constants
2
+ export var ALIGNMENT_VALUES = ['left', 'center', 'right', 'wrap-left', 'wrap-right'];
3
+ export var DEFAULT_ALIGNMENT = 'center';
4
+
5
+ /**
6
+ * Built-in keys that can be referenced in the `items` and `moreItems` arrays.
7
+ *
8
+ * Toolbar keys: REFRESH, EMBED, BORDER, ALIGNMENT, OPEN_IN_NEW_WINDOW
9
+ * More Options dropdown keys: ALWAYS_SHOW_TITLE, SET_EMBED_TYPE, COPY_LINK, DELETE
10
+ * Shared: SEPARATOR (usable in both)
11
+ */
12
+ export var BUILTIN_TOOLBAR_KEYS = {
13
+ REFRESH: 'refresh',
14
+ EMBED: 'embed',
15
+ BORDER: 'border',
16
+ ALIGNMENT: 'alignment',
17
+ OPEN_IN_NEW_WINDOW: 'openInNewWindow',
18
+ ALWAYS_SHOW_TITLE: 'alwaysShowTitle',
19
+ SET_EMBED_TYPE: 'setEmbedType',
20
+ COPY_LINK: 'copyLink',
21
+ DELETE: 'delete',
22
+ SEPARATOR: 'separator'
23
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _typeof from "@babel/runtime/helpers/typeof";
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ /**
6
+ * Generic utility to update parameters on a native embed extension node.
7
+ * Preserves existing parameters and merges in the new ones.
8
+ */
9
+ export function updateParameters(current, parameterUpdates) {
10
+ var existingParams = current.attrs && 'parameters' in current.attrs && _typeof(current.attrs.parameters) === 'object' ? current.attrs.parameters : {};
11
+ return {
12
+ attrs: _objectSpread(_objectSpread({}, current.attrs), {}, {
13
+ parameters: _objectSpread(_objectSpread({}, existingParams), parameterUpdates)
14
+ })
15
+ };
16
+ }
17
+
18
+ /**
19
+ * Helper function to create a type-safe ManifestEditorToolbarActions config.
20
+ * Automatically infers custom action keys from the customActions object.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const config = createEditorToolbarActions({
25
+ * customActions: {
26
+ * myAction: { type: 'button', key: 'myAction', ... },
27
+ * },
28
+ * items: ['refresh', 'myAction', 'separator'], // 'myAction' is type-checked
29
+ * moreItems: ['copyLink', 'myAction', 'separator', 'delete'], // 'myAction' is type-checked
30
+ * });
31
+ * ```
32
+ */
33
+ export var createEditorToolbarActions = function createEditorToolbarActions(config) {
34
+ return config;
35
+ };
@@ -1,2 +1,3 @@
1
- export { type AlignmentValue } from './types';
2
- export { DEFAULT_ALIGNMENT, ALIGNMENT_VALUES } from './constants';
1
+ export { ALIGNMENT_VALUES, DEFAULT_ALIGNMENT, BUILTIN_TOOLBAR_KEYS } from './utils/constants';
2
+ export type { AlignmentValue, EditorToolbarButtonAction, EditorToolbarAction, BuiltinToolbarKey, ManifestEditorToolbarActions, } from './utils/types';
3
+ export { updateParameters, createEditorToolbarActions } from './utils/utils';
@@ -0,0 +1,21 @@
1
+ export declare const ALIGNMENT_VALUES: readonly ["left", "center", "right", "wrap-left", "wrap-right"];
2
+ export declare const DEFAULT_ALIGNMENT: "center";
3
+ /**
4
+ * Built-in keys that can be referenced in the `items` and `moreItems` arrays.
5
+ *
6
+ * Toolbar keys: REFRESH, EMBED, BORDER, ALIGNMENT, OPEN_IN_NEW_WINDOW
7
+ * More Options dropdown keys: ALWAYS_SHOW_TITLE, SET_EMBED_TYPE, COPY_LINK, DELETE
8
+ * Shared: SEPARATOR (usable in both)
9
+ */
10
+ export declare const BUILTIN_TOOLBAR_KEYS: {
11
+ readonly REFRESH: "refresh";
12
+ readonly EMBED: "embed";
13
+ readonly BORDER: "border";
14
+ readonly ALIGNMENT: "alignment";
15
+ readonly OPEN_IN_NEW_WINDOW: "openInNewWindow";
16
+ readonly ALWAYS_SHOW_TITLE: "alwaysShowTitle";
17
+ readonly SET_EMBED_TYPE: "setEmbedType";
18
+ readonly COPY_LINK: "copyLink";
19
+ readonly DELETE: "delete";
20
+ readonly SEPARATOR: "separator";
21
+ };
@@ -0,0 +1,79 @@
1
+ import type { ComponentType } from 'react';
2
+ import type { NewCoreIconProps } from '@atlaskit/icon';
3
+ import type { ALIGNMENT_VALUES, BUILTIN_TOOLBAR_KEYS } from './constants';
4
+ export type AlignmentValue = (typeof ALIGNMENT_VALUES)[number];
5
+ /**
6
+ * A button action rendered in the editor floating toolbar.
7
+ */
8
+ export type EditorToolbarButtonAction = {
9
+ /**
10
+ * Whether this action is disabled.
11
+ * @default false
12
+ */
13
+ disabled?: boolean;
14
+ /**
15
+ * Handler key that maps to the actionHandlers config in the editor plugin.
16
+ * When clicked, the plugin looks up actionHandlers[handlerKey] and invokes it.
17
+ */
18
+ handlerKey: string;
19
+ /**
20
+ * Icon component to display.
21
+ */
22
+ icon: ComponentType<NewCoreIconProps>;
23
+ /**
24
+ * Unique key for this action, used for React keys and test IDs.
25
+ */
26
+ key: string;
27
+ /**
28
+ * Button label (used for tooltip and accessibility).
29
+ */
30
+ label: string;
31
+ /**
32
+ * Whether to show the label as text next to the icon.
33
+ * @default false
34
+ */
35
+ showTitle?: boolean;
36
+ type: 'button';
37
+ };
38
+ /**
39
+ * Union type for editor toolbar actions.
40
+ * Currently only supports buttons; dropdowns and separators can be added later.
41
+ */
42
+ export type EditorToolbarAction = EditorToolbarButtonAction;
43
+ export type BuiltinToolbarKey = (typeof BUILTIN_TOOLBAR_KEYS)[keyof typeof BUILTIN_TOOLBAR_KEYS];
44
+ /**
45
+ * Configuration for editor toolbar actions in the manifest.
46
+ *
47
+ * Use `customActions` map + `items` array to mix custom and built-in actions.
48
+ *
49
+ * @typeParam TCustomActions - The type of the customActions record. Keys are automatically
50
+ * inferred and used to type-check the `items` array.
51
+ */
52
+ export type ManifestEditorToolbarActions<TCustomActions extends Record<string, EditorToolbarAction> = Record<string, EditorToolbarAction>> = {
53
+ /**
54
+ * Custom action definitions, keyed by unique identifier.
55
+ * These can be referenced in the `items` array alongside built-in keys.
56
+ */
57
+ customActions?: TCustomActions;
58
+ /**
59
+ * Ordered array of keys specifying which toolbar items to show and in what order.
60
+ * The "More Options" dropdown is appended automatically based on `moreItems`.
61
+ *
62
+ * Can include:
63
+ * - Built-in keys: 'refresh', 'embed', 'border', 'alignment', 'openInNewWindow'
64
+ * - 'separator' for visual separators between groups
65
+ * - Custom keys defined in `customActions`
66
+ */
67
+ items?: (BuiltinToolbarKey | keyof TCustomActions)[];
68
+ /**
69
+ * Ordered array of keys specifying which items appear in the "More Options" dropdown.
70
+ * When provided with at least one item, a separator and the dropdown are automatically
71
+ * appended to the toolbar. When omitted, the default set of dropdown items is used.
72
+ *
73
+ * Can include:
74
+ * - Built-in keys: 'alwaysShowTitle', 'setEmbedType', 'copyLink', 'delete'
75
+ * - 'separator' for visual separators between groups
76
+ * - Custom keys defined in `customActions` (shared with the toolbar)
77
+ */
78
+ moreItems?: (BuiltinToolbarKey | keyof TCustomActions)[];
79
+ };
@@ -0,0 +1,30 @@
1
+ import type { ManifestEditorToolbarActions, EditorToolbarAction, BuiltinToolbarKey } from './types';
2
+ /**
3
+ * Generic utility to update parameters on a native embed extension node.
4
+ * Preserves existing parameters and merges in the new ones.
5
+ */
6
+ export declare function updateParameters(current: {
7
+ attrs?: Record<string, unknown>;
8
+ }, parameterUpdates: Record<string, unknown>): {
9
+ attrs: Record<string, unknown>;
10
+ };
11
+ /**
12
+ * Helper function to create a type-safe ManifestEditorToolbarActions config.
13
+ * Automatically infers custom action keys from the customActions object.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const config = createEditorToolbarActions({
18
+ * customActions: {
19
+ * myAction: { type: 'button', key: 'myAction', ... },
20
+ * },
21
+ * items: ['refresh', 'myAction', 'separator'], // 'myAction' is type-checked
22
+ * moreItems: ['copyLink', 'myAction', 'separator', 'delete'], // 'myAction' is type-checked
23
+ * });
24
+ * ```
25
+ */
26
+ export declare const createEditorToolbarActions: <const TCustomActions extends Record<string, EditorToolbarAction>>(config: {
27
+ customActions: TCustomActions;
28
+ items: (BuiltinToolbarKey | keyof TCustomActions)[];
29
+ moreItems?: (BuiltinToolbarKey | keyof TCustomActions)[];
30
+ }) => ManifestEditorToolbarActions<TCustomActions>;
@@ -1,2 +1,3 @@
1
- export { type AlignmentValue } from './types';
2
- export { DEFAULT_ALIGNMENT, ALIGNMENT_VALUES } from './constants';
1
+ export { ALIGNMENT_VALUES, DEFAULT_ALIGNMENT, BUILTIN_TOOLBAR_KEYS } from './utils/constants';
2
+ export type { AlignmentValue, EditorToolbarButtonAction, EditorToolbarAction, BuiltinToolbarKey, ManifestEditorToolbarActions, } from './utils/types';
3
+ export { updateParameters, createEditorToolbarActions } from './utils/utils';
@@ -0,0 +1,27 @@
1
+ export declare const ALIGNMENT_VALUES: readonly [
2
+ "left",
3
+ "center",
4
+ "right",
5
+ "wrap-left",
6
+ "wrap-right"
7
+ ];
8
+ export declare const DEFAULT_ALIGNMENT: "center";
9
+ /**
10
+ * Built-in keys that can be referenced in the `items` and `moreItems` arrays.
11
+ *
12
+ * Toolbar keys: REFRESH, EMBED, BORDER, ALIGNMENT, OPEN_IN_NEW_WINDOW
13
+ * More Options dropdown keys: ALWAYS_SHOW_TITLE, SET_EMBED_TYPE, COPY_LINK, DELETE
14
+ * Shared: SEPARATOR (usable in both)
15
+ */
16
+ export declare const BUILTIN_TOOLBAR_KEYS: {
17
+ readonly REFRESH: "refresh";
18
+ readonly EMBED: "embed";
19
+ readonly BORDER: "border";
20
+ readonly ALIGNMENT: "alignment";
21
+ readonly OPEN_IN_NEW_WINDOW: "openInNewWindow";
22
+ readonly ALWAYS_SHOW_TITLE: "alwaysShowTitle";
23
+ readonly SET_EMBED_TYPE: "setEmbedType";
24
+ readonly COPY_LINK: "copyLink";
25
+ readonly DELETE: "delete";
26
+ readonly SEPARATOR: "separator";
27
+ };
@@ -0,0 +1,79 @@
1
+ import type { ComponentType } from 'react';
2
+ import type { NewCoreIconProps } from '@atlaskit/icon';
3
+ import type { ALIGNMENT_VALUES, BUILTIN_TOOLBAR_KEYS } from './constants';
4
+ export type AlignmentValue = (typeof ALIGNMENT_VALUES)[number];
5
+ /**
6
+ * A button action rendered in the editor floating toolbar.
7
+ */
8
+ export type EditorToolbarButtonAction = {
9
+ /**
10
+ * Whether this action is disabled.
11
+ * @default false
12
+ */
13
+ disabled?: boolean;
14
+ /**
15
+ * Handler key that maps to the actionHandlers config in the editor plugin.
16
+ * When clicked, the plugin looks up actionHandlers[handlerKey] and invokes it.
17
+ */
18
+ handlerKey: string;
19
+ /**
20
+ * Icon component to display.
21
+ */
22
+ icon: ComponentType<NewCoreIconProps>;
23
+ /**
24
+ * Unique key for this action, used for React keys and test IDs.
25
+ */
26
+ key: string;
27
+ /**
28
+ * Button label (used for tooltip and accessibility).
29
+ */
30
+ label: string;
31
+ /**
32
+ * Whether to show the label as text next to the icon.
33
+ * @default false
34
+ */
35
+ showTitle?: boolean;
36
+ type: 'button';
37
+ };
38
+ /**
39
+ * Union type for editor toolbar actions.
40
+ * Currently only supports buttons; dropdowns and separators can be added later.
41
+ */
42
+ export type EditorToolbarAction = EditorToolbarButtonAction;
43
+ export type BuiltinToolbarKey = (typeof BUILTIN_TOOLBAR_KEYS)[keyof typeof BUILTIN_TOOLBAR_KEYS];
44
+ /**
45
+ * Configuration for editor toolbar actions in the manifest.
46
+ *
47
+ * Use `customActions` map + `items` array to mix custom and built-in actions.
48
+ *
49
+ * @typeParam TCustomActions - The type of the customActions record. Keys are automatically
50
+ * inferred and used to type-check the `items` array.
51
+ */
52
+ export type ManifestEditorToolbarActions<TCustomActions extends Record<string, EditorToolbarAction> = Record<string, EditorToolbarAction>> = {
53
+ /**
54
+ * Custom action definitions, keyed by unique identifier.
55
+ * These can be referenced in the `items` array alongside built-in keys.
56
+ */
57
+ customActions?: TCustomActions;
58
+ /**
59
+ * Ordered array of keys specifying which toolbar items to show and in what order.
60
+ * The "More Options" dropdown is appended automatically based on `moreItems`.
61
+ *
62
+ * Can include:
63
+ * - Built-in keys: 'refresh', 'embed', 'border', 'alignment', 'openInNewWindow'
64
+ * - 'separator' for visual separators between groups
65
+ * - Custom keys defined in `customActions`
66
+ */
67
+ items?: (BuiltinToolbarKey | keyof TCustomActions)[];
68
+ /**
69
+ * Ordered array of keys specifying which items appear in the "More Options" dropdown.
70
+ * When provided with at least one item, a separator and the dropdown are automatically
71
+ * appended to the toolbar. When omitted, the default set of dropdown items is used.
72
+ *
73
+ * Can include:
74
+ * - Built-in keys: 'alwaysShowTitle', 'setEmbedType', 'copyLink', 'delete'
75
+ * - 'separator' for visual separators between groups
76
+ * - Custom keys defined in `customActions` (shared with the toolbar)
77
+ */
78
+ moreItems?: (BuiltinToolbarKey | keyof TCustomActions)[];
79
+ };
@@ -0,0 +1,30 @@
1
+ import type { ManifestEditorToolbarActions, EditorToolbarAction, BuiltinToolbarKey } from './types';
2
+ /**
3
+ * Generic utility to update parameters on a native embed extension node.
4
+ * Preserves existing parameters and merges in the new ones.
5
+ */
6
+ export declare function updateParameters(current: {
7
+ attrs?: Record<string, unknown>;
8
+ }, parameterUpdates: Record<string, unknown>): {
9
+ attrs: Record<string, unknown>;
10
+ };
11
+ /**
12
+ * Helper function to create a type-safe ManifestEditorToolbarActions config.
13
+ * Automatically infers custom action keys from the customActions object.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const config = createEditorToolbarActions({
18
+ * customActions: {
19
+ * myAction: { type: 'button', key: 'myAction', ... },
20
+ * },
21
+ * items: ['refresh', 'myAction', 'separator'], // 'myAction' is type-checked
22
+ * moreItems: ['copyLink', 'myAction', 'separator', 'delete'], // 'myAction' is type-checked
23
+ * });
24
+ * ```
25
+ */
26
+ export declare const createEditorToolbarActions: <const TCustomActions extends Record<string, EditorToolbarAction>>(config: {
27
+ customActions: TCustomActions;
28
+ items: (BuiltinToolbarKey | keyof TCustomActions)[];
29
+ moreItems?: (BuiltinToolbarKey | keyof TCustomActions)[];
30
+ }) => ManifestEditorToolbarActions<TCustomActions>;
package/package.json CHANGED
@@ -24,6 +24,7 @@
24
24
  ],
25
25
  "atlaskit:src": "src/index.ts",
26
26
  "dependencies": {
27
+ "@atlaskit/icon": "^32.0.0",
27
28
  "@babel/runtime": "^7.0.0",
28
29
  "@compiled/react": "^0.18.6"
29
30
  },
@@ -76,7 +77,7 @@
76
77
  }
77
78
  },
78
79
  "name": "@atlaskit/native-embeds-common",
79
- "version": "0.0.0",
80
+ "version": "0.1.0",
80
81
  "description": "A shared package for native embeds to be used across experiences and plugin",
81
82
  "author": "Atlassian Pty Ltd",
82
83
  "license": "Apache-2.0",
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DEFAULT_ALIGNMENT = exports.ALIGNMENT_VALUES = void 0;
7
- var ALIGNMENT_VALUES = exports.ALIGNMENT_VALUES = ['left', 'center', 'right', 'wrap-left', 'wrap-right'];
8
-
9
- /** Alignment value for native embed extension parameters. Single source of truth. */
10
-
11
- /** Default alignment when not set in parameters. */
12
- var DEFAULT_ALIGNMENT = exports.DEFAULT_ALIGNMENT = 'center';
package/dist/cjs/types.js DELETED
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,6 +0,0 @@
1
- export const ALIGNMENT_VALUES = ['left', 'center', 'right', 'wrap-left', 'wrap-right'];
2
-
3
- /** Alignment value for native embed extension parameters. Single source of truth. */
4
-
5
- /** Default alignment when not set in parameters. */
6
- export const DEFAULT_ALIGNMENT = 'center';
File without changes
@@ -1,6 +0,0 @@
1
- export var ALIGNMENT_VALUES = ['left', 'center', 'right', 'wrap-left', 'wrap-right'];
2
-
3
- /** Alignment value for native embed extension parameters. Single source of truth. */
4
-
5
- /** Default alignment when not set in parameters. */
6
- export var DEFAULT_ALIGNMENT = 'center';
package/dist/esm/types.js DELETED
File without changes
@@ -1,5 +0,0 @@
1
- export declare const ALIGNMENT_VALUES: readonly ["left", "center", "right", "wrap-left", "wrap-right"];
2
- /** Alignment value for native embed extension parameters. Single source of truth. */
3
- export type AlignmentValue = (typeof ALIGNMENT_VALUES)[number];
4
- /** Default alignment when not set in parameters. */
5
- export declare const DEFAULT_ALIGNMENT: AlignmentValue;
@@ -1 +0,0 @@
1
- export type { AlignmentValue } from './constants';
@@ -1,11 +0,0 @@
1
- export declare const ALIGNMENT_VALUES: readonly [
2
- "left",
3
- "center",
4
- "right",
5
- "wrap-left",
6
- "wrap-right"
7
- ];
8
- /** Alignment value for native embed extension parameters. Single source of truth. */
9
- export type AlignmentValue = (typeof ALIGNMENT_VALUES)[number];
10
- /** Default alignment when not set in parameters. */
11
- export declare const DEFAULT_ALIGNMENT: AlignmentValue;
@@ -1 +0,0 @@
1
- export type { AlignmentValue } from './constants';