@atlaskit/editor-core 187.44.2 → 187.44.4

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 (94) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/plugins/expand/pm-plugins/keymap.js +2 -2
  3. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +3 -1
  4. package/dist/cjs/plugins/media/pm-plugins/keymap-media-single.js +2 -2
  5. package/dist/cjs/plugins/media/pm-plugins/main.js +1 -2
  6. package/dist/cjs/plugins/media/toolbar/index.js +2 -2
  7. package/dist/cjs/plugins/media/ui/CaptionPlaceholder/index.js +4 -5
  8. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +17 -24
  9. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/index.js +17 -24
  10. package/dist/cjs/plugins/media/utils/media-common.js +7 -8
  11. package/dist/cjs/plugins/media/utils/media-files.js +6 -6
  12. package/dist/cjs/plugins/media/utils/media-single.js +2 -2
  13. package/dist/cjs/plugins/placeholder-text/index.js +1 -1
  14. package/dist/cjs/plugins/selection/commands.js +2 -3
  15. package/dist/cjs/plugins/selection/gap-cursor/actions.js +10 -11
  16. package/dist/cjs/plugins/selection/gap-cursor/utils.js +3 -3
  17. package/dist/cjs/plugins/selection/plugin-factory.js +5 -5
  18. package/dist/cjs/plugins/selection/pm-plugins/keymap.js +1 -1
  19. package/dist/cjs/plugins/selection/utils.js +1 -2
  20. package/dist/cjs/utils/commands.js +2 -22
  21. package/dist/cjs/utils/document.js +0 -20
  22. package/dist/cjs/utils/index.js +0 -6
  23. package/dist/cjs/version-wrapper.js +1 -1
  24. package/dist/es2019/plugins/expand/pm-plugins/keymap.js +1 -1
  25. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +4 -2
  26. package/dist/es2019/plugins/media/pm-plugins/keymap-media-single.js +1 -1
  27. package/dist/es2019/plugins/media/pm-plugins/main.js +1 -2
  28. package/dist/es2019/plugins/media/toolbar/index.js +3 -3
  29. package/dist/es2019/plugins/media/ui/CaptionPlaceholder/index.js +2 -2
  30. package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +5 -16
  31. package/dist/es2019/plugins/media/ui/ResizableMediaSingle/index.js +5 -16
  32. package/dist/es2019/plugins/media/utils/media-common.js +1 -2
  33. package/dist/es2019/plugins/media/utils/media-files.js +1 -1
  34. package/dist/es2019/plugins/media/utils/media-single.js +1 -1
  35. package/dist/es2019/plugins/placeholder-text/index.js +1 -1
  36. package/dist/es2019/plugins/selection/commands.js +1 -2
  37. package/dist/es2019/plugins/selection/gap-cursor/actions.js +2 -4
  38. package/dist/es2019/plugins/selection/gap-cursor/utils.js +2 -2
  39. package/dist/es2019/plugins/selection/plugin-factory.js +1 -1
  40. package/dist/es2019/plugins/selection/pm-plugins/keymap.js +1 -1
  41. package/dist/es2019/plugins/selection/utils.js +1 -3
  42. package/dist/es2019/utils/commands.js +1 -19
  43. package/dist/es2019/utils/document.js +0 -18
  44. package/dist/es2019/utils/index.js +1 -1
  45. package/dist/es2019/version-wrapper.js +1 -1
  46. package/dist/esm/plugins/expand/pm-plugins/keymap.js +1 -1
  47. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +4 -2
  48. package/dist/esm/plugins/media/pm-plugins/keymap-media-single.js +1 -1
  49. package/dist/esm/plugins/media/pm-plugins/main.js +1 -2
  50. package/dist/esm/plugins/media/toolbar/index.js +3 -3
  51. package/dist/esm/plugins/media/ui/CaptionPlaceholder/index.js +2 -2
  52. package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +17 -24
  53. package/dist/esm/plugins/media/ui/ResizableMediaSingle/index.js +17 -24
  54. package/dist/esm/plugins/media/utils/media-common.js +1 -2
  55. package/dist/esm/plugins/media/utils/media-files.js +1 -1
  56. package/dist/esm/plugins/media/utils/media-single.js +1 -1
  57. package/dist/esm/plugins/placeholder-text/index.js +1 -1
  58. package/dist/esm/plugins/selection/commands.js +1 -2
  59. package/dist/esm/plugins/selection/gap-cursor/actions.js +2 -4
  60. package/dist/esm/plugins/selection/gap-cursor/utils.js +2 -2
  61. package/dist/esm/plugins/selection/plugin-factory.js +1 -1
  62. package/dist/esm/plugins/selection/pm-plugins/keymap.js +1 -1
  63. package/dist/esm/plugins/selection/utils.js +1 -3
  64. package/dist/esm/utils/commands.js +1 -21
  65. package/dist/esm/utils/document.js +0 -20
  66. package/dist/esm/utils/index.js +1 -1
  67. package/dist/esm/version-wrapper.js +1 -1
  68. package/dist/types/plugins/media/ui/CaptionPlaceholder/index.d.ts +0 -1
  69. package/dist/types/plugins/media/utils/media-files.d.ts +1 -2
  70. package/dist/types/plugins/selection/commands.d.ts +2 -2
  71. package/dist/types/plugins/selection/gap-cursor/actions.d.ts +1 -1
  72. package/dist/types/plugins/selection/pm-plugins/selection-main.d.ts +1 -1
  73. package/dist/types/utils/commands.d.ts +2 -12
  74. package/dist/types/utils/document.d.ts +0 -4
  75. package/dist/types/utils/index.d.ts +1 -1
  76. package/dist/types-ts4.5/plugins/media/ui/CaptionPlaceholder/index.d.ts +0 -1
  77. package/dist/types-ts4.5/plugins/media/utils/media-files.d.ts +1 -2
  78. package/dist/types-ts4.5/plugins/selection/commands.d.ts +2 -2
  79. package/dist/types-ts4.5/plugins/selection/gap-cursor/actions.d.ts +1 -1
  80. package/dist/types-ts4.5/plugins/selection/pm-plugins/selection-main.d.ts +1 -1
  81. package/dist/types-ts4.5/utils/commands.d.ts +2 -12
  82. package/dist/types-ts4.5/utils/document.d.ts +0 -4
  83. package/dist/types-ts4.5/utils/index.d.ts +1 -1
  84. package/package.json +2 -2
  85. package/dist/cjs/utils/prosemirror/position.js +0 -42
  86. package/dist/cjs/utils/table.js +0 -28
  87. package/dist/es2019/utils/prosemirror/position.js +0 -1
  88. package/dist/es2019/utils/table.js +0 -22
  89. package/dist/esm/utils/prosemirror/position.js +0 -1
  90. package/dist/esm/utils/table.js +0 -22
  91. package/dist/types/utils/prosemirror/position.d.ts +0 -1
  92. package/dist/types/utils/table.d.ts +0 -2
  93. package/dist/types-ts4.5/utils/prosemirror/position.d.ts +0 -1
  94. package/dist/types-ts4.5/utils/table.d.ts +0 -2
