@atlaskit/editor-core 188.13.2 → 188.13.5

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 (55) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/create-editor/feature-flags-from-props.js +6 -7
  3. package/dist/cjs/plugins/code-block/actions.js +27 -25
  4. package/dist/cjs/plugins/code-block/ide-ux/commands.js +64 -60
  5. package/dist/cjs/plugins/code-block/index.js +1 -1
  6. package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +6 -4
  7. package/dist/cjs/plugins/code-block/toolbar.js +8 -5
  8. package/dist/cjs/plugins/layout/actions.js +53 -50
  9. package/dist/cjs/plugins/layout/index.js +1 -2
  10. package/dist/cjs/plugins/layout/toolbar.js +10 -6
  11. package/dist/cjs/plugins/panel/actions.js +59 -56
  12. package/dist/cjs/plugins/panel/index.js +18 -10
  13. package/dist/cjs/plugins/panel/toolbar.js +11 -11
  14. package/dist/cjs/version-wrapper.js +1 -1
  15. package/dist/es2019/create-editor/feature-flags-from-props.js +6 -7
  16. package/dist/es2019/plugins/code-block/actions.js +4 -4
  17. package/dist/es2019/plugins/code-block/ide-ux/commands.js +9 -9
  18. package/dist/es2019/plugins/code-block/index.js +1 -1
  19. package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +6 -4
  20. package/dist/es2019/plugins/code-block/toolbar.js +7 -3
  21. package/dist/es2019/plugins/layout/actions.js +6 -7
  22. package/dist/es2019/plugins/layout/index.js +1 -2
  23. package/dist/es2019/plugins/layout/toolbar.js +10 -5
  24. package/dist/es2019/plugins/panel/actions.js +8 -7
  25. package/dist/es2019/plugins/panel/index.js +18 -10
  26. package/dist/es2019/plugins/panel/toolbar.js +11 -11
  27. package/dist/es2019/version-wrapper.js +1 -1
  28. package/dist/esm/create-editor/feature-flags-from-props.js +6 -7
  29. package/dist/esm/plugins/code-block/actions.js +27 -25
  30. package/dist/esm/plugins/code-block/ide-ux/commands.js +62 -58
  31. package/dist/esm/plugins/code-block/index.js +1 -1
  32. package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +6 -4
  33. package/dist/esm/plugins/code-block/toolbar.js +8 -5
  34. package/dist/esm/plugins/layout/actions.js +53 -50
  35. package/dist/esm/plugins/layout/index.js +1 -2
  36. package/dist/esm/plugins/layout/toolbar.js +10 -6
  37. package/dist/esm/plugins/panel/actions.js +59 -56
  38. package/dist/esm/plugins/panel/index.js +18 -10
  39. package/dist/esm/plugins/panel/toolbar.js +11 -11
  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-ts4.5/plugins/code-block/actions.d.ts +1 -1
  49. package/dist/types-ts4.5/plugins/code-block/ide-ux/commands.d.ts +4 -3
  50. package/dist/types-ts4.5/plugins/code-block/toolbar.d.ts +3 -3
  51. package/dist/types-ts4.5/plugins/layout/actions.d.ts +2 -2
  52. package/dist/types-ts4.5/plugins/layout/toolbar.d.ts +3 -3
  53. package/dist/types-ts4.5/plugins/panel/actions.d.ts +4 -4
  54. package/dist/types-ts4.5/plugins/panel/index.d.ts +1 -1
  55. package/package.json +1 -1
@@ -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
  }
@@ -48,7 +48,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
48
48
  id: 'editor.panel.info',
49
49
  type: 'button',
50
50
  icon: InfoIcon,
51
- onClick: changePanelType(PanelType.INFO),
51
+ onClick: changePanelType(editorAnalyticsAPI)(PanelType.INFO),
52
52
  selected: activePanelType === PanelType.INFO,
53
53
  title: formatMessage(messages.info),
54
54
  tabIndex: null
@@ -56,7 +56,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
56
56
  id: 'editor.panel.note',
57
57
  type: 'button',
58
58
  icon: NoteIcon,
59
- onClick: changePanelType(PanelType.NOTE),
59
+ onClick: changePanelType(editorAnalyticsAPI)(PanelType.NOTE),
60
60
  selected: activePanelType === PanelType.NOTE,
61
61
  title: formatMessage(messages.note),
62
62
  tabIndex: null
