@atlaskit/editor-core 150.0.2 → 151.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) 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/emoji/styles.js +1 -1
  27. package/dist/cjs/plugins/extension/pm-plugins/main.js +1 -4
  28. package/dist/cjs/plugins/extension/toolbar.js +28 -23
  29. package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +9 -3
  30. package/dist/cjs/plugins/find-replace/ui/Find.js +27 -7
  31. package/dist/cjs/plugins/hyperlink/HyperlinkToolbarAppearance.js +2 -2
  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/emoji/styles.js +2 -0
  82. package/dist/es2019/plugins/extension/pm-plugins/main.js +1 -4
  83. package/dist/es2019/plugins/extension/toolbar.js +30 -25
  84. package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +9 -4
  85. package/dist/es2019/plugins/find-replace/ui/Find.js +27 -6
  86. package/dist/es2019/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -1
  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/emoji/styles.js +1 -1
  137. package/dist/esm/plugins/extension/pm-plugins/main.js +1 -4
  138. package/dist/esm/plugins/extension/toolbar.js +28 -23
  139. package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +9 -4
  140. package/dist/esm/plugins/find-replace/ui/Find.js +27 -7
  141. package/dist/esm/plugins/hyperlink/HyperlinkToolbarAppearance.js +2 -2
  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 +2 -0
  170. package/dist/types/plugins/analytics/index.d.ts +1 -1
  171. package/dist/types/plugins/analytics/types/enums.d.ts +4 -2
  172. package/dist/types/plugins/analytics/types/events.d.ts +7 -2
  173. package/dist/types/plugins/analytics/types/general-events.d.ts +4 -1
  174. package/dist/types/plugins/analytics/types/index.d.ts +1 -1
  175. package/dist/types/plugins/analytics/types/insert-events.d.ts +6 -1
  176. package/dist/types/plugins/analytics/types/link-tool-bar-events.d.ts +1 -0
  177. package/dist/types/plugins/base/index.d.ts +1 -0
  178. package/dist/types/plugins/base/pm-plugins/frozen-editor.d.ts +3 -2
  179. package/dist/types/plugins/card/pm-plugins/main.d.ts +2 -3
  180. package/dist/types/plugins/card/pm-plugins/util/resolve.d.ts +2 -1
  181. package/dist/types/plugins/card/types.d.ts +6 -0
  182. package/dist/types/plugins/code-bidi-warning/index.d.ts +3 -0
  183. package/dist/types/plugins/code-bidi-warning/plugin-key.d.ts +2 -0
  184. package/dist/types/plugins/code-bidi-warning/pm-plugins/main.d.ts +3 -0
  185. package/dist/types/plugins/code-bidi-warning/pm-plugins/plugin-factory.d.ts +7 -0
  186. package/dist/types/plugins/code-bidi-warning/pm-plugins/reducer.d.ts +3 -0
  187. package/dist/types/plugins/code-bidi-warning/pm-plugins/types.d.ts +5 -0
  188. package/dist/types/plugins/code-block/nodeviews/highlighting-code-block.d.ts +11 -2
  189. package/dist/types/plugins/code-block/pm-plugins/main.d.ts +5 -1
  190. package/dist/types/plugins/extension/types.d.ts +0 -2
  191. package/dist/types/plugins/feature-flags-context/get-enabled-feature-flag-keys.d.ts +1 -1
  192. package/dist/types/plugins/floating-toolbar/types.d.ts +1 -1
  193. package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +1 -1
  194. package/dist/types/plugins/hyperlink/HyperlinkToolbarAppearance.d.ts +1 -1
  195. package/dist/types/plugins/hyperlink/utils.d.ts +0 -21
  196. package/dist/types/plugins/index.d.ts +1 -0
  197. package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +27 -0
  198. package/dist/types/plugins/media/pm-plugins/main.d.ts +2 -2
  199. package/dist/types/plugins/media/toolbar/utils.d.ts +2 -0
  200. package/dist/types/plugins/media/utils/media-files.d.ts +8 -0
  201. package/dist/types/plugins/panel/message.d.ts +37 -0
  202. package/dist/types/plugins/panel/toolbar.d.ts +4 -37
  203. package/dist/types/plugins/panel/types.d.ts +1 -0
  204. package/dist/types/profiler/render-count.d.ts +14 -0
  205. package/dist/types/types/feature-flags.d.ts +17 -0
  206. package/dist/types/ui/LinkSearch/types.d.ts +1 -0
  207. package/dist/types/utils/react-hooks/use-component-renderer-tracking/index.d.ts +17 -1
  208. package/package.json +21 -18
  209. package/dist/cjs/plugins/caption/nodeviews/index.test.js +0 -135
  210. package/dist/cjs/plugins/caption/pm-plugins/keymap.test.js +0 -203
  211. package/dist/cjs/plugins/caption/pm-plugins/main.test.js +0 -141
  212. package/dist/cjs/plugins/code-block/language-list.test.js +0 -74
  213. package/dist/cjs/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -101
  214. package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -98
  215. package/dist/cjs/plugins/media/commands/captions.test.js +0 -149
  216. package/dist/cjs/plugins/media/commands/linking.test.js +0 -296
  217. package/dist/cjs/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -50
  218. package/dist/cjs/plugins/panel/toolbar.test.js +0 -250
  219. package/dist/cjs/ui/ColorPickerButton/index.test.js +0 -123
  220. package/dist/cjs/ui/PortalProvider/index.test.js +0 -139
  221. package/dist/es2019/plugins/caption/nodeviews/index.test.js +0 -122
  222. package/dist/es2019/plugins/caption/pm-plugins/keymap.test.js +0 -193
  223. package/dist/es2019/plugins/caption/pm-plugins/main.test.js +0 -132
  224. package/dist/es2019/plugins/code-block/language-list.test.js +0 -69
  225. package/dist/es2019/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -83
  226. package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
  227. package/dist/es2019/plugins/media/commands/captions.test.js +0 -126
  228. package/dist/es2019/plugins/media/commands/linking.test.js +0 -208
  229. package/dist/es2019/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
  230. package/dist/es2019/plugins/panel/toolbar.test.js +0 -200
  231. package/dist/es2019/ui/ColorPickerButton/index.test.js +0 -88
  232. package/dist/es2019/ui/PortalProvider/index.test.js +0 -115
  233. package/dist/esm/plugins/caption/nodeviews/index.test.js +0 -125
  234. package/dist/esm/plugins/caption/pm-plugins/keymap.test.js +0 -195
  235. package/dist/esm/plugins/caption/pm-plugins/main.test.js +0 -124
  236. package/dist/esm/plugins/code-block/language-list.test.js +0 -71
  237. package/dist/esm/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -92
  238. package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
  239. package/dist/esm/plugins/media/commands/captions.test.js +0 -135
  240. package/dist/esm/plugins/media/commands/linking.test.js +0 -268
  241. package/dist/esm/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
  242. package/dist/esm/plugins/panel/toolbar.test.js +0 -230
  243. package/dist/esm/ui/ColorPickerButton/index.test.js +0 -107
  244. package/dist/esm/ui/PortalProvider/index.test.js +0 -129