@@ -38,7 +38,6 @@ var _view = require("@atlaskit/editor-prosemirror/view");
38
38
  var _utils = require("@atlaskit/editor-prosemirror/utils");
39
39
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
40
40
  var _selection = require("@atlaskit/editor-common/selection");
41
- var _commands = require("../../utils/commands");
42
41
  var _utils2 = require("@atlaskit/editor-common/utils");
43
42
  var _isIgnored = require("../selection/gap-cursor/utils/is-ignored");
44
43
  var _types = require("./types");
@@ -52,7 +51,7 @@ function createSelectionClickHandler(nodes, isValidTarget, options) {
52
51
  var _target = event.target;
53
52
  if (isValidTarget(_target)) {
54
53
  var selectionPos = options.getNodeSelectionPos ? options.getNodeSelectionPos(view.state, nodePos) : nodePos;
55
- (0, _commands.selectNode)(selectionPos)(view.state, view.dispatch);
54
+ (0, _selection.selectNode)(selectionPos)(view.state, view.dispatch);
56
55
  return true;
57
56
  }
58
57
  }
@@ -3,8 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.withScrollIntoView = exports.selectNode = exports.isNthParentOfType = void 0;
7
- var _state = require("@atlaskit/editor-prosemirror/state");
6
+ exports.withScrollIntoView = exports.isNthParentOfType = void 0;
8
7
  /**
9
8
  * Creates a filter that checks if the node at a given number of parents above the current
10
9
  * selection is of the correct node type.
@@ -31,23 +30,4 @@ var withScrollIntoView = function withScrollIntoView(command) {
31
30
  }, view);
32
31
  };
33
32
  };
34
-
35
- /**
36
- * Insert content, delete a range and create a new selection
37
- * This function automatically handles the mapping of positions for insertion and deletion.
38
- * The new selection is handled as a function since it may not always be necessary to resolve a position to the transactions mapping
39
- *
40
- * @param getSelectionResolvedPos get the resolved position to create a new selection
41
- * @param insertions content to insert at the specified position
42
- * @param deletions the ranges to delete
43
- */
44
- exports.withScrollIntoView = withScrollIntoView;
45
- var selectNode = function selectNode(pos) {
46
- return function (state, dispatch) {
47
- if (dispatch) {
48
- dispatch(state.tr.setSelection(new _state.NodeSelection(state.doc.resolve(pos))));
49
- }
50
- return true;
51
- };
52
- };
53
- exports.selectNode = selectNode;
33
+ exports.withScrollIntoView = withScrollIntoView;
@@ -15,32 +15,12 @@ exports.getChangedNodesIn = getChangedNodesIn;
15
15
  exports.getChildBreakoutModes = getChildBreakoutModes;
16
16
  exports.getNodesCount = getNodesCount;
17
17
  exports.isInEmptyLine = isInEmptyLine;
18
- exports.isNodeEmpty = isNodeEmpty;
19
18
  exports.nodesBetweenChanged = nodesBetweenChanged;
