@atlaskit/editor-core 188.13.1 → 188.13.3

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 (57) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/plugins/code-block/actions.js +27 -25
  3. package/dist/cjs/plugins/code-block/ide-ux/commands.js +64 -60
  4. package/dist/cjs/plugins/code-block/index.js +1 -1
  5. package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +6 -4
  6. package/dist/cjs/plugins/code-block/toolbar.js +8 -5
  7. package/dist/cjs/plugins/layout/actions.js +53 -50
  8. package/dist/cjs/plugins/layout/index.js +1 -2
  9. package/dist/cjs/plugins/layout/toolbar.js +10 -6
  10. package/dist/cjs/plugins/panel/actions.js +59 -56
  11. package/dist/cjs/plugins/panel/index.js +18 -10
  12. package/dist/cjs/plugins/panel/toolbar.js +11 -11
  13. package/dist/cjs/plugins/undo-redo/pm-plugins/keymaps.js +10 -1
  14. package/dist/cjs/version-wrapper.js +1 -1
  15. package/dist/es2019/plugins/code-block/actions.js +4 -4
  16. package/dist/es2019/plugins/code-block/ide-ux/commands.js +9 -9
  17. package/dist/es2019/plugins/code-block/index.js +1 -1
  18. package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +6 -4
  19. package/dist/es2019/plugins/code-block/toolbar.js +7 -3
  20. package/dist/es2019/plugins/layout/actions.js +6 -7
  21. package/dist/es2019/plugins/layout/index.js +1 -2
  22. package/dist/es2019/plugins/layout/toolbar.js +10 -5
  23. package/dist/es2019/plugins/panel/actions.js +8 -7
  24. package/dist/es2019/plugins/panel/index.js +18 -10
  25. package/dist/es2019/plugins/panel/toolbar.js +11 -11
  26. package/dist/es2019/plugins/undo-redo/pm-plugins/keymaps.js +11 -2
  27. package/dist/es2019/version-wrapper.js +1 -1
  28. package/dist/esm/plugins/code-block/actions.js +27 -25
  29. package/dist/esm/plugins/code-block/ide-ux/commands.js +62 -58
  30. package/dist/esm/plugins/code-block/index.js +1 -1
  31. package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +6 -4
  32. package/dist/esm/plugins/code-block/toolbar.js +8 -5
  33. package/dist/esm/plugins/layout/actions.js +53 -50
  34. package/dist/esm/plugins/layout/index.js +1 -2
  35. package/dist/esm/plugins/layout/toolbar.js +10 -6
  36. package/dist/esm/plugins/panel/actions.js +59 -56
  37. package/dist/esm/plugins/panel/index.js +18 -10
  38. package/dist/esm/plugins/panel/toolbar.js +11 -11
  39. package/dist/esm/plugins/undo-redo/pm-plugins/keymaps.js +11 -2
  40. package/dist/esm/version-wrapper.js +1 -1
  41. package/dist/types/plugins/code-block/actions.d.ts +1 -1
  42. package/dist/types/plugins/code-block/ide-ux/commands.d.ts +4 -3
  43. package/dist/types/plugins/code-block/toolbar.d.ts +3 -3
  44. package/dist/types/plugins/layout/actions.d.ts +2 -2
  45. package/dist/types/plugins/layout/toolbar.d.ts +3 -3
  46. package/dist/types/plugins/panel/actions.d.ts +4 -4
  47. package/dist/types/plugins/panel/index.d.ts +1 -1
  48. package/dist/types/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
  49. package/dist/types-ts4.5/plugins/code-block/actions.d.ts +1 -1
  50. package/dist/types-ts4.5/plugins/code-block/ide-ux/commands.d.ts +4 -3
  51. package/dist/types-ts4.5/plugins/code-block/toolbar.d.ts +3 -3
  52. package/dist/types-ts4.5/plugins/layout/actions.d.ts +2 -2
  53. package/dist/types-ts4.5/plugins/layout/toolbar.d.ts +3 -3
  54. package/dist/types-ts4.5/plugins/panel/actions.d.ts +4 -4
  55. package/dist/types-ts4.5/plugins/panel/index.d.ts +1 -1
  56. package/dist/types-ts4.5/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
  57. package/package.json +2 -2
@@ -10,7 +10,7 @@ var _adfSchema = require("@atlaskit/adf-schema");
10
10
  var _main = require("./pm-plugins/main");
11
11
  var _toolbar = require("./toolbar");
12
12
  var _keymaps = _interopRequireDefault(require("./pm-plugins/keymaps"));
13
- var _analytics = require("../analytics");
13
+ var _analytics = require("@atlaskit/editor-common/analytics");
14
14
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
15
15
  var _utils = require("@atlaskit/editor-common/utils");
