@atlaskit/native-embeds-common 0.1.1 → 0.2.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 +18 -0
- package/dist/cjs/utils/constants.js +11 -2
- package/dist/cjs/utils/plugin-actions/types.js +5 -0
- package/dist/es2019/index.js +2 -0
- package/dist/es2019/utils/constants.js +11 -2
- package/dist/es2019/utils/plugin-actions/types.js +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/utils/constants.js +11 -2
- package/dist/esm/utils/plugin-actions/types.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/utils/constants.d.ts +10 -2
- package/dist/types/utils/plugin-actions/types.d.ts +35 -0
- package/dist/types/utils/types.d.ts +11 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/utils/constants.d.ts +12 -3
- package/dist/types-ts4.5/utils/plugin-actions/types.d.ts +35 -0
- package/dist/types-ts4.5/utils/types.d.ts +11 -0
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/native-embeds-common
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`6c3e67fec342f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6c3e67fec342f) -
|
|
8
|
+
Add BUILTIN_TOOLBAR_KEYS.COPY for copying native-embed nodes. COPY_LINK is now a deprecated alias
|
|
9
|
+
for COPY. Add onCopyClick handler alongside deprecated onCopyLinkClick alias.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 0.1.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 0.1.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -11,6 +11,7 @@ var NATIVE_EMBED_PARAMETER_DEFAULTS = exports.NATIVE_EMBED_PARAMETER_DEFAULTS =
|
|
|
11
11
|
url: undefined,
|
|
12
12
|
alwaysShowTitle: false,
|
|
13
13
|
alignment: DEFAULT_ALIGNMENT,
|
|
14
|
+
displayText: undefined,
|
|
14
15
|
height: 600,
|
|
15
16
|
width: undefined
|
|
16
17
|
};
|
|
@@ -19,7 +20,7 @@ var NATIVE_EMBED_PARAMETER_DEFAULTS = exports.NATIVE_EMBED_PARAMETER_DEFAULTS =
|
|
|
19
20
|
* Built-in keys that can be referenced in the `items` and `moreItems` arrays.
|
|
20
21
|
*
|
|
21
22
|
* Toolbar keys: ASK_ROVO, REFRESH, EDIT, EMBED, BORDER, ALIGNMENT, OPEN_IN_NEW_WINDOW
|
|
22
|
-
* More Options dropdown keys: ALWAYS_SHOW_TITLE, SET_EMBED_TYPE, COPY_LINK, DELETE
|
|
23
|
+
* More Options dropdown keys: ALWAYS_SHOW_TITLE, SET_EMBED_TYPE, COPY, COPY_LINK (deprecated), DELETE
|
|
23
24
|
* Shared: SEPARATOR (usable in both)
|
|
24
25
|
*/
|
|
25
26
|
var BUILTIN_TOOLBAR_KEYS = exports.BUILTIN_TOOLBAR_KEYS = {
|
|
@@ -33,8 +34,16 @@ var BUILTIN_TOOLBAR_KEYS = exports.BUILTIN_TOOLBAR_KEYS = {
|
|
|
33
34
|
EDIT_URL: 'editUrl',
|
|
34
35
|
ALWAYS_SHOW_TITLE: 'alwaysShowTitle',
|
|
35
36
|
SET_EMBED_TYPE: 'setEmbedType',
|
|
37
|
+
/**
|
|
38
|
+
* Copies the native-embed node to the clipboard.
|
|
39
|
+
*/
|
|
40
|
+
COPY: 'copy',
|
|
41
|
+
/**
|
|
42
|
+
* @private
|
|
43
|
+
* @deprecated Use `COPY` instead. `COPY_LINK` is a deprecated alias for `COPY` and will be removed in a future release.
|
|
44
|
+
*/
|
|
36
45
|
COPY_LINK: 'copyLink',
|
|
37
46
|
DELETE: 'delete',
|
|
38
47
|
SEPARATOR: 'separator'
|
|
39
48
|
};
|
|
40
|
-
var EDITOR_TOOLBAR_HANDLER_KEYS = exports.EDITOR_TOOLBAR_HANDLER_KEYS = ['onAlignmentClick', 'onAppearanceClick', 'onAskRovoClick', '
|
|
49
|
+
var EDITOR_TOOLBAR_HANDLER_KEYS = exports.EDITOR_TOOLBAR_HANDLER_KEYS = ['onAlignmentClick', 'onAppearanceClick', 'onAskRovoClick', 'onChangeBorderClick', 'onCopyClick', 'onCopyLinkClick', 'onDeleteClick', 'onEditClick', 'onEditUrlClick', 'onOpenInNewWindowClick', 'onRefreshClick', 'onSetEmbedTypeClick', 'onShowTitleClick'];
|
package/dist/es2019/index.js
CHANGED
|
@@ -3,5 +3,7 @@ export { ALIGNMENT_VALUES, DEFAULT_ALIGNMENT, BUILTIN_TOOLBAR_KEYS, EDITOR_TOOLB
|
|
|
3
3
|
|
|
4
4
|
// Re-export types
|
|
5
5
|
|
|
6
|
+
// Plugin actions types
|
|
7
|
+
|
|
6
8
|
// Re-export utilities
|
|
7
9
|
export { createEditorToolbarActions, getParameter, getParameters, setParameter, setParameters } from './utils/utils';
|
|
@@ -5,6 +5,7 @@ export const NATIVE_EMBED_PARAMETER_DEFAULTS = {
|
|
|
5
5
|
url: undefined,
|
|
6
6
|
alwaysShowTitle: false,
|
|
7
7
|
alignment: DEFAULT_ALIGNMENT,
|
|
8
|
+
displayText: undefined,
|
|
8
9
|
height: 600,
|
|
9
10
|
width: undefined
|
|
10
11
|
};
|
|
@@ -13,7 +14,7 @@ export const NATIVE_EMBED_PARAMETER_DEFAULTS = {
|
|
|
13
14
|
* Built-in keys that can be referenced in the `items` and `moreItems` arrays.
|
|
14
15
|
*
|
|
15
16
|
* Toolbar keys: ASK_ROVO, REFRESH, EDIT, EMBED, BORDER, ALIGNMENT, OPEN_IN_NEW_WINDOW
|
|
16
|
-
* More Options dropdown keys: ALWAYS_SHOW_TITLE, SET_EMBED_TYPE, COPY_LINK, DELETE
|
|
17
|
+
* More Options dropdown keys: ALWAYS_SHOW_TITLE, SET_EMBED_TYPE, COPY, COPY_LINK (deprecated), DELETE
|
|
17
18
|
* Shared: SEPARATOR (usable in both)
|
|
18
19
|
*/
|
|
19
20
|
export const BUILTIN_TOOLBAR_KEYS = {
|
|
@@ -27,8 +28,16 @@ export const BUILTIN_TOOLBAR_KEYS = {
|
|
|
27
28
|
EDIT_URL: 'editUrl',
|
|
28
29
|
ALWAYS_SHOW_TITLE: 'alwaysShowTitle',
|
|
29
30
|
SET_EMBED_TYPE: 'setEmbedType',
|
|
31
|
+
/**
|
|
32
|
+
* Copies the native-embed node to the clipboard.
|
|
33
|
+
*/
|
|
34
|
+
COPY: 'copy',
|
|
35
|
+
/**
|
|
36
|
+
* @private
|
|
37
|
+
* @deprecated Use `COPY` instead. `COPY_LINK` is a deprecated alias for `COPY` and will be removed in a future release.
|
|
38
|
+
*/
|
|
30
39
|
COPY_LINK: 'copyLink',
|
|
31
40
|
DELETE: 'delete',
|
|
32
41
|
SEPARATOR: 'separator'
|
|
33
42
|
};
|
|
34
|
-
export const EDITOR_TOOLBAR_HANDLER_KEYS = ['onAlignmentClick', 'onAppearanceClick', 'onAskRovoClick', '
|
|
43
|
+
export const EDITOR_TOOLBAR_HANDLER_KEYS = ['onAlignmentClick', 'onAppearanceClick', 'onAskRovoClick', 'onChangeBorderClick', 'onCopyClick', 'onCopyLinkClick', 'onDeleteClick', 'onEditClick', 'onEditUrlClick', 'onOpenInNewWindowClick', 'onRefreshClick', 'onSetEmbedTypeClick', 'onShowTitleClick'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/index.js
CHANGED
|
@@ -3,5 +3,7 @@ export { ALIGNMENT_VALUES, DEFAULT_ALIGNMENT, BUILTIN_TOOLBAR_KEYS, EDITOR_TOOLB
|
|
|
3
3
|
|
|
4
4
|
// Re-export types
|
|
5
5
|
|
|
6
|
+
// Plugin actions types
|
|
7
|
+
|
|
6
8
|
// Re-export utilities
|
|
7
9
|
export { createEditorToolbarActions, getParameter, getParameters, setParameter, setParameters } from './utils/utils';
|
|
@@ -5,6 +5,7 @@ export var NATIVE_EMBED_PARAMETER_DEFAULTS = {
|
|
|
5
5
|
url: undefined,
|
|
6
6
|
alwaysShowTitle: false,
|
|
7
7
|
alignment: DEFAULT_ALIGNMENT,
|
|
8
|
+
displayText: undefined,
|
|
8
9
|
height: 600,
|
|
9
10
|
width: undefined
|
|
10
11
|
};
|
|
@@ -13,7 +14,7 @@ export var NATIVE_EMBED_PARAMETER_DEFAULTS = {
|
|
|
13
14
|
* Built-in keys that can be referenced in the `items` and `moreItems` arrays.
|
|
14
15
|
*
|
|
15
16
|
* Toolbar keys: ASK_ROVO, REFRESH, EDIT, EMBED, BORDER, ALIGNMENT, OPEN_IN_NEW_WINDOW
|
|
16
|
-
* More Options dropdown keys: ALWAYS_SHOW_TITLE, SET_EMBED_TYPE, COPY_LINK, DELETE
|
|
17
|
+
* More Options dropdown keys: ALWAYS_SHOW_TITLE, SET_EMBED_TYPE, COPY, COPY_LINK (deprecated), DELETE
|
|
17
18
|
* Shared: SEPARATOR (usable in both)
|
|
18
19
|
*/
|
|
19
20
|
export var BUILTIN_TOOLBAR_KEYS = {
|
|
@@ -27,8 +28,16 @@ export var BUILTIN_TOOLBAR_KEYS = {
|
|
|
27
28
|
EDIT_URL: 'editUrl',
|
|
28
29
|
ALWAYS_SHOW_TITLE: 'alwaysShowTitle',
|
|
29
30
|
SET_EMBED_TYPE: 'setEmbedType',
|
|
31
|
+
/**
|
|
32
|
+
* Copies the native-embed node to the clipboard.
|
|
33
|
+
*/
|
|
34
|
+
COPY: 'copy',
|
|
35
|
+
/**
|
|
36
|
+
* @private
|
|
37
|
+
* @deprecated Use `COPY` instead. `COPY_LINK` is a deprecated alias for `COPY` and will be removed in a future release.
|
|
38
|
+
*/
|
|
30
39
|
COPY_LINK: 'copyLink',
|
|
31
40
|
DELETE: 'delete',
|
|
32
41
|
SEPARATOR: 'separator'
|
|
33
42
|
};
|
|
34
|
-
export var EDITOR_TOOLBAR_HANDLER_KEYS = ['onAlignmentClick', 'onAppearanceClick', 'onAskRovoClick', '
|
|
43
|
+
export var EDITOR_TOOLBAR_HANDLER_KEYS = ['onAlignmentClick', 'onAppearanceClick', 'onAskRovoClick', 'onChangeBorderClick', 'onCopyClick', 'onCopyLinkClick', 'onDeleteClick', 'onEditClick', 'onEditUrlClick', 'onOpenInNewWindowClick', 'onRefreshClick', 'onSetEmbedTypeClick', 'onShowTitleClick'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { ALIGNMENT_VALUES, DEFAULT_ALIGNMENT, BUILTIN_TOOLBAR_KEYS, EDITOR_TOOLBAR_HANDLER_KEYS, NATIVE_EMBED_PARAMETER_DEFAULTS, } from './utils/constants';
|
|
2
2
|
export type { AlignmentValue, EditorToolbarButtonAction, EditorToolbarAction, EditorToolbarHandler, EditorToolbarHandlerContext, EditorToolbarHandlerKey, EditorToolbarHandlers, NativeEmbedAppearance, NativeEmbedParameterKey, NativeEmbedParameterValues, NativeEmbedParameterValue, NativeEmbedParameters, BuiltinToolbarKey, ManifestEditorToolbarActions, } from './utils/types';
|
|
3
|
+
export type { CardToNativeEmbedNode, CardToNativeEmbedTransformOptions, CreateCardToNativeEmbedTransform, EditorPluginNativeEmbedsPlugin, NativeEmbedLayout, NativeEmbedTransformAttrs, } from './utils/plugin-actions/types';
|
|
3
4
|
export { createEditorToolbarActions, getParameter, getParameters, setParameter, setParameters, } from './utils/utils';
|
|
@@ -6,7 +6,7 @@ export declare const NATIVE_EMBED_PARAMETER_DEFAULTS: NativeEmbedParameterValues
|
|
|
6
6
|
* Built-in keys that can be referenced in the `items` and `moreItems` arrays.
|
|
7
7
|
*
|
|
8
8
|
* Toolbar keys: ASK_ROVO, REFRESH, EDIT, EMBED, BORDER, ALIGNMENT, OPEN_IN_NEW_WINDOW
|
|
9
|
-
* More Options dropdown keys: ALWAYS_SHOW_TITLE, SET_EMBED_TYPE, COPY_LINK, DELETE
|
|
9
|
+
* More Options dropdown keys: ALWAYS_SHOW_TITLE, SET_EMBED_TYPE, COPY, COPY_LINK (deprecated), DELETE
|
|
10
10
|
* Shared: SEPARATOR (usable in both)
|
|
11
11
|
*/
|
|
12
12
|
export declare const BUILTIN_TOOLBAR_KEYS: {
|
|
@@ -20,8 +20,16 @@ export declare const BUILTIN_TOOLBAR_KEYS: {
|
|
|
20
20
|
readonly EDIT_URL: "editUrl";
|
|
21
21
|
readonly ALWAYS_SHOW_TITLE: "alwaysShowTitle";
|
|
22
22
|
readonly SET_EMBED_TYPE: "setEmbedType";
|
|
23
|
+
/**
|
|
24
|
+
* Copies the native-embed node to the clipboard.
|
|
25
|
+
*/
|
|
26
|
+
readonly COPY: "copy";
|
|
27
|
+
/**
|
|
28
|
+
* @private
|
|
29
|
+
* @deprecated Use `COPY` instead. `COPY_LINK` is a deprecated alias for `COPY` and will be removed in a future release.
|
|
30
|
+
*/
|
|
23
31
|
readonly COPY_LINK: "copyLink";
|
|
24
32
|
readonly DELETE: "delete";
|
|
25
33
|
readonly SEPARATOR: "separator";
|
|
26
34
|
};
|
|
27
|
-
export declare const EDITOR_TOOLBAR_HANDLER_KEYS: readonly ["onAlignmentClick", "onAppearanceClick", "onAskRovoClick", "
|
|
35
|
+
export declare const EDITOR_TOOLBAR_HANDLER_KEYS: readonly ["onAlignmentClick", "onAppearanceClick", "onAskRovoClick", "onChangeBorderClick", "onCopyClick", "onCopyLinkClick", "onDeleteClick", "onEditClick", "onEditUrlClick", "onOpenInNewWindowClick", "onRefreshClick", "onSetEmbedTypeClick", "onShowTitleClick"];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { Node, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
/** Accepted layout values from ADF schema (embedCard) */
|
|
6
|
+
export type NativeEmbedLayout = 'wide' | 'full-width' | 'center' | 'wrap-right' | 'wrap-left' | 'align-end' | 'align-start';
|
|
7
|
+
/** Input attrs for embedCard node (subset used by transform) */
|
|
8
|
+
export interface NativeEmbedTransformAttrs {
|
|
9
|
+
layout?: NativeEmbedLayout;
|
|
10
|
+
originalHeight?: number | null;
|
|
11
|
+
originalWidth?: number | null;
|
|
12
|
+
url: string;
|
|
13
|
+
width?: number;
|
|
14
|
+
}
|
|
15
|
+
/** Type for cardToNativeEmbedNode - converts embed attrs to native embed Node */
|
|
16
|
+
export type CardToNativeEmbedNode = (schema: Schema, attrs: NativeEmbedTransformAttrs) => Node | undefined;
|
|
17
|
+
/** Type for createEmbedCardToNativeEmbedTransform - returns a Command */
|
|
18
|
+
export type CreateCardToNativeEmbedTransform = (options?: CardToNativeEmbedTransformOptions) => Command;
|
|
19
|
+
export interface CardToNativeEmbedTransformOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Called before dispatch to allow the caller to augment the transaction
|
|
22
|
+
* (e.g. datasource stash, analytics, link metadata).
|
|
23
|
+
*/
|
|
24
|
+
augmentTransaction?: (tr: Transaction, state: EditorState) => void;
|
|
25
|
+
editorAnalyticsApi?: EditorAnalyticsAPI;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Minimal plugin type for native embeds action integration.
|
|
29
|
+
*/
|
|
30
|
+
export type EditorPluginNativeEmbedsPlugin = NextEditorPlugin<'editorPluginNativeEmbeds', {
|
|
31
|
+
actions: {
|
|
32
|
+
cardToNativeEmbedNode: CardToNativeEmbedNode;
|
|
33
|
+
createCardToNativeEmbedTransform: CreateCardToNativeEmbedTransform;
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
@@ -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
|
+
displayText?: string;
|
|
10
11
|
height: number;
|
|
11
12
|
url?: string;
|
|
12
13
|
width?: number;
|
|
@@ -18,6 +19,7 @@ export type NativeEmbedParameters = {
|
|
|
18
19
|
macroParams?: {
|
|
19
20
|
alignment?: NativeEmbedParameterValue;
|
|
20
21
|
alwaysShowTitle?: NativeEmbedParameterValue;
|
|
22
|
+
displayText?: NativeEmbedParameterValue;
|
|
21
23
|
height?: NativeEmbedParameterValue;
|
|
22
24
|
url?: NativeEmbedParameterValue;
|
|
23
25
|
width?: NativeEmbedParameterValue;
|
|
@@ -78,6 +80,15 @@ export type EditorToolbarHandlers = Partial<{
|
|
|
78
80
|
onAppearanceClick: (parameters: NativeEmbedParameterValues, appearance: NativeEmbedAppearance, context?: EditorToolbarHandlerContext) => void;
|
|
79
81
|
onAskRovoClick: (parameters: NativeEmbedParameterValues, context?: EditorToolbarHandlerContext) => void;
|
|
80
82
|
onChangeBorderClick: EditorToolbarHandler;
|
|
83
|
+
/**
|
|
84
|
+
* Handler invoked when the Copy action is clicked.
|
|
85
|
+
* Copies the native-embed node to the clipboard.
|
|
86
|
+
*/
|
|
87
|
+
onCopyClick: EditorToolbarHandler;
|
|
88
|
+
/**
|
|
89
|
+
* @private
|
|
90
|
+
* @deprecated Use `onCopyClick` instead. This is a deprecated alias and will be removed in a future release.
|
|
91
|
+
*/
|
|
81
92
|
onCopyLinkClick: EditorToolbarHandler;
|
|
82
93
|
onDeleteClick: EditorToolbarHandler;
|
|
83
94
|
onEditClick: EditorToolbarHandler;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { ALIGNMENT_VALUES, DEFAULT_ALIGNMENT, BUILTIN_TOOLBAR_KEYS, EDITOR_TOOLBAR_HANDLER_KEYS, NATIVE_EMBED_PARAMETER_DEFAULTS, } from './utils/constants';
|
|
2
2
|
export type { AlignmentValue, EditorToolbarButtonAction, EditorToolbarAction, EditorToolbarHandler, EditorToolbarHandlerContext, EditorToolbarHandlerKey, EditorToolbarHandlers, NativeEmbedAppearance, NativeEmbedParameterKey, NativeEmbedParameterValues, NativeEmbedParameterValue, NativeEmbedParameters, BuiltinToolbarKey, ManifestEditorToolbarActions, } from './utils/types';
|
|
3
|
+
export type { CardToNativeEmbedNode, CardToNativeEmbedTransformOptions, CreateCardToNativeEmbedTransform, EditorPluginNativeEmbedsPlugin, NativeEmbedLayout, NativeEmbedTransformAttrs, } from './utils/plugin-actions/types';
|
|
3
4
|
export { createEditorToolbarActions, getParameter, getParameters, setParameter, setParameters, } from './utils/utils';
|
|
@@ -12,7 +12,7 @@ export declare const NATIVE_EMBED_PARAMETER_DEFAULTS: NativeEmbedParameterValues
|
|
|
12
12
|
* Built-in keys that can be referenced in the `items` and `moreItems` arrays.
|
|
13
13
|
*
|
|
14
14
|
* Toolbar keys: ASK_ROVO, REFRESH, EDIT, EMBED, BORDER, ALIGNMENT, OPEN_IN_NEW_WINDOW
|
|
15
|
-
* More Options dropdown keys: ALWAYS_SHOW_TITLE, SET_EMBED_TYPE, COPY_LINK, DELETE
|
|
15
|
+
* More Options dropdown keys: ALWAYS_SHOW_TITLE, SET_EMBED_TYPE, COPY, COPY_LINK (deprecated), DELETE
|
|
16
16
|
* Shared: SEPARATOR (usable in both)
|
|
17
17
|
*/
|
|
18
18
|
export declare const BUILTIN_TOOLBAR_KEYS: {
|
|
@@ -26,6 +26,14 @@ export declare const BUILTIN_TOOLBAR_KEYS: {
|
|
|
26
26
|
readonly EDIT_URL: "editUrl";
|
|
27
27
|
readonly ALWAYS_SHOW_TITLE: "alwaysShowTitle";
|
|
28
28
|
readonly SET_EMBED_TYPE: "setEmbedType";
|
|
29
|
+
/**
|
|
30
|
+
* Copies the native-embed node to the clipboard.
|
|
31
|
+
*/
|
|
32
|
+
readonly COPY: "copy";
|
|
33
|
+
/**
|
|
34
|
+
* @private
|
|
35
|
+
* @deprecated Use `COPY` instead. `COPY_LINK` is a deprecated alias for `COPY` and will be removed in a future release.
|
|
36
|
+
*/
|
|
29
37
|
readonly COPY_LINK: "copyLink";
|
|
30
38
|
readonly DELETE: "delete";
|
|
31
39
|
readonly SEPARATOR: "separator";
|
|
@@ -34,11 +42,12 @@ export declare const EDITOR_TOOLBAR_HANDLER_KEYS: readonly [
|
|
|
34
42
|
"onAlignmentClick",
|
|
35
43
|
"onAppearanceClick",
|
|
36
44
|
"onAskRovoClick",
|
|
37
|
-
"onCopyLinkClick",
|
|
38
45
|
"onChangeBorderClick",
|
|
46
|
+
"onCopyClick",
|
|
47
|
+
"onCopyLinkClick",
|
|
39
48
|
"onDeleteClick",
|
|
40
|
-
"onEditUrlClick",
|
|
41
49
|
"onEditClick",
|
|
50
|
+
"onEditUrlClick",
|
|
42
51
|
"onOpenInNewWindowClick",
|
|
43
52
|
"onRefreshClick",
|
|
44
53
|
"onSetEmbedTypeClick",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { Node, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
/** Accepted layout values from ADF schema (embedCard) */
|
|
6
|
+
export type NativeEmbedLayout = 'wide' | 'full-width' | 'center' | 'wrap-right' | 'wrap-left' | 'align-end' | 'align-start';
|
|
7
|
+
/** Input attrs for embedCard node (subset used by transform) */
|
|
8
|
+
export interface NativeEmbedTransformAttrs {
|
|
9
|
+
layout?: NativeEmbedLayout;
|
|
10
|
+
originalHeight?: number | null;
|
|
11
|
+
originalWidth?: number | null;
|
|
12
|
+
url: string;
|
|
13
|
+
width?: number;
|
|
14
|
+
}
|
|
15
|
+
/** Type for cardToNativeEmbedNode - converts embed attrs to native embed Node */
|
|
16
|
+
export type CardToNativeEmbedNode = (schema: Schema, attrs: NativeEmbedTransformAttrs) => Node | undefined;
|
|
17
|
+
/** Type for createEmbedCardToNativeEmbedTransform - returns a Command */
|
|
18
|
+
export type CreateCardToNativeEmbedTransform = (options?: CardToNativeEmbedTransformOptions) => Command;
|
|
19
|
+
export interface CardToNativeEmbedTransformOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Called before dispatch to allow the caller to augment the transaction
|
|
22
|
+
* (e.g. datasource stash, analytics, link metadata).
|
|
23
|
+
*/
|
|
24
|
+
augmentTransaction?: (tr: Transaction, state: EditorState) => void;
|
|
25
|
+
editorAnalyticsApi?: EditorAnalyticsAPI;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Minimal plugin type for native embeds action integration.
|
|
29
|
+
*/
|
|
30
|
+
export type EditorPluginNativeEmbedsPlugin = NextEditorPlugin<'editorPluginNativeEmbeds', {
|
|
31
|
+
actions: {
|
|
32
|
+
cardToNativeEmbedNode: CardToNativeEmbedNode;
|
|
33
|
+
createCardToNativeEmbedTransform: CreateCardToNativeEmbedTransform;
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
@@ -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
|
+
displayText?: string;
|
|
10
11
|
height: number;
|
|
11
12
|
url?: string;
|
|
12
13
|
width?: number;
|
|
@@ -18,6 +19,7 @@ export type NativeEmbedParameters = {
|
|
|
18
19
|
macroParams?: {
|
|
19
20
|
alignment?: NativeEmbedParameterValue;
|
|
20
21
|
alwaysShowTitle?: NativeEmbedParameterValue;
|
|
22
|
+
displayText?: NativeEmbedParameterValue;
|
|
21
23
|
height?: NativeEmbedParameterValue;
|
|
22
24
|
url?: NativeEmbedParameterValue;
|
|
23
25
|
width?: NativeEmbedParameterValue;
|
|
@@ -79,6 +81,15 @@ export type EditorToolbarHandlers = Partial<{
|
|
|
79
81
|
onAppearanceClick: (parameters: NativeEmbedParameterValues, appearance: NativeEmbedAppearance, context?: EditorToolbarHandlerContext) => void;
|
|
80
82
|
onAskRovoClick: (parameters: NativeEmbedParameterValues, context?: EditorToolbarHandlerContext) => void;
|
|
81
83
|
onChangeBorderClick: EditorToolbarHandler;
|
|
84
|
+
/**
|
|
85
|
+
* Handler invoked when the Copy action is clicked.
|
|
86
|
+
* Copies the native-embed node to the clipboard.
|
|
87
|
+
*/
|
|
88
|
+
onCopyClick: EditorToolbarHandler;
|
|
89
|
+
/**
|
|
90
|
+
* @private
|
|
91
|
+
* @deprecated Use `onCopyClick` instead. This is a deprecated alias and will be removed in a future release.
|
|
92
|
+
*/
|
|
82
93
|
onCopyLinkClick: EditorToolbarHandler;
|
|
83
94
|
onDeleteClick: EditorToolbarHandler;
|
|
84
95
|
onEditClick: EditorToolbarHandler;
|
package/package.json
CHANGED
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
],
|
|
25
25
|
"atlaskit:src": "src/index.ts",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@atlaskit/editor-common": "^112.
|
|
28
|
-
"@atlaskit/
|
|
27
|
+
"@atlaskit/editor-common": "^112.13.0",
|
|
28
|
+
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
29
|
+
"@atlaskit/icon": "^33.1.0",
|
|
29
30
|
"@babel/runtime": "^7.0.0",
|
|
30
31
|
"@compiled/react": "^0.20.0"
|
|
31
32
|
},
|
|
@@ -78,7 +79,7 @@
|
|
|
78
79
|
}
|
|
79
80
|
},
|
|
80
81
|
"name": "@atlaskit/native-embeds-common",
|
|
81
|
-
"version": "0.
|
|
82
|
+
"version": "0.2.0",
|
|
82
83
|
"description": "A shared package for native embeds to be used across experiences and plugin",
|
|
83
84
|
"author": "Atlassian Pty Ltd",
|
|
84
85
|
"license": "Apache-2.0",
|