@atlaskit/editor-core 150.0.0 → 151.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/CHANGELOG.md +65 -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 +4 -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-block/toolbar.js +1 -1
  17. package/dist/cjs/plugins/collab-edit/ui/to-avatar.js +4 -8
  18. package/dist/cjs/plugins/emoji/styles.js +1 -1
  19. package/dist/cjs/plugins/extension/pm-plugins/main.js +1 -4
  20. package/dist/cjs/plugins/extension/toolbar.js +28 -23
  21. package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +8 -3
  22. package/dist/cjs/plugins/find-replace/ui/Find.js +27 -7
  23. package/dist/cjs/plugins/hyperlink/pm-plugins/keymap.js +3 -3
  24. package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
  25. package/dist/cjs/plugins/hyperlink/utils.js +6 -69
  26. package/dist/cjs/plugins/media/index.js +14 -3
  27. package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +24 -10
  28. package/dist/cjs/plugins/media/nodeviews/mediaInline.js +179 -0
  29. package/dist/cjs/plugins/media/pm-plugins/main.js +18 -9
  30. package/dist/cjs/plugins/media/toolbar/index.js +49 -17
  31. package/dist/cjs/plugins/media/toolbar/utils.js +20 -2
  32. package/dist/cjs/plugins/media/utils/media-files.js +67 -1
  33. package/dist/cjs/plugins/mentions/type-ahead/index.js +39 -3
  34. package/dist/cjs/plugins/panel/index.js +2 -3
  35. package/dist/cjs/plugins/panel/message.js +47 -0
  36. package/dist/cjs/plugins/panel/toolbar.js +64 -84
  37. package/dist/cjs/plugins/panel/utils.js +2 -2
  38. package/dist/cjs/plugins/paste/linkify-md-plugin.js +3 -3
  39. package/dist/cjs/plugins/status/styles.js +1 -1
  40. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
  41. package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -3
  42. package/dist/cjs/profiler/render-count.js +82 -0
  43. package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -5
  44. package/dist/cjs/utils/react-hooks/use-component-renderer-tracking/index.js +55 -19
  45. package/dist/cjs/version-wrapper.js +1 -1
  46. package/dist/cjs/version.json +1 -1
  47. package/dist/es2019/actions/index.js +6 -28
  48. package/dist/es2019/create-editor/ErrorBoundary.js +73 -60
  49. package/dist/es2019/create-editor/ReactEditorView.js +130 -23
  50. package/dist/es2019/create-editor/create-plugins-list.js +4 -2
  51. package/dist/es2019/editor.js +74 -35
  52. package/dist/es2019/labs/next/presets/cxhtml.js +2 -1
  53. package/dist/es2019/plugins/analytics/types/enums.js +3 -1
  54. package/dist/es2019/plugins/base/index.js +4 -3
  55. package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +63 -35
  56. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +2 -1
  57. package/dist/es2019/plugins/card/index.js +7 -2
  58. package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -0
  59. package/dist/es2019/plugins/card/pm-plugins/main.js +9 -2
  60. package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +12 -5
  61. package/dist/es2019/plugins/code-block/toolbar.js +1 -1
  62. package/dist/es2019/plugins/collab-edit/ui/to-avatar.js +2 -6
  63. package/dist/es2019/plugins/emoji/styles.js +2 -0
  64. package/dist/es2019/plugins/extension/pm-plugins/main.js +1 -4
  65. package/dist/es2019/plugins/extension/toolbar.js +30 -25
  66. package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +8 -4
  67. package/dist/es2019/plugins/find-replace/ui/Find.js +27 -6
  68. package/dist/es2019/plugins/hyperlink/pm-plugins/keymap.js +1 -1
  69. package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
  70. package/dist/es2019/plugins/hyperlink/utils.js +3 -59
  71. package/dist/es2019/plugins/media/index.js +13 -4
  72. package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +16 -7
  73. package/dist/es2019/plugins/media/nodeviews/mediaInline.js +88 -0
  74. package/dist/es2019/plugins/media/pm-plugins/main.js +20 -11
  75. package/dist/es2019/plugins/media/toolbar/index.js +44 -15
  76. package/dist/es2019/plugins/media/toolbar/utils.js +16 -0
  77. package/dist/es2019/plugins/media/utils/media-files.js +68 -2
  78. package/dist/es2019/plugins/mentions/type-ahead/index.js +21 -2
  79. package/dist/es2019/plugins/panel/index.js +3 -4
  80. package/dist/es2019/plugins/panel/message.js +38 -0
  81. package/dist/es2019/plugins/panel/toolbar.js +52 -71
  82. package/dist/es2019/plugins/panel/utils.js +2 -2
  83. package/dist/es2019/plugins/paste/linkify-md-plugin.js +2 -2
  84. package/dist/es2019/plugins/status/styles.js +2 -0
  85. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
  86. package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -3
  87. package/dist/es2019/profiler/render-count.js +60 -0
  88. package/dist/es2019/ui/Appearance/Comment/Comment.js +4 -2
  89. package/dist/es2019/utils/react-hooks/use-component-renderer-tracking/index.js +51 -18
  90. package/dist/es2019/version-wrapper.js +1 -1
  91. package/dist/es2019/version.json +1 -1
  92. package/dist/esm/actions/index.js +6 -24
  93. package/dist/esm/create-editor/ErrorBoundary.js +113 -78
  94. package/dist/esm/create-editor/ReactEditorView.js +146 -31
  95. package/dist/esm/create-editor/create-plugins-list.js +4 -2
  96. package/dist/esm/editor.js +100 -40
  97. package/dist/esm/labs/next/presets/cxhtml.js +2 -1
  98. package/dist/esm/plugins/analytics/types/enums.js +3 -1
  99. package/dist/esm/plugins/base/index.js +4 -3
  100. package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +64 -36
  101. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +3 -1
  102. package/dist/esm/plugins/card/index.js +13 -2
  103. package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -0
  104. package/dist/esm/plugins/card/pm-plugins/main.js +7 -2
  105. package/dist/esm/plugins/card/pm-plugins/util/resolve.js +12 -5
  106. package/dist/esm/plugins/code-block/toolbar.js +1 -1
  107. package/dist/esm/plugins/collab-edit/ui/to-avatar.js +4 -8
  108. package/dist/esm/plugins/emoji/styles.js +1 -1
  109. package/dist/esm/plugins/extension/pm-plugins/main.js +1 -4
  110. package/dist/esm/plugins/extension/toolbar.js +28 -23
  111. package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +8 -4
  112. package/dist/esm/plugins/find-replace/ui/Find.js +27 -7
  113. package/dist/esm/plugins/hyperlink/pm-plugins/keymap.js +1 -1
  114. package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
  115. package/dist/esm/plugins/hyperlink/utils.js +3 -59
  116. package/dist/esm/plugins/media/index.js +14 -4
  117. package/dist/esm/plugins/media/nodeviews/mediaGroup.js +24 -10
  118. package/dist/esm/plugins/media/nodeviews/mediaInline.js +147 -0
  119. package/dist/esm/plugins/media/pm-plugins/main.js +19 -11
  120. package/dist/esm/plugins/media/toolbar/index.js +47 -19
  121. package/dist/esm/plugins/media/toolbar/utils.js +15 -1
  122. package/dist/esm/plugins/media/utils/media-files.js +60 -2
  123. package/dist/esm/plugins/mentions/type-ahead/index.js +39 -3
  124. package/dist/esm/plugins/panel/index.js +3 -4
  125. package/dist/esm/plugins/panel/message.js +38 -0
  126. package/dist/esm/plugins/panel/toolbar.js +57 -77
  127. package/dist/esm/plugins/panel/utils.js +2 -2
  128. package/dist/esm/plugins/paste/linkify-md-plugin.js +2 -2
  129. package/dist/esm/plugins/status/styles.js +1 -1
  130. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
  131. package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -3
  132. package/dist/esm/profiler/render-count.js +57 -0
  133. package/dist/esm/ui/Appearance/Comment/Comment.js +6 -5
  134. package/dist/esm/utils/react-hooks/use-component-renderer-tracking/index.js +53 -20
  135. package/dist/esm/version-wrapper.js +1 -1
  136. package/dist/esm/version.json +1 -1
  137. package/dist/types/create-editor/ErrorBoundary.d.ts +6 -6
  138. package/dist/types/create-editor/ReactEditorView.d.ts +15 -3
  139. package/dist/types/editor.d.ts +3 -1
  140. package/dist/types/plugins/analytics/analytics-queue.d.ts +1 -1
  141. package/dist/types/plugins/analytics/index.d.ts +1 -1
  142. package/dist/types/plugins/analytics/types/enums.d.ts +4 -2
  143. package/dist/types/plugins/analytics/types/events.d.ts +7 -2
  144. package/dist/types/plugins/analytics/types/general-events.d.ts +4 -1
  145. package/dist/types/plugins/analytics/types/index.d.ts +1 -1
  146. package/dist/types/plugins/analytics/types/insert-events.d.ts +6 -1
  147. package/dist/types/plugins/analytics/types/link-tool-bar-events.d.ts +1 -0
  148. package/dist/types/plugins/base/index.d.ts +1 -0
  149. package/dist/types/plugins/base/pm-plugins/frozen-editor.d.ts +3 -2
  150. package/dist/types/plugins/card/pm-plugins/main.d.ts +2 -3
  151. package/dist/types/plugins/card/pm-plugins/util/resolve.d.ts +2 -1
  152. package/dist/types/plugins/card/types.d.ts +6 -0
  153. package/dist/types/plugins/collab-edit/ui/to-avatar.d.ts +1 -1
  154. package/dist/types/plugins/extension/types.d.ts +0 -2
  155. package/dist/types/plugins/extension/ui/Extension/ExtensionComponent.d.ts +2 -2
  156. package/dist/types/plugins/feature-flags-context/get-enabled-feature-flag-keys.d.ts +1 -1
  157. package/dist/types/plugins/floating-toolbar/types.d.ts +1 -1
  158. package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +1 -1
  159. package/dist/types/plugins/hyperlink/utils.d.ts +0 -21
  160. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
  161. package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +27 -0
  162. package/dist/types/plugins/media/pm-plugins/main.d.ts +2 -2
  163. package/dist/types/plugins/media/toolbar/utils.d.ts +2 -0
  164. package/dist/types/plugins/media/utils/media-files.d.ts +8 -0
  165. package/dist/types/plugins/panel/message.d.ts +37 -0
  166. package/dist/types/plugins/panel/toolbar.d.ts +4 -37
  167. package/dist/types/plugins/panel/types.d.ts +1 -0
  168. package/dist/types/plugins/quick-insert/index.d.ts +1 -1
  169. package/dist/types/profiler/render-count.d.ts +14 -0
  170. package/dist/types/types/feature-flags.d.ts +8 -0
  171. package/dist/types/ui/LinkSearch/types.d.ts +1 -0
  172. package/dist/types/utils/react-hooks/use-component-renderer-tracking/index.d.ts +17 -1
  173. package/package.json +20 -17
  174. package/dist/cjs/plugins/caption/nodeviews/index.test.js +0 -135
  175. package/dist/cjs/plugins/caption/pm-plugins/keymap.test.js +0 -203
  176. package/dist/cjs/plugins/caption/pm-plugins/main.test.js +0 -141
  177. package/dist/cjs/plugins/code-block/language-list.test.js +0 -74
  178. package/dist/cjs/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -101
  179. package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -98
  180. package/dist/cjs/plugins/media/commands/captions.test.js +0 -149
  181. package/dist/cjs/plugins/media/commands/linking.test.js +0 -296
  182. package/dist/cjs/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -50
  183. package/dist/cjs/plugins/panel/toolbar.test.js +0 -250
  184. package/dist/cjs/ui/ColorPickerButton/index.test.js +0 -123
  185. package/dist/cjs/ui/PortalProvider/index.test.js +0 -139
  186. package/dist/es2019/plugins/caption/nodeviews/index.test.js +0 -122
  187. package/dist/es2019/plugins/caption/pm-plugins/keymap.test.js +0 -193
  188. package/dist/es2019/plugins/caption/pm-plugins/main.test.js +0 -132
  189. package/dist/es2019/plugins/code-block/language-list.test.js +0 -69
  190. package/dist/es2019/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -83
  191. package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
  192. package/dist/es2019/plugins/media/commands/captions.test.js +0 -126
  193. package/dist/es2019/plugins/media/commands/linking.test.js +0 -208
  194. package/dist/es2019/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
  195. package/dist/es2019/plugins/panel/toolbar.test.js +0 -200
  196. package/dist/es2019/ui/ColorPickerButton/index.test.js +0 -88
  197. package/dist/es2019/ui/PortalProvider/index.test.js +0 -115
  198. package/dist/esm/plugins/caption/nodeviews/index.test.js +0 -125
  199. package/dist/esm/plugins/caption/pm-plugins/keymap.test.js +0 -195
  200. package/dist/esm/plugins/caption/pm-plugins/main.test.js +0 -124
  201. package/dist/esm/plugins/code-block/language-list.test.js +0 -71
  202. package/dist/esm/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -92
  203. package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
  204. package/dist/esm/plugins/media/commands/captions.test.js +0 -135
  205. package/dist/esm/plugins/media/commands/linking.test.js +0 -268
  206. package/dist/esm/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
  207. package/dist/esm/plugins/panel/toolbar.test.js +0 -230
  208. package/dist/esm/ui/ColorPickerButton/index.test.js +0 -107
  209. package/dist/esm/ui/PortalProvider/index.test.js +0 -129
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.RenderCountProfiler = exports.ProfiledComponentIds = void 0;
11
+
12
+ var _react = _interopRequireWildcard(require("react"));
13
+
14
+ var _uuid = _interopRequireDefault(require("uuid"));
15
+
16
+ var _useComponentRendererTracking = require("../utils/react-hooks/use-component-renderer-tracking");
17
+
18
+ var _editorCommon = require("@atlaskit/editor-common");
19
+
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ var ProfiledComponentIds;
25
+ exports.ProfiledComponentIds = ProfiledComponentIds;
26
+
27
+ (function (ProfiledComponentIds) {
28
+ ProfiledComponentIds["editor"] = "Editor";
29
+ ProfiledComponentIds["appearance"] = "FullPageEditor";
30
+ ProfiledComponentIds["reactEditorView"] = "ReactEditorView";
31
+ ProfiledComponentIds["contentArea"] = "FullPageContentArea";
32
+ ProfiledComponentIds["toolbar"] = "FullPageToolbar";
33
+ ProfiledComponentIds["mention"] = "MentionNodeView";
34
+ })(ProfiledComponentIds || (exports.ProfiledComponentIds = ProfiledComponentIds = {}));
35
+
36
+ var CoreRenderCountProfiler = function CoreRenderCountProfiler(_ref) {
37
+ var componentId = _ref.componentId;
38
+
39
+ var _useRef = (0, _react.useRef)((0, _uuid.default)()),
40
+ instanceId = _useRef.current;
41
+
42
+ var onRender = function onRender(_ref2) {
43
+ var renderCount = _ref2.renderCount;
44
+
45
+ var profiler = _editorCommon.RenderCountProfiler.getInstance({
46
+ store: window
47
+ });
48
+
49
+ profiler.setRenderCount({
50
+ componentId: componentId,
51
+ instanceId: instanceId,
52
+ renderCount: renderCount
53
+ });
54
+ };
55
+
56
+ (0, _useComponentRendererTracking.useComponentRenderTracking)({
57
+ onRender: onRender,
58
+ propsDiffingOptions: {
59
+ enabled: false
60
+ },
61
+ zeroBasedCount: false
62
+ });
63
+ return null;
64
+ };
65
+
66
+ var RenderCountProfiler = function RenderCountProfiler(_ref3) {
67
+ var componentId = _ref3.componentId;
68
+
69
+ var profiler = _editorCommon.RenderCountProfiler.getInstance({
70
+ store: window
71
+ });
72
+
73
+ if (profiler.isEnabled()) {
74
+ return /*#__PURE__*/_react.default.createElement(CoreRenderCountProfiler, {
75
+ componentId: componentId
76
+ });
77
+ }
78
+
79
+ return null;
80
+ };
81
+
82
+ exports.RenderCountProfiler = RenderCountProfiler;
@@ -78,12 +78,12 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
78
78
  var CommentEditorMargin = 14;