16
16
  var _messages = require("@atlaskit/editor-common/messages");
@@ -67,7 +67,8 @@ var panelPlugin = function panelPlugin(_ref) {
67
67
  state: state,
68
68
  attributes: {
69
69
  panelType: _adfSchema.PanelType.INFO
70
- }
70
+ },
71
+ api: api
71
72
  });
72
73
  }
73
74
  }, {
@@ -83,7 +84,8 @@ var panelPlugin = function panelPlugin(_ref) {
83
84
  state: state,
84
85
  attributes: {
85
86
  panelType: _adfSchema.PanelType.NOTE
86
- }
87
+ },
88
+ api: api
87
89
  });
88
90
  }
89
91
  }, {
@@ -100,7 +102,8 @@ var panelPlugin = function panelPlugin(_ref) {
100
102
  state: state,
101
103
  attributes: {
102
104
  panelType: _adfSchema.PanelType.SUCCESS
103
- }
105
+ },
106
+ api: api
104
107
  });
105
108
  }
106
109
  }, {
@@ -116,7 +119,8 @@ var panelPlugin = function panelPlugin(_ref) {
116
119
  state: state,
117
120
  attributes: {
118
121
  panelType: _adfSchema.PanelType.WARNING
119
- }
122
+ },
123
+ api: api
120
124
  });
121
125
  }
122
126
  }, {
@@ -132,7 +136,8 @@ var panelPlugin = function panelPlugin(_ref) {
132
136
  state: state,
133
137
  attributes: {
134
138
  panelType: _adfSchema.PanelType.ERROR
135
- }
139
+ },
140
+ api: api
136
141
  });
137
142
  }
138
143
  }];
@@ -156,7 +161,8 @@ var panelPlugin = function panelPlugin(_ref) {
156
161
  // TODO: https://product-fabric.atlassian.net/browse/DSP-7268
157
162
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
158
163
  panelColor: _colors.T50
159
- }
164
+ },
165
+ api: api
160
166
  });
161
167
  }
162
168
  });
@@ -184,14 +190,16 @@ var panelPlugin = function panelPlugin(_ref) {
184
190
  */
185
191
  function createPanelAction(_ref4) {
186
192
  var state = _ref4.state,
187
- attributes = _ref4.attributes;
193
+ attributes = _ref4.attributes,
194
+ api = _ref4.api;
188
195
  var tr = (0, _utils.createWrapSelectionTransaction)({
189
196
  state: state,
190
197
  type: state.schema.nodes.panel,
191
198
  nodeAttributes: attributes
192
199
  });
193
200
  if (tr) {
194
- (0, _analytics.addAnalytics)(state, tr, {
201
+ var _api$analytics2;
202
+ api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
195
203
  action: _analytics.ACTION.INSERTED,
196
204
  actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
197
205
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.PANEL,
@@ -200,7 +208,7 @@ function createPanelAction(_ref4) {
200
208
  panelType: attributes.panelType
201
209
  },
202
210
  eventType: _analytics.EVENT_TYPE.TRACK
203
- });
211
+ })(tr);
204
212
  }
205
213
  return tr;
206
214
  }
