@atlaskit/editor-core 185.2.0 → 185.2.5

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 (258) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/actions/index.js +2 -2
  3. package/dist/cjs/create-editor/ReactEditorViewInternal.js +1 -2
  4. package/dist/cjs/index.js +0 -6
  5. package/dist/cjs/labs/next/internal/hooks/use-editor/create-editor.js +1 -1
  6. package/dist/cjs/messages.js +6 -56
  7. package/dist/cjs/nodeviews/getInlineNodeViewProducer.styles.js +2 -2
  8. package/dist/cjs/plugins/base/pm-plugins/scroll-gutter.js +1 -1
  9. package/dist/cjs/plugins/card/nodeviews/blockCard.js +2 -2
  10. package/dist/cjs/plugins/card/nodeviews/embedCard.js +6 -6
  11. package/dist/cjs/plugins/card/nodeviews/genericCard.js +2 -1
  12. package/dist/cjs/plugins/card/pm-plugins/doc.js +9 -11
  13. package/dist/cjs/plugins/card/pm-plugins/keymap.js +3 -6
  14. package/dist/cjs/plugins/card/pm-plugins/main.js +2 -2
  15. package/dist/cjs/plugins/card/toolbar.js +13 -16
  16. package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +19 -18
  17. package/dist/cjs/plugins/card/ui/ResizableEmbedCard.js +7 -10
  18. package/dist/cjs/plugins/card/utils.js +3 -4
  19. package/dist/cjs/plugins/clear-marks-on-change-to-empty-document/index.js +1 -1
  20. package/dist/cjs/plugins/custom-autoformat/doc.js +1 -1
  21. package/dist/cjs/plugins/date/pm-plugins/main.js +2 -2
  22. package/dist/cjs/plugins/emoji/index.js +2 -2
  23. package/dist/cjs/plugins/floating-toolbar/index.js +8 -2
  24. package/dist/cjs/plugins/hyperlink/Toolbar.js +8 -8
  25. package/dist/cjs/plugins/hyperlink/commands.js +2 -3
  26. package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +2 -2
  27. package/dist/cjs/plugins/layout/actions.js +1 -1
  28. package/dist/cjs/plugins/media/nodeviews/mediaNodeUpdater.js +1 -1
  29. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +2 -3
  30. package/dist/cjs/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +1 -2
  31. package/dist/cjs/plugins/media/toolbar/index.js +10 -9
  32. package/dist/cjs/plugins/media/toolbar/linking-toolbar-appearance.js +4 -3
  33. package/dist/cjs/plugins/media/toolbar/linking.js +6 -6
  34. package/dist/cjs/plugins/media/ui/MediaLinkingToolbar.js +1 -1
  35. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/index.js +6 -8
  36. package/dist/cjs/plugins/media/utils/media-files.js +8 -7
  37. package/dist/cjs/plugins/mentions/pm-plugins/main.js +2 -2
  38. package/dist/cjs/plugins/placeholder/index.js +2 -3
  39. package/dist/cjs/plugins/status/plugin.js +2 -2
  40. package/dist/cjs/plugins/unsupported-content/index.js +3 -3
  41. package/dist/cjs/ui/LinkSearch/ToolbarComponents.js +4 -11
  42. package/dist/cjs/utils/document.js +7 -249
  43. package/dist/cjs/utils/index.js +1 -23
  44. package/dist/cjs/version-wrapper.js +1 -1
  45. package/dist/cjs/version.json +1 -1
  46. package/dist/es2019/actions/index.js +2 -1
  47. package/dist/es2019/create-editor/ReactEditorViewInternal.js +1 -1
  48. package/dist/es2019/index.js +1 -1
  49. package/dist/es2019/labs/next/internal/hooks/use-editor/create-editor.js +1 -1
  50. package/dist/es2019/messages.js +2 -54
  51. package/dist/es2019/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
  52. package/dist/es2019/plugins/base/pm-plugins/scroll-gutter.js +1 -1
  53. package/dist/es2019/plugins/card/nodeviews/blockCard.js +1 -1
  54. package/dist/es2019/plugins/card/nodeviews/embedCard.js +3 -3
  55. package/dist/es2019/plugins/card/nodeviews/genericCard.js +2 -1
  56. package/dist/es2019/plugins/card/pm-plugins/doc.js +2 -3
  57. package/dist/es2019/plugins/card/pm-plugins/keymap.js +3 -3
  58. package/dist/es2019/plugins/card/pm-plugins/main.js +1 -1
  59. package/dist/es2019/plugins/card/toolbar.js +8 -10
  60. package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +10 -8
  61. package/dist/es2019/plugins/card/ui/ResizableEmbedCard.js +1 -4
  62. package/dist/es2019/plugins/card/utils.js +1 -2
  63. package/dist/es2019/plugins/clear-marks-on-change-to-empty-document/index.js +1 -1
  64. package/dist/es2019/plugins/custom-autoformat/doc.js +1 -1
  65. package/dist/es2019/plugins/date/pm-plugins/main.js +1 -1
  66. package/dist/es2019/plugins/emoji/index.js +1 -1
  67. package/dist/es2019/plugins/floating-toolbar/index.js +5 -2
  68. package/dist/es2019/plugins/hyperlink/Toolbar.js +3 -3
  69. package/dist/es2019/plugins/hyperlink/commands.js +1 -2
  70. package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +1 -1
  71. package/dist/es2019/plugins/layout/actions.js +1 -1
  72. package/dist/es2019/plugins/media/nodeviews/mediaNodeUpdater.js +1 -1
  73. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +1 -1
  74. package/dist/es2019/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +1 -1
  75. package/dist/es2019/plugins/media/toolbar/index.js +10 -9
  76. package/dist/es2019/plugins/media/toolbar/linking-toolbar-appearance.js +2 -1
  77. package/dist/es2019/plugins/media/toolbar/linking.js +4 -4
  78. package/dist/es2019/plugins/media/ui/MediaLinkingToolbar.js +1 -1
  79. package/dist/es2019/plugins/media/ui/ResizableMediaSingle/index.js +2 -4
  80. package/dist/es2019/plugins/media/utils/media-files.js +4 -3
  81. package/dist/es2019/plugins/mentions/pm-plugins/main.js +1 -1
  82. package/dist/es2019/plugins/placeholder/index.js +1 -1
  83. package/dist/es2019/plugins/status/plugin.js +1 -1
  84. package/dist/es2019/plugins/unsupported-content/index.js +1 -1
  85. package/dist/es2019/ui/LinkSearch/ToolbarComponents.js +1 -4
  86. package/dist/es2019/utils/document.js +3 -244
  87. package/dist/es2019/utils/index.js +1 -4
  88. package/dist/es2019/version-wrapper.js +1 -1
  89. package/dist/es2019/version.json +1 -1
  90. package/dist/esm/actions/index.js +2 -1
  91. package/dist/esm/create-editor/ReactEditorViewInternal.js +1 -1
  92. package/dist/esm/index.js +1 -1
  93. package/dist/esm/labs/next/internal/hooks/use-editor/create-editor.js +1 -1
  94. package/dist/esm/messages.js +2 -54
  95. package/dist/esm/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
  96. package/dist/esm/plugins/base/pm-plugins/scroll-gutter.js +1 -1
  97. package/dist/esm/plugins/card/nodeviews/blockCard.js +1 -1
  98. package/dist/esm/plugins/card/nodeviews/embedCard.js +3 -3
  99. package/dist/esm/plugins/card/nodeviews/genericCard.js +2 -1
  100. package/dist/esm/plugins/card/pm-plugins/doc.js +2 -3
  101. package/dist/esm/plugins/card/pm-plugins/keymap.js +3 -3
  102. package/dist/esm/plugins/card/pm-plugins/main.js +1 -1
  103. package/dist/esm/plugins/card/toolbar.js +8 -10
  104. package/dist/esm/plugins/card/ui/EditLinkToolbar.js +18 -16
  105. package/dist/esm/plugins/card/ui/ResizableEmbedCard.js +1 -4
  106. package/dist/esm/plugins/card/utils.js +1 -2
  107. package/dist/esm/plugins/clear-marks-on-change-to-empty-document/index.js +1 -1
  108. package/dist/esm/plugins/custom-autoformat/doc.js +1 -1
  109. package/dist/esm/plugins/date/pm-plugins/main.js +1 -1
  110. package/dist/esm/plugins/emoji/index.js +1 -1
  111. package/dist/esm/plugins/floating-toolbar/index.js +5 -2
  112. package/dist/esm/plugins/hyperlink/Toolbar.js +3 -3
  113. package/dist/esm/plugins/hyperlink/commands.js +1 -2
  114. package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +1 -1
  115. package/dist/esm/plugins/layout/actions.js +1 -1
  116. package/dist/esm/plugins/media/nodeviews/mediaNodeUpdater.js +1 -1
  117. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +1 -1
  118. package/dist/esm/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +1 -1
  119. package/dist/esm/plugins/media/toolbar/index.js +10 -9
  120. package/dist/esm/plugins/media/toolbar/linking-toolbar-appearance.js +2 -1
  121. package/dist/esm/plugins/media/toolbar/linking.js +4 -4
  122. package/dist/esm/plugins/media/ui/MediaLinkingToolbar.js +1 -1
  123. package/dist/esm/plugins/media/ui/ResizableMediaSingle/index.js +2 -4
  124. package/dist/esm/plugins/media/utils/media-files.js +4 -3
  125. package/dist/esm/plugins/mentions/pm-plugins/main.js +1 -1
  126. package/dist/esm/plugins/placeholder/index.js +1 -1
  127. package/dist/esm/plugins/status/plugin.js +1 -1
  128. package/dist/esm/plugins/unsupported-content/index.js +1 -1
  129. package/dist/esm/ui/LinkSearch/ToolbarComponents.js +1 -4
  130. package/dist/esm/utils/document.js +6 -240
  131. package/dist/esm/utils/index.js +1 -4
  132. package/dist/esm/version-wrapper.js +1 -1
  133. package/dist/esm/version.json +1 -1
  134. package/dist/types/index.d.ts +1 -2
  135. package/dist/types/labs/next/presets/cxhtml.d.ts +9 -3
  136. package/dist/types/labs/next/presets/default.d.ts +13 -1
  137. package/dist/types/labs/next/presets/mobile.d.ts +9 -3
  138. package/dist/types/messages.d.ts +2 -53
  139. package/dist/types/plugins/card/index.d.ts +3 -1
  140. package/dist/types/plugins/card/nodeviews/blockCard.d.ts +1 -1
  141. package/dist/types/plugins/card/nodeviews/genericCard.d.ts +3 -3
  142. package/dist/types/plugins/card/nodeviews/inlineCard.d.ts +1 -1
  143. package/dist/types/plugins/card/toolbar.d.ts +1 -1
  144. package/dist/types/plugins/card/types.d.ts +1 -1
  145. package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +7 -4
  146. package/dist/types/plugins/card/ui/ResizableEmbedCard.d.ts +1 -1
  147. package/dist/types/plugins/date/nodeviews/date.d.ts +1 -1
  148. package/dist/types/plugins/emoji/nodeviews/emoji.d.ts +1 -1
  149. package/dist/types/plugins/floating-toolbar/index.d.ts +2 -6
  150. package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
  151. package/dist/types/plugins/hyperlink/Toolbar.d.ts +1 -1
  152. package/dist/types/plugins/hyperlink/commands.d.ts +2 -3
  153. package/dist/types/plugins/hyperlink/index.d.ts +1 -1
  154. package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.d.ts +1 -1
  155. package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +1 -1
  156. package/dist/types/plugins/media/index.d.ts +3 -1
  157. package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +1 -1
  158. package/dist/types/plugins/media/nodeviews/mediaNodeUpdater.d.ts +1 -1
  159. package/dist/types/plugins/media/nodeviews/types.d.ts +1 -1
  160. package/dist/types/plugins/media/toolbar/linking.d.ts +3 -1
  161. package/dist/types/plugins/media/ui/ResizableMediaSingle/types.d.ts +0 -15
  162. package/dist/types/plugins/media/utils/media-files.d.ts +1 -1
  163. package/dist/types/plugins/mentions/nodeviews/mention.d.ts +1 -1
  164. package/dist/types/plugins/status/nodeviews/status.d.ts +1 -1
  165. package/dist/types/plugins/unsupported-content/unsupported-inline-node-view.d.ts +1 -1
  166. package/dist/types/types/editor-props.d.ts +1 -1
  167. package/dist/types/ui/LinkSearch/ToolbarComponents.d.ts +0 -4
  168. package/dist/types/utils/document.d.ts +0 -12
  169. package/dist/types/utils/index.d.ts +1 -2
  170. package/dist/types-ts4.5/index.d.ts +1 -2
  171. package/dist/types-ts4.5/labs/next/presets/cxhtml.d.ts +9 -3
  172. package/dist/types-ts4.5/labs/next/presets/default.d.ts +13 -1
  173. package/dist/types-ts4.5/labs/next/presets/mobile.d.ts +9 -3
  174. package/dist/types-ts4.5/messages.d.ts +2 -53
  175. package/dist/types-ts4.5/plugins/card/index.d.ts +3 -1
  176. package/dist/types-ts4.5/plugins/card/nodeviews/blockCard.d.ts +1 -1
  177. package/dist/types-ts4.5/plugins/card/nodeviews/genericCard.d.ts +3 -3
  178. package/dist/types-ts4.5/plugins/card/nodeviews/inlineCard.d.ts +1 -1
  179. package/dist/types-ts4.5/plugins/card/toolbar.d.ts +1 -1
  180. package/dist/types-ts4.5/plugins/card/types.d.ts +1 -1
  181. package/dist/types-ts4.5/plugins/card/ui/EditLinkToolbar.d.ts +7 -4
  182. package/dist/types-ts4.5/plugins/card/ui/ResizableEmbedCard.d.ts +1 -1
  183. package/dist/types-ts4.5/plugins/date/nodeviews/date.d.ts +1 -1
  184. package/dist/types-ts4.5/plugins/emoji/nodeviews/emoji.d.ts +1 -1
  185. package/dist/types-ts4.5/plugins/floating-toolbar/index.d.ts +2 -9
  186. package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
  187. package/dist/types-ts4.5/plugins/hyperlink/Toolbar.d.ts +1 -1
  188. package/dist/types-ts4.5/plugins/hyperlink/commands.d.ts +2 -3
  189. package/dist/types-ts4.5/plugins/hyperlink/index.d.ts +1 -1
  190. package/dist/types-ts4.5/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.d.ts +1 -1
  191. package/dist/types-ts4.5/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +1 -1
  192. package/dist/types-ts4.5/plugins/media/index.d.ts +3 -1
  193. package/dist/types-ts4.5/plugins/media/nodeviews/mediaInline.d.ts +1 -1
  194. package/dist/types-ts4.5/plugins/media/nodeviews/mediaNodeUpdater.d.ts +1 -1
  195. package/dist/types-ts4.5/plugins/media/nodeviews/types.d.ts +1 -1
  196. package/dist/types-ts4.5/plugins/media/toolbar/linking.d.ts +3 -1
  197. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/types.d.ts +0 -15
  198. package/dist/types-ts4.5/plugins/media/utils/media-files.d.ts +1 -1
  199. package/dist/types-ts4.5/plugins/mentions/nodeviews/mention.d.ts +1 -1
  200. package/dist/types-ts4.5/plugins/status/nodeviews/status.d.ts +1 -1
  201. package/dist/types-ts4.5/plugins/unsupported-content/unsupported-inline-node-view.d.ts +1 -1
  202. package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
  203. package/dist/types-ts4.5/ui/LinkSearch/ToolbarComponents.d.ts +0 -4
  204. package/dist/types-ts4.5/utils/document.d.ts +0 -12
  205. package/dist/types-ts4.5/utils/index.d.ts +1 -2
  206. package/package.json +11 -14
  207. package/report.api.md +11 -34
  208. package/tmp/api-report-tmp.d.ts +10 -34
  209. package/dist/cjs/nodeviews/getInlineNodeViewProducer.js +0 -227
  210. package/dist/cjs/plugins/hyperlink/types.js +0 -5
  211. package/dist/cjs/ui/MediaAndEmbedsToolbar/index.js +0 -152
  212. package/dist/cjs/ui/Resizer/index.js +0 -210
  213. package/dist/cjs/ui/Resizer/styled.js +0 -15
  214. package/dist/cjs/ui/Resizer/types.js +0 -5
  215. package/dist/cjs/ui/Resizer/utils.js +0 -21
  216. package/dist/cjs/utils/filter/privacy-filter.js +0 -55
  217. package/dist/cjs/utils/linking-utils.js +0 -84
  218. package/dist/cjs/utils/rich-media-utils.js +0 -130
  219. package/dist/es2019/nodeviews/getInlineNodeViewProducer.js +0 -221
  220. package/dist/es2019/plugins/hyperlink/types.js +0 -1
  221. package/dist/es2019/ui/MediaAndEmbedsToolbar/index.js +0 -159
  222. package/dist/es2019/ui/Resizer/index.js +0 -191
  223. package/dist/es2019/ui/Resizer/styled.js +0 -15
  224. package/dist/es2019/ui/Resizer/types.js +0 -1
  225. package/dist/es2019/ui/Resizer/utils.js +0 -12
  226. package/dist/es2019/utils/filter/privacy-filter.js +0 -47
  227. package/dist/es2019/utils/linking-utils.js +0 -74
  228. package/dist/es2019/utils/rich-media-utils.js +0 -108
  229. package/dist/esm/nodeviews/getInlineNodeViewProducer.js +0 -217
  230. package/dist/esm/plugins/hyperlink/types.js +0 -1
  231. package/dist/esm/ui/MediaAndEmbedsToolbar/index.js +0 -144
  232. package/dist/esm/ui/Resizer/index.js +0 -203
  233. package/dist/esm/ui/Resizer/styled.js +0 -7
  234. package/dist/esm/ui/Resizer/types.js +0 -1
  235. package/dist/esm/ui/Resizer/utils.js +0 -12
  236. package/dist/esm/utils/filter/privacy-filter.js +0 -48
  237. package/dist/esm/utils/linking-utils.js +0 -74
  238. package/dist/esm/utils/rich-media-utils.js +0 -117
  239. package/dist/types/nodeviews/getInlineNodeViewProducer.d.ts +0 -24
  240. package/dist/types/plugins/hyperlink/types.d.ts +0 -35
  241. package/dist/types/ui/MediaAndEmbedsToolbar/index.d.ts +0 -9
  242. package/dist/types/ui/Resizer/index.d.ts +0 -41
  243. package/dist/types/ui/Resizer/styled.d.ts +0 -2
  244. package/dist/types/ui/Resizer/types.d.ts +0 -26
  245. package/dist/types/ui/Resizer/utils.d.ts +0 -6
  246. package/dist/types/utils/filter/privacy-filter.d.ts +0 -9
  247. package/dist/types/utils/linking-utils.d.ts +0 -14
  248. package/dist/types/utils/rich-media-utils.d.ts +0 -8
  249. package/dist/types-ts4.5/nodeviews/getInlineNodeViewProducer.d.ts +0 -24
  250. package/dist/types-ts4.5/plugins/hyperlink/types.d.ts +0 -35
  251. package/dist/types-ts4.5/ui/MediaAndEmbedsToolbar/index.d.ts +0 -9
  252. package/dist/types-ts4.5/ui/Resizer/index.d.ts +0 -41
  253. package/dist/types-ts4.5/ui/Resizer/styled.d.ts +0 -2
  254. package/dist/types-ts4.5/ui/Resizer/types.d.ts +0 -26
  255. package/dist/types-ts4.5/ui/Resizer/utils.d.ts +0 -6
  256. package/dist/types-ts4.5/utils/filter/privacy-filter.d.ts +0 -9
  257. package/dist/types-ts4.5/utils/linking-utils.d.ts +0 -14
  258. package/dist/types-ts4.5/utils/rich-media-utils.d.ts +0 -8