79
79
  var CommentEditorSmallerMargin = 8;
80
80
 
81
- var CommentEditor = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n\n .less-margin .ProseMirror {\n margin: 12px ", "px ", "px;\n }\n\n min-width: 272px;\n /* Border + Toolbar + Footer + (Paragraph + ((Parahraph + Margin) * (DefaultLines - 1)) */\n /* calc(2px + 40px + 24px + ( 20px + (32px * 2))) */\n min-height: 150px;\n height: auto;\n ", " background-color: white;\n border: 1px solid ", ";\n box-sizing: border-box;\n border-radius: ", "px;\n\n max-width: inherit;\n word-wrap: break-word;\n"])), CommentEditorSmallerMargin, CommentEditorSmallerMargin, function (props) {
82
- return props.maxHeight ? 'max-height: ' + props.maxHeight + 'px;' : '';
83
- }, _colors.N40, (0, _constants.borderRadius)());
81
+ var CommentEditor = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n\n .less-margin .ProseMirror {\n margin: 12px ", "px ", "px;\n }\n\n min-width: 272px;\n /* Border + Toolbar + Footer + (Paragraph + ((Parahraph + Margin) * (DefaultLines - 1)) */\n /* calc(2px + 40px + 24px + ( 20px + (32px * 2))) */\n min-height: 150px;\n height: auto;\n background-color: white;\n border: 1px solid ", ";\n box-sizing: border-box;\n border-radius: ", "px;\n\n max-width: inherit;\n word-wrap: break-word;\n"])), CommentEditorSmallerMargin, CommentEditorSmallerMargin, _colors.N40, (0, _constants.borderRadius)());
84
82
 
