@atlaskit/editor-core 187.18.2 → 187.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/labs/next/presets/default.js +2 -1
  3. package/dist/cjs/plugins/base/index.js +0 -7
  4. package/dist/cjs/plugins/code-block/index.js +1 -1
  5. package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +98 -95
  6. package/dist/cjs/plugins/composition/index.js +33 -0
  7. package/dist/cjs/plugins/{base/pm-plugins/composition.js → composition/pm-plugins/main.js} +8 -14
  8. package/dist/cjs/plugins/composition/pm-plugins/plugin-key.js +9 -0
  9. package/dist/cjs/plugins/media/index.js +4 -3
  10. package/dist/cjs/plugins/media/pm-plugins/alt-text/commands.js +10 -7
  11. package/dist/cjs/plugins/media/pm-plugins/alt-text/keymap.js +2 -2
  12. package/dist/cjs/plugins/media/pm-plugins/main.js +9 -9
  13. package/dist/cjs/plugins/media/toolbar/alt-text.js +2 -2
  14. package/dist/cjs/plugins/media/toolbar/index.js +12 -11
  15. package/dist/cjs/plugins/media/utils/media-single.js +13 -13
  16. package/dist/cjs/plugins/paste/handlers.js +2 -2
  17. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +2 -2
  18. package/dist/cjs/plugins/paste/pm-plugins/main.js +4 -4
  19. package/dist/cjs/plugins/placeholder/index.js +2 -2
  20. package/dist/cjs/plugins/selection/gap-cursor/styles.js +1 -1
  21. package/dist/cjs/plugins/selection/gap-cursor/utils/place-gap-cursor.js +3 -3
  22. package/dist/cjs/plugins/selection/gap-cursor/utils.js +6 -3
  23. package/dist/cjs/plugins/selection/pm-plugins/gap-cursor-main.js +3 -3
  24. package/dist/cjs/version-wrapper.js +1 -1
  25. package/dist/cjs/version.json +1 -1
  26. package/dist/es2019/labs/next/presets/default.js +2 -1
  27. package/dist/es2019/plugins/base/index.js +0 -5
  28. package/dist/es2019/plugins/code-block/index.js +1 -1
  29. package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +107 -104
  30. package/dist/es2019/plugins/composition/index.js +23 -0
  31. package/dist/es2019/plugins/{base/pm-plugins/composition.js → composition/pm-plugins/main.js} +7 -12
  32. package/dist/es2019/plugins/composition/pm-plugins/plugin-key.js +2 -0
  33. package/dist/es2019/plugins/media/index.js +6 -3
  34. package/dist/es2019/plugins/media/pm-plugins/alt-text/commands.js +3 -2
  35. package/dist/es2019/plugins/media/pm-plugins/alt-text/keymap.js +2 -2
  36. package/dist/es2019/plugins/media/pm-plugins/main.js +7 -7
  37. package/dist/es2019/plugins/media/toolbar/alt-text.js +2 -2
  38. package/dist/es2019/plugins/media/toolbar/index.js +12 -11
  39. package/dist/es2019/plugins/media/utils/media-single.js +7 -8
  40. package/dist/es2019/plugins/paste/handlers.js +2 -3
  41. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +2 -2
  42. package/dist/es2019/plugins/paste/pm-plugins/main.js +4 -4
  43. package/dist/es2019/plugins/placeholder/index.js +2 -2
  44. package/dist/es2019/plugins/selection/gap-cursor/styles.js +2 -1
  45. package/dist/es2019/plugins/selection/gap-cursor/utils/place-gap-cursor.js +4 -4
  46. package/dist/es2019/plugins/selection/gap-cursor/utils.js +5 -2
  47. package/dist/es2019/plugins/selection/pm-plugins/gap-cursor-main.js +4 -4
  48. package/dist/es2019/version-wrapper.js +1 -1
  49. package/dist/es2019/version.json +1 -1
  50. package/dist/esm/labs/next/presets/default.js +2 -1
  51. package/dist/esm/plugins/base/index.js +0 -7
  52. package/dist/esm/plugins/code-block/index.js +1 -1
  53. package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +98 -95
  54. package/dist/esm/plugins/composition/index.js +25 -0
  55. package/dist/esm/plugins/{base/pm-plugins/composition.js → composition/pm-plugins/main.js} +7 -12
  56. package/dist/esm/plugins/composition/pm-plugins/plugin-key.js +2 -0
  57. package/dist/esm/plugins/media/index.js +4 -3
  58. package/dist/esm/plugins/media/pm-plugins/alt-text/commands.js +10 -7
  59. package/dist/esm/plugins/media/pm-plugins/alt-text/keymap.js +2 -2
  60. package/dist/esm/plugins/media/pm-plugins/main.js +7 -7
  61. package/dist/esm/plugins/media/toolbar/alt-text.js +2 -2
  62. package/dist/esm/plugins/media/toolbar/index.js +12 -11
  63. package/dist/esm/plugins/media/utils/media-single.js +7 -7
  64. package/dist/esm/plugins/paste/handlers.js +2 -3
  65. package/dist/esm/plugins/paste/pm-plugins/analytics.js +2 -2
  66. package/dist/esm/plugins/paste/pm-plugins/main.js +4 -4
  67. package/dist/esm/plugins/placeholder/index.js +2 -2
  68. package/dist/esm/plugins/selection/gap-cursor/styles.js +1 -1
  69. package/dist/esm/plugins/selection/gap-cursor/utils/place-gap-cursor.js +4 -4
  70. package/dist/esm/plugins/selection/gap-cursor/utils.js +5 -2
  71. package/dist/esm/plugins/selection/pm-plugins/gap-cursor-main.js +4 -4
  72. package/dist/esm/version-wrapper.js +1 -1
  73. package/dist/esm/version.json +1 -1
  74. package/dist/types/labs/next/presets/default.d.ts +16 -0
  75. package/dist/types/plugins/code-block/index.d.ts +6 -4
  76. package/dist/types/plugins/code-block/pm-plugins/ide-ux.d.ts +4 -2
  77. package/dist/types/plugins/composition/index.d.ts +8 -0
  78. package/dist/types/plugins/composition/pm-plugins/main.d.ts +4 -0
  79. package/dist/types/plugins/composition/pm-plugins/plugin-key.d.ts +6 -0
  80. package/dist/types/plugins/media/pm-plugins/alt-text/commands.d.ts +2 -1
  81. package/dist/types/plugins/media/pm-plugins/alt-text/keymap.d.ts +2 -1
  82. package/dist/types/plugins/media/toolbar/alt-text.d.ts +2 -1
  83. package/dist/types/plugins/media/utils/media-single.d.ts +3 -3
  84. package/dist/types/plugins/paste/handlers.d.ts +2 -1
  85. package/dist/types/plugins/paste/index.d.ts +3 -1
  86. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +2 -1
  87. package/dist/types/plugins/placeholder/index.d.ts +2 -1
  88. package/dist/types/plugins/selection/gap-cursor/utils.d.ts +1 -1
  89. package/dist/types-ts4.5/labs/next/presets/default.d.ts +20 -0
  90. package/dist/types-ts4.5/plugins/code-block/index.d.ts +6 -4
  91. package/dist/types-ts4.5/plugins/code-block/pm-plugins/ide-ux.d.ts +4 -2
  92. package/dist/types-ts4.5/plugins/composition/index.d.ts +8 -0
  93. package/dist/types-ts4.5/plugins/composition/pm-plugins/main.d.ts +4 -0
  94. package/dist/types-ts4.5/plugins/composition/pm-plugins/plugin-key.d.ts +6 -0
  95. package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/commands.d.ts +2 -1
  96. package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/keymap.d.ts +2 -1
  97. package/dist/types-ts4.5/plugins/media/toolbar/alt-text.d.ts +2 -1
  98. package/dist/types-ts4.5/plugins/media/utils/media-single.d.ts +3 -3
  99. package/dist/types-ts4.5/plugins/paste/handlers.d.ts +2 -1
  100. package/dist/types-ts4.5/plugins/paste/index.d.ts +3 -1
  101. package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +2 -1
  102. package/dist/types-ts4.5/plugins/placeholder/index.d.ts +3 -1
  103. package/dist/types-ts4.5/plugins/selection/gap-cursor/utils.d.ts +1 -1
  104. package/package.json +1 -1
  105. package/report.api.md +1 -0
  106. package/tmp/api-report-tmp.d.ts +1 -1
  107. package/dist/types/plugins/base/pm-plugins/composition.d.ts +0 -9
  108. package/dist/types-ts4.5/plugins/base/pm-plugins/composition.d.ts +0 -9