@@ -1,125 +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', function () {
8
- return {
9
- stateKey: {
10
- getState: function getState() {
11
- return {
12
- subscribe: jest.fn(),
13
- unsubscribe: jest.fn()
14
- };
15
- }
16
- }
17
- };
18
- });
19
- var createEditorTestingLibrary = createEditorFactory(render);
20
-
21
- var editor = function editor(doc) {
22
- return createEditorTestingLibrary({
23
- doc: doc,
24
- editorProps: {
25
- media: {
26
- allowMediaSingle: true,
27
- featureFlags: {
28
- captions: true
29
- }
30
- }
31
- }
32
- });
33
- };
34
-
35
- var mediaNodeAttrs = {
36
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
37
- type: 'file',
38
- collection: 'MediaServicesSample',
39
- width: 250,
40
- height: 250
41
- };
42
- describe('caption', function () {
43
- it('should render caption children', function () {
44
- var CAPTION_TEXT = 'this is a very cool caption';
45
-
46
- var _editor = editor(doc(mediaSingle()(media(mediaNodeAttrs)(), caption(CAPTION_TEXT)))),
47
- getByText = _editor.wrapper.getByText;
48
-
49
- expect(getByText(CAPTION_TEXT)).not.toBeNull();
50
- });
51
- it("should show a placeholder if there's no children", function () {
52
- var _editor2 = editor(doc('{<node>}', // node selection
53
- mediaSingle()(media(mediaNodeAttrs)()))),
54
- getByText = _editor2.wrapper.getByText;
55
-
56
- expect(getByText('Add a caption')).not.toBeNull();
57
- });
58
- it('should not show a placeholder when selecting away from media single', function () {
59
- var _editor3 = editor(doc('{<node>}', // node selection
60
- mediaSingle()(media(mediaNodeAttrs)()), p('this is a random piece of text'))),
61
- _editor3$wrapper = _editor3.wrapper,
62
- queryByText = _editor3$wrapper.queryByText,
63
- getByText = _editor3$wrapper.getByText,
64
- editorView = _editor3.editorView;
65
-
66
- expect(getByText('Add a caption')).not.toBeNull();
67
- setTextSelection(editorView, 13, 14);
68
- expect(queryByText('Add a caption')).toBeNull();
69
- });
70
- it('should show a placeholder when selecting a media single', function () {
71
- var _editor4 = editor(doc('{node}', // node selection
72
- mediaSingle()(media(mediaNodeAttrs)()), p('this is a random p{<>}iece of text'))),
73
- _editor4$wrapper = _editor4.wrapper,
74
- queryByText = _editor4$wrapper.queryByText,
75
- getByText = _editor4$wrapper.getByText,
76
- editorView = _editor4.editorView;
77
-
78
- expect(queryByText('Add a caption')).toBeNull();
79
- setNodeSelection(editorView, 0);
80
- expect(getByText('Add a caption')).not.toBeNull();
81
- });
82
- });
83
- describe('nodeview updating based on child count', function () {
84
- var portalProviderAPI = {
85
- render: function render(component) {
86
- component();
87
- },
88
- remove: function remove() {}
89
- };
90
- var eventDispatcher = {};
91
- var node = caption('hi')(getSchemaBasedOnStage('stage0'));
92
- var view = {
93
- state: {
94
- selection: {
95
- from: 0,
96
- to: 0,
97
- $anchor: {
98
- pos: 0
99
- },
100
- $head: {
101
- pos: 20
102
- }
103
- }
104
- }
105
- };
106
- var getPos = jest.fn();
107
- it('does not update if the childCount has not changed', function () {
108
- var nodeView = captionNodeView(portalProviderAPI, eventDispatcher)(node, view, getPos); // ensure that if it falls through to the default it returns false
109
-
110
- nodeView['_viewShouldUpdate'] = jest.fn(function (_node) {
111
- return false;
112
- });
113
- expect(nodeView.viewShouldUpdate(node)).toBeFalsy();
114
- });
115
- it('updates if the childCount has changed', function () {
116
- var nodeView = captionNodeView(portalProviderAPI, eventDispatcher)(node, view, getPos); // when captions is in full schema, use defaultSchema
117
-
118
- var newNode = caption()(getSchemaBasedOnStage('stage0')); // ensure that if it falls through to the default it returns false
119
-
120
- nodeView['_viewShouldUpdate'] = jest.fn(function (_node) {
121
- return false;
122
- });
123
- expect(nodeView.viewShouldUpdate(newNode)).toBeTruthy();
124
- });
125
- });
@@ -1,195 +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
- var createEditorTestingLibrary = createEditorFactory();
8
-
9
- var editor = function editor(doc) {
10
- return createEditorTestingLibrary({
11
- doc: doc,
12
- editorProps: {
13
- allowPanel: true,
14
- media: {
15
- allowMediaSingle: true,
16
- featureFlags: {
17
- captions: true
18
- }
19
- }
20
- }
21
- });
22
- };
23
-
24
- describe('caption keymap', function () {
25
- it('should go to caption on tab', function () {
26
- var _editor = editor(doc('{<node>}', mediaSingle()(media({
27
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
28
- type: 'file',
29
- collection: 'MediaServicesSample'
30
- })(), caption('Hello')))),
31
- editorView = _editor.editorView;
32
-
33
- sendKeyToPm(editorView, 'Tab');
34
- var captionParentNode = findParentNodeOfType(editorView.state.schema.nodes.caption)(editorView.state.selection);
35
- expect(editorView.state.selection instanceof TextSelection).toBe(true);
36
- expect(captionParentNode).toBeDefined();
37
- });
38
- it('should select caption on arrow down', function () {
39
- var _editor2 = editor(doc('{<node>}', mediaSingle()(media({
40
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
41
- type: 'file',
42
- collection: 'MediaServicesSample'
43
- })(), caption('Hello')), p(''))),
44
- editorView = _editor2.editorView;
45
-
46
- sendKeyToPm(editorView, 'ArrowDown');
47
- var captionParentNode = findParentNodeOfType(editorView.state.schema.nodes.caption)(editorView.state.selection);
48
- expect(editorView.state.selection instanceof TextSelection).toBe(true);
49
- expect(captionParentNode).toBeDefined();
50
- });
51
- it('should select media from paragraph below on arrow up', function () {
52
- var _editor3 = editor(doc(mediaSingle({
53
- layout: 'center'
54
- })(media({
55
- id: 'abc',
56
- type: 'file',
57
- collection: 'xyz'
58
- })(), caption('hello')), p('{<>}something'))),
59
- editorView = _editor3.editorView;
60
-
61
- sendKeyToPm(editorView, 'ArrowUp');
62
- expect(editorView.state.selection instanceof NodeSelection).toBe(true);
63
- expect(editorView.state.selection.from).toBe(0);
64
- });
65
- it('should select media from caption on arrow up', function () {
66
- var _editor4 = editor(doc(mediaSingle({
67
- layout: 'center'
68
- })(media({
69
- id: 'abc',
70
- type: 'file',
71
- collection: 'xyz'
72
- })(), caption('he{<>}llo')), p('something'))),
73
- editorView = _editor4.editorView;
74
-
75
- sendKeyToPm(editorView, 'ArrowUp');
76
- expect(editorView.state.selection instanceof NodeSelection).toBe(true);
77
- expect(editorView.state.selection.from).toBe(0);
78
- });
79
- it('should select media from caption on shift + tab', function () {
80
- var _editor5 = editor(doc(mediaSingle({
81
- layout: 'center'
82
- })(media({
83
- id: 'abc',
84
- type: 'file',
85
- collection: 'xyz'
86
- })(), caption('he{<>}llo')), p('something'))),
87
- editorView = _editor5.editorView;
88
-
89
- sendKeyToPm(editorView, 'Shift-Tab');
90
- expect(editorView.state.selection instanceof NodeSelection).toBe(true);
91
- expect(editorView.state.selection.from).toBe(0);
92
- });
93
- it('should create paragraph below caption on arrow down', function () {
94
- var _editor6 = 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
- editorView = _editor6.editorView;
102
-
103
- sendKeyToPm(editorView, 'ArrowDown');
104
- expect(editorView.state.doc).toEqualDocument(doc(mediaSingle()(media({
105
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
106
- type: 'file',
107
- collection: 'MediaServicesSample'
108
- })(), caption('hello')), p()));
109
- });
110
- it('should create paragraph below caption on enter', function () {
111
- var _editor7 = 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
- editorView = _editor7.editorView;
119
-
120
- sendKeyToPm(editorView, 'Enter');
121
- expect(editorView.state.doc).toEqualDocument(doc(mediaSingle()(media({
122
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
123
- type: 'file',
124
- collection: 'MediaServicesSample'
125
- })(), caption('hello')), p()));
126
- });
127
- it('should not create paragraph below panel on enter', function () {
128
- var _editor8 = editor(doc(panel()(p('text{<>}')))),
129
- editorView = _editor8.editorView;
130
-
131
- sendKeyToPm(editorView, 'Enter');
132
- expect(editorView.state.doc).toEqualDocument(doc(panel()(p('text'), p())));
133
- });
134
- it('should move to paragraph below caption on arrow down', function () {
135
- var _editor9 = 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
- editorView = _editor9.editorView;
143
-
144
- sendKeyToPm(editorView, 'ArrowDown');
145
- expect(editorView.state).toEqualDocumentAndSelection(doc(mediaSingle()(media({
146
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
147
- type: 'file',
148
- collection: 'MediaServicesSample'
149
- })(), caption('hello')), p('{<>}something')));
150
- });
151
- it('should move to paragraph below caption on enter', function () {
152
- var _editor10 = 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
- editorView = _editor10.editorView;
160
-
161
- sendKeyToPm(editorView, 'Enter');
162
- expect(editorView.state).toEqualDocumentAndSelection(doc(mediaSingle()(media({
163
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
164
- type: 'file',
165
- collection: 'MediaServicesSample'
166
- })(), caption('hello')), p('{<>}something')));
167
- });
168
- it('should gap cursor parent media single on left arrow', function () {
169
- var _editor11 = editor(doc(mediaSingle()(media({
170
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
171
- type: 'file',
172
- collection: 'MediaServicesSample'
173
- })(), caption('{<>}Hello')), p(''))),
174
- editorView = _editor11.editorView;
175
-
176
- sendKeyToPm(editorView, 'ArrowLeft');
177
- expect(editorView.state.selection).toBeInstanceOf(GapCursorSelection);
178
- expect(editorView.state).toEqualDocumentAndSelection(doc('{<gap|>}', mediaSingle()(media({
179
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
180
- type: 'file',
181
- collection: 'MediaServicesSample'
182
- })(), caption('Hello')), p('')));
183
- });
184
- it('should not gap cursor parent media single on left arrow when not at start', function () {
185
- var _editor12 = editor(doc(mediaSingle()(media({
186
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
187
- type: 'file',
188
- collection: 'MediaServicesSample'
189
- })(), caption('H{<>}ello')), p(''))),
190
- editorView = _editor12.editorView;
191
-
192
- sendKeyToPm(editorView, 'ArrowLeft');
193
- expect(editorView.state.selection).not.toBeInstanceOf(GapCursorSelection);
194
- });
195
- });
@@ -1,124 +0,0 @@
1
- import { createProsemirrorEditorFactory, Preset } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
2
- import mediaPlugin from '../../media';
3
- import captionPlugin from '../';
4
- import { caption, doc, media, mediaSingle, p } from '@atlaskit/editor-test-helpers/doc-builder';
5
- import { pluginKey } from './plugin-key';
6
- import { setTextSelection } from '../../../utils/selection';
7
- import * as analyticsUtils from '../../analytics/utils';
8
- describe('Caption plugin', function () {
9
- var createEditor = createProsemirrorEditorFactory();
10
-
11
- var editor = function editor(doc) {
12
- return createEditor({
13
- doc: doc,
14
- pluginKey: pluginKey,
15
- preset: new Preset().add([mediaPlugin, {
16
- allowMediaSingle: true,
17
- featureFlags: {
18
- captions: true
19
- }
20
- }]).add(captionPlugin)
21
- });
22
- };
23
-
24
- it('should not remove caption when there is content', function () {
25
- var _editor = editor(doc(mediaSingle()(media({
26
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
27
- type: 'file',
28
- collection: 'MediaServicesSample'
29
- })(), caption('Test{<>}')), p('Line {movePos}two'))),
30
- editorView = _editor.editorView,
31
- movePos = _editor.refs.movePos;
32
-
33
- setTextSelection(editorView, movePos);
34
- expect(editorView.state.doc).toEqualDocument(doc(mediaSingle()(media({
35
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
36
- type: 'file',
37
- collection: 'MediaServicesSample'
38
- })(), caption('Test')), p('Line two')));
39
- });
40
- it('should remove caption when there is no content', function () {
41
- var _editor2 = editor(doc(mediaSingle()(media({
42
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
43
- type: 'file',
44
- collection: 'MediaServicesSample'
45
- })(), caption('{<>}')), p('Line {movePos}two'))),
46
- editorView = _editor2.editorView,
47
- movePos = _editor2.refs.movePos;
48
-
49
- setTextSelection(editorView, movePos);
50
- expect(editorView.state.doc).toEqualDocument(doc(mediaSingle()(media({
51
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
52
- type: 'file',
53
- collection: 'MediaServicesSample'
54
- })()), p('Line two')));
55
- });
56
- it('should remove caption when clicking onto another caption', function () {
57
- var _editor3 = editor(doc(mediaSingle()(media({
58
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
59
- type: 'file',
60
- collection: 'MediaServicesSample'
61
- })(), caption('{<>}')), mediaSingle()(media({
62
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
63
- type: 'file',
64
- collection: 'MediaServicesSample'
65
- })(), caption('second {movePos}caption')))),
66
- editorView = _editor3.editorView,
67
- movePos = _editor3.refs.movePos;
68
-
69
- setTextSelection(editorView, movePos);
70
- expect(editorView.state.doc).toEqualDocument(doc(mediaSingle()(media({
71
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
72
- type: 'file',
73
- collection: 'MediaServicesSample'
74
- })()), mediaSingle()(media({
75
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
76
- type: 'file',
77
- collection: 'MediaServicesSample'
78
- })(), caption('second caption'))));
79
- });
80
- describe('analytics', function () {
81
- var addAnalyticsSpy = jest.spyOn(analyticsUtils, 'addAnalytics');
82
- var FIRST_CALL = 0;
83
- var PAYLOAD_ARGUMENT = 2;
84
- beforeEach(function () {
85
- addAnalyticsSpy.mockReset();
86
- });
87
- it('should fire deleted analytic when removing caption', function () {
88
- var _editor4 = editor(doc(mediaSingle()(media({
89
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
90
- type: 'file',
91
- collection: 'MediaServicesSample'
92
- })(), caption('{<>}')), p('Line {movePos}two'))),
93
- editorView = _editor4.editorView,
94
- movePos = _editor4.refs.movePos;
95
-
96
- setTextSelection(editorView, movePos);
97
- expect(addAnalyticsSpy).toBeCalled();
98
- expect(addAnalyticsSpy.mock.calls[FIRST_CALL][PAYLOAD_ARGUMENT]).toEqual({
99
- action: 'deleted',
100
- actionSubject: 'mediaSingle',
101
- actionSubjectId: 'caption',
102
- eventType: 'track'
103
- });
104
- });
105
- it('should fire edited analytic when moving away from a non empty caption', function () {
106
- var _editor5 = editor(doc(mediaSingle()(media({
107
- id: 'a559980d-cd47-43e2-8377-27359fcb905f',
108
- type: 'file',
109
- collection: 'MediaServicesSample'
110
- })(), caption('Test{<>}')), p('Line {movePos}two'))),
111
- editorView = _editor5.editorView,
112
- movePos = _editor5.refs.movePos;
113
-
114
- setTextSelection(editorView, movePos);
115
- expect(addAnalyticsSpy).toBeCalled();
116
- expect(addAnalyticsSpy.mock.calls[FIRST_CALL][PAYLOAD_ARGUMENT]).toEqual({
117
- action: 'edited',
118
- actionSubject: 'mediaSingle',
119
- actionSubjectId: 'caption',
120
- eventType: 'track'
121
- });
122
- });
123
- });
124
- });
@@ -1,71 +0,0 @@
1
- import { DEFAULT_LANGUAGES, findMatchedLanguage, filterSupportedLanguages, getLanguageIdentifier, createLanguageList } from './language-list';
2
- var mockSupportedLanguages = [{
3
- name: 'JSON',
4
- alias: ['json'],
5
- value: 'json'
6
- }, {
7
- name: 'JavaScript',
8
- alias: ['javascript', 'js'],
9
- value: 'javascript'
10
- }, {
11
- name: 'Python',
12
- alias: ['python', 'py'],
13
- value: 'python'
14
- }];
15
- describe('languageList utils', function () {
16
- it('should find matched language', function () {
17
- expect(findMatchedLanguage(mockSupportedLanguages, 'JavaScript')).toEqual({
18
- name: 'JavaScript',
19
- alias: ['javascript', 'js'],
20
- value: 'javascript'
21
- });
22
- expect(findMatchedLanguage(mockSupportedLanguages, 'Python')).toEqual({
23
- name: 'Python',
24
- alias: ['python', 'py'],
25
- value: 'python'
26
- });
27
- expect(findMatchedLanguage(mockSupportedLanguages, 'GiBBeRish')).toBeUndefined();
28
- });
29
- it('should filter supported languages', function () {
30
- var mockSupportedLanguageStrings = mockSupportedLanguages.map(function (language) {
31
- return language.name.toLowerCase();
32
- });
33
- expect(filterSupportedLanguages([])).toEqual(DEFAULT_LANGUAGES);
34
- expect(filterSupportedLanguages(mockSupportedLanguageStrings)).toEqual([{
35
- name: 'Python',
36
- alias: ['python', 'py'],
37
- value: 'python'
38
- }, {
39
- name: 'JavaScript',
40
- alias: ['javascript', 'js'],
41
- value: 'javascript'
42
- }, {
43
- name: 'JSON',
44
- alias: ['json'],
45
- value: 'json'
46
- } // '(None)' is not an actual language and should not be 'supported'
47
- ]);
48
- });
49
- it('should get language identifier', function () {
50
- expect(getLanguageIdentifier({
51
- name: 'MyLanguage',
52
- alias: ['myalias'],
53
- value: 'myalias'
54
- })).toEqual('myalias');
55
- });
56
- it('should create language list sorted as case insensitive', function () {
57
- expect(createLanguageList(mockSupportedLanguages)).toEqual([{
58
- name: 'JavaScript',
59
- alias: ['javascript', 'js'],
60
- value: 'javascript'
61
- }, {
62
- name: 'JSON',
63
- alias: ['json'],
64
- value: 'json'
65
- }, {
66
- name: 'Python',
67
- alias: ['python', 'py'],
68
- value: 'python'
69
- }]);
70
- });
71
- });
@@ -1,92 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _extends from "@babel/runtime/helpers/extends";
3
-
4
- 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; }
5
-
6
- 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) { _defineProperty(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; }
7
-
8
- import React from 'react';
9
- import { render, act } from '@testing-library/react';
10
- import { IntlProvider } from 'react-intl';
11
- import { SaveIndicator } from './SaveIndicator';
12
- jest.useFakeTimers();
13
-
14
- function setup() {
15
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16
-
17
- var onSaveStarted = function onSaveStarted() {};
18
-
19
- var result = render( /*#__PURE__*/React.createElement(IntlProvider, {
20
- locale: "en"
21
- }, /*#__PURE__*/React.createElement(SaveIndicator, _extends({
22
- duration: 2000
23
- }, props), function (_ref) {
24
- var _onSaveStarted = _ref.onSaveStarted;
25
- onSaveStarted = _onSaveStarted;
26
- return /*#__PURE__*/React.createElement("div", {
27
- "data-testid": "my-component"
28
- });
29
- })));
30
- return _objectSpread(_objectSpread({}, result), {}, {
31
- onSaveStarted: onSaveStarted
32
- });
33
- }
34
-
35
- describe('Extension Context Panel - Save Indicator', function () {
36
- it('should call the render function ', function () {
37
- var renderFunction = jest.fn().mockImplementation(function () {
38
- return /*#__PURE__*/React.createElement("div", {
39
- "data-testid": "my-component"
40
- });
41
- });
42
-
43
- var _render = render( /*#__PURE__*/React.createElement(IntlProvider, {
44
- locale: "en"
45
- }, /*#__PURE__*/React.createElement(SaveIndicator, {
46
- duration: 1000
47
- }, renderFunction))),
48
- queryByTestId = _render.queryByTestId;
49
-
50
- expect(queryByTestId('my-component')).not.toBeNull();
51
- });
52
- it('should show the save indicator when is saving ', function () {
53
- var _setup = setup(),
54
- onSaveStarted = _setup.onSaveStarted,
55
- queryByTestId = _setup.queryByTestId;
56
-
57
- act(function () {
58
- onSaveStarted();
59
- });
60
- expect(queryByTestId('save-indicator-content')).not.toBeNull();
61
- });
62
- it('should hide once the duration is over ', function () {
63
- jest.clearAllTimers();
64
- var duration = 2000;
65
-
66
- var _setup2 = setup({
67
- duration: duration
68
- }),
69
- onSaveStarted = _setup2.onSaveStarted,
70
- queryByTestId = _setup2.queryByTestId;
71
-
72
- act(function () {
73
- onSaveStarted();
74
- });
75
- act(function () {
76
- jest.advanceTimersByTime(duration);
77
- });
78
- expect(queryByTestId('save-indicator-content')).toBeNull();
79
- });
80
- it('should not show the save indicator after saving when visible is false ', function () {
81
- var _setup3 = setup({
82
- visible: false
83
- }),
84
- onSaveStarted = _setup3.onSaveStarted,
85
- queryByTestId = _setup3.queryByTestId;
86
-
87
- act(function () {
88
- onSaveStarted();
89
- });
90
- expect(queryByTestId('save-indicator-content')).toBeNull();
91
- });
92
- });