@atlaskit/editor-core 150.0.1 → 151.1.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 (248) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/dist/cjs/actions/index.js +5 -23
  3. package/dist/cjs/create-editor/ErrorBoundary.js +113 -79
  4. package/dist/cjs/create-editor/ReactEditorView.js +145 -31
  5. package/dist/cjs/create-editor/create-plugins-list.js +8 -2
  6. package/dist/cjs/editor.js +101 -40
  7. package/dist/cjs/labs/next/presets/cxhtml.js +2 -1
  8. package/dist/cjs/plugins/analytics/types/enums.js +3 -1
  9. package/dist/cjs/plugins/base/index.js +4 -3
  10. package/dist/cjs/plugins/base/pm-plugins/frozen-editor.js +66 -36
  11. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +3 -1
  12. package/dist/cjs/plugins/card/index.js +13 -2
  13. package/dist/cjs/plugins/card/nodeviews/embedCard.js +1 -0
  14. package/dist/cjs/plugins/card/pm-plugins/main.js +7 -2
  15. package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +10 -3
  16. package/dist/cjs/plugins/code-bidi-warning/index.js +25 -0
  17. package/dist/cjs/plugins/code-bidi-warning/plugin-key.js +11 -0
  18. package/dist/cjs/plugins/code-bidi-warning/pm-plugins/main.js +43 -0
  19. package/dist/cjs/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +118 -0
  20. package/dist/cjs/plugins/code-bidi-warning/pm-plugins/reducer.js +12 -0
  21. package/dist/cjs/plugins/code-bidi-warning/pm-plugins/types.js +5 -0
  22. package/dist/cjs/plugins/code-block/index.js +10 -6
  23. package/dist/cjs/plugins/code-block/nodeviews/highlighting-code-block.js +16 -5
  24. package/dist/cjs/plugins/code-block/pm-plugins/main.js +12 -3
  25. package/dist/cjs/plugins/code-block/toolbar.js +1 -1
  26. package/dist/cjs/plugins/collab-edit/ui/to-avatar.js +4 -8
  27. package/dist/cjs/plugins/emoji/styles.js +1 -1
  28. package/dist/cjs/plugins/extension/pm-plugins/main.js +1 -4
  29. package/dist/cjs/plugins/extension/toolbar.js +28 -23
  30. package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +9 -3
  31. package/dist/cjs/plugins/find-replace/ui/Find.js +27 -7
  32. package/dist/cjs/plugins/hyperlink/pm-plugins/keymap.js +3 -3
  33. package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
  34. package/dist/cjs/plugins/hyperlink/utils.js +6 -69
  35. package/dist/cjs/plugins/index.js +8 -0
  36. package/dist/cjs/plugins/media/index.js +14 -3
  37. package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +24 -10
  38. package/dist/cjs/plugins/media/nodeviews/mediaInline.js +179 -0
  39. package/dist/cjs/plugins/media/pm-plugins/main.js +18 -9
  40. package/dist/cjs/plugins/media/toolbar/index.js +49 -17
  41. package/dist/cjs/plugins/media/toolbar/utils.js +20 -2
  42. package/dist/cjs/plugins/media/utils/media-files.js +67 -1
  43. package/dist/cjs/plugins/mentions/type-ahead/index.js +39 -3
  44. package/dist/cjs/plugins/panel/index.js +2 -3
  45. package/dist/cjs/plugins/panel/message.js +47 -0
  46. package/dist/cjs/plugins/panel/toolbar.js +64 -84
  47. package/dist/cjs/plugins/panel/utils.js +2 -2
  48. package/dist/cjs/plugins/paste/linkify-md-plugin.js +3 -3
  49. package/dist/cjs/plugins/rank.js +1 -1
  50. package/dist/cjs/plugins/status/styles.js +1 -1
  51. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
  52. package/dist/cjs/profiler/render-count.js +82 -0
  53. package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -5
  54. package/dist/cjs/utils/react-hooks/use-component-renderer-tracking/index.js +55 -19
  55. package/dist/cjs/version-wrapper.js +1 -1
  56. package/dist/cjs/version.json +1 -1
  57. package/dist/es2019/actions/index.js +6 -28
  58. package/dist/es2019/create-editor/ErrorBoundary.js +73 -60
  59. package/dist/es2019/create-editor/ReactEditorView.js +130 -23
  60. package/dist/es2019/create-editor/create-plugins-list.js +9 -3
  61. package/dist/es2019/editor.js +74 -35
  62. package/dist/es2019/labs/next/presets/cxhtml.js +2 -1
  63. package/dist/es2019/plugins/analytics/types/enums.js +3 -1
  64. package/dist/es2019/plugins/base/index.js +4 -3
  65. package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +63 -35
  66. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +2 -1
  67. package/dist/es2019/plugins/card/index.js +7 -2
  68. package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -0
  69. package/dist/es2019/plugins/card/pm-plugins/main.js +9 -2
  70. package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +12 -5
  71. package/dist/es2019/plugins/code-bidi-warning/index.js +15 -0
  72. package/dist/es2019/plugins/code-bidi-warning/plugin-key.js +2 -0
  73. package/dist/es2019/plugins/code-bidi-warning/pm-plugins/main.js +31 -0
  74. package/dist/es2019/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +88 -0
  75. package/dist/es2019/plugins/code-bidi-warning/pm-plugins/reducer.js +3 -0
  76. package/dist/es2019/plugins/code-bidi-warning/pm-plugins/types.js +1 -0
  77. package/dist/es2019/plugins/code-block/index.js +6 -1
  78. package/dist/es2019/plugins/code-block/nodeviews/highlighting-code-block.js +16 -4
  79. package/dist/es2019/plugins/code-block/pm-plugins/main.js +50 -39
  80. package/dist/es2019/plugins/code-block/toolbar.js +1 -1
  81. package/dist/es2019/plugins/collab-edit/ui/to-avatar.js +2 -6
  82. package/dist/es2019/plugins/emoji/styles.js +2 -0
  83. package/dist/es2019/plugins/extension/pm-plugins/main.js +1 -4
  84. package/dist/es2019/plugins/extension/toolbar.js +30 -25
  85. package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +9 -4
  86. package/dist/es2019/plugins/find-replace/ui/Find.js +27 -6
  87. package/dist/es2019/plugins/hyperlink/pm-plugins/keymap.js +1 -1
  88. package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
  89. package/dist/es2019/plugins/hyperlink/utils.js +3 -59
  90. package/dist/es2019/plugins/index.js +2 -1
  91. package/dist/es2019/plugins/media/index.js +13 -4
  92. package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +16 -7
  93. package/dist/es2019/plugins/media/nodeviews/mediaInline.js +88 -0
  94. package/dist/es2019/plugins/media/pm-plugins/main.js +20 -11
  95. package/dist/es2019/plugins/media/toolbar/index.js +44 -15
  96. package/dist/es2019/plugins/media/toolbar/utils.js +16 -0
  97. package/dist/es2019/plugins/media/utils/media-files.js +68 -2
  98. package/dist/es2019/plugins/mentions/type-ahead/index.js +21 -2
  99. package/dist/es2019/plugins/panel/index.js +3 -4
  100. package/dist/es2019/plugins/panel/message.js +38 -0
  101. package/dist/es2019/plugins/panel/toolbar.js +52 -71
  102. package/dist/es2019/plugins/panel/utils.js +2 -2
  103. package/dist/es2019/plugins/paste/linkify-md-plugin.js +2 -2
  104. package/dist/es2019/plugins/rank.js +1 -1
  105. package/dist/es2019/plugins/status/styles.js +2 -0
  106. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
  107. package/dist/es2019/profiler/render-count.js +60 -0
  108. package/dist/es2019/ui/Appearance/Comment/Comment.js +4 -2
  109. package/dist/es2019/utils/react-hooks/use-component-renderer-tracking/index.js +51 -18
  110. package/dist/es2019/version-wrapper.js +1 -1
  111. package/dist/es2019/version.json +1 -1
  112. package/dist/esm/actions/index.js +6 -24
  113. package/dist/esm/create-editor/ErrorBoundary.js +113 -78
  114. package/dist/esm/create-editor/ReactEditorView.js +146 -31
  115. package/dist/esm/create-editor/create-plugins-list.js +9 -3
  116. package/dist/esm/editor.js +100 -40
  117. package/dist/esm/labs/next/presets/cxhtml.js +2 -1
  118. package/dist/esm/plugins/analytics/types/enums.js +3 -1
  119. package/dist/esm/plugins/base/index.js +4 -3
  120. package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +64 -36
  121. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +3 -1
  122. package/dist/esm/plugins/card/index.js +13 -2
  123. package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -0
  124. package/dist/esm/plugins/card/pm-plugins/main.js +7 -2
  125. package/dist/esm/plugins/card/pm-plugins/util/resolve.js +12 -5
  126. package/dist/esm/plugins/code-bidi-warning/index.js +17 -0
  127. package/dist/esm/plugins/code-bidi-warning/plugin-key.js +2 -0
  128. package/dist/esm/plugins/code-bidi-warning/pm-plugins/main.js +30 -0
  129. package/dist/esm/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +96 -0
  130. package/dist/esm/plugins/code-bidi-warning/pm-plugins/reducer.js +3 -0
  131. package/dist/esm/plugins/code-bidi-warning/pm-plugins/types.js +1 -0
  132. package/dist/esm/plugins/code-block/index.js +10 -6
  133. package/dist/esm/plugins/code-block/nodeviews/highlighting-code-block.js +16 -5
  134. package/dist/esm/plugins/code-block/pm-plugins/main.js +11 -3
  135. package/dist/esm/plugins/code-block/toolbar.js +1 -1
  136. package/dist/esm/plugins/collab-edit/ui/to-avatar.js +4 -8
  137. package/dist/esm/plugins/emoji/styles.js +1 -1
  138. package/dist/esm/plugins/extension/pm-plugins/main.js +1 -4
  139. package/dist/esm/plugins/extension/toolbar.js +28 -23
  140. package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +9 -4
  141. package/dist/esm/plugins/find-replace/ui/Find.js +27 -7
  142. package/dist/esm/plugins/hyperlink/pm-plugins/keymap.js +1 -1
  143. package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
  144. package/dist/esm/plugins/hyperlink/utils.js +3 -59
  145. package/dist/esm/plugins/index.js +2 -1
  146. package/dist/esm/plugins/media/index.js +14 -4
  147. package/dist/esm/plugins/media/nodeviews/mediaGroup.js +24 -10
  148. package/dist/esm/plugins/media/nodeviews/mediaInline.js +147 -0
  149. package/dist/esm/plugins/media/pm-plugins/main.js +19 -11
  150. package/dist/esm/plugins/media/toolbar/index.js +47 -19
  151. package/dist/esm/plugins/media/toolbar/utils.js +15 -1
  152. package/dist/esm/plugins/media/utils/media-files.js +60 -2
  153. package/dist/esm/plugins/mentions/type-ahead/index.js +39 -3
  154. package/dist/esm/plugins/panel/index.js +3 -4
  155. package/dist/esm/plugins/panel/message.js +38 -0
  156. package/dist/esm/plugins/panel/toolbar.js +57 -77
  157. package/dist/esm/plugins/panel/utils.js +2 -2
  158. package/dist/esm/plugins/paste/linkify-md-plugin.js +2 -2
  159. package/dist/esm/plugins/rank.js +1 -1
  160. package/dist/esm/plugins/status/styles.js +1 -1
  161. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
  162. package/dist/esm/profiler/render-count.js +57 -0
  163. package/dist/esm/ui/Appearance/Comment/Comment.js +6 -5
  164. package/dist/esm/utils/react-hooks/use-component-renderer-tracking/index.js +53 -20
  165. package/dist/esm/version-wrapper.js +1 -1
  166. package/dist/esm/version.json +1 -1
  167. package/dist/types/create-editor/ErrorBoundary.d.ts +6 -6
  168. package/dist/types/create-editor/ReactEditorView.d.ts +15 -3
  169. package/dist/types/editor.d.ts +3 -1
  170. package/dist/types/plugins/analytics/analytics-queue.d.ts +1 -1
  171. package/dist/types/plugins/analytics/index.d.ts +1 -1
  172. package/dist/types/plugins/analytics/types/enums.d.ts +4 -2
  173. package/dist/types/plugins/analytics/types/events.d.ts +7 -2
  174. package/dist/types/plugins/analytics/types/general-events.d.ts +4 -1
  175. package/dist/types/plugins/analytics/types/index.d.ts +1 -1
  176. package/dist/types/plugins/analytics/types/insert-events.d.ts +6 -1
  177. package/dist/types/plugins/analytics/types/link-tool-bar-events.d.ts +1 -0
  178. package/dist/types/plugins/base/index.d.ts +1 -0
  179. package/dist/types/plugins/base/pm-plugins/frozen-editor.d.ts +3 -2
  180. package/dist/types/plugins/card/pm-plugins/main.d.ts +2 -3
  181. package/dist/types/plugins/card/pm-plugins/util/resolve.d.ts +2 -1
  182. package/dist/types/plugins/card/types.d.ts +6 -0
  183. package/dist/types/plugins/code-bidi-warning/index.d.ts +3 -0
  184. package/dist/types/plugins/code-bidi-warning/plugin-key.d.ts +2 -0
  185. package/dist/types/plugins/code-bidi-warning/pm-plugins/main.d.ts +3 -0
  186. package/dist/types/plugins/code-bidi-warning/pm-plugins/plugin-factory.d.ts +7 -0
  187. package/dist/types/plugins/code-bidi-warning/pm-plugins/reducer.d.ts +3 -0
  188. package/dist/types/plugins/code-bidi-warning/pm-plugins/types.d.ts +5 -0
  189. package/dist/types/plugins/code-block/nodeviews/highlighting-code-block.d.ts +11 -2
  190. package/dist/types/plugins/code-block/pm-plugins/main.d.ts +5 -1
  191. package/dist/types/plugins/collab-edit/ui/to-avatar.d.ts +1 -1
  192. package/dist/types/plugins/extension/types.d.ts +0 -2
  193. package/dist/types/plugins/extension/ui/Extension/ExtensionComponent.d.ts +2 -2
  194. package/dist/types/plugins/feature-flags-context/get-enabled-feature-flag-keys.d.ts +1 -1
  195. package/dist/types/plugins/floating-toolbar/types.d.ts +1 -1
  196. package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +1 -1
  197. package/dist/types/plugins/hyperlink/utils.d.ts +0 -21
  198. package/dist/types/plugins/index.d.ts +1 -0
  199. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
  200. package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +27 -0
  201. package/dist/types/plugins/media/pm-plugins/main.d.ts +2 -2
  202. package/dist/types/plugins/media/toolbar/utils.d.ts +2 -0
  203. package/dist/types/plugins/media/utils/media-files.d.ts +8 -0
  204. package/dist/types/plugins/panel/message.d.ts +37 -0
  205. package/dist/types/plugins/panel/toolbar.d.ts +4 -37
  206. package/dist/types/plugins/panel/types.d.ts +1 -0
  207. package/dist/types/plugins/quick-insert/index.d.ts +1 -1
  208. package/dist/types/profiler/render-count.d.ts +14 -0
  209. package/dist/types/types/feature-flags.d.ts +17 -0
  210. package/dist/types/ui/LinkSearch/types.d.ts +1 -0
  211. package/dist/types/utils/react-hooks/use-component-renderer-tracking/index.d.ts +17 -1
  212. package/package.json +22 -19
  213. package/dist/cjs/plugins/caption/nodeviews/index.test.js +0 -135
  214. package/dist/cjs/plugins/caption/pm-plugins/keymap.test.js +0 -203
  215. package/dist/cjs/plugins/caption/pm-plugins/main.test.js +0 -141
  216. package/dist/cjs/plugins/code-block/language-list.test.js +0 -74
  217. package/dist/cjs/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -101
  218. package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -98
  219. package/dist/cjs/plugins/media/commands/captions.test.js +0 -149
  220. package/dist/cjs/plugins/media/commands/linking.test.js +0 -296
  221. package/dist/cjs/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -50
  222. package/dist/cjs/plugins/panel/toolbar.test.js +0 -250
  223. package/dist/cjs/ui/ColorPickerButton/index.test.js +0 -123
  224. package/dist/cjs/ui/PortalProvider/index.test.js +0 -139
  225. package/dist/es2019/plugins/caption/nodeviews/index.test.js +0 -122
  226. package/dist/es2019/plugins/caption/pm-plugins/keymap.test.js +0 -193
  227. package/dist/es2019/plugins/caption/pm-plugins/main.test.js +0 -132
  228. package/dist/es2019/plugins/code-block/language-list.test.js +0 -69
  229. package/dist/es2019/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -83
  230. package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
  231. package/dist/es2019/plugins/media/commands/captions.test.js +0 -126
  232. package/dist/es2019/plugins/media/commands/linking.test.js +0 -208
  233. package/dist/es2019/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
  234. package/dist/es2019/plugins/panel/toolbar.test.js +0 -200
  235. package/dist/es2019/ui/ColorPickerButton/index.test.js +0 -88
  236. package/dist/es2019/ui/PortalProvider/index.test.js +0 -115
  237. package/dist/esm/plugins/caption/nodeviews/index.test.js +0 -125
  238. package/dist/esm/plugins/caption/pm-plugins/keymap.test.js +0 -195
  239. package/dist/esm/plugins/caption/pm-plugins/main.test.js +0 -124
  240. package/dist/esm/plugins/code-block/language-list.test.js +0 -71
  241. package/dist/esm/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -92
  242. package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
  243. package/dist/esm/plugins/media/commands/captions.test.js +0 -135
  244. package/dist/esm/plugins/media/commands/linking.test.js +0 -268
  245. package/dist/esm/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
  246. package/dist/esm/plugins/panel/toolbar.test.js +0 -230
  247. package/dist/esm/ui/ColorPickerButton/index.test.js +0 -107
  248. package/dist/esm/ui/PortalProvider/index.test.js +0 -129
