@atlaskit/editor-core 187.5.5 → 187.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/plugins/media/index.js +1 -1
  3. package/dist/cjs/plugins/media/pm-plugins/main.js +8 -5
  4. package/dist/cjs/plugins/media/utils/media-single.js +23 -5
  5. package/dist/cjs/version-wrapper.js +1 -1
  6. package/dist/cjs/version.json +1 -1
  7. package/dist/es2019/plugins/media/index.js +1 -1
  8. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +1 -2
  9. package/dist/es2019/plugins/media/pm-plugins/main.js +6 -4
  10. package/dist/es2019/plugins/media/utils/media-single.js +21 -5
  11. package/dist/es2019/version-wrapper.js +1 -1
  12. package/dist/es2019/version.json +1 -1
  13. package/dist/esm/plugins/media/index.js +1 -1
  14. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +1 -2
  15. package/dist/esm/plugins/media/pm-plugins/main.js +8 -5
  16. package/dist/esm/plugins/media/utils/media-single.js +23 -5
  17. package/dist/esm/version-wrapper.js +1 -1
  18. package/dist/esm/version.json +1 -1
  19. package/dist/types/plugins/media/index.d.ts +6 -6
  20. package/dist/types/plugins/media/nodeviews/mediaSingle.d.ts +13 -13
  21. package/dist/types/plugins/media/pm-plugins/main.d.ts +19 -14
  22. package/dist/types/plugins/media/utils/media-single.d.ts +9 -7
  23. package/dist/types-ts4.5/plugins/media/index.d.ts +6 -6
  24. package/dist/types-ts4.5/plugins/media/nodeviews/mediaSingle.d.ts +13 -13
  25. package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +19 -14
  26. package/dist/types-ts4.5/plugins/media/utils/media-single.d.ts +9 -7
  27. package/package.json +2 -2
  28. package/report.api.md +4 -2
  29. package/tmp/api-report-tmp.d.ts +4 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 187.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`91410d6064c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/91410d6064c) - [ux] NOISSUE Fix linkify of file links on space
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
13
+ ## 187.5.6
14
+
15
+ ### Patch Changes
16
+
17
+ - [`6b6ec9afee3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6b6ec9afee3) - [ED-19157] Support setting image width based on editor size for newly inserted images behind feature flag
18
+
3
19
  ## 187.5.5
4
20
 
5
21
  ### Patch Changes
@@ -119,7 +119,7 @@ var mediaPlugin = function mediaPlugin() {
119
119
  customDropzoneContainer: options && options.customDropzoneContainer,
120
120
  customMediaPicker: options && options.customMediaPicker,
121
121
  allowResizing: !!(options && options.allowResizing)
122
- }, reactContext, getIntl, dispatch, options, featureFlags.newInsertionBehaviour);
122
+ }, reactContext, getIntl, dispatch, options, featureFlags.newInsertionBehaviour, api);
123
123
  }
124
124
  }, {
125
125
  name: 'mediaKeymap',
@@ -68,8 +68,10 @@ var createDropPlaceholder = function createDropPlaceholder(intl, allowDropLine)
68
68
  };
69
69
  var MEDIA_RESOLVED_STATES = ['ready', 'error', 'cancelled'];
