@atlaskit/editor-core 165.0.0 → 166.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 (181) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/cjs/actions/index.js +9 -0
  3. package/dist/cjs/create-editor/ReactEditorView.js +14 -6
  4. package/dist/cjs/create-editor/create-plugins-list.js +1 -2
  5. package/dist/cjs/editor.js +13 -0
  6. package/dist/cjs/event-dispatcher/index.js +9 -0
  7. package/dist/cjs/nodeviews/ReactNodeView.js +1 -11
  8. package/dist/cjs/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
  9. package/dist/cjs/plugins/analytics/types/enums.js +1 -0
  10. package/dist/cjs/plugins/base/pm-plugins/frozen-editor.js +128 -79
  11. package/dist/cjs/plugins/base/utils/input-latency-tracking.js +157 -0
  12. package/dist/cjs/plugins/card/styles.js +3 -1
  13. package/dist/cjs/plugins/code-block/styles.js +6 -4
  14. package/dist/cjs/plugins/collab-edit/plugin-state.js +23 -5
  15. package/dist/cjs/plugins/date/styles.js +3 -1
  16. package/dist/cjs/plugins/emoji/index.js +30 -34
  17. package/dist/cjs/plugins/emoji/nodeviews/emoji.js +12 -66
  18. package/dist/cjs/plugins/emoji/styles.js +3 -17
  19. package/dist/cjs/plugins/expand/ui/styles.js +2 -2
  20. package/dist/cjs/plugins/extension/ui/styles.js +3 -1
  21. package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +20 -22
  22. package/dist/cjs/plugins/hyperlink/pm-plugins/input-rule.js +1 -9
  23. package/dist/cjs/plugins/hyperlink/pm-plugins/keymap.js +1 -9
  24. package/dist/cjs/plugins/layout/styles.js +3 -1
  25. package/dist/cjs/plugins/list/commands/indent-list.js +5 -1
  26. package/dist/cjs/plugins/list/commands/outdent-list.js +5 -1
  27. package/dist/cjs/plugins/list/transforms.js +11 -3
  28. package/dist/cjs/plugins/media/styles.js +3 -1
  29. package/dist/cjs/plugins/mentions/index.js +10 -14
  30. package/dist/cjs/plugins/mentions/nodeviews/mention.js +15 -67
  31. package/dist/cjs/plugins/mentions/pm-plugins/main.js +19 -10
  32. package/dist/cjs/plugins/mentions/type-ahead/index.js +7 -2
  33. package/dist/cjs/plugins/panel/styles.js +3 -1
  34. package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +3 -1
  35. package/dist/cjs/plugins/rule/styles.js +3 -1
  36. package/dist/cjs/plugins/selection/utils.js +39 -23
  37. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +24 -0
  38. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  39. package/dist/cjs/plugins/table/ui/consts.js +6 -4
  40. package/dist/cjs/plugins/tasks-and-decisions/styles.js +3 -1
  41. package/dist/cjs/plugins/type-ahead/index.js +6 -2
  42. package/dist/cjs/plugins/unsupported-content/index.js +22 -10
  43. package/dist/cjs/plugins/unsupported-content/styles.js +4 -2
  44. package/dist/cjs/plugins/unsupported-content/unsupported-inline-node-view.js +21 -0
  45. package/dist/cjs/ui/Appearance/Chromeless.js +6 -3
  46. package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -4
  47. package/dist/cjs/ui/ChromeCollapsed/styles.js +3 -1
  48. package/dist/cjs/ui/ContentStyles/index.js +2 -2
  49. package/dist/cjs/version-wrapper.js +1 -1
  50. package/dist/cjs/version.json +1 -1
  51. package/dist/es2019/actions/index.js +12 -1
  52. package/dist/es2019/create-editor/ReactEditorView.js +14 -6
  53. package/dist/es2019/create-editor/create-plugins-list.js +1 -2
  54. package/dist/es2019/editor.js +14 -0
  55. package/dist/es2019/event-dispatcher/index.js +8 -0
  56. package/dist/es2019/nodeviews/ReactNodeView.js +1 -10
  57. package/dist/es2019/nodeviews/getInlineNodeViewProducer.styles.js +9 -0
  58. package/dist/es2019/plugins/analytics/types/enums.js +1 -0
  59. package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +138 -80
  60. package/dist/es2019/plugins/base/utils/input-latency-tracking.js +128 -0
  61. package/dist/es2019/plugins/card/styles.js +9 -5
  62. package/dist/es2019/plugins/code-block/styles.js +11 -8
  63. package/dist/es2019/plugins/collab-edit/plugin-state.js +23 -8
  64. package/dist/es2019/plugins/date/styles.js +3 -1
  65. package/dist/es2019/plugins/emoji/index.js +16 -21
  66. package/dist/es2019/plugins/emoji/nodeviews/emoji.js +12 -31
  67. package/dist/es2019/plugins/emoji/styles.js +1 -82
  68. package/dist/es2019/plugins/expand/ui/styles.js +2 -2
  69. package/dist/es2019/plugins/extension/ui/styles.js +4 -2
  70. package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +20 -22
  71. package/dist/es2019/plugins/hyperlink/pm-plugins/input-rule.js +1 -8
  72. package/dist/es2019/plugins/hyperlink/pm-plugins/keymap.js +1 -8
  73. package/dist/es2019/plugins/layout/styles.js +3 -2
  74. package/dist/es2019/plugins/list/commands/indent-list.js +4 -1
  75. package/dist/es2019/plugins/list/commands/outdent-list.js +4 -1
  76. package/dist/es2019/plugins/list/transforms.js +9 -4
  77. package/dist/es2019/plugins/media/styles.js +9 -7
  78. package/dist/es2019/plugins/mentions/index.js +1 -6
  79. package/dist/es2019/plugins/mentions/nodeviews/mention.js +16 -35
  80. package/dist/es2019/plugins/mentions/pm-plugins/main.js +18 -10
  81. package/dist/es2019/plugins/mentions/type-ahead/index.js +7 -2
  82. package/dist/es2019/plugins/panel/styles.js +5 -4
  83. package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +3 -1
  84. package/dist/es2019/plugins/rule/styles.js +2 -1
  85. package/dist/es2019/plugins/selection/utils.js +35 -20
  86. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +22 -0
  87. package/dist/es2019/plugins/table/ui/common-styles.js +4 -0
  88. package/dist/es2019/plugins/table/ui/consts.js +5 -4
  89. package/dist/es2019/plugins/tasks-and-decisions/styles.js +4 -2
  90. package/dist/es2019/plugins/type-ahead/index.js +5 -1
  91. package/dist/es2019/plugins/unsupported-content/index.js +23 -12
  92. package/dist/es2019/plugins/unsupported-content/styles.js +5 -3
  93. package/dist/es2019/plugins/unsupported-content/unsupported-inline-node-view.js +7 -0
  94. package/dist/es2019/ui/Appearance/Chromeless.js +5 -2
  95. package/dist/es2019/ui/Appearance/Comment/Comment.js +5 -2
  96. package/dist/es2019/ui/ChromeCollapsed/styles.js +2 -1
  97. package/dist/es2019/ui/ContentStyles/index.js +3 -3
  98. package/dist/es2019/version-wrapper.js +1 -1
  99. package/dist/es2019/version.json +1 -1
  100. package/dist/esm/actions/index.js +8 -0
  101. package/dist/esm/create-editor/ReactEditorView.js +14 -6
  102. package/dist/esm/create-editor/create-plugins-list.js +1 -2
  103. package/dist/esm/editor.js +14 -0
  104. package/dist/esm/event-dispatcher/index.js +9 -0
  105. package/dist/esm/nodeviews/ReactNodeView.js +1 -10
  106. package/dist/esm/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
  107. package/dist/esm/plugins/analytics/types/enums.js +1 -0
  108. package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +128 -79
  109. package/dist/esm/plugins/base/utils/input-latency-tracking.js +149 -0
  110. package/dist/esm/plugins/card/styles.js +2 -1
  111. package/dist/esm/plugins/code-block/styles.js +5 -4
  112. package/dist/esm/plugins/collab-edit/plugin-state.js +21 -6
  113. package/dist/esm/plugins/date/styles.js +2 -1
  114. package/dist/esm/plugins/emoji/index.js +26 -29
  115. package/dist/esm/plugins/emoji/nodeviews/emoji.js +11 -56
  116. package/dist/esm/plugins/emoji/styles.js +3 -14
  117. package/dist/esm/plugins/expand/ui/styles.js +2 -2
  118. package/dist/esm/plugins/extension/ui/styles.js +2 -1
  119. package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +20 -22
  120. package/dist/esm/plugins/hyperlink/pm-plugins/input-rule.js +1 -8
  121. package/dist/esm/plugins/hyperlink/pm-plugins/keymap.js +1 -8
  122. package/dist/esm/plugins/layout/styles.js +2 -1
  123. package/dist/esm/plugins/list/commands/indent-list.js +4 -1
  124. package/dist/esm/plugins/list/commands/outdent-list.js +4 -1
  125. package/dist/esm/plugins/list/transforms.js +9 -4
  126. package/dist/esm/plugins/media/styles.js +2 -1
  127. package/dist/esm/plugins/mentions/index.js +10 -14
  128. package/dist/esm/plugins/mentions/nodeviews/mention.js +13 -58
  129. package/dist/esm/plugins/mentions/pm-plugins/main.js +18 -10
  130. package/dist/esm/plugins/mentions/type-ahead/index.js +7 -2
  131. package/dist/esm/plugins/panel/styles.js +2 -1
  132. package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +3 -1
  133. package/dist/esm/plugins/rule/styles.js +2 -1
  134. package/dist/esm/plugins/selection/utils.js +35 -20
  135. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +23 -0
  136. package/dist/esm/plugins/table/ui/common-styles.js +1 -1
  137. package/dist/esm/plugins/table/ui/consts.js +5 -4
  138. package/dist/esm/plugins/tasks-and-decisions/styles.js +2 -1
  139. package/dist/esm/plugins/type-ahead/index.js +6 -2
  140. package/dist/esm/plugins/unsupported-content/index.js +21 -11
  141. package/dist/esm/plugins/unsupported-content/styles.js +3 -2
  142. package/dist/esm/plugins/unsupported-content/unsupported-inline-node-view.js +7 -0
  143. package/dist/esm/ui/Appearance/Chromeless.js +6 -3
  144. package/dist/esm/ui/Appearance/Comment/Comment.js +6 -4
  145. package/dist/esm/ui/ChromeCollapsed/styles.js +2 -1
  146. package/dist/esm/ui/ContentStyles/index.js +3 -3
  147. package/dist/esm/version-wrapper.js +1 -1
  148. package/dist/esm/version.json +1 -1
  149. package/dist/types/actions/index.d.ts +3 -1
  150. package/dist/types/editor.d.ts +3 -0
  151. package/dist/types/event-dispatcher/index.d.ts +1 -0
  152. package/dist/types/nodeviews/ReactNodeView.d.ts +1 -5
  153. package/dist/types/plugins/analytics/types/enums.d.ts +1 -0
  154. package/dist/types/plugins/analytics/types/events.d.ts +2 -2
  155. package/dist/types/plugins/analytics/types/general-events.d.ts +10 -1
  156. package/dist/types/plugins/base/utils/input-latency-tracking.d.ts +44 -0
  157. package/dist/types/plugins/collab-edit/plugin-state.d.ts +4 -0
  158. package/dist/types/plugins/emoji/index.d.ts +2 -6
  159. package/dist/types/plugins/emoji/nodeviews/emoji.d.ts +4 -14
  160. package/dist/types/plugins/emoji/styles.d.ts +0 -1
  161. package/dist/types/plugins/emoji/types.d.ts +0 -1
  162. package/dist/types/plugins/list/transforms.d.ts +10 -1
  163. package/dist/types/plugins/mentions/nodeviews/mention.d.ts +6 -14
  164. package/dist/types/plugins/mentions/pm-plugins/main.d.ts +2 -5
  165. package/dist/types/plugins/selection/utils.d.ts +7 -15
  166. package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +3 -0
  167. package/dist/types/plugins/table/ui/consts.d.ts +2 -2
  168. package/dist/types/plugins/type-ahead/types.d.ts +1 -0
  169. package/dist/types/plugins/unsupported-content/unsupported-inline-node-view.d.ts +11 -0
  170. package/dist/types/types/editor-appearance-component.d.ts +1 -0
  171. package/dist/types/types/editor-props.d.ts +1 -0
  172. package/dist/types/types/feature-flags.d.ts +0 -14
  173. package/dist/types/ui/Appearance/Chromeless.d.ts +1 -0
  174. package/dist/types/ui/Appearance/Comment/Comment.d.ts +1 -0
  175. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +4 -4
  176. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  177. package/package.json +22 -22
  178. package/dist/cjs/plugins/emoji/nodeviews/emoji-next.js +0 -250
  179. package/dist/es2019/plugins/emoji/nodeviews/emoji-next.js +0 -177
  180. package/dist/esm/plugins/emoji/nodeviews/emoji-next.js +0 -234
  181. package/dist/types/plugins/emoji/nodeviews/emoji-next.d.ts +0 -31