@@ -64,7 +64,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
64
64
  id: 'editor.panel.success',
65
65
  type: 'button',
66
66
  icon: SuccessIcon,
67
- onClick: changePanelType(PanelType.SUCCESS),
67
+ onClick: changePanelType(editorAnalyticsAPI)(PanelType.SUCCESS),
68
68
  selected: activePanelType === PanelType.SUCCESS,
69
69
  title: formatMessage(messages.success),
70
70
  tabIndex: null
@@ -72,7 +72,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
72
72
  id: 'editor.panel.warning',
73
73
  type: 'button',
74
74
  icon: WarningIcon,
75
- onClick: changePanelType(PanelType.WARNING),
75
+ onClick: changePanelType(editorAnalyticsAPI)(PanelType.WARNING),
76
76
  selected: activePanelType === PanelType.WARNING,
77
77
  title: formatMessage(messages.warning),
78
78
  tabIndex: null
@@ -80,7 +80,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
80
80
  id: 'editor.panel.error',
81
81
  type: 'button',
82
82
  icon: ErrorIcon,
83
- onClick: changePanelType(PanelType.ERROR),
83
+ onClick: changePanelType(editorAnalyticsAPI)(PanelType.ERROR),
84
84
  selected: activePanelType === PanelType.ERROR,
85
85
  title: formatMessage(messages.error),
86
86
  tabIndex: null
@@ -99,7 +99,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
99
99
  emojiId: panelEmoji.id
100
100
  } : {};