20
19
  exports.processRawFragmentValue = processRawFragmentValue;
21
20
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
22
21
  var _model = require("@atlaskit/editor-prosemirror/model");
23
22
  var _nodeWidth = require("./node-width");
24
23
  var _utils = require("@atlaskit/editor-common/utils");
25
- /**
26
- * Checks if a node has any content. Ignores node that only contain empty block nodes.
27
- */
28
- function isNodeEmpty(node) {
29
- if (node && node.textContent) {
30
- return false;
31
- }
32
- if (!node || !node.childCount || node.childCount === 1 && (0, _utils.isEmptyParagraph)(node.firstChild)) {
33
- return true;
34
- }
35
- var block = [];
36
- var nonBlock = [];
37
- node.forEach(function (child) {
38
- child.isInline ? nonBlock.push(child) : block.push(child);
39
- });
40
- return !nonBlock.length && !block.filter(function (childNode) {
41
- return !!childNode.childCount && !(childNode.childCount === 1 && (0, _utils.isEmptyParagraph)(childNode.firstChild)) || childNode.isAtom;
42
- }).length;
43
- }
44
24
  function isInEmptyLine(state) {
45
25
  var selection = state.selection;
46
26
  var _ref = selection,
@@ -75,12 +75,6 @@ Object.defineProperty(exports, "isLinkMark", {
75
75
  }
76
76
  });
77
77
  exports.isMarkTypeAllowedInCurrentSelection = isMarkTypeAllowedInCurrentSelection;
