@atlaskit/editor-plugin-media 0.3.1 → 0.3.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/toolbar/index.js +6 -1
  3. package/dist/cjs/toolbar/utils.js +5 -2
  4. package/dist/es2019/toolbar/index.js +5 -2
  5. package/dist/es2019/toolbar/utils.js +5 -3
  6. package/dist/esm/toolbar/index.js +7 -2
  7. package/dist/esm/toolbar/utils.js +5 -2
  8. package/dist/types/toolbar/utils.d.ts +1 -1
  9. package/dist/types-ts4.5/commands/captions.d.ts +5 -0
  10. package/dist/types-ts4.5/commands/helpers.d.ts +15 -0
  11. package/dist/types-ts4.5/commands/index.d.ts +1 -0
  12. package/dist/types-ts4.5/commands/linking.d.ts +9 -0
  13. package/dist/types-ts4.5/index.d.ts +2 -0
  14. package/dist/types-ts4.5/media-plugin-options.d.ts +17 -0
  15. package/dist/types-ts4.5/next-plugin-type.d.ts +33 -0
  16. package/dist/types-ts4.5/nodeviews/__mocks__/mediaNodeUpdater.d.ts +24 -0
  17. package/dist/types-ts4.5/nodeviews/mediaGroup.d.ts +33 -0
  18. package/dist/types-ts4.5/nodeviews/mediaInline.d.ts +50 -0
  19. package/dist/types-ts4.5/nodeviews/mediaNodeUpdater.d.ts +45 -0
  20. package/dist/types-ts4.5/nodeviews/mediaNodeView/index.d.ts +28 -0
  21. package/dist/types-ts4.5/nodeviews/mediaNodeView/media.d.ts +44 -0
  22. package/dist/types-ts4.5/nodeviews/mediaSingle.d.ts +62 -0
  23. package/dist/types-ts4.5/nodeviews/messages.d.ts +7 -0
  24. package/dist/types-ts4.5/nodeviews/styles.d.ts +16 -0
  25. package/dist/types-ts4.5/nodeviews/types.d.ts +42 -0
  26. package/dist/types-ts4.5/picker-facade.d.ts +44 -0
  27. package/dist/types-ts4.5/plugin.d.ts +7 -0
  28. package/dist/types-ts4.5/pm-plugins/alt-text/actions.d.ts +10 -0
  29. package/dist/types-ts4.5/pm-plugins/alt-text/commands.d.ts +4 -0
  30. package/dist/types-ts4.5/pm-plugins/alt-text/index.d.ts +7 -0
  31. package/dist/types-ts4.5/pm-plugins/alt-text/keymap.d.ts +4 -0
  32. package/dist/types-ts4.5/pm-plugins/alt-text/messages.d.ts +37 -0
  33. package/dist/types-ts4.5/pm-plugins/alt-text/reducer.d.ts +4 -0
  34. package/dist/types-ts4.5/pm-plugins/alt-text/types.d.ts +3 -0
  35. package/dist/types-ts4.5/pm-plugins/alt-text/ui/AltTextEdit.d.ts +41 -0
  36. package/dist/types-ts4.5/pm-plugins/keymap-media-single.d.ts +3 -0
  37. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +6 -0
  38. package/dist/types-ts4.5/pm-plugins/linking/actions.d.ts +20 -0
  39. package/dist/types-ts4.5/pm-plugins/linking/index.d.ts +10 -0
  40. package/dist/types-ts4.5/pm-plugins/linking/keymap.d.ts +3 -0
  41. package/dist/types-ts4.5/pm-plugins/linking/reducer.d.ts +4 -0
  42. package/dist/types-ts4.5/pm-plugins/linking/types.d.ts +12 -0
  43. package/dist/types-ts4.5/pm-plugins/main.d.ts +120 -0
  44. package/dist/types-ts4.5/pm-plugins/media-editor-plugin-factory.d.ts +3 -0
  45. package/dist/types-ts4.5/pm-plugins/mediaTaskManager.d.ts +9 -0
  46. package/dist/types-ts4.5/pm-plugins/plugin-key.d.ts +3 -0
  47. package/dist/types-ts4.5/pm-plugins/types.d.ts +65 -0
  48. package/dist/types-ts4.5/toolbar/alt-text.d.ts +13 -0
  49. package/dist/types-ts4.5/toolbar/commands.d.ts +12 -0
  50. package/dist/types-ts4.5/toolbar/filePreviewItem.d.ts +9 -0
  51. package/dist/types-ts4.5/toolbar/imageBorder.d.ts +2 -0
  52. package/dist/types-ts4.5/toolbar/index.d.ts +6 -0
  53. package/dist/types-ts4.5/toolbar/linking-toolbar-appearance.d.ts +14 -0
  54. package/dist/types-ts4.5/toolbar/linking.d.ts +10 -0
  55. package/dist/types-ts4.5/toolbar/utils.d.ts +11 -0
  56. package/dist/types-ts4.5/types.d.ts +119 -0
  57. package/dist/types-ts4.5/ui/CaptionPlaceholder/index.d.ts +6 -0
  58. package/dist/types-ts4.5/ui/CaptionPlaceholder/messages.d.ts +7 -0
  59. package/dist/types-ts4.5/ui/ImageBorder/index.d.ts +11 -0
  60. package/dist/types-ts4.5/ui/ImageBorder/messages.d.ts +42 -0
  61. package/dist/types-ts4.5/ui/ImageBorder/styles.d.ts +15 -0
  62. package/dist/types-ts4.5/ui/Media/DropPlaceholder.d.ts +8 -0
  63. package/dist/types-ts4.5/ui/Media/drop-placeholder-messages.d.ts +7 -0
  64. package/dist/types-ts4.5/ui/MediaLinkingToolbar.d.ts +35 -0
  65. package/dist/types-ts4.5/ui/MediaPicker/BrowserWrapper.d.ts +11 -0
  66. package/dist/types-ts4.5/ui/MediaPicker/ClipboardWrapper.d.ts +10 -0
  67. package/dist/types-ts4.5/ui/MediaPicker/DropzoneWrapper.d.ts +13 -0
  68. package/dist/types-ts4.5/ui/MediaPicker/PickerFacadeProvider.d.ts +28 -0
  69. package/dist/types-ts4.5/ui/MediaPicker/index.d.ts +23 -0
  70. package/dist/types-ts4.5/ui/PixelEntry/constants.d.ts +1 -0
  71. package/dist/types-ts4.5/ui/PixelEntry/index.d.ts +8 -0
  72. package/dist/types-ts4.5/ui/PixelEntry/messages.d.ts +47 -0
  73. package/dist/types-ts4.5/ui/PixelEntry/styles.d.ts +8 -0
  74. package/dist/types-ts4.5/ui/PixelEntry/types.d.ts +58 -0
  75. package/dist/types-ts4.5/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.d.ts +3 -0
  76. package/dist/types-ts4.5/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +59 -0
  77. package/dist/types-ts4.5/ui/ResizableMediaSingle/index.d.ts +45 -0
  78. package/dist/types-ts4.5/ui/ResizableMediaSingle/styled.d.ts +2 -0
  79. package/dist/types-ts4.5/ui/ResizableMediaSingle/styles.d.ts +1 -0
  80. package/dist/types-ts4.5/ui/ResizableMediaSingle/types.d.ts +27 -0
  81. package/dist/types-ts4.5/ui/ToolbarMedia/index.d.ts +13 -0
  82. package/dist/types-ts4.5/ui/ToolbarMedia/toolbar-media-messages.d.ts +7 -0
  83. package/dist/types-ts4.5/ui/media-linking-toolbar-messages.d.ts +7 -0
  84. package/dist/types-ts4.5/utils/analytics.d.ts +3 -0
  85. package/dist/types-ts4.5/utils/check-media-type.d.ts +4 -0
  86. package/dist/types-ts4.5/utils/current-media-node.d.ts +9 -0
  87. package/dist/types-ts4.5/utils/is-image.d.ts +1 -0
  88. package/dist/types-ts4.5/utils/media-common.d.ts +20 -0
  89. package/dist/types-ts4.5/utils/media-files.d.ts +30 -0
  90. package/dist/types-ts4.5/utils/media-single.d.ts +20 -0
  91. package/package.json +3 -3
  92. package/report.api.md +2 -0
  93. package/tmp/api-report-tmp.d.ts +392 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 0.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#41248](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41248) [`21fa5648746`](https://bitbucket.org/atlassian/atlassian-frontend/commits/21fa5648746) - Fix incorrect layout calculation for nested Media Single nodes resized via toolbar
