@atlaskit/editor-core 187.9.0 → 187.10.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 (154) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/commands/index.js +8 -134
  3. package/dist/cjs/plugins/base/index.js +2 -2
  4. package/dist/cjs/plugins/block-type/commands/block-type.js +34 -36
  5. package/dist/cjs/plugins/block-type/commands/transform-to-code-block.js +1 -2
  6. package/dist/cjs/plugins/block-type/index.js +16 -13
  7. package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +19 -18
  8. package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +12 -14
  9. package/dist/cjs/plugins/block-type/pm-plugins/main.js +9 -9
  10. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +7 -7
  11. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +3 -4
  12. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +13 -5
  13. package/dist/cjs/plugins/block-type/utils.js +73 -2
  14. package/dist/cjs/plugins/caption/pm-plugins/keymap.js +2 -2
  15. package/dist/cjs/plugins/emoji/commands/insert-emoji.js +31 -28
  16. package/dist/cjs/plugins/emoji/index.js +4 -3
  17. package/dist/cjs/plugins/emoji/pm-plugins/ascii-input-rules.js +23 -18
  18. package/dist/cjs/plugins/extension/pm-plugins/main.js +54 -9
  19. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +1 -1
  20. package/dist/cjs/plugins/media/utils/media-common.js +5 -5
  21. package/dist/cjs/plugins/selection/pm-plugins/events/keydown.js +61 -25
  22. package/dist/cjs/plugins/undo-redo/pm-plugins/keymaps.js +2 -2
  23. package/dist/cjs/ui/styles.js +4 -11
  24. package/dist/cjs/utils/index.js +4 -80
  25. package/dist/cjs/utils/input-rules.js +6 -66
  26. package/dist/cjs/utils/mark.js +2 -38
  27. package/dist/cjs/version-wrapper.js +1 -1
  28. package/dist/cjs/version.json +1 -1
  29. package/dist/es2019/commands/index.js +1 -128
  30. package/dist/es2019/plugins/base/index.js +1 -1
  31. package/dist/es2019/plugins/block-type/commands/block-type.js +11 -13
  32. package/dist/es2019/plugins/block-type/commands/transform-to-code-block.js +1 -2
  33. package/dist/es2019/plugins/block-type/index.js +21 -12
  34. package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +18 -18
  35. package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +8 -9
  36. package/dist/es2019/plugins/block-type/pm-plugins/main.js +9 -9
  37. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -2
  38. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +2 -3
  39. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +21 -2
  40. package/dist/es2019/plugins/block-type/utils.js +70 -1
  41. package/dist/es2019/plugins/caption/pm-plugins/keymap.js +1 -1
  42. package/dist/es2019/plugins/emoji/commands/insert-emoji.js +5 -5
  43. package/dist/es2019/plugins/emoji/index.js +6 -3
  44. package/dist/es2019/plugins/emoji/pm-plugins/ascii-input-rules.js +14 -11
  45. package/dist/es2019/plugins/extension/pm-plugins/main.js +50 -0
  46. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +1 -1
  47. package/dist/es2019/plugins/media/utils/media-common.js +1 -1
  48. package/dist/es2019/plugins/selection/pm-plugins/events/keydown.js +60 -24
  49. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -1
  50. package/dist/es2019/plugins/undo-redo/pm-plugins/keymaps.js +1 -1
  51. package/dist/es2019/ui/styles.js +0 -16
  52. package/dist/es2019/utils/index.js +0 -80
  53. package/dist/es2019/utils/input-rules.js +4 -61
  54. package/dist/es2019/utils/mark.js +0 -33
  55. package/dist/es2019/version-wrapper.js +1 -1
  56. package/dist/es2019/version.json +1 -1
  57. package/dist/esm/commands/index.js +7 -125
  58. package/dist/esm/plugins/base/index.js +1 -1
  59. package/dist/esm/plugins/block-type/commands/block-type.js +11 -13
  60. package/dist/esm/plugins/block-type/commands/transform-to-code-block.js +1 -2
  61. package/dist/esm/plugins/block-type/index.js +15 -12
  62. package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +18 -18
  63. package/dist/esm/plugins/block-type/pm-plugins/keymap.js +8 -9
  64. package/dist/esm/plugins/block-type/pm-plugins/main.js +9 -9
  65. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -2
  66. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +2 -3
  67. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +8 -4
  68. package/dist/esm/plugins/block-type/utils.js +69 -1
  69. package/dist/esm/plugins/caption/pm-plugins/keymap.js +1 -1
  70. package/dist/esm/plugins/emoji/commands/insert-emoji.js +29 -27
  71. package/dist/esm/plugins/emoji/index.js +4 -3
  72. package/dist/esm/plugins/emoji/pm-plugins/ascii-input-rules.js +23 -18
  73. package/dist/esm/plugins/extension/pm-plugins/main.js +45 -0
  74. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +1 -1
  75. package/dist/esm/plugins/media/utils/media-common.js +1 -1
  76. package/dist/esm/plugins/selection/pm-plugins/events/keydown.js +62 -25
  77. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -1
  78. package/dist/esm/plugins/undo-redo/pm-plugins/keymaps.js +1 -1
  79. package/dist/esm/ui/styles.js +3 -6
  80. package/dist/esm/utils/index.js +3 -77
  81. package/dist/esm/utils/input-rules.js +4 -61
  82. package/dist/esm/utils/mark.js +0 -35
  83. package/dist/esm/version-wrapper.js +1 -1
  84. package/dist/esm/version.json +1 -1
  85. package/dist/types/commands/index.d.ts +0 -6
  86. package/dist/types/plugins/block-type/commands/block-type.d.ts +5 -6
  87. package/dist/types/plugins/block-type/commands/delete-and-move-cursor.d.ts +1 -1
  88. package/dist/types/plugins/block-type/commands/delete-block-content.d.ts +1 -1
  89. package/dist/types/plugins/block-type/index.d.ts +1 -1
  90. package/dist/types/plugins/block-type/pm-plugins/input-rule.d.ts +3 -2
  91. package/dist/types/plugins/block-type/pm-plugins/keymap.d.ts +2 -2
  92. package/dist/types/plugins/block-type/pm-plugins/main.d.ts +2 -1
  93. package/dist/types/plugins/block-type/styles.d.ts +1 -1
  94. package/dist/types/plugins/block-type/types.d.ts +2 -3
  95. package/dist/types/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +1 -2
  96. package/dist/types/plugins/block-type/ui/ToolbarBlockType/index.d.ts +2 -2
  97. package/dist/types/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +5 -1
  98. package/dist/types/plugins/block-type/utils.d.ts +15 -1
  99. package/dist/types/plugins/emoji/commands/insert-emoji.d.ts +2 -2
  100. package/dist/types/plugins/emoji/pm-plugins/ascii-input-rules.d.ts +3 -2
  101. package/dist/types/plugins/extension/pm-plugins/main.d.ts +1 -1
  102. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +1 -0
  103. package/dist/types/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
  104. package/dist/types/types/index.d.ts +1 -1
  105. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  106. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  107. package/dist/types/ui/styles.d.ts +0 -3
  108. package/dist/types/utils/index.d.ts +0 -6
  109. package/dist/types/utils/input-rules.d.ts +4 -16
  110. package/dist/types/utils/mark.d.ts +0 -1
  111. package/dist/types-ts4.5/commands/index.d.ts +0 -6
  112. package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +5 -6
  113. package/dist/types-ts4.5/plugins/block-type/commands/delete-and-move-cursor.d.ts +1 -1
  114. package/dist/types-ts4.5/plugins/block-type/commands/delete-block-content.d.ts +1 -1
  115. package/dist/types-ts4.5/plugins/block-type/index.d.ts +1 -1
  116. package/dist/types-ts4.5/plugins/block-type/pm-plugins/input-rule.d.ts +3 -2
  117. package/dist/types-ts4.5/plugins/block-type/pm-plugins/keymap.d.ts +2 -2
  118. package/dist/types-ts4.5/plugins/block-type/pm-plugins/main.d.ts +2 -1
  119. package/dist/types-ts4.5/plugins/block-type/styles.d.ts +1 -1
  120. package/dist/types-ts4.5/plugins/block-type/types.d.ts +2 -3
  121. package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +1 -2
  122. package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/index.d.ts +2 -2
  123. package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +5 -1
  124. package/dist/types-ts4.5/plugins/block-type/utils.d.ts +15 -1
  125. package/dist/types-ts4.5/plugins/emoji/commands/insert-emoji.d.ts +2 -2
  126. package/dist/types-ts4.5/plugins/emoji/pm-plugins/ascii-input-rules.d.ts +3 -2
  127. package/dist/types-ts4.5/plugins/extension/pm-plugins/main.d.ts +1 -1
  128. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +1 -0
  129. package/dist/types-ts4.5/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
  130. package/dist/types-ts4.5/types/index.d.ts +1 -1
  131. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  132. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  133. package/dist/types-ts4.5/ui/styles.d.ts +0 -3
  134. package/dist/types-ts4.5/utils/index.d.ts +0 -6
  135. package/dist/types-ts4.5/utils/input-rules.d.ts +4 -16
  136. package/dist/types-ts4.5/utils/mark.d.ts +0 -1
  137. package/package.json +4 -4
  138. package/report.api.md +6 -16
  139. package/tmp/api-report-tmp.d.ts +5 -16
  140. package/dist/cjs/types/allowed-block-types.js +0 -5
  141. package/dist/cjs/utils/keymap.js +0 -38
  142. package/dist/es2019/types/allowed-block-types.js +0 -1
  143. package/dist/es2019/utils/keymap.js +0 -33
  144. package/dist/esm/types/allowed-block-types.js +0 -1
  145. package/dist/esm/utils/keymap.js +0 -33
  146. package/dist/types/types/allowed-block-types.d.ts +0 -1
  147. package/dist/types/utils/keymap.d.ts +0 -11
  148. package/dist/types-ts4.5/types/allowed-block-types.d.ts +0 -1
  149. package/dist/types-ts4.5/utils/keymap.d.ts +0 -11
  150. /package/dist/cjs/{keymaps → plugins/block-type}/consts.js +0 -0
  151. /package/dist/es2019/{keymaps → plugins/block-type}/consts.js +0 -0
  152. /package/dist/esm/{keymaps → plugins/block-type}/consts.js +0 -0
  153. /package/dist/types/{keymaps → plugins/block-type}/consts.d.ts +0 -0
  154. /package/dist/types-ts4.5/{keymaps → plugins/block-type}/consts.d.ts +0 -0
