@atlaskit/editor-core 183.1.6 → 184.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/labs/next/full-page.js +2 -6
  3. package/dist/cjs/labs/next/presets/create-stub-internal-apis.js +4 -2
  4. package/dist/cjs/labs/next/presets/default.js +2 -2
  5. package/dist/cjs/labs/next/presets/universal.js +2 -1
  6. package/dist/cjs/plugins/breakout/index.js +54 -35
  7. package/dist/cjs/plugins/card/toolbar.js +4 -3
  8. package/dist/cjs/plugins/collab-edit/plugin-state.js +2 -3
  9. package/dist/cjs/plugins/copy-button/commands.js +8 -1
  10. package/dist/cjs/plugins/extension/index.js +1 -1
  11. package/dist/cjs/plugins/extension/nodeviews/extension.js +5 -3
  12. package/dist/cjs/plugins/extension/pm-plugins/main.js +6 -6
  13. package/dist/cjs/plugins/extension/ui/Extension/Extension/index.js +34 -4
  14. package/dist/cjs/plugins/extension/ui/Extension/ExtensionComponent.js +4 -2
  15. package/dist/cjs/plugins/extension/ui/Extension/index.js +4 -2
  16. package/dist/cjs/plugins/help-dialog/index.js +12 -8
  17. package/dist/cjs/plugins/index.js +0 -14
  18. package/dist/cjs/plugins/layout/pm-plugins/main.js +0 -1
  19. package/dist/cjs/plugins/media/index.js +15 -5
  20. package/dist/cjs/plugins/media/nodeviews/mediaNodeView/index.js +22 -14
  21. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +53 -34
  22. package/dist/cjs/plugins/media/styles.js +1 -1
  23. package/dist/cjs/plugins/media/toolbar/index.js +4 -3
  24. package/dist/cjs/plugins/paste/pm-plugins/main.js +7 -1
  25. package/dist/cjs/test-utils.js +6 -1
  26. package/dist/cjs/ui/Appearance/Comment/Comment.js +2 -2
  27. package/dist/cjs/ui/Appearance/FullPage/FullPage.js +2 -2
  28. package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea.js +1 -2
  29. package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +2 -2
  30. package/dist/cjs/ui/ContentStyles/index.js +9 -10
  31. package/dist/cjs/ui/ContextPanel/index.js +67 -56
  32. package/dist/cjs/ui/MediaAndEmbedsToolbar/index.js +10 -11
  33. package/dist/cjs/ui/Resizer/index.js +8 -8
  34. package/dist/cjs/ui/WidthEmitter/index.js +10 -4
  35. package/dist/cjs/utils/clipboard.js +18 -11
  36. package/dist/cjs/utils/performance/instrumented-plugin.js +14 -2
  37. package/dist/cjs/version-wrapper.js +1 -1
  38. package/dist/cjs/version.json +1 -1
  39. package/dist/es2019/labs/next/full-page.js +2 -5
  40. package/dist/es2019/labs/next/presets/create-stub-internal-apis.js +4 -2
  41. package/dist/es2019/labs/next/presets/default.js +1 -1
  42. package/dist/es2019/labs/next/presets/universal.js +2 -1
  43. package/dist/es2019/plugins/breakout/index.js +48 -31
  44. package/dist/es2019/plugins/card/toolbar.js +4 -3
  45. package/dist/es2019/plugins/collab-edit/plugin-state.js +2 -4
  46. package/dist/es2019/plugins/copy-button/commands.js +9 -2
  47. package/dist/es2019/plugins/extension/index.js +1 -1
  48. package/dist/es2019/plugins/extension/nodeviews/extension.js +5 -3
  49. package/dist/es2019/plugins/extension/pm-plugins/main.js +4 -4
  50. package/dist/es2019/plugins/extension/ui/Extension/Extension/index.js +38 -2
  51. package/dist/es2019/plugins/extension/ui/Extension/ExtensionComponent.js +4 -2
  52. package/dist/es2019/plugins/extension/ui/Extension/index.js +4 -2
  53. package/dist/es2019/plugins/help-dialog/index.js +14 -9
  54. package/dist/es2019/plugins/index.js +0 -2
  55. package/dist/es2019/plugins/layout/pm-plugins/main.js +0 -1
  56. package/dist/es2019/plugins/media/index.js +15 -5
  57. package/dist/es2019/plugins/media/nodeviews/mediaNodeView/index.js +21 -10
  58. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +53 -33
  59. package/dist/es2019/plugins/media/styles.js +1 -7
  60. package/dist/es2019/plugins/media/toolbar/index.js +4 -4
  61. package/dist/es2019/plugins/paste/pm-plugins/main.js +7 -1
  62. package/dist/es2019/test-utils.js +6 -1
  63. package/dist/es2019/ui/Appearance/Comment/Comment.js +1 -1
  64. package/dist/es2019/ui/Appearance/FullPage/FullPage.js +1 -1
  65. package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea.js +1 -1
  66. package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +1 -1
  67. package/dist/es2019/ui/ContentStyles/index.js +1 -2
  68. package/dist/es2019/ui/ContextPanel/index.js +66 -43
  69. package/dist/es2019/ui/MediaAndEmbedsToolbar/index.js +8 -9
  70. package/dist/es2019/ui/Resizer/index.js +1 -1
  71. package/dist/es2019/ui/WidthEmitter/index.js +10 -4
  72. package/dist/es2019/utils/clipboard.js +12 -7
  73. package/dist/es2019/utils/performance/instrumented-plugin.js +15 -2
  74. package/dist/es2019/version-wrapper.js +1 -1
  75. package/dist/es2019/version.json +1 -1
  76. package/dist/esm/labs/next/full-page.js +2 -5
  77. package/dist/esm/labs/next/presets/create-stub-internal-apis.js +4 -2
  78. package/dist/esm/labs/next/presets/default.js +1 -1
  79. package/dist/esm/labs/next/presets/universal.js +2 -1
  80. package/dist/esm/plugins/breakout/index.js +54 -35
  81. package/dist/esm/plugins/card/toolbar.js +4 -3
  82. package/dist/esm/plugins/collab-edit/plugin-state.js +2 -3
  83. package/dist/esm/plugins/copy-button/commands.js +9 -2
  84. package/dist/esm/plugins/extension/index.js +1 -1
  85. package/dist/esm/plugins/extension/nodeviews/extension.js +5 -3
  86. package/dist/esm/plugins/extension/pm-plugins/main.js +6 -6
  87. package/dist/esm/plugins/extension/ui/Extension/Extension/index.js +33 -2
  88. package/dist/esm/plugins/extension/ui/Extension/ExtensionComponent.js +4 -2
  89. package/dist/esm/plugins/extension/ui/Extension/index.js +4 -2
  90. package/dist/esm/plugins/help-dialog/index.js +12 -8
  91. package/dist/esm/plugins/index.js +0 -2
  92. package/dist/esm/plugins/layout/pm-plugins/main.js +0 -1
  93. package/dist/esm/plugins/media/index.js +15 -5
  94. package/dist/esm/plugins/media/nodeviews/mediaNodeView/index.js +22 -14
  95. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +54 -35
  96. package/dist/esm/plugins/media/styles.js +2 -2
  97. package/dist/esm/plugins/media/toolbar/index.js +4 -3
  98. package/dist/esm/plugins/paste/pm-plugins/main.js +7 -1
  99. package/dist/esm/test-utils.js +6 -1
  100. package/dist/esm/ui/Appearance/Comment/Comment.js +1 -1
  101. package/dist/esm/ui/Appearance/FullPage/FullPage.js +1 -1
  102. package/dist/esm/ui/Appearance/FullPage/FullPageContentArea.js +1 -1
  103. package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +1 -1
  104. package/dist/esm/ui/ContentStyles/index.js +1 -2
  105. package/dist/esm/ui/ContextPanel/index.js +64 -53
  106. package/dist/esm/ui/MediaAndEmbedsToolbar/index.js +10 -11
  107. package/dist/esm/ui/Resizer/index.js +1 -1
  108. package/dist/esm/ui/WidthEmitter/index.js +10 -4
  109. package/dist/esm/utils/clipboard.js +16 -10
  110. package/dist/esm/utils/performance/instrumented-plugin.js +14 -2
  111. package/dist/esm/version-wrapper.js +1 -1
  112. package/dist/esm/version.json +1 -1
  113. package/dist/types/actions/index.d.ts +1 -1
  114. package/dist/types/create-editor/get-plugins.d.ts +2 -0
  115. package/dist/types/index.d.ts +0 -1
  116. package/dist/types/plugins/breakout/index.d.ts +4 -0
  117. package/dist/types/plugins/breakout/ui/LayoutButton.d.ts +1 -1
  118. package/dist/types/plugins/card/index.d.ts +2 -2
  119. package/dist/types/plugins/collab-edit/actions.d.ts +3 -2
  120. package/dist/types/plugins/collab-edit/events/handlers.d.ts +3 -3
  121. package/dist/types/plugins/collab-edit/events/initialize.d.ts +1 -1
  122. package/dist/types/plugins/collab-edit/events/send-transaction.d.ts +1 -1
  123. package/dist/types/plugins/collab-edit/index.d.ts +0 -1
  124. package/dist/types/plugins/collab-edit/native-collab-provider-plugin.d.ts +2 -2
  125. package/dist/types/plugins/collab-edit/participants.d.ts +1 -1
  126. package/dist/types/plugins/collab-edit/plugin.d.ts +0 -2
  127. package/dist/types/plugins/collab-edit/types.d.ts +1 -3
  128. package/dist/types/plugins/collab-edit/ui/to-avatar.d.ts +1 -1
  129. package/dist/types/plugins/collab-edit/utils.d.ts +2 -1
  130. package/dist/types/plugins/extension/index.d.ts +2 -1
  131. package/dist/types/plugins/extension/nodeviews/extension.d.ts +4 -1
  132. package/dist/types/plugins/extension/pm-plugins/main.d.ts +3 -1
  133. package/dist/types/plugins/extension/ui/Extension/Extension/index.d.ts +6 -0
  134. package/dist/types/plugins/extension/ui/Extension/ExtensionComponent.d.ts +3 -0
  135. package/dist/types/plugins/extension/ui/Extension/index.d.ts +3 -0
  136. package/dist/types/plugins/help-dialog/index.d.ts +3 -1
  137. package/dist/types/plugins/index.d.ts +0 -3
  138. package/dist/types/plugins/media/index.d.ts +12 -2
  139. package/dist/types/plugins/media/nodeviews/mediaNodeView/index.d.ts +4 -2
  140. package/dist/types/plugins/media/nodeviews/mediaSingle.d.ts +1 -1
  141. package/dist/types/plugins/media/nodeviews/types.d.ts +2 -1
  142. package/dist/types/plugins/media/toolbar/index.d.ts +3 -1
  143. package/dist/types/plugins/media/ui/ResizableMediaSingle/types.d.ts +2 -2
  144. package/dist/types/test-utils.d.ts +3 -1
  145. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  146. package/dist/types/ui/ColorPickerButton/index.d.ts +1 -1
  147. package/dist/types/ui/ContextPanel/index.d.ts +3 -4
  148. package/dist/types/ui/MediaAndEmbedsToolbar/index.d.ts +3 -1
  149. package/dist/types/ui/PluginSlot/index.d.ts +1 -1
  150. package/dist/types/ui/Resizer/types.d.ts +2 -2
  151. package/dist/types/utils/clipboard.d.ts +1 -0
  152. package/dist/types-ts4.5/actions/index.d.ts +1 -1
  153. package/dist/types-ts4.5/create-editor/get-plugins.d.ts +2 -0
  154. package/dist/types-ts4.5/index.d.ts +0 -1
  155. package/dist/types-ts4.5/plugins/breakout/index.d.ts +6 -0
  156. package/dist/types-ts4.5/plugins/breakout/ui/LayoutButton.d.ts +1 -1
  157. package/dist/types-ts4.5/plugins/card/index.d.ts +2 -2
  158. package/dist/types-ts4.5/plugins/collab-edit/actions.d.ts +3 -2
  159. package/dist/types-ts4.5/plugins/collab-edit/events/handlers.d.ts +3 -3
  160. package/dist/types-ts4.5/plugins/collab-edit/events/initialize.d.ts +1 -1
  161. package/dist/types-ts4.5/plugins/collab-edit/events/send-transaction.d.ts +1 -1
  162. package/dist/types-ts4.5/plugins/collab-edit/index.d.ts +0 -1
  163. package/dist/types-ts4.5/plugins/collab-edit/native-collab-provider-plugin.d.ts +2 -2
  164. package/dist/types-ts4.5/plugins/collab-edit/participants.d.ts +1 -1
  165. package/dist/types-ts4.5/plugins/collab-edit/plugin.d.ts +0 -2
  166. package/dist/types-ts4.5/plugins/collab-edit/types.d.ts +1 -3
  167. package/dist/types-ts4.5/plugins/collab-edit/ui/to-avatar.d.ts +1 -1
  168. package/dist/types-ts4.5/plugins/collab-edit/utils.d.ts +2 -1
  169. package/dist/types-ts4.5/plugins/extension/index.d.ts +3 -1
  170. package/dist/types-ts4.5/plugins/extension/nodeviews/extension.d.ts +4 -1
  171. package/dist/types-ts4.5/plugins/extension/pm-plugins/main.d.ts +3 -1
  172. package/dist/types-ts4.5/plugins/extension/ui/Extension/Extension/index.d.ts +6 -0
  173. package/dist/types-ts4.5/plugins/extension/ui/Extension/ExtensionComponent.d.ts +3 -0
  174. package/dist/types-ts4.5/plugins/extension/ui/Extension/index.d.ts +3 -0
  175. package/dist/types-ts4.5/plugins/help-dialog/index.d.ts +5 -1
  176. package/dist/types-ts4.5/plugins/index.d.ts +0 -3
  177. package/dist/types-ts4.5/plugins/media/index.d.ts +9 -2
  178. package/dist/types-ts4.5/plugins/media/nodeviews/mediaNodeView/index.d.ts +4 -2
  179. package/dist/types-ts4.5/plugins/media/nodeviews/mediaSingle.d.ts +1 -1
  180. package/dist/types-ts4.5/plugins/media/nodeviews/types.d.ts +2 -1
  181. package/dist/types-ts4.5/plugins/media/toolbar/index.d.ts +3 -1
  182. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/types.d.ts +2 -2
  183. package/dist/types-ts4.5/test-utils.d.ts +3 -1
  184. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  185. package/dist/types-ts4.5/ui/ColorPickerButton/index.d.ts +1 -1
  186. package/dist/types-ts4.5/ui/ContextPanel/index.d.ts +3 -4
  187. package/dist/types-ts4.5/ui/MediaAndEmbedsToolbar/index.d.ts +3 -1
  188. package/dist/types-ts4.5/ui/PluginSlot/index.d.ts +1 -1
  189. package/dist/types-ts4.5/ui/Resizer/types.d.ts +2 -2
  190. package/dist/types-ts4.5/utils/clipboard.d.ts +1 -0
  191. package/package.json +18 -16
  192. package/report.api.md +15 -63
  193. package/dist/cjs/plugins/collab-edit/provider/index.js +0 -5
  194. package/dist/cjs/plugins/collab-edit/provider/types.js +0 -5
  195. package/dist/cjs/plugins/grid/index.js +0 -207
  196. package/dist/cjs/plugins/grid/styles.js +0 -16
  197. package/dist/cjs/plugins/grid/types.js +0 -5
  198. package/dist/cjs/plugins/width/index.js +0 -88
  199. package/dist/cjs/ui/ContextPanel/context.js +0 -89
  200. package/dist/es2019/plugins/collab-edit/provider/index.js +0 -1
  201. package/dist/es2019/plugins/collab-edit/provider/types.js +0 -1
  202. package/dist/es2019/plugins/grid/index.js +0 -168
  203. package/dist/es2019/plugins/grid/styles.js +0 -36
  204. package/dist/es2019/plugins/grid/types.js +0 -1
  205. package/dist/es2019/plugins/width/index.js +0 -72
  206. package/dist/es2019/ui/ContextPanel/context.js +0 -65
  207. package/dist/esm/plugins/collab-edit/provider/index.js +0 -1
  208. package/dist/esm/plugins/collab-edit/provider/types.js +0 -1
  209. package/dist/esm/plugins/grid/index.js +0 -191
  210. package/dist/esm/plugins/grid/styles.js +0 -7
  211. package/dist/esm/plugins/grid/types.js +0 -1
  212. package/dist/esm/plugins/width/index.js +0 -78
  213. package/dist/esm/ui/ContextPanel/context.js +0 -79
  214. package/dist/types/plugins/collab-edit/provider/index.d.ts +0 -1
  215. package/dist/types/plugins/collab-edit/provider/types.d.ts +0 -1
  216. package/dist/types/plugins/grid/index.d.ts +0 -25
  217. package/dist/types/plugins/grid/styles.d.ts +0 -2
  218. package/dist/types/plugins/grid/types.d.ts +0 -7
  219. package/dist/types/plugins/width/index.d.ts +0 -18
  220. package/dist/types/ui/ContextPanel/context.d.ts +0 -24
  221. package/dist/types-ts4.5/plugins/collab-edit/provider/index.d.ts +0 -1
  222. package/dist/types-ts4.5/plugins/collab-edit/provider/types.d.ts +0 -1
  223. package/dist/types-ts4.5/plugins/grid/index.d.ts +0 -27
  224. package/dist/types-ts4.5/plugins/grid/styles.d.ts +0 -2
  225. package/dist/types-ts4.5/plugins/grid/types.d.ts +0 -7
  226. package/dist/types-ts4.5/plugins/width/index.d.ts +0 -18
  227. package/dist/types-ts4.5/ui/ContextPanel/context.d.ts +0 -24