8
+ - Updated dependencies
9
+
3
10
  ## 0.3.1
4
11
 
5
12
  ### Patch Changes
@@ -297,6 +297,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
297
297
  // get pos of media node
298
298
  mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH);
299
299
  var pixelWidth = isLegacy ? pixelWidthFromElement : mediaSingleWidth;
300
+
301
+ //hasParentNode will return falsey value if selection depth === 0
302
+ var isNested = (0, _utils.hasParentNode)(function (n) {
303
+ return n.type !== state.schema.nodes.doc;
304
+ })(state.selection);
300
305
  return /*#__PURE__*/_react.default.createElement(_PixelEntry.PixelEntry, {
301
306
  intl: intl,
302
307
  width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
@@ -316,7 +321,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
316
321
  var _pluginInjectionApi$a4;
317
322
  var width = _ref2.width,
318
323
  validation = _ref2.validation;
319
- var newLayout = (0, _utils2.calcNewLayout)(width, layout, contentWidth, options.fullWidthEnabled);
324
+ var newLayout = (0, _utils2.calcNewLayout)(width, layout, contentWidth, options.fullWidthEnabled, isNested);
320
325
  (0, _commands.updateMediaSingleWidth)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(width, validation, newLayout)(state, dispatch);
321
326
  },
322
327
  onMigrate: function onMigrate() {
@@ -81,7 +81,10 @@ var getPixelWidthOfElement = exports.getPixelWidthOfElement = function getPixelW
81
81
  };
82
82
  var calcNewLayout = exports.calcNewLayout = function calcNewLayout(width, layout, contentWidth) {
83
83
  var fullWidthMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
84
+ var isNested = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
84
85
  var isWrappedLayout = _mediaSingle.wrappedLayouts.indexOf(layout) > -1;
86
+
87
+ //See flowchart for layout logic: https://hello.atlassian.net/wiki/spaces/TWPCP/whiteboard/2969594044
85
88
  if (width >= _editorSharedStyles.akEditorFullWidthLayoutWidth) {
86
89
  // If width is greater than or equal to full editor width
87
90
  return 'full-width';
@@ -90,11 +93,11 @@ var calcNewLayout = exports.calcNewLayout = function calcNewLayout(width, layout
90
93
  // If under editor full width mode
91
94
  return isWrappedLayout ? layout : 'center';
92
95
  }
93
- if (width > contentWidth) {
96
+ if (width > contentWidth && !isNested) {
94
97
  // If width is greater than content length and not nested
95
98
  return 'wide';
96
99
  }
97
- return isWrappedLayout && width !== contentWidth ? layout : 'center';
100
+ return isNested || isWrappedLayout && width !== contentWidth ? layout : 'center';
98
101
  };
99
102
  var maxToolbarFitWidth = 0;
100
103
  var getMaxToolbarWidth = exports.getMaxToolbarWidth = function getMaxToolbarWidth() {
@@ -4,7 +4,7 @@ import { buildLayoutButtons } from '@atlaskit/editor-common/card';
4
4
  import { calcMinWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
5
5
  import commonMessages, { cardMessages } from '@atlaskit/editor-common/messages';
6
6
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
7
- import { findParentNodeOfType, hasParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
7
+ import { findParentNodeOfType, hasParentNode, hasParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
8
8
  import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
9
9
  import DownloadIcon from '@atlaskit/icon/glyph/download';
10
10
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
@@ -300,6 +300,9 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
300
300
  // get pos of media node
301
301
  mediaWidth || DEFAULT_IMAGE_WIDTH);
302
302
  const pixelWidth = isLegacy ? pixelWidthFromElement : mediaSingleWidth;
303
+
304
+ //hasParentNode will return falsey value if selection depth === 0
305
+ const isNested = hasParentNode(n => n.type !== state.schema.nodes.doc)(state.selection);
303
306
  return /*#__PURE__*/React.createElement(PixelEntry, {
304
307
  intl: intl,
305
308
  width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
@@ -320,7 +323,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
320
323
  validation
321
324
  }) => {
322
325
  var _pluginInjectionApi$a4;
323
- const newLayout = calcNewLayout(width, layout, contentWidth, options.fullWidthEnabled);
326
+ const newLayout = calcNewLayout(width, layout, contentWidth, options.fullWidthEnabled, isNested);
324
327
  updateMediaSingleWidth(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(width, validation, newLayout)(state, dispatch);
325
328
  },
326
329
  onMigrate: () => {
@@ -56,8 +56,10 @@ export const getPixelWidthOfElement = (editorView, pos, mediaWidth) => {
56
56
  }
57
57
  return mediaWidth;
58
58
  };
59
- export const calcNewLayout = (width, layout, contentWidth, fullWidthMode = false) => {
59
+ export const calcNewLayout = (width, layout, contentWidth, fullWidthMode = false, isNested = false) => {
60
60
  const isWrappedLayout = wrappedLayouts.indexOf(layout) > -1;
61
+
62
+ //See flowchart for layout logic: https://hello.atlassian.net/wiki/spaces/TWPCP/whiteboard/2969594044
61
63
  if (width >= akEditorFullWidthLayoutWidth) {
62
64
  // If width is greater than or equal to full editor width
63
65
  return 'full-width';
@@ -66,11 +68,11 @@ export const calcNewLayout = (width, layout, contentWidth, fullWidthMode = false
66
68
  // If under editor full width mode
67
69
  return isWrappedLayout ? layout : 'center';
68
70
  }
69
- if (width > contentWidth) {
71
+ if (width > contentWidth && !isNested) {
70
72
  // If width is greater than content length and not nested
71
73
  return 'wide';
72
74
  }
73
- return isWrappedLayout && width !== contentWidth ? layout : 'center';
75
+ return isNested || isWrappedLayout && width !== contentWidth ? layout : 'center';
74
76
  };
75
77
  let maxToolbarFitWidth = 0;
76
78
  export const getMaxToolbarWidth = () => {
@@ -8,7 +8,7 @@ import { buildLayoutButtons } from '@atlaskit/editor-common/card';
8
8
  import { calcMinWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
9
9
  import commonMessages, { cardMessages } from '@atlaskit/editor-common/messages';
10
10
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
11
- import { findParentNodeOfType, hasParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
11
+ import { findParentNodeOfType, hasParentNode, hasParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
12
12
  import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
13
13
  import DownloadIcon from '@atlaskit/icon/glyph/download';
14
14
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
@@ -287,6 +287,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
287
287
  // get pos of media node
288
288
  mediaWidth || DEFAULT_IMAGE_WIDTH);
289
289
  var pixelWidth = isLegacy ? pixelWidthFromElement : mediaSingleWidth;
290
+
291
+ //hasParentNode will return falsey value if selection depth === 0
292
+ var isNested = hasParentNode(function (n) {
293
+ return n.type !== state.schema.nodes.doc;
294
+ })(state.selection);
290
295
  return /*#__PURE__*/React.createElement(PixelEntry, {
291
296
  intl: intl,
292
297
  width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
@@ -306,7 +311,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
306
311
  var _pluginInjectionApi$a4;
307
312
  var width = _ref2.width,
308
313
  validation = _ref2.validation;
309
- var newLayout = calcNewLayout(width, layout, contentWidth, options.fullWidthEnabled);
314
+ var newLayout = calcNewLayout(width, layout, contentWidth, options.fullWidthEnabled, isNested);
310
315
  updateMediaSingleWidth(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(width, validation, newLayout)(state, dispatch);
311
316
  },
312
317
  onMigrate: function onMigrate() {
@@ -74,7 +74,10 @@ export var getPixelWidthOfElement = function getPixelWidthOfElement(editorView,
74
74
  };
75
75
  export var calcNewLayout = function calcNewLayout(width, layout, contentWidth) {
76
76
  var fullWidthMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
77
+ var isNested = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
77
78
  var isWrappedLayout = wrappedLayouts.indexOf(layout) > -1;
79
+
80
+ //See flowchart for layout logic: https://hello.atlassian.net/wiki/spaces/TWPCP/whiteboard/2969594044
78
81
  if (width >= akEditorFullWidthLayoutWidth) {
79
82
  // If width is greater than or equal to full editor width
80
83
  return 'full-width';
@@ -83,11 +86,11 @@ export var calcNewLayout = function calcNewLayout(width, layout, contentWidth) {
83
86
  // If under editor full width mode
84
87
  return isWrappedLayout ? layout : 'center';
85
88
  }
86
- if (width > contentWidth) {
89
+ if (width > contentWidth && !isNested) {
87
90
  // If width is greater than content length and not nested
88
91
  return 'wide';
89
92
  }
90
- return isWrappedLayout && width !== contentWidth ? layout : 'center';
93
+ return isNested || isWrappedLayout && width !== contentWidth ? layout : 'center';
91
94
  };
92
95
  var maxToolbarFitWidth = 0;
93
96
  export var getMaxToolbarWidth = function getMaxToolbarWidth() {
@@ -7,5 +7,5 @@ export declare const downloadMedia: (mediaPluginState: MediaPluginState) => Prom
7
7
  export declare const removeMediaGroupNode: (state: EditorState) => import("prosemirror-state").Transaction;
8
8
  export declare const getSelectedMediaSingle: (state: EditorState) => import("prosemirror-utils/dist/types").FindResult;
9
9
  export declare const getPixelWidthOfElement: (editorView: EditorView, pos: number, mediaWidth: number) => number;
10
- export declare const calcNewLayout: (width: number, layout: RichMediaLayout, contentWidth: number, fullWidthMode?: boolean) => RichMediaLayout;
10
+ export declare const calcNewLayout: (width: number, layout: RichMediaLayout, contentWidth: number, fullWidthMode?: boolean, isNested?: boolean) => RichMediaLayout;
11
11
  export declare const getMaxToolbarWidth: () => number;
@@ -0,0 +1,5 @@
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import type { Command } from '@atlaskit/editor-common/types';
3
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
+ export declare const selectCaptionFromMediaSinglePos: (mediaSingleNodePos: number, mediaSingleNode: PMNode) => Command;
5
+ export declare const insertAndSelectCaptionFromMediaSinglePos: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (mediaSingleNodePos: number | undefined, mediaSingleNode: PMNode) => Command;
@@ -0,0 +1,15 @@
1
+ import type { Command } from '@atlaskit/editor-common/types';
2
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
3
+ import type { MediaNodeWithPosHandler, MediaPluginState } from '../pm-plugins/types';
4
+ /**
5
+ * Note that Media Inline is inserted like a media single node into the media plugin state.
6
+ * Though it is not of type mediaSingle, it shares the same `findMediaSingleNode` method
7
+ *
8
+ */
9
+ export declare const findMediaSingleNode: (mediaPluginState: MediaPluginState, id: string) => MediaNodeWithPosHandler | null;
10
+ export declare const findAllMediaSingleNodes: (mediaPluginState: MediaPluginState, id: string) => MediaNodeWithPosHandler[];
11
+ export declare const isMediaNode: (pos: number, state: EditorState) => boolean | null;
12
+ export declare const updateAllMediaSingleNodesAttrs: (id: string, attrs: object) => Command;
13
+ export declare const updateCurrentMediaNodeAttrs: (attrs: object, mediaNode: MediaNodeWithPosHandler) => Command;
14
+ export declare const updateMediaSingleNodeAttrs: (id: string, attrs: object) => Command;
15
+ export declare const replaceExternalMedia: (pos: number, attrs: object) => Command;
@@ -0,0 +1 @@
1
+ export { updateMediaSingleNodeAttrs, updateAllMediaSingleNodesAttrs, replaceExternalMedia, } from './helpers';
@@ -0,0 +1,9 @@
1
+ import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ import type { Command, CommandDispatch } from '@atlaskit/editor-common/types';
3
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
+ export declare const showLinkingToolbar: Command;
6
+ export declare const showLinkingToolbarWithMediaTypeCheck: Command;
7
+ export declare const hideLinkingToolbar: (state: EditorState, dispatch?: CommandDispatch, view?: EditorView, focusFloatingToolbar?: boolean) => void;
8
+ export declare const unlink: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
9
+ export declare const setUrlToMedia: (url: string, inputMethod: INPUT_METHOD.TYPEAHEAD | INPUT_METHOD.MANUAL, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
@@ -0,0 +1,2 @@
1
+ export type { MediaNextEditorPluginType as MediaPlugin } from './next-plugin-type';
2
+ export { mediaPlugin } from './plugin';
@@ -0,0 +1,17 @@
1
+ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
2
+ import type { ErrorReporter } from '@atlaskit/editor-common/utils';
3
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
+ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
5
+ import type { CustomMediaPicker, getPosHandler, MediaState } from './types';
6
+ export type MediaPluginOptions = {
7
+ providerFactory: ProviderFactory;
8
+ nodeViews: {
9
+ [name: string]: (node: PMNode, view: EditorView, getPos: getPosHandler) => NodeView;
10
+ };
11
+ errorReporter?: ErrorReporter;
12
+ uploadErrorHandler?: (state: MediaState) => void;
13
+ waitForMediaUpload?: boolean;
14
+ customDropzoneContainer?: HTMLElement;
15
+ customMediaPicker?: CustomMediaPicker;
16
+ allowResizing: boolean;
17
+ };
@@ -0,0 +1,33 @@
1
+ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
+ import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
4
+ import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
5
+ import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
6
+ import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-toolbar';
7
+ import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
8
+ import type { GridPlugin } from '@atlaskit/editor-plugin-grid';
9
+ import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
10
+ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
11
+ import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
12
+ import type { MediaPluginState } from './pm-plugins/types';
13
+ import type { MediaOptions } from './types';
14
+ import type { InsertMediaAsMediaSingle } from './utils/media-single';
15
+ export type MediaNextEditorPluginType = NextEditorPlugin<'media', {
16
+ pluginConfiguration: MediaOptions | undefined;
17
+ dependencies: [
18
+ FeatureFlagsPlugin,
19
+ OptionalPlugin<AnalyticsPlugin>,
20
+ GuidelinePlugin,
21
+ GridPlugin,
22
+ WidthPlugin,
23
+ DecorationsPlugin,
24
+ FloatingToolbarPlugin,
25
+ EditorDisabledPlugin,
26
+ FocusPlugin,
27
+ SelectionPlugin
28
+ ];
29
+ sharedState: MediaPluginState | null;
30
+ actions: {
31
+ insertMediaAsMediaSingle: InsertMediaAsMediaSingle;
32
+ };
33
+ }>;
@@ -0,0 +1,24 @@
1
+ export declare class MediaNodeUpdater {
2
+ static instances: MediaNodeUpdater[];
3
+ static mockOverrides: {};
4
+ static mockReset(): void;
5
+ constructor();
6
+ static setMock(thisKey: string, value: any): void;
7
+ updateContextId(): Promise<void>;
8
+ updateNodeContextId(): Promise<void>;
9
+ getAttrs(): void;
10
+ getObjectId(): Promise<void>;
11
+ getNodeContextId(): void;
12
+ updateDimensions(): void;
13
+ getRemoteDimensions(): Promise<void>;
14
+ isNodeFromDifferentCollection(): Promise<void>;
15
+ hasDifferentContextId(): Promise<void>;
16
+ copyNode(): Promise<void>;
17
+ copyNodeFromPos(): Promise<void>;
18
+ updateMediaSingleFileAttrs(): Promise<void>;
19
+ uploadExternalMedia(): Promise<void>;
20
+ isMediaBlobUrl(): void;
21
+ copyNodeFromBlobUrl(): void;
22
+ updateNodeAttrs(): void;
23
+ handleExternalMedia(): Promise<void>;
24
+ }
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
4
+ import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
5
+ import type { ContextIdentifierProvider, MediaProvider, ProviderFactory } from '@atlaskit/editor-common/provider-factory';
6
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
7
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
8
+ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
9
+ import type { MediaClientConfig } from '@atlaskit/media-core';
10
+ import type { MediaNextEditorPluginType } from '../next-plugin-type';
11
+ import type { getPosHandler, MediaOptions } from '../types';
12
+ export type MediaGroupProps = {
13
+ forwardRef?: (ref: HTMLElement) => void;
14
+ node: PMNode;
15
+ view: EditorView;
16
+ getPos: () => number | undefined;
17
+ disabled?: boolean;
18
+ allowLazyLoading?: boolean;
19
+ mediaProvider: Promise<MediaProvider>;
20
+ contextIdentifierProvider?: Promise<ContextIdentifierProvider>;
21
+ isCopyPasteEnabled?: boolean;
22
+ anchorPos: number;
23
+ headPos: number;
24
+ mediaOptions: MediaOptions;
25
+ } & WrappedComponentProps;
26
+ export interface MediaGroupState {
27
+ viewMediaClientConfig?: MediaClientConfig;
28
+ }
29
+ declare const IntlMediaGroup: React.FC<import("react-intl-next").WithIntlProps<MediaGroupProps>> & {
30
+ WrappedComponent: React.ComponentType<MediaGroupProps>;
31
+ };
32
+ export default IntlMediaGroup;
33
+ export declare const ReactMediaGroupNode: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, mediaOptions: MediaOptions | undefined, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined) => (node: PMNode, view: EditorView, getPos: getPosHandler) => NodeView;
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
+ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
4
+ import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
5
+ import type { ContextIdentifierProvider, MediaProvider, ProviderFactory } from '@atlaskit/editor-common/provider-factory';
6
+ import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
7
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
8
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
9
+ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
10
+ import type { FileIdentifier } from '@atlaskit/media-client';
11
+ import type { MediaNextEditorPluginType } from '../next-plugin-type';
12
+ import type { MediaPluginState } from '../pm-plugins/types';
13
+ import type { getPosHandler, getPosHandler as ProsemirrorGetPosHandler } from '../types';
14
+ import { MediaNodeUpdater } from './mediaNodeUpdater';
15
+ export interface MediaInlineProps {
16
+ mediaProvider: Promise<MediaProvider>;
17
+ identifier: FileIdentifier;
18
+ node: PMNode;
19
+ isSelected: boolean;
20
+ view: EditorView;
21
+ getPos: ProsemirrorGetPosHandler;
22
+ dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
23
+ contextIdentifierProvider?: Promise<ContextIdentifierProvider>;
24
+ mediaPluginState: MediaPluginState;
25
+ }
26
+ export declare const createMediaNodeUpdater: (props: MediaInlineProps) => MediaNodeUpdater;
27
+ /**
28
+ * Handles updating the media inline node attributes
29
+ * but also handling copy-paste for cross-editor of the same instance
30
+ * using the contextid
31
+ *
32
+ */
33
+ export declare const updateMediaNodeAttributes: (props: MediaInlineProps, mediaNodeUpdater: MediaNodeUpdater) => Promise<void>;
34
+ export declare const handleNewNode: (props: MediaInlineProps) => void;
35
+ export declare const MediaInline: React.FC<MediaInlineProps>;
36
+ export interface MediaInlineNodeViewProps {
37
+ providerFactory: ProviderFactory;
38
+ api: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined;
39
+ dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
40
+ }
41
+ export declare class MediaInlineNodeView extends SelectionBasedNodeView<MediaInlineNodeViewProps> {
42
+ createDomRef(): HTMLSpanElement;
43
+ getContentDOM(): {
44
+ dom: HTMLSpanElement;
45
+ };
46
+ ignoreMutation(): boolean;
47
+ viewShouldUpdate(nextNode: PMNode): boolean;
48
+ render(props: MediaInlineNodeViewProps): JSX.Element;
49
+ }
50
+ export declare const ReactMediaInlineNode: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, api: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined, dispatchAnalyticsEvent?: DispatchAnalyticsEvent) => (node: PMNode, view: EditorView, getPos: getPosHandler) => NodeView;
@@ -0,0 +1,45 @@
1
+ import type { MediaADFAttrs } from '@atlaskit/adf-schema';
2
+ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
+ import type { ContextIdentifierProvider, MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { MediaTraceContext } from '@atlaskit/media-common';
7
+ import type { MediaOptions, getPosHandler as ProsemirrorGetPosHandler } from '../types';
8
+ export type RemoteDimensions = {
9
+ id: string;
10
+ height: number;
11
+ width: number;
12
+ };
13
+ export interface MediaNodeUpdaterProps {
14
+ view: EditorView;
15
+ node: PMNode;
16
+ mediaProvider?: Promise<MediaProvider>;
17
+ contextIdentifierProvider?: Promise<ContextIdentifierProvider>;
18
+ isMediaSingle: boolean;
19
+ mediaOptions?: MediaOptions;
20
+ dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
21
+ }
22
+ export declare class MediaNodeUpdater {
23
+ props: MediaNodeUpdaterProps;
24
+ constructor(props: MediaNodeUpdaterProps);
25
+ isMediaBlobUrl(): boolean;
26
+ updateContextId: () => Promise<void>;
27
+ updateNodeContextId: (getPos: ProsemirrorGetPosHandler) => Promise<void>;
28
+ private hasFileAttributesDefined;
29
+ private getNewFileAttrsForNode;
30
+ updateMediaSingleFileAttrs: () => Promise<void>;
31
+ updateNodeAttrs: (getPos: ProsemirrorGetPosHandler) => Promise<void>;
32
+ getAttrs: () => MediaADFAttrs | undefined;
33
+ getObjectId: () => Promise<string | null>;
34
+ uploadExternalMedia: (getPos: ProsemirrorGetPosHandler) => Promise<void>;
35
+ getNodeContextId: () => string | null;
36
+ updateDimensions: (dimensions: RemoteDimensions) => void;
37
+ getRemoteDimensions(): Promise<false | RemoteDimensions>;
38
+ hasDifferentContextId: () => Promise<boolean>;
39
+ isNodeFromDifferentCollection: () => Promise<boolean>;
40
+ handleExternalMedia(getPos: ProsemirrorGetPosHandler): Promise<void>;
41
+ copyNodeFromBlobUrl: (getPos: ProsemirrorGetPosHandler) => Promise<void>;
42
+ copyNodeFromPos: (getPos: ProsemirrorGetPosHandler, traceContext?: MediaTraceContext) => Promise<void>;
43
+ copyNode: (traceContext?: MediaTraceContext) => Promise<void>;
44
+ private copyFile;
45
+ }
@@ -0,0 +1,28 @@
1
+ /// <reference types="react" />
2
+ import type { MediaADFAttrs } from '@atlaskit/adf-schema';
3
+ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
4
+ import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
5
+ import type { ContextIdentifierProvider, MediaProvider, ProviderFactory, Providers } from '@atlaskit/editor-common/provider-factory';
6
+ import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
7
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
8
+ import type { WidthPluginState } from '@atlaskit/editor-plugin-width';
9
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
10
+ import type { Decoration, EditorView } from '@atlaskit/editor-prosemirror/view';
11
+ import type { MediaNextEditorPluginType } from '../../next-plugin-type';
12
+ import type { getPosHandler, MediaOptions } from '../../types';
13
+ import type { MediaNodeViewProps } from '../types';
14
+ declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
15
+ private isSelected;
16
+ createDomRef(): HTMLElement;
17
+ viewShouldUpdate(nextNode: PMNode, decorations: Decoration[]): boolean;
18
+ stopEvent(event: Event): boolean;
19
+ getAttrs(): MediaADFAttrs;
20
+ isMediaBlobUrl(): boolean;
21
+ renderMediaNodeWithState: (mediaProvider?: Promise<MediaProvider>, contextIdentifierProvider?: Promise<ContextIdentifierProvider>) => ({ width: editorWidth }: {
22
+ width?: import("@atlaskit/editor-common/types").EditorContainerWidth | undefined;
23
+ }) => JSX.Element;
24
+ renderMediaNodeWithProviders: ({ mediaProvider, contextIdentifierProvider, }: Providers) => JSX.Element;
25
+ render(): JSX.Element;
26
+ }
27
+ export declare const ReactMediaNode: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, mediaOptions: MediaOptions | undefined, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined) => (node: PMNode, view: EditorView, getPos: getPosHandler) => MediaNodeView;
28
+ export {};
@@ -0,0 +1,44 @@
1
+ import React, { Component } from 'react';
2
+ import type { ContextIdentifierProvider, MediaProvider } from '@atlaskit/editor-common/provider-factory';
3
+ import type { ImageLoaderProps } from '@atlaskit/editor-common/utils';
4
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { CardDimensions, CardOnClickCallback, NumericalCardDimensions } from '@atlaskit/media-card';
7
+ import type { MediaClientConfig } from '@atlaskit/media-core';
8
+ import type { MediaOptions, getPosHandler as ProsemirrorGetPosHandler, ReactNodeProps } from '../../types';
9
+ export declare const MEDIA_HEIGHT = 125;
10
+ export declare const FILE_WIDTH = 156;
11
+ export interface MediaNodeProps extends ReactNodeProps, ImageLoaderProps {
12
+ view: EditorView;
13
+ node: PMNode;
14
+ getPos: ProsemirrorGetPosHandler;
15
+ contextIdentifierProvider?: Promise<ContextIdentifierProvider>;
16
+ originalDimensions: NumericalCardDimensions;
17
+ maxDimensions: CardDimensions;
18
+ isMediaSingle?: boolean;
19
+ onClick?: CardOnClickCallback;
20
+ mediaProvider?: Promise<MediaProvider>;
21
+ isLoading?: boolean;
22
+ mediaOptions?: MediaOptions;
23
+ }
24
+ interface MediaNodeState {
25
+ viewMediaClientConfig?: MediaClientConfig;
26
+ contextIdentifierProvider?: ContextIdentifierProvider;
27
+ }
28
+ export declare class MediaNode extends Component<MediaNodeProps, MediaNodeState> {
29
+ private mediaPluginState;
30
+ state: MediaNodeState;
31
+ constructor(props: MediaNodeProps);
32
+ shouldComponentUpdate(nextProps: MediaNodeProps, nextState: MediaNodeState): boolean;
33
+ componentDidMount(): Promise<void>;
34
+ componentWillUnmount(): void;
35
+ componentDidUpdate(prevProps: Readonly<MediaNodeProps>): void;
36
+ private setViewMediaClientConfig;
37
+ private selectMediaSingleFromCard;
38
+ private selectMediaSingle;
39
+ render(): JSX.Element;
40
+ private onFullscreenChange;
41
+ private handleNewNode;
42
+ }
43
+ declare const _default: React.ComponentClass<MediaNodeProps & ImageLoaderProps, any>;
44
+ export default _default;
@@ -0,0 +1,62 @@
1
+ /** @jsx jsx */
2
+ import type { MouseEvent } from 'react';
3
+ import React, { Component } from 'react';
4
+ import { jsx } from '@emotion/react';
5
+ import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
6
+ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
7
+ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
8
+ import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
9
+ import type { ContextIdentifierProvider, ProviderFactory } from '@atlaskit/editor-common/provider-factory';
10
+ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
11
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
12
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
13
+ import type { Decoration, DecorationSource, EditorView } from '@atlaskit/editor-prosemirror/view';
14
+ import type { CardEvent } from '@atlaskit/media-card';
15
+ import type { MediaClientConfig } from '@atlaskit/media-core';
16
+ import type { MediaNextEditorPluginType } from '../next-plugin-type';
17
+ import type { ForwardRef, getPosHandler } from '../types';
18
+ import type { MediaOptions } from '../types';
19
+ import { MediaNodeUpdater } from './mediaNodeUpdater';
20
+ import type { MediaSingleNodeProps, MediaSingleNodeViewProps } from './types';
21
+ export interface MediaSingleNodeState {
22
+ width?: number;
23
+ height?: number;
24
+ viewMediaClientConfig?: MediaClientConfig;
25
+ contextIdentifierProvider?: ContextIdentifierProvider;
26
+ isCopying: boolean;
27
+ }
28
+ export default class MediaSingleNode extends Component<MediaSingleNodeProps, MediaSingleNodeState> {
29
+ static defaultProps: Partial<MediaSingleNodeProps>;
30
+ static displayName: string;
31
+ state: MediaSingleNodeState;
32
+ mediaSingleWrapperRef: React.RefObject<HTMLDivElement>;
33
+ captionPlaceHolderRef: React.RefObject<HTMLSpanElement>;
34
+ createMediaNodeUpdater: (props: MediaSingleNodeProps) => MediaNodeUpdater;
35
+ UNSAFE_componentWillReceiveProps(nextProps: MediaSingleNodeProps): void;
36
+ setViewMediaClientConfig: (props: MediaSingleNodeProps) => Promise<void>;
37
+ updateMediaNodeAttributes: (props: MediaSingleNodeProps) => Promise<void>;
38
+ componentDidMount(): Promise<void>;
39
+ selectMediaSingle: ({ event }: CardEvent) => void;
40
+ updateSize: (width: number | null, layout: MediaSingleLayout) => void;
41
+ onMediaSingleClicked: (event: MouseEvent) => void;
42
+ render(): jsx.JSX.Element;
43
+ private clickPlaceholder;
44
+ }
45
+ declare class MediaSingleNodeView extends ReactNodeView<MediaSingleNodeViewProps> {
46
+ lastOffsetLeft: number;
47
+ forceViewUpdate: boolean;
48
+ selectionType: number | null;
49
+ createDomRef(): HTMLElement;
50
+ getContentDOM(): {
51
+ dom: HTMLDivElement;
52
+ };
53
+ viewShouldUpdate(nextNode: PMNode): boolean;
54
+ checkAndUpdateSelectionType: () => import("@atlaskit/editor-common/utils").SelectedState | null;
55
+ isNodeSelected: () => boolean;
56
+ getNodeMediaId(node: PMNode): string | undefined;
57
+ update(node: PMNode, decorations: readonly Decoration[], _innerDecorations?: DecorationSource, isValidUpdate?: (currentNode: PMNode, newNode: PMNode) => boolean): boolean;
58
+ render(props: MediaSingleNodeViewProps, forwardRef?: ForwardRef): jsx.JSX.Element;
59
+ ignoreMutation(): boolean;
60
+ }
61
+ export declare const ReactMediaSingleNode: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined, dispatchAnalyticsEvent?: DispatchAnalyticsEvent, mediaOptions?: MediaOptions) => (node: PMNode, view: EditorView, getPos: getPosHandler) => MediaSingleNodeView;
62
+ export {};
@@ -0,0 +1,7 @@
1
+ export declare const messages: {
2
+ mediaGroupDeleteLabel: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ };
@@ -0,0 +1,16 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { jsx } from '@emotion/react';
4
+ import type { NumericalCardDimensions } from '@atlaskit/media-card';
5
+ export declare const MediaInlineNodeSelector = "media-inline-node";
6
+ export declare const MediaSingleNodeSelector = "media-single-node";
7
+ export declare const figureWrapper: import("@emotion/react").SerializedStyles;
8
+ type MediaCardWrapperProps = {
9
+ dimensions: NumericalCardDimensions;
10
+ children: React.ReactNode;
11
+ selected?: boolean;
12
+ borderWidth?: number;
13
+ onContextMenu?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
14
+ };
15
+ export declare const MediaCardWrapper: ({ dimensions, children, selected, borderWidth, onContextMenu, }: MediaCardWrapperProps) => jsx.JSX.Element;
16
+ export {};