@atlaskit/editor-common 74.37.0 → 74.38.1

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 (77) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/guideline/constants.js +4 -2
  3. package/dist/cjs/guideline/defaultGuideline.js +4 -3
  4. package/dist/cjs/guideline/index.js +10 -4
  5. package/dist/cjs/guideline/snapping.js +42 -30
  6. package/dist/cjs/keymaps/index.js +11 -7
  7. package/dist/cjs/media-single/utils.js +1 -1
  8. package/dist/cjs/monitoring/error.js +1 -1
  9. package/dist/cjs/preset/index.js +8 -1
  10. package/dist/cjs/preset/plugin-commands.js +19 -0
  11. package/dist/cjs/preset/plugin-injection-api.js +28 -1
  12. package/dist/cjs/types/plugin-command.js +5 -0
  13. package/dist/cjs/ui/DropList/index.js +1 -1
  14. package/dist/cjs/ui/MediaSingle/styled.js +1 -11
  15. package/dist/cjs/utils/rich-media-utils.js +6 -3
  16. package/dist/cjs/version.json +1 -1
  17. package/dist/es2019/guideline/constants.js +2 -1
  18. package/dist/es2019/guideline/defaultGuideline.js +4 -3
  19. package/dist/es2019/guideline/index.js +2 -2
  20. package/dist/es2019/guideline/snapping.js +35 -27
  21. package/dist/es2019/keymaps/index.js +10 -7
  22. package/dist/es2019/media-single/utils.js +1 -1
  23. package/dist/es2019/monitoring/error.js +1 -1
  24. package/dist/es2019/preset/index.js +2 -1
  25. package/dist/es2019/preset/plugin-commands.js +14 -0
  26. package/dist/es2019/preset/plugin-injection-api.js +21 -1
  27. package/dist/es2019/types/plugin-command.js +1 -0
  28. package/dist/es2019/ui/DropList/index.js +1 -1
  29. package/dist/es2019/ui/MediaSingle/styled.js +11 -24
  30. package/dist/es2019/utils/rich-media-utils.js +6 -3
  31. package/dist/es2019/version.json +1 -1
  32. package/dist/esm/guideline/constants.js +2 -1
  33. package/dist/esm/guideline/defaultGuideline.js +4 -3
  34. package/dist/esm/guideline/index.js +2 -2
  35. package/dist/esm/guideline/snapping.js +40 -28
  36. package/dist/esm/keymaps/index.js +10 -7
  37. package/dist/esm/media-single/utils.js +1 -1
  38. package/dist/esm/monitoring/error.js +1 -1
  39. package/dist/esm/preset/index.js +2 -1
  40. package/dist/esm/preset/plugin-commands.js +13 -0
  41. package/dist/esm/preset/plugin-injection-api.js +28 -1
  42. package/dist/esm/types/plugin-command.js +1 -0
  43. package/dist/esm/ui/DropList/index.js +1 -1
  44. package/dist/esm/ui/MediaSingle/styled.js +3 -12
  45. package/dist/esm/utils/rich-media-utils.js +6 -3
  46. package/dist/esm/version.json +1 -1
  47. package/dist/types/guideline/constants.d.ts +1 -0
  48. package/dist/types/guideline/dynamicGuideline.d.ts +1 -1
  49. package/dist/types/guideline/index.d.ts +3 -3
  50. package/dist/types/guideline/snapping.d.ts +12 -11
  51. package/dist/types/guideline/types.d.ts +13 -2
  52. package/dist/types/keymaps/index.d.ts +5 -1
  53. package/dist/types/media-single/utils.d.ts +1 -1
  54. package/dist/types/preset/index.d.ts +1 -0
  55. package/dist/types/preset/plugin-commands.d.ts +3 -0
  56. package/dist/types/preset/plugin-injection-api.d.ts +1 -0
  57. package/dist/types/types/index.d.ts +1 -0
  58. package/dist/types/types/next-editor-plugin.d.ts +10 -1
  59. package/dist/types/types/plugin-command.d.ts +7 -0
  60. package/dist/types/ui/MediaSingle/styled.d.ts +3 -2
  61. package/dist/types/utils/rich-media-utils.d.ts +1 -1
  62. package/dist/types-ts4.5/guideline/constants.d.ts +1 -0
  63. package/dist/types-ts4.5/guideline/dynamicGuideline.d.ts +1 -1
  64. package/dist/types-ts4.5/guideline/index.d.ts +3 -3
  65. package/dist/types-ts4.5/guideline/snapping.d.ts +12 -11
  66. package/dist/types-ts4.5/guideline/types.d.ts +13 -2
  67. package/dist/types-ts4.5/keymaps/index.d.ts +5 -1
  68. package/dist/types-ts4.5/media-single/utils.d.ts +1 -1
  69. package/dist/types-ts4.5/preset/index.d.ts +1 -0
  70. package/dist/types-ts4.5/preset/plugin-commands.d.ts +3 -0
  71. package/dist/types-ts4.5/preset/plugin-injection-api.d.ts +1 -0
  72. package/dist/types-ts4.5/types/index.d.ts +1 -0
  73. package/dist/types-ts4.5/types/next-editor-plugin.d.ts +10 -1
  74. package/dist/types-ts4.5/types/plugin-command.d.ts +7 -0
  75. package/dist/types-ts4.5/ui/MediaSingle/styled.d.ts +3 -2
  76. package/dist/types-ts4.5/utils/rich-media-utils.d.ts +1 -1
  77. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