@@ -1,123 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
6
-
7
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
8
-
9
- var _react = _interopRequireDefault(require("react"));
10
-
11
- var _enzyme = require("@atlaskit/editor-test-helpers/enzyme");
12
-
13
- var _theme = require("@atlaskit/theme");
14
-
15
- var _Palettes = require("../ColorPalette/Palettes");
16
-
17
- var _panelBackgroundPalette = require("../ColorPalette/Palettes/panelBackgroundPalette");
18
-
19
- var _mockAnalyticsNext = require("@atlaskit/editor-test-helpers/mock-analytics-next");
20
-
21
- var _index = _interopRequireDefault(require("./index"));
22
-
23
- var _types = require("../../plugins/analytics/types");
24
-
25
- var _consts = require("../../plugins/analytics/consts");
26
-
27
- var _testUtils = require("react-dom/test-utils");
28
-
29
- // AFP-2532 TODO: Fix automatic suppressions below
30
- // eslint-disable-next-line @atlassian/tangerine/import/entry-points
31
- describe('color-picker-button', function () {
32
- var onChangeMock = jest.fn();
33
-
34
- var getWrapper = function getWrapper() {
35
- var placement = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
36
- return (0, _enzyme.mountWithIntl)( /*#__PURE__*/_react.default.createElement(_index.default, {
37
- onChange: onChangeMock,
38
- colorPalette: _panelBackgroundPalette.panelBackgroundPalette,
39
- placement: placement
40
- }));
41
- };
42
-
43
- var selectColor = function selectColor(wrapper, colorLabel) {
44
- // show popup
45
- wrapper.find('button').simulate('click'); // select purple
46
-
47
- wrapper.find('Color').findWhere(function (node) {
48
- return node.prop('label') === colorLabel;
49
- }).find('button').simulate('click');
50
- };
51
-
52
- afterEach(function () {
53
- jest.clearAllMocks();
54
- });
55
- it('should render a button', function () {
56
- var wrapper = getWrapper();
57
- expect(wrapper.find('button')).toHaveLength(1); // ensure no popup is rendered
58
-
59
- expect(wrapper.find('Popup')).toHaveLength(0);
60
- });
61
- it('should show a ColorPalette popup after clicking button', function () {
62
- var wrapper = getWrapper(); // show the popup
63
-
64
- wrapper.find('button').simulate('click');
65
- expect(wrapper.find('Popup')).toHaveLength(1);
66
- expect(wrapper.find('ColorPalette')).toHaveLength(1);
67
- expect(wrapper.find('Color')).toHaveLength(21);
68
- });
69
- it('should close ColorPalette popup after clicking outside', function () {
70
- var wrapper = getWrapper(); // show the popup
71
-
72
- wrapper.find('button').simulate('click'); // make sure the popup and picker are shown
73
-
74
- expect(wrapper.find('Popup')).toHaveLength(1);
75
- var colorPalette = wrapper.find('InjectIntl(ColorPalette)').instance();
76
- (0, _testUtils.act)(function () {
77
- colorPalette.props.handleClickOutside();
78
- });
79
- wrapper.update(); // make sure popup is hidden
80
-
81
- expect(wrapper.find('Popup')).toHaveLength(0);
82
- });
83
- it('should hide popup and call onChange after selecting a color', function () {
84
- var wrapper = getWrapper();
85
- selectColor(wrapper, 'Mintie'); // ensure popup is hidden
86
-
87
- expect(wrapper.find('Popup')).toHaveLength(0); // ensure callback was called
88
-
89
- expect(onChangeMock).toBeCalledWith({
90
- label: 'Mintie',
91
- value: _theme.colors.G75,
92
- border: _Palettes.DEFAULT_BORDER_COLOR
93
- });
94
- });
95
- it('analytics', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
96
- var wrapper;
97
- return _regenerator.default.wrap(function _callee$(_context) {
98
- while (1) {
99
- switch (_context.prev = _context.next) {
100
- case 0:
101
- wrapper = getWrapper('ConfigPanel');
102
- selectColor(wrapper, 'Doctor');
103
- expect(_mockAnalyticsNext.mockCreateAnalyticsEvent).toHaveBeenCalledWith({
104
- action: _types.ACTION.UPDATED,
105
- actionSubject: _types.ACTION_SUBJECT.PICKER,
106
- actionSubjectId: _types.ACTION_SUBJECT_ID.PICKER_COLOR,
107
- attributes: {
108
- color: '#FFFFFF',
109
- label: 'Doctor',
110
- placement: 'ConfigPanel'
111
- },
112
- eventType: _types.EVENT_TYPE.TRACK
113
- });
114
- expect(_mockAnalyticsNext.mockFire).toHaveBeenCalledWith(_consts.editorAnalyticsChannel);
115
-
116
- case 4:
117
- case "end":
118
- return _context.stop();
119
- }
120
- }
121
- }, _callee);
122
- })));
123
- });
@@ -1,139 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
6
-
7
- var _react = _interopRequireDefault(require("react"));
8
-
9
- var _reactDom = require("react-dom");
10
-
11
- var _enzyme = require("enzyme");
12
-
13
- var _analyticsNext = require("@atlaskit/analytics-next");
14
-
15
- var _ = require("./");
16
-
17
- var _contextAdapter = require("../../nodeviews/context-adapter");
18
-
19
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
20
-
21
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
22
-
23
- jest.mock('react-dom', function () {
24
- return _objectSpread(_objectSpread({}, jest.requireActual('react-dom')), {}, {
25
- unmountComponentAtNode: jest.fn()
26
- });
27
- });
28
-
29
- var Component = function Component() {
30
- return /*#__PURE__*/_react.default.createElement("div", {
31
- className: "component"
32
- }, "My component");
33
- };
34
-
35
- var Component2 = function Component2() {
36
- var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
37
- createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
38
-
39
- var event = createAnalyticsEvent({});
40
- event.fire('portalprovidertest');
41
- return /*#__PURE__*/_react.default.createElement("div", null, "Component 2");
42
- };
43
-
44
- var ComponentWithAnalytics = function ComponentWithAnalytics() {
45
- return /*#__PURE__*/_react.default.createElement(Component2, null);
46
- };
47
-
48
- describe('PortalProvider', function () {
49
- var portalProviderAPI;
50
- var wrapper;
51
- var place;
52
- var place2;
53
- var handleAnalyticsEvent;
54
- var handleAnalyticsEventFromContext;
55
-
56
- var initPortalProvider = function initPortalProvider() {
57
- handleAnalyticsEvent = jest.fn();
58
- handleAnalyticsEventFromContext = jest.fn();
59
- wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_analyticsNext.AnalyticsListener, {
60
- channel: "portalprovidertest",
61
- onEvent: handleAnalyticsEventFromContext
62
- }, /*#__PURE__*/_react.default.createElement(_contextAdapter.ContextAdapter, null, /*#__PURE__*/_react.default.createElement(_.PortalProvider, {
63
- onAnalyticsEvent: handleAnalyticsEvent,
64
- useAnalyticsContext: true,
65
- render: function render(api) {
66
- portalProviderAPI = api;
67
- return /*#__PURE__*/_react.default.createElement(_.PortalRenderer, {
68
- portalProviderAPI: api
69
- });
70
- }
71
- }))));
72
- portalProviderAPI.render(Component, place);
73
- wrapper.update();
74
- };
75
-
76
- beforeEach(function () {
77
- jest.resetAllMocks();
78
- place = document.body.appendChild(document.createElement('div'));
79
- place.classList.add('place');
80
- place2 = document.body.appendChild(document.createElement('div'));
81
- place2.classList.add('place2');
82
- initPortalProvider();
83
- });
84
- afterEach(function () {
85
- place.parentNode.removeChild(place);
86
- place2.parentNode.removeChild(place2);
87
- });
88
- it('should render a component successfully', function () {
89
- expect((0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(Component, null)).html()).toEqual(place.innerHTML);
90
- });
91
- it('should render several components successfully', function () {
92
- portalProviderAPI.render(Component, place2);
93
- wrapper.update();
94
- var component = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(Component, null));
95
- expect(component.html()).toEqual(place.innerHTML);
96
- expect(component.html()).toEqual(place2.innerHTML);
97
- });
98
- it('should destroy a component successfully', function () {
99
- portalProviderAPI.remove(place);
100
- wrapper.update();
101
- expect(_reactDom.unmountComponentAtNode).toBeCalledWith(place);
102
- });
103
- describe('React throws an error while unmounting child component', function () {
104
- var error = new Error('Something happened...');
105
- beforeEach(function () {
106
- _reactDom.unmountComponentAtNode.mockImplementation(function () {
107
- throw error;
108
- });
109
- });
110
- it('should not throw error', function () {
111
- expect(function () {
112
- return portalProviderAPI.remove(place);
113
- }).not.toThrowError();
114
- });
115
- it('should fire analytics if React throws an error when unmounting', function () {
116
- portalProviderAPI.remove(place);
117
- expect(handleAnalyticsEvent).toHaveBeenCalledWith({
118
- payload: {
119
- action: 'failedToUnmount',
120
- actionSubject: 'editor',
121
- actionSubjectId: 'reactNodeView',
122
- attributes: {
123
- error: error,
124
- domNodes: {
125
- container: 'place',
126
- child: 'component'
127
- }
128
- },
129
- eventType: 'operational'
130
- }
131
- });
132
- });
133
- });
134
- it('should propogate events up from child component', function () {
135
- portalProviderAPI.render(ComponentWithAnalytics, place);
136
- wrapper.update();
137
- expect(handleAnalyticsEventFromContext).toBeCalledTimes(1);
138
- });
139
- });
@@ -1,122 +0,0 @@
1
- import { createEditorFactory } from '@atlaskit/editor-test-helpers/create-editor';
2
- import { caption, doc, media, mediaSingle, p } from '@atlaskit/editor-test-helpers/doc-builder';
3
- import { setNodeSelection, setTextSelection } from '../../../utils';
4
- import { render } from '@testing-library/react';
5
- import { getSchemaBasedOnStage } from '@atlaskit/adf-schema';
6
- import captionNodeView from '.';
7
- jest.mock('../../base/pm-plugins/react-nodeview', () => ({
8
- stateKey: {
9
- getState: () => ({
10
- subscribe: jest.fn(),
11
- unsubscribe: jest.fn()
12
- })
13
- }
14
- }));
15
- const createEditorTestingLibrary = createEditorFactory(render);
16
-
17
- const editor = doc => createEditorTestingLibrary({
18
- doc,
19
- editorProps: {
20
- media: {
21
- allowMediaSingle: true,
22
- featureFlags: {
23
- captions: true
24
- }
25
- }
26
- }
27
- });
28
-
29
- const mediaNodeAttrs = {
30
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
31
- type: 'file',
32
- collection: 'MediaServicesSample',
33
- width: 250,
34
- height: 250
35
- };
36
- describe('caption', () => {
37
- it('should render caption children', () => {
38
- const CAPTION_TEXT = 'this is a very cool caption';
39
- const {
40
- wrapper: {
41
- getByText
42
- }
43
- } = editor(doc(mediaSingle()(media(mediaNodeAttrs)(), caption(CAPTION_TEXT))));
44
- expect(getByText(CAPTION_TEXT)).not.toBeNull();
45
- });
46
- it("should show a placeholder if there's no children", () => {
47
- const {
48
- wrapper: {
49
- getByText
50
- }
51
- } = editor(doc('{<node>}', // node selection
52
- mediaSingle()(media(mediaNodeAttrs)())));
53
- expect(getByText('Add a caption')).not.toBeNull();
54
- });
55
- it('should not show a placeholder when selecting away from media single', () => {
56
- const {
57
- wrapper: {
58
- queryByText,
59
- getByText
60
- },
61
- editorView
62
- } = editor(doc('{<node>}', // node selection
63
- mediaSingle()(media(mediaNodeAttrs)()), p('this is a random piece of text')));
64
- expect(getByText('Add a caption')).not.toBeNull();
65
- setTextSelection(editorView, 13, 14);
66
- expect(queryByText('Add a caption')).toBeNull();
67
- });
68
- it('should show a placeholder when selecting a media single', () => {
69
- const {
70
- wrapper: {
71
- queryByText,
72
- getByText
73
- },
74
- editorView
75
- } = editor(doc('{node}', // node selection
76
- mediaSingle()(media(mediaNodeAttrs)()), p('this is a random p{<>}iece of text')));
77
- expect(queryByText('Add a caption')).toBeNull();
78
- setNodeSelection(editorView, 0);
79
- expect(getByText('Add a caption')).not.toBeNull();
80
- });
81
- });
82
- describe('nodeview updating based on child count', () => {
83
- const portalProviderAPI = {
84
- render(component) {
85
- component();
86
- },
87
-
88
- remove() {}
89
-
90
- };
91
- const eventDispatcher = {};
92
- const node = caption('hi')(getSchemaBasedOnStage('stage0'));
93
- const view = {
94
- state: {
95
- selection: {
96
- from: 0,
97
- to: 0,
98
- $anchor: {
99
- pos: 0
100
- },
101
- $head: {
102
- pos: 20
103
- }
104
- }
105
- }
106
- };
107
- const getPos = jest.fn();
108
- it('does not update if the childCount has not changed', () => {
109
- const nodeView = captionNodeView(portalProviderAPI, eventDispatcher)(node, view, getPos); // ensure that if it falls through to the default it returns false
110
-
111
- nodeView['_viewShouldUpdate'] = jest.fn(_node => false);
112
- expect(nodeView.viewShouldUpdate(node)).toBeFalsy();
113
- });
114
- it('updates if the childCount has changed', () => {
115
- const nodeView = captionNodeView(portalProviderAPI, eventDispatcher)(node, view, getPos); // when captions is in full schema, use defaultSchema
116
-
117
- const newNode = caption()(getSchemaBasedOnStage('stage0')); // ensure that if it falls through to the default it returns false
118
-
119
- nodeView['_viewShouldUpdate'] = jest.fn(_node => false);
120
- expect(nodeView.viewShouldUpdate(newNode)).toBeTruthy();
121
- });
122
- });
@@ -1,193 +0,0 @@
1
- import { sendKeyToPm } from '@atlaskit/editor-test-helpers/send-key-to-pm';
2
- import { createEditorFactory } from '@atlaskit/editor-test-helpers/create-editor';
3
- import { caption, doc, media, mediaSingle, p, panel } from '@atlaskit/editor-test-helpers/doc-builder';
4
- import { NodeSelection, TextSelection } from 'prosemirror-state';
5
- import { findParentNodeOfType } from 'prosemirror-utils';
6
- import { GapCursorSelection } from '../../selection/gap-cursor/selection';
7
- const createEditorTestingLibrary = createEditorFactory();
8
-
9
- const editor = doc => createEditorTestingLibrary({
10
- doc,
11
- editorProps: {
12
- allowPanel: true,
13
- media: {
14
- allowMediaSingle: true,
15
- featureFlags: {
16
- captions: true
17
- }
18
- }
19
- }
20
- });
21
-
22
- describe('caption keymap', () => {
23
- it('should go to caption on tab', () => {
24
- const {
25
- editorView
26
- } = editor(doc('{<node>}', mediaSingle()(media({
27
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
28
- type: 'file',
29
- collection: 'MediaServicesSample'
30
- })(), caption('Hello'))));
31
- sendKeyToPm(editorView, 'Tab');
32
- const captionParentNode = findParentNodeOfType(editorView.state.schema.nodes.caption)(editorView.state.selection);
33
- expect(editorView.state.selection instanceof TextSelection).toBe(true);
34
- expect(captionParentNode).toBeDefined();
35
- });
36
- it('should select caption on arrow down', () => {
37
- const {
38
- editorView
39
- } = editor(doc('{<node>}', mediaSingle()(media({
40
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
41
- type: 'file',
42
- collection: 'MediaServicesSample'
43
- })(), caption('Hello')), p('')));
44
- sendKeyToPm(editorView, 'ArrowDown');
45
- const captionParentNode = findParentNodeOfType(editorView.state.schema.nodes.caption)(editorView.state.selection);
46
- expect(editorView.state.selection instanceof TextSelection).toBe(true);
47
- expect(captionParentNode).toBeDefined();
48
- });
49
- it('should select media from paragraph below on arrow up', () => {
50
- const {
51
- editorView
52
- } = editor(doc(mediaSingle({
53
- layout: 'center'
54
- })(media({
55
- id: 'abc',
56
- type: 'file',
57
- collection: 'xyz'
58
- })(), caption('hello')), p('{<>}something')));
59
- sendKeyToPm(editorView, 'ArrowUp');
60
- expect(editorView.state.selection instanceof NodeSelection).toBe(true);
61
- expect(editorView.state.selection.from).toBe(0);
62
- });
63
- it('should select media from caption on arrow up', () => {
64
- const {
65
- editorView
66
- } = editor(doc(mediaSingle({
67
- layout: 'center'
68
- })(media({
69
- id: 'abc',
70
- type: 'file',
71
- collection: 'xyz'
72
- })(), caption('he{<>}llo')), p('something')));
73
- sendKeyToPm(editorView, 'ArrowUp');
74
- expect(editorView.state.selection instanceof NodeSelection).toBe(true);
75
- expect(editorView.state.selection.from).toBe(0);
76
- });
77
- it('should select media from caption on shift + tab', () => {
78
- const {
79
- editorView
80
- } = editor(doc(mediaSingle({
81
- layout: 'center'
82
- })(media({
83
- id: 'abc',
84
- type: 'file',
85
- collection: 'xyz'
86
- })(), caption('he{<>}llo')), p('something')));
87
- sendKeyToPm(editorView, 'Shift-Tab');
88
- expect(editorView.state.selection instanceof NodeSelection).toBe(true);
89
- expect(editorView.state.selection.from).toBe(0);
90
- });
91
- it('should create paragraph below caption on arrow down', () => {
92
- const {
93
- editorView
94
- } = editor(doc(mediaSingle({
95
- layout: 'center'
96
- })(media({
97
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
98
- type: 'file',
99
- collection: 'MediaServicesSample'
100
- })(), caption('hello{<>}'))));
101
- sendKeyToPm(editorView, 'ArrowDown');
102
- expect(editorView.state.doc).toEqualDocument(doc(mediaSingle()(media({
103
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
104
- type: 'file',
105
- collection: 'MediaServicesSample'
106
- })(), caption('hello')), p()));
107
- });
108
- it('should create paragraph below caption on enter', () => {
109
- const {
110
- editorView
111
- } = editor(doc(mediaSingle({
112
- layout: 'center'
113
- })(media({
114
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
115
- type: 'file',
116
- collection: 'MediaServicesSample'
117
- })(), caption('hello{<>}'))));
118
- sendKeyToPm(editorView, 'Enter');
119
- expect(editorView.state.doc).toEqualDocument(doc(mediaSingle()(media({
120
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
121
- type: 'file',
122
- collection: 'MediaServicesSample'
123
- })(), caption('hello')), p()));
124
- });
125
- it('should not create paragraph below panel on enter', () => {
126
- const {
127
- editorView
128
- } = editor(doc(panel()(p('text{<>}'))));
129
- sendKeyToPm(editorView, 'Enter');
130
- expect(editorView.state.doc).toEqualDocument(doc(panel()(p('text'), p())));
131
- });
132
- it('should move to paragraph below caption on arrow down', () => {
133
- const {
134
- editorView
135
- } = editor(doc(mediaSingle({
136
- layout: 'center'
137
- })(media({
138
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
139
- type: 'file',
140
- collection: 'MediaServicesSample'
141
- })(), caption('hel{<>}lo')), p('something')));
142
- sendKeyToPm(editorView, 'ArrowDown');
143
- expect(editorView.state).toEqualDocumentAndSelection(doc(mediaSingle()(media({
144
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
145
- type: 'file',
146
- collection: 'MediaServicesSample'
147
- })(), caption('hello')), p('{<>}something')));
148
- });
149
- it('should move to paragraph below caption on enter', () => {
150
- const {
151
- editorView
152
- } = editor(doc(mediaSingle({
153
- layout: 'center'
154
- })(media({
155
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
156
- type: 'file',
157
- collection: 'MediaServicesSample'
158
- })(), caption('he{<>}llo')), p('something')));
159
- sendKeyToPm(editorView, 'Enter');
160
- expect(editorView.state).toEqualDocumentAndSelection(doc(mediaSingle()(media({
161
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
162
- type: 'file',
163
- collection: 'MediaServicesSample'
164
- })(), caption('hello')), p('{<>}something')));
165
- });
166
- it('should gap cursor parent media single on left arrow', () => {
167
- const {
168
- editorView
169
- } = editor(doc(mediaSingle()(media({
170
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
171
- type: 'file',
172
- collection: 'MediaServicesSample'
173
- })(), caption('{<>}Hello')), p('')));
174
- sendKeyToPm(editorView, 'ArrowLeft');
175
- expect(editorView.state.selection).toBeInstanceOf(GapCursorSelection);
176
- expect(editorView.state).toEqualDocumentAndSelection(doc('{<gap|>}', mediaSingle()(media({
177
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
178
- type: 'file',
179
- collection: 'MediaServicesSample'
180
- })(), caption('Hello')), p('')));
181
- });
182
- it('should not gap cursor parent media single on left arrow when not at start', () => {
183
- const {
184
- editorView
185
- } = editor(doc(mediaSingle()(media({
186
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
187
- type: 'file',
188
- collection: 'MediaServicesSample'
189
- })(), caption('H{<>}ello')), p('')));
190
- sendKeyToPm(editorView, 'ArrowLeft');
191
- expect(editorView.state.selection).not.toBeInstanceOf(GapCursorSelection);
192
- });
193
- });