@atlaskit/editor-core 185.2.0 → 185.2.2

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