@atlaskit/editor-core 187.19.1 → 187.20.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 (113) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cjs/plugins/emoji/commands/insert-emoji.js +21 -20
  3. package/dist/cjs/plugins/emoji/index.js +16 -5
  4. package/dist/cjs/plugins/index.js +2 -2
  5. package/dist/cjs/plugins/insert-block/index.js +3 -7
  6. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
  7. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +28 -10
  8. package/dist/cjs/plugins/media/pm-plugins/main.js +13 -1
  9. package/dist/cjs/plugins/media/styles.js +1 -1
  10. package/dist/cjs/plugins/media/toolbar/index.js +21 -8
  11. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +40 -8
  12. package/dist/cjs/plugins/media/utils/media-single.js +21 -2
  13. package/dist/cjs/plugins/text-color/commands/toggle-color.js +3 -2
  14. package/dist/cjs/utils/document.js +6 -24
  15. package/dist/cjs/utils/index.js +33 -105
  16. package/dist/cjs/utils/prosemirror/position.js +33 -41
  17. package/dist/cjs/version-wrapper.js +1 -1
  18. package/dist/cjs/version.json +1 -1
  19. package/dist/es2019/plugins/emoji/commands/insert-emoji.js +24 -20
  20. package/dist/es2019/plugins/emoji/index.js +14 -4
  21. package/dist/es2019/plugins/index.js +1 -1
  22. package/dist/es2019/plugins/insert-block/index.js +3 -7
  23. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +6 -3
  24. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +21 -3
  25. package/dist/es2019/plugins/media/pm-plugins/main.js +9 -0
  26. package/dist/es2019/plugins/media/styles.js +8 -2
  27. package/dist/es2019/plugins/media/toolbar/index.js +22 -10
  28. package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +39 -7
  29. package/dist/es2019/plugins/media/utils/media-single.js +21 -2
  30. package/dist/es2019/plugins/text-color/commands/toggle-color.js +3 -2
  31. package/dist/es2019/utils/document.js +1 -20
  32. package/dist/es2019/utils/index.js +1 -99
  33. package/dist/es2019/utils/prosemirror/position.js +1 -51
  34. package/dist/es2019/version-wrapper.js +1 -1
  35. package/dist/es2019/version.json +1 -1
  36. package/dist/esm/plugins/emoji/commands/insert-emoji.js +21 -20
  37. package/dist/esm/plugins/emoji/index.js +14 -4
  38. package/dist/esm/plugins/index.js +1 -1
  39. package/dist/esm/plugins/insert-block/index.js +3 -7
  40. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
  41. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +21 -3
  42. package/dist/esm/plugins/media/pm-plugins/main.js +11 -0
  43. package/dist/esm/plugins/media/styles.js +1 -1
  44. package/dist/esm/plugins/media/toolbar/index.js +23 -10
  45. package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +41 -9
  46. package/dist/esm/plugins/media/utils/media-single.js +20 -2
  47. package/dist/esm/plugins/text-color/commands/toggle-color.js +3 -2
  48. package/dist/esm/utils/document.js +1 -22
  49. package/dist/esm/utils/index.js +1 -97
  50. package/dist/esm/utils/prosemirror/position.js +1 -39
  51. package/dist/esm/version-wrapper.js +1 -1
  52. package/dist/esm/version.json +1 -1
  53. package/dist/types/actions/index.d.ts +2 -3
  54. package/dist/types/labs/next/presets/default.d.ts +32 -32
  55. package/dist/types/plugins/collab-edit/actions.d.ts +1 -1
  56. package/dist/types/plugins/collab-edit/events/handlers.d.ts +2 -2
  57. package/dist/types/plugins/collab-edit/events/initialize.d.ts +1 -1
  58. package/dist/types/plugins/collab-edit/events/send-transaction.d.ts +1 -1
  59. package/dist/types/plugins/collab-edit/index.d.ts +1 -1
  60. package/dist/types/plugins/collab-edit/native-collab-provider-plugin.d.ts +2 -2
  61. package/dist/types/plugins/collab-edit/participants.d.ts +1 -1
  62. package/dist/types/plugins/collab-edit/plugin.d.ts +5 -6
  63. package/dist/types/plugins/collab-edit/types.d.ts +1 -2
  64. package/dist/types/plugins/collab-edit/ui/to-avatar.d.ts +2 -2
  65. package/dist/types/plugins/collab-edit/utils.d.ts +1 -2
  66. package/dist/types/plugins/emoji/commands/insert-emoji.d.ts +2 -2
  67. package/dist/types/plugins/emoji/index.d.ts +9 -4
  68. package/dist/types/plugins/index.d.ts +1 -1
  69. package/dist/types/plugins/insert-block/index.d.ts +3 -1
  70. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -1
  71. package/dist/types/plugins/media/nodeviews/mediaSingle.d.ts +6 -1
  72. package/dist/types/plugins/media/pm-plugins/main.d.ts +3 -0
  73. package/dist/types/plugins/media/pm-plugins/types.d.ts +2 -0
  74. package/dist/types/plugins/media/toolbar/index.d.ts +1 -2
  75. package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +2 -1
  76. package/dist/types/plugins/media/utils/media-single.d.ts +2 -1
  77. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  78. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  79. package/dist/types/utils/document.d.ts +2 -7
  80. package/dist/types/utils/index.d.ts +2 -6
  81. package/dist/types/utils/prosemirror/position.d.ts +1 -8
  82. package/dist/types-ts4.5/actions/index.d.ts +2 -3
  83. package/dist/types-ts4.5/labs/next/presets/default.d.ts +32 -32
  84. package/dist/types-ts4.5/plugins/collab-edit/actions.d.ts +1 -1
  85. package/dist/types-ts4.5/plugins/collab-edit/events/handlers.d.ts +2 -2
  86. package/dist/types-ts4.5/plugins/collab-edit/events/initialize.d.ts +1 -1
  87. package/dist/types-ts4.5/plugins/collab-edit/events/send-transaction.d.ts +1 -1
  88. package/dist/types-ts4.5/plugins/collab-edit/index.d.ts +1 -1
  89. package/dist/types-ts4.5/plugins/collab-edit/native-collab-provider-plugin.d.ts +2 -2
  90. package/dist/types-ts4.5/plugins/collab-edit/participants.d.ts +1 -1
  91. package/dist/types-ts4.5/plugins/collab-edit/plugin.d.ts +5 -6
  92. package/dist/types-ts4.5/plugins/collab-edit/types.d.ts +1 -2
  93. package/dist/types-ts4.5/plugins/collab-edit/ui/to-avatar.d.ts +2 -2
  94. package/dist/types-ts4.5/plugins/collab-edit/utils.d.ts +1 -2
  95. package/dist/types-ts4.5/plugins/emoji/commands/insert-emoji.d.ts +2 -2
  96. package/dist/types-ts4.5/plugins/emoji/index.d.ts +9 -4
  97. package/dist/types-ts4.5/plugins/index.d.ts +1 -1
  98. package/dist/types-ts4.5/plugins/insert-block/index.d.ts +3 -1
  99. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -1
  100. package/dist/types-ts4.5/plugins/media/nodeviews/mediaSingle.d.ts +6 -1
  101. package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +3 -0
  102. package/dist/types-ts4.5/plugins/media/pm-plugins/types.d.ts +2 -0
  103. package/dist/types-ts4.5/plugins/media/toolbar/index.d.ts +1 -2
  104. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +2 -1
  105. package/dist/types-ts4.5/plugins/media/utils/media-single.d.ts +2 -1
  106. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  107. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  108. package/dist/types-ts4.5/utils/document.d.ts +2 -7
  109. package/dist/types-ts4.5/utils/index.d.ts +2 -6
  110. package/dist/types-ts4.5/utils/prosemirror/position.d.ts +1 -8
  111. package/package.json +4 -4
  112. package/report.api.md +5 -1
  113. package/tmp/api-report-tmp.d.ts +5 -1