@@ -1,227 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.getInlineNodeViewProducer = getInlineNodeViewProducer;
8
- exports.inlineNodeViewClassname = void 0;
9
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var _react = require("@emotion/react");
11
- var _react2 = _interopRequireDefault(require("react"));
12
- var _utils = require("@atlaskit/editor-common/utils");
13
- var _analytics = require("../plugins/analytics");
14
- var _consts = require("../plugins/analytics/consts");
15
- var _ErrorBoundary = require("../ui/ErrorBoundary");
16
- var _getPerformanceOptions = require("./getPerformanceOptions");
17
- /** @jsx jsx */
18
-
19
- var inlineNodeViewClassname = 'inlineNodeView';
20
- exports.inlineNodeViewClassname = inlineNodeViewClassname;
21
- function createNodeView(_ref) {
22
- var nodeViewParams = _ref.nodeViewParams,
23
- pmPluginFactoryParams = _ref.pmPluginFactoryParams,
24
- Component = _ref.Component,
25
- extraComponentProps = _ref.extraComponentProps;
26
- // We set a variable for the current node which is
27
- // used for comparisions when doing updates, before being
28
- // overwritten to the updated node.
29
- var currentNode = nodeViewParams.node;
30
-
31
- // First we setup the dom element which will be rendered and "tracked" by prosemirror
32
- // and also used as a "editor portal" (not react portal) target by the editor
33
- // portal provider api, for rendering the Component passed.
34
-
35
- var domRef = document.createElement('span');
36
- domRef.contentEditable = 'false';
37
- setDomAttrs(nodeViewParams.node, domRef);
38
-
39
- // @see ED-3790
40
- // something gets messed up during mutation processing inside of a
41
- // nodeView if DOM structure has nested plain "div"s, it doesn't see the
42
- // difference between them and it kills the nodeView
43
- domRef.classList.add("".concat(nodeViewParams.node.type.name, "View-content-wrap"), "".concat(inlineNodeViewClassname));
44
-
45
- // This util is shared for tracking rendering, and the ErrorBoundary that
46
- // is setup to wrap the Component when rendering
47
- // NOTE: This is not a prosemirror dispatch
48
- function dispatchAnalyticsEvent(payload) {
49
- pmPluginFactoryParams.eventDispatcher.emit(_consts.analyticsEventKey, {
50
- payload: payload
51
- });
52
- }
53
-
54
- // This is called to render the Component into domRef which is inside the
55
- // prosemirror View.
56
- // Internally it uses the unstable_renderSubtreeIntoContainer api to render,
57
- // to the passed dom element (domRef) which means it is automatically
58
- // "cleaned up" when you do a "re render".
59
- function renderComponent() {
60
- pmPluginFactoryParams.portalProviderAPI.render(getPortalChildren({
61
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
62
- currentNode: currentNode,
63
- nodeViewParams: nodeViewParams,
64
- Component: Component,
65
- extraComponentProps: extraComponentProps
66
- }), domRef, false,
67
- // node views should be rendered with intl context
68
- true);
69
- }
70
- var _getPerformanceOption = (0, _getPerformanceOptions.getPerformanceOptions)(nodeViewParams.view),
71
- samplingRate = _getPerformanceOption.samplingRate,
72
- slowThreshold = _getPerformanceOption.slowThreshold,
73
- trackingEnabled = _getPerformanceOption.trackingEnabled;
74
- trackingEnabled && (0, _getPerformanceOptions.startMeasureReactNodeViewRendered)({
75
- nodeTypeName: currentNode.type.name
76
- });
77
-
78
- // We render the component while creating the node view
79
- renderComponent();
80
- trackingEnabled && (0, _getPerformanceOptions.stopMeasureReactNodeViewRendered)({
81
- nodeTypeName: currentNode.type.name,
82
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
83
- editorState: nodeViewParams.view.state,
84
- samplingRate: samplingRate,
85
- slowThreshold: slowThreshold
86
- });
87
-
88
- // https://prosemirror.net/docs/ref/#view.NodeView
89
- var nodeView = {
90
- get dom() {
91
- return domRef;
92
- },
93
- update: function update(nextNode, _decorations) {
94
- // Let ProseMirror handle the update if node types are different.
95
- // This prevents an issue where it was not possible to select the
96
- // inline node view then replace it by entering text - the node
97
- // view contents would be deleted but the node view itself would
98
- // stay in the view and become uneditable.
99
- if (currentNode.type !== nextNode.type) {
100
- return false;
101
- }
102
- // On updates, we only set the new attributes if the type, attributes, and marks
103
- // have changed on the node.
104
-
105
- // NOTE: this could mean attrs changes aren't reflected in the dom,
106
- // when an attribute key which was previously present is no longer
107
- // present.
108
- // ie.
109
- // -> Original attributes { text: "hello world", color: "red" }
110
- // -> Updated attributes { color: "blue" }
111
- // in this case, the dom text attribute will not be cleared.
112
- //
113
- // This may not be an issue with any of our current node schemas.
114
- if (!currentNode.sameMarkup(nextNode)) {
115
- setDomAttrs(nextNode, domRef);
116
- }
117
- currentNode = nextNode;
118
- renderComponent();
119
- return true;
120
- },
121
- destroy: function destroy() {
122
- // When prosemirror destroys the node view, we need to clean up
123
- // what we have previously rendered using the editor portal
124
- // provider api.
125
- pmPluginFactoryParams.portalProviderAPI.remove(domRef);
126
- // @ts-expect-error Expect an error as domRef is expected to be
127
- // of HTMLSpanElement type however once the node view has
128
- // been destroyed no other consumers should still be using it.
129
- domRef = undefined;
130
- }
131
- };
132
- return nodeView;
133
- }
134
-
135
- /**
136
- * Copies the attributes from a ProseMirror Node to a DOM node.
137
- * @param node The Prosemirror Node from which to source the attributes
138
- */
139
- function setDomAttrs(node, element) {
140
- Object.keys(node.attrs || {}).forEach(function (attr) {
141
- element.setAttribute(attr, node.attrs[attr]);
142
- });
143
- }
144
- function getPortalChildren(_ref2) {
145
- var dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
146
- currentNode = _ref2.currentNode,
147
- nodeViewParams = _ref2.nodeViewParams,
148
- Component = _ref2.Component,
149
- extraComponentProps = _ref2.extraComponentProps;
150
- return function portalChildren() {
151
- var _currentNode$type$nam, _currentNode$type;
152
- // All inline nodes use `display: inline` to allow for multi-line
153
- // wrapping. This does produce an issue in Chrome where it is not
154
- // possible to click select the position after the node,
155
- // see: https://product-fabric.atlassian.net/browse/ED-12003
156
- // however this is only a problem for node views that use
157
- // `display: inline-block` somewhere within the Component.
158
- // Looking at the below structure, spans with className
159
- // `inlineNodeViewAddZeroWidthSpace` have pseudo elements that
160
- // add a zero width space which fixes the problem.
161
- // Without the additional zero width space before the Component,
162
- // it is not possible to use the keyboard to range select in Safari.
163
- //
164
- // Zero width spaces on either side of the Component also prevent
165
- // the cursor from appearing inside the node view on all browsers.
166
- //
167
- // Note:
168
- // In future it is worth considering prohibiting the use of `display: inline-block`
169
- // within inline node view Components however would require a sizable
170
- // refactor. A test suite to catch any instances of this is ideal however
171
- // the refactor required is currently out of scope for https://product-fabric.atlassian.net/browse/ED-14176
172
-
173
- return (0, _react.jsx)(_ErrorBoundary.ErrorBoundary, {
174
- component: _analytics.ACTION_SUBJECT.REACT_NODE_VIEW,
175
- componentId: (_currentNode$type$nam = currentNode === null || currentNode === void 0 ? void 0 : (_currentNode$type = currentNode.type) === null || _currentNode$type === void 0 ? void 0 : _currentNode$type.name) !== null && _currentNode$type$nam !== void 0 ? _currentNode$type$nam : _analytics.ACTION_SUBJECT_ID.UNKNOWN_NODE,
176
- dispatchAnalyticsEvent: dispatchAnalyticsEvent
177
- }, (0, _react.jsx)("span", {
178
- "aria-hidden": "true",
179
- className: "zeroWidthSpaceContainer"
180
- }, (0, _react.jsx)("span", {
181
- className: "".concat(inlineNodeViewClassname, "AddZeroWidthSpace")
182
- }), _utils.ZERO_WIDTH_SPACE), (0, _react.jsx)(Component, (0, _extends2.default)({
183
- view: nodeViewParams.view,
184
- getPos: nodeViewParams.getPos,
185
- node: currentNode
186
- }, extraComponentProps)), (0, _react.jsx)("span", {
187
- "aria-hidden": "true",
188
- className: "".concat(inlineNodeViewClassname, "AddZeroWidthSpace")
189
- }));
190
- };
191
- }
192
-
193
- // https://prosemirror.net/docs/ref/#view.EditorProps.nodeViews
194
- // The prosemirror EditorProps has a nodeViews key which has the rough shape:
195
- // type nodeViews: {
196
- // [nodeViewName: string]: (node, editorView, getPos, decorations, innerDecorations) => NodeView
197
- // }
198
- // So the value of the keys on the nodeViews object, are a function which should return a NodeView.
199
- // The following type NodeViewProducer, refers to these functions which return a NodeView.
200
- //
201
- // So the above type could also be described as
202
- // type NodeViewProducer = (node, editorView, getPos, decorations, innerDecorations) => NodeView
203
- // nodeViews: {
204
- // [nodeViewName: string]: NodeViewProducer
205
- // }
206
- // This return of this function is intended to be the value of a key
207
- // in a ProseMirror nodeViews object.
208
- function getInlineNodeViewProducer(_ref3) {
209
- var pmPluginFactoryParams = _ref3.pmPluginFactoryParams,
210
- Component = _ref3.Component,
211
- extraComponentProps = _ref3.extraComponentProps;
212
- function nodeViewProducer() {
213
- var nodeView = createNodeView({
214
- nodeViewParams: {
215
- node: arguments.length <= 0 ? undefined : arguments[0],
216
- view: arguments.length <= 1 ? undefined : arguments[1],
217
- getPos: arguments.length <= 2 ? undefined : arguments[2],
218
- decorations: arguments.length <= 3 ? undefined : arguments[3]
219
- },
220
- pmPluginFactoryParams: pmPluginFactoryParams,
221
- Component: Component,
222
- extraComponentProps: extraComponentProps
223
- });
224
- return nodeView;
225
- }
226
- return nodeViewProducer;
227
- }
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,152 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
- var _prosemirrorState = require("prosemirror-state");
10
- var _prosemirrorUtils = require("prosemirror-utils");
11
- var _messages = _interopRequireDefault(require("../../messages"));
12
- var _mediaWrapLeft = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/media-wrap-left"));
13
- var _mediaWrapRight = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/media-wrap-right"));
14
- var _mediaWide = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/media-wide"));
15
- var _mediaFullWidth = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/media-full-width"));
16
- var _alignImageLeft = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/align-image-left"));
17
- var _alignImageRight = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/align-image-right"));
18
- var _alignImageCenter = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/align-image-center"));
19
- var _richMediaUtils = require("../../utils/rich-media-utils");
20
- var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
21
- var _utils = require("../../plugins/analytics/utils");
22
- var _analytics = require("../../plugins/analytics");
23
- var _toolbarMessages = require("./toolbar-messages");
24
- var _utils2 = require("../../utils");
25
- var alignmentIcons = [{
26
- id: 'editor.media.alignLeft',
27
- value: 'align-start',
28
- icon: _alignImageLeft.default
29
- }, {
30
- id: 'editor.media.alignCenter',
31
- value: 'center',
32
- icon: _alignImageCenter.default
33
- }, {
34
- id: 'editor.media.alignRight',
35
- value: 'align-end',
36
- icon: _alignImageRight.default
37
- }];
38
- var wrappingIcons = [{
39
- id: 'editor.media.wrapLeft',
40
- value: 'wrap-left',
41
- icon: _mediaWrapLeft.default
42
- }, {
43
- id: 'editor.media.wrapRight',
44
- value: 'wrap-right',
45
- icon: _mediaWrapRight.default
46
- }];
47
- var breakoutIcons = [{
48
- value: 'wide',
49
- icon: _mediaWide.default
50
- }, {
51
- value: 'full-width',
52
- icon: _mediaFullWidth.default
53
- }];
54
- var layoutToMessages = {
55
- 'wrap-left': _toolbarMessages.toolbarMessages.wrapLeft,
56
- center: _messages.default.alignImageCenter,
57
- 'wrap-right': _toolbarMessages.toolbarMessages.wrapRight,
58
- wide: _messages.default.layoutWide,
59
- 'full-width': _messages.default.layoutFullWidth,
60
- 'align-end': _messages.default.alignImageRight,
61
- 'align-start': _messages.default.alignImageLeft
62
- };
63
- var getNodeWidth = function getNodeWidth(node, schema) {
64
- var embedCard = schema.nodes.embedCard;
65
- if (node.type === embedCard) {
66
- return node.attrs.originalWidth || _editorSharedStyles.DEFAULT_EMBED_CARD_WIDTH;
67
- }
68
- return node.firstChild && node.firstChild.attrs.width || node.attrs.width;
69
- };
70
- var makeAlign = function makeAlign(layout, nodeType, widthPluginDependencyApi) {
71
- return function (state, dispatch) {
72
- var _ref = state.selection,
73
- node = _ref.node;
74
- var previousLayoutType = node.attrs.layout;
75
- var mediaSingle = state.schema.nodes.mediaSingle;
76
- if (!dispatch) {
77
- return false;
78
- }
79
- var widthPluginState = widthPluginDependencyApi === null || widthPluginDependencyApi === void 0 ? void 0 : widthPluginDependencyApi.sharedState.currentState();
80
- if (!node || node.type !== nodeType || !widthPluginState) {
81
- return false;
82
- }
83
- var nodeWidth = getNodeWidth(node, state.schema);
84
- var newAttrs = (0, _richMediaUtils.alignAttributes)(layout, node.attrs, undefined, nodeWidth, widthPluginState.lineLength);
85
- var tr = state.tr.setNodeMarkup(state.selection.from, undefined, newAttrs);
86
- tr.setMeta('scrollIntoView', false);
87
- // when image captions are enabled, the wrong node gets selected after
88
- // setNodeMarkup is called
89
- tr.setSelection(_prosemirrorState.NodeSelection.create(tr.doc, state.selection.from));
90
- var paragraph = tr.doc.type.schema.nodes.paragraph;
91
-
92
- // see https://product-fabric.atlassian.net/browse/ED-15518 insert a new paragraph when an embedded card is wrapped left or right
93
- if (layout.startsWith('wrap') && paragraph && !tr.doc.nodeAt(state.selection.to) && ((0, _utils2.insideTable)(state) || (0, _utils2.isInLayoutColumn)(state))) {
94
- tr.insert(state.selection.to, paragraph.createAndFill());
95
- }
96
- dispatch((0, _utils.addAnalytics)(state, tr, {
97
- eventType: _analytics.EVENT_TYPE.TRACK,
98
- action: _analytics.ACTION.SELECTED,
99
- actionSubject: _analytics.ACTION_SUBJECT[node.type === mediaSingle ? 'MEDIA_SINGLE' : 'EMBEDS'],
100
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.RICH_MEDIA_LAYOUT,
101
- attributes: {
102
- previousLayoutType: previousLayoutType,
103
- currentLayoutType: layout
104
- }
105
- }));
106
- return true;
107
- };
108
- };
109
- var mapIconsToToolbarItem = function mapIconsToToolbarItem(icons, layout, intl, nodeType, widthPluginDependencyApi) {
110
- return icons.map(function (toolbarItem) {
111
- var id = toolbarItem.id,
112
- value = toolbarItem.value;
113
- return {
114
- id: id,
115
- type: 'button',
116
- icon: toolbarItem.icon,
117
- title: intl.formatMessage(layoutToMessages[value]),
118
- selected: layout === value,
119
- onClick: makeAlign(value, nodeType, widthPluginDependencyApi)
120
- };
121
- });
122
- };
123
- var shouldHideLayoutToolbar = function shouldHideLayoutToolbar(selection, _ref2, allowResizingInTables) {
124
- var nodes = _ref2.nodes;
125
- return (0, _prosemirrorUtils.hasParentNodeOfType)([nodes.bodiedExtension, nodes.listItem, nodes.expand, nodes.nestedExpand].concat((0, _toConsumableArray2.default)(allowResizingInTables ? [] : [nodes.table])).filter(Boolean))(selection);
126
- };
127
- var buildLayoutButtons = function buildLayoutButtons(state, intl, nodeType, widthPluginDependencyApi, allowResizing, allowResizingInTables) {
128
- var allowWrapping = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : true;
129
- var allowAlignment = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : true;
130
- var selection = state.selection;
131
- if (!(selection instanceof _prosemirrorState.NodeSelection) || !selection.node || !nodeType || shouldHideLayoutToolbar(selection, state.schema, allowResizingInTables)) {
132
- return [];
133
- }
134
- var layout = selection.node.attrs.layout;
135
- var alignmentToolbarItems = allowAlignment ? mapIconsToToolbarItem(alignmentIcons, layout, intl, nodeType, widthPluginDependencyApi) : [];
136
- var wrappingToolbarItems = allowWrapping ? mapIconsToToolbarItem(wrappingIcons, layout, intl, nodeType, widthPluginDependencyApi) : [];
137
- var breakOutToolbarItems = !allowResizing ? mapIconsToToolbarItem(breakoutIcons, layout, intl, nodeType, widthPluginDependencyApi) : [];
138
- var items = [].concat((0, _toConsumableArray2.default)(alignmentToolbarItems), (0, _toConsumableArray2.default)(getSeparatorBetweenAlignmentAndWrapping(allowAlignment, allowWrapping)), (0, _toConsumableArray2.default)(wrappingToolbarItems), (0, _toConsumableArray2.default)(getSeparatorBeforeBreakoutItems(allowAlignment, allowWrapping, allowResizing)), (0, _toConsumableArray2.default)(breakOutToolbarItems));
139
- return items;
140
- };
141
- var getSeparatorBetweenAlignmentAndWrapping = function getSeparatorBetweenAlignmentAndWrapping(allowAlignment, allowWrapping) {
142
- return allowAlignment && allowWrapping ? [{
143
- type: 'separator'
144
- }] : [];
145
- };
146
- var getSeparatorBeforeBreakoutItems = function getSeparatorBeforeBreakoutItems(allowAlignment, allowWrapping, allowResizing) {
147
- return !allowResizing && (allowAlignment || allowWrapping) ? [{
148
- type: 'separator'
149
- }] : [];
150
- };
151
- var _default = buildLayoutButtons;
152
- exports.default = _default;
@@ -1,210 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
- var _react = _interopRequireDefault(require("react"));
16
- var _classnames = _interopRequireDefault(require("classnames"));
17
- var _reResizable = require("re-resizable");
18
- var _utils = require("@atlaskit/editor-common/utils");
19
- var _utils2 = require("./utils");
20
- var _styles = require("@atlaskit/editor-common/styles");
21
- var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
22
- var _analytics = require("../../plugins/analytics");
23
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
24
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
25
- var getResizeAnalyticsEvent = function getResizeAnalyticsEvent(type, size, layout) {
26
- var actionSubject = type === 'embed' ? _analytics.ACTION_SUBJECT.EMBEDS : _analytics.ACTION_SUBJECT.MEDIA_SINGLE;
27
- return {
28
- action: _analytics.ACTION.EDITED,
29
- actionSubject: actionSubject,
30
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.RESIZED,
31
- attributes: {
32
- size: size,
33
- layout: layout
34
- },
35
- eventType: _analytics.EVENT_TYPE.UI
36
- };
37
- };
38
- var getWidthFromSnapPoints = function getWidthFromSnapPoints(width, snapPoints) {
39
- if (snapPoints.length) {
40
- return Math.min(Math.max(width, snapPoints[0]), snapPoints[snapPoints.length - 1]);
41
- }
42
- return width;
43
- };
44
- var Resizer = /*#__PURE__*/function (_React$Component) {
45
- (0, _inherits2.default)(Resizer, _React$Component);
46
- var _super = _createSuper(Resizer);
47
- function Resizer() {
48
- var _this;
49
- (0, _classCallCheck2.default)(this, Resizer);
50
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
51
- args[_key] = arguments[_key];
52
- }
53
- _this = _super.call.apply(_super, [this].concat(args));
54
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resizable", /*#__PURE__*/_react.default.createRef());
55
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
56
- isResizing: false
57
- });
58
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResizeStart", function (event) {
59
- var _this$props = _this.props,
60
- _this$props$innerPadd = _this$props.innerPadding,
61
- innerPadding = _this$props$innerPadd === void 0 ? 0 : _this$props$innerPadd,
62
- highlights = _this$props.highlights,
63
- displayGrid = _this$props.displayGrid,
64
- layout = _this$props.layout,
65
- width = _this$props.width,
66
- snapPoints = _this$props.snapPoints;
67
-
68
- // prevent creating a drag event on Firefox
69
- event.preventDefault();
70
- _this.setState({
71
- isResizing: true
72
- }, function () {
73
- var newHighlights = highlights(width + innerPadding, snapPoints);
74
- displayGrid === null || displayGrid === void 0 ? void 0 : displayGrid(newHighlights.length > 0, (0, _utils.gridTypeForLayout)(layout), newHighlights);
75
- });
76
- });
77
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResize", function (_event, _direction, _elementRef, delta) {
78
- var _this$props2 = _this.props,
79
- highlights = _this$props2.highlights,
80
- calcNewSize = _this$props2.calcNewSize,
81
- scaleFactor = _this$props2.scaleFactor,
82
- snapPoints = _this$props2.snapPoints,
83
- displayGrid = _this$props2.displayGrid,
84
- layout = _this$props2.layout,
85
- updateSize = _this$props2.updateSize,
86
- _this$props2$innerPad = _this$props2.innerPadding,
87
- innerPadding = _this$props2$innerPad === void 0 ? 0 : _this$props2$innerPad;
88
- var resizable = _this.resizable.current;
89
- var isResizing = _this.state.isResizing;
90
- if (!resizable || !resizable.state.original || !isResizing) {
91
- return;
92
- }
93
- var newWidth = getWidthFromSnapPoints(resizable.state.original.width + delta.width * (scaleFactor || 1), snapPoints);
94
- var newSize = calcNewSize(newWidth + innerPadding, false);
95
- if (newSize.layout !== layout) {
96
- updateSize(newSize.width, newSize.layout);
97
- }
98
- var newHighlights = highlights(newWidth, snapPoints);
99
- displayGrid === null || displayGrid === void 0 ? void 0 : displayGrid(newHighlights.length > 0, (0, _utils.gridTypeForLayout)(newSize.layout), newHighlights);
100
- resizable.updateSize({
101
- width: newWidth,
102
- height: 'auto'
103
- });
104
- resizable.setState({
105
- isResizing: true
106
- });
107
- });
108
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResizeStop", function (_event, _direction, _elementRef, delta) {
109
- var _this$props3 = _this.props,
110
- highlights = _this$props3.highlights,
111
- calcNewSize = _this$props3.calcNewSize,
112
- snapPoints = _this$props3.snapPoints,
113
- displayGrid = _this$props3.displayGrid,
114
- layout = _this$props3.layout,
115
- updateSize = _this$props3.updateSize,
116
- dispatchAnalyticsEvent = _this$props3.dispatchAnalyticsEvent,
117
- nodeType = _this$props3.nodeType;
118
- var resizable = _this.resizable.current;
119
- var isResizing = _this.state.isResizing;
120
- if (!resizable || !resizable.state.original || !isResizing) {
121
- return;
122
- }
123
- var newWidth = getWidthFromSnapPoints(resizable.state.original.width + delta.width, snapPoints);
124
- var snapWidth = (0, _utils2.snapTo)(newWidth, snapPoints);
125
- var newSize = calcNewSize(snapWidth, true);
126
- var newHighlights = highlights(newWidth, snapPoints);
127
- if (dispatchAnalyticsEvent) {
128
- dispatchAnalyticsEvent(getResizeAnalyticsEvent(nodeType, newSize.width, newSize.layout));
129
- }
130
- // show committed grid size
131
- displayGrid === null || displayGrid === void 0 ? void 0 : displayGrid(newHighlights.length > 0, (0, _utils.gridTypeForLayout)(newSize.layout), newHighlights);
132
- _this.setState({
133
- isResizing: false
134
- }, function () {
135
- updateSize(newSize.width, newSize.layout);
136
- displayGrid === null || displayGrid === void 0 ? void 0 : displayGrid(false, (0, _utils.gridTypeForLayout)(layout), []);
137
- });
138
- });
139
- return _this;
140
- }
141
- (0, _createClass2.default)(Resizer, [{
142
- key: "render",
143
- value: function render() {
144
- var handleStyles = {};
145
- var handles = {};
146
- var handleComponent = {};
147
- var _this$props4 = this.props,
148
- _this$props4$innerPad = _this$props4.innerPadding,
149
- innerPadding = _this$props4$innerPad === void 0 ? 0 : _this$props4$innerPad,
150
- width = _this$props4.width,
151
- pctWidth = _this$props4.pctWidth,
152
- selected = _this$props4.selected,
153
- layout = _this$props4.layout,
154
- enable = _this$props4.enable,
155
- children = _this$props4.children,
156
- ratio = _this$props4.ratio,
157
- handleComponentFunc = _this$props4.handleComponentFunc;
158
- var isResizing = this.state.isResizing;
159
- _utils2.handleSides.forEach(function (side) {
160
- var _handleStyles$side;
161
- handles[side] = "richMedia-resize-handle-".concat(side);
162
- handleStyles[side] = (_handleStyles$side = {
163
- width: '24px'
164
- }, (0, _defineProperty2.default)(_handleStyles$side, side, "".concat(-13 - innerPadding, "px")), (0, _defineProperty2.default)(_handleStyles$side, "zIndex", _editorSharedStyles.akRichMediaResizeZIndex), (0, _defineProperty2.default)(_handleStyles$side, "pointerEvents", 'auto'), _handleStyles$side);
165
- var sideHandleComponent = handleComponentFunc && handleComponentFunc(side);
166
- if (sideHandleComponent) {
167
- handleComponent[side] = sideHandleComponent;
168
- }
169
- });
170
- var className = (0, _classnames.default)(_styles.richMediaClassName, "image-".concat(layout), this.props.className, {
171
- 'is-resizing': isResizing,
172
- 'not-resized': !pctWidth,
173
- 'richMedia-selected': selected,
174
- 'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
175
- });
176
- var handleWrapperStyle;
177
- if (ratio) {
178
- handleWrapperStyle = {
179
- position: 'absolute',
180
- width: '100%',
181
- paddingBottom: "".concat(ratio, "%"),
182
- top: 0,
183
- pointerEvents: 'none'
184
- };
185
- }
186
-
187
- // Ideally, Resizable would let you pass in the component rather than
188
- // the div. For now, we just apply the same styles using CSS
189
- return /*#__PURE__*/_react.default.createElement(_reResizable.Resizable, {
190
- ref: this.resizable,
191
- size: {
192
- width: width,
193
- // just content itself (no paddings)
194
- height: 'auto'
195
- },
196
- className: className,
197
- handleClasses: handles,
198
- handleStyles: handleStyles,
199
- handleWrapperStyle: handleWrapperStyle,
200
- handleComponent: handleComponent,
201
- enable: enable,
202
- onResize: this.handleResize,
203
- onResizeStop: this.handleResizeStop,
204
- onResizeStart: this.handleResizeStart
205
- }, children);
206
- }
207
- }]);
208
- return Resizer;
209
- }(_react.default.Component);
210
- exports.default = Resizer;
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.wrapperStyle = void 0;
8
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
- var _react = require("@emotion/react");
10
- var _ui = require("@atlaskit/editor-common/ui");
11
- var _templateObject;
12
- var wrapperStyle = function wrapperStyle(props) {
13
- return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n & > div {\n ", ";\n position: relative;\n clear: both;\n\n > div {\n position: absolute;\n height: 100%;\n width: 100%;\n }\n }\n"])), (0, _ui.MediaSingleDimensionHelper)(props));
14
- };
15
- exports.wrapperStyle = wrapperStyle;
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.snapTo = exports.imageAlignmentMap = exports.handleSides = void 0;
7
- var snapTo = function snapTo(target, points) {
8
- return points.length === 0 ?
9
- // extreme last case if there are no points somehow
10
- target : points.reduce(function (point, closest) {
11
- return Math.abs(closest - target) < Math.abs(point - target) ? closest : point;
12
- });
13
- };
14
- exports.snapTo = snapTo;
15
- var handleSides = ['left', 'right'];
16
- exports.handleSides = handleSides;
17
- var imageAlignmentMap = {
18
- left: 'start',
19
- right: 'end'
20
- };
21
- exports.imageAlignmentMap = imageAlignmentMap;