@@ -1,7 +1,6 @@
1
1
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
- import { mapSlice } from '../../../utils/slice';
3
2
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
4
- import { timestampToString } from '@atlaskit/editor-common/utils';
3
+ import { timestampToString, mapSlice } from '@atlaskit/editor-common/utils';
5
4
  export function transformToCodeBlockAction(state, start, attrs) {
6
5
  const startOfCodeBlockText = state.selection.$from;
7
6
  const endPosition = state.selection.empty ? startOfCodeBlockText.end() : state.selection.$to.pos;
@@ -1,16 +1,16 @@
1
1
  import React from 'react';
2
2
  import { blockquote, hardBreak, heading } from '@atlaskit/adf-schema';
3
+ import { ToolbarSize } from '@atlaskit/editor-common/types';
4
+ import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
5
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
+ import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
7
+ import * as keymaps from '@atlaskit/editor-common/keymaps';
3
8
  import { createPlugin, pluginKey } from './pm-plugins/main';
4
9
  import keymapPlugin from './pm-plugins/keymap';
5
10
  import inputRulePlugin from './pm-plugins/input-rule';
6
11
  import ToolbarBlockType from './ui/ToolbarBlockType';
7
- import WithPluginState from '../../ui/WithPluginState';
8
12
  import { setBlockTypeWithAnalytics } from './commands';
9
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
10
- import * as keymaps from '../../keymaps';
11
- import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
12
13
  import { messages } from './messages';
13
- import { ToolbarSize } from '../../ui/Toolbar/types';
14
14
  const headingPluginOptions = ({
15
15
  formatMessage
16
16
  }, isAllowed, editorAnalyticsApi) => {
@@ -105,13 +105,19 @@ const blockTypePlugin = (options, api) => ({
105
105
  name: 'blockType',
106
106
  plugin: ({
107
107
  dispatch
108
- }) => createPlugin(dispatch, options && options.lastNodeMustBeParagraph)
108
+ }) => {
109
+ var _api$dependencies$ana;
110
+ return createPlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions, dispatch, options && options.lastNodeMustBeParagraph);
111
+ }
109
112
  }, {
110
113
  name: 'blockTypeInputRule',
111
114
  plugin: ({
112
115
  schema,
113
116
  featureFlags
114
- }) => inputRulePlugin(schema, featureFlags)
117
+ }) => {
118
+ var _api$dependencies$ana2;
119
+ return inputRulePlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions, schema, featureFlags);
120
+ }
115
121
  },
