@atlaskit/editor-core 187.43.11 → 187.43.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 187.43.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [`621b904a076`](https://bitbucket.org/atlassian/atlassian-frontend/commits/621b904a076) - ED-19729 fix behaviour of image floating toolbar layout
8
+
3
9
  ## 187.43.11
4
10
 
5
11
  ### Patch Changes
@@ -366,7 +366,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
366
366
  origWidth: width,
367
367
  layout: layout,
368
368
  // This will only be used when calculating legacy media single width
369
- // thus we use the legecy value (exclude table as container node)
369
+ // thus we use the legacy value (exclude table as container node)
370
370
  contentWidth: contentWidthForLegacyExperience,
371
371
  containerWidth: containerWidth,
372
372
  gutterOffset: _mediaSingle.MEDIA_SINGLE_GUTTER_SIZE
@@ -41,6 +41,7 @@ var _CaptionPlaceholder = require("../ui/CaptionPlaceholder");
41
41
  var _reactIntlNext = require("react-intl-next");
42
42
  var _mediaTaskManager = require("./mediaTaskManager");
43
43
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
44
+ var _mediaSingle2 = require("@atlaskit/editor-common/media-single");
44
45
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
45
46
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
46
47
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
@@ -515,6 +516,11 @@ var MediaPluginStateImplementation = /*#__PURE__*/function () {
515
516
  var selectedContainer = this.selectedMediaContainerNode();
516
517
  if (selectedContainer && this.isMediaSchemaNode(selectedContainer)) {
517
518
  newElement = this.getDomElement(this.view.domAtPos.bind(this.view));
519
+ if (selectedContainer.type === this.view.state.schema.nodes.mediaSingle) {
520
+ this.currentMaxWidth = (0, _mediaSingle2.getMaxWidthForNestedNodeNext)(this.view, this.view.state.selection.$anchor.pos) || undefined;
521
+ } else {
522
+ this.currentMaxWidth = undefined;
523
+ }
518
524
  }
519
525
  if (this.element !== newElement) {
520
526
  this.element = newElement;
@@ -246,11 +246,9 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
246
246
  var _widthPlugin$sharedSt;
247
247
  var contentWidth = widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength;
248
248
  var selectedNode = (0, _utils2.getSelectedMediaSingle)(state);
249
- if (selectedNode && contentWidth) {
250
- var width = selectedNode.node.attrs.width;
251
- if (width >= contentWidth) {
252
- isChangingLayoutDisabled = true;
253
- }
249
+ var selectedNodeMaxWidth = pluginState.currentMaxWidth || contentWidth;
250
+ if (selectedNode && selectedNodeMaxWidth && selectedNode.node.attrs.width >= selectedNodeMaxWidth) {
251
+ isChangingLayoutDisabled = true;
254
252
  }
255
253
  }
256
254
  var layoutButtons = (0, _card.buildLayoutButtons)(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
@@ -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.43.11";
9
+ var version = "187.43.12";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -273,7 +273,7 @@ export default class MediaSingleNode extends Component {
273
273
  origWidth: width,
274
274
  layout,
275
275
  // This will only be used when calculating legacy media single width
276
- // thus we use the legecy value (exclude table as container node)
276
+ // thus we use the legacy value (exclude table as container node)
277
277
  contentWidth: contentWidthForLegacyExperience,
278
278
  containerWidth,
279
279
  gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
@@ -24,6 +24,7 @@ import { CAPTION_PLACEHOLDER_ID } from '../ui/CaptionPlaceholder';
24
24
  import { RawIntlProvider } from 'react-intl-next';
25
25
  import { MediaTaskManager } from './mediaTaskManager';
26
26
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
27
+ import { getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
27
28
  export { stateKey } from './plugin-key';
28
29
  export const MEDIA_CONTENT_WRAP_CLASS_NAME = 'media-content-wrap';
29
30
  export const MEDIA_PLUGIN_IS_RESIZING_KEY = 'mediaSinglePlugin.isResizing';
@@ -437,6 +438,11 @@ export class MediaPluginStateImplementation {
437
438
  const selectedContainer = this.selectedMediaContainerNode();
438
439
  if (selectedContainer && this.isMediaSchemaNode(selectedContainer)) {
439
440
  newElement = this.getDomElement(this.view.domAtPos.bind(this.view));
441
+ if (selectedContainer.type === this.view.state.schema.nodes.mediaSingle) {
442
+ this.currentMaxWidth = getMaxWidthForNestedNodeNext(this.view, this.view.state.selection.$anchor.pos) || undefined;
443
+ } else {
444
+ this.currentMaxWidth = undefined;
445
+ }
440
446
  }
441
447
  if (this.element !== newElement) {
442
448
  this.element = newElement;
@@ -246,13 +246,9 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
246
246
  var _widthPlugin$sharedSt;
247
247
  const contentWidth = widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength;
248
248
  const selectedNode = getSelectedMediaSingle(state);
249
- if (selectedNode && contentWidth) {
250
- const {
251
- width
252
- } = selectedNode.node.attrs;
253
- if (width >= contentWidth) {
254
- isChangingLayoutDisabled = true;
255
- }
249
+ const selectedNodeMaxWidth = pluginState.currentMaxWidth || contentWidth;
250
+ if (selectedNode && selectedNodeMaxWidth && selectedNode.node.attrs.width >= selectedNodeMaxWidth) {
251
+ isChangingLayoutDisabled = true;
256
252
  }
257
253
  }
258
254
  const layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.43.11";
2
+ export const version = "187.43.12";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -357,7 +357,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
357
357
  origWidth: width,
358
358
  layout: layout,
359
359
  // This will only be used when calculating legacy media single width
360
- // thus we use the legecy value (exclude table as container node)
360
+ // thus we use the legacy value (exclude table as container node)
361
361
  contentWidth: contentWidthForLegacyExperience,
362
362
  containerWidth: containerWidth,
363
363
  gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
@@ -33,6 +33,7 @@ import { CAPTION_PLACEHOLDER_ID } from '../ui/CaptionPlaceholder';
33
33
  import { RawIntlProvider } from 'react-intl-next';
34
34
  import { MediaTaskManager } from './mediaTaskManager';
35
35
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
36
+ import { getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
36
37
  export { stateKey } from './plugin-key';
37
38
  export var MEDIA_CONTENT_WRAP_CLASS_NAME = 'media-content-wrap';
38
39
  export var MEDIA_PLUGIN_IS_RESIZING_KEY = 'mediaSinglePlugin.isResizing';
@@ -498,6 +499,11 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
498
499
  var selectedContainer = this.selectedMediaContainerNode();
499
500
  if (selectedContainer && this.isMediaSchemaNode(selectedContainer)) {
500
501
  newElement = this.getDomElement(this.view.domAtPos.bind(this.view));
502
+ if (selectedContainer.type === this.view.state.schema.nodes.mediaSingle) {
503
+ this.currentMaxWidth = getMaxWidthForNestedNodeNext(this.view, this.view.state.selection.$anchor.pos) || undefined;
504
+ } else {
505
+ this.currentMaxWidth = undefined;
506
+ }
501
507
  }
502
508
  if (this.element !== newElement) {
503
509
  this.element = newElement;
@@ -239,11 +239,9 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
239
239
  var _widthPlugin$sharedSt;
240
240
  var contentWidth = widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength;
241
241
  var selectedNode = getSelectedMediaSingle(state);
242
- if (selectedNode && contentWidth) {
243
- var width = selectedNode.node.attrs.width;
244
- if (width >= contentWidth) {
245
- isChangingLayoutDisabled = true;
246
- }
242
+ var selectedNodeMaxWidth = pluginState.currentMaxWidth || contentWidth;
243
+ if (selectedNode && selectedNodeMaxWidth && selectedNode.node.attrs.width >= selectedNodeMaxWidth) {
244
+ isChangingLayoutDisabled = true;
247
245
  }
248
246
  }
249
247
  var layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "187.43.11";
2
+ export var version = "187.43.12";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -37,6 +37,7 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
37
37
  newInsertionBehaviour?: boolean;
38
38
  isResizing: boolean;
39
39
  resizingWidth: number;
40
+ currentMaxWidth?: number;
40
41
  private view;
41
42
  private destroyed;
42
43
  private contextIdentifierProvider?;
@@ -34,6 +34,7 @@ export interface MediaPluginState {
34
34
  mediaOptions?: MediaOptions;
35
35
  isResizing: boolean;
36
36
  resizingWidth: number;
37
+ currentMaxWidth?: number;
37
38
  dispatch?: Dispatch;
38
39
  onContextIdentifierProvider: (_name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>;
39
40
  setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
@@ -37,6 +37,7 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
37
37
  newInsertionBehaviour?: boolean;
38
38
  isResizing: boolean;
39
39
  resizingWidth: number;
40
+ currentMaxWidth?: number;
40
41
  private view;
41
42
  private destroyed;
42
43
  private contextIdentifierProvider?;
@@ -34,6 +34,7 @@ export interface MediaPluginState {
34
34
  mediaOptions?: MediaOptions;
35
35
  isResizing: boolean;
36
36
  resizingWidth: number;
37
+ currentMaxWidth?: number;
37
38
  dispatch?: Dispatch;
38
39
  onContextIdentifierProvider: (_name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>;
39
40
  setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.43.11",
3
+ "version": "187.43.12",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
package/report.api.md CHANGED
@@ -1290,6 +1290,8 @@ interface MediaPluginState {
1290
1290
  // (undocumented)
1291
1291
  allUploadsFinished: boolean;
1292
1292
  // (undocumented)
1293
+ currentMaxWidth?: number;
1294
+ // (undocumented)
1293
1295
  destroy(): void;
1294
1296
  // (undocumented)
1295
1297
  dispatch?: Dispatch;
@@ -1172,6 +1172,8 @@ interface MediaPluginState {
1172
1172
  // (undocumented)
1173
1173
  allUploadsFinished: boolean;
1174
1174
  // (undocumented)
1175
+ currentMaxWidth?: number;
1176
+ // (undocumented)
1175
1177
  destroy(): void;
1176
1178
  // (undocumented)
1177
1179
  dispatch?: Dispatch;