@@ -1,6 +1,7 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { SLI_EVENT_TYPE, SMART_EVENT_TYPE, buildSliPayload } from '@atlaskit/mention/resource';
3
- import mentionNodeView from '../nodeviews/mention';
3
+ import { getInlineNodeViewProducer } from '../../../nodeviews/getInlineNodeViewProducer';
4
+ import { MentionNodeView } from '../nodeviews/mention';
4
5
  import { mentionPluginKey } from './key';
5
6
  const ACTIONS = {
6
7
  SET_PROVIDER: 'SET_PROVIDER',
@@ -32,7 +33,7 @@ export const setContext = context => (state, dispatch) => {
32
33
 
33
34
  return true;
34
35
  };
35
- export function createMentionPlugin(dispatch, providerFactory, portalProviderAPI, eventDispatcher, fireEvent, options) {
36
+ export function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
36
37
  let mentionProvider;
37
38
 
38
39
  const sendAnalytics = (event, actionSubject, action, attributes) => {
@@ -63,14 +64,14 @@ export function createMentionPlugin(dispatch, providerFactory, portalProviderAPI
63
64
  newPluginState = { ...pluginState,
64
65
  mentionProvider: params.provider
65
66
  };
66
- dispatch(mentionPluginKey, newPluginState);
67
+ pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
67
68
  return newPluginState;
68
69
 
69
70
  case ACTIONS.SET_CONTEXT:
70
71
  newPluginState = { ...pluginState,
71
72
  contextIdentifierProvider: params.context
72
73
  };
73
- dispatch(mentionPluginKey, newPluginState);
74
+ pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
74
75
  return newPluginState;
75
76
  }
76
77
 
@@ -80,7 +81,14 @@ export function createMentionPlugin(dispatch, providerFactory, portalProviderAPI
80
81
  },
81
82
  props: {
82
83
  nodeViews: {
83
- mention: mentionNodeView(portalProviderAPI, eventDispatcher, providerFactory, options)
84
+ mention: getInlineNodeViewProducer({
85
+ pmPluginFactoryParams,
86
+ Component: MentionNodeView,
87
+ extraComponentProps: {
88
+ providerFactory: pmPluginFactoryParams.providerFactory,
89
+ options
90
+ }
91
+ })
84
92
  }
85
93
  },
86
94
 
@@ -117,13 +125,13 @@ export function createMentionPlugin(dispatch, providerFactory, portalProviderAPI
117
125
  return;
118
126
  };
119
127
 
120
- providerFactory.subscribe('mentionProvider', providerHandler);
121
- providerFactory.subscribe('contextIdentifierProvider', providerHandler);
128
+ pmPluginFactoryParams.providerFactory.subscribe('mentionProvider', providerHandler);
129
+ pmPluginFactoryParams.providerFactory.subscribe('contextIdentifierProvider', providerHandler);
122
130
  return {
123
131
  destroy() {
124
- if (providerFactory) {
125
- providerFactory.unsubscribe('mentionProvider', providerHandler);
126
- providerFactory.unsubscribe('contextIdentifierProvider', providerHandler);
132
+ if (pmPluginFactoryParams.providerFactory) {
133
+ pmPluginFactoryParams.providerFactory.unsubscribe('mentionProvider', providerHandler);
134
+ pmPluginFactoryParams.providerFactory.unsubscribe('contextIdentifierProvider', providerHandler);
127
135
  }
128
136
 
129
137
  if (mentionProvider) {
@@ -364,11 +364,16 @@ export const createTypeAheadConfig = ({
364
364
  dismiss({
365
365
  editorState,
366
366
  query,
367
- stats
367
+ stats,
368
+ wasItemInserted
368
369
  }) {
369
370
  firstQueryWithoutResults = null;
370
371
  const pickerElapsedTime = stats.startedAt ? Date.now() - stats.startedAt : 0;
371
- fireEvent(buildTypeAheadCancelPayload(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, query || ''));
372
+
373
+ if (!wasItemInserted) {
374
+ fireEvent(buildTypeAheadCancelPayload(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, query || ''));
375
+ }
376
+
372
377
  const pluginState = getMentionPluginState(editorState);
373
378
 
374
379
  if (pluginState !== null && pluginState !== void 0 && pluginState.mentionProvider) {
@@ -1,6 +1,7 @@
1
1
  import { css } from '@emotion/react';
2
2
  import { panelSharedStyles, PanelSharedCssClassName } from '@atlaskit/editor-common/panel';
3
3
  import { SelectionStyle, getSelectionStyles, akEditorDeleteBackground, akEditorDeleteBackgroundWithOpacity, akEditorDeleteBorder, akEditorSelectedBorderSize, akEditorDeleteIconColor, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
4
+ import { token } from '@atlaskit/tokens';
4
5
  export const panelStyles = props => css`
5
6
  .ProseMirror {
6
7
  .${PanelSharedCssClassName.prefix} {
@@ -10,10 +11,10 @@ export const panelStyles = props => css`
10
11
  &.danger {
11
12
  box-shadow: 0 0 0 ${akEditorSelectedBorderSize}px
12
13
  ${akEditorDeleteBorder};
13
- background-color: ${akEditorDeleteBackground} !important;
14
+ background-color: ${token('color.background.danger', akEditorDeleteBackground)} !important;
14
15
 
15
16
  .${PanelSharedCssClassName.icon} {
16
- color: ${akEditorDeleteIconColor} !important;
17
+ color: ${token('color.icon.danger', akEditorDeleteIconColor)} !important;
17
18
  }
18
19
  }
19
20
  }
@@ -25,10 +26,10 @@ export const panelStyles = props => css`
25
26
  /* Danger when nested node */
26
27
  .danger .${PanelSharedCssClassName.prefix} {
27
28
  &[data-panel-type] {
28
- background-color: ${akEditorDeleteBackgroundWithOpacity};
29
+ background-color: ${token('color.blanket.danger', akEditorDeleteBackgroundWithOpacity)};
29
30
 
30
31
  .${PanelSharedCssClassName.icon} {
31
- color: ${akEditorDeleteIconColor};
32
+ color: ${token('color.icon.danger', akEditorDeleteIconColor)};
32
33
  }
33
34
  }
34
35
  }
@@ -3,7 +3,9 @@ import { browser, ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
3
3
 
4
4
  const serializePlaceholderNode = node => {
5
5
  const element = document.createElement('span');
6
- element.classList.add('pm-placeholder');
6
+ element.classList.add('pm-placeholder'); // the inline node api test suite requires the following class name
7
+
8
+ element.classList.add('placeholderView-content-wrap');
7
9
 
8
10
  if (browser.gecko) {
9
11
  element.setAttribute('contenteditable', 'true');
@@ -1,6 +1,7 @@
1
1
  import { css } from '@emotion/react';
2
2
  import { ruleSharedStyles } from '@atlaskit/editor-common/styles';
3
3
  import { akEditorLineHeight, akEditorSelectedBorderColor, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
4
+ import { token } from '@atlaskit/tokens';
4
5
  export const ruleStyles = props => css`
5
6
  .ProseMirror {
6
7
  ${ruleSharedStyles(props)};
@@ -13,7 +14,7 @@ export const ruleStyles = props => css`
13
14
 
14
15
  &.${akEditorSelectedNodeClassName} {
15
16
  outline: none;
16
- background-color: ${akEditorSelectedBorderColor};
17
+ background-color: ${token('color.border.selected', akEditorSelectedBorderColor)};
17
18
  }
18
19
  }
19
20
  }
@@ -39,7 +39,7 @@ export const getDecorations = tr => {
39
39
  }
40
40
 
41
41
  if (tr.selection instanceof TextSelection || tr.selection instanceof AllSelection) {
42
- const decorations = getTopLevelNodesFromSelection(tr.selection, tr.doc).map(({
42
+ const decorations = getNodesToDecorateFromSelection(tr.selection, tr.doc).map(({
43
43
  node,
44
44
  pos
45
45
  }) => {
@@ -92,24 +92,17 @@ export function getCellSelectionAnalyticsPayload(state) {
92
92
  };
93
93
  }
94
94
  }
95
+ const topLevelBlockNodesThatHaveSelectionStyles = ['table', 'panel', 'expand', 'layoutSection', 'decisionList', 'decisionItem', 'codeBlock'];
95
96
  /**
96
- * Use `getTopLevelNodesFromSelection` to collect and return
97
- * a list of only the outermost nodes of the given/passed `Selection`. This
98
- * function will ignore `paragraph` and `text` node types when collecting
99
- * top-level nodes. It will also ignore any top-level nodes that don't
100
- * completely sit within the given `Selection`.
101
- *
102
- * For example, using the following document:
103
- * ```
104
- * doc(p('{<}one'), blockquote(p('hello')), p(expand({ title: 'two' })(p('three'))), p('four{>}'))))
105
- * ```
106
- * we would expect `getTopLevelNodesFromSelection` to return:
107
- * ```
108
- * [blockquote(p('hello')), expand({ title: 'two' })(p('three')))]
109
- * ```
97
+ * Use `getNodesToDecorateFromSelection` to collect and return
98
+ * a list of nodes within the Selection that should have Selection
99
+ * decorations applied. This allows selection styles to be added to
100
+ * nested nodes. It will ignore text nodes as decorations are
101
+ * applied natively and also ignore nodes that don't completely
102
+ * sit within the given `Selection`.
110
103
  */
111
104
 
112
- export const getTopLevelNodesFromSelection = (selection, doc) => {
105
+ export const getNodesToDecorateFromSelection = (selection, doc) => {
113
106
  const nodes = [];
114
107
 
115
108
  if (selection.from !== selection.to) {
@@ -118,14 +111,36 @@ export const getTopLevelNodesFromSelection = (selection, doc) => {
118
111
  to
119
112
  } = selection;
120
113
  doc.nodesBetween(from, to, (node, pos) => {
121
- const withinSelection = from <= pos && pos + node.nodeSize <= to;
122
-
123
- if (node && node.type.name !== 'paragraph' && !node.isText && withinSelection) {
114
+ const withinSelection = from <= pos && pos + node.nodeSize <= to; // The reason we need to check for these nodes is to stop
115
+ // traversing their children if they are within a selection -
116
+ // this is to prevent selection styles from being added to
117
+ // the children as well as the parent node.
118
+ // Example scenario is if an entire table has been selected
119
+ // we should not traverse its children so we can apply the
120
+ // selection styles to the table. But if an entire tableRow
121
+ // has been selected (but the parent table has not) we should
122
+ // traverse it as it could contain other nodes that need
123
+ // selection styles. I couldn’t see a clear way to differentiate
124
+ // without explicitly stating which nodes should be traversed
125
+ // and which shouldn’t.
126
+
127
+ const isTopLevelNodeThatHasSelectionStyles = topLevelBlockNodesThatHaveSelectionStyles.includes(node.type.name); // If the node is a top-level block node and completely sits within
128
+ // the selection, we do not recurse it's children to prevent selection
129
+ // styles being added to its child nodes. The expected behaviour
130
+ // is that selection styles are only added to the parent.
131
+
132
+ if (node && withinSelection && isTopLevelNodeThatHasSelectionStyles) {
133
+ nodes.push({
134
+ node,
135
+ pos
136
+ });
137
+ return false; // Otherwise we recurse the children and return them so we can apply
138
+ // selection styles. Text is handled by the browser.
139
+ } else if (node && withinSelection && !node.isText) {
124
140
  nodes.push({
125
141
  node,
126
142
  pos
127
143
  });
128
- return false;
129
144
  }
130
145
 
131
146
  return true;
@@ -9,6 +9,13 @@ import { syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '
9
9
  import { updateStickyState } from '../commands';
10
10
  import { getTop, getTree } from './dom';
11
11
  import { getFeatureFlags } from '../../../../feature-flags-context';
12
+ import debounce from 'lodash/debounce';
13
+ import throttle from 'lodash/throttle'; // limit scroll event calls
14
+
15
+ const HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200; // timeout for resetting the scroll class - if it’s too long then users won’t be able to click on the header cells,
16
+ // if too short it would trigger too many dom udpates.
17
+
18
+ const HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
12
19
  export const supportedHeaderRow = node => {
13
20
  const allHeaders = mapChildren(node, child => child.type.name === 'tableHeader').every(Boolean);
14
21
  const someMerged = mapChildren(node, child => child.attrs.rowspan || 0).some(rowspan => rowspan > 1);
@@ -33,6 +40,17 @@ export class TableRowNodeView {
33
40
 
34
41
  _defineProperty(this, "listening", false);
35
42
 
43
+ _defineProperty(this, "headerRowMouseScrollEnd", debounce(() => {
44
+ this.dom.classList.remove('no-pointer-events');
45
+ }, HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT));
46
+
47
+ _defineProperty(this, "headerRowMouseScroll", throttle(() => {
48
+ if (this.isSticky) {
49
+ this.dom.classList.add('no-pointer-events');
50
+ this.headerRowMouseScrollEnd();
51
+ }
52
+ }, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
53
+
36
54
  _defineProperty(this, "onScroll", () => {
37
55
  if (!this.tree) {
38
56
  return;
@@ -322,6 +340,8 @@ export class TableRowNodeView {
322
340
  this.eventDispatcher.on(widthPluginKey.key, this.onWidthPluginState);
323
341
  this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState);
324
342
  this.listening = true;
343
+ this.dom.addEventListener('wheel', this.headerRowMouseScroll.bind(this));
344
+ this.dom.addEventListener('touchmove', this.headerRowMouseScroll.bind(this));
325
345
  }
326
346
 
327
347
  unsubscribe() {
@@ -344,6 +364,8 @@ export class TableRowNodeView {
344
364
  this.eventDispatcher.off(widthPluginKey.key, this.onWidthPluginState);
345
365
  this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginState);
346
366
  this.listening = false;
367
+ this.dom.removeEventListener('wheel', this.headerRowMouseScroll);
368
+ this.dom.removeEventListener('touchmove', this.headerRowMouseScroll);
347
369
  } // initialize intersection observer to track if table is within scroll area
348
370
 
349
371
 
@@ -163,6 +163,10 @@ export const tableStyles = props => {
163
163
 
164
164
  box-shadow: 0 6px 4px -4px ${N40A};
165
165
  margin-left: -1px;
166
+
167
+ &.no-pointer-events {
168
+ pointer-events: none;
169
+ }
166
170
  }
167
171
 
168
172
  .${ClassName.TABLE_STICKY} .${ClassName.TABLE_STICKY_SHADOW} {
@@ -1,6 +1,7 @@
1
1
  import { B200, B300, B75, N0, N20, R50, R400, R75, DN400, N200, DN30 } from '@atlaskit/theme/colors';
2
2
  import { tableCellBorderWidth, tableMarginTop } from '@atlaskit/editor-common/styles';
3
3
  import { akEditorTableBorder, akEditorTableBorderDark, akEditorTableToolbar, akEditorTableToolbarDark, akEditorTableToolbarSize, akEditorUnitZIndex, akRichMediaResizeZIndex } from '@atlaskit/editor-shared-styles';
4
+ import { token } from '@atlaskit/tokens';
4
5
  import { RESIZE_HANDLE_AREA_DECORATION_GAP } from '../types';
5
6
  import { themed } from '@atlaskit/theme/components';
6
7
  /**
@@ -12,16 +13,16 @@ export const tableCellBackgroundColor = themed({
12
13
  dark: DN30
13
14
  });
14
15
  export const tableToolbarColor = themed({
15
- light: akEditorTableToolbar,
16
- dark: akEditorTableToolbarDark
16
+ light: token('color.background.neutral', akEditorTableToolbar),
17
+ dark: token('color.background.neutral', akEditorTableToolbarDark)
17
18
  });
18
19
  export const tableTextColor = themed({
19
20
  light: N200,
20
21
  dark: DN400
21
22
  });
22
23
  export const tableBorderColor = themed({
23
- light: akEditorTableBorder,
24
- dark: akEditorTableBorderDark
24
+ light: token('color.border', akEditorTableBorder),
25
+ dark: token('color.border', akEditorTableBorderDark)
25
26
  });
26
27
  export const tableFloatingControlsColor = N20;
27
28
  export const tableCellSelectedColor = B75;
@@ -1,6 +1,7 @@
1
1
  import { css } from '@emotion/react';
2
2
  import { TaskDecisionSharedCssClassName } from '@atlaskit/editor-common/styles';
3
3
  import { SelectionStyle, getSelectionStyles, akEditorDeleteBackgroundWithOpacity, akEditorDeleteBorder, akEditorSelectedBorderSize, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
4
+ import { token } from '@atlaskit/tokens';
4
5
  export const taskDecisionStyles = css`
5
6
  [data-decision-wrapper] {
6
7
  cursor: pointer;
@@ -15,8 +16,9 @@ export const taskDecisionStyles = css`
15
16
  .danger {
16
17
  .${TaskDecisionSharedCssClassName.DECISION_CONTAINER}.${akEditorSelectedNodeClassName}
17
18
  > div {
18
- box-shadow: 0 0 0 ${akEditorSelectedBorderSize}px ${akEditorDeleteBorder};
19
- background-color: ${akEditorDeleteBackgroundWithOpacity};
19
+ box-shadow: 0 0 0 ${akEditorSelectedBorderSize}px
20
+ ${token('color.border.danger', akEditorDeleteBorder)};
21
+ background-color: ${token('color.blanket.danger', akEditorDeleteBackgroundWithOpacity)};
20
22
  &::after {
21
23
  content: none; /* reset the Blanket selection style */
22
24
  }
@@ -180,6 +180,7 @@ const typeAheadPlugin = options => {
180
180
  },
181
181
 
182
182
  onEditorViewStateUpdated({
183
+ originalTransaction,
183
184
  oldEditorState,
184
185
  newEditorState
185
186
  }) {
@@ -199,10 +200,13 @@ const typeAheadPlugin = options => {
199
200
  const isANewHandler = oldTriggerHandler !== newTriggerHandler;
200
201
 
201
202
  if (oldTriggerHandler !== null && oldTriggerHandler !== void 0 && oldTriggerHandler.dismiss && isANewHandler) {
203
+ const typeAheadMessage = originalTransaction.getMeta(typeAheadPluginKey);
204
+ const wasItemInserted = typeAheadMessage && typeAheadMessage.action === 'INSERT_RAW_QUERY';
202
205
  oldTriggerHandler.dismiss({
203
206
  editorState: newEditorState,
204
207
  query: oldPluginState.query,
205
- stats: (oldPluginState.stats || new StatsModifier()).serialize()
208
+ stats: (oldPluginState.stats || new StatsModifier()).serialize(),
209
+ wasItemInserted
206
210
  });
207
211
  }
208
212
 
@@ -1,16 +1,19 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { PluginKey } from 'prosemirror-state';
3
3
  import { confluenceUnsupportedBlock, confluenceUnsupportedInline, unsupportedBlock, unsupportedInline, unsupportedMark, unsupportedNodeAttribute } from '@atlaskit/adf-schema';
4
- import { UnsupportedBlock, UnsupportedInline } from '@atlaskit/editor-common/ui';
4
+ import { UnsupportedBlock } from '@atlaskit/editor-common/ui';
5
+ import { UnsupportedInlineNodeView } from './unsupported-inline-node-view';
5
6
  import { ReactNodeView } from '../../nodeviews';
7
+ import { getInlineNodeViewProducer } from '../../nodeviews/getInlineNodeViewProducer';
6
8
  export const pluginKey = new PluginKey('unsupportedContentPlugin');
7
9
 
8
- const createPlugin = ({
9
- portalProviderAPI,
10
- eventDispatcher,
11
- dispatchAnalyticsEvent
12
- }) => {
10
+ const createPlugin = pmPluginFactoryParams => {
13
11
  const hasIntlContext = true;
12
+ const {
13
+ portalProviderAPI,
14
+ eventDispatcher,
15
+ dispatchAnalyticsEvent
16
+ } = pmPluginFactoryParams;
14
17
  return new SafePlugin({
15
18
  key: pluginKey,
16
19
  props: {
@@ -18,15 +21,23 @@ const createPlugin = ({
18
21
  confluenceUnsupportedBlock: ReactNodeView.fromComponent(UnsupportedBlock, portalProviderAPI, eventDispatcher, {
19
22
  dispatchAnalyticsEvent
20
23
  }, undefined, hasIntlContext),
21
- confluenceUnsupportedInline: ReactNodeView.fromComponent(UnsupportedInline, portalProviderAPI, eventDispatcher, {
22
- dispatchAnalyticsEvent
23
- }, undefined, hasIntlContext),
24
+ confluenceUnsupportedInline: getInlineNodeViewProducer({
25
+ pmPluginFactoryParams,
26
+ Component: UnsupportedInlineNodeView,
27
+ extraComponentProps: {
28
+ dispatchAnalyticsEvent
29
+ }
30
+ }),
24
31
  unsupportedBlock: ReactNodeView.fromComponent(UnsupportedBlock, portalProviderAPI, eventDispatcher, {
25
32
  dispatchAnalyticsEvent
26
33
  }, undefined, hasIntlContext),
27
- unsupportedInline: ReactNodeView.fromComponent(UnsupportedInline, portalProviderAPI, eventDispatcher, {
28
- dispatchAnalyticsEvent
29
- }, undefined, hasIntlContext)
34
+ unsupportedInline: getInlineNodeViewProducer({
35
+ pmPluginFactoryParams,
36
+ Component: UnsupportedInlineNodeView,
37
+ extraComponentProps: {
38
+ dispatchAnalyticsEvent
39
+ }
40
+ })
30
41
  }
31
42
  }
32
43
  });
@@ -1,10 +1,11 @@
1
1
  import { css } from '@emotion/react';
2
2
  import { SelectionStyle, getSelectionStyles, akEditorDeleteBackgroundWithOpacity, akEditorSelectedBorderSize, akEditorDeleteBorder, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
3
+ import { token } from '@atlaskit/tokens';
3
4
  export const UnsupportedSharedCssClassName = {
4
5
  BLOCK_CONTAINER: 'unsupportedBlockView-content-wrap',
5
6
  INLINE_CONTAINER: 'unsupportedInlineView-content-wrap'
6
7
  };
7
- const inlineUnsupportedSelector = `.${UnsupportedSharedCssClassName.INLINE_CONTAINER} > span`;
8
+ const inlineUnsupportedSelector = `.${UnsupportedSharedCssClassName.INLINE_CONTAINER} > span:nth-child(2)`;
8
9
  const blockUnsupportedSelector = `.${UnsupportedSharedCssClassName.BLOCK_CONTAINER} > div`;
9
10
  export const unsupportedStyles = css`
10
11
  ${blockUnsupportedSelector}, ${inlineUnsupportedSelector} {
@@ -19,8 +20,9 @@ export const unsupportedStyles = css`
19
20
  .danger {
20
21
  .${akEditorSelectedNodeClassName}${blockUnsupportedSelector},
21
22
  .${akEditorSelectedNodeClassName}${inlineUnsupportedSelector} {
22
- border: ${akEditorSelectedBorderSize}px solid ${akEditorDeleteBorder};
23
- background-color: ${akEditorDeleteBackgroundWithOpacity};
23
+ border: ${akEditorSelectedBorderSize}px solid
24
+ ${token('color.border.danger', akEditorDeleteBorder)};
25
+ background-color: ${token('color.blanket.danger', akEditorDeleteBackgroundWithOpacity)};
24
26
  }
25
27
  }
26
28
  `;
@@ -0,0 +1,7 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { jsx } from '@emotion/react';
4
+ import { UnsupportedInline } from '@atlaskit/editor-common/ui';
5
+ export const UnsupportedInlineNodeView = props => {
6
+ return jsx(UnsupportedInline, props);
7
+ };
@@ -12,7 +12,6 @@ import WithFlash from '../WithFlash';
12
12
  const chromelessEditor = css`
13
13
  line-height: 20px;
14
14
  height: auto;
15
- min-height: 30px;
16
15
 
17
16
  overflow-x: hidden;
18
17
  overflow-y: auto;
@@ -50,6 +49,7 @@ export default class Editor extends React.Component {
50
49
  contentComponents,
51
50
  customContentComponents,
52
51
  maxHeight,
52
+ minHeight = 30,
53
53
  popupsMountPoint,
54
54
  popupsBoundariesElement,
55
55
  popupsScrollableElement,
@@ -62,7 +62,10 @@ export default class Editor extends React.Component {
62
62
  }, jsx("div", {
63
63
  css: [chromelessEditor, maxHeight && css`
64
64
  max-height: ${maxHeight}px;
65
- `],
65
+ `, css`
66
+ min-height: ${minHeight}px;
67
+ `],
68
+ "data-testid": "chromeless-editor",
66
69
  ref: ref => this.containerElement = ref
67
70
  }, jsx(ContentArea, null, customContentComponents, jsx(PluginSlot, {
68
71
  editorView: editorView,
@@ -37,7 +37,7 @@ const commentEditorStyle = css`
37
37
  min-width: 272px;
38
38
  /* Border + Toolbar + Footer + (Paragraph + ((Parahraph + Margin) * (DefaultLines - 1)) */
39
39
  /* calc(2px + 40px + 24px + ( 20px + (32px * 2))) */
40
- min-height: 150px;
40
+
41
41
  height: auto;
42
42
  background-color: white;
43
43
  border: 1px solid ${N40};
@@ -117,6 +117,7 @@ class Editor extends React.Component {
117
117
  popupsBoundariesElement,
118
118
  popupsScrollableElement,
119
119
  maxHeight,
120
+ minHeight = 150,
120
121
  onSave,
121
122
  onCancel,
122
123
  disabled,
@@ -129,7 +130,9 @@ class Editor extends React.Component {
129
130
  return jsx(WithFlash, {
130
131
  animate: maxContentSizeReached
131
132
  }, jsx("div", {
132
- css: commentEditorStyle,
133
+ css: [commentEditorStyle, css`
134
+ min-height: ${minHeight}px;
135
+ `],
133
136
  className: "akEditor"
134
137
  }, jsx(MainToolbar, {
135
138
  useStickyToolbar: useStickyToolbar
@@ -2,11 +2,12 @@ import { css } from '@emotion/react';
2
2
  import { akEditorSubtleAccent, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
3
3
  import { borderRadius } from '@atlaskit/theme/constants';
4
4
  import { N300, N50 } from '@atlaskit/theme/colors';
5
+ import { token } from '@atlaskit/tokens';
5
6
  export const inputStyle = css`
6
7
  /* Normal .className gets overridden by input[type=text] hence this hack to produce input.className */
7
8
  input& {
8
9
  background-color: white;
9
- border: 1px solid ${akEditorSubtleAccent};
10
+ border: 1px solid ${token('color.border.input', akEditorSubtleAccent)};
10
11
  border-radius: ${borderRadius()}px;
11
12
  box-sizing: border-box;
12
13
  height: 40px;
@@ -17,7 +17,7 @@ import { layoutStyles } from '../../plugins/layout/styles';
17
17
  import { panelStyles } from '../../plugins/panel/styles';
18
18
  import { fakeCursorStyles } from '../../plugins/fake-text-cursor/styles';
19
19
  import { mentionsStyles } from '../../plugins/mentions/styles';
20
- import { emojiStyles, emojiStylesNext } from '../../plugins/emoji/styles';
20
+ import { emojiStyles } from '../../plugins/emoji/styles';
21
21
  import { textFormattingStyles } from '../../plugins/text-formatting/styles';
22
22
  import { placeholderTextStyles } from '../../plugins/placeholder-text/styles';
23
23
  import { gridStyles } from '../../plugins/grid/styles';
@@ -35,7 +35,7 @@ import { useFeatureFlags } from '../../plugins/feature-flags-context';
35
35
  import { InlineNodeViewSharedStyles } from '../../nodeviews/getInlineNodeViewProducer.styles';
36
36
 
37
37
  const contentStyles = props => {
38
- var _props$featureFlags, _props$featureFlags2;
38
+ var _props$featureFlags;
39
39
 
40
40
  return css`
41
41
  .ProseMirror {
@@ -89,7 +89,7 @@ const contentStyles = props => {
89
89
  ${panelStyles(props)}
90
90
  ${fakeCursorStyles}
91
91
  ${mentionsStyles}
92
- ${(_props$featureFlags2 = props.featureFlags) !== null && _props$featureFlags2 !== void 0 && _props$featureFlags2.nextEmojiNodeView ? emojiStylesNext : emojiStyles}
92
+ ${emojiStyles}
93
93
  ${tasksAndDecisionsStyles}
94
94
  ${gridStyles}
95
95
  ${linkStyles}
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "165.0.0";
2
+ export const version = "166.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": "165.0.0",
3
+ "version": "166.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -14,6 +14,7 @@ import { analyticsEventKey } from '@atlaskit/editor-common/utils';
14
14
  import { findNodePosWithLocalId } from '../plugins/extension/utils';
15
15
  import { getFeatureFlags } from '../plugins/feature-flags-context/get-feature-flags';
16
16
  import { getCollabProvider } from '../plugins/collab-edit/native-collab-provider-plugin';
17
+ import deprecationWarnings from '../utils/deprecation-warnings';
17
18
 
18
19
  var EditorActions = /*#__PURE__*/function () {
19
20
  function EditorActions() {
@@ -300,6 +301,13 @@ var EditorActions = /*#__PURE__*/function () {
300
301
  value: function replaceDocument(rawValue) {
301
302
  var shouldScrollToBottom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
302
303
  var shouldAddToHistory = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
304
+ deprecationWarnings('EditorActions.replaceDocument', {
305
+ shouldAddToHistory: shouldAddToHistory
306
+ }, [{
307
+ property: 'shouldAddToHistory',
308
+ description: '[ED-14158] EditorActions.replaceDocument does not use the shouldAddToHistory arg',
309
+ type: 'removed'
310
+ }]);
303
311
 
304
312
  if (!this.editorView || rawValue === undefined || rawValue === null) {
305
313
  return false;
@@ -580,11 +580,22 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
580
580
  config: _this.config,
581
581
  eventDispatcher: _this.eventDispatcher,
582
582
  transformer: _this.contentTransformer
583
- });
583
+ }); // Allows us to dispatch analytics within the plugin view.destory methods
584
+
585
+
586
+ var analyticsConnected = _this.eventDispatcher.has(analyticsEventKey, _this.handleAnalyticsEvent);
587
+
588
+ if (!analyticsConnected) {
589
+ _this.eventDispatcher.on(analyticsEventKey, _this.handleAnalyticsEvent);
590
+ }
584
591
 
585
592
  _this.view.destroy(); // Destroys the dom node & all node views
586
593
 
587
594
 
595
+ if (!analyticsConnected) {
596
+ _this.eventDispatcher.off(analyticsEventKey, _this.handleAnalyticsEvent);
597
+ }
598
+
588
599
  _this.view = undefined;
589
600
  }
590
601
  });
@@ -755,7 +766,6 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
755
766
  // This serves to avoid potential runtime exceptions which could arise
756
767
  // from an async dispatched transaction after it's unmounted.
757
768
  this.canDispatchTransactions = false;
758
- this.eventDispatcher.destroy();
759
769
  clearTimeout(this.focusTimeoutId);
760
770
 
761
771
  if (this.reliabilityInterval) {
@@ -774,11 +784,9 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
774
784
  state.destroy();
775
785
  }
776
786
  });
777
- } // this.view will be destroyed when React unmounts in handleEditorViewRef
778
-
787
+ }
779
788
 
780
- this.eventDispatcher.off(analyticsEventKey, this.handleAnalyticsEvent);
781
- this.eventDispatcher.off('resetEditorState', this.resetEditorState);
789
+ this.eventDispatcher.destroy(); // this.view will be destroyed when React unmounts in handleEditorViewRef
782
790
  } // Helper to allow tests to inject plugins directly
783
791
 
784
792
  }, {