@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
@@ -1,4 +1,3 @@
1
- import { defineMessages } from 'react-intl';
2
1
  import SuccessIcon from '@atlaskit/icon/glyph/editor/success';
3
2
  import InfoIcon from '@atlaskit/icon/glyph/editor/info';
4
3
  import NoteIcon from '@atlaskit/icon/glyph/editor/note';
@@ -16,44 +15,16 @@ import { findDomRefAtPos } from 'prosemirror-utils';
16
15
  import { DEFAULT_BORDER_COLOR } from '../../ui/ColorPalette/Palettes';
17
16
  import { PanelType } from '@atlaskit/adf-schema';
18
17
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID, withAnalytics } from '../analytics';
19
- export const messages = defineMessages({
20
- info: {
21
- id: 'fabric.editor.info',
22
- defaultMessage: 'Info',
23
- description: 'Panels provide a way to highlight text. The info panel has a blue background.'
24
- },
25
- note: {
26
- id: 'fabric.editor.note',
27
- defaultMessage: 'Note',
28
- description: 'Panels provide a way to highlight text. The note panel has a purple background.'
29
- },
30
- success: {
31
- id: 'fabric.editor.success',
32
- defaultMessage: 'Success',
33
- description: 'Panels provide a way to highlight text. The success panel has a green background.'
34
- },
35
- warning: {
36
- id: 'fabric.editor.warning',
37
- defaultMessage: 'Warning',
38
- description: 'Panels provide a way to highlight text. The warning panel has a yellow background.'
39
- },
40
- error: {
41
- id: 'fabric.editor.error',
42
- defaultMessage: 'Error',
43
- description: 'Panels provide a way to highlight text. The error panel has a red background.'
44
- },
45
- emoji: {
46
- id: 'fabric.editor.panel.emoji',
47
- defaultMessage: 'Add emoji',
48
- description: 'Select the panel icon'
49
- },
50
- backgroundColor: {
51
- id: 'fabric.editor.panel.backgroundColor',
52
- defaultMessage: 'Background color',
53
- description: 'Select the panel background color.'
54
- }
55
- });
56
- export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabled, providerFactory, activePanelType, activePanelColor, activePanelIcon) => {
18
+ import { messages } from './message';
19
+ export const panelIconMap = {
20
+ [PanelType.INFO]: ':info:',
21
+ [PanelType.NOTE]: ':note:',
22
+ [PanelType.WARNING]: ':warning:',
23
+ [PanelType.ERROR]: ':error:',
24
+ [PanelType.SUCCESS]: ':success:',
25
+ [PanelType.TIP]: ':tip:'
26
+ };
27
+ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabled, isCustomPanelEditable, providerFactory, activePanelType, activePanelColor, activePanelIcon) => {
57
28
  const items = [{
58
29
  id: 'editor.panel.info',
59
30
  type: 'button',
@@ -100,10 +71,16 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
100
71
  }
101
72
 
102
73
  let previousColor = panelNode.node.attrs.panelColor || getPanelTypeBackground(panelNode.node.attrs.panelType);
74
+ const emojiInfo = panelNode.node.attrs.panelType;
75
+ const panelInfo = panelIconMap[emojiInfo];
76
+ const previousEmoji = panelInfo ? {
77
+ emoji: panelInfo
78
+ } : {};
103
79
 
104
80
  if (previousColor === color) {
105
81
  changePanelType(PanelType.CUSTOM, {
106
- color
82
+ color,
83
+ ...previousEmoji
107
84
  }, isCustomPanelEnabled)(state, dispatch);
108
85
  return false;
109
86
  }
@@ -119,7 +96,8 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
119
96
  eventType: EVENT_TYPE.TRACK
120
97
  };
121
98
  withAnalytics(payload)(changePanelType(PanelType.CUSTOM, {
122
- color
99
+ color,
100
+ ...previousEmoji
123
101
  }, isCustomPanelEnabled))(state, dispatch);
124
102
  return false;
125
103
  };
@@ -188,35 +166,38 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
188
166
  value: panelColor,
189
167
  border: DEFAULT_BORDER_COLOR
190
168
  };