101
101
  if (previousColor === color) {
102
- changePanelType(PanelType.CUSTOM, {
102
+ changePanelType(editorAnalyticsAPI)(PanelType.CUSTOM, {
103
103
  color,
104
104
  ...previousEmoji
105
105
  }, isCustomPanelEnabled)(state, dispatch);
@@ -115,7 +115,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
115
115
  },
116
116
  eventType: EVENT_TYPE.TRACK
117
117
  };
118
- withAnalytics(editorAnalyticsAPI, payload)(changePanelType(PanelType.CUSTOM, {
118
+ withAnalytics(editorAnalyticsAPI, payload)(changePanelType(editorAnalyticsAPI)(PanelType.CUSTOM, {
119
119
  color,
120
120
  ...previousEmoji
121
121
  }, isCustomPanelEnabled))(state, dispatch);
@@ -128,7 +128,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
128
128
  }
129
129
  let previousIcon = panelNode.node.attrs.panelIcon || '';
130
130
  if (previousIcon === emoji.shortName) {
131
- changePanelType(PanelType.CUSTOM, {
131
+ changePanelType(editorAnalyticsAPI)(PanelType.CUSTOM, {
132
132
  emoji: emoji.shortName,
133
133
  emojiId: emoji.id,
134
134
  emojiText: emoji.fallback
@@ -145,7 +145,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
145
145
  },
146
146
  eventType: EVENT_TYPE.TRACK
147
147
  };
148
- withAnalytics(editorAnalyticsAPI, payload)(changePanelType(PanelType.CUSTOM, {
148
+ withAnalytics(editorAnalyticsAPI, payload)(changePanelType(editorAnalyticsAPI)(PanelType.CUSTOM, {
149
149
  emoji: emoji.shortName,
150
150
  emojiId: emoji.id,
151
151
  emojiText: emoji.fallback
@@ -169,7 +169,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
169
169
  },
170
170
  eventType: EVENT_TYPE.TRACK
171
171
  };
172
- withAnalytics(editorAnalyticsAPI, payload)(changePanelType(PanelType.CUSTOM, {
172
+ withAnalytics(editorAnalyticsAPI, payload)(changePanelType(editorAnalyticsAPI)(PanelType.CUSTOM, {
173
173
  emoji: undefined,
174
174
  emojiId: undefined,
175
175
  emojiText: undefined
@@ -234,7 +234,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
234
234
  appearance: 'danger',
235
235
  focusEditoronEnter: true,
236
236
  icon: RemoveIcon,
237
- onClick: removePanel(),
237
+ onClick: removePanel(editorAnalyticsAPI),
238
238
  onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(panelNodeType, true),
239
239
  onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(panelNodeType, false),
240
240
  onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(panelNodeType, true),
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "188.13.2";
2
+ export const version = "188.13.5";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -25,7 +25,7 @@ function getSpellCheck(featureFlags) {
25
25
  * which is used by both current and archv3 editors.
26
26
  */
27
27
  export function createFeatureFlagsFromProps(props) {
28
- var _props$allowLayouts, _props$performanceTra, _props$allowExtension, _props$featureFlags, _props$featureFlags2, _props$featureFlags3, _props$featureFlags4, _props$featureFlags5, _props$featureFlags6, _props$featureFlags7, _props$featureFlags8, _props$featureFlags9, _props$featureFlags10, _props$featureFlags11, _props$featureFlags12, _props$featureFlags13, _props$featureFlags14, _props$collabEdit, _props$collabEdit2, _props$featureFlags15, _props$featureFlags16, _props$featureFlags17, _props$featureFlags18, _props$featureFlags19, _props$featureFlags20, _props$featureFlags21, _props$featureFlags22, _props$featureFlags23;
28
+ var _props$allowLayouts, _props$performanceTra, _props$allowExtension, _props$featureFlags, _props$featureFlags2, _props$featureFlags3, _props$featureFlags4, _props$featureFlags5, _props$featureFlags6, _props$featureFlags7, _props$featureFlags8, _props$featureFlags9, _props$featureFlags10, _props$featureFlags11, _props$featureFlags12, _props$featureFlags13, _props$featureFlags14, _props$collabEdit, _props$collabEdit2, _props$featureFlags15, _props$featureFlags16, _props$featureFlags17, _props$featureFlags18, _props$featureFlags19, _props$featureFlags20, _props$featureFlags21, _props$featureFlags22;
29
29
  var normalizedFeatureFlags = normalizeFeatureFlags(props.featureFlags);
30
30
  return _objectSpread(_objectSpread({}, normalizedFeatureFlags), {}, {
31
31
  newInsertionBehaviour: props.allowNewInsertionBehaviour,
@@ -46,15 +46,14 @@ export function createFeatureFlagsFromProps(props) {
46
46
  ufo: Boolean(typeof ((_props$featureFlags11 = props.featureFlags) === null || _props$featureFlags11 === void 0 ? void 0 : _props$featureFlags11.ufo) === 'boolean' ? !!((_props$featureFlags12 = props.featureFlags) !== null && _props$featureFlags12 !== void 0 && _props$featureFlags12.ufo) : false),
47
47
  twoLineEditorToolbar: Boolean(typeof ((_props$featureFlags13 = props.featureFlags) === null || _props$featureFlags13 === void 0 ? void 0 : _props$featureFlags13.twoLineEditorToolbar) === 'boolean' ? !!((_props$featureFlags14 = props.featureFlags) !== null && _props$featureFlags14 !== void 0 && _props$featureFlags14.twoLineEditorToolbar) : false),
48
48
  useNativeCollabPlugin: Boolean(typeof ((_props$collabEdit = props.collabEdit) === null || _props$collabEdit === void 0 ? void 0 : _props$collabEdit.useNativePlugin) === 'boolean' ? !!((_props$collabEdit2 = props.collabEdit) !== null && _props$collabEdit2 !== void 0 && _props$collabEdit2.useNativePlugin) : false),
49
- chromeCursorHandlerFixedVersion: typeof ((_props$featureFlags15 = props.featureFlags) === null || _props$featureFlags15 === void 0 ? void 0 : _props$featureFlags15.chromeCursorHandlerFixedVersion) === 'string' ? Number(props.featureFlags.chromeCursorHandlerFixedVersion) || undefined : undefined,
50
- showHoverPreview: Boolean(typeof ((_props$featureFlags16 = props.featureFlags) === null || _props$featureFlags16 === void 0 ? void 0 : _props$featureFlags16.showHoverPreview) === 'boolean' ? !!((_props$featureFlags17 = props.featureFlags) !== null && _props$featureFlags17 !== void 0 && _props$featureFlags17.showHoverPreview) : false),
51
- indentationButtonsInTheToolbar: typeof props.showIndentationButtons === 'boolean' ? props.showIndentationButtons : Boolean(typeof normalizedFeatureFlags.indentationButtonsInTheToolbar === 'boolean' && !!normalizedFeatureFlags.indentationButtonsInTheToolbar || (typeof ((_props$featureFlags18 = props.featureFlags) === null || _props$featureFlags18 === void 0 ? void 0 : _props$featureFlags18.indentationButtonsInTheToolbar) === 'boolean' ? !!((_props$featureFlags19 = props.featureFlags) !== null && _props$featureFlags19 !== void 0 && _props$featureFlags19.indentationButtonsInTheToolbar) : false)),
52
- floatingToolbarLinkSettingsButton: typeof ((_props$featureFlags20 = props.featureFlags) === null || _props$featureFlags20 === void 0 ? void 0 : _props$featureFlags20['floating-toolbar-link-settings-button']) === 'string' ? props.featureFlags['floating-toolbar-link-settings-button'] || undefined : undefined,
49
+ showHoverPreview: Boolean(typeof ((_props$featureFlags15 = props.featureFlags) === null || _props$featureFlags15 === void 0 ? void 0 : _props$featureFlags15.showHoverPreview) === 'boolean' ? !!((_props$featureFlags16 = props.featureFlags) !== null && _props$featureFlags16 !== void 0 && _props$featureFlags16.showHoverPreview) : false),
50
+ indentationButtonsInTheToolbar: typeof props.showIndentationButtons === 'boolean' ? props.showIndentationButtons : Boolean(typeof normalizedFeatureFlags.indentationButtonsInTheToolbar === 'boolean' && !!normalizedFeatureFlags.indentationButtonsInTheToolbar || (typeof ((_props$featureFlags17 = props.featureFlags) === null || _props$featureFlags17 === void 0 ? void 0 : _props$featureFlags17.indentationButtonsInTheToolbar) === 'boolean' ? !!((_props$featureFlags18 = props.featureFlags) !== null && _props$featureFlags18 !== void 0 && _props$featureFlags18.indentationButtonsInTheToolbar) : false)),
51
+ floatingToolbarLinkSettingsButton: typeof ((_props$featureFlags19 = props.featureFlags) === null || _props$featureFlags19 === void 0 ? void 0 : _props$featureFlags19['floating-toolbar-link-settings-button']) === 'string' ? props.featureFlags['floating-toolbar-link-settings-button'] || undefined : undefined,
53
52
  disableSpellcheckByBrowser: getSpellCheck(props.featureFlags),
54
53
  // Including fallback to props.featureFlags so that mobile feature flags
55
54
  // are included (they are not kebab cased)
56
- restartNumberedLists: normalizedFeatureFlags.restartNumberedLists === true || ((_props$featureFlags21 = props.featureFlags) === null || _props$featureFlags21 === void 0 ? void 0 : _props$featureFlags21.restartNumberedLists) === true,
55
+ restartNumberedLists: normalizedFeatureFlags.restartNumberedLists === true || ((_props$featureFlags20 = props.featureFlags) === null || _props$featureFlags20 === void 0 ? void 0 : _props$featureFlags20.restartNumberedLists) === true,
57
56
  lpLinkPickerFocusTrap: Boolean(normalizedFeatureFlags.lpLinkPickerFocusTrap),
58
- preventPopupOverflow: Boolean(typeof ((_props$featureFlags22 = props.featureFlags) === null || _props$featureFlags22 === void 0 ? void 0 : _props$featureFlags22['prevent-popup-overflow']) === 'boolean' ? !!((_props$featureFlags23 = props.featureFlags) !== null && _props$featureFlags23 !== void 0 && _props$featureFlags23['prevent-popup-overflow']) : false)
57
+ preventPopupOverflow: Boolean(typeof ((_props$featureFlags21 = props.featureFlags) === null || _props$featureFlags21 === void 0 ? void 0 : _props$featureFlags21['prevent-popup-overflow']) === 'boolean' ? !!((_props$featureFlags22 = props.featureFlags) !== null && _props$featureFlags22 !== void 0 && _props$featureFlags22['prevent-popup-overflow']) : false)
59
58
  });
60
59
  }
@@ -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';
@@ -23,30 +22,33 @@ export var removeCodeBlock = function removeCodeBlock(state, dispatch) {
23
22
  }
24
23
  return true;
25
24
  };
26
- export var changeLanguage = function changeLanguage(language) {
27
- return function (state, dispatch) {
28
- var _pluginKey$getState;
29
- var codeBlock = state.schema.nodes.codeBlock;
30
- var pos = (_pluginKey$getState = pluginKey.getState(state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.pos;
31
- if (typeof pos !== 'number') {
32
- return false;
33
- }
34
- var tr = state.tr.setNodeMarkup(pos, codeBlock, {
35
- language: language
36
- }).setMeta('scrollIntoView', false);
37
- var selection = isNodeSelection(state.selection) ? NodeSelection.create(tr.doc, pos) : tr.selection;
38
- var result = tr.setSelection(selection);
39
- if (dispatch) {
40
- dispatch(addAnalytics(state, result, {
41
- action: ACTION.LANGUAGE_SELECTED,
42
- actionSubject: ACTION_SUBJECT.CODE_BLOCK,
43
- attributes: {
44
- language: language
45
- },
46
- eventType: EVENT_TYPE.TRACK
47
- }));
48
- }
49
- return true;
25
+ export var changeLanguage = function changeLanguage(editorAnalyticsAPI) {
26
+ return function (language) {
27
+ return function (state, dispatch) {
28
+ var _pluginKey$getState;
29
+ var codeBlock = state.schema.nodes.codeBlock;
30
+ var pos = (_pluginKey$getState = pluginKey.getState(state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.pos;
31
+ if (typeof pos !== 'number') {
32
+ return false;
33
+ }
34
+ var tr = state.tr.setNodeMarkup(pos, codeBlock, {
35
+ language: language
36
+ }).setMeta('scrollIntoView', false);
37
+ var selection = isNodeSelection(state.selection) ? NodeSelection.create(tr.doc, pos) : tr.selection;
38
+ var result = tr.setSelection(selection);
39
+ if (dispatch) {
40
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
41
+ action: ACTION.LANGUAGE_SELECTED,
42
+ actionSubject: ACTION_SUBJECT.CODE_BLOCK,
43
+ attributes: {
44
+ language: language
45
+ },
46
+ eventType: EVENT_TYPE.TRACK
47
+ })(result);
48
+ dispatch(result);
49
+ }
50
+ return true;
51
+ };
50
52
  };
51
53
  };
52
54
  export var copyContentToClipboard = function copyContentToClipboard(state, dispatch) {
@@ -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,55 +12,21 @@ function getIndentLevel(indentText, indentSize) {
12
12
  }
13
13
  return indentText.length / indentSize;
14
14
  }
15
- export function indent(state, dispatch) {
16
- var _getLinesFromSelectio = getLinesFromSelection(state),
17
- text = _getLinesFromSelectio.text,
18
- start = _getLinesFromSelectio.start;
19
- var tr = state.tr,
20
- selection = state.selection;
21
- forEachLine(text, function (line, offset) {
22
- var _getLineInfo = getLineInfo(line),
23
- indentText = _getLineInfo.indentText,
24
- indentToken = _getLineInfo.indentToken;
25
- var indentLevel = getIndentLevel(indentText, indentToken.size);
26
- var indentToAdd = indentToken.token.repeat(indentToken.size - indentText.length % indentToken.size || indentToken.size);
27
- tr.insertText(indentToAdd, tr.mapping.map(start + offset, -1));
28
- addAnalytics(state, tr, {
29
- action: ACTION.FORMATTED,
30
- actionSubject: ACTION_SUBJECT.TEXT,
31
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_INDENT,
32
- eventType: EVENT_TYPE.TRACK,
33
- attributes: {
34
- inputMethod: INPUT_METHOD.KEYBOARD,
35
- previousIndentationLevel: indentLevel,
36
- newIndentLevel: indentLevel + 1,
37
- direction: INDENT_DIRECTION.INDENT,
38
- indentType: INDENT_TYPE.CODE_BLOCK
39
- }
40
- });
41
- if (!selection.empty) {
42
- tr.setSelection(TextSelection.create(tr.doc, tr.mapping.map(selection.from, -1), tr.selection.to));
43
- }
44
- });
45
- if (dispatch) {
46
- dispatch(tr);
47
- }
48
- return true;
49
- }
50
- export function outdent(state, dispatch) {
51
- var _getLinesFromSelectio2 = getLinesFromSelection(state),
52
- text = _getLinesFromSelectio2.text,
53
- start = _getLinesFromSelectio2.start;
54
- var tr = state.tr;
55
- forEachLine(text, function (line, offset) {
56
- var _getLineInfo2 = getLineInfo(line),
57
- indentText = _getLineInfo2.indentText,
58
- indentToken = _getLineInfo2.indentToken;
59
- if (indentText) {
15
+ export var indent = function indent(editorAnalyticsAPI) {
16
+ return function (state, dispatch) {
17
+ var _getLinesFromSelectio = getLinesFromSelection(state),
18
+ text = _getLinesFromSelectio.text,
19
+ start = _getLinesFromSelectio.start;
20
+ var tr = state.tr,
21
+ selection = state.selection;
22
+ forEachLine(text, function (line, offset) {
23
+ var _getLineInfo = getLineInfo(line),
24
+ indentText = _getLineInfo.indentText,
25
+ indentToken = _getLineInfo.indentToken;
60
26
  var indentLevel = getIndentLevel(indentText, indentToken.size);
61
- var unindentLength = indentText.length % indentToken.size || indentToken.size;
62
- tr.delete(tr.mapping.map(start + offset), tr.mapping.map(start + offset + unindentLength));
63
- addAnalytics(state, tr, {
27
+ var indentToAdd = indentToken.token.repeat(indentToken.size - indentText.length % indentToken.size || indentToken.size);
28
+ tr.insertText(indentToAdd, tr.mapping.map(start + offset, -1));
29
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
64
30
  action: ACTION.FORMATTED,
65
31
  actionSubject: ACTION_SUBJECT.TEXT,
66
32
  actionSubjectId: ACTION_SUBJECT_ID.FORMAT_INDENT,
@@ -68,18 +34,56 @@ export function outdent(state, dispatch) {
68
34
  attributes: {
69
35
  inputMethod: INPUT_METHOD.KEYBOARD,
70
36
  previousIndentationLevel: indentLevel,
71
- newIndentLevel: indentLevel - 1,
72
- direction: INDENT_DIRECTION.OUTDENT,
37
+ newIndentLevel: indentLevel + 1,
38
+ direction: INDENT_DIRECTION.INDENT,
73
39
  indentType: INDENT_TYPE.CODE_BLOCK
74
40
  }
75
- });
41
+ })(tr);
42
+ if (!selection.empty) {
43
+ tr.setSelection(TextSelection.create(tr.doc, tr.mapping.map(selection.from, -1), tr.selection.to));
44
+ }
45
+ });
46
+ if (dispatch) {
47
+ dispatch(tr);
76
48
  }
77
- });
78
- if (dispatch) {
79
- dispatch(tr);
80
- }
81
- return true;
82
- }
49
+ return true;
50
+ };
51
+ };
52
+ export var outdent = function outdent(editorAnalyticsAPI) {
53
+ return function (state, dispatch) {
54
+ var _getLinesFromSelectio2 = getLinesFromSelection(state),
55
+ text = _getLinesFromSelectio2.text,
56
+ start = _getLinesFromSelectio2.start;
57
+ var tr = state.tr;
58
+ forEachLine(text, function (line, offset) {
59
+ var _getLineInfo2 = getLineInfo(line),
60
+ indentText = _getLineInfo2.indentText,
61
+ indentToken = _getLineInfo2.indentToken;
62
+ if (indentText) {
63
+ var indentLevel = getIndentLevel(indentText, indentToken.size);
64
+ var unindentLength = indentText.length % indentToken.size || indentToken.size;
65
+ tr.delete(tr.mapping.map(start + offset), tr.mapping.map(start + offset + unindentLength));
66
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
67
+ action: ACTION.FORMATTED,
68
+ actionSubject: ACTION_SUBJECT.TEXT,
69
+ actionSubjectId: ACTION_SUBJECT_ID.FORMAT_INDENT,
70
+ eventType: EVENT_TYPE.TRACK,
71
+ attributes: {
72
+ inputMethod: INPUT_METHOD.KEYBOARD,
73
+ previousIndentationLevel: indentLevel,
74
+ newIndentLevel: indentLevel - 1,
75
+ direction: INDENT_DIRECTION.OUTDENT,
76
+ indentType: INDENT_TYPE.CODE_BLOCK
77
+ }
78
+ })(tr);
79
+ }
80
+ });
81
+ if (dispatch) {
82
+ dispatch(tr);
83
+ }
84
+ return true;
85
+ };
86
+ };
83
87
  export function insertIndent(state, dispatch) {
84
88
  var _getStartOfCurrentLin = getStartOfCurrentLine(state),
85
89
  textAtStartOfLine = _getStartOfCurrentLin.text;
@@ -106,7 +106,7 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
106
106
  }
107
107
  }];
108
108
  },
109
- floatingToolbar: getToolbarConfig(options === null || options === void 0 ? void 0 : options.allowCopyToClipboard, api === null || api === void 0 ? void 0 : api.decorations.actions.hoverDecoration)
109
+ floatingToolbar: getToolbarConfig(options === null || options === void 0 ? void 0 : options.allowCopyToClipboard, api)
110
110
  }
111
111
  };
112
112
  };
@@ -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
  var ideUX = function ideUX(pluginInjectionApi) {
13
+ var _pluginInjectionApi$a;
14
+ var editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === 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: function handleTextInput(view, from, to, text) {
@@ -92,8 +94,8 @@ var ideUX = function ideUX(pluginInjectionApi) {
92
94
  return false;
93
95
  },
94
96
  Enter: filter(isSelectionEntirelyInsideCodeBlock, insertNewlineWithIndent),
95
- 'Mod-]': filter(isSelectionEntirelyInsideCodeBlock, indent),
96
- 'Mod-[': filter(isSelectionEntirelyInsideCodeBlock, outdent),
97
+ 'Mod-]': filter(isSelectionEntirelyInsideCodeBlock, indent(editorAnalyticsAPI)),
98
+ 'Mod-[': filter(isSelectionEntirelyInsideCodeBlock, outdent(editorAnalyticsAPI)),
97
99
  Tab: filter(isSelectionEntirelyInsideCodeBlock, function (state, dispatch) {
98
100
  if (!dispatch) {
99
101
  return false;
@@ -101,9 +103,9 @@ var ideUX = function ideUX(pluginInjectionApi) {
101
103
  if (isCursorInsideCodeBlock(state)) {
102
104
  return insertIndent(state, dispatch);
103
105
  }
104
- return indent(state, dispatch);
106
+ return indent(editorAnalyticsAPI)(state, dispatch);
105
107
  }),
106
- 'Shift-Tab': filter(isSelectionEntirelyInsideCodeBlock, outdent),
108
+ 'Shift-Tab': filter(isSelectionEntirelyInsideCodeBlock, outdent(editorAnalyticsAPI)),
107
109
  'Mod-a': function ModA(state, dispatch) {
108
110
  if (isSelectionEntirelyInsideCodeBlock(state)) {
109
111
  var _state$selection = state.selection,
@@ -18,10 +18,13 @@ export var messages = defineMessages({
18
18
  var languageList = createLanguageList(DEFAULT_LANGUAGES);
19
19
  export var getToolbarConfig = function getToolbarConfig() {
20
20
  var allowCopyToClipboard = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
21
- var hoverDecoration = arguments.length > 1 ? arguments[1] : undefined;
21
+ var api = arguments.length > 1 ? arguments[1] : undefined;
22
22
  return function (state, _ref) {
23
- var _codeBlockState$pos, _node$attrs;
23
+ var _api$decorations$acti, _api$analytics, _codeBlockState$pos, _node$attrs;
24
24
  var formatMessage = _ref.formatMessage;
25
+ var _ref2 = (_api$decorations$acti = api === null || api === void 0 ? void 0 : api.decorations.actions) !== null && _api$decorations$acti !== void 0 ? _api$decorations$acti : {},
26
+ hoverDecoration = _ref2.hoverDecoration;
27
+ var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
25
28
  var codeBlockState = pluginKey.getState(state);
26
29
  var pos = (_codeBlockState$pos = codeBlockState === null || codeBlockState === void 0 ? void 0 : codeBlockState.pos) !== null && _codeBlockState$pos !== void 0 ? _codeBlockState$pos : null;
27
30
  if (!codeBlockState || pos === null) {
@@ -52,7 +55,7 @@ export var getToolbarConfig = function getToolbarConfig() {
52
55
  type: 'select',
53
56
  selectType: 'list',
54
57
  onChange: function onChange(option) {
55
- return changeLanguage(option.value);
58
+ return changeLanguage(editorAnalyticsAPI)(option.value);
56
59
  },
57
60
  defaultValue: defaultValue,
58
61
  placeholder: formatMessage(messages.selectLanguage),
@@ -110,8 +113,8 @@ export var getToolbarConfig = function getToolbarConfig() {
110
113
  * Filters language list based on both name and alias properties.
111
114
  */
112
115
  export var languageListFilter = function languageListFilter(option, rawInput) {
113
- var _ref2 = option,
114
- data = _ref2.data;
116
+ var _ref3 = option,
117
+ data = _ref3.data;
115
118
  var searchString = rawInput.toLowerCase();
116
119
  return data.label.toLowerCase().includes(searchString) || data.alias.some(function (alias) {
117
120
  return alias.toLowerCase() === searchString;