@@ -9,112 +9,115 @@ import { getAutoClosingBracketInfo, shouldAutoCloseBracket } from '../ide-ux/bra
9
9
  import { getAutoClosingQuoteInfo, shouldAutoCloseQuote } from '../ide-ux/quote-handling';
10
10
  import { getEndOfCurrentLine, getStartOfCurrentLine, isCursorInsideCodeBlock, isSelectionEntirelyInsideCodeBlock, getLineInfo } from '../ide-ux/line-handling';
11
11
  import { insertIndent, outdent, indent, insertNewlineWithIndent } from '../ide-ux/commands';
12
- import { isComposing } from '../../base/pm-plugins/composition';
13
- export default new SafePlugin({
14
- props: {
15
- handleTextInput: function handleTextInput(view, from, to, text) {
16
- var state = view.state,
17
- dispatch = view.dispatch;
18
- if (isCursorInsideCodeBlock(state) && !isComposing(state)) {
19
- var beforeText = getStartOfCurrentLine(state).text;
20
- var afterText = getEndOfCurrentLine(state).text;
21
-
22
- // If text is a closing bracket/quote and we've already inserted it, move the selection after
23
- if (isCursorBeforeClosingCharacter(afterText) && isClosingCharacter(text) && afterText.startsWith(text)) {
24
- dispatch(setTextSelection(to + text.length)(state.tr));
25
- return true;
26
- }
27
-
28
- // Automatically add right-hand side bracket when user types the left bracket
29
- if (shouldAutoCloseBracket(beforeText, afterText)) {
30
- var _getAutoClosingBracke = getAutoClosingBracketInfo(beforeText + text, afterText),
31
- left = _getAutoClosingBracke.left,
32
- right = _getAutoClosingBracke.right;
33
- if (left && right) {
34
- var bracketPair = state.schema.text(text + right);
35
- var tr = state.tr.replaceWith(from, to, bracketPair);
36
- dispatch(setTextSelection(from + text.length)(tr));
37
- return true;
38
- }
39
- }
40
-
41
- // Automatically add closing quote when user types a starting quote
42
- if (shouldAutoCloseQuote(beforeText, afterText)) {
43
- var _getAutoClosingQuoteI = getAutoClosingQuoteInfo(beforeText + text, afterText),
44
- leftQuote = _getAutoClosingQuoteI.left,
45
- rightQuote = _getAutoClosingQuoteI.right;
46
- if (leftQuote && rightQuote) {
47
- var quotePair = state.schema.text(text + rightQuote);
48
- var _tr = state.tr.replaceWith(from, to, quotePair);
49
- dispatch(setTextSelection(from + text.length)(_tr));
50
- return true;
51
- }
52
- }
53
- }
54
- return false;
55
- },
56
- handleKeyDown: keydownHandler({
57
- Backspace: function Backspace(state, dispatch) {
58
- if (isCursorInsideCodeBlock(state)) {
59
- var $cursor = getCursor(state.selection);
12
+ var ideUX = function ideUX(pluginInjectionApi) {
13
+ return new SafePlugin({
14
+ props: {
15
+ handleTextInput: function handleTextInput(view, from, to, text) {
16
+ var state = view.state,
17
+ dispatch = view.dispatch;
18
+ var compositionPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.composition.sharedState.currentState();
19
+ if (isCursorInsideCodeBlock(state) && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing)) {
60
20
  var beforeText = getStartOfCurrentLine(state).text;
61
21
  var afterText = getEndOfCurrentLine(state).text;
62
- var _getAutoClosingBracke2 = getAutoClosingBracketInfo(beforeText, afterText),
63
- leftBracket = _getAutoClosingBracke2.left,
64
- rightBracket = _getAutoClosingBracke2.right,
65
- hasTrailingMatchingBracket = _getAutoClosingBracke2.hasTrailingMatchingBracket;
66
- if (leftBracket && rightBracket && hasTrailingMatchingBracket && dispatch) {
67
- dispatch(state.tr.delete($cursor.pos - leftBracket.length, $cursor.pos + rightBracket.length));
22
+
23
+ // If text is a closing bracket/quote and we've already inserted it, move the selection after
24
+ if (isCursorBeforeClosingCharacter(afterText) && isClosingCharacter(text) && afterText.startsWith(text)) {
25
+ dispatch(setTextSelection(to + text.length)(state.tr));
68
26
  return true;
69
27
  }
70
- var _getAutoClosingQuoteI2 = getAutoClosingQuoteInfo(beforeText, afterText),
71
- leftQuote = _getAutoClosingQuoteI2.left,
72
- rightQuote = _getAutoClosingQuoteI2.right,
73
- hasTrailingMatchingQuote = _getAutoClosingQuoteI2.hasTrailingMatchingQuote;
74
- if (leftQuote && rightQuote && hasTrailingMatchingQuote && dispatch) {
75
- dispatch(state.tr.delete($cursor.pos - leftQuote.length, $cursor.pos + rightQuote.length));
76
- return true;
28
+
29
+ // Automatically add right-hand side bracket when user types the left bracket
30
+ if (shouldAutoCloseBracket(beforeText, afterText)) {
31
+ var _getAutoClosingBracke = getAutoClosingBracketInfo(beforeText + text, afterText),
32
+ left = _getAutoClosingBracke.left,
33
+ right = _getAutoClosingBracke.right;
34
+ if (left && right) {
35
+ var bracketPair = state.schema.text(text + right);
36
+ var tr = state.tr.replaceWith(from, to, bracketPair);
37
+ dispatch(setTextSelection(from + text.length)(tr));
38
+ return true;
39
+ }
77
40
  }
78
- var _getLineInfo = getLineInfo(beforeText),
79
- _getLineInfo$indentTo = _getLineInfo.indentToken,
80
- size = _getLineInfo$indentTo.size,
81
- token = _getLineInfo$indentTo.token,
82
- indentText = _getLineInfo.indentText;
83
- if (beforeText === indentText) {
84
- if (indentText.endsWith(token.repeat(size)) && dispatch) {
85
- dispatch(state.tr.delete($cursor.pos - (size - indentText.length % size || size), $cursor.pos));
41
+
42
+ // Automatically add closing quote when user types a starting quote
43
+ if (shouldAutoCloseQuote(beforeText, afterText)) {
44
+ var _getAutoClosingQuoteI = getAutoClosingQuoteInfo(beforeText + text, afterText),
45
+ leftQuote = _getAutoClosingQuoteI.left,
46
+ rightQuote = _getAutoClosingQuoteI.right;
47
+ if (leftQuote && rightQuote) {
48
+ var quotePair = state.schema.text(text + rightQuote);
49
+ var _tr = state.tr.replaceWith(from, to, quotePair);
50
+ dispatch(setTextSelection(from + text.length)(_tr));
86
51
  return true;
87
52
  }
88
53
  }
89
54
  }
90
55
  return false;
91
56
  },
92
- Enter: filter(isSelectionEntirelyInsideCodeBlock, insertNewlineWithIndent),
93
- 'Mod-]': filter(isSelectionEntirelyInsideCodeBlock, indent),
94
- 'Mod-[': filter(isSelectionEntirelyInsideCodeBlock, outdent),
95
- Tab: filter(isSelectionEntirelyInsideCodeBlock, function (state, dispatch) {
96
- if (!dispatch) {
57
+ handleKeyDown: keydownHandler({
58
+ Backspace: function Backspace(state, dispatch) {
59
+ if (isCursorInsideCodeBlock(state)) {
60
+ var $cursor = getCursor(state.selection);
61
+ var beforeText = getStartOfCurrentLine(state).text;
62
+ var afterText = getEndOfCurrentLine(state).text;
63
+ var _getAutoClosingBracke2 = getAutoClosingBracketInfo(beforeText, afterText),
64
+ leftBracket = _getAutoClosingBracke2.left,
65
+ rightBracket = _getAutoClosingBracke2.right,
66
+ hasTrailingMatchingBracket = _getAutoClosingBracke2.hasTrailingMatchingBracket;
67
+ if (leftBracket && rightBracket && hasTrailingMatchingBracket && dispatch) {
68
+ dispatch(state.tr.delete($cursor.pos - leftBracket.length, $cursor.pos + rightBracket.length));
69
+ return true;
70
+ }
71
+ var _getAutoClosingQuoteI2 = getAutoClosingQuoteInfo(beforeText, afterText),
72
+ leftQuote = _getAutoClosingQuoteI2.left,
73
+ rightQuote = _getAutoClosingQuoteI2.right,
74
+ hasTrailingMatchingQuote = _getAutoClosingQuoteI2.hasTrailingMatchingQuote;
75
+ if (leftQuote && rightQuote && hasTrailingMatchingQuote && dispatch) {
76
+ dispatch(state.tr.delete($cursor.pos - leftQuote.length, $cursor.pos + rightQuote.length));
77
+ return true;
78
+ }
79
+ var _getLineInfo = getLineInfo(beforeText),
80
+ _getLineInfo$indentTo = _getLineInfo.indentToken,
81
+ size = _getLineInfo$indentTo.size,
82
+ token = _getLineInfo$indentTo.token,
83
+ indentText = _getLineInfo.indentText;
84
+ if (beforeText === indentText) {
85
+ if (indentText.endsWith(token.repeat(size)) && dispatch) {
86
+ dispatch(state.tr.delete($cursor.pos - (size - indentText.length % size || size), $cursor.pos));
87
+ return true;
88
+ }
89
+ }
90
+ }
97
91
  return false;
98
- }
99
- if (isCursorInsideCodeBlock(state)) {
100
- return insertIndent(state, dispatch);
101
- }
102
- return indent(state, dispatch);
103
- }),
104
- 'Shift-Tab': filter(isSelectionEntirelyInsideCodeBlock, outdent),
105
- 'Mod-a': function ModA(state, dispatch) {
106
- if (isSelectionEntirelyInsideCodeBlock(state)) {
107
- var _state$selection = state.selection,
108
- $from = _state$selection.$from,
109
- $to = _state$selection.$to;
110
- var isFullCodeBlockSelection = $from.parentOffset === 0 && $to.parentOffset === $to.parent.nodeSize - 2;
111
- if (!isFullCodeBlockSelection && dispatch) {
112
- dispatch(state.tr.setSelection(TextSelection.create(state.doc, $from.start(), $to.end())));
113
- return true;
92
+ },
93
+ Enter: filter(isSelectionEntirelyInsideCodeBlock, insertNewlineWithIndent),
94
+ 'Mod-]': filter(isSelectionEntirelyInsideCodeBlock, indent),
95
+ 'Mod-[': filter(isSelectionEntirelyInsideCodeBlock, outdent),
96
+ Tab: filter(isSelectionEntirelyInsideCodeBlock, function (state, dispatch) {
97
+ if (!dispatch) {
98
+ return false;
99
+ }
100
+ if (isCursorInsideCodeBlock(state)) {
101
+ return insertIndent(state, dispatch);
114
102
  }
103
+ return indent(state, dispatch);
104
+ }),
105
+ 'Shift-Tab': filter(isSelectionEntirelyInsideCodeBlock, outdent),
106
+ 'Mod-a': function ModA(state, dispatch) {
107
+ if (isSelectionEntirelyInsideCodeBlock(state)) {
108
+ var _state$selection = state.selection,
109
+ $from = _state$selection.$from,
110
+ $to = _state$selection.$to;
111
+ var isFullCodeBlockSelection = $from.parentOffset === 0 && $to.parentOffset === $to.parent.nodeSize - 2;
112
+ if (!isFullCodeBlockSelection && dispatch) {
113
+ dispatch(state.tr.setSelection(TextSelection.create(state.doc, $from.start(), $to.end())));
114
+ return true;
115
+ }
116
+ }
117
+ return false;
115
118
  }
116
- return false;
117
- }
118
- })
119
- }
120
- });
119
+ })
120
+ }
121
+ });
122
+ };
123
+ export default ideUX;
@@ -0,0 +1,25 @@
1
+ import createPlugin from './pm-plugins/main';
2
+ import { pluginKey } from './pm-plugins/plugin-key';
3
+ var composition = function composition() {
4
+ return {
5
+ name: 'composition',
6
+ getSharedState: function getSharedState(editorState) {
7
+ var _pluginKey$getState;
8
+ if (!editorState) {
9
+ return undefined;
10
+ }
11
+ return {
12
+ isComposing: !!((_pluginKey$getState = pluginKey.getState(editorState)) !== null && _pluginKey$getState !== void 0 && _pluginKey$getState.isComposing)
13
+ };
14
+ },
15
+ pmPlugins: function pmPlugins() {
16
+ return [{
17
+ name: 'composition',
18
+ plugin: function plugin() {
19
+ return createPlugin();
20
+ }
21
+ }];
22
+ }
23
+ };
24
+ };
25
+ export default composition;
@@ -1,17 +1,12 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
2
  import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
4
- var compositionPluginKey = new PluginKey('compositionPlugin');
5
- export var isComposing = function isComposing(state) {
6
- var _compositionPluginKey;
7
- return !!((_compositionPluginKey = compositionPluginKey.getState(state)) !== null && _compositionPluginKey !== void 0 && _compositionPluginKey.isComposing);
8
- };
3
+ import { pluginKey } from './plugin-key';
9
4
  var isLinux = function isLinux() {
10
5
  return navigator.userAgent.indexOf('Linux') >= 0;
11
6
  };
12
7
  export default (function () {
13
8
  return new SafePlugin({
14
- key: compositionPluginKey,
9
+ key: pluginKey,
15
10
  state: {
16
11
  init: function init() {
17
12
  return {
@@ -20,7 +15,7 @@ export default (function () {
20
15
  };
21
16
  },
22
17
  apply: function apply(tr, value) {
23
- var isComposing = tr.getMeta(compositionPluginKey);
18
+ var isComposing = tr.getMeta(pluginKey);
24
19
  var zeroWidthSpacePos = tr.getMeta('zeroWidthSpacePos');
25
20
  if (typeof isComposing === 'undefined') {
26
21
  return value;
@@ -35,7 +30,7 @@ export default (function () {
35
30
  handleDOMEvents: {
36
31
  compositionstart: function compositionstart(view, event) {
37
32
  var tr = view.state.tr;
38
- tr.setMeta(compositionPluginKey, true);
33
+ tr.setMeta(pluginKey, true);
39
34
 
40
35
  // only apply for linux and cursor is at start of line
41
36
  if (isLinux() && view.state.selection.$from.parentOffset === 0) {
@@ -49,10 +44,10 @@ export default (function () {
49
44
  },
50
45
  compositionend: function compositionend(view, event) {
51
46
  var tr = view.state.tr;
52
- tr.setMeta(compositionPluginKey, false);
47
+ tr.setMeta(pluginKey, false);
53
48
  if (isLinux()) {
54
- var _compositionPluginKey2;
55
- var zeroWidthSpacePos = (_compositionPluginKey2 = compositionPluginKey.getState(view.state)) === null || _compositionPluginKey2 === void 0 ? void 0 : _compositionPluginKey2.zeroWidthSpacePos;
49
+ var _pluginKey$getState;
50
+ var zeroWidthSpacePos = (_pluginKey$getState = pluginKey.getState(view.state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.zeroWidthSpacePos;
56
51
  if (typeof zeroWidthSpacePos !== 'undefined') {
57
52
  tr.deleteRange(zeroWidthSpacePos, zeroWidthSpacePos + 1);
58
53
  }
@@ -0,0 +1,2 @@
1
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
+ export var pluginKey = new PluginKey('compositionPlugin');
@@ -132,8 +132,9 @@ var mediaPlugin = function mediaPlugin() {
132
132
  pmPlugins.push({
133
133
  name: 'mediaAltTextKeymap',
134
134
  plugin: function plugin(_ref4) {
135
+ var _api$dependencies$ana2;
135
136
  var schema = _ref4.schema;
136
- return keymapMediaAltTextPlugin(schema);
137
+ return keymapMediaAltTextPlugin(schema, 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);
137
138
  }
138
139
  });
139
140
  }
@@ -228,11 +229,11 @@ var mediaPlugin = function mediaPlugin() {
228
229
  return /*#__PURE__*/React.createElement(IconImages, null);
229
230
  },
230
231
  action: function action(insert, state) {
231
- var _api$dependencies$ana2;
232
+ var _api$dependencies$ana3;
232
233
  var pluginState = pluginKey.getState(state);
233
234
  pluginState === null || pluginState === void 0 ? void 0 : pluginState.showMediaPicker();
234
235
  var tr = insert('');
235
- 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.attachAnalyticsEvent({
236
+ 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.attachAnalyticsEvent({
236
237
  action: ACTION.OPENED,
237
238
  actionSubject: ACTION_SUBJECT.PICKER,
238
239
  actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
@@ -3,14 +3,17 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
4
  import { createCommand } from '.';
5
5
  import { isSelectionMediaSingleNode, getMediaNodeFromSelection } from '../../utils/media-common';
6
- import { ACTION_SUBJECT, EVENT_TYPE, withAnalytics, ACTION_SUBJECT_ID, ACTION } from '../../../analytics';
6
+ import { ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID, ACTION } from '@atlaskit/editor-common/analytics';
7
+ import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
7
8
  var createCommandWithAnalytics = function createCommandWithAnalytics(actionType, action, transform) {
8
- return withAnalytics({
9
- action: actionType,
10
- actionSubject: ACTION_SUBJECT.MEDIA,
11
- actionSubjectId: ACTION_SUBJECT_ID.ALT_TEXT,
12
- eventType: EVENT_TYPE.TRACK
13
- })(createCommand(action, transform));
9
+ return function (editorAnalyticsAPI) {
10
+ return withAnalytics(editorAnalyticsAPI, {
11
+ action: actionType,
12
+ actionSubject: ACTION_SUBJECT.MEDIA,
13
+ actionSubjectId: ACTION_SUBJECT_ID.ALT_TEXT,
14
+ eventType: EVENT_TYPE.TRACK
15
+ })(createCommand(action, transform));
16
+ };
14
17
  };
15
18
  export var closeMediaAltTextMenu = createCommand(function (state) {
16
19
  if (isSelectionMediaSingleNode(state)) {
@@ -1,9 +1,9 @@
1
1
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
2
2
  import * as keymaps from '../../../../keymaps';
3
3
  import { openMediaAltTextMenu, closeMediaAltTextMenu } from './commands';
4
- export default function keymapPlugin(schema) {
4
+ export default function keymapPlugin(schema, editorAnalyticsAPI) {
5
5
  var list = {};
6
- keymaps.bindKeymapWithCommand(keymaps.addAltText.common, openMediaAltTextMenu, list);
6
+ keymaps.bindKeymapWithCommand(keymaps.addAltText.common, openMediaAltTextMenu(editorAnalyticsAPI), list);
7
7
  keymaps.bindKeymapWithCommand(keymaps.escape.common, closeMediaAltTextMenu, list);
8
8
  return keymap(list);
9
9
  }
@@ -25,7 +25,7 @@ import * as helpers from '../commands/helpers';
25
25
  import { updateMediaSingleNodeAttrs } from '../commands/helpers';
26
26
  import { stateKey } from './plugin-key';
27
27
  import PickerFacade from '../picker-facade';
28
- import { INPUT_METHOD } from '../../analytics/types';
28
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
29
29
  import { isInEmptyLine } from '../../../utils/document';
30
30
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
31
31
  import { isInListItem } from '../../../utils';
@@ -224,16 +224,16 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
224
224
  });
225
225
  }
226
226
  if (isMediaSingle(state.schema, mediaStateWithContext.fileMimeType)) {
227
- var _this$pluginInjection;
227
+ var _this$pluginInjection, _pluginInjectionApi$d, _pluginInjectionApi$d2;
228
228
  // read width state right before inserting to get up-to-date and define values
229
229
  var widthPluginState = (_this$pluginInjection = _this.pluginInjectionApi) === null || _this$pluginInjection === void 0 ? void 0 : _this$pluginInjection.dependencies.width.sharedState.currentState();
230
- insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, _this.newInsertionBehaviour, widthPluginState);
230
+ insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, _this.newInsertionBehaviour, widthPluginState, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions);
231
231
  } else if (getMediaFeatureFlag('mediaInline', (_this$mediaOptions2 = _this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInListItem(state)) && canInsertMediaInline(state)) {
232
- var _pluginInjectionApi$d, _pluginInjectionApi$d2;
233
- insertMediaInlineNode(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions)(_this.view, mediaStateWithContext, collection, _this.getInputMethod(pickerType));
234
- } else {
235
232
  var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
236
- insertMediaGroupNode(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : (_pluginInjectionApi$d4 = _pluginInjectionApi$d3.analytics) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions)(_this.view, [mediaStateWithContext], collection, _this.getInputMethod(pickerType));
233
+ insertMediaInlineNode(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : (_pluginInjectionApi$d4 = _pluginInjectionApi$d3.analytics) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions)(_this.view, mediaStateWithContext, collection, _this.getInputMethod(pickerType));
234
+ } else {
235
+ var _pluginInjectionApi$d5, _pluginInjectionApi$d6;
236
+ insertMediaGroupNode(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d5 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : (_pluginInjectionApi$d6 = _pluginInjectionApi$d5.analytics) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : _pluginInjectionApi$d6.actions)(_this.view, [mediaStateWithContext], collection, _this.getInputMethod(pickerType));
237
237
  }
238
238
 
239
239
  // do events when media state changes
@@ -9,7 +9,7 @@ import AltTextEdit, { CONTAINER_WIDTH_IN_PX } from '../pm-plugins/alt-text/ui/Al
9
9
  import { getMediaNodeFromSelection } from '../utils/media-common';
10
10
  import { ClassNames } from '../pm-plugins/alt-text/style';
11
11
  var testId = 'alt-text-edit-button';
12
- export var altTextButton = function altTextButton(intl, state) {
12
+ export var altTextButton = function altTextButton(intl, state, editorAnalyticsAPI) {
13
13
  var mediaNode = getMediaNodeFromSelection(state);
14
14
  var message = mediaNode && mediaNode.attrs.alt ? messages.editAltText : messages.altText;
15
15
  var title = intl.formatMessage(message);
@@ -17,7 +17,7 @@ export var altTextButton = function altTextButton(intl, state) {
17
17
  title: title,
18
18
  id: 'editor.media.altText',
19
19
  type: 'button',
20
- onClick: openMediaAltTextMenu,
20
+ onClick: openMediaAltTextMenu(editorAnalyticsAPI),
21
21
  showTitle: true,
22
22
  testId: testId,
23
23
  tooltipContent: /*#__PURE__*/React.createElement(ToolTipContent, {
@@ -191,7 +191,7 @@ var generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToo
191
191
  return items;
192
192
  };
193
193
  var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToolbar(state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) {
194
- var _pluginInjectionApi$d7;
194
+ var _pluginInjectionApi$d8;
195
195
  var mediaSingle = state.schema.nodes.mediaSingle;
196
196
  var allowResizing = options.allowResizing,
197
197
  allowLinking = options.allowLinking,
@@ -347,11 +347,12 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
347
347
  }
348
348
  }
349
349
  if (allowAltTextOnImages) {
350
- toolbarButtons.push(altTextButton(intl, state), {
350
+ var _pluginInjectionApi$d7;
351
+ toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d7 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d7 === void 0 ? void 0 : _pluginInjectionApi$d7.actions), {
351
352
  type: 'separator'
352
353
  });
353
354
  }
354
- var _ref2 = (_pluginInjectionApi$d7 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d7 !== void 0 ? _pluginInjectionApi$d7 : {},
355
+ var _ref2 = (_pluginInjectionApi$d8 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d8 !== void 0 ? _pluginInjectionApi$d8 : {},
355
356
  hoverDecoration = _ref2.hoverDecoration;
356
357
  var removeButton = {
357
358
  id: 'editor.media.delete',
@@ -380,7 +381,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
380
381
  return items;
381
382
  };
382
383
  export var floatingToolbar = function floatingToolbar(state, intl) {
383
- var _pluginInjectionApi$d8;
384
+ var _pluginInjectionApi$d9;
384
385
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
385
386
  var pluginInjectionApi = arguments.length > 3 ? arguments[3] : undefined;
386
387
  var _state$schema$nodes = state.schema.nodes,
@@ -396,7 +397,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
396
397
  getEditorFeatureFlags = options.getEditorFeatureFlags;
397
398
  var mediaPluginState = stateKey.getState(state);
398
399
  var mediaLinkingState = getMediaLinkingState(state);
399
- var _ref3 = (_pluginInjectionApi$d8 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d8 !== void 0 ? _pluginInjectionApi$d8 : {},
400
+ var _ref3 = (_pluginInjectionApi$d9 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d9 !== void 0 ? _pluginInjectionApi$d9 : {},
400
401
  hoverDecoration = _ref3.hoverDecoration;
401
402
  if (!mediaPluginState || mediaPluginState.isResizing) {
402
403
  return;
@@ -418,10 +419,10 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
418
419
  if (allowAltTextOnImages) {
419
420
  var mediaAltTextPluginState = getMediaAltTextPluginState(state);
420
421
  if (mediaAltTextPluginState.isAltTextEditorOpen) {
421
- var _pluginInjectionApi$d9;
422
+ var _pluginInjectionApi$d10;
422
423
  return getAltTextToolbar(baseToolbar, {
423
424
  altTextValidator: altTextValidator,
424
- forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d9 = pluginInjectionApi.dependencies.floatingToolbar.actions) === null || _pluginInjectionApi$d9 === void 0 ? void 0 : _pluginInjectionApi$d9.forceFocusSelector
425
+ forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d10 = pluginInjectionApi.dependencies.floatingToolbar.actions) === null || _pluginInjectionApi$d10 === void 0 ? void 0 : _pluginInjectionApi$d10.forceFocusSelector
425
426
  });
426
427
  }
427
428
  }
@@ -432,22 +433,22 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
432
433
  selectedNodeType = state.selection.node.type;
433
434
  }
434
435
  if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
435
- var _pluginInjectionApi$d10, _pluginInjectionApi$d11;
436
+ var _pluginInjectionApi$d11, _pluginInjectionApi$d12;
436
437
  var mediaOffset = state.selection.$from.parentOffset + 1;
437
438
  baseToolbar.getDomRef = function () {
438
439
  var _mediaPluginState$ele;
439
440
  var selector = mediaFilmstripItemDOMSelector(mediaOffset);
440
441
  return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
441
442
  };
442
- items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d10 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d10 === void 0 ? void 0 : (_pluginInjectionApi$d11 = _pluginInjectionApi$d10.analytics) === null || _pluginInjectionApi$d11 === void 0 ? void 0 : _pluginInjectionApi$d11.actions);
443
+ items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d11 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d11 === void 0 ? void 0 : (_pluginInjectionApi$d12 = _pluginInjectionApi$d11.analytics) === null || _pluginInjectionApi$d12 === void 0 ? void 0 : _pluginInjectionApi$d12.actions);
443
444
  } else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
444
- var _pluginInjectionApi$d12, _pluginInjectionApi$d13;
445
+ var _pluginInjectionApi$d13, _pluginInjectionApi$d14;
445
446
  baseToolbar.getDomRef = function () {
446
447
  var _mediaPluginState$ele2;
447
448
  var element = (_mediaPluginState$ele2 = mediaPluginState.element) === null || _mediaPluginState$ele2 === void 0 ? void 0 : _mediaPluginState$ele2.querySelector(".".concat(MediaInlineNodeSelector));
448
449
  return element || mediaPluginState.element;
449
450
  };
450
- items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d12 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d12 === void 0 ? void 0 : (_pluginInjectionApi$d13 = _pluginInjectionApi$d12.analytics) === null || _pluginInjectionApi$d13 === void 0 ? void 0 : _pluginInjectionApi$d13.actions);
451
+ items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d13 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d13 === void 0 ? void 0 : (_pluginInjectionApi$d14 = _pluginInjectionApi$d13.analytics) === null || _pluginInjectionApi$d14 === void 0 ? void 0 : _pluginInjectionApi$d14.actions);
451
452
  } else {
452
453
  baseToolbar.getDomRef = function () {
453
454
  var _mediaPluginState$ele3;
@@ -8,7 +8,6 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
8
8
  import { getMediaSingleInitialWidth } from '@atlaskit/editor-common/media-single';
9
9
  import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
10
10
  import { mapSlice } from '../../../utils/slice';
11
- import { addAnalytics } from '../../analytics';
12
11
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
13
12
  import { safeInsert, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
14
13
  import { isImage } from './is-image';
@@ -33,6 +32,7 @@ function shouldAddParagraph(state) {
33
32
  }
34
33
  function insertNodesWithOptionalParagraph(nodes) {
35
34
  var analyticsAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
35
+ var editorAnalyticsAPI = arguments.length > 2 ? arguments[2] : undefined;
36
36
  return function (state, dispatch) {
37
37
  var tr = state.tr,
38
38
  schema = state.schema;
@@ -46,7 +46,7 @@ function insertNodesWithOptionalParagraph(nodes) {
46
46
  }
47
47
  tr.replaceSelection(new Slice(Fragment.from(nodes), 0, openEnd));
48
48
  if (inputMethod) {
49
- addAnalytics(state, tr, getInsertMediaAnalytics(inputMethod, fileExtension));
49
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension))(tr);
50
50
  }
51
51
  if (dispatch) {
52
52
  dispatch(tr);
@@ -57,7 +57,7 @@ function insertNodesWithOptionalParagraph(nodes) {
57
57
  export var isMediaSingle = function isMediaSingle(schema, fileMimeType) {
58
58
  return !!schema.nodes.mediaSingle && isImage(fileMimeType);
59
59
  };
60
- export var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inputMethod) {
60
+ export var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inputMethod, editorAnalyticsAPI) {
61
61
  var state = view.state,
62
62
  dispatch = view.dispatch;
63
63
  var _state$schema$nodes = state.schema.nodes,
@@ -77,9 +77,9 @@ export var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, no
77
77
  inputMethod: inputMethod,
78
78
  fileExtension: node.attrs.__fileMimeType
79
79
  };
80
- return insertNodesWithOptionalParagraph(nodes, analyticsAttributes)(state, dispatch);
80
+ return insertNodesWithOptionalParagraph(nodes, analyticsAttributes, editorAnalyticsAPI)(state, dispatch);
81
81
  };
82
- export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour, widthPluginState) {
82
+ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour, widthPluginState, editorAnalyticsAPI) {
83
83
  var _state$selection$$fro;
84
84
  if (collection === undefined) {
85
85
  return false;
@@ -110,7 +110,7 @@ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaSta
110
110
  insertNodesWithOptionalParagraph([node], {
111
111
  fileExtension: fileExtension,
112
112
  inputMethod: inputMethod
113
- })(state, dispatch);
113
+ }, editorAnalyticsAPI)(state, dispatch);
114
114
  } else {
115
115
  var tr = null;
116
116
  if (newInsertionBehaviour) {
@@ -121,7 +121,7 @@ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaSta
121
121
  tr = pmSafeInsert(content, undefined, true)(state.tr);
122
122
  }
123
123
  if (inputMethod) {
124
- tr = addAnalytics(state, tr, getInsertMediaAnalytics(inputMethod, fileExtension));
124
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension))(tr);
125
125
  }
126
126
  dispatch(tr);
127
127
  }
@@ -25,7 +25,6 @@ import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } f
25
25
  import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
26
26
  import { doesSelectionWhichStartsOrEndsInListContainEntireList } from '../../utils/lists';
27
27
  import { anyMarkActive } from '@atlaskit/editor-common/mark';
28
-
29
28
  // remove text attribute from mention for copy/paste (GDPR)
30
29
  export function handleMention(slice, schema) {
31
30
  return mapSlice(slice, function (node) {
@@ -522,12 +521,12 @@ function isOnlyMediaSingle(state, slice) {
522
521
  var mediaSingle = state.schema.nodes.mediaSingle;
523
522
  return mediaSingle && slice.content.childCount === 1 && slice.content.firstChild.type === mediaSingle;
524
523
  }
525
- export function handleMediaSingle(inputMethod) {
524
+ export function handleMediaSingle(inputMethod, editorAnalyticsAPI) {
526
525
  return function (slice) {
527
526
  return function (state, dispatch, view) {
528
527
  if (view) {
529
528
  if (isOnlyMedia(state, slice)) {
530
- return insertMediaAsMediaSingle(view, slice.content.firstChild, inputMethod);
529
+ return insertMediaAsMediaSingle(view, slice.content.firstChild, inputMethod, editorAnalyticsAPI);
531
530
  }
532
531
  if (insideTable(state) && isOnlyMediaSingle(state, slice)) {
533
532
  var tr = state.tr.replaceSelection(slice);
@@ -239,10 +239,10 @@ export var handleCodeBlockWithAnalytics = function handleCodeBlockWithAnalytics(
239
239
  type: PasteTypes.plain
240
240
  }))(handleCodeBlock(text));
241
241
  };
242
- export var handleMediaSingleWithAnalytics = function handleMediaSingleWithAnalytics(view, event, slice, type) {
242
+ export var handleMediaSingleWithAnalytics = function handleMediaSingleWithAnalytics(view, event, slice, type, editorAnalyticsAPI) {
243
243
  return injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
244
244
  type: type
245
- }))(handleMediaSingle(INPUT_METHOD.CLIPBOARD)(slice));
245
+ }))(handleMediaSingle(INPUT_METHOD.CLIPBOARD, editorAnalyticsAPI)(slice));
246
246
  };
247
247
  export var handlePastePreservingMarksWithAnalytics = function handlePastePreservingMarksWithAnalytics(view, event, slice, type, pluginInjectionApi) {
248
248
  var _pluginInjectionApi$d3, _pluginInjectionApi$d4;