116
122
  // Needs to be lower priority than editor-tables.tableEditing
117
123
  // plugin as it is currently swallowing right/down arrow events inside tables
@@ -121,8 +127,8 @@ const blockTypePlugin = (options, api) => ({
121
127
  schema,
122
128
  featureFlags
123
129
  }) => {
124
- var _api$dependencies$ana;
125
- return keymapPlugin(schema, featureFlags, api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions);
130
+ var _api$dependencies$ana3;
131
+ return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions, schema, featureFlags);
126
132
  }
127
133
  }];
128
134
  },
@@ -137,7 +143,10 @@ const blockTypePlugin = (options, api) => ({
137
143
  eventDispatcher
138
144
  }) {
139
145
  const isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < ToolbarSize.XXL : toolbarSize < ToolbarSize.XL;
140
- const boundSetBlockType = name => setBlockTypeWithAnalytics(name, INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
146
+ const boundSetBlockType = name => {
147
+ var _api$dependencies$ana4;
148
+ return setBlockTypeWithAnalytics(name, INPUT_METHOD.TOOLBAR, api === null || api === void 0 ? void 0 : (_api$dependencies$ana4 = api.dependencies.analytics) === null || _api$dependencies$ana4 === void 0 ? void 0 : _api$dependencies$ana4.actions)(editorView.state, editorView.dispatch);
149
+ };
141
150
  return /*#__PURE__*/React.createElement(WithPluginState, {
142
151
  editorView: editorView,
143
152
  eventDispatcher: eventDispatcher,
@@ -162,9 +171,9 @@ const blockTypePlugin = (options, api) => ({
162
171
  },
163
172
  pluginsOptions: {
164
173
  quickInsert: intl => {
165
- var _api$dependencies$ana2, _api$dependencies$ana3;
174
+ var _api$dependencies$ana5, _api$dependencies$ana6;
166
175
  const exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
167
- return [...blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions), ...headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions)];
176
+ return [...blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 ? void 0 : (_api$dependencies$ana5 = api.dependencies.analytics) === null || _api$dependencies$ana5 === void 0 ? void 0 : _api$dependencies$ana5.actions), ...headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 ? void 0 : (_api$dependencies$ana6 = api.dependencies.analytics) === null || _api$dependencies$ana6 === void 0 ? void 0 : _api$dependencies$ana6.actions)];
168
177
  }
169
178
  }
170
179
  });