70
70
  var MediaPluginStateImplementation = /*#__PURE__*/function () {
71
- function MediaPluginStateImplementation(_state, options, mediaOptions, newInsertionBehaviour, _dispatch) {
72
- var _this = this;
71
+ function MediaPluginStateImplementation(_state, options, mediaOptions, newInsertionBehaviour, _dispatch, pluginInjectionApi) {
72
+ var _this = this,
73
+ _pluginInjectionApi$d,
74
+ _pluginInjectionApi$d2;
73
75
  (0, _classCallCheck2.default)(this, MediaPluginStateImplementation);
74
76
  (0, _defineProperty2.default)(this, "allowsUploads", false);
75
77
  (0, _defineProperty2.default)(this, "ignoreLinks", false);
@@ -237,7 +239,7 @@ var MediaPluginStateImplementation = /*#__PURE__*/function () {
237
239
  });
238
240
  }
239
241
  if ((0, _mediaSingle.isMediaSingle)(state.schema, mediaStateWithContext.fileMimeType)) {
240
- (0, _mediaSingle.insertMediaSingleNode)(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, _this.newInsertionBehaviour);
242
+ (0, _mediaSingle.insertMediaSingleNode)(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, _this.newInsertionBehaviour, _this.widthPluginState);
241
243
  } else if ((0, _mediaCommon2.getMediaFeatureFlag)('mediaInline', (_this$mediaOptions2 = _this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags) && !(0, _document.isInEmptyLine)(state) && (!(0, _mediaCommon.isInsidePotentialEmptyParagraph)(state) || (0, _utils2.isInListItem)(state)) && (0, _mediaFiles.canInsertMediaInline)(state)) {
242
244
  (0, _mediaFiles.insertMediaInlineNode)(_this.view, mediaStateWithContext, collection, _this.getInputMethod(pickerType));
243
245
  } else {
@@ -478,6 +480,7 @@ var MediaPluginStateImplementation = /*#__PURE__*/function () {
478
480
  this.mediaOptions = mediaOptions;
479
481
  this.newInsertionBehaviour = newInsertionBehaviour;
480
482
  this.dispatch = _dispatch;
483
+ this.widthPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.width) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.sharedState.currentState();
481
484
  this.waitForMediaUpload = options.waitForMediaUpload === undefined ? true : options.waitForMediaUpload;
482
485
  var nodes = _state.schema.nodes;
483
486
  (0, _assert.default)(nodes.media && (nodes.mediaGroup || nodes.mediaSingle), 'Editor: unable to init media plugin - media or mediaGroup/mediaSingle node absent in schema');
@@ -620,13 +623,13 @@ var getMediaPluginState = function getMediaPluginState(state) {
620
623
  return _pluginKey.stateKey.getState(state);
621
624
  };
622
625
  exports.getMediaPluginState = getMediaPluginState;
623
- var createPlugin = function createPlugin(_schema, options, reactContext, getIntl, dispatch, mediaOptions, newInsertionBehaviour) {
626
+ var createPlugin = function createPlugin(_schema, options, reactContext, getIntl, dispatch, mediaOptions, newInsertionBehaviour, pluginInjectionApi) {
624
627
  var intl = getIntl();
625
628
  var dropPlaceholder = createDropPlaceholder(intl, mediaOptions && mediaOptions.allowDropzoneDropLine);
626
629
  return new _safePlugin.SafePlugin({
627
630
  state: {
628
631
  init: function init(_config, state) {
629
- return new MediaPluginStateImplementation(state, options, mediaOptions, newInsertionBehaviour, dispatch);
632
+ return new MediaPluginStateImplementation(state, options, mediaOptions, newInsertionBehaviour, dispatch, pluginInjectionApi);
630
633
  },
631
634
  apply: function apply(tr, pluginState) {
632
635
  // remap editing media single position if we're in collab
@@ -13,14 +13,18 @@ var _prosemirrorModel = require("prosemirror-model");
13
13
  var _prosemirrorUtils = require("prosemirror-utils");
14
14
  var _utils = require("../../../utils");
15
15
  var _utils2 = require("@atlaskit/editor-common/utils");
16
+ var _mediaSingle = require("@atlaskit/editor-common/media-single");
16
17
  var _mediaCommon = require("../utils/media-common");
17
18
  var _slice = require("../../../utils/slice");
18
19
  var _analytics = require("../../analytics");
20
+ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
19
21
  var _analytics2 = require("@atlaskit/editor-common/analytics");
20
22
  var _insert = require("@atlaskit/editor-common/insert");
21
23
  var _isImage = require("./is-image");
22
24
  var _position = require("../../../utils/prosemirror/position");
23
25
  var _mediaCommon2 = require("@atlaskit/media-common");
26
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
27
+ var _ui = require("@atlaskit/editor-common/ui");
24
28
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
29
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
26
30
  var getInsertMediaAnalytics = function getInsertMediaAnalytics(inputMethod, fileExtension) {
@@ -89,7 +93,7 @@ var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inp
89
93
  return insertNodesWithOptionalParagraph(nodes, analyticsAttributes)(state, dispatch);
90
94
  };
91
95
  exports.insertMediaAsMediaSingle = insertMediaAsMediaSingle;
92
- var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour) {
96
+ var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour, widthPluginState) {
93
97
  var _state$selection$$fro;
94
98
  if (collection === undefined) {
95
99
  return false;
@@ -98,7 +102,11 @@ var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inp
98
102
  dispatch = view.dispatch;
99
103
  var grandParentNodeType = (_state$selection$$fro = state.selection.$from.node(-1)) === null || _state$selection$$fro === void 0 ? void 0 : _state$selection$$fro.type;
100
104
  var parentNodeType = state.selection.$from.parent.type;
101
- var node = createMediaSingleNode(state.schema, collection, alignLeftOnInsert)(mediaState);
105
+
106
+ // add undefined as fallback as we don't want media single width to have upper limit as 0
107
+ // if widthPluginState.width is 0, default 760 will be used
108
+ var contentWidth = (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
109
+ var node = createMediaSingleNode(state.schema, collection, contentWidth, undefined, alignLeftOnInsert)(mediaState);
102
110
  var fileExtension;
103
111
  if (mediaState.fileName) {
104
112
  var extensionIdx = mediaState.fileName.lastIndexOf('.');
@@ -132,7 +140,10 @@ var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inp
132
140
  return true;
133
141
  };
134
142
  exports.insertMediaSingleNode = insertMediaSingleNode;
135
- var createMediaSingleNode = function createMediaSingleNode(schema, collection, alignLeftOnInsert) {
143
+ var createMediaSingleNode = function createMediaSingleNode(schema, collection) {
144
+ var maxWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _editorSharedStyles.akEditorDefaultLayoutWidth;
145
+ var minWidth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _mediaSingle.MEDIA_SINGLE_MIN_PIXEL_WIDTH;
146
+ var alignLeftOnInsert = arguments.length > 4 ? arguments[4] : undefined;
136
147
  return function (mediaState) {
137
148
  var id = mediaState.id,
138
149
  dimensions = mediaState.dimensions,
@@ -148,19 +159,26 @@ var createMediaSingleNode = function createMediaSingleNode(schema, collection, a
148
159
  var _schema$nodes = schema.nodes,
149
160
  media = _schema$nodes.media,
150
161
  mediaSingle = _schema$nodes.mediaSingle;
162
+ var scaledWidth = width && Math.round(width / scaleFactor);
151
163
  var mediaNode = media.create({
152
164
  id: id,
153
165
  type: 'file',
154
166
  collection: collection,
155
167
  contextId: contextId,
156
- width: width && Math.round(width / scaleFactor),
168
+ width: scaledWidth,
157
169
  height: height && Math.round(height / scaleFactor)
158
170
  });
159
171
  var mediaSingleAttrs = alignLeftOnInsert ? {
160
172
  layout: 'align-start'
161
173
  } : {};
174
+ var extendedMediaSingleAttrs = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience') ? _objectSpread(_objectSpread({}, mediaSingleAttrs), {}, {
175
+ // constrain initial width between max width (editor content width) and min width (default to 24)
176
+ width: Math.max(Math.min(scaledWidth || _ui.DEFAULT_IMAGE_WIDTH, maxWidth), minWidth),
177
+ // TODO: change to use enum
178
+ widthType: 'pixel'
179
+ }) : mediaSingleAttrs;
162
180
  (0, _mediaCommon.copyOptionalAttrsFromMediaState)(mediaState, mediaNode);
163
- return mediaSingle.createChecked(mediaSingleAttrs, mediaNode);
181
+ return mediaSingle.createChecked(extendedMediaSingleAttrs, mediaNode);
164
182
  };
165
183
  };
166
184
  exports.createMediaSingleNode = createMediaSingleNode;
@@ -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.5.5";
9
+ var version = "187.6.0";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.5.5",
3
+ "version": "187.6.0",
4
4
  "sideEffects": false
5
5
  }
@@ -104,7 +104,7 @@ const mediaPlugin = (options = {}, api) => {
104
104
  customDropzoneContainer: options && options.customDropzoneContainer,
105
105
  customMediaPicker: options && options.customMediaPicker,
106
106
  allowResizing: !!(options && options.allowResizing)
107
- }, reactContext, getIntl, dispatch, options, featureFlags.newInsertionBehaviour);
107
+ }, reactContext, getIntl, dispatch, options, featureFlags.newInsertionBehaviour, api);
108
108
  }
109
109
  }, {
110
110
  name: 'mediaKeymap',
@@ -5,7 +5,7 @@ import { jsx } from '@emotion/react';
5
5
  import React, { Component } from 'react';
6
6
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
7
7
  import { MediaSingle, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/ui';
8
- import { browser } from '@atlaskit/editor-common/utils';
8
+ import { browser, floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-common/utils';
9
9
  import { isNodeSelectedOrInRange } from '../../../utils/nodes';
10
10
  import { setNodeSelection, setTextSelection } from '../../../utils';
11
11
  import ResizableMediaSingle from '../ui/ResizableMediaSingle';
@@ -14,7 +14,6 @@ import { MediaNodeUpdater } from './mediaNodeUpdater';
14
14
  import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
15
15
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
16
16
  import { figureWrapper, MediaSingleNodeSelector } from './styles';
17
- import { floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-common/utils';
18
17
  import { getAttrsFromUrl } from '@atlaskit/media-client';
19
18
  import { isMediaBlobUrlFromAttrs } from '../utils/media-common';
20
19
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
@@ -44,7 +44,8 @@ const createDropPlaceholder = (intl, allowDropLine) => {
44
44
  };
45
45
  const MEDIA_RESOLVED_STATES = ['ready', 'error', 'cancelled'];
46
46
  export class MediaPluginStateImplementation {
47
- constructor(_state, options, mediaOptions, newInsertionBehaviour, _dispatch) {
47
+ constructor(_state, options, mediaOptions, newInsertionBehaviour, _dispatch, pluginInjectionApi) {
48
+ var _pluginInjectionApi$d, _pluginInjectionApi$d2;
48
49
  _defineProperty(this, "allowsUploads", false);
49
50
  _defineProperty(this, "ignoreLinks", false);
50
51
  _defineProperty(this, "waitForMediaUpload", true);
@@ -168,7 +169,7 @@ export class MediaPluginStateImplementation {
168
169
  });
169
170
  }
170
171
  if (isMediaSingle(state.schema, mediaStateWithContext.fileMimeType)) {
171
- insertMediaSingleNode(this.view, mediaStateWithContext, this.getInputMethod(pickerType), collection, this.mediaOptions && this.mediaOptions.alignLeftOnInsert, this.newInsertionBehaviour);
172
+ insertMediaSingleNode(this.view, mediaStateWithContext, this.getInputMethod(pickerType), collection, this.mediaOptions && this.mediaOptions.alignLeftOnInsert, this.newInsertionBehaviour, this.widthPluginState);
172
173
  } else if (getMediaFeatureFlag('mediaInline', (_this$mediaOptions2 = this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInListItem(state)) && canInsertMediaInline(state)) {
173
174
  insertMediaInlineNode(this.view, mediaStateWithContext, collection, this.getInputMethod(pickerType));
174
175
  } else {
@@ -408,6 +409,7 @@ export class MediaPluginStateImplementation {
408
409
  this.mediaOptions = mediaOptions;
409
410
  this.newInsertionBehaviour = newInsertionBehaviour;
410
411
  this.dispatch = _dispatch;
412
+ this.widthPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.width) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.sharedState.currentState();
411
413
  this.waitForMediaUpload = options.waitForMediaUpload === undefined ? true : options.waitForMediaUpload;
412
414
  const {
413
415
  nodes
@@ -509,13 +511,13 @@ export class MediaPluginStateImplementation {
509
511
  }
510
512
  }
511
513
  export const getMediaPluginState = state => stateKey.getState(state);
512
- export const createPlugin = (_schema, options, reactContext, getIntl, dispatch, mediaOptions, newInsertionBehaviour) => {
514
+ export const createPlugin = (_schema, options, reactContext, getIntl, dispatch, mediaOptions, newInsertionBehaviour, pluginInjectionApi) => {
513
515
  const intl = getIntl();
514
516
  const dropPlaceholder = createDropPlaceholder(intl, mediaOptions && mediaOptions.allowDropzoneDropLine);
515
517
  return new SafePlugin({
516
518
  state: {
517
519
  init(_config, state) {
518
- return new MediaPluginStateImplementation(state, options, mediaOptions, newInsertionBehaviour, dispatch);
520
+ return new MediaPluginStateImplementation(state, options, mediaOptions, newInsertionBehaviour, dispatch, pluginInjectionApi);
519
521
  },
520
522
  apply(tr, pluginState) {
521
523
  // remap editing media single position if we're in collab
@@ -2,14 +2,18 @@ import { Fragment, Slice } from 'prosemirror-model';
2
2
  import { safeInsert as pmSafeInsert, hasParentNodeOfType } from 'prosemirror-utils';
3
3
  import { checkNodeDown } from '../../../utils';
4
4
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
5
+ import { MEDIA_SINGLE_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
5
6
  import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
6
7
  import { mapSlice } from '../../../utils/slice';
7
8
  import { addAnalytics } from '../../analytics';
9
+ import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
8
10
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
9
11
  import { safeInsert, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
10
12
  import { isImage } from './is-image';
11
13
  import { atTheBeginningOfBlock } from '../../../utils/prosemirror/position';
12
14
  import { getRandomHex } from '@atlaskit/media-common';
15
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
16
+ import { DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/ui';
13
17
  const getInsertMediaAnalytics = (inputMethod, fileExtension) => ({
14
18
  action: ACTION.INSERTED,
15
19
  actionSubject: ACTION_SUBJECT.DOCUMENT,
@@ -78,7 +82,7 @@ export const insertMediaAsMediaSingle = (view, node, inputMethod) => {
78
82
  };
79
83
  return insertNodesWithOptionalParagraph(nodes, analyticsAttributes)(state, dispatch);
80
84
  };
81
- export const insertMediaSingleNode = (view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour) => {
85
+ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour, widthPluginState) => {
82
86
  var _state$selection$$fro;
83
87
  if (collection === undefined) {
84
88
  return false;
@@ -89,7 +93,11 @@ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection,
89
93
  } = view;
90
94
  const grandParentNodeType = (_state$selection$$fro = state.selection.$from.node(-1)) === null || _state$selection$$fro === void 0 ? void 0 : _state$selection$$fro.type;
91
95
  const parentNodeType = state.selection.$from.parent.type;
92
- const node = createMediaSingleNode(state.schema, collection, alignLeftOnInsert)(mediaState);
96
+
97
+ // add undefined as fallback as we don't want media single width to have upper limit as 0
98
+ // if widthPluginState.width is 0, default 760 will be used
99
+ const contentWidth = (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
100
+ const node = createMediaSingleNode(state.schema, collection, contentWidth, undefined, alignLeftOnInsert)(mediaState);
93
101
  let fileExtension;
94
102
  if (mediaState.fileName) {
95
103
  const extensionIdx = mediaState.fileName.lastIndexOf('.');
@@ -122,7 +130,7 @@ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection,
122
130
  }
123
131
  return true;
124
132
  };
125
- export const createMediaSingleNode = (schema, collection, alignLeftOnInsert) => mediaState => {
133
+ export const createMediaSingleNode = (schema, collection, maxWidth = akEditorDefaultLayoutWidth, minWidth = MEDIA_SINGLE_MIN_PIXEL_WIDTH, alignLeftOnInsert) => mediaState => {
126
134
  const {
127
135
  id,
128
136
  dimensions,
@@ -140,19 +148,27 @@ export const createMediaSingleNode = (schema, collection, alignLeftOnInsert) =>
140
148
  media,
141
149
  mediaSingle
142
150
  } = schema.nodes;
151
+ const scaledWidth = width && Math.round(width / scaleFactor);
143
152
  const mediaNode = media.create({
144
153
  id,
145
154
  type: 'file',
146
155
  collection,
147
156
  contextId,
148
- width: width && Math.round(width / scaleFactor),
157
+ width: scaledWidth,
149
158
  height: height && Math.round(height / scaleFactor)
150
159
  });
151
160
  const mediaSingleAttrs = alignLeftOnInsert ? {
152
161
  layout: 'align-start'
153
162
  } : {};
163
+ const extendedMediaSingleAttrs = getBooleanFF('platform.editor.media.extended-resize-experience') ? {
164
+ ...mediaSingleAttrs,
165
+ // constrain initial width between max width (editor content width) and min width (default to 24)
166
+ width: Math.max(Math.min(scaledWidth || DEFAULT_IMAGE_WIDTH, maxWidth), minWidth),
167
+ // TODO: change to use enum
168
+ widthType: 'pixel'
169
+ } : mediaSingleAttrs;
154
170
  copyOptionalAttrsFromMediaState(mediaState, mediaNode);
155
- return mediaSingle.createChecked(mediaSingleAttrs, mediaNode);
171
+ return mediaSingle.createChecked(extendedMediaSingleAttrs, mediaNode);
156
172
  };
157
173
  export function transformSliceForMedia(slice, schema) {
158
174
  const {
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.5.5";
2
+ export const version = "187.6.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.5.5",
3
+ "version": "187.6.0",
4
4
  "sideEffects": false
5
5
  }
@@ -106,7 +106,7 @@ var mediaPlugin = function mediaPlugin() {
106
106
  customDropzoneContainer: options && options.customDropzoneContainer,
107
107
  customMediaPicker: options && options.customMediaPicker,
108
108
  allowResizing: !!(options && options.allowResizing)
109
- }, reactContext, getIntl, dispatch, options, featureFlags.newInsertionBehaviour);
109
+ }, reactContext, getIntl, dispatch, options, featureFlags.newInsertionBehaviour, api);
110
110
  }
111
111
  }, {
112
112
  name: 'mediaKeymap',
@@ -18,7 +18,7 @@ import { jsx } from '@emotion/react';
18
18
  import React, { Component } from 'react';
19
19
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
20
20
  import { MediaSingle, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/ui';
21
- import { browser } from '@atlaskit/editor-common/utils';
21
+ import { browser, floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-common/utils';
22
22
  import { isNodeSelectedOrInRange } from '../../../utils/nodes';
23
23
  import { setNodeSelection, setTextSelection } from '../../../utils';
24
24
  import ResizableMediaSingle from '../ui/ResizableMediaSingle';
@@ -27,7 +27,6 @@ import { MediaNodeUpdater } from './mediaNodeUpdater';
27
27
  import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
28
28
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
29
29
  import { figureWrapper, MediaSingleNodeSelector } from './styles';
30
- import { floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-common/utils';
31
30
  import { getAttrsFromUrl } from '@atlaskit/media-client';
32
31
  import { isMediaBlobUrlFromAttrs } from '../utils/media-common';
33
32
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
@@ -53,8 +53,10 @@ var createDropPlaceholder = function createDropPlaceholder(intl, allowDropLine)
53
53
  };
54
54
  var MEDIA_RESOLVED_STATES = ['ready', 'error', 'cancelled'];
55
55
  export var MediaPluginStateImplementation = /*#__PURE__*/function () {
56
- function MediaPluginStateImplementation(_state, options, mediaOptions, newInsertionBehaviour, _dispatch) {
57
- var _this = this;
56
+ function MediaPluginStateImplementation(_state, options, mediaOptions, newInsertionBehaviour, _dispatch, pluginInjectionApi) {
57
+ var _this = this,
58
+ _pluginInjectionApi$d,
59
+ _pluginInjectionApi$d2;
58
60
  _classCallCheck(this, MediaPluginStateImplementation);
59
61
  _defineProperty(this, "allowsUploads", false);
60
62
  _defineProperty(this, "ignoreLinks", false);
@@ -222,7 +224,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
222
224
  });
223
225
  }
224
226
  if (isMediaSingle(state.schema, mediaStateWithContext.fileMimeType)) {
225
- insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, _this.newInsertionBehaviour);
227
+ insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, _this.newInsertionBehaviour, _this.widthPluginState);
226
228
  } else if (getMediaFeatureFlag('mediaInline', (_this$mediaOptions2 = _this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInListItem(state)) && canInsertMediaInline(state)) {
227
229
  insertMediaInlineNode(_this.view, mediaStateWithContext, collection, _this.getInputMethod(pickerType));
228
230
  } else {
@@ -463,6 +465,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
463
465
  this.mediaOptions = mediaOptions;
464
466
  this.newInsertionBehaviour = newInsertionBehaviour;
465
467
  this.dispatch = _dispatch;
468
+ this.widthPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.width) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.sharedState.currentState();
466
469
  this.waitForMediaUpload = options.waitForMediaUpload === undefined ? true : options.waitForMediaUpload;
467
470
  var nodes = _state.schema.nodes;
468
471
  assert(nodes.media && (nodes.mediaGroup || nodes.mediaSingle), 'Editor: unable to init media plugin - media or mediaGroup/mediaSingle node absent in schema');
@@ -603,13 +606,13 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
603
606
  export var getMediaPluginState = function getMediaPluginState(state) {
604
607
  return stateKey.getState(state);
605
608
  };
606
- export var createPlugin = function createPlugin(_schema, options, reactContext, getIntl, dispatch, mediaOptions, newInsertionBehaviour) {
609
+ export var createPlugin = function createPlugin(_schema, options, reactContext, getIntl, dispatch, mediaOptions, newInsertionBehaviour, pluginInjectionApi) {
607
610
  var intl = getIntl();
608
611
  var dropPlaceholder = createDropPlaceholder(intl, mediaOptions && mediaOptions.allowDropzoneDropLine);
609
612
  return new SafePlugin({
610
613
  state: {
611
614
  init: function init(_config, state) {
612
- return new MediaPluginStateImplementation(state, options, mediaOptions, newInsertionBehaviour, dispatch);
615
+ return new MediaPluginStateImplementation(state, options, mediaOptions, newInsertionBehaviour, dispatch, pluginInjectionApi);
613
616
  },
614
617
  apply: function apply(tr, pluginState) {
615
618
  // remap editing media single position if we're in collab
@@ -5,14 +5,18 @@ import { Fragment, Slice } from 'prosemirror-model';
5
5
  import { safeInsert as pmSafeInsert, hasParentNodeOfType } from 'prosemirror-utils';
6
6
  import { checkNodeDown } from '../../../utils';
7
7
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
8
+ import { MEDIA_SINGLE_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
8
9
  import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
9
10
  import { mapSlice } from '../../../utils/slice';
10
11
  import { addAnalytics } from '../../analytics';
12
+ import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
11
13
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
12
14
  import { safeInsert, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
13
15
  import { isImage } from './is-image';
14
16
  import { atTheBeginningOfBlock } from '../../../utils/prosemirror/position';
15
17
  import { getRandomHex } from '@atlaskit/media-common';
18
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
19
+ import { DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/ui';
16
20
  var getInsertMediaAnalytics = function getInsertMediaAnalytics(inputMethod, fileExtension) {
17
21
  return {
18
22
  action: ACTION.INSERTED,
@@ -77,7 +81,7 @@ export var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, no
77
81
  };
78
82
  return insertNodesWithOptionalParagraph(nodes, analyticsAttributes)(state, dispatch);
79
83
  };
80
- export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour) {
84
+ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour, widthPluginState) {
81
85
  var _state$selection$$fro;
82
86
  if (collection === undefined) {
83
87
  return false;
@@ -86,7 +90,11 @@ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaSta
86
90
  dispatch = view.dispatch;
87
91
  var grandParentNodeType = (_state$selection$$fro = state.selection.$from.node(-1)) === null || _state$selection$$fro === void 0 ? void 0 : _state$selection$$fro.type;
88
92
  var parentNodeType = state.selection.$from.parent.type;
89
- var node = createMediaSingleNode(state.schema, collection, alignLeftOnInsert)(mediaState);
93
+
94
+ // add undefined as fallback as we don't want media single width to have upper limit as 0
95
+ // if widthPluginState.width is 0, default 760 will be used
96
+ var contentWidth = (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
97
+ var node = createMediaSingleNode(state.schema, collection, contentWidth, undefined, alignLeftOnInsert)(mediaState);
90
98
  var fileExtension;
91
99
  if (mediaState.fileName) {
92
100
  var extensionIdx = mediaState.fileName.lastIndexOf('.');
@@ -119,7 +127,10 @@ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaSta
119
127
  }
120
128
  return true;
121
129
  };
122
- export var createMediaSingleNode = function createMediaSingleNode(schema, collection, alignLeftOnInsert) {
130
+ export var createMediaSingleNode = function createMediaSingleNode(schema, collection) {
131
+ var maxWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : akEditorDefaultLayoutWidth;
132
+ var minWidth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : MEDIA_SINGLE_MIN_PIXEL_WIDTH;
133
+ var alignLeftOnInsert = arguments.length > 4 ? arguments[4] : undefined;
123
134
  return function (mediaState) {
124
135
  var id = mediaState.id,
125
136
  dimensions = mediaState.dimensions,
@@ -135,19 +146,26 @@ export var createMediaSingleNode = function createMediaSingleNode(schema, collec
135
146
  var _schema$nodes = schema.nodes,
136
147
  media = _schema$nodes.media,
137
148
  mediaSingle = _schema$nodes.mediaSingle;
149
+ var scaledWidth = width && Math.round(width / scaleFactor);
138
150
  var mediaNode = media.create({
139
151
  id: id,
140
152
  type: 'file',
141
153
  collection: collection,
142
154
  contextId: contextId,
143
- width: width && Math.round(width / scaleFactor),
155
+ width: scaledWidth,
144
156
  height: height && Math.round(height / scaleFactor)
145
157
  });
146
158
  var mediaSingleAttrs = alignLeftOnInsert ? {
147
159
  layout: 'align-start'
148
160
  } : {};
161
+ var extendedMediaSingleAttrs = getBooleanFF('platform.editor.media.extended-resize-experience') ? _objectSpread(_objectSpread({}, mediaSingleAttrs), {}, {
162
+ // constrain initial width between max width (editor content width) and min width (default to 24)
163
+ width: Math.max(Math.min(scaledWidth || DEFAULT_IMAGE_WIDTH, maxWidth), minWidth),
164
+ // TODO: change to use enum
165
+ widthType: 'pixel'
166
+ }) : mediaSingleAttrs;
149
167
  copyOptionalAttrsFromMediaState(mediaState, mediaNode);
150
- return mediaSingle.createChecked(mediaSingleAttrs, mediaNode);
168
+ return mediaSingle.createChecked(extendedMediaSingleAttrs, mediaNode);
151
169
  };
152
170
  };
153
171
  export function transformSliceForMedia(slice, schema) {
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "187.5.5";
2
+ export var version = "187.6.0";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.5.5",
3
+ "version": "187.6.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,14 +1,14 @@
1
- import { MediaProvider } from '@atlaskit/editor-common/provider-factory';
2
- import { NextEditorPlugin } from '../../types';
3
- import { OptionalPlugin } from '@atlaskit/editor-common/types';
4
- import { MediaState } from './pm-plugins/main';
5
- import { CustomMediaPicker, MediaOptions } from './types';
1
+ import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
2
+ import type { NextEditorPlugin } from '../../types';
3
+ import type { OptionalPlugin } from '@atlaskit/editor-common/types';
4
+ import type { MediaState } from './pm-plugins/main';
5
+ import type { CustomMediaPicker, MediaOptions } from './types';
6
6
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
7
7
  import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
8
8
  import type { gridPlugin } from '@atlaskit/editor-plugin-grid';
9
9
  import type { widthPlugin } from '@atlaskit/editor-plugin-width';
10
10
  import type { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
11
- import { MediaPluginState } from './pm-plugins/types';
11
+ import type { MediaPluginState } from './pm-plugins/types';
12
12
  import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-toolbar';
13
13
  import type editorDisabled from '../editor-disabled';
14
14
  export type { MediaState, MediaProvider, CustomMediaPicker };
@@ -1,19 +1,19 @@
1
1
  /** @jsx jsx */
2
2
  import { jsx } from '@emotion/react';
3
- import React, { Component, MouseEvent } from 'react';
4
- import { Node as PMNode } from 'prosemirror-model';
5
- import { DecorationSource, EditorView, Decoration } from 'prosemirror-view';
6
- import { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
7
- import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
8
- import type { ContextIdentifierProvider } from '@atlaskit/editor-common/provider-factory';
3
+ import type { MouseEvent } from 'react';
4
+ import React, { Component } from 'react';
5
+ import type { Node as PMNode } from 'prosemirror-model';
6
+ import type { DecorationSource, EditorView, Decoration } from 'prosemirror-view';
7
+ import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
8
+ import type { ContextIdentifierProvider, ProviderFactory } from '@atlaskit/editor-common/provider-factory';
9
9
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
10
- import { CardEvent } from '@atlaskit/media-card';
11
- import { MediaClientConfig } from '@atlaskit/media-core';
12
- import { getPosHandler, ForwardRef } from '../../../nodeviews/';
13
- import { EventDispatcher } from '../../../event-dispatcher';
14
- import { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
15
- import { MediaOptions } from '../types';
16
- import { MediaSingleNodeProps, MediaSingleNodeViewProps } from './types';
10
+ import type { CardEvent } from '@atlaskit/media-card';
11
+ import type { MediaClientConfig } from '@atlaskit/media-core';
12
+ import type { getPosHandler, ForwardRef } from '../../../nodeviews/';
13
+ import type { EventDispatcher } from '../../../event-dispatcher';
14
+ import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
15
+ import type { MediaOptions } from '../types';
16
+ import type { MediaSingleNodeProps, MediaSingleNodeViewProps } from './types';
17
17
  import { MediaNodeUpdater } from './mediaNodeUpdater';
18
18
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
19
19
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
@@ -1,17 +1,21 @@
1
- import { Node as PMNode, Schema } from 'prosemirror-model';
1
+ import type { Node as PMNode, Schema } from 'prosemirror-model';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import { EditorState } from 'prosemirror-state';
4
- import { EditorView } from 'prosemirror-view';
5
- import { MediaClientConfig } from '@atlaskit/media-core';
6
- import { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
3
+ import type { EditorState } from 'prosemirror-state';
4
+ import type { EditorView } from 'prosemirror-view';
5
+ import type { MediaClientConfig } from '@atlaskit/media-core';
6
+ import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
7
7
  import type { ContextIdentifierProvider, MediaProvider } from '@atlaskit/editor-common/provider-factory';
8
- import { Dispatch } from '../../../event-dispatcher';
9
- import { ProsemirrorGetPosHandler } from '../../../nodeviews';
10
- import { MediaPluginOptions } from '../media-plugin-options';
11
- import { MediaOptions, MediaState, MediaStateStatus } from '../types';
12
- import PickerFacade, { MediaStateEventSubscriber } from '../picker-facade';
13
- import { MediaNodeWithPosHandler, MediaPluginState } from './types';
14
- import { IntlShape } from 'react-intl-next';
8
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
9
+ import type { WidthPluginState } from '@atlaskit/editor-plugin-width';
10
+ import type { Dispatch } from '../../../event-dispatcher';
11
+ import type { ProsemirrorGetPosHandler } from '../../../nodeviews';
12
+ import type { MediaPluginOptions } from '../media-plugin-options';
13
+ import type { MediaOptions, MediaState, MediaStateStatus } from '../types';
14
+ import type { MediaStateEventSubscriber } from '../picker-facade';
15
+ import PickerFacade from '../picker-facade';
16
+ import type { MediaNodeWithPosHandler, MediaPluginState } from './types';
17
+ import type { IntlShape } from 'react-intl-next';
18
+ import type mediaPlugin from '../index';
15
19
  export type { MediaState, MediaProvider, MediaStateStatus };
16
20
  export { stateKey } from './plugin-key';
17
21
  export declare const MEDIA_CONTENT_WRAP_CLASS_NAME = "media-content-wrap";
@@ -46,7 +50,8 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
46
50
  showEditingDialog?: boolean;
47
51
  mediaOptions?: MediaOptions;
48
52
  dispatch?: Dispatch;
49
- constructor(state: EditorState, options: MediaPluginOptions, mediaOptions?: MediaOptions, newInsertionBehaviour?: boolean, dispatch?: Dispatch);
53
+ widthPluginState?: WidthPluginState | undefined;
54
+ constructor(state: EditorState, options: MediaPluginOptions, mediaOptions?: MediaOptions, newInsertionBehaviour?: boolean, dispatch?: Dispatch, pluginInjectionApi?: ExtractInjectionAPI<typeof mediaPlugin> | undefined);
50
55
  onContextIdentifierProvider: (_name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>;
51
56
  setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
52
57
  getMediaOptions: () => MediaPluginOptions;
@@ -105,4 +110,4 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
105
110
  updateAndDispatch(props: Partial<Pick<this, 'allowsUploads' | 'allUploadsFinished' | 'isFullscreen'>>): void;
106
111
  }
107
112
  export declare const getMediaPluginState: (state: EditorState) => MediaPluginState;
108
- export declare const createPlugin: (_schema: Schema, options: MediaPluginOptions, reactContext: () => {}, getIntl: () => IntlShape, dispatch?: Dispatch, mediaOptions?: MediaOptions, newInsertionBehaviour?: boolean) => SafePlugin<MediaPluginState>;
113
+ export declare const createPlugin: (_schema: Schema, options: MediaPluginOptions, reactContext: () => {}, getIntl: () => IntlShape, dispatch?: Dispatch, mediaOptions?: MediaOptions, newInsertionBehaviour?: boolean, pluginInjectionApi?: ExtractInjectionAPI<typeof mediaPlugin> | undefined) => SafePlugin<MediaPluginState>;
@@ -1,8 +1,10 @@
1
- import { Node as PMNode, Schema, Slice } from 'prosemirror-model';
2
- import { EditorView } from 'prosemirror-view';
3
- import { Selection } from 'prosemirror-state';
4
- import { MediaState } from '../types';
5
- import { InputMethodInsertMedia } from '@atlaskit/editor-common/analytics';
1
+ import type { Node as PMNode, Schema } from 'prosemirror-model';
2
+ import { Slice } from 'prosemirror-model';
3
+ import type { EditorView } from 'prosemirror-view';
4
+ import type { Selection } from 'prosemirror-state';
5
+ import type { MediaState } from '../types';
6
+ import type { InputMethodInsertMedia } from '@atlaskit/editor-common/analytics';
7
+ import type { WidthPluginState } from '@atlaskit/editor-plugin-width';
6
8
  export interface MediaSingleState extends MediaState {
7
9
  dimensions: {
8
10
  width: number;
@@ -13,7 +15,7 @@ export interface MediaSingleState extends MediaState {
13
15
  }
14
16
  export declare const isMediaSingle: (schema: Schema, fileMimeType?: string) => boolean;
15
17
  export declare const insertMediaAsMediaSingle: (view: EditorView, node: PMNode, inputMethod: InputMethodInsertMedia) => boolean;
16
- export declare const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, newInsertionBehaviour?: boolean) => boolean;
17
- export declare const createMediaSingleNode: (schema: Schema, collection: string, alignLeftOnInsert?: boolean) => (mediaState: MediaSingleState) => PMNode;
18
+ export declare const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, newInsertionBehaviour?: boolean, widthPluginState?: WidthPluginState | undefined) => boolean;
19
+ export declare const createMediaSingleNode: (schema: Schema, collection: string, maxWidth?: number, minWidth?: number, alignLeftOnInsert?: boolean) => (mediaState: MediaSingleState) => PMNode;
18
20
  export declare function transformSliceForMedia(slice: Slice, schema: Schema): (selection: Selection) => Slice;
19
21
  export declare function isCaptionNode(editorView: EditorView): boolean;
@@ -1,14 +1,14 @@
1
- import { MediaProvider } from '@atlaskit/editor-common/provider-factory';
2
- import { NextEditorPlugin } from '../../types';
3
- import { OptionalPlugin } from '@atlaskit/editor-common/types';
4
- import { MediaState } from './pm-plugins/main';
5
- import { CustomMediaPicker, MediaOptions } from './types';
1
+ import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
2
+ import type { NextEditorPlugin } from '../../types';
3
+ import type { OptionalPlugin } from '@atlaskit/editor-common/types';
4
+ import type { MediaState } from './pm-plugins/main';
5
+ import type { CustomMediaPicker, MediaOptions } from './types';
6
6
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
7
7
  import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
8
8
  import type { gridPlugin } from '@atlaskit/editor-plugin-grid';
9
9
  import type { widthPlugin } from '@atlaskit/editor-plugin-width';
10
10
  import type { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
11
- import { MediaPluginState } from './pm-plugins/types';
11
+ import type { MediaPluginState } from './pm-plugins/types';
12
12
  import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-toolbar';
13
13
  import type editorDisabled from '../editor-disabled';
14
14
  export type { MediaState, MediaProvider, CustomMediaPicker };
@@ -1,19 +1,19 @@
1
1
  /** @jsx jsx */
2
2
  import { jsx } from '@emotion/react';
3
- import React, { Component, MouseEvent } from 'react';
4
- import { Node as PMNode } from 'prosemirror-model';
5
- import { DecorationSource, EditorView, Decoration } from 'prosemirror-view';
6
- import { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
7
- import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
8
- import type { ContextIdentifierProvider } from '@atlaskit/editor-common/provider-factory';
3
+ import type { MouseEvent } from 'react';
4
+ import React, { Component } from 'react';
5
+ import type { Node as PMNode } from 'prosemirror-model';
6
+ import type { DecorationSource, EditorView, Decoration } from 'prosemirror-view';
7
+ import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
8
+ import type { ContextIdentifierProvider, ProviderFactory } from '@atlaskit/editor-common/provider-factory';
9
9
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
10
- import { CardEvent } from '@atlaskit/media-card';
11
- import { MediaClientConfig } from '@atlaskit/media-core';
12
- import { getPosHandler, ForwardRef } from '../../../nodeviews/';
13
- import { EventDispatcher } from '../../../event-dispatcher';
14
- import { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
15
- import { MediaOptions } from '../types';
16
- import { MediaSingleNodeProps, MediaSingleNodeViewProps } from './types';
10
+ import type { CardEvent } from '@atlaskit/media-card';
11
+ import type { MediaClientConfig } from '@atlaskit/media-core';
12
+ import type { getPosHandler, ForwardRef } from '../../../nodeviews/';
13
+ import type { EventDispatcher } from '../../../event-dispatcher';
14
+ import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
15
+ import type { MediaOptions } from '../types';
16
+ import type { MediaSingleNodeProps, MediaSingleNodeViewProps } from './types';
17
17
  import { MediaNodeUpdater } from './mediaNodeUpdater';
18
18
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
19
19
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
@@ -1,17 +1,21 @@
1
- import { Node as PMNode, Schema } from 'prosemirror-model';
1
+ import type { Node as PMNode, Schema } from 'prosemirror-model';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import { EditorState } from 'prosemirror-state';
4
- import { EditorView } from 'prosemirror-view';
5
- import { MediaClientConfig } from '@atlaskit/media-core';
6
- import { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
3
+ import type { EditorState } from 'prosemirror-state';
4
+ import type { EditorView } from 'prosemirror-view';
5
+ import type { MediaClientConfig } from '@atlaskit/media-core';
6
+ import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
7
7
  import type { ContextIdentifierProvider, MediaProvider } from '@atlaskit/editor-common/provider-factory';
8
- import { Dispatch } from '../../../event-dispatcher';
9
- import { ProsemirrorGetPosHandler } from '../../../nodeviews';
10
- import { MediaPluginOptions } from '../media-plugin-options';
11
- import { MediaOptions, MediaState, MediaStateStatus } from '../types';
12
- import PickerFacade, { MediaStateEventSubscriber } from '../picker-facade';
13
- import { MediaNodeWithPosHandler, MediaPluginState } from './types';
14
- import { IntlShape } from 'react-intl-next';
8
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
9
+ import type { WidthPluginState } from '@atlaskit/editor-plugin-width';
10
+ import type { Dispatch } from '../../../event-dispatcher';
11
+ import type { ProsemirrorGetPosHandler } from '../../../nodeviews';
12
+ import type { MediaPluginOptions } from '../media-plugin-options';
13
+ import type { MediaOptions, MediaState, MediaStateStatus } from '../types';
14
+ import type { MediaStateEventSubscriber } from '../picker-facade';
15
+ import PickerFacade from '../picker-facade';
16
+ import type { MediaNodeWithPosHandler, MediaPluginState } from './types';
17
+ import type { IntlShape } from 'react-intl-next';
18
+ import type mediaPlugin from '../index';
15
19
  export type { MediaState, MediaProvider, MediaStateStatus };
16
20
  export { stateKey } from './plugin-key';
17
21
  export declare const MEDIA_CONTENT_WRAP_CLASS_NAME = "media-content-wrap";
@@ -46,7 +50,8 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
46
50
  showEditingDialog?: boolean;
47
51
  mediaOptions?: MediaOptions;
48
52
  dispatch?: Dispatch;
49
- constructor(state: EditorState, options: MediaPluginOptions, mediaOptions?: MediaOptions, newInsertionBehaviour?: boolean, dispatch?: Dispatch);
53
+ widthPluginState?: WidthPluginState | undefined;
54
+ constructor(state: EditorState, options: MediaPluginOptions, mediaOptions?: MediaOptions, newInsertionBehaviour?: boolean, dispatch?: Dispatch, pluginInjectionApi?: ExtractInjectionAPI<typeof mediaPlugin> | undefined);
50
55
  onContextIdentifierProvider: (_name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>;
51
56
  setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
52
57
  getMediaOptions: () => MediaPluginOptions;
@@ -105,4 +110,4 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
105
110
  updateAndDispatch(props: Partial<Pick<this, 'allowsUploads' | 'allUploadsFinished' | 'isFullscreen'>>): void;
106
111
  }
107
112
  export declare const getMediaPluginState: (state: EditorState) => MediaPluginState;
108
- export declare const createPlugin: (_schema: Schema, options: MediaPluginOptions, reactContext: () => {}, getIntl: () => IntlShape, dispatch?: Dispatch, mediaOptions?: MediaOptions, newInsertionBehaviour?: boolean) => SafePlugin<MediaPluginState>;
113
+ export declare const createPlugin: (_schema: Schema, options: MediaPluginOptions, reactContext: () => {}, getIntl: () => IntlShape, dispatch?: Dispatch, mediaOptions?: MediaOptions, newInsertionBehaviour?: boolean, pluginInjectionApi?: ExtractInjectionAPI<typeof mediaPlugin> | undefined) => SafePlugin<MediaPluginState>;
@@ -1,8 +1,10 @@
1
- import { Node as PMNode, Schema, Slice } from 'prosemirror-model';
2
- import { EditorView } from 'prosemirror-view';
3
- import { Selection } from 'prosemirror-state';
4
- import { MediaState } from '../types';
5
- import { InputMethodInsertMedia } from '@atlaskit/editor-common/analytics';
1
+ import type { Node as PMNode, Schema } from 'prosemirror-model';
2
+ import { Slice } from 'prosemirror-model';
3
+ import type { EditorView } from 'prosemirror-view';
4
+ import type { Selection } from 'prosemirror-state';
5
+ import type { MediaState } from '../types';
6
+ import type { InputMethodInsertMedia } from '@atlaskit/editor-common/analytics';
7
+ import type { WidthPluginState } from '@atlaskit/editor-plugin-width';
6
8
  export interface MediaSingleState extends MediaState {
7
9
  dimensions: {
8
10
  width: number;
@@ -13,7 +15,7 @@ export interface MediaSingleState extends MediaState {
13
15
  }
14
16
  export declare const isMediaSingle: (schema: Schema, fileMimeType?: string) => boolean;
15
17
  export declare const insertMediaAsMediaSingle: (view: EditorView, node: PMNode, inputMethod: InputMethodInsertMedia) => boolean;
16
- export declare const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, newInsertionBehaviour?: boolean) => boolean;
17
- export declare const createMediaSingleNode: (schema: Schema, collection: string, alignLeftOnInsert?: boolean) => (mediaState: MediaSingleState) => PMNode;
18
+ export declare const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, newInsertionBehaviour?: boolean, widthPluginState?: WidthPluginState | undefined) => boolean;
19
+ export declare const createMediaSingleNode: (schema: Schema, collection: string, maxWidth?: number, minWidth?: number, alignLeftOnInsert?: boolean) => (mediaState: MediaSingleState) => PMNode;
18
20
  export declare function transformSliceForMedia(slice: Slice, schema: Schema): (selection: Selection) => Slice;
19
21
  export declare function isCaptionNode(editorView: EditorView): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.5.5",
3
+ "version": "187.6.0",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@atlaskit/activity-provider": "^2.4.0",
43
- "@atlaskit/adf-schema": "^26.2.0",
43
+ "@atlaskit/adf-schema": "^26.3.0",
44
44
  "@atlaskit/adf-utils": "^19.0.0",
45
45
  "@atlaskit/analytics-gas-types": "^5.1.0",
46
46
  "@atlaskit/analytics-listeners": "^8.7.0",
package/report.api.md CHANGED
@@ -90,7 +90,7 @@ import type { gridPlugin } from '@atlaskit/editor-plugin-grid';
90
90
  import { HeadingLevelsAndNormalText } from '@atlaskit/editor-common/types';
91
91
  import type { HyperlinkPluginOptions } from '@atlaskit/editor-common/types';
92
92
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
93
- import { InputMethodInsertMedia } from '@atlaskit/editor-common/analytics';
93
+ import type { InputMethodInsertMedia } from '@atlaskit/editor-common/analytics';
94
94
  import { InputTracking } from '@atlaskit/editor-common/types';
95
95
  import { IntlShape } from 'react-intl-next';
96
96
  import { JSONDocNode } from '@atlaskit/editor-json-transformer/types';
@@ -116,7 +116,7 @@ import { Node as Node_2 } from 'prosemirror-model';
116
116
  import { NodeConfig } from '@atlaskit/editor-common/types';
117
117
  import { NodeType } from 'prosemirror-model';
118
118
  import { NodeView } from 'prosemirror-view';
119
- import { OptionalPlugin } from '@atlaskit/editor-common/types';
119
+ import type { OptionalPlugin } from '@atlaskit/editor-common/types';
120
120
  import { PaletteColor } from '@atlaskit/editor-common/ui-color';
121
121
  import { PerformanceTracking } from '@atlaskit/editor-common/types';
122
122
  import type { PluginConfig } from '@atlaskit/editor-plugin-table/types';
@@ -166,6 +166,7 @@ import { UploadParams } from '@atlaskit/media-picker/types';
166
166
  import { UploadPreviewUpdateEventPayload } from '@atlaskit/media-picker/types';
167
167
  import type { WeekDay } from '@atlaskit/calendar/types';
168
168
  import type { widthPlugin } from '@atlaskit/editor-plugin-width';
169
+ import type { WidthPluginState } from '@atlaskit/editor-plugin-width';
169
170
  import { WithIntlProps } from 'react-intl-next';
170
171
  import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
171
172
  import { WrappedComponentProps } from 'react-intl-next';
@@ -1247,6 +1248,7 @@ export const insertMediaSingleNode: (
1247
1248
  collection?: string,
1248
1249
  alignLeftOnInsert?: boolean,
1249
1250
  newInsertionBehaviour?: boolean,
1251
+ widthPluginState?: WidthPluginState | undefined,
1250
1252
  ) => boolean;
1251
1253
 
1252
1254
  // @public (undocumented)
@@ -79,7 +79,7 @@ import type { gridPlugin } from '@atlaskit/editor-plugin-grid';
79
79
  import { HeadingLevelsAndNormalText } from '@atlaskit/editor-common/types';
80
80
  import type { HyperlinkPluginOptions } from '@atlaskit/editor-common/types';
81
81
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
82
- import { InputMethodInsertMedia } from '@atlaskit/editor-common/analytics';
82
+ import type { InputMethodInsertMedia } from '@atlaskit/editor-common/analytics';
83
83
  import { InputTracking } from '@atlaskit/editor-common/types';
84
84
  import { IntlShape } from 'react-intl-next';
85
85
  import { JSONDocNode } from '@atlaskit/editor-json-transformer/types';
@@ -105,7 +105,7 @@ import { Node as Node_2 } from 'prosemirror-model';
105
105
  import { NodeConfig } from '@atlaskit/editor-common/types';
106
106
  import { NodeType } from 'prosemirror-model';
107
107
  import { NodeView } from 'prosemirror-view';
108
- import { OptionalPlugin } from '@atlaskit/editor-common/types';
108
+ import type { OptionalPlugin } from '@atlaskit/editor-common/types';
109
109
  import { PaletteColor } from '@atlaskit/editor-common/ui-color';
110
110
  import { PerformanceTracking } from '@atlaskit/editor-common/types';
111
111
  import type { PluginConfig } from '@atlaskit/editor-plugin-table/types';
@@ -155,6 +155,7 @@ import { UploadParams } from '@atlaskit/media-picker/types';
155
155
  import { UploadPreviewUpdateEventPayload } from '@atlaskit/media-picker/types';
156
156
  import type { WeekDay } from '@atlaskit/calendar/types';
157
157
  import type { widthPlugin } from '@atlaskit/editor-plugin-width';
158
+ import type { WidthPluginState } from '@atlaskit/editor-plugin-width';
158
159
  import { WithIntlProps } from 'react-intl-next';
159
160
  import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
160
161
  import { WrappedComponentProps } from 'react-intl-next';
@@ -1128,7 +1129,7 @@ type InsertItemProps = {
1128
1129
  };
1129
1130
 
1130
1131
  // @public (undocumented)
1131
- export const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, newInsertionBehaviour?: boolean) => boolean;
1132
+ export const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, newInsertionBehaviour?: boolean, widthPluginState?: WidthPluginState | undefined) => boolean;
1132
1133
 
1133
1134
  // @public (undocumented)
1134
1135
  export const insertTaskDecisionCommand: (listType: TaskDecisionListType, inputMethod?: INPUT_METHOD.FORMATTING | INPUT_METHOD.QUICK_INSERT | InsertBlockInputMethodToolbar, addItem?: AddItemTransactionCreator, listLocalId?: string, itemLocalId?: string) => Command;