2
2
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
3
- const packageVersion = "74.37.0";
3
+ const packageVersion = "74.38.1";
4
4
  const sanitiseSentryEvents = (data, _hint) => {
5
5
  // Remove URL as it has UGC
6
6
  // TODO: Sanitise the URL instead of just removing it
@@ -1,2 +1,3 @@
1
1
  export { EditorPresetBuilder } from './builder';
2
- export { EditorPluginInjectionAPI } from './plugin-injection-api';
2
+ export { EditorPluginInjectionAPI } from './plugin-injection-api';
3
+ export { pluginCommandToPMCommand } from './plugin-commands';
@@ -0,0 +1,14 @@
1
+ export function pluginCommandToPMCommand(command) {
2
+ return ({
3
+ tr
4
+ }, dispatch) => {
5
+ const newTr = command === null || command === void 0 ? void 0 : command({
6
+ tr
7
+ });
8
+ if (newTr) {
9
+ dispatch === null || dispatch === void 0 ? void 0 : dispatch(newTr);
10
+ return true;
11
+ }
12
+ return false;
13
+ };
14
+ }
@@ -7,6 +7,9 @@ function hasGetSharedState(plugin) {
7
7
  function hasActions(plugin) {
8
8
  return typeof plugin.actions === 'object';
9
9
  }
10
+ function hasCommands(plugin) {
11
+ return typeof plugin.commands === 'object';
12
+ }
10
13
  const filterPluginsWithListeners = ({
11
14
  listeners,
12
15
  plugins
@@ -70,6 +73,19 @@ class ActionsAPI {
70
73
  });
71
74
  }
72
75
  }
76
+ class PluginCommandsAPI {
77
+ createAPI(plugin) {
78
+ if (!plugin || !hasCommands(plugin)) {
79
+ return {};
80
+ }
81
+ return new Proxy(plugin.commands || {}, {
82
+ get: function (target, prop, receiver) {
83
+ // We will be able to track perfomance here
84
+ return Reflect.get(target, prop);
85
+ }
86
+ });
87
+ }
88
+ }
73
89
  export class SharedStateAPI {
74
90
  constructor({
75
91
  getEditorState
@@ -171,11 +187,13 @@ export class EditorPluginInjectionAPI {
171
187
  });
172
188
  this.plugins = new Map();
173
189
  this.actionsAPI = new ActionsAPI();
190
+ this.commandsAPI = new PluginCommandsAPI();
174
191
  }
175
192
  api() {
176
193
  const {
177
194
  sharedStateAPI,
178
195
  actionsAPI,
196
+ commandsAPI,
179
197
  getPluginByName
180
198
  } = this;
181
199
  const dependencies = new Proxy({}, {
@@ -195,9 +213,11 @@ export class EditorPluginInjectionAPI {
195
213
  }
196
214
  const sharedState = sharedStateAPI.createAPI(plugin);
197
215
  const actions = actionsAPI.createAPI(plugin);
216
+ const commands = commandsAPI.createAPI(plugin);
198
217
  const proxyCoreAPI = {
199
218
  sharedState,
200
- actions
219
+ actions,
220
+ commands
201
221
  };
202
222
  return proxyCoreAPI;
203
223
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -8,7 +8,7 @@ import { themed } from '@atlaskit/theme/components';
8
8
  import { borderRadius } from '@atlaskit/theme/constants';
9
9
  import Layer from '../Layer';
10
10
  const packageName = "@atlaskit/editor-common";
11
- const packageVersion = "74.37.0";
11
+ const packageVersion = "74.38.1";
12
12
  const halfFocusRing = 1;
13
13
  const dropOffset = '0, 8';
14
14
  class DropList extends Component {
@@ -1,7 +1,8 @@
1
1
  /** @jsx jsx */
2
+
2
3
  import React from 'react';
3
4
  import { css, jsx } from '@emotion/react';
4
- import { akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth, akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
5
+ import { akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
5
6
  import { calcMediaSingleMaxWidth } from '../../media-single';
6
7
  import { nonWrappedLayouts } from '../../utils';
7
8
  import { calcBreakoutWidth, calcWideWidth } from '../../utils/breakout';
@@ -77,16 +78,6 @@ const getEffectiveFullWidth = (containerWidth, fullWidthMode) => {
77
78
  }
78
79
  return `${calcMediaSingleMaxWidth(containerWidth)}px`;
79
80
  };
80
- const calcMaxWidthWhenResizing = (containerWidth, fullWidthMode, isNestedNode) => {
81
- if (isNestedNode) {
82
- return '100%';
83
- }
84
- // non-nested node can resize up to full width
85
- return getEffectiveFullWidth(containerWidth, fullWidthMode);
86
- };
87
- const calcMaxWidthWhenNotResizing = (containerWidth, mediaSingleWidth) => {
88
- return `${Math.min(mediaSingleWidth, containerWidth - akEditorGutterPadding * 2)}px`;
89
- };
90
81
  function calcMargin(layout) {
91
82
  switch (layout) {
92
83
  case 'wrap-right':
@@ -134,25 +125,21 @@ export const MediaSingleDimensionHelper = ({
134
125
  min-width: 100%;
135
126
  `}
136
127
  max-width: ${calcMaxWidth(layout, containerWidth)};
137
- &[class*='is-resizing'] {
138
- ${isExtendedResizeExperienceOn && `max-width: ${calcMaxWidthWhenResizing(containerWidth, fullWidthMode, isNestedNode)};
139
-
140
- ${nonWrappedLayouts.includes(layout) && `margin-left: 50%;
141
- transform: translateX(-50%);`}
142
128
 
129
+ ${isExtendedResizeExperienceOn && `&[class*='is-resizing'] {
143
130
  .new-file-experience-wrapper {
144
- box-shadow: none;
145
- }`}
146
- }
131
+ box-shadow: none !important;
132
+ }
147
133
 
148
- /* Handles responsiveness of non-nested, not-resizing nodes in editor */
149
- &[class*='not-resizing'] {
150
- ${!isNestedNode && `max-width: ${layout !== 'full-width' && mediaSingleWidth && calcMaxWidthWhenNotResizing(containerWidth, mediaSingleWidth)};
134
+ ${!isNestedNode && nonWrappedLayouts.includes(layout) && `margin-left: 50%;
135
+ transform: translateX(-50%);`}
136
+ }`}
151
137
 
152
- ${nonWrappedLayouts.includes(layout) && `margin-left: 50%;
138
+ &[class*='not-resizing'] {
139
+ ${!isNestedNode && `${nonWrappedLayouts.includes(layout) && `margin-left: 50%;
153
140
  transform: translateX(-50%);`}
154
141
 
155
- // override min-width to counteract max-width set in old experience
142
+ // override min-width to counteract max-width set by ResizerNext inline style
156
143
  ${layout === 'full-width' && `min-width: ${getEffectiveFullWidth(containerWidth, fullWidthMode)} !important;`};`}
157
144
  }
158
145
 
@@ -6,7 +6,7 @@ export const shouldAddDefaultWrappedWidth = (layout, width, lineLength) => {
6
6
  };
7
7
  export const nonWrappedLayouts = ['center', 'wide', 'full-width'];
8
8
  export const floatingLayouts = ['wrap-left', 'wrap-right'];
9
- export const isRichMediaInsideOfBlockNode = (view, pos) => {
9
+ export const isRichMediaInsideOfBlockNode = (view, pos, includeMoreParentNodeTypes) => {
10
10
  if (typeof pos !== 'number' || isNaN(pos) || !view) {
11
11
  return false;
12
12
  }
@@ -14,9 +14,12 @@ export const isRichMediaInsideOfBlockNode = (view, pos) => {
14
14
  const {
15
15
  expand,
16
16
  nestedExpand,
17
- layoutColumn
17
+ layoutColumn,
18
+ tableCell,
19
+ listItem
18
20
  } = view.state.schema.nodes;
19
- return !!findParentNodeOfTypeClosestToPos($pos, [expand, nestedExpand, layoutColumn]);
21
+ const parentNodeTypes = [expand, nestedExpand, layoutColumn];
22
+ return !!findParentNodeOfTypeClosestToPos($pos, includeMoreParentNodeTypes ? [...parentNodeTypes, tableCell, listItem] : parentNodeTypes);
20
23
  };
21
24
  export const alignAttributes = (layout, oldAttrs, gridSize = 12, originalWidth, lineLength) => {
22
25
  let width = oldAttrs.width;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.37.0",
3
+ "version": "74.38.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1 +1,2 @@
1
- export var MEDIA_DYNAMIC_GUIDELINE_PREFIX = 'media_';
1
+ export var MEDIA_DYNAMIC_GUIDELINE_PREFIX = 'media_';
2
+ export var INNER_GRID_GUIDELINE_PREFIX = 'grid_';
@@ -1,19 +1,20 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import memoizeOne from 'memoize-one';
3
3
  import { breakoutWideScaleRatio } from '@atlaskit/editor-shared-styles';
4
+ import { roundToNearest } from '../media-single';
4
5
  import { getContainerWidthOrFullEditorWidth } from './utils';
5
6
  var getDefaultGuidelines = memoizeOne(function (editorWidth) {
6
7
  return [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6].map(function (val, index) {
7
8
  return {
8
9
  key: "grid_".concat(index),
9
10
  position: {
10
- x: val / 12 * editorWidth
11
+ x: roundToNearest(val / 12 * editorWidth)
11
12
  }
12
13
  };
13
14
  });
14
15
  });
15
16
  var getWideGuidelines = memoizeOne(function (editorWidth) {
16
- var wideSpacing = editorWidth * breakoutWideScaleRatio / 2;
17
+ var wideSpacing = roundToNearest(editorWidth * breakoutWideScaleRatio / 2);
17
18
  return [{
18
19
  key: "wide_left",
19
20
  position: {
@@ -27,7 +28,7 @@ var getWideGuidelines = memoizeOne(function (editorWidth) {
27
28
  }];
28
29
  });
29
30
  var getFullWidthGuidelines = memoizeOne(function (containerWidth) {
30
- var fullWidth = getContainerWidthOrFullEditorWidth(containerWidth);
31
+ var fullWidth = roundToNearest(getContainerWidthOrFullEditorWidth(containerWidth));
31
32
  return [{
32
33
  key: "full_width_left",
33
34
  position: {
@@ -2,6 +2,6 @@ export { generateDynamicGuidelines } from './dynamicGuideline';
2
2
  export { createFixedGuidelinesFromLengths, createGuidesFromLengths } from './fixedGuideline';
3
3
  export { generateDefaultGuidelines } from './defaultGuideline';
4
4
  export { getGuidelinesWithHighlights } from './updateGuideline';
5
- export { MEDIA_DYNAMIC_GUIDELINE_PREFIX } from './constants';
6
- export { getSnapWidth, findClosestSnap } from './snapping';
5
+ export { MEDIA_DYNAMIC_GUIDELINE_PREFIX, INNER_GRID_GUIDELINE_PREFIX } from './constants';
6
+ export { getGuidelineSnaps, findClosestSnap } from './snapping';
7
7
  export { isVerticalPosition, getContainerWidthOrFullEditorWidth } from './utils';
@@ -1,21 +1,25 @@
1
- import { MediaSingleLayout } from '../media-single';
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import memoizeOne from 'memoize-one';
2
3
  import { MEDIA_DYNAMIC_GUIDELINE_PREFIX } from './constants';
4
+ import { isVerticalPosition } from './utils';
5
+
3
6
  /**
4
7
  * Returns keys of guidelines that are closest to the image and withthin the snapGap.
5
8
  * If both default and dynamic guidelines present, only returns default guidelines
6
9
  */
7
- export var findClosestSnap = function findClosestSnap(mediaSingleWidth, snapArray, snapTo) {
10
+ export var findClosestSnap = function findClosestSnap(mediaSingleWidth, snapArray, guidelineSnaps) {
8
11
  var snapGap = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
9
12
  var closestGapIndex = snapArray.reduce(function (prev, curr, index) {
10
13
  return Math.abs(curr - mediaSingleWidth) < Math.abs(snapArray[prev] - mediaSingleWidth) ? index : prev;
11
14
  }, 0);
12
15
  var gap = Math.abs(snapArray[closestGapIndex] - mediaSingleWidth);
13
16
  if (gap < snapGap) {
14
- var snappingWidth = Math.round(snapTo[closestGapIndex].width);
17
+ var snappingWidth = snapArray[closestGapIndex];
15
18
  var guidelineKeys = [];
16
- snapTo.forEach(function (s) {
17
- if (Math.round(Math.abs(s.width)) === snappingWidth) {
18
- guidelineKeys.push(s.guidelineKey);
19
+ // find wich guideline have the matching snap width
20
+ guidelineSnaps.forEach(function (gs) {
21
+ if (gs.width === snappingWidth) {
22
+ guidelineKeys.push(gs.guidelineKey);
19
23
  }
20
24
  });
21
25
  var defaultGuidelineKeys = guidelineKeys.filter(function (guidelineKey) {
@@ -33,35 +37,43 @@ export var findClosestSnap = function findClosestSnap(mediaSingleWidth, snapArra
33
37
  keys: []
34
38
  };
35
39
  };
36
-
37
- /**
38
- * Get snapping widths and respective guideline keys
39
- */
40
- export var getSnapWidth = function getSnapWidth(guidelines, mediaSingleWidth, snap, layout) {
41
- return guidelines.map(function (guideline) {
42
- var _guideline$position;
43
- var positionX = (_guideline$position = guideline.position) !== null && _guideline$position !== void 0 && _guideline$position.x && typeof guideline.position.x === 'number' ? guideline.position.x : 0;
44
- if (layout === MediaSingleLayout.CENTER || layout === MediaSingleLayout.WIDE || layout === MediaSingleLayout.FULL_WIDTH) {
45
- return {
46
- guidelineKey: guideline.key,
47
- width: mediaSingleWidth + (snap - positionX) * 2
48
- };
49
- } else if (layout === MediaSingleLayout.ALIGN_END || layout === MediaSingleLayout.WRAP_RIGHT) {
40
+ export var getGuidelineSnaps = memoizeOne(function (guidelines, editorWidth) {
41
+ var layout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'center';
42
+ var offset = editorWidth / 2;
43
+ var getPositionX = function getPositionX(position) {
44
+ return isVerticalPosition(position) ? position.x : 0;
45
+ };
46
+ var calcXSnaps = function calcXSnaps(guidelineReference) {
47
+ var snapsWidth = guidelineReference.filter(function (g) {
48
+ return g.width > 0;
49
+ }).map(function (g) {
50
+ return g.width;
51
+ });
52
+ var uniqueSnapWidth = _toConsumableArray(new Set(snapsWidth));
53
+ return snapsWidth.length ? uniqueSnapWidth : undefined;
54
+ };
55
+ var guidelinesSnapsReference = guidelines.map(function (guideline) {
56
+ var positionX = getPositionX(guideline.position);
57
+ if (['align-end', 'wrap-right'].includes(layout)) {
50
58
  return {
51
59
  guidelineKey: guideline.key,
52
- width: mediaSingleWidth + (snap - positionX)
60
+ width: offset - positionX
53
61
  };
54
- } else if (layout === MediaSingleLayout.ALIGN_START || layout === MediaSingleLayout.WRAP_LEFT) {
62
+ } else if (['align-start', 'wrap-left'].includes(layout)) {
55
63
  return {
56
64
  guidelineKey: guideline.key,
57
- width: mediaSingleWidth + positionX - snap
65
+ width: positionX + offset
58
66
  };
59
67
  }
60
68
  return {
61
- guidelineKey: '',
62
- width: 0
69
+ guidelineKey: guideline.key,
70
+ width: Math.abs(positionX) * 2
63
71
  };
64
- }).filter(function (guideline) {
65
- return guideline.guidelineKey !== '';
66
72
  });
67
- };
73
+ return {
74
+ guidelineReference: guidelinesSnapsReference,
75
+ snaps: {
76
+ x: calcXSnaps(guidelinesSnapsReference)
77
+ }
78
+ };
79
+ });
@@ -5,6 +5,7 @@ var _templateObject;
5
5
  import React, { Fragment } from 'react';
6
6
  import { css, jsx } from '@emotion/react';
7
7
  import { N400 } from '@atlaskit/theme/colors';
8
+ import { pluginCommandToPMCommand } from '../preset/plugin-commands';
8
9
  import { browser } from '../utils';
9
10
  export var addAltText = makeKeyMapWithCommon('Add Alt Text', 'Mod-Alt-y');
10
11
  export var navToEditorToolbar = makeKeyMapWithCommon('Navigate to editor toolbar', 'Alt-F9');
@@ -182,15 +183,17 @@ export function makeKeyMapWithCommon(description, common) {
182
183
  var mac = common.replace(/Mod/i, 'Cmd');
183
184
  return makeKeymap(description, windows, mac, common);
184
185
  }
186
+ function combineWithOldCommand(cmd, oldCmd) {
187
+ return function (state, dispatch, editorView) {
188
+ return oldCmd(state, dispatch) || cmd(state, dispatch, editorView);
189
+ };
190
+ }
185
191
  export function bindKeymapWithCommand(shortcut, cmd, keymap) {
186
192
  var oldCmd = keymap[shortcut];
187
- var newCmd = cmd;
188
- if (keymap[shortcut]) {
189
- newCmd = function newCmd(state, dispatch, editorView) {
190
- return oldCmd(state, dispatch) || cmd(state, dispatch, editorView);
191
- };
192
- }
193
- keymap[shortcut] = newCmd;
193
+ keymap[shortcut] = oldCmd ? combineWithOldCommand(cmd, oldCmd) : cmd;
194
+ }
195
+ export function bindKeymapWithPluginCommand(shortcut, cmd, keymap) {
196
+ bindKeymapWithCommand(shortcut, pluginCommandToPMCommand(cmd), keymap);
194
197
  }
195
198
  export function findKeyMapForBrowser(keyMap) {
196
199
  if (keyMap) {
@@ -87,7 +87,7 @@ var calcLegacyWideWidth = function calcLegacyWideWidth(containerWidth, origWidth
87
87
  };
88
88
 
89
89
  /**
90
- * Calculate maximum width allowed for media single in new experience
90
+ * Calculate maximum width allowed for media single node in fix-width editor in new experience
91
91
  * @param containerWidth width of editor container
92
92
  */
93
93
  export var calcMediaSingleMaxWidth = function calcMediaSingleMaxWidth(containerWidth) {
@@ -6,7 +6,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
6
6
  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) { _defineProperty(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; }
7
7
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
8
8
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
9
- var packageVersion = "74.37.0";
9
+ var packageVersion = "74.38.1";
10
10
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
11
11
  // Remove URL as it has UGC
12
12
  // TODO: Sanitise the URL instead of just removing it
@@ -1,2 +1,3 @@
1
1
  export { EditorPresetBuilder } from './builder';
2
- export { EditorPluginInjectionAPI } from './plugin-injection-api';
2
+ export { EditorPluginInjectionAPI } from './plugin-injection-api';
3
+ export { pluginCommandToPMCommand } from './plugin-commands';
@@ -0,0 +1,13 @@
1
+ export function pluginCommandToPMCommand(command) {
2
+ return function (_ref, dispatch) {
3
+ var tr = _ref.tr;
4
+ var newTr = command === null || command === void 0 ? void 0 : command({
5
+ tr: tr
6
+ });
7
+ if (newTr) {
8
+ dispatch === null || dispatch === void 0 ? void 0 : dispatch(newTr);
9
+ return true;
10
+ }
11
+ return false;
12
+ };
13
+ }
@@ -15,6 +15,9 @@ function hasGetSharedState(plugin) {
15
15
  function hasActions(plugin) {
16
16
  return _typeof(plugin.actions) === 'object';
17
17
  }
18
+ function hasCommands(plugin) {
19
+ return _typeof(plugin.commands) === 'object';
20
+ }
18
21
  var filterPluginsWithListeners = function filterPluginsWithListeners(_ref) {
19
22
  var listeners = _ref.listeners,
20
23
  plugins = _ref.plugins;
@@ -113,6 +116,26 @@ var ActionsAPI = /*#__PURE__*/function () {
113
116
  }]);
114
117
  return ActionsAPI;
115
118
  }();
119
+ var PluginCommandsAPI = /*#__PURE__*/function () {
120
+ function PluginCommandsAPI() {
121
+ _classCallCheck(this, PluginCommandsAPI);
122
+ }
123
+ _createClass(PluginCommandsAPI, [{
124
+ key: "createAPI",
125
+ value: function createAPI(plugin) {
126
+ if (!plugin || !hasCommands(plugin)) {
127
+ return {};
128
+ }
129
+ return new Proxy(plugin.commands || {}, {
130
+ get: function get(target, prop, receiver) {
131
+ // We will be able to track perfomance here
132
+ return Reflect.get(target, prop);
133
+ }
134
+ });
135
+ }
136
+ }]);
137
+ return PluginCommandsAPI;
138
+ }();
116
139
  export var SharedStateAPI = /*#__PURE__*/function () {
117
140
  function SharedStateAPI(_ref4) {
118
141
  var getEditorState = _ref4.getEditorState;
@@ -237,12 +260,14 @@ export var EditorPluginInjectionAPI = /*#__PURE__*/function () {
237
260
  });
238
261
  this.plugins = new Map();
239
262
  this.actionsAPI = new ActionsAPI();
263
+ this.commandsAPI = new PluginCommandsAPI();
240
264
  }
241
265
  _createClass(EditorPluginInjectionAPI, [{
242
266
  key: "api",
243
267
  value: function api() {
244
268
  var sharedStateAPI = this.sharedStateAPI,
245
269
  actionsAPI = this.actionsAPI,
270
+ commandsAPI = this.commandsAPI,
246
271
  getPluginByName = this.getPluginByName;
247
272
  var dependencies = new Proxy({}, {
248
273
  get: function get(target, prop, receiver) {
@@ -261,9 +286,11 @@ export var EditorPluginInjectionAPI = /*#__PURE__*/function () {
261
286
  }
262
287
  var sharedState = sharedStateAPI.createAPI(plugin);
263
288
  var actions = actionsAPI.createAPI(plugin);
289
+ var commands = commandsAPI.createAPI(plugin);
264
290
  var proxyCoreAPI = {
265
291
  sharedState: sharedState,
266
- actions: actions
292
+ actions: actions,
293
+ commands: commands
267
294
  };
268
295
  return proxyCoreAPI;
269
296
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -18,7 +18,7 @@ import { themed } from '@atlaskit/theme/components';
18
18
  import { borderRadius } from '@atlaskit/theme/constants';
19
19
  import Layer from '../Layer';
20
20
  var packageName = "@atlaskit/editor-common";
21
- var packageVersion = "74.37.0";
21
+ var packageVersion = "74.38.1";
22
22
  var halfFocusRing = 1;
23
23
  var dropOffset = '0, 8';
24
24
  var DropList = /*#__PURE__*/function (_Component) {
@@ -3,9 +3,10 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
3
3
  var _excluded = ["children"];
4
4
  var _templateObject, _templateObject2, _templateObject3, _templateObject4;
5
5
  /** @jsx jsx */
6
+
6
7
  import React from 'react';
7
8
  import { css, jsx } from '@emotion/react';
8
- import { akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth, akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
9
+ import { akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
9
10
  import { calcMediaSingleMaxWidth } from '../../media-single';
10
11
  import { nonWrappedLayouts } from '../../utils';
11
12
  import { calcBreakoutWidth, calcWideWidth } from '../../utils/breakout';
@@ -85,16 +86,6 @@ var getEffectiveFullWidth = function getEffectiveFullWidth(containerWidth, fullW
85
86
  }
86
87
  return "".concat(calcMediaSingleMaxWidth(containerWidth), "px");
87
88
  };
88
- var calcMaxWidthWhenResizing = function calcMaxWidthWhenResizing(containerWidth, fullWidthMode, isNestedNode) {
89
- if (isNestedNode) {
90
- return '100%';
91
- }
92
- // non-nested node can resize up to full width
93
- return getEffectiveFullWidth(containerWidth, fullWidthMode);
94
- };
95
- var calcMaxWidthWhenNotResizing = function calcMaxWidthWhenNotResizing(containerWidth, mediaSingleWidth) {
96
- return "".concat(Math.min(mediaSingleWidth, containerWidth - akEditorGutterPadding * 2), "px");
97
- };
98
89
  function calcMargin(layout) {
99
90
  switch (layout) {
100
91
  case 'wrap-right':
@@ -131,7 +122,7 @@ export var MediaSingleDimensionHelper = function MediaSingleDimensionHelper(_ref
131
122
  isExtendedResizeExperienceOn = _ref.isExtendedResizeExperienceOn,
132
123
  _ref$isNestedNode = _ref.isNestedNode,
133
124
  isNestedNode = _ref$isNestedNode === void 0 ? false : _ref$isNestedNode;
134
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /* For nested rich media items, set max-width to 100% */\n tr &,\n [data-layout-column] &,\n [data-node-type='expand'] & {\n max-width: 100%;\n }\n\n width: ", ";\n ", "\n max-width: ", ";\n &[class*='is-resizing'] {\n ", "\n }\n\n /* Handles responsiveness of non-nested, not-resizing nodes in editor */\n &[class*='not-resizing'] {\n ", "\n }\n\n float: ", ";\n margin: ", ";\n ", ";\n\n &:not(.is-resizing) {\n transition: width 100ms ease-in;\n }\n"])), mediaSingleWidth || pctWidth ? calcResizedWidth(layout, width || 0, containerWidth) : calcLegacyWidth(layout, width || 0, containerWidth, fullWidthMode, isResized), layout === 'full-width' && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n min-width: 100%;\n "]))), calcMaxWidth(layout, containerWidth), isExtendedResizeExperienceOn && "max-width: ".concat(calcMaxWidthWhenResizing(containerWidth, fullWidthMode, isNestedNode), ";\n\n ").concat(nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n\n .new-file-experience-wrapper {\n box-shadow: none;\n }"), !isNestedNode && "max-width: ".concat(layout !== 'full-width' && mediaSingleWidth && calcMaxWidthWhenNotResizing(containerWidth, mediaSingleWidth), ";\n\n ").concat(nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n\n // override min-width to counteract max-width set in old experience\n ").concat(layout === 'full-width' && "min-width: ".concat(getEffectiveFullWidth(containerWidth, fullWidthMode), " !important;"), ";"), float(layout), calcMargin(layout), isImageAligned(layout));
125
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /* For nested rich media items, set max-width to 100% */\n tr &,\n [data-layout-column] &,\n [data-node-type='expand'] & {\n max-width: 100%;\n }\n\n width: ", ";\n ", "\n max-width: ", ";\n\n ", "\n\n &[class*='not-resizing'] {\n ", "\n }\n\n float: ", ";\n margin: ", ";\n ", ";\n\n &:not(.is-resizing) {\n transition: width 100ms ease-in;\n }\n"])), mediaSingleWidth || pctWidth ? calcResizedWidth(layout, width || 0, containerWidth) : calcLegacyWidth(layout, width || 0, containerWidth, fullWidthMode, isResized), layout === 'full-width' && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n min-width: 100%;\n "]))), calcMaxWidth(layout, containerWidth), isExtendedResizeExperienceOn && "&[class*='is-resizing'] {\n .new-file-experience-wrapper {\n box-shadow: none !important;\n }\n\n ".concat(!isNestedNode && nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n }"), !isNestedNode && "".concat(nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n\n // override min-width to counteract max-width set by ResizerNext inline style\n ").concat(layout === 'full-width' && "min-width: ".concat(getEffectiveFullWidth(containerWidth, fullWidthMode), " !important;"), ";"), float(layout), calcMargin(layout), isImageAligned(layout));
135
126
  };
136
127
  var RenderFallbackContainer = function RenderFallbackContainer(_ref2) {
137
128
  var hasFallbackContainer = _ref2.hasFallbackContainer,
@@ -9,7 +9,7 @@ export var shouldAddDefaultWrappedWidth = function shouldAddDefaultWrappedWidth(
9
9
  };
10
10
  export var nonWrappedLayouts = ['center', 'wide', 'full-width'];
11
11
  export var floatingLayouts = ['wrap-left', 'wrap-right'];
12
- export var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(view, pos) {
12
+ export var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(view, pos, includeMoreParentNodeTypes) {
13
13
  if (typeof pos !== 'number' || isNaN(pos) || !view) {
14
14
  return false;
15
15
  }
@@ -17,8 +17,11 @@ export var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(
17
17
  var _view$state$schema$no = view.state.schema.nodes,
18
18
  expand = _view$state$schema$no.expand,
19
19
  nestedExpand = _view$state$schema$no.nestedExpand,
20
- layoutColumn = _view$state$schema$no.layoutColumn;
21
- return !!findParentNodeOfTypeClosestToPos($pos, [expand, nestedExpand, layoutColumn]);
20
+ layoutColumn = _view$state$schema$no.layoutColumn,
21
+ tableCell = _view$state$schema$no.tableCell,
22
+ listItem = _view$state$schema$no.listItem;
23
+ var parentNodeTypes = [expand, nestedExpand, layoutColumn];
24
+ return !!findParentNodeOfTypeClosestToPos($pos, includeMoreParentNodeTypes ? [].concat(parentNodeTypes, [tableCell, listItem]) : parentNodeTypes);
22
25
  };
23
26
  export var alignAttributes = function alignAttributes(layout, oldAttrs) {
24
27
  var gridSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 12;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.37.0",
3
+ "version": "74.38.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1 +1,2 @@
1
1
  export declare const MEDIA_DYNAMIC_GUIDELINE_PREFIX = "media_";
2
+ export declare const INNER_GRID_GUIDELINE_PREFIX = "grid_";
@@ -1,4 +1,4 @@
1
- import { EditorState } from '@atlaskit/editor-prosemirror/state';
1
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
2
  import type { GuidelineConfig } from './types';
3
3
  export declare const generateDynamicGuidelines: (state: EditorState, editorWidth: number, styles?: Omit<GuidelineConfig, 'key' | 'position'>) => ({
4
4
  styles?: {
@@ -2,7 +2,7 @@ export { generateDynamicGuidelines } from './dynamicGuideline';
2
2
  export { createFixedGuidelinesFromLengths, createGuidesFromLengths, } from './fixedGuideline';
3
3
  export { generateDefaultGuidelines } from './defaultGuideline';
4
4
  export { getGuidelinesWithHighlights } from './updateGuideline';
5
- export { MEDIA_DYNAMIC_GUIDELINE_PREFIX } from './constants';
6
- export type { WidthTypes, Position, GuidelineConfig, GuidelinePluginState, GuidelinePluginOptions, DisplayGuideline, DisplayGrid, VerticalPosition, HorizontalPosition, } from './types';
7
- export { getSnapWidth, findClosestSnap } from './snapping';
5
+ export { MEDIA_DYNAMIC_GUIDELINE_PREFIX, INNER_GRID_GUIDELINE_PREFIX, } from './constants';
6
+ export type { WidthTypes, Position, GuidelineConfig, GuidelinePluginState, GuidelinePluginOptions, DisplayGuideline, DisplayGrid, VerticalPosition, HorizontalPosition, GuidelineSnap, GuidelineSnapsReference, } from './types';
7
+ export { getGuidelineSnaps, findClosestSnap } from './snapping';
8
8
  export { isVerticalPosition, getContainerWidthOrFullEditorWidth, } from './utils';
@@ -1,18 +1,19 @@
1
- import { RichMediaLayout } from '@atlaskit/adf-schema';
2
- import type { GuidelineConfig } from './types';
3
- export type SnapTo = {
4
- guidelineKey: string;
5
- width: number;
6
- };
1
+ import type { RichMediaLayout } from '@atlaskit/adf-schema';
2
+ import type { GuidelineConfig, GuidelineSnap } from './types';
7
3
  /**
8
4
  * Returns keys of guidelines that are closest to the image and withthin the snapGap.
9
5
  * If both default and dynamic guidelines present, only returns default guidelines
10
6
  */
11
- export declare const findClosestSnap: (mediaSingleWidth: number, snapArray: number[], snapTo: SnapTo[], snapGap?: number) => {
7
+ export declare const findClosestSnap: (mediaSingleWidth: number, snapArray: number[], guidelineSnaps: GuidelineSnap[], snapGap?: number) => {
12
8
  gap: number;
13
9
  keys: string[];
14
10
  };
15
- /**
16
- * Get snapping widths and respective guideline keys
17
- */
18
- export declare const getSnapWidth: (guidelines: GuidelineConfig[], mediaSingleWidth: number, snap: number, layout: RichMediaLayout | null) => SnapTo[];
11
+ export declare const getGuidelineSnaps: import("memoize-one").MemoizedFn<(guidelines: GuidelineConfig[], editorWidth: number, layout?: RichMediaLayout) => {
12
+ guidelineReference: {
13
+ guidelineKey: string;
14
+ width: number;
15
+ }[];
16
+ snaps: {
17
+ x: number[] | undefined;
18
+ };
19
+ }>;