85
83
  CommentEditor.displayName = 'CommentEditor';
86
- var ContentArea = (0, _styledComponents.default)(_ContentStyles.default)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n flex-grow: 1;\n overflow-x: hidden;\n overflow-y: auto;\n line-height: 24px;\n\n /** Hack for Bitbucket to ensure entire editorView gets drop event; see ED-3294 **/\n /** Hack for tables controlls. Otherwise marging collapse and controlls are misplaced. **/\n .ProseMirror {\n margin: 12px ", "px ", "px;\n }\n\n .gridParent {\n margin-left: ", "px;\n margin-right: ", "px;\n width: calc(100% + ", "px);\n }\n\n padding: ", "px;\n\n ", ";\n"])), CommentEditorMargin, CommentEditorMargin, CommentEditorMargin - _grid.GRID_GUTTER, CommentEditorMargin - _grid.GRID_GUTTER, CommentEditorMargin - _grid.GRID_GUTTER, _Toolbar2.TableControlsPadding, _commonStyles.tableCommentEditorStyles);
84
+ var ContentArea = (0, _styledComponents.default)(_ContentStyles.default)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n flex-grow: 1;\n overflow-x: hidden;\n overflow-y: auto;\n line-height: 24px;\n ", ";\n\n /** Hack for Bitbucket to ensure entire editorView gets drop event; see ED-3294 **/\n /** Hack for tables controlls. Otherwise marging collapse and controlls are misplaced. **/\n .ProseMirror {\n margin: 12px ", "px ", "px;\n }\n\n .gridParent {\n margin-left: ", "px;\n margin-right: ", "px;\n width: calc(100% + ", "px);\n }\n\n padding: ", "px;\n\n ", ";\n"])), function (props) {
85
+ return props.maxHeight ? 'max-height: ' + props.maxHeight + 'px;' : '';
86
+ }, CommentEditorMargin, CommentEditorMargin, CommentEditorMargin - _grid.GRID_GUTTER, CommentEditorMargin - _grid.GRID_GUTTER, CommentEditorMargin - _grid.GRID_GUTTER, _Toolbar2.TableControlsPadding, _commonStyles.tableCommentEditorStyles);
87
87
  ContentArea.displayName = 'ContentArea';