@@ -5,7 +5,6 @@ import { stateKey as mediaStateKey } from '../media/pm-plugins/plugin-key';
5
5
  import { isTypeAheadAllowed } from '../type-ahead/utils';
6
6
  import { pluginKey as layoutStateKey } from '../layout';
7
7
  import { insertMacroFromMacroBrowser } from '../macro';
8
- import { emojiPluginKey } from '../emoji';
9
8
  import WithPluginState from '../../ui/WithPluginState';
10
9
  import ToolbarInsertBlock from './ui/ToolbarInsertBlock';
11
10
  import { pluginKey as typeAheadPluginKey } from '../type-ahead/pm-plugins/key';
@@ -65,7 +64,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
65
64
  blockTypeState: blockTypeStateKey,
66
65
  mediaState: mediaStateKey,
67
66
  macroState: macroStateKey,
68
- emojiState: emojiPluginKey,
69
67
  placeholderTextState: placeholderTextStateKey,
70
68
  layoutState: layoutStateKey
71
69
  },
@@ -74,7 +72,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
74
72
  mediaState = _ref2.mediaState,
75
73
  _ref2$macroState = _ref2.macroState,
76
74
  macroState = _ref2$macroState === void 0 ? {} : _ref2$macroState,
77
- emojiState = _ref2.emojiState,
78
75
  placeholderTextState = _ref2.placeholderTextState,
79
76
  layoutState = _ref2.layoutState;