78
- Object.defineProperty(exports, "isNodeEmpty", {
79
- enumerable: true,
80
- get: function get() {
81
- return _document.isNodeEmpty;
82
- }
83
- });
84
78
  Object.defineProperty(exports, "isParagraph", {
85
79
  enumerable: true,
86
80
  get: function get() {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "187.44.2";
9
+ var version = "187.44.4";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -8,7 +8,7 @@ import { expandClassNames } from '../ui/class-names';
8
8
  import { deleteExpand, focusTitle } from '../commands';
9
9
  import { getPluginState as getSelectionPluginState } from '../../selection/plugin-factory';
10
10
  import { RelativeSelectionPos } from '../../selection/types';
11
- import { isPositionNearTableRow } from '../../../utils/table';
11
+ import { isPositionNearTableRow } from '@atlaskit/editor-common/utils';
12
12
  const isExpandNode = node => {
13
13
  return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
14
14
  };
@@ -23,7 +23,7 @@ import CaptionPlaceholder from '../ui/CaptionPlaceholder';
23
23
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
24
24
  import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
25
25
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
26
- import { calcMediaSinglePixelWidth, MEDIA_SINGLE_GUTTER_SIZE, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, getMaxWidthForNestedNode, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
26
+ import { calcMediaSinglePixelWidth, MEDIA_SINGLE_GUTTER_SIZE, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, getMaxWidthForNestedNode } from '@atlaskit/editor-common/media-single';
27
27
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
28
28
  export default class MediaSingleNode extends Component {
29
29
  constructor(...args) {
@@ -201,6 +201,7 @@ export default class MediaSingleNode extends Component {
201
201
  });
202
202
  }
203
203
  render() {
204
+ var _pluginInjectionApi$m;
204
205
  const {
205
206
  selected,
206
207
  getPos,
@@ -257,8 +258,9 @@ export default class MediaSingleNode extends Component {
257
258
  height = DEFAULT_IMAGE_HEIGHT;
258
259
  }
259
260
  const isSelected = selected();
261
+ const currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth : undefined;
260
262
  const contentWidthForLegacyExperience = getMaxWidthForNestedNode(view, getPos()) || lineLength;
261
- const contentWidth = getMaxWidthForNestedNodeNext(view, getPos()) || lineLength;
263
+ const contentWidth = currentMaxWidth || lineLength;
262
264
  const mediaSingleProps = {
263
265
  layout,
264
266
  width,
@@ -3,7 +3,7 @@ import { bindKeymapWithCommand, backspace } from '@atlaskit/editor-common/keymap
3
3
  import { isEmptyNode, isSelectionInsideLastNodeInDocument } from '../../../utils';
4
4
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { selectNodeBackward } from '@atlaskit/editor-prosemirror/commands';
6
- import { atTheEndOfDoc } from '../../../utils/prosemirror/position';
6
+ import { atTheEndOfDoc } from '@atlaskit/editor-common/selection';
7
7
 
8
8
  /**
9
9
  * Check if is an empty selection at the start of the node
@@ -20,11 +20,10 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
20
20
  import { isInEmptyLine } from '../../../utils/document';
21
21
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
22
22
  import { isInListItem } from '../../../utils';
23
- import { CAPTION_PLACEHOLDER_ID } from '../ui/CaptionPlaceholder';
24
23
  import { RawIntlProvider } from 'react-intl-next';
25
24
  import { MediaTaskManager } from './mediaTaskManager';
26
25
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
27
- import { getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
26
+ import { getMaxWidthForNestedNodeNext, CAPTION_PLACEHOLDER_ID } from '@atlaskit/editor-common/media-single';
28
27
  export { stateKey } from './plugin-key';
29
28
  export const MEDIA_CONTENT_WRAP_CLASS_NAME = 'media-content-wrap';
30
29
  export const MEDIA_PLUGIN_IS_RESIZING_KEY = 'mediaSinglePlugin.isResizing';
@@ -26,7 +26,7 @@ import ImageBorderItem from '../ui/ImageBorder';
26
26
  import { currentMediaNodeBorderMark } from '../utils/current-media-node';
27
27
  import { shouldShowImageBorder } from './imageBorder';
28
28
  import { PixelEntry, FullWidthDisplay } from '../ui/PixelEntry';
29
- import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, calcMinWidth, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
29
+ import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, calcMinWidth } from '@atlaskit/editor-common/media-single';
30
30
  import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
31
31
  const remove = (state, dispatch) => {
32
32
  if (dispatch) {
@@ -266,7 +266,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
266
266
  type: 'custom',
267
267
  fallback: [],
268
268
  render: editorView => {
269
- var _widthPlugin$sharedSt2;
269
+ var _widthPlugin$sharedSt2, _pluginInjectionApi$m;
270
270
  if (!editorView || !selectedMediaSingleNode) {
271
271
  return null;
272
272
  }
@@ -288,7 +288,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
288
288
  width: mediaWidth,
289
289
  height: mediaHeight
290
290
  } = selectedMediaNode.attrs;
291
- const maxWidthForNestedNode = getMaxWidthForNestedNodeNext(editorView, selectedMediaSingleNode.pos);
291
+ const maxWidthForNestedNode = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth;
292
292
  const maxWidth = maxWidthForNestedNode || akEditorFullWidthLayoutWidth;
293
293
  const isVideoFile = isVideo(selectedMediaNode.attrs.__fileMimeType);
294
294
  const minWidth = calcMinWidth(isVideoFile, maxWidthForNestedNode || contentWidth);
@@ -4,14 +4,14 @@ import { css, jsx } from '@emotion/react';
4
4
  import { FormattedMessage } from 'react-intl-next';
5
5
  import { N200 } from '@atlaskit/theme/colors';
6
6
  import { messages } from './messages';
7
+ import { CAPTION_PLACEHOLDER_ID } from '@atlaskit/editor-common/media-single';
7
8
  const placeholder = css`
8
9
  color: ${`var(--ds-text-subtlest, ${N200})`};
9
10
  width: 100%;
10
11
  text-align: center;
11
- margin-top: 8px !important;
12
+ margin-top: ${"var(--ds-space-100, 8px)"} !important;
12
13
  display: block;
13
14
  `;
14
- export const CAPTION_PLACEHOLDER_ID = 'caption-placeholder';
15
15
  export default /*#__PURE__*/React.forwardRef(({
16
16
  onClick
17
17
  }, ref) => {
@@ -3,7 +3,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import React from 'react';
4
4
  import { jsx } from '@emotion/react';
5
5
  import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
6
- import { getMediaClient } from '@atlaskit/media-client';
7
6
  import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap } from '@atlaskit/editor-common/ui';
8
7
  import { nonWrappedLayouts, setNodeSelection } from '@atlaskit/editor-common/utils';
9
8
  import { akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
@@ -18,6 +17,7 @@ import { getMediaResizeAnalyticsEvent } from '../../utils/analytics';
18
17
  import throttle from 'lodash/throttle';
19
18
  import { MEDIA_PLUGIN_IS_RESIZING_KEY, MEDIA_PLUGIN_RESIZING_WIDTH_KEY } from '../../pm-plugins/main';
20
19
  import { ResizableMediaMigrationNotification } from './ResizableMediaMigrationNotification';
20
+ import { checkMediaType } from '../../utils/check-media-type';
21
21
  export const resizerNextTestId = 'mediaSingle.resizerNext.testid';
22
22
  class ResizableMediaSingleNext extends React.Component {
23
23
  constructor(props) {
@@ -374,22 +374,11 @@ class ResizableMediaSingleNext extends React.Component {
374
374
  return;
375
375
  }
376
376
  const mediaNode = this.props.view.state.doc.nodeAt(this.pos + 1);
377
- if (!mediaNode || !mediaNode.attrs.id) {
378
- return;
379
- }
380
- const mediaClient = getMediaClient(viewMediaClientConfig);
381
- try {
382
- const state = await mediaClient.file.getCurrentState(mediaNode.attrs.id, {
383
- collectionName: mediaNode.attrs.collection
384
- });
385
- if (state && state.status !== 'error' && state.mediaType === 'image') {
386
- this.setState({
387
- isVideoFile: false
388
- });
389
- }
390
- } catch (err) {
377
+ const mediaType = mediaNode ? await checkMediaType(mediaNode, viewMediaClientConfig) : undefined;
378
+ const isVideoFile = mediaType !== 'external' && mediaType !== 'image';
379
+ if (this.state.isVideoFile !== isVideoFile) {
391
380
  this.setState({
392
- isVideoFile: false
381
+ isVideoFile
393
382
  });
394
383
  }
395
384
  }
@@ -4,12 +4,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import React from 'react';
5
5
  import { jsx } from '@emotion/react';
6
6
  import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
- import { getMediaClient } from '@atlaskit/media-client';
8
7
  import { calcPctFromPx, calcColumnsFromPx, wrappedLayouts, Resizer, calcMediaPxWidth, snapTo, handleSides, imageAlignmentMap } from '@atlaskit/editor-common/ui';
9
8
  import { akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
10
9
  import { wrapperStyle } from './styled';
11
10
  import { calculateOffsetLeft } from '@atlaskit/editor-common/media-single';
12
11
  import { calculateSnapPoints } from '@atlaskit/editor-common/utils';
12
+ import { checkMediaType } from '../../utils/check-media-type';
13
13
  export default class ResizableMediaSingle extends React.Component {
14
14
  constructor(...args) {
15
15
  super(...args);
@@ -193,22 +193,11 @@ export default class ResizableMediaSingle extends React.Component {
193
193
  return;
194
194
  }
195
195
  const mediaNode = this.props.view.state.doc.nodeAt($pos.pos + 1);
196
- if (!mediaNode || !mediaNode.attrs.id) {
197
- return;
198
- }
199
- const mediaClient = getMediaClient(viewMediaClientConfig);
200
- try {
201
- const state = await mediaClient.file.getCurrentState(mediaNode.attrs.id, {
202
- collectionName: mediaNode.attrs.collection
203
- });
204
- if (state && state.status !== 'error' && state.mediaType === 'image') {
205
- this.setState({
206
- isVideoFile: false
207
- });
208
- }
209
- } catch (err) {
196
+ const mediaType = mediaNode ? await checkMediaType(mediaNode, viewMediaClientConfig) : undefined;
197
+ const isVideoFile = mediaType !== 'external' && mediaType !== 'image';
198
+ if (this.state.isVideoFile !== isVideoFile) {
210
199
  this.setState({
211
- isVideoFile: false
200
+ isVideoFile
212
201
  });
213
202
  }
214
203
  }
@@ -6,8 +6,7 @@ import { isTemporary } from '../../../utils';
6
6
  import { mapSlice } from '../../../utils/slice';
7
7
  import { walkUpTreeUntil, removeNestedEmptyEls, unwrap } from '../../../utils/dom';
8
8
  import { isImage } from './is-image';
9
- import { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, endPositionOfParent, startPositionOfParent } from '../../../utils/prosemirror/position';
10
- import { GapCursorSelection } from '@atlaskit/editor-common/selection';
9
+ import { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, endPositionOfParent, startPositionOfParent, GapCursorSelection } from '@atlaskit/editor-common/selection';
11
10
  import { isMediaBlobUrl } from '@atlaskit/media-client';
12
11
  export const isMediaBlobUrlFromAttrs = attrs => {
13
12
  return !!(attrs && attrs.type === 'external' && isMediaBlobUrl(attrs.url));
@@ -3,7 +3,7 @@ import { setNodeSelection, setTextSelection, insideTableCell, isInListItem, find
3
3
  import { isInLayoutColumn, isSupportedInParent } from '@atlaskit/editor-common/utils';
4
4
  import { posOfPrecedingMediaGroup, posOfMediaGroupNearby, posOfParentMediaGroup, isSelectionNonMediaBlockNode, isInsidePotentialEmptyParagraph, copyOptionalAttrsFromMediaState } from './media-common';
5
5
  import { canInsert, safeInsert, hasParentNode } from '@atlaskit/editor-prosemirror/utils';
6
- import { atTheBeginningOfBlock, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, startPositionOfParent } from '../../../utils/prosemirror/position';
6
+ import { atTheBeginningOfBlock, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, startPositionOfParent } from '@atlaskit/editor-common/selection';
7
7
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
8
8
  export const canInsertMediaInline = state => {
9
9
  const node = state.schema.nodes.mediaInline.create({});
@@ -8,7 +8,7 @@ import { mapSlice } from '../../../utils/slice';
8
8
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
9
9
  import { safeInsert, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
10
10
  import { isImage } from './is-image';
11
- import { atTheBeginningOfBlock } from '../../../utils/prosemirror/position';
11
+ import { atTheBeginningOfBlock } from '@atlaskit/editor-common/selection';
12
12
  import { getRandomHex } from '@atlaskit/media-common';
13
13
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
14
14
  const getInsertMediaAnalytics = (inputMethod, fileExtension) => ({
@@ -4,7 +4,7 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
4
4
  import { placeholder } from '@atlaskit/adf-schema';
5
5
  import MediaServicesTextIcon from '@atlaskit/icon/glyph/media-services/text';
6
6
  import WithPluginState from '../../ui/WithPluginState';
7
- import { isNodeEmpty } from '../../utils';
7
+ import { isNodeEmpty } from '@atlaskit/editor-common/utils';
8
8
  import { FakeTextCursorSelection } from '../fake-text-cursor/cursor';
9
9
  import PlaceholderFloatingToolbar from './ui/PlaceholderFloatingToolbar';
10
10
  import { hidePlaceholderFloatingToolbar, insertPlaceholderTextAtSelection } from './actions';
@@ -1,8 +1,7 @@
1
1
  import { NodeSelection, TextSelection, Selection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { GapCursorSelection, Side } from './gap-cursor-selection';
3
3
  import { isIgnored as isIgnoredByGapCursor } from '../selection/gap-cursor/utils/is-ignored';
4
- import { isNodeEmpty } from '../../utils/document';
5
- import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
4
+ import { isNodeEmpty, isEmptyParagraph } from '@atlaskit/editor-common/utils';
6
5
  import { SelectionActionTypes } from './actions';
7
6
  import { createCommand, getPluginState } from './plugin-factory';
8
7
  import { isSelectableContainerNode, isSelectionAtEndOfParentNode, findSelectableContainerParent, isSelectionAtStartOfParentNode, findSelectableContainerBefore, findSelectableContainerAfter, findFirstChildNodeToSelect, findLastChildNodeToSelect } from './utils';
@@ -1,14 +1,12 @@
1
1
  import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { findDomRefAtPos, findPositionOfNodeBefore, removeNodeBefore } from '@atlaskit/editor-prosemirror/utils';
3
- import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
4
3
  import { Direction, isBackward, isForward } from './direction';
5
4
  import { GapCursorSelection, Side } from './selection';
6
5
  import { isTextBlockNearPos } from './utils';
7
6
  import { isValidTargetNode } from './utils/is-valid-target-node';
8
- import { atTheBeginningOfDoc, atTheEndOfDoc } from '../../../utils/prosemirror/position';
7
+ import { atTheBeginningOfDoc, atTheEndOfDoc } from '@atlaskit/editor-common/selection';
9
8
  import { gapCursorPluginKey } from '../pm-plugins/gap-cursor-plugin-key';
10
- import { isPositionNearTableRow } from '../../../utils/table';
11
- import { isMediaNode, isNodeBeforeMediaNode } from '@atlaskit/editor-common/utils';
9
+ import { ZERO_WIDTH_SPACE, isMediaNode, isNodeBeforeMediaNode, isPositionNearTableRow } from '@atlaskit/editor-common/utils';
12
10
  export const shouldSkipGapCursor = (direction, state, $pos) => {
13
11
  var _$pos$nodeBefore;
14
12
  const {
@@ -1,6 +1,6 @@
1
1
  import { TableSharedCssClassName, UnsupportedSharedCssClassName } from '@atlaskit/editor-common/styles';
2
2
  import { Side } from './selection';
3
- import { CAPTION_PLACEHOLDER_ID } from '../../media/ui/CaptionPlaceholder';
3
+ import { CAPTION_PLACEHOLDER_ID } from '@atlaskit/editor-common/media-single';
4
4
  export const isLeftCursor = side => side === Side.LEFT;
5
5
  export function getMediaNearPos(doc, $pos, schema, dir = -1) {
6
6
  let $currentPos = $pos;
@@ -109,7 +109,7 @@ export const isIgnoredClick = elem => {
109
109
  return false;
110
110
  };
111
111
 
112
- /*
112
+ /*
113
113
  Calculates custom style for breakout mode
114
114
  Mainly to handle table width to include the numbered column width as well
115
115
  */
@@ -1,7 +1,7 @@
1
1
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
3
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
4
- import { pluginFactory } from '../../utils/plugin-state-factory';
4
+ import { pluginFactory } from '@atlaskit/editor-common/utils';
5
5
  import { reducer } from './reducer';
6
6
  import { selectionPluginKey } from './types';
7
7
  import { getDecorations, isSelectableContainerNode } from './utils';
@@ -1,5 +1,5 @@
1
1
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
2
- import { bindKeymapWithCommand, moveRight, moveLeft } from '../../../keymaps';
2
+ import { bindKeymapWithCommand, moveRight, moveLeft } from '@atlaskit/editor-common/keymaps';
3
3
  import { arrowRight, arrowLeft } from '../commands';
4
4
  function keymapPlugin() {
5
5
  const list = {};
@@ -2,12 +2,10 @@ import { NodeSelection, TextSelection, Selection, AllSelection } from '@atlaskit
2
2
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
3
  import { flatten, findParentNode } from '@atlaskit/editor-prosemirror/utils';
4
4
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
5
- import { isSelectionAtStartOfNode, isSelectionAtEndOfNode } from '@atlaskit/editor-common/selection';
6
- import { selectNode } from '../../utils/commands';
5
+ import { isSelectionAtStartOfNode, isSelectionAtEndOfNode, getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, selectNode } from '@atlaskit/editor-common/selection';
7
6
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
8
7
  import { isIgnored as isIgnoredByGapCursor } from '../selection/gap-cursor/utils/is-ignored';
9
8
  import { selectionPluginKey } from './types';
10
- import { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload } from '@atlaskit/editor-common/selection';
11
9
  export function createSelectionClickHandler(nodes, isValidTarget, options) {
12
10
  return function handleClickOn(view, pos, node, nodePos, event, direct) {
13
11
  if (options.useLongPressSelection) {
@@ -1,4 +1,3 @@
1
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
1
  /**
3
2
  * Creates a filter that checks if the node at a given number of parents above the current
4
3
  * selection is of the correct node type.
@@ -22,21 +21,4 @@ const withScrollIntoView = command => (state, dispatch, view) => command(state,
22
21
  dispatch(tr);
23
22
  }
24
23
  }, view);
25
-
26
- /**
27
- * Insert content, delete a range and create a new selection
28
- * This function automatically handles the mapping of positions for insertion and deletion.
29
- * The new selection is handled as a function since it may not always be necessary to resolve a position to the transactions mapping
30
- *
31
- * @param getSelectionResolvedPos get the resolved position to create a new selection
32
- * @param insertions content to insert at the specified position
33
- * @param deletions the ranges to delete
34
- */
35
-
36
- const selectNode = pos => (state, dispatch) => {
37
- if (dispatch) {
38
- dispatch(state.tr.setSelection(new NodeSelection(state.doc.resolve(pos))));
39
- }
40
- return true;
41
- };
42
- export { isNthParentOfType, withScrollIntoView, selectNode };
24
+ export { isNthParentOfType, withScrollIntoView };
@@ -2,24 +2,6 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
2
  import { getBreakoutMode } from './node-width';
3
3
  import { processRawValue, hasDocAsParent, getStepRange, isEmptyParagraph } from '@atlaskit/editor-common/utils';
4
4
  export { findFarthestParentNode } from '@atlaskit/editor-common/utils';
5
-
6
- /**
7
- * Checks if a node has any content. Ignores node that only contain empty block nodes.
8
- */
9
- export function isNodeEmpty(node) {
10
- if (node && node.textContent) {
11
- return false;
12
- }
13
- if (!node || !node.childCount || node.childCount === 1 && isEmptyParagraph(node.firstChild)) {
14
- return true;
15
- }
16
- const block = [];
17
- const nonBlock = [];
18
- node.forEach(child => {
19
- child.isInline ? nonBlock.push(child) : block.push(child);
20
- });
21
- return !nonBlock.length && !block.filter(childNode => !!childNode.childCount && !(childNode.childCount === 1 && isEmptyParagraph(childNode.firstChild)) || childNode.isAtom).length;
22
- }
23
5
  export function isInEmptyLine(state) {
24
6
  const {
25
7
  selection
@@ -4,7 +4,7 @@ import { FakeTextCursorSelection } from '../plugins/fake-text-cursor/cursor';
4
4
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
5
  export { isEmptyNode, isSelectionInsideLastNodeInDocument, checkNodeDown, insideTableCell, isInListItem } from '@atlaskit/editor-common/utils';
6
6
  export { insideTable } from '@atlaskit/editor-common/core-utils';
7
- export { isNodeEmpty, findFarthestParentNode, nodesBetweenChanged, getNodesCount } from './document';
7
+ export { findFarthestParentNode, nodesBetweenChanged, getNodesCount } from './document';
8
8
  export { isParagraph, isText, isLinkMark } from './nodes';
9
9
  export { setNodeSelection, setTextSelection } from './selection';
10
10
  export { default as measurements } from './performance/measure-enum';
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.44.2";
2
+ export const version = "187.44.4";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -8,7 +8,7 @@ import { expandClassNames } from '../ui/class-names';
8
8
  import { deleteExpand, focusTitle } from '../commands';
9
9
  import { getPluginState as getSelectionPluginState } from '../../selection/plugin-factory';
10
10
  import { RelativeSelectionPos } from '../../selection/types';
11
- import { isPositionNearTableRow } from '../../../utils/table';
11
+ import { isPositionNearTableRow } from '@atlaskit/editor-common/utils';
12
12
  var isExpandNode = function isExpandNode(node) {
13
13
  return (node === null || node === void 0 ? void 0 : node.type.name) === 'expand' || (node === null || node === void 0 ? void 0 : node.type.name) === 'nestedExpand';
14
14
  };
@@ -36,7 +36,7 @@ import CaptionPlaceholder from '../ui/CaptionPlaceholder';
36
36
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
37
37
  import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
38
38
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
39
- import { calcMediaSinglePixelWidth, MEDIA_SINGLE_GUTTER_SIZE, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, getMaxWidthForNestedNode, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
39
+ import { calcMediaSinglePixelWidth, MEDIA_SINGLE_GUTTER_SIZE, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, getMaxWidthForNestedNode } from '@atlaskit/editor-common/media-single';
40
40
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
41
41
  var MediaSingleNode = /*#__PURE__*/function (_Component) {
42
42
  _inherits(MediaSingleNode, _Component);
@@ -294,6 +294,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
294
294
  }, {
295
295
  key: "render",
296
296
  value: function render() {
297
+ var _pluginInjectionApi$m;
297
298
  var _this$props2 = this.props,
298
299
  selected = _this$props2.selected,
299
300
  getPos = _this$props2.getPos,
@@ -341,8 +342,9 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
341
342
  height = DEFAULT_IMAGE_HEIGHT;
342
343
  }
343
344
  var isSelected = selected();
345
+ var currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth : undefined;
344
346
  var contentWidthForLegacyExperience = getMaxWidthForNestedNode(view, getPos()) || lineLength;
345
- var contentWidth = getMaxWidthForNestedNodeNext(view, getPos()) || lineLength;
347
+ var contentWidth = currentMaxWidth || lineLength;
346
348
  var mediaSingleProps = {
347
349
  layout: layout,
348
350
  width: width,
@@ -3,7 +3,7 @@ import { bindKeymapWithCommand, backspace } from '@atlaskit/editor-common/keymap
3
3
  import { isEmptyNode, isSelectionInsideLastNodeInDocument } from '../../../utils';
4
4
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { selectNodeBackward } from '@atlaskit/editor-prosemirror/commands';
6
- import { atTheEndOfDoc } from '../../../utils/prosemirror/position';
6
+ import { atTheEndOfDoc } from '@atlaskit/editor-common/selection';
7
7
 
8
8
  /**
9
9
  * Check if is an empty selection at the start of the node
@@ -29,11 +29,10 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
29
29
  import { isInEmptyLine } from '../../../utils/document';
30
30
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
31
31
  import { isInListItem } from '../../../utils';
32
- import { CAPTION_PLACEHOLDER_ID } from '../ui/CaptionPlaceholder';
33
32
  import { RawIntlProvider } from 'react-intl-next';
34
33
  import { MediaTaskManager } from './mediaTaskManager';
35
34
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
36
- import { getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
35
+ import { getMaxWidthForNestedNodeNext, CAPTION_PLACEHOLDER_ID } from '@atlaskit/editor-common/media-single';
37
36
  export { stateKey } from './plugin-key';
38
37
  export var MEDIA_CONTENT_WRAP_CLASS_NAME = 'media-content-wrap';
39
38
  export var MEDIA_PLUGIN_IS_RESIZING_KEY = 'mediaSinglePlugin.isResizing';
@@ -30,7 +30,7 @@ import ImageBorderItem from '../ui/ImageBorder';
30
30
  import { currentMediaNodeBorderMark } from '../utils/current-media-node';
31
31
  import { shouldShowImageBorder } from './imageBorder';
32
32
  import { PixelEntry, FullWidthDisplay } from '../ui/PixelEntry';
33
- import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, calcMinWidth, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
33
+ import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, calcMinWidth } from '@atlaskit/editor-common/media-single';
34
34
  import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
35
35
  var remove = function remove(state, dispatch) {
36
36
  if (dispatch) {
@@ -259,7 +259,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
259
259
  type: 'custom',
260
260
  fallback: [],
261
261
  render: function render(editorView) {
262
- var _widthPlugin$sharedSt2;
262
+ var _widthPlugin$sharedSt2, _pluginInjectionApi$m;
263
263
  if (!editorView || !selectedMediaSingleNode) {
264
264
  return null;
265
265
  }
@@ -277,7 +277,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
277
277
  var _selectedMediaNode$at = selectedMediaNode.attrs,
278
278
  mediaWidth = _selectedMediaNode$at.width,
279
279
  mediaHeight = _selectedMediaNode$at.height;
280
- var maxWidthForNestedNode = getMaxWidthForNestedNodeNext(editorView, selectedMediaSingleNode.pos);
280
+ var maxWidthForNestedNode = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth;
281
281
  var maxWidth = maxWidthForNestedNode || akEditorFullWidthLayoutWidth;
282
282
  var isVideoFile = isVideo(selectedMediaNode.attrs.__fileMimeType);
283
283
  var minWidth = calcMinWidth(isVideoFile, maxWidthForNestedNode || contentWidth);
@@ -6,8 +6,8 @@ import { css, jsx } from '@emotion/react';
6
6
  import { FormattedMessage } from 'react-intl-next';
7
7
  import { N200 } from '@atlaskit/theme/colors';
8
8
  import { messages } from './messages';
9
- var placeholder = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n width: 100%;\n text-align: center;\n margin-top: 8px !important;\n display: block;\n"])), "var(--ds-text-subtlest, ".concat(N200, ")"));
10
- export var CAPTION_PLACEHOLDER_ID = 'caption-placeholder';
9
+ import { CAPTION_PLACEHOLDER_ID } from '@atlaskit/editor-common/media-single';
10
+ var placeholder = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n width: 100%;\n text-align: center;\n margin-top: ", " !important;\n display: block;\n"])), "var(--ds-text-subtlest, ".concat(N200, ")"), "var(--ds-space-100, 8px)");
11
11
  export default /*#__PURE__*/React.forwardRef(function (_ref, ref) {
12
12
  var onClick = _ref.onClick;
13
13
  return jsx("span", {