@@ -3,13 +3,12 @@ import React from 'react';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { breakout } from '@atlaskit/adf-schema';
5
5
  import { calcBreakoutWidthPx } from '@atlaskit/editor-common/utils';
6
- import WithPluginState from '../../ui/WithPluginState';
7
- import { pluginKey as widthPluginKey } from '../width';
8
6
  import LayoutButton from './ui/LayoutButton';
9
7
  import { BreakoutCssClassName } from './constants';
10
8
  import { pluginKey } from './plugin-key';
11
9
  import { findSupportedNodeForBreakout } from './utils/find-breakout-node';
12
10
  import { akEditorSwoopCubicBezier } from '@atlaskit/editor-shared-styles';
11
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
13
12
  class BreakoutView {
14
13
  constructor(
15
14
  /**
@@ -17,12 +16,12 @@ class BreakoutView {
17
16
  * of the prosemirror and prosemirror types mean using PMNode
18
17
  * is not problematic.
19
18
  */
20
- mark, view, eventDispatcher) {
19
+ mark, view, pluginInjectionApi) {
21
20
  _defineProperty(this, "updateWidth", widthState => {
22
21
  // we skip updating the width of breakout nodes if the editorView dom
23
22
  // element was hidden (to avoid breakout width and button thrashing
24
23
  // when an editor is hidden, re-rendered and unhidden).
25
- if (widthState.width === 0) {
24
+ if (widthState === undefined || widthState.width === 0) {
26
25
  return;
27
26
  }
28
27
  let containerStyle = ``;
@@ -81,14 +80,16 @@ class BreakoutView {
81
80
  this.mark = mark;
82
81
  this.view = view;
83
82
  this.contentDOM = contentDOM;
84
- this.eventDispatcher = eventDispatcher;
85
- eventDispatcher.on(widthPluginKey.key, this.updateWidth);
86
- this.updateWidth(widthPluginKey.getState(this.view.state));
83
+ this.unsubscribe = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.width.sharedState.onChange(({
84
+ nextSharedState
85
+ }) => this.updateWidth(nextSharedState));
86
+ this.updateWidth(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.width.sharedState.currentState());
87
87
  }
88
88
  // NOTE: Lifecycle events doesn't work for mark NodeView. So currently this is a no-op.
89
89
  // @see https://github.com/ProseMirror/prosemirror/issues/1082
90
90
  destroy() {
91
- this.eventDispatcher.off(widthPluginKey.key, this.updateWidth);
91
+ var _this$unsubscribe;
92
+ (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 ? void 0 : _this$unsubscribe.call(this);
92
93
  }
93
94
  }
94
95
  function shouldPluginStateUpdate(newBreakoutNode, currentBreakoutNode) {
@@ -97,9 +98,8 @@ function shouldPluginStateUpdate(newBreakoutNode, currentBreakoutNode) {
97
98
  }
98
99
  return newBreakoutNode || currentBreakoutNode ? true : false;
99
100
  }
100
- function createPlugin({
101
- dispatch,
102
- eventDispatcher
101
+ function createPlugin(pluginInjectionApi, {
102
+ dispatch
103
103
  }) {
104
104
  return new SafePlugin({
105
105
  state: {
@@ -130,18 +130,38 @@ function createPlugin({
130
130
  // See the following link for more details:
131
131
  // https://prosemirror.net/docs/ref/#view.EditorProps.nodeViews.
132
132
  breakout: (mark, view) => {
133
- return new BreakoutView(mark, view, eventDispatcher);
133
+ return new BreakoutView(mark, view, pluginInjectionApi);
134
134
  }
135
135
  }
136
136
  }
137
137
  });
138
138
  }
139
- const breakoutPlugin = options => ({
139
+ const LayoutButtonWrapper = ({
140
+ api,
141
+ editorView,
142
+ boundariesElement,
143
+ scrollableElement,
144
+ mountPoint
145
+ }) => {
146
+ var _breakoutState$breako;
147
+ // Re-render with `width` (but don't use state) due to https://bitbucket.org/atlassian/%7Bc8e2f021-38d2-46d0-9b7a-b3f7b428f724%7D/pull-requests/24272
148
+ const {
149
+ breakoutState
150
+ } = useSharedPluginState(api, ['width', 'breakout']);
151
+ return /*#__PURE__*/React.createElement(LayoutButton, {
152
+ editorView: editorView,
153
+ mountPoint: mountPoint,
154
+ boundariesElement: boundariesElement,
155
+ scrollableElement: scrollableElement,
156
+ node: (_breakoutState$breako = breakoutState === null || breakoutState === void 0 ? void 0 : breakoutState.breakoutNode) !== null && _breakoutState$breako !== void 0 ? _breakoutState$breako : null
157
+ });
158
+ };
159
+ const breakoutPlugin = (options, api) => ({
140
160
  name: 'breakout',
141
161
  pmPlugins() {
142
162
  return [{
143
163
  name: 'breakout',
144
- plugin: createPlugin
164
+ plugin: props => createPlugin(api, props)
145
165
  }];
146
166
  },
147
167
  marks() {
@@ -150,6 +170,14 @@ const breakoutPlugin = options => ({
150
170
  mark: breakout
151
171
  }];
152
172
  },
173
+ getSharedState(editorState) {
174
+ if (!editorState) {
175
+ return {
176
+ breakoutNode: undefined
177
+ };
178
+ }
179
+ return pluginKey.getState(editorState);
180
+ },
153
181
  contentComponent({
154
182
  editorView,
155
183
  popupsMountPoint,
@@ -160,23 +188,12 @@ const breakoutPlugin = options => ({
160
188
  if (options && !options.allowBreakoutButton) {
161
189
  return null;
162
190
  }
163
- return /*#__PURE__*/React.createElement(WithPluginState, {
164
- plugins: {
165
- breakoutPluginState: pluginKey,
166
- widthPluginState: widthPluginKey
167
- },
168
- render: ({
169
- breakoutPluginState
170
- }) => {
171
- var _breakoutPluginState$;
172
- return /*#__PURE__*/React.createElement(LayoutButton, {
173
- editorView: editorView,
174
- mountPoint: popupsMountPoint,
175
- boundariesElement: popupsBoundariesElement,
176
- scrollableElement: popupsScrollableElement,
177
- node: (_breakoutPluginState$ = breakoutPluginState === null || breakoutPluginState === void 0 ? void 0 : breakoutPluginState.breakoutNode) !== null && _breakoutPluginState$ !== void 0 ? _breakoutPluginState$ : null
178
- });
179
- }
191
+ return /*#__PURE__*/React.createElement(LayoutButtonWrapper, {
192
+ api: api,
193
+ mountPoint: popupsMountPoint,
194
+ editorView: editorView,
195
+ boundariesElement: popupsBoundariesElement,
196
+ scrollableElement: popupsScrollableElement
180
197
  });
181
198
  }
182
199
  });
@@ -158,8 +158,8 @@ const unlinkCard = (node, state, editorAnalyticsApi) => {
158
158
  }
159
159
  return () => false;
160
160
  };
161
- const buildAlignmentOptions = (state, intl, cardOptions) => {
162
- return buildLayoutButtons(state, intl, state.schema.nodes.embedCard, true, true, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowWrapping, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowAlignment);
161
+ const buildAlignmentOptions = (state, intl, widthPluginDependencyApi, cardOptions) => {
162
+ return buildLayoutButtons(state, intl, state.schema.nodes.embedCard, widthPluginDependencyApi, true, true, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowWrapping, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowAlignment);
163
163
  };
164
164
  const withToolbarMetadata = command => commandWithMetadata(command, {
165
165
  inputMethod: INPUT_METHOD.FLOATING_TB
@@ -245,7 +245,8 @@ const generateToolbarItems = (state, featureFlags, intl, providerFactory, cardOp
245
245
  onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
246
246
  }];
247
247
  if (currentAppearance === 'embed') {
248
- const alignmentOptions = buildAlignmentOptions(state, intl, cardOptions);
248
+ var _pluginInjectionApi$d5;
249
+ const alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d5 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.width, cardOptions);
249
250
  if (alignmentOptions.length) {
250
251
  alignmentOptions.push({
251
252
  type: 'separator'
@@ -89,10 +89,8 @@ export class PluginState {
89
89
  remove = remove.concat(oldPointers);
90
90
  }
91
91
  const endOfDocPos = tr.doc.nodeSize - 2;
92
- const {
93
- anchor,
94
- head
95
- } = telepointerData.selection;
92
+ const anchor = telepointerData.selection.anchor;
93
+ const head = telepointerData.selection.head;
96
94
  let rawFrom = anchor < head ? anchor : head;
97
95
  let rawTo = anchor >= head ? anchor : head;
98
96
  if (rawFrom > endOfDocPos) {
@@ -1,9 +1,11 @@
1
1
  import { copyButtonPluginKey } from './pm-plugins/plugin-key';
2
2
  import { hoverDecoration } from '../base/pm-plugins/decoration';
3
- import { copyHTMLToClipboard } from '../../utils/clipboard';
3
+ import { NodeSelection } from 'prosemirror-state';
4
+ import { copyHTMLToClipboard, copyHTMLToClipboardPolyfill } from '../../utils/clipboard';
4
5
  import { getSelectedNodeOrNodeParentByNodeType, toDOM } from './utils';
5
6
  import { addAnalytics, ACTION, INPUT_METHOD } from '../analytics';
6
7
  import { getAnalyticsPayload } from '../clipboard/pm-plugins/main';
8
+ import { browser } from '@atlaskit/editor-common/utils';
7
9
  export function createToolbarCopyCommandForMark(markType) {
8
10
  function command(state, dispatch) {
9
11
  const textNode = state.tr.selection.$head.parent.maybeChild(state.tr.selection.$head.index());
@@ -121,7 +123,12 @@ export const createToolbarCopyCommandForNode = nodeType => (state, dispatch) =>
121
123
  // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
122
124
  div.firstChild.setAttribute('data-pm-slice', '0 0 []');
123
125
  }
124
- copyHTMLToClipboard(div);
126
+ // ED-17083 safari seems have bugs for extension copy because exntension do not have a child text(innerText) and it will not recognized as html in clipboard, this could be merge into one if this extension fixed children issue or safari fix the copy bug
127
+ if (browser.safari && state.selection instanceof NodeSelection && state.selection.node.type === state.schema.nodes.extension) {
128
+ copyHTMLToClipboardPolyfill(div);
129
+ } else {
130
+ copyHTMLToClipboard(div);
131
+ }
125
132
  }
126
133
  copyToClipboardTr.setMeta('scrollIntoView', false);
127
134
  dispatch(copyToClipboardTr);
@@ -31,7 +31,7 @@ const extensionPlugin = (options = {}, api) => {
31
31
  eventDispatcher
32
32
  }) => {
33
33
  const extensionHandlers = options.extensionHandlers || {};
34
- return createPlugin(dispatch, providerFactory, extensionHandlers, portalProviderAPI, eventDispatcher, options.useLongPressSelection, {
34
+ return createPlugin(dispatch, providerFactory, extensionHandlers, portalProviderAPI, eventDispatcher, api, options.useLongPressSelection, {
35
35
  appearance: options.appearance
36
36
  });
37
37
  }
@@ -43,17 +43,19 @@ export class ExtensionNode extends ReactNodeView {
43
43
  providerFactory: props.providerFactory,
44
44
  handleContentDOMRef: forwardRef,
45
45
  extensionHandlers: props.extensionHandlers,
46
- editorAppearance: (_props$extensionNodeV = props.extensionNodeViewOptions) === null || _props$extensionNodeV === void 0 ? void 0 : _props$extensionNodeV.appearance
46
+ editorAppearance: (_props$extensionNodeV = props.extensionNodeViewOptions) === null || _props$extensionNodeV === void 0 ? void 0 : _props$extensionNodeV.appearance,
47
+ pluginInjectionApi: props.pluginInjectionApi
47
48
  }));
48
49
  }
49
50
  }
50
- export default function ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions) {
51
+ export default function ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi) {
51
52
  return (node, view, getPos) => {
52
53
  const hasIntlContext = true;
53
54
  return new ExtensionNode(node, view, getPos, portalProviderAPI, eventDispatcher, {
54
55
  providerFactory,
55
56
  extensionHandlers,
56
- extensionNodeViewOptions
57
+ extensionNodeViewOptions,
58
+ pluginInjectionApi
57
59
  }, undefined, undefined, undefined, hasIntlContext).init();
58
60
  };
59
61
  }
@@ -125,7 +125,7 @@ export const handleUpdate = ({
125
125
  }
126
126
  return true;
127
127
  };
128
- const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProviderAPI, eventDispatcher, useLongPressSelection = false, options = {}) => {
128
+ const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProviderAPI, eventDispatcher, pluginInjectionApi, useLongPressSelection = false, options = {}) => {
129
129
  const state = createPluginState(dispatch, {
130
130
  showEditButton: false,
131
131
  showContextPanel: false
@@ -160,11 +160,11 @@ const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProvid
160
160
  props: {
161
161
  nodeViews: {
162
162
  // WARNING: referentiality-plugin also creates these nodeviews
163
- extension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions),
163
+ extension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi),
164
164
  // WARNING: referentiality-plugin also creates these nodeviews
165
- bodiedExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions),
165
+ bodiedExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi),
166
166
  // WARNING: referentiality-plugin also creates these nodeviews
167
- inlineExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions)
167
+ inlineExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi)
168
168
  },
169
169
  handleClickOn: createSelectionClickHandler(['extension', 'bodiedExtension'], target => !target.closest('.extension-content'), {
170
170
  useLongPressSelection
@@ -7,9 +7,8 @@ import { calculateBreakoutStyles } from '@atlaskit/editor-common/utils';
7
7
  import { wrapperStyle, header, content, contentWrapper, widerLayoutClassName } from './styles';
8
8
  import { overlay } from '../styles';
9
9
  import ExtensionLozenge from '../Lozenge';
10
- import { pluginKey as widthPluginKey } from '../../../../width';
11
- import WithPluginState from '../../../../../ui/WithPluginState';
12
10
  import classnames from 'classnames';
11
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
13
12
  function ExtensionWithPluginState(props) {
14
13
  const {
15
14
  node,
@@ -92,6 +91,39 @@ function ExtensionWithPluginState(props) {
92
91
  }))));
93
92
  }
94
93
  const Extension = props => {
94
+ // TODO: ED-17836 This code is here because confluence injects
95
+ // the `editor-referentiality` plugin via `dangerouslyAppendPlugins`
96
+ // which cannot access the `pluginInjectionApi`. When we move
97
+ // Confluence to using presets we can remove this workaround.
98
+ const {
99
+ pluginInjectionApi
100
+ } = props;
101
+ return pluginInjectionApi === undefined ? jsx(ExtensionDeprecated, props) : jsx(ExtensionWithSharedState, props);
102
+ };
103
+ const ExtensionWithSharedState = props => {
104
+ const {
105
+ pluginInjectionApi
106
+ } = props;
107
+ const {
108
+ widthState
109
+ } = useSharedPluginState(pluginInjectionApi, ['width']);
110
+ return jsx(ExtensionWithPluginState, _extends({
111
+ widthState: widthState
112
+ }, props));
113
+ };
114
+ import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
115
+ // TODO: ED-17836 This code is here because Confluence injects
116
+ // the `editor-referentiality` plugin via `dangerouslyAppendPlugins`
117
+ // which cannot access the `pluginInjectionApi`. When we move
118
+ // Confluence to using presets we can remove this workaround.
119
+ // @ts-ignore
120
+ const widthPluginKey = {
121
+ key: 'widthPlugin$',
122
+ getState: state => {
123
+ return state['widthPlugin$'];
124
+ }
125
+ };
126
+ const ExtensionDeprecated = props => {
95
127
  return jsx(WithPluginState, {
96
128
  editorView: props.view,
97
129
  plugins: {
@@ -104,6 +136,10 @@ const Extension = props => {
104
136
  }, props))
105
137
  });
106
138
  };
139
+ /**
140
+ * End workaround
141
+ */
142
+
107
143
  export default overflowShadow(Extension, {
108
144
  overflowSelector: '.extension-overflow-wrapper'
109
145
  });
@@ -134,7 +134,8 @@ export default class ExtensionComponent extends Component {
134
134
  handleContentDOMRef,
135
135
  editorView,
136
136
  references,
137
- editorAppearance
137
+ editorAppearance,
138
+ pluginInjectionApi
138
139
  } = this.props;
139
140
  const extensionHandlerResult = this.tryExtensionHandler();
140
141
  switch (node.type.name) {
@@ -148,7 +149,8 @@ export default class ExtensionComponent extends Component {
148
149
  handleContentDOMRef: handleContentDOMRef,
149
150
  view: editorView,
150
151
  editorAppearance: editorAppearance,
151
- hideFrame: (_this$state$_privateP = this.state._privateProps) === null || _this$state$_privateP === void 0 ? void 0 : _this$state$_privateP.__hideFrame
152
+ hideFrame: (_this$state$_privateP = this.state._privateProps) === null || _this$state$_privateP === void 0 ? void 0 : _this$state$_privateP.__hideFrame,
153
+ pluginInjectionApi: pluginInjectionApi
152
154
  }, extensionHandlerResult);
153
155
  case 'inlineExtension':
154
156
  return /*#__PURE__*/React.createElement(InlineExtension, {
@@ -16,7 +16,8 @@ export default class Extension extends Component {
16
16
  handleContentDOMRef,
17
17
  extensionHandlers,
18
18
  references,
19
- editorAppearance
19
+ editorAppearance,
20
+ pluginInjectionApi
20
21
  } = this.props;
21
22
  return /*#__PURE__*/React.createElement(ExtensionComponent, {
22
23
  editorView: editorView,
@@ -26,7 +27,8 @@ export default class Extension extends Component {
26
27
  extensionProvider: extensionProvider,
27
28
  handleContentDOMRef: handleContentDOMRef,
28
29
  extensionHandlers: extensionHandlers,
29
- editorAppearance: editorAppearance
30
+ editorAppearance: editorAppearance,
31
+ pluginInjectionApi: pluginInjectionApi
30
32
  });
31
33
  });
32
34
  this.providerFactory = props.providerFactory || new ProviderFactory();
@@ -6,7 +6,7 @@ import { openHelp, tooltip } from '../../keymaps';
6
6
  import WithPluginState from '../../ui/WithPluginState';
7
7
  import { HelpDialogLoader } from './ui/HelpDialogLoader';
8
8
  import { pluginKey as quickInsertPluginKey } from '../quick-insert';
9
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE, INPUT_METHOD } from '../../plugins/analytics';
9
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
10
10
  import QuestionCircleIcon from '@atlaskit/icon/glyph/question-circle';
11
11
  import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
12
12
  import { openHelpCommand } from './commands';
@@ -37,7 +37,7 @@ export function createPlugin(dispatch, imageEnabled) {
37
37
  }
38
38
  });
39
39
  }
40
- const helpDialog = (imageUploadProviderExists = false) => ({
40
+ const helpDialog = (imageUploadProviderExists = false, api) => ({
41
41
  name: 'helpDialog',
42
42
  pmPlugins() {
43
43
  return [{
@@ -47,7 +47,10 @@ const helpDialog = (imageUploadProviderExists = false) => ({
47
47
  }) => createPlugin(dispatch, imageUploadProviderExists)
48
48
  }, {
49
49
  name: 'helpDialogKeymap',
50
- plugin: () => keymapPlugin()
50
+ plugin: () => {
51
+ var _api$dependencies$ana;
52
+ return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions);
53
+ }
51
54
  }];
52
55
  },
53
56
  pluginsOptions: {
@@ -63,10 +66,11 @@ const helpDialog = (imageUploadProviderExists = false) => ({
63
66
  icon: () => /*#__PURE__*/React.createElement(QuestionCircleIcon, {
64
67
  label: ""
65
68
  }),
66
- action(insert, state) {
69
+ action(insert) {
70
+ var _api$dependencies$ana2;
67
71
  const tr = insert('');
68
72
  openHelpCommand(tr);
69
- return addAnalytics(state, tr, {
73
+ api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions.attachAnalyticsEvent({
70
74
  action: ACTION.HELP_OPENED,
71
75
  actionSubject: ACTION_SUBJECT.HELP,
72
76
  actionSubjectId: ACTION_SUBJECT_ID.HELP_QUICK_INSERT,
@@ -74,7 +78,8 @@ const helpDialog = (imageUploadProviderExists = false) => ({
74
78
  inputMethod: INPUT_METHOD.QUICK_INSERT
75
79
  },
76
80
  eventType: EVENT_TYPE.UI
77
- });
81
+ })(tr);
82
+ return tr;
78
83
  }
79
84
  }]
80
85
  },
@@ -98,7 +103,7 @@ const helpDialog = (imageUploadProviderExists = false) => ({
98
103
  });
99
104
  }
100
105
  });
101
- const keymapPlugin = () => {
106
+ const keymapPlugin = editorAnalyticsAPI => {
102
107
  const list = {};
103
108
  keymaps.bindKeymapWithCommand(keymaps.openHelp.common, (state, dispatch) => {
104
109
  let {
@@ -106,7 +111,7 @@ const keymapPlugin = () => {
106
111
  } = state;
107
112
  const isVisible = tr.getMeta(pluginKey);
108
113
  if (!isVisible) {
109
- tr = addAnalytics(state, tr, {
114
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
110
115
  action: ACTION.CLICKED,
111
116
  actionSubject: ACTION_SUBJECT.BUTTON,
112
117
  actionSubjectId: ACTION_SUBJECT_ID.BUTTON_HELP,
@@ -114,7 +119,7 @@ const keymapPlugin = () => {
114
119
  inputMethod: INPUT_METHOD.SHORTCUT
115
120
  },
116
121
  eventType: EVENT_TYPE.UI
117
- });
122
+ })(tr);
118
123
  openHelpCommand(tr, dispatch);
119
124
  }
120
125
  return true;
@@ -33,11 +33,9 @@ export { default as textColorPlugin } from './text-color';
33
33
  export { default as textFormattingPlugin } from './text-formatting';
34
34
  export { default as typeAheadPlugin } from './type-ahead';
35
35
  export { default as unsupportedContentPlugin } from './unsupported-content';
36
- export { default as widthPlugin } from './width';
37
36
  export { default as cardPlugin } from './card';
38
37
  export { default as floatingToolbarPlugin } from './floating-toolbar';
39
38
  export { default as statusPlugin } from './status';
40
- export { default as gridPlugin } from './grid';
41
39
  export { default as breakoutPlugin } from './breakout';
42
40
  export { default as alignmentPlugin } from './alignment';
43
41
  export { default as dataConsumerMarkPlugin } from './data-consumer';
@@ -134,7 +134,6 @@ export default (options => new SafePlugin({
134
134
  tr = fixColumnStructure(newState) || tr;
135
135
  if (tr.docChanged) {
136
136
  tr.setSelection(Selection.fromJSON(tr.doc, selection));
137
- tr.setMeta('addToHistory', false);
138
137
  return tr;
139
138
  }
140
139
  }
@@ -14,19 +14,26 @@ import ToolbarMedia from './ui/ToolbarMedia';
14
14
  import { ReactMediaGroupNode } from './nodeviews/mediaGroup';
15
15
  import { ReactMediaSingleNode } from './nodeviews/mediaSingle';
16
16
  import { floatingToolbar } from './toolbar';
17
- import { addAnalytics, ACTION, ACTION_SUBJECT, INPUT_METHOD, EVENT_TYPE, ACTION_SUBJECT_ID } from '../analytics';
17
+ import { ACTION, ACTION_SUBJECT, INPUT_METHOD, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
18
18
  import { IconImages } from '../quick-insert/assets';
19
19
  import WithPluginState from '../../ui/WithPluginState';
20
20
  import { MediaPickerComponents } from './ui/MediaPicker';
21
21
  import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
22
22
  import { ReactMediaNode } from './nodeviews/mediaNodeView';
23
23
  import { ReactMediaInlineNode } from './nodeviews/mediaInline';
24
+ import { stateKey } from './pm-plugins/plugin-key';
24
25
  export { insertMediaSingleNode } from './utils/media-single';
25
26
  const mediaPlugin = (options = {}, api) => {
26
27
  var _api$dependencies, _api$dependencies$fea;
27
28
  const featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
28
29
  return {
29
30
  name: 'media',
31
+ getSharedState(editorState) {
32
+ if (!editorState) {
33
+ return null;
34
+ }
35
+ return stateKey.getState(editorState);
36
+ },
30
37
  nodes() {
31
38
  const {
32
39
  allowMediaGroup = true,
@@ -80,7 +87,7 @@ const mediaPlugin = (options = {}, api) => {
80
87
  nodeViews: {
81
88
  mediaGroup: ReactMediaGroupNode(portalProviderAPI, eventDispatcher, providerFactory, options),
82
89
  mediaSingle: ReactMediaSingleNode(portalProviderAPI, eventDispatcher, providerFactory, dispatchAnalyticsEvent, options, api),
83
- media: ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options),
90
+ media: ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options, api),
84
91
  mediaInline: ReactMediaInlineNode(portalProviderAPI, eventDispatcher, providerFactory)
85
92
  },
86
93
  errorReporter,
@@ -207,9 +214,11 @@ const mediaPlugin = (options = {}, api) => {
207
214
  keywords: ['attachment', 'gif', 'media', 'picture', 'image', 'video'],
208
215
  icon: () => /*#__PURE__*/React.createElement(IconImages, null),
209
216
  action(insert, state) {
217
+ var _api$dependencies$ana;
210
218
  const pluginState = pluginKey.getState(state);
211
219
  pluginState.showMediaPicker();
212
- return addAnalytics(state, insert(''), {
220
+ const tr = insert('');
221
+ api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions.attachAnalyticsEvent({
213
222
  action: ACTION.OPENED,
214
223
  actionSubject: ACTION_SUBJECT.PICKER,
215
224
  actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
@@ -217,7 +226,8 @@ const mediaPlugin = (options = {}, api) => {
217
226
  inputMethod: INPUT_METHOD.QUICK_INSERT
218
227
  },
219
228
  eventType: EVENT_TYPE.UI
220
- });
229
+ })(tr);
230
+ return tr;
221
231
  }
222
232
  }],
223
233
  floatingToolbar: (state, intl, providerFactory) => floatingToolbar(state, intl, {
@@ -229,7 +239,7 @@ const mediaPlugin = (options = {}, api) => {
229
239
  allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
230
240
  allowAltTextOnImages: options && options.allowAltTextOnImages,
231
241
  altTextValidator: options && options.altTextValidator
232
- })
242
+ }, api)
233
243
  }
234
244
  };
235
245
  };
@@ -4,11 +4,21 @@ import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-comm
4
4
  import { NodeSelection } from 'prosemirror-state';
5
5
  import React from 'react';
6
6
  import { SelectionBasedNodeView } from '../../../../nodeviews';
7
- import WithPluginState from '../../../../ui/WithPluginState';
8
- import { pluginKey as widthPluginKey } from '../../../width';
9
7
  import MediaNode from './media';
10
8
  import { getAttrsFromUrl } from '@atlaskit/media-client';
11
9
  import { isMediaBlobUrlFromAttrs } from '../../utils/media-common';
10
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
11
+ const MediaNodeWithProviders = ({
12
+ pluginInjectionApi,
13
+ innerComponent
14
+ }) => {
15
+ const {
16
+ widthState
17
+ } = useSharedPluginState(pluginInjectionApi, ['width']);
18
+ return innerComponent({
19
+ width: widthState
20
+ });
21
+ };
12
22
  class MediaNodeView extends SelectionBasedNodeView {
13
23
  constructor(...args) {
14
24
  super(...args);
@@ -69,12 +79,12 @@ class MediaNodeView extends SelectionBasedNodeView {
69
79
  mediaProvider,
70
80
  contextIdentifierProvider
71
81
  }) => {
72
- return /*#__PURE__*/React.createElement(WithPluginState, {
73
- editorView: this.view,
74
- plugins: {
75
- width: widthPluginKey
76
- },
77
- render: this.renderMediaNodeWithState(mediaProvider, contextIdentifierProvider)
82
+ const {
83
+ pluginInjectionApi
84
+ } = this.reactComponentProps;
85
+ return /*#__PURE__*/React.createElement(MediaNodeWithProviders, {
86
+ pluginInjectionApi: pluginInjectionApi,
87
+ innerComponent: this.renderMediaNodeWithState(mediaProvider, contextIdentifierProvider)
78
88
  });
79
89
  });
80
90
  }
@@ -124,11 +134,12 @@ class MediaNodeView extends SelectionBasedNodeView {
124
134
  });
125
135
  }
126
136
  }
127
- export const ReactMediaNode = (portalProviderAPI, eventDispatcher, providerFactory, mediaOptions = {}) => (node, view, getPos) => {
137
+ export const ReactMediaNode = (portalProviderAPI, eventDispatcher, providerFactory, mediaOptions = {}, pluginInjectionApi) => (node, view, getPos) => {
128
138
  const hasIntlContext = true;
129
139
  return new MediaNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {
130
140
  eventDispatcher,
131
141
  providerFactory,
132
- mediaOptions
142
+ mediaOptions,
143
+ pluginInjectionApi
133
144
  }, undefined, undefined, undefined, hasIntlContext).init();
134
145
  };