80
77
  return /*#__PURE__*/React.createElement(ToolbarInsertBlockWithInjectionApi, {
@@ -94,7 +91,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
94
91
  blockTypeState: blockTypeState,
95
92
  mediaState: mediaState,
96
93
  macroState: macroState,
97
- emojiState: emojiState,
98
94
  placeholderTextState: placeholderTextState,
99
95
  layoutState: layoutState,
100
96
  providers: providers,
@@ -130,16 +126,16 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
130
126
  blockTypeState = _ref3.blockTypeState,
131
127
  mediaState = _ref3.mediaState,
132
128
  macroState = _ref3.macroState,
133
- emojiState = _ref3.emojiState,
134
129
  placeholderTextState = _ref3.placeholderTextState,
135
130
  layoutState = _ref3.layoutState,
136
131
  featureFlags = _ref3.featureFlags;
137
132
  var buttons = toolbarSizeToButtons(toolbarSize);
138
- var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention']),
133
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji']),
139
134
  dateState = _useSharedPluginState.dateState,
140
135
  hyperlinkState = _useSharedPluginState.hyperlinkState,
141
136
  imageUploadState = _useSharedPluginState.imageUploadState,
142
- mentionState = _useSharedPluginState.mentionState;
137
+ mentionState = _useSharedPluginState.mentionState,
138
+ emojiState = _useSharedPluginState.emojiState;
143
139
  return /*#__PURE__*/React.createElement(ToolbarInsertBlock, {
144
140
  pluginInjectionApi: pluginInjectionApi,
145
141
  buttons: buttons,
@@ -27,8 +27,7 @@ import { insertTaskDecisionCommand } from '../../../tasks-and-decisions/commands
27
27
  import { insertExpand } from '../../../expand/commands';
28
28
  import { createTypeAheadTools } from '../../../type-ahead/api';
29
29
  import { updateStatusWithAnalytics } from '../../../status/actions';
30
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '../../../analytics';
31
- import { insertEmoji } from '../../../emoji/commands/insert-emoji';
30
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
32
31
  import { messages } from './messages';
33
32
  import { createItems } from './create-items';
34
33
  import { BlockInsertMenu } from './block-insert-menu';
@@ -277,8 +276,10 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
277
276
  };
278
277
  });
279
278
  _defineProperty(_assertThisInitialized(_this), "handleSelectedEmoji", function (emojiId) {
279
+ var _pluginInjectionApi$d8;
280
+ var pluginInjectionApi = _this.props.pluginInjectionApi;
280
281
  _this.props.editorView.focus();
281
- insertEmoji(_this.editorAnalyticsAPI)(emojiId, INPUT_METHOD.PICKER)(_this.props.editorView.state, _this.props.editorView.dispatch);
282
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.executeCommand((_pluginInjectionApi$d8 = pluginInjectionApi.dependencies.emoji) === null || _pluginInjectionApi$d8 === void 0 ? void 0 : _pluginInjectionApi$d8.commands.insertEmoji(emojiId, INPUT_METHOD.PICKER));
282
283
  _this.toggleEmojiPicker();
283
284
  return true;
284
285
  });
@@ -21,6 +21,7 @@ import { MediaSingle } from '@atlaskit/editor-common/ui';
21
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
+ import { getParentWidthForNestedMediaSingleNode } from '../utils/media-single';
24
25
  import ResizableMediaSingleNext from '../ui/ResizableMediaSingle/ResizableMediaSingleNext';
25
26
  import ResizableMediaSingle from '../ui/ResizableMediaSingle';
26
27
  import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
@@ -245,13 +246,12 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
245
246
  * Get parent width for a nested media single node
246
247
  * @param view Editor view
247
248
  * @param pos node position
248
- * @param includeMoreParentNodeTypes should consider table and list as parent nodes(only true for new experience)
249
249
  */
250
250
  _defineProperty(_assertThisInitialized(_this), "getLineLength", function (view, pos, includeMoreParentNodeTypes) {
251
251
  if (typeof pos !== 'number') {
252
252
  return null;
253
253
  }
254
- if (isRichMediaInsideOfBlockNode(view, pos, includeMoreParentNodeTypes)) {
254
+ if (isRichMediaInsideOfBlockNode(view, pos)) {
255
255
  var $pos = view.state.doc.resolve(pos);
256
256
  var domNode = view.nodeDOM($pos.pos);
257
257
  if ($pos.nodeAfter && floatingLayouts.indexOf($pos.nodeAfter.attrs.layout) > -1 && domNode && domNode.parentElement) {
@@ -263,6 +263,21 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
263
263
  }
264
264
  return null;
265
265
  });
266
+ /**
267
+ * Get parent width for a nested media single node for new experience
268
+ * @param view Editor view
269
+ * @param pos node position
270
+ */
271
+ _defineProperty(_assertThisInitialized(_this), "getLineLengthNext", function (view, pos) {
272
+ if (typeof pos !== 'number') {
273
+ return null;
274
+ }
275
+ var $pos = view.state.doc.resolve(pos);
276
+ if ($pos && $pos.parent.type.name !== 'doc') {
277
+ return getParentWidthForNestedMediaSingleNode($pos, view);
278
+ }
279
+ return null;
280
+ });
266
281
  return _this;
267
282
  }
268
283
  _createClass(MediaSingleNode, [{
@@ -364,7 +379,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
364
379
  }
365
380
  var isSelected = selected();
366
381
  var contentWidthForLegacyExperience = this.getLineLength(view, getPos()) || lineLength;
367
- var contentWidth = this.getLineLength(view, getPos(), true) || lineLength;
382
+ var contentWidth = this.getLineLengthNext(view, getPos()) || lineLength;
368
383
  var mediaSingleProps = {
369
384
  layout: layout,
370
385
  width: width,
@@ -501,6 +516,9 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
501
516
  // see also: https://github.com/ProseMirror/prosemirror/issues/884
502
517
  domRef.contentEditable = 'true';
503
518
  }
519
+ if (getBooleanFF('platform.editor.media.extended-resize-experience')) {
520
+ domRef.classList.add('media-extended-resize-experience');
521
+ }
504
522
  return domRef;
505
523
  }
506
524
  }, {
@@ -36,6 +36,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
36
36
  export { stateKey } from './plugin-key';
37
37
  export var MEDIA_CONTENT_WRAP_CLASS_NAME = 'media-content-wrap';
38
38
  export var MEDIA_PLUGIN_IS_RESIZING_KEY = 'mediaSinglePlugin.isResizing';
39
+ export var MEDIA_PLUGIN_RESIZING_WIDTH_KEY = 'mediaSinglePlugin.resizing-width';
39
40
  var createDropPlaceholder = function createDropPlaceholder(intl, allowDropLine) {
40
41
  var dropPlaceholder = document.createElement('div');
41
42
  var createElement = React.createElement;
@@ -66,6 +67,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
66
67
  _defineProperty(this, "layout", 'center');
67
68
  _defineProperty(this, "mediaNodes", []);
68
69
  _defineProperty(this, "isResizing", false);
70
+ _defineProperty(this, "resizingWidth", 0);
69
71
  _defineProperty(this, "destroyed", false);
70
72
  _defineProperty(this, "removeOnCloseListener", function () {});
71
73
  _defineProperty(this, "onPopupToggleCallback", function () {});
@@ -485,6 +487,11 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
485
487
  value: function setIsResizing(isResizing) {
486
488
  this.isResizing = isResizing;
487
489
  }
490
+ }, {
491
+ key: "setResizingWidth",
492
+ value: function setResizingWidth(width) {
493
+ this.resizingWidth = width;
494
+ }
488
495
  }, {
489
496
  key: "updateElement",
490
497
  value: function updateElement() {
@@ -626,9 +633,13 @@ export var createPlugin = function createPlugin(_schema, options, reactContext,
626
633
  },
627
634
  apply: function apply(tr, pluginState) {
628
635
  var isResizing = tr.getMeta(MEDIA_PLUGIN_IS_RESIZING_KEY);
636
+ var resizingWidth = tr.getMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY);
629
637
  if (isResizing !== undefined) {
630
638
  pluginState.setIsResizing(isResizing);
631
639
  }
640
+ if (resizingWidth) {
641
+ pluginState.setResizingWidth(resizingWidth);
642
+ }
632
643
 
633
644
  // remap editing media single position if we're in collab
634
645
  if (typeof pluginState.editingMediaSinglePos === 'number') {
@@ -5,7 +5,7 @@ import { mediaSingleSharedStyle, richMediaClassName } from '@atlaskit/editor-com
5
5
  import { akEditorDeleteBorder, akEditorDeleteBackground, akEditorSelectedBorderBoldSize, akEditorMediaResizeHandlerPaddingWide, akEditorMediaResizeHandlerPadding, akEditorSelectedNodeClassName, akEditorDeleteIconColor } from '@atlaskit/editor-shared-styles';
6
6
  import { N60, B200 } from '@atlaskit/theme/colors';
7
7
  import { fileCardImageViewSelector, inlinePlayerClassName, newFileExperienceClassName } from '@atlaskit/media-card';
8
- export var mediaStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror {\n ", " & [layout='full-width'] .", ",\n & [layout='wide'] .", " {\n margin-left: 50%;\n transform: translateX(-50%);\n }\n\n & [layout^='wrap-'] + [layout^='wrap-'] {\n clear: none;\n & + p,\n & + div[class^='fabric-editor-align'],\n & + ul,\n & + ol,\n & + h1,\n & + h2,\n & + h3,\n & + h4,\n & + h5,\n & + h6 {\n clear: both !important;\n }\n & .", " {\n margin-left: 0;\n margin-right: 0;\n }\n }\n\n .mediaSingleView-content-wrap[layout^='wrap-'] {\n max-width: 100%;\n // overwrite default Prosemirror setting making it clear: both\n clear: inherit;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-left'] {\n float: left;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-right'] {\n float: right;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-right']\n + .mediaSingleView-content-wrap[layout='wrap-left'] {\n clear: both;\n }\n\n /* Larger margins for resize handlers when at depth 0 of the document */\n & > .mediaSingleView-content-wrap {\n .richMedia-resize-handle-right {\n margin-right: -", "px;\n }\n .richMedia-resize-handle-left {\n margin-left: -", "px;\n }\n }\n }\n\n .richMedia-resize-handle-right,\n .richMedia-resize-handle-left {\n display: flex;\n flex-direction: column;\n\n /* vertical align */\n justify-content: center;\n }\n\n .richMedia-resize-handle-right {\n align-items: flex-end;\n padding-right: 12px;\n margin-right: -", "px;\n }\n\n .richMedia-resize-handle-left {\n align-items: flex-start;\n padding-left: 12px;\n margin-left: -", "px;\n }\n\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n content: ' ';\n display: flex;\n width: 3px;\n height: 64px;\n\n border-radius: 6px;\n }\n\n .", ":hover .richMedia-resize-handle-left::after,\n .", ":hover .richMedia-resize-handle-right::after {\n background: ", ";\n }\n\n .", " .richMedia-resize-handle-right::after,\n .", " .richMedia-resize-handle-left::after,\n .", " .richMedia-resize-handle-right:hover::after,\n .", " .richMedia-resize-handle-left:hover::after,\n .", ".is-resizing .richMedia-resize-handle-right::after,\n .", ".is-resizing .richMedia-resize-handle-left::after {\n background: ", ";\n }\n\n .__resizable_base__ {\n left: unset !important;\n width: auto !important;\n height: auto !important;\n }\n\n /* Danger when top level node for smart cards / inline links */\n .danger > div > div > .media-card-frame,\n .danger > span > a {\n background-color: ", ";\n box-shadow: 0px 0px 0px ", "px\n ", ";\n transition: background-color 0s, box-shadow 0s;\n }\n /* Danger when nested node or common */\n .danger {\n /* Media single */\n .", " .", "::after {\n border: 1px solid ", ";\n }\n /* Media single video player */\n .", " .", "::after {\n border: 1px solid ", ";\n }\n /* New file experience */\n .", " .", " {\n box-shadow: 0 0 0 1px\n ", " !important;\n }\n /* Media resize handlers */\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n background: ", ";\n }\n\n /* Smart cards */\n div div .media-card-frame,\n .inlineCardView-content-wrap > span > a {\n background-color: ", "; /* R75 with 50% opactiy */\n transition: background-color 0s;\n }\n\n div div .media-card-frame::after {\n box-shadow: none;\n }\n }\n"])), mediaSingleSharedStyle, richMediaClassName, richMediaClassName, richMediaClassName, akEditorMediaResizeHandlerPaddingWide, akEditorMediaResizeHandlerPaddingWide, akEditorMediaResizeHandlerPadding, akEditorMediaResizeHandlerPadding, richMediaClassName, richMediaClassName, "var(--ds-border, ".concat(N60, ")"), akEditorSelectedNodeClassName, akEditorSelectedNodeClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, "var(--ds-border-focused, ".concat(B200, ")"), "var(--ds-background-danger, ".concat(akEditorDeleteBackground, ")"), akEditorSelectedBorderBoldSize, "var(--ds-border-danger, ".concat(akEditorDeleteBorder, ")"), richMediaClassName, fileCardImageViewSelector, "var(--ds-border-danger, ".concat(akEditorDeleteIconColor, ")"), richMediaClassName, inlinePlayerClassName, "var(--ds-border-danger, ".concat(akEditorDeleteIconColor, ")"), richMediaClassName, newFileExperienceClassName, "var(--ds-border-danger, ".concat(akEditorDeleteIconColor, ")"), "var(--ds-icon-danger, ".concat(akEditorDeleteIconColor, ")"), "var(--ds-blanket-danger, rgb(255, 189, 173, 0.5))");
8
+ export var mediaStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror {\n ", " & [layout='full-width'] .", ",\n & [layout='wide'] .", " {\n margin-left: 50%;\n transform: translateX(-50%);\n }\n\n .media-extended-resize-experience[layout^='wrap-'] {\n // override 'overflow: auto' when viewport <= 410 set by mediaSingleSharedStyle\n // to prevent scroll bar\n overflow: visible !important;\n }\n\n & [layout^='wrap-'] + [layout^='wrap-'] {\n clear: none;\n & + p,\n & + div[class^='fabric-editor-align'],\n & + ul,\n & + ol,\n & + h1,\n & + h2,\n & + h3,\n & + h4,\n & + h5,\n & + h6 {\n clear: both !important;\n }\n & .", " {\n margin-left: 0;\n margin-right: 0;\n }\n }\n\n .mediaSingleView-content-wrap[layout^='wrap-'] {\n max-width: 100%;\n // overwrite default Prosemirror setting making it clear: both\n clear: inherit;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-left'] {\n float: left;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-right'] {\n float: right;\n }\n\n .mediaSingleView-content-wrap[layout='wrap-right']\n + .mediaSingleView-content-wrap[layout='wrap-left'] {\n clear: both;\n }\n\n /* Larger margins for resize handlers when at depth 0 of the document */\n & > .mediaSingleView-content-wrap {\n .richMedia-resize-handle-right {\n margin-right: -", "px;\n }\n .richMedia-resize-handle-left {\n margin-left: -", "px;\n }\n }\n }\n\n .richMedia-resize-handle-right,\n .richMedia-resize-handle-left {\n display: flex;\n flex-direction: column;\n\n /* vertical align */\n justify-content: center;\n }\n\n .richMedia-resize-handle-right {\n align-items: flex-end;\n padding-right: ", ";\n margin-right: -", "px;\n }\n\n .richMedia-resize-handle-left {\n align-items: flex-start;\n padding-left: ", ";\n margin-left: -", "px;\n }\n\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n content: ' ';\n display: flex;\n width: 3px;\n height: 64px;\n\n border-radius: 6px;\n }\n\n .", ":hover .richMedia-resize-handle-left::after,\n .", ":hover .richMedia-resize-handle-right::after {\n background: ", ";\n }\n\n .", " .richMedia-resize-handle-right::after,\n .", " .richMedia-resize-handle-left::after,\n .", " .richMedia-resize-handle-right:hover::after,\n .", " .richMedia-resize-handle-left:hover::after,\n .", ".is-resizing .richMedia-resize-handle-right::after,\n .", ".is-resizing .richMedia-resize-handle-left::after {\n background: ", ";\n }\n\n .__resizable_base__ {\n left: unset !important;\n width: auto !important;\n height: auto !important;\n }\n\n /* Danger when top level node for smart cards / inline links */\n .danger > div > div > .media-card-frame,\n .danger > span > a {\n background-color: ", ";\n box-shadow: 0px 0px 0px ", "px\n ", ";\n transition: background-color 0s, box-shadow 0s;\n }\n /* Danger when nested node or common */\n .danger {\n /* Media single */\n .", " .", "::after {\n border: 1px solid ", ";\n }\n /* Media single video player */\n .", " .", "::after {\n border: 1px solid ", ";\n }\n /* New file experience */\n .", " .", " {\n box-shadow: 0 0 0 1px\n ", " !important;\n }\n /* Media resize handlers */\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n background: ", ";\n }\n\n /* Smart cards */\n div div .media-card-frame,\n .inlineCardView-content-wrap > span > a {\n background-color: ", "; /* R75 with 50% opactiy */\n transition: background-color 0s;\n }\n\n div div .media-card-frame::after {\n box-shadow: none;\n }\n }\n"])), mediaSingleSharedStyle, richMediaClassName, richMediaClassName, richMediaClassName, akEditorMediaResizeHandlerPaddingWide, akEditorMediaResizeHandlerPaddingWide, "var(--ds-space-150, 12px)", akEditorMediaResizeHandlerPadding, "var(--ds-space-150, 12px)", akEditorMediaResizeHandlerPadding, richMediaClassName, richMediaClassName, "var(--ds-border, ".concat(N60, ")"), akEditorSelectedNodeClassName, akEditorSelectedNodeClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, "var(--ds-border-focused, ".concat(B200, ")"), "var(--ds-background-danger, ".concat(akEditorDeleteBackground, ")"), akEditorSelectedBorderBoldSize, "var(--ds-border-danger, ".concat(akEditorDeleteBorder, ")"), richMediaClassName, fileCardImageViewSelector, "var(--ds-border-danger, ".concat(akEditorDeleteIconColor, ")"), richMediaClassName, inlinePlayerClassName, "var(--ds-border-danger, ".concat(akEditorDeleteIconColor, ")"), richMediaClassName, newFileExperienceClassName, "var(--ds-border-danger, ".concat(akEditorDeleteIconColor, ")"), "var(--ds-icon-danger, ".concat(akEditorDeleteIconColor, ")"), "var(--ds-blanket-danger, rgb(255, 189, 173, 0.5))");
9
9
 
10
10
  /* `left: unset` above is to work around Chrome bug where rendering a div with
11
11
  * that style applied inside a container that has a scroll, causes any svgs on
@@ -29,8 +29,8 @@ import ImageBorderItem from '../ui/ImageBorder';
29
29
  import { currentMediaNodeBorderMark } from '../utils/current-media-node';
30
30
  import { shouldShowImageBorder } from './imageBorder';
31
31
  import { PixelEntry } from '../ui/PixelEntry';
32
- import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
33
- import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
32
+ import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_GUTTER_SIZE, calcMediaSinglePixelWidth } from '@atlaskit/editor-common/media-single';
33
+ import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
34
34
  var remove = function remove(state, dispatch) {
35
35
  if (dispatch) {
36
36
  dispatch(removeSelectedNode(state.tr));
@@ -258,12 +258,15 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
258
258
  type: 'custom',
259
259
  fallback: [],
260
260
  render: function render(editorView) {
261
+ var _widthPlugin$sharedSt2, _widthPlugin$sharedSt3;
261
262
  if (!editorView) {
262
263
  return null;
263
264
  }
264
265
  var state = editorView.state,
265
266
  dispatch = editorView.dispatch;
266
267
  var selectedMediaSingleNode = getSelectedMediaSingle(state);
268
+ var contentWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || akEditorDefaultLayoutWidth;
269
+ var containerWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.width) || akEditorFullWidthLayoutWidth;
267
270
  if (!selectedMediaSingleNode) {
268
271
  return null;
269
272
  }
@@ -271,13 +274,25 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
271
274
  if (!selectedMediaNode) {
272
275
  return null;
273
276
  }
274
- var singleMediaWidth = selectedMediaSingleNode.node.attrs.width;
277
+ var _selectedMediaSingleN = selectedMediaSingleNode.node.attrs,
278
+ singleMediaWidth = _selectedMediaSingleN.width,
279
+ widthType = _selectedMediaSingleN.widthType,
280
+ layout = _selectedMediaSingleN.layout;
275
281
  var _selectedMediaNode$at = selectedMediaNode.attrs,
276
282
  mediaWidth = _selectedMediaNode$at.width,
277
283
  mediaHeight = _selectedMediaNode$at.height;
284
+ var pixelWidth = calcMediaSinglePixelWidth({
285
+ width: singleMediaWidth,
286
+ widthType: widthType,
287
+ origWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
288
+ layout: layout,
289
+ contentWidth: contentWidth,
290
+ containerWidth: containerWidth,
291
+ gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
292
+ });
278
293
  return /*#__PURE__*/React.createElement(PixelEntry, {
279
294
  intl: intl,
280
- width: singleMediaWidth,
295
+ width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
281
296
  mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
282
297
  mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
283
298
  validate: function validate(value) {
@@ -297,11 +312,9 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
297
312
  });
298
313
  }
299
314
  });
300
- if (!pluginState.isResizing) {
301
- toolbarButtons.push({
302
- type: 'separator'
303
- });
304
- }
315
+ toolbarButtons.push({
316
+ type: 'separator'
317
+ });
305
318
  }
306
319
  if (allowLinking && shouldShowMediaLinkToolbar(state)) {
307
320
  toolbarButtons.push({
@@ -399,7 +412,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
399
412
  var mediaLinkingState = getMediaLinkingState(state);
400
413
  var _ref3 = (_pluginInjectionApi$d9 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d9 !== void 0 ? _pluginInjectionApi$d9 : {},
401
414
  hoverDecoration = _ref3.hoverDecoration;
402
- if (!mediaPluginState || mediaPluginState.isResizing) {
415
+ if (!mediaPluginState) {
403
416
  return;
404
417
  }
405
418
  var nodeType = allowMediaInline ? [mediaInline, mediaSingle, media] : [mediaSingle];
@@ -23,9 +23,11 @@ import { ResizerNext } from '@atlaskit/editor-common/resizer';
23
23
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
24
24
  import classnames from 'classnames';
25
25
  import { richMediaClassName, resizerStyles } from '@atlaskit/editor-common/styles';
26
- import { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, calculateOffsetLeft, DEFAULT_IMAGE_WIDTH, calcMediaSingleMaxWidth } from '@atlaskit/editor-common/media-single';
26
+ import { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, calculateOffsetLeft, DEFAULT_IMAGE_WIDTH, calcMediaSingleMaxWidth } from '@atlaskit/editor-common/media-single';
27
27
  import { findClosestSnap, getGuidelinesWithHighlights, generateDefaultGuidelines, generateDynamicGuidelines, getGuidelineSnaps } from '@atlaskit/editor-common/guideline';
28
28
  import memoizeOne from 'memoize-one';
29
+ import throttle from 'lodash/throttle';
30
+ import { MEDIA_PLUGIN_IS_RESIZING_KEY, MEDIA_PLUGIN_RESIZING_WIDTH_KEY } from '../../pm-plugins/main';
29
31
  export var resizerNextTestId = 'mediaSingle.resizerNext.testid';
30
32
 
31
33
  // TODO: Create new fixed image size event
@@ -70,12 +72,13 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
70
72
  layout = _this$props2.layout,
71
73
  state = _this$props2.view.state,
72
74
  containerWidth = _this$props2.containerWidth,
73
- lineLength = _this$props2.lineLength;
75
+ lineLength = _this$props2.lineLength,
76
+ fullWidthMode = _this$props2.fullWidthMode;
74
77
  var newPct = calcPctFromPx(newWidth, _this.props.lineLength) * 100;
75
78
  _this.setState({
76
79
  resizedPctWidth: newPct
77
80
  });
78
- var newLayout = hasParentNodeOfType(state.schema.nodes.table)(state.selection) ? layout : _this.calcUnwrappedLayout(newWidth, containerWidth, lineLength);
81
+ var newLayout = hasParentNodeOfType(state.schema.nodes.table)(state.selection) ? layout : _this.calcUnwrappedLayout(newWidth, containerWidth, lineLength, fullWidthMode);
79
82
  if (newPct <= 100) {
80
83
  if (_this.wrappedLayout && (stop ? newPct !== 100 : true)) {
81
84
  newLayout = layout;
@@ -91,7 +94,13 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
91
94
  };
92
95
  }
93
96
  });
94
- _defineProperty(_assertThisInitialized(_this), "calcUnwrappedLayout", function (width, containerWidth, contentWidth) {
97
+ _defineProperty(_assertThisInitialized(_this), "calcUnwrappedLayout", function (width, containerWidth, contentWidth, fullWidthMode) {
98
+ if (fullWidthMode) {
99
+ if (width < contentWidth) {
100
+ return 'center';
101
+ }
102
+ return 'full-width';
103
+ }
95
104
  if (width <= contentWidth) {
96
105
  return 'center';
97
106
  }
@@ -130,7 +139,15 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
130
139
  state = _this$props$view.state,
131
140
  dispatch = _this$props$view.dispatch;
132
141
  var tr = state.tr;
133
- tr.setMeta('mediaSinglePlugin.isResizing', isResizing);
142
+ tr.setMeta(MEDIA_PLUGIN_IS_RESIZING_KEY, isResizing);
143
+ return dispatch(tr);
144
+ });
145
+ _defineProperty(_assertThisInitialized(_this), "updateSizeInPluginState", function (width) {
146
+ var _this$props$view2 = _this.props.view,
147
+ state = _this$props$view2.state,
148
+ dispatch = _this$props$view2.dispatch;
149
+ var tr = state.tr;
150
+ tr.setMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY, width);
134
151
  return dispatch(tr);
135
152
  });
136
153
  _defineProperty(_assertThisInitialized(_this), "calcMaxWidth", memoizeOne(function (contentWidth, containerWidth, fullWidthMode) {
@@ -184,11 +201,12 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
184
201
  });
185
202
  _this.selectCurrentMediaNode();
186
203
  _this.setIsResizing(true);
204
+ _this.updateSizeInPluginState(_this.state.size.width);
187
205
  // re-calucate guidelines
188
206
  _this.guidelines = _this.getAllGuidelines();
189
207
  return 0;
190
208
  });
191
- _defineProperty(_assertThisInitialized(_this), "handleResize", function (size, delta) {
209
+ _defineProperty(_assertThisInitialized(_this), "handleResize", throttle(function (size, delta) {
192
210
  var _this$props4 = _this.props,
193
211
  originalWidth = _this$props4.width,
194
212
  originalHeight = _this$props4.height,
@@ -208,10 +226,11 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
208
226
  },
209
227
  snaps: guidelineSnaps.snaps
210
228
  });
229
+ _this.updateSizeInPluginState(width);
211
230
  if (calculatedWidthWithLayout.layout !== layout) {
212
231
  updateSize(width, calculatedWidthWithLayout.layout);
213
232
  }
214
- });
233
+ }, MEDIA_SINGLE_RESIZE_THROTTLE_TIME));
215
234
  _defineProperty(_assertThisInitialized(_this), "handleResizeStop", function (size, delta) {
216
235
  var _this$props5 = _this.props,
217
236
  originalWidth = _this$props5.width,
@@ -271,6 +290,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
271
290
  }, {
272
291
  key: "componentDidUpdate",
273
292
  value: function componentDidUpdate(prevProps) {
293
+ var _this2 = this;
274
294
  var offsetLeft = calculateOffsetLeft(this.insideInlineLike, this.insideLayout, this.props.view.dom, this.wrapper);
275
295
  if (offsetLeft !== this.state.offsetLeft && offsetLeft >= 0) {
276
296
  this.setState({
@@ -296,6 +316,18 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
296
316
  }
297
317
  });
298
318
  }
319
+ if (this.props.layout === 'full-width' && !this.isNestedNode() && prevProps.containerWidth !== this.props.containerWidth) {
320
+ // To achieve edge-to-edge for full-width, we need to update its width according to containerWidth
321
+ // Update state to allow resizer to get most up-to-date width to avoid jumping when start resizing
322
+ this.setState(function (prevState) {
323
+ return {
324
+ size: {
325
+ width: calcMediaSingleMaxWidth(_this2.props.containerWidth),
326
+ height: prevState.size.height
327
+ }
328
+ };
329
+ });
330
+ }
299
331
  return true;
300
332
  }
301
333
 
@@ -455,7 +487,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
455
487
  }, {
456
488
  key: "render",
457
489
  value: function render() {
458
- var _this2 = this;
490
+ var _this3 = this;
459
491
  var _this$props8 = this.props,
460
492
  origWidth = _this$props8.width,
461
493
  layout = _this$props8.layout,
@@ -472,7 +504,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
472
504
  handleSides.forEach(function (side) {
473
505
  var oppositeSide = side === 'left' ? 'right' : 'left';
474
506
  enable[side] = nonWrappedLayouts.concat("wrap-".concat(oppositeSide)).concat("align-".concat(imageAlignmentMap[oppositeSide])).indexOf(layout) > -1;
475
- if (side === 'left' && _this2.insideInlineLike) {
507
+ if (side === 'left' && _this3.insideInlineLike) {
476
508
  enable[side] = false;
477
509
  }
478
510
  });
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
5
5
  import { safeInsert as pmSafeInsert, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
6
  import { checkNodeDown } from '../../../utils';
7
- import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
7
+ import { isEmptyParagraph, floatingLayouts } from '@atlaskit/editor-common/utils';
8
8
  import { getMediaSingleInitialWidth } from '@atlaskit/editor-common/media-single';
9
9
  import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
10
10
  import { mapSlice } from '../../../utils/slice';
@@ -209,4 +209,22 @@ export function isCaptionNode(editorView) {
209
209
  return true;
210
210
  }
211
211
  return false;
212
- }
212
+ }
213
+ export var getParentWidthForNestedMediaSingleNode = function getParentWidthForNestedMediaSingleNode(resolvedPos, view) {
214
+ var domNode = view.nodeDOM(resolvedPos.pos);
215
+ if (resolvedPos.nodeAfter && floatingLayouts.includes(resolvedPos.nodeAfter.attrs.layout) && domNode && domNode.parentElement) {
216
+ var _view$state$schema$no = view.state.schema.nodes,
217
+ tableCell = _view$state$schema$no.tableCell,
218
+ tableHeader = _view$state$schema$no.tableHeader;
219
+ if ([tableCell, tableHeader].includes(resolvedPos.parent.type)) {
220
+ // since table has constant padding, use hardcoded constant instead of query the dom
221
+ var tablePadding = 8;
222
+ return domNode.parentElement.offsetWidth - tablePadding * 2;
223
+ }
224
+ return domNode.parentElement.offsetWidth;
225
+ }
226
+ if (domNode instanceof HTMLElement) {
227
+ return domNode.offsetWidth;
228
+ }
229
+ return null;
230
+ };
@@ -1,6 +1,7 @@
1
1
  import { toggleMark } from '@atlaskit/editor-common/mark';
2
2
  import { ACTIONS, pluginKey } from '../pm-plugins/main';
3
3
  import { getDisabledState } from '../utils/disabled';
4
+ import { pluginCommandToPMCommand } from '@atlaskit/editor-common/preset';
4
5
  export var toggleColor = function toggleColor(color) {
5
6
  return function (state, dispatch) {
6
7
  var textColor = state.schema.marks.textColor;
@@ -20,9 +21,9 @@ export var toggleColor = function toggleColor(color) {
20
21
  color: color
21
22
  });
22
23
  state.tr.scrollIntoView();
23
- toggleMark(textColor, {
24
+ pluginCommandToPMCommand(toggleMark(textColor, {
24
25
  color: color
25
- })(state, dispatch);
26
+ }))(state, dispatch);
26
27
  }
27
28
  return true;
28
29
  };
@@ -2,6 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
3
  import { getBreakoutMode } from './node-width';
4
4
  import { processRawValue, hasDocAsParent, getStepRange, isEmptyParagraph } from '@atlaskit/editor-common/utils';
5
+ export { findFarthestParentNode } from '@atlaskit/editor-common/utils';
5
6
 
6
7
  /**
7
8
  * Checks if a node has any content. Ignores node that only contain empty block nodes.
@@ -50,28 +51,6 @@ export function processRawFragmentValue(schema, value, providerFactory, sanitize
50
51
  }
51
52
  return Fragment.from(adfEntities);
52
53
  }
53
-
54
- /**
55
- * Find the farthest node given a condition
56
- * @param predicate Function to check the node
57
- */
58
- export var findFarthestParentNode = function findFarthestParentNode(predicate) {
59
- return function ($pos) {
60
- var candidate = null;
61
- for (var i = $pos.depth; i > 0; i--) {
62
- var _node = $pos.node(i);
63
- if (predicate(_node)) {
64
- candidate = {
65
- pos: i > 0 ? $pos.before(i) : 0,
66
- start: $pos.start(i),
67
- depth: i,
68
- node: _node
69
- };
70
- }
71
- }
72
- return candidate;
73
- };
74
- };
75
54
  export var isSelectionEndOfParagraph = function isSelectionEndOfParagraph(state) {
76
55
  return state.selection.$to.parent.type === state.schema.nodes.paragraph && state.selection.$to.pos === state.doc.resolve(state.selection.$to.pos).end();
77
56
  };
@@ -2,7 +2,7 @@ import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
2
2
  import { JSONTransformer } from '@atlaskit/editor-json-transformer';
3
3
  import { FakeTextCursorSelection } from '../plugins/fake-text-cursor/cursor';
4
4
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
- import { isNodeEmpty } from './document';
5
+ export { isEmptyNode, isSelectionInsideLastNodeInDocument, checkNodeDown, insideTableCell, isInListItem } from '@atlaskit/editor-common/utils';
6
6
  export { insideTable } from '@atlaskit/editor-common/core-utils';
7
7
  export { isNodeEmpty, findFarthestParentNode, isSelectionEndOfParagraph, nodesBetweenChanged, getNodesCount } from './document';
8
8
  export { sanitiseMarksInSelection } from './mark';
@@ -15,11 +15,6 @@ function isMarkTypeCompatibleWithMark(markType, mark) {
15
15
  function isMarkTypeAllowedInNode(markType, state) {
16
16
  return toggleMark(markType)(state);
17
17
  }
18
- export function isSelectionInsideLastNodeInDocument(selection) {
19
- var docNode = selection.$anchor.node(0);
20
- var rootNode = selection.$anchor.node(1);
21
- return docNode.lastChild === rootNode;
22
- }
23
18
  export function getCursor(selection) {
24
19
  return selection.$cursor || undefined;
25
20
  }
@@ -67,36 +62,6 @@ export function isMarkTypeAllowedInCurrentSelection(markType, state) {
67
62
  return allowedInActiveMarks;
68
63
  });
69
64
  }
70
- export function checkNodeDown(selection, doc, filter) {
71
- var ancestorDepth = findAncestorPosition(doc, selection.$to).depth;
72
-
73
- // Top level node
74
- if (ancestorDepth === 0) {
75
- return false;
76
- }
77
- var res = doc.resolve(selection.$to.after(ancestorDepth));
78
- return res.nodeAfter ? filter(res.nodeAfter) : false;
79
- }
80
-
81
- /**
82
- * Traverse the document until an "ancestor" is found. Any nestable block can be an ancestor.
83
- */
84
- function findAncestorPosition(doc, pos) {
85
- var nestableBlocks = ['blockquote', 'bulletList', 'orderedList'];
86
- if (pos.depth === 1) {
87
- return pos;
88
- }
89
- var node = pos.node(pos.depth);
90
- var newPos = pos;
91
- while (pos.depth >= 1) {
92
- pos = doc.resolve(pos.before(pos.depth));
93
- node = pos.node(pos.depth);
94
- if (node && nestableBlocks.indexOf(node.type.name) !== -1) {
95
- newPos = pos;
96
- }
97
- }
98
- return newPos;
99
- }
100
65
  var transformer = new JSONTransformer();
101
66
  export function toJSON(node) {
102
67
  return transformer.encode(node);
@@ -142,67 +107,6 @@ export function whichTransitionEvent() {
142
107
  export var isTemporary = function isTemporary(id) {
143
108
  return id.indexOf('temporary:') === 0;
144
109
  };
145
- export var isEmptyNode = function isEmptyNode(schema) {
146
- var _schema$nodes = schema.nodes,
147
- doc = _schema$nodes.doc,
148
- paragraph = _schema$nodes.paragraph,
149
- codeBlock = _schema$nodes.codeBlock,
150
- blockquote = _schema$nodes.blockquote,
151
- panel = _schema$nodes.panel,
152
- heading = _schema$nodes.heading,
153
- listItem = _schema$nodes.listItem,
154
- bulletList = _schema$nodes.bulletList,
155
- orderedList = _schema$nodes.orderedList,
156
- taskList = _schema$nodes.taskList,
157
- taskItem = _schema$nodes.taskItem,
158
- decisionList = _schema$nodes.decisionList,
159
- decisionItem = _schema$nodes.decisionItem,
160
- media = _schema$nodes.media,
161
- mediaGroup = _schema$nodes.mediaGroup,
162
- mediaSingle = _schema$nodes.mediaSingle;
163
- var innerIsEmptyNode = function innerIsEmptyNode(node) {
164
- switch (node.type) {
165
- case media:
166
- case mediaGroup:
167
- case mediaSingle:
168
- return false;
169
- case paragraph:
170
- case codeBlock:
171
- case heading:
172
- case taskItem:
173
- case decisionItem:
174
- return node.content.size === 0;
175
- case blockquote:
176
- case panel:
177
- case listItem:
178
- return node.content.size === 2 && innerIsEmptyNode(node.content.firstChild);
179
- case bulletList:
180
- case orderedList:
181
- return node.content.size === 4 && innerIsEmptyNode(node.content.firstChild);
182
- case taskList:
183
- case decisionList:
184
- return node.content.size === 2 && innerIsEmptyNode(node.content.firstChild);
185
- case doc:
186
- var isEmpty = true;
187
- node.content.forEach(function (child) {
188
- isEmpty = isEmpty && innerIsEmptyNode(child);
189
- });
190
- return isEmpty;
191
- default:
192
- return isNodeEmpty(node);
193
- }
194
- };
195
- return innerIsEmptyNode;
196
- };
197
- export var insideTableCell = function insideTableCell(state) {
198
- var _state$schema$nodes = state.schema.nodes,
199
- tableCell = _state$schema$nodes.tableCell,
200
- tableHeader = _state$schema$nodes.tableHeader;
201
- return hasParentNodeOfType([tableCell, tableHeader])(state.selection);
202
- };
203
- export var isInListItem = function isInListItem(state) {
204
- return hasParentNodeOfType(state.schema.nodes.listItem)(state.selection);
205
- };
206
110
  export var hasOpenEnd = function hasOpenEnd(slice) {
207
111
  return slice.openStart > 0 || slice.openEnd > 0;
208
112
  };