191
- const colorPicker = {
192
- id: 'editor.panel.colorPicker',
193
- title: formatMessage(messages.backgroundColor),
194
- type: 'select',
195
- selectType: 'color',
196
- defaultValue: defaultPalette,
197
- options: panelBackgroundPalette,
198
- onChange: option => changeColor(option.value)
199
- };
200
- const emojiPicker = {
201
- id: 'editor.panel.emojiPicker',
202
- title: formatMessage(messages.emoji),
203
- type: 'select',
204
- selectType: 'emoji',
205
- options: [],
206
- selected: activePanelType === PanelType.CUSTOM && !!activePanelIcon,
207
- onChange: emojiShortName => changeEmoji(emojiShortName)
208
- };
209
- const removeEmojiButton = {
210
- id: 'editor.panel.removeEmoji',
211
- type: 'button',
212
- icon: RemoveEmojiIcon,
213
- onClick: removeEmoji(),
214
- title: formatMessage(commonMessages.removeEmoji),
215
- disabled: activePanelIcon ? false : true
216
- };
217
- items.push(emojiPicker, removeEmojiButton, {
218
- type: 'separator'
219
- }, colorPicker);
169
+
170
+ if (isCustomPanelEditable) {
171
+ const colorPicker = {
172
+ id: 'editor.panel.colorPicker',
173
+ title: formatMessage(messages.backgroundColor),
174
+ type: 'select',
175
+ selectType: 'color',
176
+ defaultValue: defaultPalette,
177
+ options: panelBackgroundPalette,
178
+ onChange: option => changeColor(option.value)
179
+ };
180
+ const emojiPicker = {
181
+ id: 'editor.panel.emojiPicker',
182
+ title: formatMessage(messages.emoji),
183
+ type: 'select',
184
+ selectType: 'emoji',
185
+ options: [],
186
+ selected: activePanelType === PanelType.CUSTOM && !!activePanelIcon,
187
+ onChange: emojiShortName => changeEmoji(emojiShortName)
188
+ };
189
+ const removeEmojiButton = {
190
+ id: 'editor.panel.removeEmoji',
191
+ type: 'button',
192
+ icon: RemoveEmojiIcon,
193
+ onClick: removeEmoji(),
194
+ title: formatMessage(commonMessages.removeEmoji),
195
+ disabled: activePanelIcon ? false : true
196
+ };
197
+ items.push(emojiPicker, removeEmojiButton, {
198
+ type: 'separator'
199
+ }, colorPicker);
200
+ }
220
201
  }
221
202
 
