@atlaskit/editor-plugin-media 0.3.0 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
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
+
10
+ ## 0.3.1
11
+
12
+ ### Patch Changes
13
+
14
+ - [#40750](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40750) [`fc19a7b9edd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fc19a7b9edd) - [ED-19875] Extraction of Editor Core's Selection Plugin into independent package '@atlaskit/editor-plugin-selection'.
15
+ - Updated dependencies
16
+
3
17
  ## 0.3.0
4
18
 
5
19
  ### Minor Changes
@@ -153,7 +153,7 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
153
153
  name: 'mediaKeymap',
154
154
  plugin: function plugin() {
155
155
  var _api$analytics2;
156
- return (0, _keymap2.default)(options, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
156
+ return (0, _keymap2.default)(options, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : api.selection.actions);
157
157
  }
158
158
  }];
159
159
  if (options && options.allowMediaSingle) {
@@ -12,7 +12,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
12
12
  var _mediaCommon = require("@atlaskit/media-common");
13
13
  var _captions = require("../commands/captions");
14
14
  var _pluginKey = require("../pm-plugins/plugin-key");
15
- function keymapPlugin(options, editorAnalyticsAPI) {
15
+ function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI) {
16
16
  var list = {};
17
17
  var _ref = options || {},
18
18
  featureFlags = _ref.featureFlags;
@@ -21,8 +21,8 @@ function keymapPlugin(options, editorAnalyticsAPI) {
21
21
  if (options !== null && options !== void 0 && options.allowCaptions || (0, _mediaCommon.getMediaFeatureFlag)('captions', featureFlags)) {
22
22
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.moveDown.common, insertAndSelectCaption(editorAnalyticsAPI), list);
23
23
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.tab.common, insertAndSelectCaption(editorAnalyticsAPI), list);
24
- (0, _keymaps.bindKeymapWithCommand)(_keymaps.moveLeft.common, arrowLeftFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
25
- (0, _keymaps.bindKeymapWithCommand)(_keymaps.moveRight.common, arrowRightFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
24
+ (0, _keymaps.bindKeymapWithCommand)(_keymaps.moveLeft.common, arrowLeftFromMediaSingle(editorSelectionAPI), list);
25
+ (0, _keymaps.bindKeymapWithCommand)(_keymaps.moveRight.common, arrowRightFromMediaSingle(editorSelectionAPI), list);
26
26
  }
27
27
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.insertNewLine.common, splitMediaGroup, list);
28
28
  return (0, _keymap.keymap)(list);
@@ -57,7 +57,7 @@ var arrowLeftFromMediaSingle = function arrowLeftFromMediaSingle(editorSelection
57
57
  return function (state, dispatch) {
58
58
  var selection = state.selection;
59
59
  if (editorSelectionAPI && selection instanceof _state.NodeSelection && selection.node.type.name === 'mediaSingle') {
60
- var tr = editorSelectionAPI.setSelectionRelativeToNode({
60
+ var tr = editorSelectionAPI.selectNearNode({
61
61
  selectionRelativeToNode: undefined,
62
62
  selection: new _selection.GapCursorSelection(state.doc.resolve(selection.from), _selection.Side.LEFT)
63
63
  })(state);
@@ -73,7 +73,7 @@ var arrowRightFromMediaSingle = function arrowRightFromMediaSingle(editorSelecti
73
73
  return function (state, dispatch) {
74
74
  var selection = state.selection;
75
75
  if (editorSelectionAPI && selection instanceof _state.NodeSelection && selection.node.type.name === 'mediaSingle') {
76
- var tr = editorSelectionAPI.setSelectionRelativeToNode({
76
+ var tr = editorSelectionAPI.selectNearNode({
77
77
  selectionRelativeToNode: undefined,
78
78
  selection: new _selection.GapCursorSelection(state.doc.resolve(selection.to), _selection.Side.RIGHT)
79
79
  })(state);
@@ -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() {
@@ -144,7 +144,7 @@ export const mediaPlugin = ({
144
144
  name: 'mediaKeymap',
145
145
  plugin: () => {
146
146
  var _api$analytics2;
147
- return keymapPlugin(options, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
147
+ return keymapPlugin(options, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : api.selection.actions);
148
148
  }
149
149
  }];
150
150
  if (options && options.allowMediaSingle) {
@@ -5,7 +5,7 @@ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
6
6
  import { insertAndSelectCaptionFromMediaSinglePos, selectCaptionFromMediaSinglePos } from '../commands/captions';
7
7
  import { stateKey } from '../pm-plugins/plugin-key';
8
- export function keymapPlugin(options, editorAnalyticsAPI) {
8
+ export function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI) {
9
9
  const list = {};
10
10
  const {
11
11
  featureFlags
@@ -15,8 +15,8 @@ export function keymapPlugin(options, editorAnalyticsAPI) {
15
15
  if (options !== null && options !== void 0 && options.allowCaptions || getMediaFeatureFlag('captions', featureFlags)) {
16
16
  bindKeymapWithCommand(moveDown.common, insertAndSelectCaption(editorAnalyticsAPI), list);
17
17
  bindKeymapWithCommand(tab.common, insertAndSelectCaption(editorAnalyticsAPI), list);
18
- bindKeymapWithCommand(moveLeft.common, arrowLeftFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
19
- bindKeymapWithCommand(moveRight.common, arrowRightFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
18
+ bindKeymapWithCommand(moveLeft.common, arrowLeftFromMediaSingle(editorSelectionAPI), list);
19
+ bindKeymapWithCommand(moveRight.common, arrowRightFromMediaSingle(editorSelectionAPI), list);
20
20
  }
21
21
  bindKeymapWithCommand(insertNewLine.common, splitMediaGroup, list);
22
22
  return keymap(list);
@@ -54,7 +54,7 @@ const arrowLeftFromMediaSingle = editorSelectionAPI => (state, dispatch) => {
54
54
  selection
55
55
  } = state;
56
56
  if (editorSelectionAPI && selection instanceof NodeSelection && selection.node.type.name === 'mediaSingle') {
57
- const tr = editorSelectionAPI.setSelectionRelativeToNode({
57
+ const tr = editorSelectionAPI.selectNearNode({
58
58
  selectionRelativeToNode: undefined,
59
59
  selection: new GapCursorSelection(state.doc.resolve(selection.from), Side.LEFT)
60
60
  })(state);
@@ -70,7 +70,7 @@ const arrowRightFromMediaSingle = editorSelectionAPI => (state, dispatch) => {
70
70
  selection
71
71
  } = state;
72
72
  if (editorSelectionAPI && selection instanceof NodeSelection && selection.node.type.name === 'mediaSingle') {
73
- const tr = editorSelectionAPI.setSelectionRelativeToNode({
73
+ const tr = editorSelectionAPI.selectNearNode({
74
74
  selectionRelativeToNode: undefined,
75
75
  selection: new GapCursorSelection(state.doc.resolve(selection.to), Side.RIGHT)
76
76
  })(state);
@@ -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 = () => {
@@ -142,7 +142,7 @@ export var mediaPlugin = function mediaPlugin(_ref2) {
142
142
  name: 'mediaKeymap',
143
143
  plugin: function plugin() {
144
144
  var _api$analytics2;
145
- return keymapPlugin(options, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
145
+ return keymapPlugin(options, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : api.selection.actions);
146
146
  }
147
147
  }];
148
148
  if (options && options.allowMediaSingle) {
@@ -5,7 +5,7 @@ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
6
6
  import { insertAndSelectCaptionFromMediaSinglePos, selectCaptionFromMediaSinglePos } from '../commands/captions';
7
7
  import { stateKey } from '../pm-plugins/plugin-key';
8
- export function keymapPlugin(options, editorAnalyticsAPI) {
8
+ export function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI) {
9
9
  var list = {};
10
10
  var _ref = options || {},
11
11
  featureFlags = _ref.featureFlags;
@@ -14,8 +14,8 @@ export function keymapPlugin(options, editorAnalyticsAPI) {
14
14
  if (options !== null && options !== void 0 && options.allowCaptions || getMediaFeatureFlag('captions', featureFlags)) {
15
15
  bindKeymapWithCommand(moveDown.common, insertAndSelectCaption(editorAnalyticsAPI), list);
16
16
  bindKeymapWithCommand(tab.common, insertAndSelectCaption(editorAnalyticsAPI), list);
17
- bindKeymapWithCommand(moveLeft.common, arrowLeftFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
18
- bindKeymapWithCommand(moveRight.common, arrowRightFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
17
+ bindKeymapWithCommand(moveLeft.common, arrowLeftFromMediaSingle(editorSelectionAPI), list);
18
+ bindKeymapWithCommand(moveRight.common, arrowRightFromMediaSingle(editorSelectionAPI), list);
19
19
  }
20
20
  bindKeymapWithCommand(insertNewLine.common, splitMediaGroup, list);
21
21
  return keymap(list);
@@ -50,7 +50,7 @@ var arrowLeftFromMediaSingle = function arrowLeftFromMediaSingle(editorSelection
50
50
  return function (state, dispatch) {
51
51
  var selection = state.selection;
52
52
  if (editorSelectionAPI && selection instanceof NodeSelection && selection.node.type.name === 'mediaSingle') {
53
- var tr = editorSelectionAPI.setSelectionRelativeToNode({
53
+ var tr = editorSelectionAPI.selectNearNode({
54
54
  selectionRelativeToNode: undefined,
55
55
  selection: new GapCursorSelection(state.doc.resolve(selection.from), Side.LEFT)
56
56
  })(state);
@@ -66,7 +66,7 @@ var arrowRightFromMediaSingle = function arrowRightFromMediaSingle(editorSelecti
66
66
  return function (state, dispatch) {
67
67
  var selection = state.selection;
68
68
  if (editorSelectionAPI && selection instanceof NodeSelection && selection.node.type.name === 'mediaSingle') {
69
- var tr = editorSelectionAPI.setSelectionRelativeToNode({
69
+ var tr = editorSelectionAPI.selectNearNode({
70
70
  selectionRelativeToNode: undefined,
71
71
  selection: new GapCursorSelection(state.doc.resolve(selection.to), Side.RIGHT)
72
72
  })(state);
@@ -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,6 +7,7 @@ import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-too
7
7
  import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
8
8
  import type { GridPlugin } from '@atlaskit/editor-plugin-grid';
9
9
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
10
+ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
10
11
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
11
12
  import type { MediaPluginState } from './pm-plugins/types';
12
13
  import type { MediaOptions } from './types';
@@ -22,7 +23,8 @@ export type MediaNextEditorPluginType = NextEditorPlugin<'media', {
22
23
  DecorationsPlugin,
23
24
  FloatingToolbarPlugin,
24
25
  EditorDisabledPlugin,
25
- FocusPlugin
26
+ FocusPlugin,
27
+ SelectionPlugin
26
28
  ];
27
29
  sharedState: MediaPluginState | null;
28
30
  actions: {
@@ -1,5 +1,6 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
2
  import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import type { EditorSelectionAPI } from '@atlaskit/editor-plugin-selection';
3
4
  import type { MediaOptions } from '../types';
4
- export declare function keymapPlugin(options: MediaOptions | undefined, editorAnalyticsAPI: EditorAnalyticsAPI | undefined): SafePlugin;
5
+ export declare function keymapPlugin(options: MediaOptions | undefined, editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorSelectionAPI: EditorSelectionAPI | undefined): SafePlugin;
5
6
  export default keymapPlugin;
@@ -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;
@@ -7,6 +7,7 @@ import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-too
7
7
  import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
8
8
  import type { GridPlugin } from '@atlaskit/editor-plugin-grid';
9
9
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
10
+ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
10
11
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
11
12
  import type { MediaPluginState } from './pm-plugins/types';
12
13
  import type { MediaOptions } from './types';
@@ -22,7 +23,8 @@ export type MediaNextEditorPluginType = NextEditorPlugin<'media', {
22
23
  DecorationsPlugin,
23
24
  FloatingToolbarPlugin,
24
25
  EditorDisabledPlugin,
25
- FocusPlugin
26
+ FocusPlugin,
27
+ SelectionPlugin
26
28
  ];
27
29
  sharedState: MediaPluginState | null;
28
30
  actions: {
@@ -1,5 +1,6 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
2
  import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import type { EditorSelectionAPI } from '@atlaskit/editor-plugin-selection';
3
4
  import type { MediaOptions } from '../types';
4
- export declare function keymapPlugin(options: MediaOptions | undefined, editorAnalyticsAPI: EditorAnalyticsAPI | undefined): SafePlugin;
5
+ export declare function keymapPlugin(options: MediaOptions | undefined, editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorSelectionAPI: EditorSelectionAPI | undefined): SafePlugin;
5
6
  export default keymapPlugin;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -36,7 +36,7 @@
36
36
  "@atlaskit/analytics-namespaced-context": "^6.7.0",
37
37
  "@atlaskit/analytics-next": "^9.1.0",
38
38
  "@atlaskit/button": "^16.10.0",
39
- "@atlaskit/editor-common": "^76.6.0",
39
+ "@atlaskit/editor-common": "^76.9.0",
40
40
  "@atlaskit/editor-palette": "1.5.1",
41
41
  "@atlaskit/editor-plugin-analytics": "^0.2.0",
42
42
  "@atlaskit/editor-plugin-decorations": "^0.2.0",
@@ -62,7 +62,7 @@
62
62
  "@atlaskit/platform-feature-flags": "^0.2.0",
63
63
  "@atlaskit/textfield": "^5.6.0",
64
64
  "@atlaskit/theme": "^12.6.0",
65
- "@atlaskit/tokens": "^1.22.0",
65
+ "@atlaskit/tokens": "^1.26.0",
66
66
  "@atlaskit/tooltip": "^17.8.0",
67
67
  "@babel/runtime": "^7.0.0",
68
68
  "@emotion/react": "^11.7.1",
package/report.api.md CHANGED
@@ -43,6 +43,7 @@ import type { OptionalPlugin } from '@atlaskit/editor-common/types';
43
43
  import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
44
44
  import type { Providers } from '@atlaskit/editor-common/provider-factory';
45
45
  import type { RichMediaLayout } from '@atlaskit/adf-schema';
46
+ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
46
47
  import type { UploadEndEventPayload } from '@atlaskit/media-picker/types';
47
48
  import type { UploadErrorEventPayload } from '@atlaskit/media-picker/types';
48
49
  import type { UploadParams } from '@atlaskit/media-picker/types';
@@ -164,6 +165,7 @@ export type MediaPlugin = NextEditorPlugin<
164
165
  FloatingToolbarPlugin,
165
166
  EditorDisabledPlugin,
166
167
  FocusPlugin,
168
+ SelectionPlugin,
167
169
  ];
168
170
  sharedState: MediaPluginState | null;
169
171
  actions: {
@@ -32,6 +32,7 @@ import type { OptionalPlugin } from '@atlaskit/editor-common/types';
32
32
  import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
33
33
  import type { Providers } from '@atlaskit/editor-common/provider-factory';
34
34
  import type { RichMediaLayout } from '@atlaskit/adf-schema';
35
+ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
35
36
  import type { UploadEndEventPayload } from '@atlaskit/media-picker/types';
36
37
  import type { UploadErrorEventPayload } from '@atlaskit/media-picker/types';
37
38
  import type { UploadParams } from '@atlaskit/media-picker/types';
@@ -146,7 +147,8 @@ export type MediaPlugin = NextEditorPlugin<'media', {
146
147
  DecorationsPlugin,
147
148
  FloatingToolbarPlugin,
148
149
  EditorDisabledPlugin,
149
- FocusPlugin
150
+ FocusPlugin,
151
+ SelectionPlugin
150
152
  ];
151
153
  sharedState: MediaPluginState | null;
152
154
  actions: {