@@ -52,7 +52,7 @@ var getToolbarItems = exports.getToolbarItems = function getToolbarItems(formatM
52
52
  id: 'editor.panel.info',
53
53
  type: 'button',
54
54
  icon: _info.default,
55
- onClick: (0, _actions.changePanelType)(_adfSchema.PanelType.INFO),
55
+ onClick: (0, _actions.changePanelType)(editorAnalyticsAPI)(_adfSchema.PanelType.INFO),
56
56
  selected: activePanelType === _adfSchema.PanelType.INFO,
57
57
  title: formatMessage(_message.messages.info),
58
58
  tabIndex: null
@@ -60,7 +60,7 @@ var getToolbarItems = exports.getToolbarItems = function getToolbarItems(formatM
60
60
  id: 'editor.panel.note',
61
61
  type: 'button',
62
62
  icon: _note.default,
63
- onClick: (0, _actions.changePanelType)(_adfSchema.PanelType.NOTE),
63
+ onClick: (0, _actions.changePanelType)(editorAnalyticsAPI)(_adfSchema.PanelType.NOTE),
64
64
  selected: activePanelType === _adfSchema.PanelType.NOTE,
65
65
  title: formatMessage(_message.messages.note),
66
66
  tabIndex: null
@@ -68,7 +68,7 @@ var getToolbarItems = exports.getToolbarItems = function getToolbarItems(formatM
68
68
  id: 'editor.panel.success',
69
69
  type: 'button',
70
70
  icon: _success.default,
71
- onClick: (0, _actions.changePanelType)(_adfSchema.PanelType.SUCCESS),
71
+ onClick: (0, _actions.changePanelType)(editorAnalyticsAPI)(_adfSchema.PanelType.SUCCESS),
72
72
  selected: activePanelType === _adfSchema.PanelType.SUCCESS,
73
73
  title: formatMessage(_message.messages.success),
74
74
  tabIndex: null
@@ -76,7 +76,7 @@ var getToolbarItems = exports.getToolbarItems = function getToolbarItems(formatM
76
76
  id: 'editor.panel.warning',
77
77
  type: 'button',
78
78
  icon: _warning.default,
79
- onClick: (0, _actions.changePanelType)(_adfSchema.PanelType.WARNING),
79
+ onClick: (0, _actions.changePanelType)(editorAnalyticsAPI)(_adfSchema.PanelType.WARNING),
80
80
  selected: activePanelType === _adfSchema.PanelType.WARNING,
81
81
  title: formatMessage(_message.messages.warning),
82
82
  tabIndex: null
@@ -84,7 +84,7 @@ var getToolbarItems = exports.getToolbarItems = function getToolbarItems(formatM
84
84
  id: 'editor.panel.error',
85
85
  type: 'button',
86
86
  icon: _error.default,
87
- onClick: (0, _actions.changePanelType)(_adfSchema.PanelType.ERROR),
87
+ onClick: (0, _actions.changePanelType)(editorAnalyticsAPI)(_adfSchema.PanelType.ERROR),
88
88
  selected: activePanelType === _adfSchema.PanelType.ERROR,
89
89
  title: formatMessage(_message.messages.error),
90
90
  tabIndex: null
@@ -104,7 +104,7 @@ var getToolbarItems = exports.getToolbarItems = function getToolbarItems(formatM
104
104
  emojiId: panelEmoji.id
105
105
  } : {};
106
106
  if (previousColor === color) {
107
- (0, _actions.changePanelType)(_adfSchema.PanelType.CUSTOM, _objectSpread({
107
+ (0, _actions.changePanelType)(editorAnalyticsAPI)(_adfSchema.PanelType.CUSTOM, _objectSpread({
108
108
  color: color
109
109
  }, previousEmoji), isCustomPanelEnabled)(state, dispatch);
110
110
  return false;
@@ -119,7 +119,7 @@ var getToolbarItems = exports.getToolbarItems = function getToolbarItems(formatM
119
119
  },
120
120
  eventType: _analytics.EVENT_TYPE.TRACK
121
121
  };
122
- (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, payload)((0, _actions.changePanelType)(_adfSchema.PanelType.CUSTOM, _objectSpread({
122
+ (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, payload)((0, _actions.changePanelType)(editorAnalyticsAPI)(_adfSchema.PanelType.CUSTOM, _objectSpread({
123
123
  color: color
124
124
  }, previousEmoji), isCustomPanelEnabled))(state, dispatch);
125
125
  return false;
@@ -133,7 +133,7 @@ var getToolbarItems = exports.getToolbarItems = function getToolbarItems(formatM
133
133
  }
134
134
  var previousIcon = panelNode.node.attrs.panelIcon || '';
135
135
  if (previousIcon === emoji.shortName) {
136
- (0, _actions.changePanelType)(_adfSchema.PanelType.CUSTOM, {
136
+ (0, _actions.changePanelType)(editorAnalyticsAPI)(_adfSchema.PanelType.CUSTOM, {
137
137
  emoji: emoji.shortName,
138
138
  emojiId: emoji.id,
139
139
  emojiText: emoji.fallback
@@ -150,7 +150,7 @@ var getToolbarItems = exports.getToolbarItems = function getToolbarItems(formatM
150
150
  },
151
151
  eventType: _analytics.EVENT_TYPE.TRACK
152
152
  };
153
- (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, payload)((0, _actions.changePanelType)(_adfSchema.PanelType.CUSTOM, {
153
+ (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, payload)((0, _actions.changePanelType)(editorAnalyticsAPI)(_adfSchema.PanelType.CUSTOM, {
154
154
  emoji: emoji.shortName,
155
155
  emojiId: emoji.id,
156
156
  emojiText: emoji.fallback
@@ -176,7 +176,7 @@ var getToolbarItems = exports.getToolbarItems = function getToolbarItems(formatM
176
176
  },
177
177
  eventType: _analytics.EVENT_TYPE.TRACK
178
178
  };
179
- (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, payload)((0, _actions.changePanelType)(_adfSchema.PanelType.CUSTOM, {
179
+ (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, payload)((0, _actions.changePanelType)(editorAnalyticsAPI)(_adfSchema.PanelType.CUSTOM, {
180
180
  emoji: undefined,
181
181
  emojiId: undefined,
182
182
  emojiText: undefined
@@ -248,7 +248,7 @@ var getToolbarItems = exports.getToolbarItems = function getToolbarItems(formatM
248
248
  appearance: 'danger',
249
249
  focusEditoronEnter: true,
250
250
  icon: _remove.default,
251
- onClick: (0, _actions.removePanel)(),
251
+ onClick: (0, _actions.removePanel)(editorAnalyticsAPI),
252
252
  onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(panelNodeType, true),
253
253
  onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(panelNodeType, false),
254
254
  onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(panelNodeType, true),
@@ -4,11 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.keymapPlugin = keymapPlugin;
7
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
7
8
  var _keymaps = require("@atlaskit/editor-common/keymaps");
8
9
  var _commands = require("../commands");
10
+ var _keymap = require("@atlaskit/editor-prosemirror/keymap");
9
11
  function keymapPlugin() {
10
12
  var list = {};
11
13
  (0, _keymaps.bindKeymapWithCommand)((0, _keymaps.findKeyMapForBrowser)(_keymaps.redo), _commands.redoFromKeyboard, list);
12
14
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.undo.common, _commands.undoFromKeyboard, list);
13
- return (0, _keymaps.keymap)(list);
15
+ return new _safePlugin.SafePlugin({
16
+ props: {
17
+ handleKeyDown: function handleKeyDown(view, event) {
18
+ var keyboardEvent = (0, _keymaps.isCapsLockOnAndModifyKeyboardEvent)(event);
19
+ return (0, _keymap.keydownHandler)(list)(view, keyboardEvent);
20
+ }
21
+ }
22
+ });
14
23
  }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/editor-core";
8
- var version = exports.version = "188.13.1";
8
+ var version = exports.version = "188.13.3";
9
9
  var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
10
10
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
11
11
  };
@@ -4,7 +4,6 @@ import { pluginKey } from './plugin-key';
4
4
  import { copySelectionPluginKey } from './pm-plugins/codeBlockCopySelectionPlugin';
5
5
  import { ACTIONS } from './pm-plugins/actions';
6
6
  import { copyToClipboard } from '../../utils/clipboard';
7
- import { addAnalytics } from '../analytics/utils';
8
7
  import { shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
9
8
  import { transformToCodeBlockAction } from './transform-to-code-block';
10
9
  import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
@@ -27,7 +26,7 @@ export const removeCodeBlock = (state, dispatch) => {
27
26
  }
28
27
  return true;
29
28
  };
30
- export const changeLanguage = language => (state, dispatch) => {
29
+ export const changeLanguage = editorAnalyticsAPI => language => (state, dispatch) => {
31
30
  var _pluginKey$getState;
32
31
  const {
33
32
  codeBlock
@@ -42,14 +41,15 @@ export const changeLanguage = language => (state, dispatch) => {
42
41
  const selection = isNodeSelection(state.selection) ? NodeSelection.create(tr.doc, pos) : tr.selection;
43
42
  const result = tr.setSelection(selection);
44
43
  if (dispatch) {
45
- dispatch(addAnalytics(state, result, {
44
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
46
45
  action: ACTION.LANGUAGE_SELECTED,
47
46
  actionSubject: ACTION_SUBJECT.CODE_BLOCK,
48
47
  attributes: {
49
48
  language
50
49
  },
51
50
  eventType: EVENT_TYPE.TRACK
52
- }));
51
+ })(result);
52
+ dispatch(result);
53
53
  }
54
54
  return true;
55
55
  };
@@ -1,6 +1,6 @@
1
1
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { getLinesFromSelection, getLineInfo, forEachLine, getStartOfCurrentLine } from './line-handling';
3
- import { addAnalytics, ACTION, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, INDENT_DIRECTION, INDENT_TYPE, ACTION_SUBJECT } from '../../analytics';
3
+ import { ACTION, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, INDENT_DIRECTION, INDENT_TYPE, ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
4
4
  /**
5
5
  * Return the current indentation level
6
6
  * @param indentText - Text in the code block that represent an indentation
@@ -12,7 +12,7 @@ function getIndentLevel(indentText, indentSize) {
12
12
  }
13
13
  return indentText.length / indentSize;
14
14
  }
15
- export function indent(state, dispatch) {
15
+ export const indent = editorAnalyticsAPI => (state, dispatch) => {
16
16
  const {
17
17
  text,
18
18
  start
@@ -29,7 +29,7 @@ export function indent(state, dispatch) {
29
29
  const indentLevel = getIndentLevel(indentText, indentToken.size);
30
30
  const indentToAdd = indentToken.token.repeat(indentToken.size - indentText.length % indentToken.size || indentToken.size);
31
31
  tr.insertText(indentToAdd, tr.mapping.map(start + offset, -1));
32
- addAnalytics(state, tr, {
32
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
33
33
  action: ACTION.FORMATTED,
34
34
  actionSubject: ACTION_SUBJECT.TEXT,
35
35
  actionSubjectId: ACTION_SUBJECT_ID.FORMAT_INDENT,
@@ -41,7 +41,7 @@ export function indent(state, dispatch) {
41
41
  direction: INDENT_DIRECTION.INDENT,
42
42
  indentType: INDENT_TYPE.CODE_BLOCK
43
43
  }
44
- });
44
+ })(tr);
45
45
  if (!selection.empty) {
46
46
  tr.setSelection(TextSelection.create(tr.doc, tr.mapping.map(selection.from, -1), tr.selection.to));
47
47
  }
@@ -50,8 +50,8 @@ export function indent(state, dispatch) {
50
50
  dispatch(tr);
51
51
  }
52
52
  return true;
53
- }
54
- export function outdent(state, dispatch) {
53
+ };
54
+ export const outdent = editorAnalyticsAPI => (state, dispatch) => {
55
55
  const {
56
56
  text,
57
57
  start
@@ -68,7 +68,7 @@ export function outdent(state, dispatch) {
68
68
  const indentLevel = getIndentLevel(indentText, indentToken.size);
69
69
  const unindentLength = indentText.length % indentToken.size || indentToken.size;
70
70
  tr.delete(tr.mapping.map(start + offset), tr.mapping.map(start + offset + unindentLength));
71
- addAnalytics(state, tr, {
71
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
72
72
  action: ACTION.FORMATTED,
73
73
  actionSubject: ACTION_SUBJECT.TEXT,
74
74
  actionSubjectId: ACTION_SUBJECT_ID.FORMAT_INDENT,
@@ -80,14 +80,14 @@ export function outdent(state, dispatch) {
80
80
  direction: INDENT_DIRECTION.OUTDENT,
81
81
  indentType: INDENT_TYPE.CODE_BLOCK
82
82
  }
83
- });
83
+ })(tr);
84
84
  }
85
85
  });
86
86
  if (dispatch) {
87
87
  dispatch(tr);
88
88
  }
89
89
  return true;
90
- }
90
+ };
91
91
  export function insertIndent(state, dispatch) {
92
92
  const {
93
93
  text: textAtStartOfLine
@@ -98,7 +98,7 @@ const codeBlockPlugin = ({
98
98
  return tr;
99
99
  }
100
100
  }],
101
- floatingToolbar: getToolbarConfig(options === null || options === void 0 ? void 0 : options.allowCopyToClipboard, api === null || api === void 0 ? void 0 : api.decorations.actions.hoverDecoration)
101
+ floatingToolbar: getToolbarConfig(options === null || options === void 0 ? void 0 : options.allowCopyToClipboard, api)
102
102
  }
103
103
  });
104
104
  export default codeBlockPlugin;
@@ -10,6 +10,8 @@ import { getAutoClosingQuoteInfo, shouldAutoCloseQuote } from '../ide-ux/quote-h
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
12
  const ideUX = pluginInjectionApi => {
13
+ var _pluginInjectionApi$a;
14
+ const editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
13
15
  return new SafePlugin({
14
16
  props: {
15
17
  handleTextInput(view, from, to, text) {
@@ -100,8 +102,8 @@ const ideUX = pluginInjectionApi => {
100
102
  return false;
101
103
  },
102
104
  Enter: filter(isSelectionEntirelyInsideCodeBlock, insertNewlineWithIndent),
103
- 'Mod-]': filter(isSelectionEntirelyInsideCodeBlock, indent),
104
- 'Mod-[': filter(isSelectionEntirelyInsideCodeBlock, outdent),
105
+ 'Mod-]': filter(isSelectionEntirelyInsideCodeBlock, indent(editorAnalyticsAPI)),
106
+ 'Mod-[': filter(isSelectionEntirelyInsideCodeBlock, outdent(editorAnalyticsAPI)),
105
107
  Tab: filter(isSelectionEntirelyInsideCodeBlock, (state, dispatch) => {
106
108
  if (!dispatch) {
107
109
  return false;
@@ -109,9 +111,9 @@ const ideUX = pluginInjectionApi => {
109
111
  if (isCursorInsideCodeBlock(state)) {
110
112
  return insertIndent(state, dispatch);
111
113
  }
112
- return indent(state, dispatch);
114
+ return indent(editorAnalyticsAPI)(state, dispatch);
113
115
  }),
114
- 'Shift-Tab': filter(isSelectionEntirelyInsideCodeBlock, outdent),
116
+ 'Shift-Tab': filter(isSelectionEntirelyInsideCodeBlock, outdent(editorAnalyticsAPI)),
115
117
  'Mod-a': (state, dispatch) => {
116
118
  if (isSelectionEntirelyInsideCodeBlock(state)) {
117
119
  const {
@@ -16,10 +16,14 @@ export const messages = defineMessages({
16
16
  }
17
17
  });
18
18
  const languageList = createLanguageList(DEFAULT_LANGUAGES);
19
- export const getToolbarConfig = (allowCopyToClipboard = false, hoverDecoration) => (state, {
19
+ export const getToolbarConfig = (allowCopyToClipboard = false, api) => (state, {
20
20
  formatMessage
21
21
  }) => {
22
- var _codeBlockState$pos, _node$attrs;
22
+ var _api$decorations$acti, _api$analytics, _codeBlockState$pos, _node$attrs;
23
+ const {
24
+ hoverDecoration
25
+ } = (_api$decorations$acti = api === null || api === void 0 ? void 0 : api.decorations.actions) !== null && _api$decorations$acti !== void 0 ? _api$decorations$acti : {};
26
+ const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
23
27
  const codeBlockState = pluginKey.getState(state);
24
28
  const pos = (_codeBlockState$pos = codeBlockState === null || codeBlockState === void 0 ? void 0 : codeBlockState.pos) !== null && _codeBlockState$pos !== void 0 ? _codeBlockState$pos : null;
25
29
  if (!codeBlockState || pos === null) {
@@ -43,7 +47,7 @@ export const getToolbarConfig = (allowCopyToClipboard = false, hoverDecoration)
43
47
  id: 'editor.codeBlock.languageOptions',
44
48
  type: 'select',
45
49
  selectType: 'list',
46
- onChange: option => changeLanguage(option.value),
50
+ onChange: option => changeLanguage(editorAnalyticsAPI)(option.value),
47
51
  defaultValue,
48
52
  placeholder: formatMessage(messages.selectLanguage),
49
53
  options,
@@ -4,7 +4,6 @@ import { TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state
4
4
  import { flatmap, mapChildren } from '../../utils/slice';
5
5
  import { getStepRange, isEmptyDocument } from '@atlaskit/editor-common/utils';
6
6
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
7
- import { addAnalytics } from '../analytics/utils';
8
7
  import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
9
8
  import { LAYOUT_TYPE } from '../analytics/types/node-events';
10
9
  import { pluginKey } from './pm-plugins/plugin-key';
@@ -194,7 +193,7 @@ export function forceSectionToPresetLayout(state, node, pos, presetLayout) {
194
193
  const selectionPos$ = tr.doc.resolve(selection.$from.pos);
195
194
  return tr.setSelection(state.selection instanceof NodeSelection ? new NodeSelection(selectionPos$) : new TextSelection(selectionPos$));
196
195
  }
197
- export const setPresetLayout = layout => (state, dispatch) => {
196
+ export const setPresetLayout = editorAnalyticsAPI => layout => (state, dispatch) => {
198
197
  const {
199
198
  pos,
200
199
  selectedLayout
@@ -208,7 +207,7 @@ export const setPresetLayout = layout => (state, dispatch) => {
208
207
  }
209
208
  let tr = forceSectionToPresetLayout(state, node, pos, layout);
210
209
  if (tr) {
211
- tr = addAnalytics(state, tr, {
210
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
212
211
  action: ACTION.CHANGED_LAYOUT,
213
212
  actionSubject: ACTION_SUBJECT.LAYOUT,
214
213
  attributes: {
@@ -216,7 +215,7 @@ export const setPresetLayout = layout => (state, dispatch) => {
216
215
  newLayout: formatLayoutName(layout)
217
216
  },
218
217
  eventType: EVENT_TYPE.TRACK
219
- });
218
+ })(tr);
220
219
  tr.setMeta('scrollIntoView', false);
221
220
  if (dispatch) {
222
221
  dispatch(tr);
@@ -290,7 +289,7 @@ export const fixColumnStructure = state => {
290
289
  }
291
290
  return;
292
291
  };
293
- export const deleteActiveLayoutNode = (state, dispatch) => {
292
+ export const deleteActiveLayoutNode = editorAnalyticsAPI => (state, dispatch) => {
294
293
  const {
295
294
  pos,
296
295
  selectedLayout
@@ -299,14 +298,14 @@ export const deleteActiveLayoutNode = (state, dispatch) => {
299
298
  const node = state.doc.nodeAt(pos);
300
299
  if (dispatch) {
301
300
  let tr = state.tr.delete(pos, pos + node.nodeSize);
302
- tr = addAnalytics(state, tr, {
301
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
303
302
  action: ACTION.DELETED,
304
303
  actionSubject: ACTION_SUBJECT.LAYOUT,
305
304
  attributes: {
306
305
  layout: formatLayoutName(selectedLayout)
307
306
  },
308
307
  eventType: EVENT_TYPE.TRACK
309
- });
308
+ })(tr);
310
309
  dispatch(tr);
311
310
  }
312
311
  return true;
@@ -42,8 +42,7 @@ const layoutPlugin = ({
42
42
  allowSingleColumnLayout
43
43
  } = pluginKey.getState(state);
44
44
  if (pos !== null) {
45
- var _api$decorations$acti;
46
- return buildToolbar(state, intl, pos, allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api === null || api === void 0 ? void 0 : (_api$decorations$acti = api.decorations.actions) === null || _api$decorations$acti === void 0 ? void 0 : _api$decorations$acti.hoverDecoration);
45
+ return buildToolbar(state, intl, pos, allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api);
47
46
  }
48
47
  return undefined;
49
48
  },
@@ -42,18 +42,23 @@ const SIDEBAR_LAYOUT_TYPES = [{
42
42
  title: toolbarMessages.threeColumnsWithSidebars,
43
43
  icon: LayoutThreeWithSidebarsIcon
44
44
  }];
45
- const buildLayoutButton = (intl, item, currentLayout) => ({
45
+ const buildLayoutButton = (intl, item, currentLayout, editorAnalyticsAPI) => ({
46
46
  id: item.id,
47
47
  type: 'button',
48
48
  icon: item.icon,
49
49
  testId: item.title.id,
50
50
  title: intl.formatMessage(item.title),
51
- onClick: setPresetLayout(item.type),
51
+ onClick: setPresetLayout(editorAnalyticsAPI)(item.type),
52
52
  selected: !!currentLayout && currentLayout === item.type,
53
53
  tabIndex: null
54
54
  });
55
55
  export const layoutToolbarTitle = 'Layout floating controls';
56
- export const buildToolbar = (state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout, hoverDecoration) => {
56
+ export const buildToolbar = (state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api) => {
57
+ var _api$decorations$acti, _api$decorations, _api$analytics;
58
+ const {
59
+ hoverDecoration
60
+ } = (_api$decorations$acti = api === null || api === void 0 ? void 0 : (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions) !== null && _api$decorations$acti !== void 0 ? _api$decorations$acti : {};
61
+ const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
57
62
  const node = state.doc.nodeAt(pos);
58
63
  if (node) {
59
64
  const currentLayout = getPresetLayout(node);
@@ -69,7 +74,7 @@ export const buildToolbar = (state, intl, pos, _allowBreakout, addSidebarLayouts
69
74
  icon: RemoveIcon,
70
75
  testId: commonMessages.remove.id,
71
76
  title: intl.formatMessage(commonMessages.remove),
72
- onClick: deleteActiveLayoutNode,
77
+ onClick: deleteActiveLayoutNode(editorAnalyticsAPI),
73
78
  onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
74
79
  onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
75
80
  onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
@@ -81,7 +86,7 @@ export const buildToolbar = (state, intl, pos, _allowBreakout, addSidebarLayouts
81
86
  title: layoutToolbarTitle,
82
87
  getDomRef: view => findDomRefAtPos(pos, view.domAtPos.bind(view)),
83
88
  nodeType,
84
- items: [...layoutTypes.map(i => buildLayoutButton(intl, i, currentLayout)), ...(addSidebarLayouts ? SIDEBAR_LAYOUT_TYPES.map(i => buildLayoutButton(intl, i, currentLayout)) : []), {
89
+ items: [...layoutTypes.map(i => buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI)), ...(addSidebarLayouts ? SIDEBAR_LAYOUT_TYPES.map(i => buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI)) : []), {
85
90
  type: 'copy-button',
86
91
  items: [separator, {
87
92
  state,
@@ -1,12 +1,12 @@
1
1
  import { removeParentNodeOfType, findSelectedNodeOfType, removeSelectedNode, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
2
2
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { PanelType } from '@atlaskit/adf-schema';
4
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE, addAnalytics } from '../analytics';
4
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
5
5
  import { findPanel } from './utils';
6
6
  import { getPanelTypeBackgroundNoTokens } from '@atlaskit/editor-common/panel';
7
7
  import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
8
8
  import { wrapSelectionIn } from '@atlaskit/editor-common/utils';
9
- export const removePanel = () => (state, dispatch) => {
9
+ export const removePanel = editorAnalyticsAPI => (state, dispatch) => {
10
10
  const {
11
11
  schema: {
12
12
  nodes
@@ -31,11 +31,12 @@ export const removePanel = () => (state, dispatch) => {
31
31
  return false;
32
32
  }
33
33
  if (dispatch) {
34
- dispatch(addAnalytics(state, deleteTr, payload));
34
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(payload)(deleteTr);
35
+ dispatch(deleteTr);
35
36
  }
36
37
  return true;
37
38
  };
38
- export const changePanelType = (panelType, panelOptions = {}, allowCustomPanel = false) => (state, dispatch) => {
39
+ export const changePanelType = editorAnalyticsAPI => (panelType, panelOptions = {}, allowCustomPanel = false) => (state, dispatch) => {
39
40
  const {
40
41
  schema: {
41
42
  nodes
@@ -85,10 +86,10 @@ export const changePanelType = (panelType, panelOptions = {}, allowCustomPanel =
85
86
 
86
87
  // Select the panel if it was previously selected
87
88
  const newTrWithSelection = state.selection instanceof NodeSelection && state.selection.node.type.name === 'panel' ? newTr.setSelection(new NodeSelection(tr.doc.resolve(panelNode.pos))) : newTr;
88
- const changePanelTypeTr = addAnalytics(state, newTrWithSelection, payload);
89
- changePanelTypeTr.setMeta('scrollIntoView', false);
89
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(payload)(newTrWithSelection);
90
+ newTrWithSelection.setMeta('scrollIntoView', false);
90
91
  if (dispatch) {
91
- dispatch(changePanelTypeTr);
92
+ dispatch(newTrWithSelection);
92
93
  }
93
94
  return true;
94
95
  };
@@ -3,7 +3,7 @@ import { panel, PanelType } from '@atlaskit/adf-schema';
3
3
  import { createPlugin } from './pm-plugins/main';
4
4
  import { getToolbarConfig } from './toolbar';
5
5
  import keymap from './pm-plugins/keymaps';
6
- import { addAnalytics, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE } from '../analytics';
6
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
7
7
  import { IconPanel, IconPanelNote, IconPanelSuccess, IconPanelWarning, IconPanelError } from '@atlaskit/editor-common/quick-insert';
8
8
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
9
9
  import { blockTypeMessages } from '@atlaskit/editor-common/messages';
@@ -56,7 +56,8 @@ const panelPlugin = ({
56
56
  state,
57
57
  attributes: {
58
58
  panelType: PanelType.INFO
59
- }
59
+ },
60
+ api
60
61
  });
61
62
  }
62
63
  }, {
@@ -70,7 +71,8 @@ const panelPlugin = ({
70
71
  state,
71
72
  attributes: {
72
73
  panelType: PanelType.NOTE
73
- }
74
+ },
75
+ api
74
76
  });
75
77
  }
76
78
  }, {
@@ -85,7 +87,8 @@ const panelPlugin = ({
85
87
  state,
86
88
  attributes: {
87
89
  panelType: PanelType.SUCCESS
88
- }
90
+ },
91
+ api
89
92
  });
90
93
  }
91
94
  }, {
@@ -99,7 +102,8 @@ const panelPlugin = ({
99
102
  state,
100
103
  attributes: {
101
104
  panelType: PanelType.WARNING
102
- }
105
+ },
106
+ api
103
107
  });
104
108
  }
105
109
  }, {
@@ -113,7 +117,8 @@ const panelPlugin = ({
113
117
  state,
114
118
  attributes: {
115
119
  panelType: PanelType.ERROR
116
- }
120
+ },
121
+ api
117
122
  });
118
123
  }
119
124
  }];
@@ -135,7 +140,8 @@ const panelPlugin = ({
135
140
  // TODO: https://product-fabric.atlassian.net/browse/DSP-7268
136
141
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
137
142
  panelColor: T50
138
- }
143
+ },
144
+ api
139
145
  });
140
146
  }
141
147
  });
@@ -160,7 +166,8 @@ const panelPlugin = ({
160
166
  */
161
167
  function createPanelAction({
162
168
  state,
163
- attributes
169
+ attributes,
170
+ api
164
171
  }) {
165
172
  const tr = createWrapSelectionTransaction({
166
173
  state,
@@ -168,7 +175,8 @@ function createPanelAction({
168
175
  nodeAttributes: attributes
169
176
  });
170
177
  if (tr) {
171
- addAnalytics(state, tr, {
178
+ var _api$analytics2;
179
+ api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.attachAnalyticsEvent({
172
180
  action: ACTION.INSERTED,
173
181
  actionSubject: ACTION_SUBJECT.DOCUMENT,
174
182
  actionSubjectId: ACTION_SUBJECT_ID.PANEL,
@@ -177,7 +185,7 @@ function createPanelAction({
177
185
  panelType: attributes.panelType
178
186
  },
179
187
  eventType: EVENT_TYPE.TRACK
180
- });
188
+ })(tr);
181
189
  }
182
190
  return tr;
183
191
  }