88
88
 
89
89
  var SecondaryToolbar = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n box-sizing: border-box;\n justify-content: flex-end;\n align-items: center;\n display: flex;\n padding: 12px 1px;\n"])));
@@ -173,7 +173,8 @@ var Editor = /*#__PURE__*/function (_React$Component) {
173
173
  },
174
174
  className: (0, _classnames.default)('ak-editor-content-area', {
175
175
  'less-margin': width < _editorSharedStyles.akEditorMobileBreakoutPoint
176
- })
176
+ }),
177
+ maxHeight: maxHeight
177
178
  }, customContentComponents, /*#__PURE__*/_react.default.createElement(_PluginSlot.default, {
178
179
  editorView: editorView,
179
180
  editorActions: editorActions,
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -8,40 +10,74 @@ exports.RenderTracking = RenderTracking;
8
10
 
9
11
  var _react = require("react");
10
12
 
13
+ var _debounce = _interopRequireDefault(require("lodash/debounce"));
14
+
11
15
  var _compare = require("../../compare");
12
16
 
13
17
  var _analytics = require("../../../plugins/analytics");
14
18
 
15
- function useComponentRenderTracking(props, action, actionSubject, handleAnalyticsEvent) {
16
- var propsToIgnore = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
17
- var useShallow = arguments.length > 5 ? arguments[5] : undefined;
19
+ function useComponentRenderTracking(_ref) {
20
+ var onRender = _ref.onRender,
21
+ propsDiffingOptions = _ref.propsDiffingOptions,
22
+ _ref$zeroBasedCount = _ref.zeroBasedCount,
23
+ zeroBasedCount = _ref$zeroBasedCount === void 0 ? true : _ref$zeroBasedCount;
18
24
  var propsRef = (0, _react.useRef)();
19
- var renderCountRef = (0, _react.useRef)(0);
25
+ var renderCountRef = (0, _react.useRef)(zeroBasedCount ? 0 : 1);
20
26
  (0, _react.useEffect)(function () {
21
27
  var lastProps = propsRef.current;
22
28
  var renderCount = renderCountRef.current;
29
+ var propsDifference;
23
30
 
24
- if (lastProps) {
25
- var difference = useShallow ? (0, _compare.getShallowPropsDifference)(lastProps, props) : (0, _compare.getPropsDifference)(lastProps, props, 0, 2, propsToIgnore);
26
- handleAnalyticsEvent({
27
- payload: {
28
- action: action,
29
- actionSubject: actionSubject,
30
- attributes: {
31
- propsDifference: difference,
32
- count: renderCount
33
- },
34
- eventType: _analytics.EVENT_TYPE.OPERATIONAL
35
- }
36
- });
31
+ if (propsDiffingOptions !== null && propsDiffingOptions !== void 0 && propsDiffingOptions.enabled && lastProps) {
32
+ propsDifference = propsDiffingOptions !== null && propsDiffingOptions !== void 0 && propsDiffingOptions.useShallow ? (0, _compare.getShallowPropsDifference)(lastProps, propsDiffingOptions.props) : (0, _compare.getPropsDifference)(lastProps, propsDiffingOptions.props, 0, 2, propsDiffingOptions === null || propsDiffingOptions === void 0 ? void 0 : propsDiffingOptions.propsToIgnore);
33
+ }
34
+
35
+ var result = {
36
+ renderCount: renderCount,
37
+ propsDifference: propsDifference
38
+ };
39
+ onRender(result);
40
+
41
+ if (propsDiffingOptions !== null && propsDiffingOptions !== void 0 && propsDiffingOptions.enabled) {
42
+ propsRef.current = propsDiffingOptions.props;
37
43
  }
38
44
 
39
- propsRef.current = props;
40
45
  renderCountRef.current = renderCountRef.current + 1;
41
46
  }); // No dependencies run on each render
42
47
  }
43
48
 
44
49
  function RenderTracking(props) {
45
- useComponentRenderTracking(props.componentProps, props.action, props.actionSubject, props.handleAnalyticsEvent, props.propsToIgnore, props.useShallow);
50
+ var debouncedHandleAnalyticsEvent = (0, _react.useMemo)(function () {
51
+ return (0, _debounce.default)(props.handleAnalyticsEvent, 500);
52
+ }, [props.handleAnalyticsEvent]);
53
+ useComponentRenderTracking({
54
+ onRender: function onRender(_ref2) {
55
+ var renderCount = _ref2.renderCount,
56
+ propsDifference = _ref2.propsDifference;
57
+
58
+ if (!renderCount) {
59
+ return;
60
+ }
61
+
62
+ debouncedHandleAnalyticsEvent({
63
+ payload: {
64
+ action: props.action,
65
+ actionSubject: props.actionSubject,
66
+ attributes: {
67
+ count: renderCount,
68
+ propsDifference: propsDifference
69
+ },
70
+ eventType: _analytics.EVENT_TYPE.OPERATIONAL
71
+ }
72
+ });
73
+ },
74
+ propsDiffingOptions: {
75
+ enabled: true,
76
+ props: props.componentProps,
77
+ propsToIgnore: props.propsToIgnore,
78
+ useShallow: props.useShallow
79
+ },
80
+ zeroBasedCount: true
81
+ });
46
82
  return null;
47
83
  }
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.nextMajorVersion = exports.version = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "150.0.0";
9
+ var version = "151.0.0";
10
10
  exports.version = version;
11
11
 
12
12
  var nextMajorVersion = function nextMajorVersion() {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "150.0.0",
3
+ "version": "151.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { Node } from 'prosemirror-model';
3
- import { TextSelection, Selection } from 'prosemirror-state';
3
+ import { TextSelection } from 'prosemirror-state';
4
4
  import { toJSON } from '../utils';
5
5
  import { processRawValue, isEmptyDocument } from '../utils/document';
6
6
  import { getEditorValueWithMedia, __temporaryFixForConfigPanel } from '../utils/action';
@@ -171,35 +171,13 @@ export default class EditorActions {
171
171
  return false;
172
172
  }
173
173
 
174
- const {
175
- state
176
- } = this.editorView;
177
- const {
178
- schema
179
- } = state;
180
- const content = processRawValue(schema, rawValue, undefined, undefined, this.contentTransformer, this.dispatchAnalyticsEvent);
181
-
182
- if (!content) {
183
- return false;
184
- } // In case of replacing a whole document, we only need a content of a top level node e.g. document.
185
-
186
-
187
- let tr = state.tr.replaceWith(0, state.doc.nodeSize - 2, content.content);
188
-
189
- if (!shouldScrollToBottom && !tr.selectionSet) {
190
- // Restore selection at start of document instead of the end.
191
- tr.setSelection(Selection.atStart(tr.doc));
192
- }
193
-
194
- if (shouldScrollToBottom) {
195
- tr = tr.scrollIntoView();
196
- }
197
-
198
- if (!shouldAddToHistory) {
199
- tr.setMeta('addToHistory', false);
174
+ if (this.eventDispatcher) {
175
+ this.eventDispatcher.emit('resetEditorState', {
176
+ doc: rawValue,
177
+ shouldScrollToBottom
178
+ });
200
179
  }
201
180
 
202
- this.editorView.dispatch(tr);
203
181
  return true;
204
182
  }
205
183
 
@@ -3,14 +3,20 @@ import React from 'react';
3
3
  import uuid from 'uuid';
4
4
  import memoizeOne from 'memoize-one';
5
5
  import { sniffUserBrowserExtensions } from '@atlaskit/editor-common';
6
+ import { ExperienceStore } from '@atlaskit/editor-common/ufo';
6
7
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '../plugins/analytics';
7
8
  import { editorAnalyticsChannel } from '../plugins/analytics/consts';
8
9
  import { getFeatureFlags } from '../plugins/feature-flags-context';
9
10
  import { getDocStructure } from '../utils/document-logger';
10
11
  import { WithEditorView } from './WithEditorView';
11
12
  export class ErrorBoundaryWithEditorView extends React.Component {
12
- constructor(...args) {
13
- super(...args);
13
+ // Memoizing this as react alternative suggestion of https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops
14
+ get featureFlags() {
15
+ return this.getFeatureFlags(this.props.editorView);
16
+ }
17
+
18
+ constructor(props) {
19
+ super(props);
14
20
 
15
21
  _defineProperty(this, "browserExtensions", undefined);
16
22
 
@@ -26,60 +32,48 @@ export class ErrorBoundaryWithEditorView extends React.Component {
26
32
  return getFeatureFlags(editorView.state);
27
33
  }));
28
34
 
29
- _defineProperty(this, "fireAnalytics", analyticsErrorPayload => {
35
+ _defineProperty(this, "sendErrorData", async analyticsErrorPayload => {
36
+ const product = await this.getProductName();
30
37
  const {
31
- createAnalyticsEvent
32
- } = this.props;
33
- this.getProductName().then(product => {
34
- if (createAnalyticsEvent) {
35
- const {
36
- error,
37
- errorInfo,
38
- errorStack
39
- } = analyticsErrorPayload;
40
- const sharedId = uuid();
41
- const event = {
42
- action: ACTION.EDITOR_CRASHED,
43
- actionSubject: ACTION_SUBJECT.EDITOR,
44
- eventType: EVENT_TYPE.OPERATIONAL,
45
- attributes: {
46
- product,
47
- browserInfo: window && window.navigator && window.navigator.userAgent ? window.navigator.userAgent : 'unknown',
48
- error: error,
49
- errorInfo,
50
- errorId: sharedId,
51
- browserExtensions: this.browserExtensions
52
- }
53
- }; // Add doc structure if the feature flag is on
54
-
55
- if (this.featureFlags.errorBoundaryDocStructure && this.props.editorView) {
56
- event.attributes.docStructure = getDocStructure(this.props.editorView.state.doc, {
57
- compact: true
58
- });
59
- }
60
-
61
- createAnalyticsEvent(event).fire(editorAnalyticsChannel);
62
- createAnalyticsEvent({
63
- action: ACTION.EDITOR_CRASHED_ADDITIONAL_INFORMATION,
64
- actionSubject: ACTION_SUBJECT.EDITOR,
65
- eventType: EVENT_TYPE.OPERATIONAL,
66
- attributes: {
67
- errorStack,
68
- errorId: sharedId
69
- }
70
- }).fire(editorAnalyticsChannel);
71
- } else {
72
- // eslint-disable-next-line no-console
73
- console.error('Editor Error Boundary: Missing `createAnalyticsEvent` prop.', {
74
- channel: editorAnalyticsChannel,
75
- product,
76
- error: analyticsErrorPayload
77
- });
38
+ error,
39
+ errorInfo,
40
+ errorStack
41
+ } = analyticsErrorPayload;
42
+ const sharedId = uuid();
43
+ const attributes = {
44
+ product,
45
+ browserInfo: window && window.navigator && window.navigator.userAgent ? window.navigator.userAgent : 'unknown',
46
+ error: error,
47
+ errorInfo,
48
+ errorId: sharedId,
49
+ browserExtensions: this.browserExtensions,
50
+ docStructure: this.featureFlags.errorBoundaryDocStructure && this.props.editorView ? getDocStructure(this.props.editorView.state.doc, {
51
+ compact: true
52
+ }) : undefined
53
+ };
54
+ this.fireAnalyticsEvent({
55
+ action: ACTION.EDITOR_CRASHED,
56
+ actionSubject: ACTION_SUBJECT.EDITOR,
57
+ eventType: EVENT_TYPE.OPERATIONAL,
58
+ attributes
59
+ });
60
+ this.fireAnalyticsEvent({
61
+ action: ACTION.EDITOR_CRASHED_ADDITIONAL_INFORMATION,
62
+ actionSubject: ACTION_SUBJECT.EDITOR,
63
+ eventType: EVENT_TYPE.OPERATIONAL,
64
+ attributes: {
65
+ errorStack,
66
+ errorId: sharedId
78
67
  }
79
- }).catch(e => {
80
- // eslint-disable-next-line no-console
81
- console.error('Failed to resolve product name from contextIdentifierProvider.', e);
82
68
  });
69
+
70
+ if (this.featureFlags.ufo && this.props.editorView) {
71
+ var _this$experienceStore;
72
+
73
+ (_this$experienceStore = this.experienceStore) === null || _this$experienceStore === void 0 ? void 0 : _this$experienceStore.failAll({ ...this.getExperienceMetadata(attributes),
74
+ errorStack
75
+ });
76
+ }
83
77
  });
84
78
 
85
79
  _defineProperty(this, "getProductName", async () => {
@@ -97,20 +91,39 @@ export class ErrorBoundaryWithEditorView extends React.Component {
97
91
 
98
92
  return 'atlaskit';
99
93
  });
100
- }
101
94
 
102
- get featureFlags() {
103
- return this.getFeatureFlags(this.props.editorView);
95
+ _defineProperty(this, "fireAnalyticsEvent", event => {
96
+ var _this$props$createAna, _this$props;
97
+
98
+ (_this$props$createAna = (_this$props = this.props).createAnalyticsEvent) === null || _this$props$createAna === void 0 ? void 0 : _this$props$createAna.call(_this$props, event).fire(editorAnalyticsChannel);
99
+ });
100
+
101
+ _defineProperty(this, "getExperienceMetadata", attributes => {
102
+ var _attributes$browserEx;
103
+
104
+ return {
105
+ browserInfo: attributes.browserInfo,
106
+ error: attributes.error.toString(),
107
+ errorInfo: {
108
+ componentStack: attributes.errorInfo.componentStack
109
+ },
110
+ errorId: attributes.errorId,
111
+ browserExtensions: (_attributes$browserEx = attributes.browserExtensions) === null || _attributes$browserEx === void 0 ? void 0 : _attributes$browserEx.toString(),
112
+ docStructure: attributes.docStructure
113
+ };
114
+ });
115
+
116
+ if (props.editorView) {
117
+ this.experienceStore = ExperienceStore.getInstance(props.editorView);
118
+ }
104
119
  }
105
120
 
106
121
  componentDidCatch(error, errorInfo) {
107
- // Log the error
108
- this.fireAnalytics({
122
+ this.sendErrorData({
109
123
  error: error.toString(),
110
124
  errorInfo,
111
125
  errorStack: error.stack
112
- }); //
113
- // // Update state to allow a re-render to attempt graceful recovery (in the event that
126
+ }); // // Update state to allow a re-render to attempt graceful recovery (in the event that
114
127
  // // the error was caused by a race condition or is intermittent)
115
128
 
116
129
  this.setState({