@@ -1,10 +1,10 @@
1
- import { createJoinNodesRule, createWrappingTextBlockRule, ruleWithAnalytics } from '../../../utils/input-rules';
2
- import { createRule, createPlugin } from '@atlaskit/prosemirror-input-rules';
3
- import { leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
4
- import { isConvertableToCodeBlock, transformToCodeBlockAction } from '../commands/transform-to-code-block';
5
- import { insertBlock } from '../commands/insert-block';
6
1
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
2
+ import { createRule, createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
7
3
  import { INPUT_METHOD, ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
4
+ import { inputRuleWithAnalytics } from '@atlaskit/editor-common/utils';
5
+ import { isConvertableToCodeBlock, transformToCodeBlockAction } from '../commands/transform-to-code-block';
6
+ import { insertBlock } from '../commands/insert-block';
7
+ import { createJoinNodesRule, createWrappingTextBlockRule } from '../utils';
8
8
  const MAX_HEADING_LEVEL = 6;
9
9
  function getHeadingLevel(match) {
10
10
  return {
@@ -28,7 +28,7 @@ function blockQuoteRule(nodeType) {
28
28
  * @param {Schema} schema
29
29
  * @returns {InputRuleWithHandler[]}
30
30
  */
31
- function getHeadingRules(schema) {
31
+ function getHeadingRules(editorAnalyticsAPI, schema) {
32
32
  // '# ' for h1, '## ' for h2 and etc
33
33
  const hashRule = headingRule(schema.nodes.heading, MAX_HEADING_LEVEL);
34
34
  const leftNodeReplacementHashRule = createRule(new RegExp(`${leafNodeReplacementCharacter}(#{1,6})\\s$`), (state, match, start, end) => {
@@ -39,7 +39,7 @@ function getHeadingRules(schema) {
39
39
  });
40
40
 
41
41
  // New analytics handler
42
- const ruleWithHeadingAnalytics = ruleWithAnalytics((_state, matchResult) => ({
42
+ const ruleWithHeadingAnalytics = inputRuleWithAnalytics((_state, matchResult) => ({
43
43
  action: ACTION.FORMATTED,
44
44
  actionSubject: ACTION_SUBJECT.TEXT,
45
45
  eventType: EVENT_TYPE.TRACK,
@@ -48,7 +48,7 @@ function getHeadingRules(schema) {
48
48
  inputMethod: INPUT_METHOD.FORMATTING,
49
49
  newHeadingLevel: getHeadingLevel(matchResult).level
50
50
  }
51
- }));
51
+ }), editorAnalyticsAPI);
52
52
  return [ruleWithHeadingAnalytics(hashRule), ruleWithHeadingAnalytics(leftNodeReplacementHashRule)];
53
53
  }
54
54
 
@@ -58,7 +58,7 @@ function getHeadingRules(schema) {
58
58
  * @param {Schema} schema
59
59
  * @returns {InputRuleWithHandler[]}
60
60
  */
61
- function getBlockQuoteRules(schema) {
61
+ function getBlockQuoteRules(editorAnalyticsAPI, schema) {
62
62
  // '> ' for blockquote
63
63
  const greatherThanRule = blockQuoteRule(schema.nodes.blockquote);
64
64
  const leftNodeReplacementGreatherRule = createRule(new RegExp(`${leafNodeReplacementCharacter}\\s*>\\s$`), (state, _match, start, end) => {
@@ -66,7 +66,7 @@ function getBlockQuoteRules(schema) {
66
66
  });
67
67
 
68
68
  // Analytics V3 handler
69
- const ruleWithBlockQuoteAnalytics = ruleWithAnalytics({
69
+ const ruleWithBlockQuoteAnalytics = inputRuleWithAnalytics({
70
70
  action: ACTION.FORMATTED,
71
71
  actionSubject: ACTION_SUBJECT.TEXT,
72
72
  eventType: EVENT_TYPE.TRACK,
@@ -74,7 +74,7 @@ function getBlockQuoteRules(schema) {
74
74
  attributes: {
75
75
  inputMethod: INPUT_METHOD.FORMATTING
76
76
  }
77
- });
77
+ }, editorAnalyticsAPI);
78
78
  return [ruleWithBlockQuoteAnalytics(greatherThanRule), ruleWithBlockQuoteAnalytics(leftNodeReplacementGreatherRule)];
79
79
  }
80
80
 
@@ -84,8 +84,8 @@ function getBlockQuoteRules(schema) {
84
84
  * @param {Schema} schema
85
85
  * @returns {InputRuleWithHandler[]}
86
86
  */
87
- function getCodeBlockRules(schema) {
88
- const ruleAnalytics = ruleWithAnalytics({
87
+ function getCodeBlockRules(editorAnalyticsAPI, schema) {
88
+ const ruleAnalytics = inputRuleWithAnalytics({
89
89
  action: ACTION.INSERTED,
90
90
  actionSubject: ACTION_SUBJECT.DOCUMENT,
91
91
  actionSubjectId: ACTION_SUBJECT_ID.CODE_BLOCK,
@@ -93,7 +93,7 @@ function getCodeBlockRules(schema) {
93
93
  inputMethod: INPUT_METHOD.FORMATTING
94
94
  },
95
95
  eventType: EVENT_TYPE.TRACK
96
- });
96
+ }, editorAnalyticsAPI);
97
97
  const validMatchLength = match => match.length > 0 && match[0].length === 3;
98
98
  const threeTildeRule = createRule(/(?!\s)(`{3,})$/, (state, match, start, end) => {
99
99
  if (!validMatchLength(match)) {
@@ -125,16 +125,16 @@ function getCodeBlockRules(schema) {
125
125
  });
126
126
  return [ruleAnalytics(threeTildeRule), ruleAnalytics(leftNodeReplacementThreeTildeRule)];
127
127
  }
128
- function inputRulePlugin(schema, featureFlags) {
128
+ function inputRulePlugin(editorAnalyticsAPI, schema, featureFlags) {
129
129
  const rules = [];
130
130
  if (schema.nodes.heading) {
131
- rules.push(...getHeadingRules(schema));
131
+ rules.push(...getHeadingRules(editorAnalyticsAPI, schema));
132
132
  }
133
133
  if (schema.nodes.blockquote) {
134
- rules.push(...getBlockQuoteRules(schema));
134
+ rules.push(...getBlockQuoteRules(editorAnalyticsAPI, schema));
135
135
  }
136
136
  if (schema.nodes.codeBlock) {
137
- rules.push(...getCodeBlockRules(schema));
137
+ rules.push(...getCodeBlockRules(editorAnalyticsAPI, schema));
138
138
  }
139
139
  if (rules.length !== 0) {
140
140
  return createPlugin('block-type', rules, {
@@ -1,20 +1,19 @@
1
1
  import { redo, undo } from '@atlaskit/editor-prosemirror/history';
2
2
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
3
- import * as keymaps from '../../../keymaps';
4
- import * as commands from '../../../commands';
3
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import * as keymaps from '@atlaskit/editor-common/keymaps';
5
+ import { keymap } from '@atlaskit/editor-common/keymaps';
6
+ import { insertNewLineWithAnalytics, createNewParagraphAbove, createNewParagraphBelow, deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
5
7
  import * as blockTypes from '../types';
6
- import { keymap } from '../../../utils/keymap';
7
8
  import { cleanUpAtTheStartOfDocument, deleteAndMoveCursor, deleteBlockContent, insertBlockTypesWithAnalytics } from '../commands';
8
- import { deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
9
- import { INPUT_METHOD } from '../../analytics';
10
9
  import { isNodeAWrappingBlockNode } from '../utils';
11
10
  const backspace = chainCommands(cleanUpAtTheStartOfDocument, deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
12
11
  const del = chainCommands(deleteEmptyParagraphAndMoveBlockUp(isNodeAWrappingBlockNode), deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
13
- export default function keymapPlugin(schema, featureFlags, editorAnalyticsApi) {
12
+ export default function keymapPlugin(editorAnalyticsApi, schema, _featureFlags) {
14
13
  const list = {};
15
- keymaps.bindKeymapWithCommand(keymaps.insertNewLine.common, commands.insertNewLineWithAnalytics, list);
16
- keymaps.bindKeymapWithCommand(keymaps.moveUp.common, commands.createNewParagraphAbove, list);
17
- keymaps.bindKeymapWithCommand(keymaps.moveDown.common, commands.createNewParagraphBelow, list);
14
+ keymaps.bindKeymapWithCommand(keymaps.insertNewLine.common, insertNewLineWithAnalytics(editorAnalyticsApi), list);
15
+ keymaps.bindKeymapWithCommand(keymaps.moveUp.common, createNewParagraphAbove, list);
16
+ keymaps.bindKeymapWithCommand(keymaps.moveDown.common, createNewParagraphBelow, list);
18
17
  keymaps.bindKeymapWithCommand(keymaps.findKeyMapForBrowser(keymaps.redo), redo, list);
19
18
  keymaps.bindKeymapWithCommand(keymaps.undo.common, undo, list);
20
19
  keymaps.bindKeymapWithCommand(keymaps.backspace.common, backspace, list);
@@ -1,11 +1,11 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
3
  import { browser } from '@atlaskit/editor-common/utils';
4
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
5
  import { NORMAL_TEXT, HEADING_1, HEADING_2, HEADING_3, HEADING_4, HEADING_5, HEADING_6, BLOCK_QUOTE, CODE_BLOCK, PANEL, OTHER, TEXT_BLOCK_TYPES, WRAPPER_BLOCK_TYPES, HEADINGS_BY_LEVEL } from '../types';
5
- import { areBlockTypesDisabled } from '../../../utils';
6
+ import { HEADING_KEYS } from '../consts';
6
7
  import { setHeadingWithAnalytics, setNormalTextWithAnalytics } from '../commands';
7
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
- import { HEADING_KEYS } from '../../../keymaps/consts';
8
+ import { areBlockTypesDisabled } from '../utils';
9
9
  const blockTypeForNode = (node, schema) => {
10
10
  if (node.type === schema.nodes.heading) {
11
11
  const maybeNode = HEADINGS_BY_LEVEL[node.attrs['level']];
@@ -59,16 +59,16 @@ const detectBlockType = (availableBlockTypes, state) => {
59
59
  });
60
60
  return blockType || OTHER;
61
61
  };
62
- const autoformatHeading = (headingLevel, view) => {
62
+ const autoformatHeading = (headingLevel, view, editorAnalyticsApi) => {
63
63
  if (headingLevel === 0) {
64
- setNormalTextWithAnalytics(INPUT_METHOD.FORMATTING)(view.state, view.dispatch);
64
+ setNormalTextWithAnalytics(INPUT_METHOD.FORMATTING, editorAnalyticsApi)(view.state, view.dispatch);
65
65
  } else {
66
- setHeadingWithAnalytics(headingLevel, INPUT_METHOD.FORMATTING)(view.state, view.dispatch);
66
+ setHeadingWithAnalytics(headingLevel, INPUT_METHOD.FORMATTING, editorAnalyticsApi)(view.state, view.dispatch);
67
67
  }
68
68
  return true;
69
69
  };
70
70
  export const pluginKey = new PluginKey('blockTypePlugin');
71
- export const createPlugin = (dispatch, lastNodeMustBeParagraph) => {
71
+ export const createPlugin = (editorAnalyticsApi, dispatch, lastNodeMustBeParagraph) => {
72
72
  let altKeyLocation = 0;
73
73
  return new SafePlugin({
74
74
  appendTransaction(_transactions, _oldState, newState) {
@@ -118,9 +118,9 @@ export const createPlugin = (dispatch, lastNodeMustBeParagraph) => {
118
118
  const headingLevel = HEADING_KEYS.indexOf(event.keyCode);
119
119
  if (headingLevel > -1 && event.altKey) {
120
120
  if (browser.mac && event.metaKey) {
121
- return autoformatHeading(headingLevel, view);
121
+ return autoformatHeading(headingLevel, view, editorAnalyticsApi);
122
122
  } else if (!browser.mac && event.ctrlKey && altKeyLocation !== event.DOM_KEY_LOCATION_RIGHT) {
123
- return autoformatHeading(headingLevel, view);
123
+ return autoformatHeading(headingLevel, view, editorAnalyticsApi);
124
124
  }
125
125
  } else if (event.key === 'Alt') {
126
126
  // event.location is for the current key only; when a user hits Ctrl-Alt-1 the
@@ -4,10 +4,10 @@ import { jsx } from '@emotion/react';
4
4
  import { FormattedMessage, defineMessages } from 'react-intl-next';
5
5
  import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
6
6
  import TextStyleIcon from '@atlaskit/icon/glyph/editor/text-style';
7
- import ToolbarButton from '../../../../ui/ToolbarButton';
8
- import { buttonContentStyle, buttonContentReducedSpacingStyle, wrapperSmallStyle, expandIconWrapperStyle } from '../../../../ui/styles';
9
7
  import { wrapperStyle } from '@atlaskit/editor-common/styles';
8
+ import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
10
9
  import { NORMAL_TEXT } from '../../types';
10
+ import { buttonContentStyle, buttonContentReducedSpacingStyle, wrapperSmallStyle, expandIconWrapperStyle } from './styled';
11
11
  export const messages = defineMessages({
12
12
  textStyles: {
13
13
  id: 'fabric.editor.textStyles',
@@ -4,12 +4,11 @@ import React from 'react';
4
4
  import { jsx } from '@emotion/react';
5
5
  import { injectIntl } from 'react-intl-next';
6
6
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
7
- import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
7
+ import { getAriaKeyshortcuts, tooltip, findKeymapByDescription } from '@atlaskit/editor-common/keymaps';
8
8
  import { separatorStyles, wrapperStyle } from '@atlaskit/editor-common/styles';
9
+ import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
9
10
  import { blockTypeMenuItemStyle, keyboardShortcut, keyboardShortcutSelect } from './styled';
10
- import { tooltip, findKeymapByDescription } from '../../../../keymaps';
11
11
  import { BlockTypeButton } from './blocktype-button';
12
- import { getAriaKeyshortcuts } from '@atlaskit/editor-common/keymaps';
13
12
  class ToolbarBlockType extends React.PureComponent {
14
13
  constructor(...args) {
15
14
  super(...args);
@@ -2,7 +2,7 @@
2
2
  import { css } from '@emotion/react';
3
3
  import { N400 } from '@atlaskit/theme/colors';
4
4
  import { headingsSharedStyles } from '@atlaskit/editor-common/styles';
5
- import { shortcutStyle } from '../../../../ui/styles';
5
+ import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
6
6
  export const blockTypeMenuItemStyle = (tagName, selected) => {
7
7
  // TEMP FIX: See https://product-fabric.atlassian.net/browse/ED-13878
8
8
  const selectedStyle = selected ? `${tagName} { color: ${"var(--ds-text, white)"} !important; }` : '';
@@ -23,8 +23,27 @@ export const blockTypeMenuItemStyle = (tagName, selected) => {
23
23
  };
24
24
  export const keyboardShortcut = css`
25
25
  ${shortcutStyle}
26
- margin-left: 16px;
26
+ margin-left: ${"var(--ds-space-200, 16px)"};
27
27
  `;
28
28
  export const keyboardShortcutSelect = css`
29
29
  color: ${`var(--ds-icon, ${N400})`};
30
+ `;
31
+ export const buttonContentStyle = css`
32
+ display: flex;
33
+ min-width: 80px;
34
+ align-items: center;
35
+ overflow: hidden;
36
+ justify-content: center;
37
+ flex-direction: column;
38
+ padding: ${"var(--ds-space-075, 6px)"};
39
+ `;
40
+ export const buttonContentReducedSpacingStyle = css`
41
+ padding: ${"var(--ds-space-100, 8px)"};
42
+ `;
43
+ export const wrapperSmallStyle = css`
44
+ margin-left: ${"var(--ds-space-050, 4px)"};
45
+ min-width: 40px;
46
+ `;
47
+ export const expandIconWrapperStyle = css`
48
+ margin-left: -8px;
30
49
  `;
@@ -1,7 +1,76 @@
1
+ import { createRule } from '@atlaskit/prosemirror-input-rules';
2
+ import { createWrappingJoinRule } from '@atlaskit/editor-common/utils';
1
3
  import { WRAPPER_BLOCK_TYPES } from './types';
2
4
  export const isNodeAWrappingBlockNode = node => {
3
5
  if (!node) {
4
6
  return false;
5
7
  }
6
8
  return WRAPPER_BLOCK_TYPES.some(blockNode => blockNode.name === node.type.name);
7
- };
9
+ };
10
+ export const createJoinNodesRule = (match, nodeType) => {
11
+ return createWrappingJoinRule({
12
+ nodeType,
13
+ match,
14
+ getAttrs: {},
15
+ joinPredicate: (_, node) => node.type === nodeType
16
+ });
17
+ };
18
+ export const createWrappingTextBlockRule = ({
19
+ match,
20
+ nodeType,
21
+ getAttrs
22
+ }) => {
23
+ const handler = (state, match, start, end) => {
24
+ const fixedStart = Math.max(start, 1);
25
+ const $start = state.doc.resolve(fixedStart);
26
+ const attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
27
+ const nodeBefore = $start.node(-1);
28
+ if (nodeBefore && !nodeBefore.canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType)) {
29
+ return null;
30
+ }
31
+ return state.tr.delete(fixedStart, end).setBlockType(fixedStart, fixedStart, nodeType, attrs);
32
+ };
33
+ return createRule(match, handler);
34
+ };
35
+
36
+ /**
37
+ * Function will create a list of wrapper blocks present in a selection.
38
+ */
39
+ function getSelectedWrapperNodes(state) {
40
+ const nodes = [];
41
+ if (state.selection) {
42
+ const {
43
+ $from,
44
+ $to
45
+ } = state.selection;
46
+ const {
47
+ blockquote,
48
+ panel,
49
+ orderedList,
50
+ bulletList,
51
+ listItem,
52
+ codeBlock,
53
+ decisionItem,
54
+ decisionList,
55
+ taskItem,
56
+ taskList
57
+ } = state.schema.nodes;
58
+ state.doc.nodesBetween($from.pos, $to.pos, node => {
59
+ if (node.isBlock && [blockquote, panel, orderedList, bulletList, listItem, codeBlock, decisionItem, decisionList, taskItem, taskList].indexOf(node.type) >= 0) {
60
+ nodes.push(node.type);
61
+ }
62
+ });
63
+ }
64
+ return nodes;
65
+ }
66
+
67
+ /**
68
+ * Function will check if changing block types: Paragraph, Heading is enabled.
69
+ */
70
+ export function areBlockTypesDisabled(state) {
71
+ const nodesTypes = getSelectedWrapperNodes(state);
72
+ const {
73
+ panel
74
+ } = state.schema.nodes;
75
+ return nodesTypes.filter(type => type !== panel).length > 0;
76
+ }
@@ -2,7 +2,7 @@ import { keymap } from '@atlaskit/editor-prosemirror/keymap';
2
2
  import { Selection } from '@atlaskit/editor-prosemirror/state';
3
3
  import * as keymaps from '../../../keymaps';
4
4
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
- import { createNewParagraphBelow } from '../../../commands';
5
+ import { createNewParagraphBelow } from '@atlaskit/editor-common/utils';
6
6
  import { GapCursorSelection } from '../../selection/gap-cursor/selection';
7
7
  export function captionKeymap() {
8
8
  const list = {};
@@ -1,8 +1,8 @@
1
1
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
2
2
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
3
  import { Selection } from '@atlaskit/editor-prosemirror/state';
4
- import { addAnalytics, EVENT_TYPE, ACTION_SUBJECT_ID, ACTION_SUBJECT, ACTION } from '../../analytics';
5
- export function insertEmoji(emojiId, inputMethod) {
4
+ import { EVENT_TYPE, ACTION_SUBJECT_ID, ACTION_SUBJECT, ACTION } from '@atlaskit/editor-common/analytics';
5
+ export const insertEmoji = editorAnalyticsAPI => (emojiId, inputMethod) => {
6
6
  return (state, dispatch) => {
7
7
  const {
8
8
  emoji
@@ -17,7 +17,7 @@ export function insertEmoji(emojiId, inputMethod) {
17
17
  const fragment = Fragment.fromArray([node, textNode]);
18
18
  const tr = safeInsert(fragment)(state.tr);
19
19
  if (inputMethod) {
20
- addAnalytics(state, tr, {
20
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
21
21
  action: ACTION.INSERTED,
22
22
  actionSubject: ACTION_SUBJECT.DOCUMENT,
23
23
  actionSubjectId: ACTION_SUBJECT_ID.EMOJI,
@@ -25,7 +25,7 @@ export function insertEmoji(emojiId, inputMethod) {
25
25
  inputMethod
26
26
  },
27
27
  eventType: EVENT_TYPE.TRACK
28
- });
28
+ })(tr);
29
29
  }
30
30
  dispatch(tr.setSelection(Selection.near(tr.doc.resolve(state.selection.$from.pos + fragment.size))));
31
31
  }
@@ -33,4 +33,4 @@ export function insertEmoji(emojiId, inputMethod) {
33
33
  }
34
34
  return false;
35
35
  };
36
- }
36
+ };
@@ -169,7 +169,10 @@ const emojiPlugin = (options, api) => {
169
169
  schema,
170
170
  providerFactory,
171
171
  featureFlags
172
- }) => asciiInputRulePlugin(schema, providerFactory, featureFlags)
172
+ }) => {
173
+ var _api$dependencies$ana8;
174
+ return asciiInputRulePlugin(schema, providerFactory, featureFlags, api === null || api === void 0 ? void 0 : (_api$dependencies$ana8 = api.dependencies.analytics) === null || _api$dependencies$ana8 === void 0 ? void 0 : _api$dependencies$ana8.actions);
175
+ }
173
176
  }];
174
177
  },
175
178
  pluginsOptions: {
@@ -183,13 +186,13 @@ const emojiPlugin = (options, api) => {
183
186
  keyshortcut: ':',
184
187
  icon: () => /*#__PURE__*/React.createElement(IconEmoji, null),
185
188
  action(insert, state) {
186
- var _api$dependencies$ana8;
189
+ var _api$dependencies$ana9;
187
190
  const tr = insert(undefined);
188
191
  openTypeAheadAtCursor({
189
192
  triggerHandler: typeAhead,
190
193
  inputMethod: INPUT_METHOD.QUICK_INSERT
191
194
  })(tr);
192
- api === null || api === void 0 ? void 0 : (_api$dependencies$ana8 = api.dependencies.analytics) === null || _api$dependencies$ana8 === void 0 ? void 0 : _api$dependencies$ana8.actions.attachAnalyticsEvent({
195
+ api === null || api === void 0 ? void 0 : (_api$dependencies$ana9 = api.dependencies.analytics) === null || _api$dependencies$ana9 === void 0 ? void 0 : _api$dependencies$ana9.actions.attachAnalyticsEvent({
193
196
  action: ACTION.INVOKED,
194
197
  actionSubject: ACTION_SUBJECT.TYPEAHEAD,
195
198
  actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_EMOJI,
@@ -2,12 +2,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
3
  import { createRule, createPlugin } from '@atlaskit/prosemirror-input-rules';
4
4
  import { leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
5
- import { addAnalytics, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE } from '../../analytics';
5
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
6
6
  let matcher;
7
- export function inputRulePlugin(schema, providerFactory, featureFlags) {
7
+ export function inputRulePlugin(schema, providerFactory, featureFlags, editorAnalyticsAPI) {
8
8
  if (schema.nodes.emoji && providerFactory) {
9
9
  initMatcher(providerFactory);
10
- const asciiEmojiRule = createRule(AsciiEmojiMatcher.REGEX, inputRuleHandler);
10
+ const asciiEmojiRule = createRule(AsciiEmojiMatcher.REGEX, inputRuleHandler(editorAnalyticsAPI));
11
11
  return createPlugin('emoji', [asciiEmojiRule]);
12
12
  }
13
13
  return;
@@ -25,17 +25,17 @@ function initMatcher(providerFactory) {
25
25
  };
26
26
  providerFactory.subscribe('emojiProvider', handleProvider);
27
27
  }
28
- function inputRuleHandler(state, matchParts, start, end) {
28
+ const inputRuleHandler = editorAnalyticsAPI => (state, matchParts, start, end) => {
29
29
  if (!matcher) {
30
30
  return null;
31
31
  }
32
32
  const match = matcher.match(matchParts);
33
33
  if (match) {
34
- const transactionCreator = new AsciiEmojiTransactionCreator(state, match, start, end);
34
+ const transactionCreator = new AsciiEmojiTransactionCreator(state, match, start, end, editorAnalyticsAPI);
35
35
  return transactionCreator.create();
36
36
  }
37
37
  return null;
38
- }
38
+ };
39
39
  const REGEX_LEADING_CAPTURE_INDEX = 1;
40
40
  const REGEX_EMOJI_LEADING_PARENTHESES = 2;
41
41
  const REGEX_EMOJI_ASCII_CAPTURE_INDEX = 3;
@@ -107,15 +107,17 @@ class RecordingAsciiEmojiMatcher extends AsciiEmojiMatcher {
107
107
  }
108
108
  }
109
109
  class AsciiEmojiTransactionCreator {
110
- constructor(state, match, start, end) {
110
+ constructor(state, match, start, end, editorAnalyticsAPI) {
111
111
  this.state = state;
112
112
  this.match = match;
113
113
  this.start = start;
114
114
  this.end = end;
115
+ this.editorAnalyticsAPI = editorAnalyticsAPI;
115
116
  }
116
117
  create() {
118
+ var _this$editorAnalytics;
117
119
  const tr = this.state.tr.replaceWith(this.from, this.to, this.createNodes());
118
- return addAnalytics(this.state, tr, {
120
+ (_this$editorAnalytics = this.editorAnalyticsAPI) === null || _this$editorAnalytics === void 0 ? void 0 : _this$editorAnalytics.attachAnalyticsEvent({
119
121
  action: ACTION.INSERTED,
120
122
  actionSubject: ACTION_SUBJECT.DOCUMENT,
121
123
  actionSubjectId: ACTION_SUBJECT_ID.EMOJI,
@@ -123,7 +125,8 @@ class AsciiEmojiTransactionCreator {
123
125
  inputMethod: INPUT_METHOD.ASCII
124
126
  },
125
127
  eventType: EVENT_TYPE.TRACK
126
- });
128
+ })(tr);
129
+ return tr;
127
130
  }
128
131
  get from() {
129
132
  return this.start + this.match.leadingString.length;
@@ -160,7 +163,7 @@ class AsciiEmojiTransactionCreator {
160
163
  }
161
164
  }
162
165
  export const stateKey = new PluginKey('asciiEmojiPlugin');
163
- const plugins = (schema, providerFactory, featureFlags) => {
164
- return [inputRulePlugin(schema, providerFactory, featureFlags)].filter(plugin => !!plugin);
166
+ const plugins = (schema, providerFactory, featureFlags, editorAnalyticsAPI) => {
167
+ return [inputRulePlugin(schema, providerFactory, featureFlags, editorAnalyticsAPI)].filter(plugin => !!plugin);
165
168
  };
166
169
  export default plugins;
@@ -1,4 +1,7 @@
1
+ import { TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
+ import { findParentNodeOfTypeClosestToPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
1
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
+ import { isSelectionAtStartOfNode, isSelectionAtEndOfNode } from '@atlaskit/editor-common/selection';
2
5
  import { createSelectionClickHandler } from '../../selection/utils';
3
6
  import ExtensionNodeView from '../nodeviews/extension';
4
7
  import { updateState, clearEditingContext } from '../commands';
@@ -163,6 +166,53 @@ const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProvid
163
166
  },
164
167
  key: pluginKey,
165
168
  props: {
169
+ handleDOMEvents: {
170
+ /**
171
+ * ED-18072 - Cannot shift + arrow past bodied extension if it is not empty.
172
+ * This code is to handle the case where the selection starts inside or on the node and the user is trying to shift + arrow.
173
+ * For other part of the solution see code in: packages/editor/editor-core/src/plugins/selection/pm-plugins/events/keydown.ts
174
+ */
175
+ keydown: (view, event) => {
176
+ if (event instanceof KeyboardEvent && event.shiftKey && ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
177
+ const {
178
+ schema,
179
+ selection,
180
+ selection: {
181
+ $head
182
+ },
183
+ doc,
184
+ tr
185
+ } = view.state;
186
+ const {
187
+ bodiedExtension
188
+ } = schema.nodes;
189
+ if (selection instanceof TextSelection || selection instanceof NodeSelection) {
190
+ const maybeBodiedExtension = selection instanceof TextSelection ? findParentNodeOfTypeClosestToPos($head, bodiedExtension) : findSelectedNodeOfType(bodiedExtension)(selection);
191
+ if (maybeBodiedExtension) {
192
+ const end = maybeBodiedExtension.pos + maybeBodiedExtension.node.nodeSize;
193
+ if (event.key === 'ArrowUp' || event.key === 'ArrowLeft' && isSelectionAtStartOfNode($head, maybeBodiedExtension)) {
194
+ const anchor = end + 1;
195
+
196
+ // an offset is used here so that left arrow selects the first character before the node (consistent with arrow right)
197
+ const headOffset = event.key === 'ArrowLeft' ? -1 : 0;
198
+ const head = maybeBodiedExtension.pos + headOffset;
199
+ const newSelection = TextSelection.create(doc, Math.max(anchor, selection.anchor), head);
200
+ view.dispatch(tr.setSelection(newSelection));
201
+ return true;
202
+ }
203
+ if (event.key === 'ArrowDown' || event.key === 'ArrowRight' && isSelectionAtEndOfNode($head, maybeBodiedExtension)) {
204
+ const anchor = maybeBodiedExtension.pos - 1;
205
+ const head = end + 1;
206
+ const newSelection = TextSelection.create(doc, Math.min(anchor, selection.anchor), head);
207
+ view.dispatch(tr.setSelection(newSelection));
208
+ return true;
209
+ }
210
+ }
211
+ }
212
+ }
213
+ return false;
214
+ }
215
+ },
166
216
  nodeViews: {
167
217
  // WARNING: referentiality-plugin also creates these nodeviews
168
218
  extension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi),
@@ -290,7 +290,7 @@ export class ToolbarInsertBlock extends React.PureComponent {
290
290
  });
291
291
  _defineProperty(this, "handleSelectedEmoji", emojiId => {
292
292
  this.props.editorView.focus();
293
- insertEmoji(emojiId, INPUT_METHOD.PICKER)(this.props.editorView.state, this.props.editorView.dispatch);
293
+ insertEmoji(this.editorAnalyticsAPI)(emojiId, INPUT_METHOD.PICKER)(this.props.editorView.state, this.props.editorView.dispatch);
294
294
  this.toggleEmojiPicker();
295
295
  return true;
296
296
  });