222
203
  items.push({
@@ -249,7 +230,7 @@ export const getToolbarConfig = (state, intl, options = {}, providerFactory) =>
249
230
  panelIcon
250
231
  } = panelObject.node.attrs; // force toolbar to be turned on
251
232
 
252
- const items = getToolbarItems(formatMessage, nodeType, options.UNSAFE_allowCustomPanel || false, providerFactory, panelType, options.UNSAFE_allowCustomPanel ? panelColor : undefined, options.UNSAFE_allowCustomPanel ? panelIcon : undefined);
233
+ const items = getToolbarItems(formatMessage, nodeType, options.UNSAFE_allowCustomPanel || false, options.UNSAFE_allowCustomPanel && options.UNSAFE_allowCustomPanelEdit || false, providerFactory, panelType, options.UNSAFE_allowCustomPanel ? panelColor : undefined, options.UNSAFE_allowCustomPanel ? panelIcon : undefined);
253
234
 
254
235
  const getDomRef = editorView => {
255
236
  const domAtPos = editorView.domAtPos.bind(editorView);
@@ -21,7 +21,7 @@ export const panelAttrsToDom = (attrs, allowCustomPanel) => {
21
21
  'data-panel-type': panelType || PanelType.INFO,
22
22
  style
23
23
  };
24
- const iconSpan = ['span', {
24
+ const iconDiv = ['div', {
25
25
  class: PanelSharedCssClassName.icon
26
26
  }];
27
27
  const contentDiv = ['div', {
@@ -29,7 +29,7 @@ export const panelAttrsToDom = (attrs, allowCustomPanel) => {
29
29
  }, 0];
30
30
 
31
31
  if (hasIcon) {
32
- return ['div', panelAttrs, iconSpan, contentDiv];
32
+ return ['div', panelAttrs, iconDiv, contentDiv];
33
33
  } else {
34
34
  return ['div', panelAttrs, contentDiv];
35
35
  }
@@ -1,5 +1,5 @@
1
- import LinkifyIt from 'linkify-it';
2
- import { linkifyMatch } from '../hyperlink/utils'; // modified version of the original Linkify plugin
1
+ import { linkifyMatch } from '@atlaskit/adf-schema';
2
+ import LinkifyIt from 'linkify-it'; // modified version of the original Linkify plugin
3
3
  // https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js
4
4
 
5
5
  const arrayReplaceAt = (src, pos, newElements) => {
@@ -3,6 +3,8 @@ import { StatusSharedCssClassName } from '@atlaskit/editor-common';
3
3
  import { SelectionStyle, getSelectionStyles, akEditorDeleteBackgroundWithOpacity, akEditorDeleteBorder, akEditorSelectedBorderSize, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
4
4
  export const statusStyles = css`
5
5
  .${StatusSharedCssClassName.STATUS_CONTAINER} {
6
+ display: inline-block;
7
+
6
8
  > span {
7
9
  display: inline-block;
8
10
  cursor: pointer;
@@ -462,10 +462,26 @@ export class TableRowNodeView {
462
462
  * so it should be safe to ignore mutations that we cause
463
463
  * by updating styles and classnames on this DOM element
464
464
  *
465
- * Update: should allow mutations for row selection to avoid known issue with table selection highlight in firefox
465
+ * Update: should not ignore mutations for row selection to avoid known issue with table selection highlight in firefox
466
466
  * Related bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1289673
467
467
  * */
468
- return !(mutationRecord.type === 'selection' && mutationRecord.target.tagName === 'TR');
468
+ const isTableSelection = mutationRecord.type === 'selection' && mutationRecord.target.nodeName === 'TR';
469
+ /**
470
+ * Update: should not ignore mutations when an node is added, as this interferes with
471
+ * prosemirrors handling of some language inputs in Safari (ie. Pinyin, Hiragana).
472
+ *
473
+ * In paticular, when a composition occurs at the start of the first node inside a table cell, if the resulting mutation
474
+ * from the composition end is ignored than prosemirror will end up with; invalid table markup nesting and a misplaced
475
+ * selection and insertion.
476
+ */
477
+
478
+ const isNodeInsertion = mutationRecord.type === 'childList' && mutationRecord.target.nodeName === 'TR' && mutationRecord.addedNodes.length;
479
+
480
+ if (isTableSelection || isNodeInsertion) {
481
+ return false;
482
+ }
483
+
484
+ return true;
469
485
  }
470
486
  /* receive external events */
471
487
 
@@ -17,7 +17,24 @@ export const openTypeAheadAtCursor = ({
17
17
  const {
18
18
  selection
19
19
  } = tr;
20
- const isTextRangeSelection = selection instanceof TextSelection && selection.$cursor === null;
21
- const nextTr = isTextRangeSelection ? tr.deleteSelection() : tr;
22
- return nextTr;
20
+
21
+ if (!(selection instanceof TextSelection)) {
22
+ return tr;
23
+ }
24
+
25
+ if (!selection.$cursor) {
26
+ tr.deleteSelection();
27
+ return tr;
28
+ } // Search & Destroy placeholder
29
+
30
+
31
+ const cursorPos = selection.$cursor.pos;
32
+ const nodeAtCursor = tr.doc.nodeAt(cursorPos);
33
+ const isPlaceholderAtCursorPosition = nodeAtCursor && nodeAtCursor.type.name === 'placeholder';
34
+
35
+ if (nodeAtCursor && isPlaceholderAtCursorPosition) {
36
+ tr.delete(cursorPos, cursorPos + nodeAtCursor.nodeSize);
37
+ }
38
+
39
+ return tr;
23
40
  };
@@ -0,0 +1,60 @@
1
+ import React, { useRef } from 'react';
2
+ import uuid from 'uuid';
3
+ import { useComponentRenderTracking } from '../utils/react-hooks/use-component-renderer-tracking';
4
+ import { RenderCountProfiler as RenderCountProfilerClass } from '@atlaskit/editor-common';
5
+ export let ProfiledComponentIds;
6
+
7
+ (function (ProfiledComponentIds) {
8
+ ProfiledComponentIds["editor"] = "Editor";
9
+ ProfiledComponentIds["appearance"] = "FullPageEditor";
10
+ ProfiledComponentIds["reactEditorView"] = "ReactEditorView";
11
+ ProfiledComponentIds["contentArea"] = "FullPageContentArea";
12
+ ProfiledComponentIds["toolbar"] = "FullPageToolbar";
13
+ ProfiledComponentIds["mention"] = "MentionNodeView";
14
+ })(ProfiledComponentIds || (ProfiledComponentIds = {}));
15
+
16
+ const CoreRenderCountProfiler = ({
17
+ componentId
18
+ }) => {
19
+ const {
20
+ current: instanceId
21
+ } = useRef(uuid());
22
+
23
+ const onRender = ({
24
+ renderCount
25
+ }) => {
26
+ const profiler = RenderCountProfilerClass.getInstance({
27
+ store: window
28
+ });
29
+ profiler.setRenderCount({
30
+ componentId,
31
+ instanceId,
32
+ renderCount
33
+ });
34
+ };
35
+
36
+ useComponentRenderTracking({
37
+ onRender,
38
+ propsDiffingOptions: {
39
+ enabled: false
40
+ },
41
+ zeroBasedCount: false
42
+ });
43
+ return null;
44
+ };
45
+
46
+ export const RenderCountProfiler = ({
47
+ componentId
48
+ }) => {
49
+ const profiler = RenderCountProfilerClass.getInstance({
50
+ store: window
51
+ });
52
+
53
+ if (profiler.isEnabled()) {
54
+ return /*#__PURE__*/React.createElement(CoreRenderCountProfiler, {
55
+ componentId: componentId
56
+ });
57
+ }
58
+
59
+ return null;
60
+ };
@@ -37,7 +37,7 @@ const CommentEditor = styled.div`
37
37
  /* calc(2px + 40px + 24px + ( 20px + (32px * 2))) */
38
38
  min-height: 150px;
39
39
  height: auto;
40
- ${props => props.maxHeight ? 'max-height: ' + props.maxHeight + 'px;' : ''} background-color: white;
40
+ background-color: white;
41
41
  border: 1px solid ${N40};
42
42
  box-sizing: border-box;
43
43
  border-radius: ${borderRadius()}px;
@@ -51,6 +51,7 @@ const ContentArea = styled(ContentStyles)`
51
51
  overflow-x: hidden;
52
52
  overflow-y: auto;
53
53
  line-height: 24px;
54
+ ${props => props.maxHeight ? 'max-height: ' + props.maxHeight + 'px;' : ''};
54
55
 
55
56
  /** Hack for Bitbucket to ensure entire editorView gets drop event; see ED-3294 **/
56
57
  /** Hack for tables controlls. Otherwise marging collapse and controlls are misplaced. **/
@@ -155,7 +156,8 @@ class Editor extends React.Component {
155
156
  innerRef: ref => this.containerElement = ref,
156
157
  className: classnames('ak-editor-content-area', {
157
158
  'less-margin': width < akEditorMobileBreakoutPoint
158
- })
159
+ }),
160
+ maxHeight: maxHeight
159
161
  }, customContentComponents, /*#__PURE__*/React.createElement(PluginSlot, {
160
162
  editorView: editorView,
161
163
  editorActions: editorActions,
@@ -1,33 +1,66 @@
1
- import { useEffect, useRef } from 'react';
1
+ import { useMemo, useEffect, useRef } from 'react';
2
+ import debounce from 'lodash/debounce';
2
3
  import { getShallowPropsDifference, getPropsDifference } from '../../compare';
3
4
  import { EVENT_TYPE } from '../../../plugins/analytics';
4
- export function useComponentRenderTracking(props, action, actionSubject, handleAnalyticsEvent, propsToIgnore = [], useShallow) {
5
+ export function useComponentRenderTracking({
6
+ onRender,
7
+ propsDiffingOptions,
8
+ zeroBasedCount = true
9
+ }) {
5
10
  const propsRef = useRef();
6
- const renderCountRef = useRef(0);
11
+ const renderCountRef = useRef(zeroBasedCount ? 0 : 1);
7
12
  useEffect(() => {
8
13
  const lastProps = propsRef.current;
9
14
  const renderCount = renderCountRef.current;
15
+ let propsDifference;
10
16
 
11
- if (lastProps) {
12
- let difference = useShallow ? getShallowPropsDifference(lastProps, props) : getPropsDifference(lastProps, props, 0, 2, propsToIgnore);
13
- handleAnalyticsEvent({
14
- payload: {
15
- action,
16
- actionSubject,
17
- attributes: {
18
- propsDifference: difference,
19
- count: renderCount
20
- },
21
- eventType: EVENT_TYPE.OPERATIONAL
22
- }
23
- });
17
+ if (propsDiffingOptions !== null && propsDiffingOptions !== void 0 && propsDiffingOptions.enabled && lastProps) {
18
+ propsDifference = propsDiffingOptions !== null && propsDiffingOptions !== void 0 && propsDiffingOptions.useShallow ? getShallowPropsDifference(lastProps, propsDiffingOptions.props) : getPropsDifference(lastProps, propsDiffingOptions.props, 0, 2, propsDiffingOptions === null || propsDiffingOptions === void 0 ? void 0 : propsDiffingOptions.propsToIgnore);
19
+ }
20
+
21
+ const result = {
22
+ renderCount,
23
+ propsDifference
24
+ };
25
+ onRender(result);
26
+
27
+ if (propsDiffingOptions !== null && propsDiffingOptions !== void 0 && propsDiffingOptions.enabled) {
28
+ propsRef.current = propsDiffingOptions.props;
24
29
  }
25
30
 
26
- propsRef.current = props;
27
31
  renderCountRef.current = renderCountRef.current + 1;
28
32
  }); // No dependencies run on each render
29
33
  }
30
34
  export function RenderTracking(props) {
31
- useComponentRenderTracking(props.componentProps, props.action, props.actionSubject, props.handleAnalyticsEvent, props.propsToIgnore, props.useShallow);
35
+ const debouncedHandleAnalyticsEvent = useMemo(() => debounce(props.handleAnalyticsEvent, 500), [props.handleAnalyticsEvent]);
36
+ useComponentRenderTracking({
37
+ onRender: ({
38
+ renderCount,
39
+ propsDifference
40
+ }) => {
41
+ if (!renderCount) {
42
+ return;
43
+ }
44
+
45
+ debouncedHandleAnalyticsEvent({
46
+ payload: {
47
+ action: props.action,
48
+ actionSubject: props.actionSubject,
49
+ attributes: {
50
+ count: renderCount,
51
+ propsDifference: propsDifference
52
+ },
53
+ eventType: EVENT_TYPE.OPERATIONAL
54
+ }
55
+ });
56
+ },
57
+ propsDiffingOptions: {
58
+ enabled: true,
59
+ props: props.componentProps,
60
+ propsToIgnore: props.propsToIgnore,
61
+ useShallow: props.useShallow
62
+ },
63
+ zeroBasedCount: true
64
+ });
32
65
  return null;
33
66
  }
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "150.0.0";
2
+ export const version = "151.0.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -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
  }
@@ -4,7 +4,7 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
4
  import _createClass from "@babel/runtime/helpers/createClass";
5
5
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
6
  import { Node } from 'prosemirror-model';
7
- import { TextSelection, Selection } from 'prosemirror-state';
7
+ import { TextSelection } from 'prosemirror-state';
8
8
  import { toJSON } from '../utils';
9
9
  import { processRawValue, isEmptyDocument } from '../utils/document';
10
10
  import { getEditorValueWithMedia, __temporaryFixForConfigPanel as _temporaryFixForConfigPanel } from '../utils/action';
@@ -244,31 +244,13 @@ var EditorActions = /*#__PURE__*/function () {
244
244
  return false;
245
245
  }
246
246
 
247
- var state = this.editorView.state;
248
- var schema = state.schema;
249
- var content = processRawValue(schema, rawValue, undefined, undefined, this.contentTransformer, this.dispatchAnalyticsEvent);
250
-
251
- if (!content) {
252
- return false;
253
- } // In case of replacing a whole document, we only need a content of a top level node e.g. document.
254
-
255
-
256
- var tr = state.tr.replaceWith(0, state.doc.nodeSize - 2, content.content);
257
-
258
- if (!shouldScrollToBottom && !tr.selectionSet) {
259
- // Restore selection at start of document instead of the end.
260
- tr.setSelection(Selection.atStart(tr.doc));
261
- }
262
-
263
- if (shouldScrollToBottom) {
264
- tr = tr.scrollIntoView();
265
- }
266
-
267
- if (!shouldAddToHistory) {
268
- tr.setMeta('addToHistory', false);
247
+ if (this.eventDispatcher) {
248
+ this.eventDispatcher.emit('resetEditorState', {
249
+ doc: rawValue,
250
+ shouldScrollToBottom: shouldScrollToBottom
251
+ });
269
252
  }
270
253
 
271
- this.editorView.dispatch(tr);
272
254
  return true;
273
255
  }
274
256
  }, {