@atlaskit/editor-plugin-alignment 3.1.8 → 3.1.9

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-plugin-alignment
2
2
 
3
+ ## 3.1.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#139038](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/139038)
8
+ [`50d48758aba38`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/50d48758aba38) -
9
+ [ED-27448] Implement alignment updated event
10
+ - Updated dependencies
11
+
3
12
  ## 3.1.8
4
13
 
5
14
  ### Patch Changes
@@ -69,7 +69,7 @@ var alignmentPlugin = exports.alignmentPlugin = function alignmentPlugin(_ref) {
69
69
  }, {
70
70
  name: 'annotationKeymap',
71
71
  plugin: function plugin() {
72
- return (0, _keymap.keymapPlugin)();
72
+ return (0, _keymap.keymapPlugin)(api);
73
73
  }
74
74
  }];
75
75
  },
@@ -4,8 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isAlignable = exports.changeAlignment = void 0;
7
+ var _analytics = require("@atlaskit/editor-common/analytics");
7
8
  var _commands = require("@atlaskit/editor-common/commands");
9
+ var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
8
10
  var _state = require("@atlaskit/editor-prosemirror/state");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
12
  /**
10
13
  * Iterates over the commands one after the other,
11
14
  * passes the tr through and dispatches the cumulated transaction
@@ -46,14 +49,52 @@ var isAlignable = exports.isAlignable = function isAlignable(align) {
46
49
  }, [paragraph, heading])(state, dispatch);
47
50
  };
48
51
  };
49
- var changeAlignment = exports.changeAlignment = function changeAlignment(align) {
52
+ var changeBlockAlignmentWithAnalytics = function changeBlockAlignmentWithAnalytics(editorAnalyticsApi, align, inputMethod) {
50
53
  return function (state, dispatch) {
51
54
  var _state$schema2 = state.schema,
52
55
  _state$schema2$nodes = _state$schema2.nodes,
53
56
  paragraph = _state$schema2$nodes.paragraph,
54
57
  heading = _state$schema2$nodes.heading,
55
58
  alignment = _state$schema2.marks.alignment;
56
- return cascadeCommands([(0, _commands.changeImageAlignment)(align), (0, _commands.toggleBlockMark)(alignment, function () {
59
+ return (0, _editorAnalytics.withAnalytics)(editorAnalyticsApi, {
60
+ eventType: _analytics.EVENT_TYPE.TRACK,
61
+ actionSubject: _analytics.ACTION_SUBJECT.ALIGNMENT,
62
+ action: _analytics.ACTION.UPDATED,
63
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.TEXT,
64
+ attributes: {
65
+ alignmentType: align,
66
+ inputMethod: inputMethod
67
+ }
68
+ })((0, _commands.toggleBlockMark)(alignment, function () {
69
+ return !align ? undefined : align === 'start' ? false : {
70
+ align: align
71
+ };
72
+ }, [paragraph, heading]))(state, dispatch);
73
+ };
74
+ };
75
+ var changeImageAlignmentWithAnalytics = function changeImageAlignmentWithAnalytics(editorAnalyticsApi, align, inputMethod) {
76
+ return function (state, dispatch) {
77
+ return (0, _editorAnalytics.withAnalytics)(editorAnalyticsApi, {
78
+ eventType: _analytics.EVENT_TYPE.TRACK,
79
+ actionSubject: _analytics.ACTION_SUBJECT.ALIGNMENT,
80
+ action: _analytics.ACTION.UPDATED,
81
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.MEDIA_SINGLE,
82
+ attributes: {
83
+ alignmentType: align,
84
+ inputMethod: inputMethod
85
+ }
86
+ })((0, _commands.changeImageAlignment)(align))(state, dispatch);
87
+ };
88
+ };
89
+ var changeAlignment = exports.changeAlignment = function changeAlignment(align, api, inputMethod) {
90
+ return function (state, dispatch) {
91
+ var _api$analytics, _api$analytics2;
92
+ var _state$schema3 = state.schema,
93
+ _state$schema3$nodes = _state$schema3.nodes,
94
+ paragraph = _state$schema3$nodes.paragraph,
95
+ heading = _state$schema3$nodes.heading,
96
+ alignment = _state$schema3.marks.alignment;
97
+ return cascadeCommands((0, _platformFeatureFlags.fg)('platform_editor_add_alignment_tracking') ? [changeImageAlignmentWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, align, inputMethod), changeBlockAlignmentWithAnalytics(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, align, inputMethod)] : [(0, _commands.changeImageAlignment)(align), (0, _commands.toggleBlockMark)(alignment, function () {
57
98
  return !align ? undefined : align === 'start' ? false : {
58
99
  align: align
59
100
  };
@@ -4,19 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.keymapPlugin = keymapPlugin;
7
+ var _analytics = require("@atlaskit/editor-common/analytics");
7
8
  var _keymaps = require("@atlaskit/editor-common/keymaps");
8
9
  var _editorCommands = require("../editor-commands");
9
- function keymapPlugin() {
10
+ function keymapPlugin(api) {
10
11
  var list = {};
11
12
 
12
13
  // Ignored via go/ees005
14
+ (0, _keymaps.bindKeymapWithCommand)(
13
15
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
14
- (0, _keymaps.bindKeymapWithCommand)(_keymaps.alignLeft.common, (0, _editorCommands.changeAlignment)('start'), list);
16
+ _keymaps.alignLeft.common, (0, _editorCommands.changeAlignment)('start', api, _analytics.INPUT_METHOD.SHORTCUT), list);
15
17
  // Ignored via go/ees005
18
+ (0, _keymaps.bindKeymapWithCommand)(
16
19
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
17
- (0, _keymaps.bindKeymapWithCommand)(_keymaps.alignCenter.common, (0, _editorCommands.changeAlignment)('center'), list);
20
+ _keymaps.alignCenter.common, (0, _editorCommands.changeAlignment)('center', api, _analytics.INPUT_METHOD.SHORTCUT), list);
18
21
  // Ignored via go/ees005
22
+ (0, _keymaps.bindKeymapWithCommand)(
19
23
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20
- (0, _keymaps.bindKeymapWithCommand)(_keymaps.alignRight.common, (0, _editorCommands.changeAlignment)('end'), list);
24
+ _keymaps.alignRight.common, (0, _editorCommands.changeAlignment)('end', api, _analytics.INPUT_METHOD.SHORTCUT), list);
21
25
  return (0, _keymaps.keymap)(list);
22
26
  }
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.FloatingToolbarComponent = FloatingToolbarComponent;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
+ var _analytics = require("@atlaskit/editor-common/analytics");
10
11
  var _hooks = require("@atlaskit/editor-common/hooks");
11
12
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
12
13
  var _editorCommands = require("../editor-commands");
@@ -24,8 +25,8 @@ function FloatingToolbarComponent(_ref) {
24
25
  var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['alignment']),
25
26
  alignmentState = _useSharedPluginState.alignmentState;
26
27
  var changeAlignmentCallback = (0, _react.useCallback)(function (align) {
27
- return (0, _editorCommands.changeAlignment)(align)(editorView.state, editorView.dispatch);
28
- }, [editorView]);
28
+ return (0, _editorCommands.changeAlignment)(align, api, _analytics.INPUT_METHOD.FLOATING_TB)(editorView.state, editorView.dispatch);
29
+ }, [editorView, api]);
29
30
  return /*#__PURE__*/_react.default.createElement(_ToolbarAlignment.default, {
30
31
  pluginState: alignmentState,
31
32
  isReducedSpacing: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? false : FloatingToolbarSettings.isToolbarReducedSpacing,
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.PrimaryToolbarComponent = PrimaryToolbarComponent;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
+ var _analytics = require("@atlaskit/editor-common/analytics");
10
11
  var _hooks = require("@atlaskit/editor-common/hooks");
11
12
  var _types = require("@atlaskit/editor-common/types");
12
13
  var _editorCommands = require("../editor-commands");
@@ -27,8 +28,8 @@ function PrimaryToolbarComponent(_ref) {
27
28
  var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['alignment']),
28
29
  alignmentState = _useSharedPluginState.alignmentState;
29
30
  var changeAlignmentCallback = (0, _react.useCallback)(function (align) {
30
- return (0, _editorCommands.changeAlignment)(align)(editorView.state, editorView.dispatch);
31
- }, [editorView]);
31
+ return (0, _editorCommands.changeAlignment)(align, api, _analytics.INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
32
+ }, [editorView, api]);
32
33
  return /*#__PURE__*/_react.default.createElement(_ToolbarAlignment.default, {
33
34
  pluginState: alignmentState,
34
35
  isReducedSpacing: isToolbarReducedSpacing,
@@ -62,7 +62,7 @@ export const alignmentPlugin = ({
62
62
  }) => createPlugin(dispatch, defaultConfig)
63
63
  }, {
64
64
  name: 'annotationKeymap',
65
- plugin: () => keymapPlugin()
65
+ plugin: () => keymapPlugin(api)
66
66
  }];
67
67
  },
68
68
  pluginsOptions: {
@@ -1,5 +1,8 @@
1
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
1
2
  import { changeImageAlignment, toggleBlockMark } from '@atlaskit/editor-common/commands';
3
+ import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
2
4
  import { Selection } from '@atlaskit/editor-prosemirror/state';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
3
6
  /**
4
7
  * Iterates over the commands one after the other,
5
8
  * passes the tr through and dispatches the cumulated transaction
@@ -40,7 +43,7 @@ export const isAlignable = align => (state, dispatch) => {
40
43
  align
41
44
  }, [paragraph, heading])(state, dispatch);
42
45
  };
43
- export const changeAlignment = align => (state, dispatch) => {
46
+ const changeBlockAlignmentWithAnalytics = (editorAnalyticsApi, align, inputMethod) => (state, dispatch) => {
44
47
  const {
45
48
  nodes: {
46
49
  paragraph,
@@ -50,7 +53,43 @@ export const changeAlignment = align => (state, dispatch) => {
50
53
  alignment
51
54
  }
52
55
  } = state.schema;
53
- return cascadeCommands([changeImageAlignment(align), toggleBlockMark(alignment, () => !align ? undefined : align === 'start' ? false : {
56
+ return withAnalytics(editorAnalyticsApi, {
57
+ eventType: EVENT_TYPE.TRACK,
58
+ actionSubject: ACTION_SUBJECT.ALIGNMENT,
59
+ action: ACTION.UPDATED,
60
+ actionSubjectId: ACTION_SUBJECT_ID.TEXT,
61
+ attributes: {
62
+ alignmentType: align,
63
+ inputMethod
64
+ }
65
+ })(toggleBlockMark(alignment, () => !align ? undefined : align === 'start' ? false : {
66
+ align
67
+ }, [paragraph, heading]))(state, dispatch);
68
+ };
69
+ const changeImageAlignmentWithAnalytics = (editorAnalyticsApi, align, inputMethod) => (state, dispatch) => {
70
+ return withAnalytics(editorAnalyticsApi, {
71
+ eventType: EVENT_TYPE.TRACK,
72
+ actionSubject: ACTION_SUBJECT.ALIGNMENT,
73
+ action: ACTION.UPDATED,
74
+ actionSubjectId: ACTION_SUBJECT_ID.MEDIA_SINGLE,
75
+ attributes: {
76
+ alignmentType: align,
77
+ inputMethod
78
+ }
79
+ })(changeImageAlignment(align))(state, dispatch);
80
+ };
81
+ export const changeAlignment = (align, api, inputMethod) => (state, dispatch) => {
82
+ var _api$analytics, _api$analytics2;
83
+ const {
84
+ nodes: {
85
+ paragraph,
86
+ heading
87
+ },
88
+ marks: {
89
+ alignment
90
+ }
91
+ } = state.schema;
92
+ return cascadeCommands(fg('platform_editor_add_alignment_tracking') ? [changeImageAlignmentWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, align, inputMethod), changeBlockAlignmentWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, align, inputMethod)] : [changeImageAlignment(align), toggleBlockMark(alignment, () => !align ? undefined : align === 'start' ? false : {
54
93
  align
55
94
  }, [paragraph, heading])])(state, dispatch);
56
95
  };
@@ -1,16 +1,20 @@
1
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
1
2
  import { alignCenter, alignLeft, alignRight, bindKeymapWithCommand, keymap } from '@atlaskit/editor-common/keymaps';
2
3
  import { changeAlignment } from '../editor-commands';
3
- export function keymapPlugin() {
4
+ export function keymapPlugin(api) {
4
5
  const list = {};
5
6
 
6
7
  // Ignored via go/ees005
8
+ bindKeymapWithCommand(
7
9
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8
- bindKeymapWithCommand(alignLeft.common, changeAlignment('start'), list);
10
+ alignLeft.common, changeAlignment('start', api, INPUT_METHOD.SHORTCUT), list);
9
11
  // Ignored via go/ees005
12
+ bindKeymapWithCommand(
10
13
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
11
- bindKeymapWithCommand(alignCenter.common, changeAlignment('center'), list);
14
+ alignCenter.common, changeAlignment('center', api, INPUT_METHOD.SHORTCUT), list);
12
15
  // Ignored via go/ees005
16
+ bindKeymapWithCommand(
13
17
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
14
- bindKeymapWithCommand(alignRight.common, changeAlignment('end'), list);
18
+ alignRight.common, changeAlignment('end', api, INPUT_METHOD.SHORTCUT), list);
15
19
  return keymap(list);
16
20
  }
@@ -1,4 +1,5 @@
1
1
  import React, { useCallback } from 'react';
2
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
4
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
5
  import { changeAlignment } from '../editor-commands';
@@ -16,8 +17,8 @@ export function FloatingToolbarComponent({
16
17
  alignmentState
17
18
  } = useSharedPluginState(api, ['alignment']);
18
19
  const changeAlignmentCallback = useCallback(align => {
19
- return changeAlignment(align)(editorView.state, editorView.dispatch);
20
- }, [editorView]);
20
+ return changeAlignment(align, api, INPUT_METHOD.FLOATING_TB)(editorView.state, editorView.dispatch);
21
+ }, [editorView, api]);
21
22
  return /*#__PURE__*/React.createElement(ToolbarAlignment, {
22
23
  pluginState: alignmentState,
23
24
  isReducedSpacing: editorExperiment('platform_editor_controls', 'variant1') ? false : FloatingToolbarSettings.isToolbarReducedSpacing,
@@ -1,4 +1,5 @@
1
1
  import React, { useCallback } from 'react';
2
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
4
  import { ToolbarSize } from '@atlaskit/editor-common/types';
4
5
  import { changeAlignment } from '../editor-commands';
@@ -17,7 +18,7 @@ export function PrimaryToolbarComponent({
17
18
  const {
18
19
  alignmentState
19
20
  } = useSharedPluginState(api, ['alignment']);
20
- const changeAlignmentCallback = useCallback(align => changeAlignment(align)(editorView.state, editorView.dispatch), [editorView]);
21
+ const changeAlignmentCallback = useCallback(align => changeAlignment(align, api, INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch), [editorView, api]);
21
22
  return /*#__PURE__*/React.createElement(ToolbarAlignment, {
22
23
  pluginState: alignmentState,
23
24
  isReducedSpacing: isToolbarReducedSpacing,
@@ -62,7 +62,7 @@ export var alignmentPlugin = function alignmentPlugin(_ref) {
62
62
  }, {
63
63
  name: 'annotationKeymap',
64
64
  plugin: function plugin() {
65
- return keymapPlugin();
65
+ return keymapPlugin(api);
66
66
  }
67
67
  }];
68
68
  },
@@ -1,5 +1,8 @@
1
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
1
2
  import { changeImageAlignment, toggleBlockMark } from '@atlaskit/editor-common/commands';
3
+ import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
2
4
  import { Selection } from '@atlaskit/editor-prosemirror/state';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
3
6
  /**
4
7
  * Iterates over the commands one after the other,
5
8
  * passes the tr through and dispatches the cumulated transaction
@@ -40,14 +43,52 @@ export var isAlignable = function isAlignable(align) {
40
43
  }, [paragraph, heading])(state, dispatch);
41
44
  };
42
45
  };
43
- export var changeAlignment = function changeAlignment(align) {
46
+ var changeBlockAlignmentWithAnalytics = function changeBlockAlignmentWithAnalytics(editorAnalyticsApi, align, inputMethod) {
44
47
  return function (state, dispatch) {
45
48
  var _state$schema2 = state.schema,
46
49
  _state$schema2$nodes = _state$schema2.nodes,
47
50
  paragraph = _state$schema2$nodes.paragraph,
48
51
  heading = _state$schema2$nodes.heading,
49
52
  alignment = _state$schema2.marks.alignment;
50
- return cascadeCommands([changeImageAlignment(align), toggleBlockMark(alignment, function () {
53
+ return withAnalytics(editorAnalyticsApi, {
54
+ eventType: EVENT_TYPE.TRACK,
55
+ actionSubject: ACTION_SUBJECT.ALIGNMENT,
56
+ action: ACTION.UPDATED,
57
+ actionSubjectId: ACTION_SUBJECT_ID.TEXT,
58
+ attributes: {
59
+ alignmentType: align,
60
+ inputMethod: inputMethod
61
+ }
62
+ })(toggleBlockMark(alignment, function () {
63
+ return !align ? undefined : align === 'start' ? false : {
64
+ align: align
65
+ };
66
+ }, [paragraph, heading]))(state, dispatch);
67
+ };
68
+ };
69
+ var changeImageAlignmentWithAnalytics = function changeImageAlignmentWithAnalytics(editorAnalyticsApi, align, inputMethod) {
70
+ return function (state, dispatch) {
71
+ return withAnalytics(editorAnalyticsApi, {
72
+ eventType: EVENT_TYPE.TRACK,
73
+ actionSubject: ACTION_SUBJECT.ALIGNMENT,
74
+ action: ACTION.UPDATED,
75
+ actionSubjectId: ACTION_SUBJECT_ID.MEDIA_SINGLE,
76
+ attributes: {
77
+ alignmentType: align,
78
+ inputMethod: inputMethod
79
+ }
80
+ })(changeImageAlignment(align))(state, dispatch);
81
+ };
82
+ };
83
+ export var changeAlignment = function changeAlignment(align, api, inputMethod) {
84
+ return function (state, dispatch) {
85
+ var _api$analytics, _api$analytics2;
86
+ var _state$schema3 = state.schema,
87
+ _state$schema3$nodes = _state$schema3.nodes,
88
+ paragraph = _state$schema3$nodes.paragraph,
89
+ heading = _state$schema3$nodes.heading,
90
+ alignment = _state$schema3.marks.alignment;
91
+ return cascadeCommands(fg('platform_editor_add_alignment_tracking') ? [changeImageAlignmentWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, align, inputMethod), changeBlockAlignmentWithAnalytics(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, align, inputMethod)] : [changeImageAlignment(align), toggleBlockMark(alignment, function () {
51
92
  return !align ? undefined : align === 'start' ? false : {
52
93
  align: align
53
94
  };
@@ -1,16 +1,20 @@
1
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
1
2
  import { alignCenter, alignLeft, alignRight, bindKeymapWithCommand, keymap } from '@atlaskit/editor-common/keymaps';
2
3
  import { changeAlignment } from '../editor-commands';
3
- export function keymapPlugin() {
4
+ export function keymapPlugin(api) {
4
5
  var list = {};
5
6
 
6
7
  // Ignored via go/ees005
8
+ bindKeymapWithCommand(
7
9
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8
- bindKeymapWithCommand(alignLeft.common, changeAlignment('start'), list);
10
+ alignLeft.common, changeAlignment('start', api, INPUT_METHOD.SHORTCUT), list);
9
11
  // Ignored via go/ees005
12
+ bindKeymapWithCommand(
10
13
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
11
- bindKeymapWithCommand(alignCenter.common, changeAlignment('center'), list);
14
+ alignCenter.common, changeAlignment('center', api, INPUT_METHOD.SHORTCUT), list);
12
15
  // Ignored via go/ees005
16
+ bindKeymapWithCommand(
13
17
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
14
- bindKeymapWithCommand(alignRight.common, changeAlignment('end'), list);
18
+ alignRight.common, changeAlignment('end', api, INPUT_METHOD.SHORTCUT), list);
15
19
  return keymap(list);
16
20
  }
@@ -1,4 +1,5 @@
1
1
  import React, { useCallback } from 'react';
2
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
4
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
5
  import { changeAlignment } from '../editor-commands';
@@ -14,8 +15,8 @@ export function FloatingToolbarComponent(_ref) {
14
15
  var _useSharedPluginState = useSharedPluginState(api, ['alignment']),
15
16
  alignmentState = _useSharedPluginState.alignmentState;
16
17
  var changeAlignmentCallback = useCallback(function (align) {
17
- return changeAlignment(align)(editorView.state, editorView.dispatch);
18
- }, [editorView]);
18
+ return changeAlignment(align, api, INPUT_METHOD.FLOATING_TB)(editorView.state, editorView.dispatch);
19
+ }, [editorView, api]);
19
20
  return /*#__PURE__*/React.createElement(ToolbarAlignment, {
20
21
  pluginState: alignmentState,
21
22
  isReducedSpacing: editorExperiment('platform_editor_controls', 'variant1') ? false : FloatingToolbarSettings.isToolbarReducedSpacing,
@@ -1,4 +1,5 @@
1
1
  import React, { useCallback } from 'react';
2
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
4
  import { ToolbarSize } from '@atlaskit/editor-common/types';
4
5
  import { changeAlignment } from '../editor-commands';
@@ -17,8 +18,8 @@ export function PrimaryToolbarComponent(_ref) {
17
18
  var _useSharedPluginState = useSharedPluginState(api, ['alignment']),
18
19
  alignmentState = _useSharedPluginState.alignmentState;
19
20
  var changeAlignmentCallback = useCallback(function (align) {
20
- return changeAlignment(align)(editorView.state, editorView.dispatch);
21
- }, [editorView]);
21
+ return changeAlignment(align, api, INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
22
+ }, [editorView, api]);
22
23
  return /*#__PURE__*/React.createElement(ToolbarAlignment, {
23
24
  pluginState: alignmentState,
24
25
  isReducedSpacing: isToolbarReducedSpacing,
@@ -1,12 +1,16 @@
1
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
1
2
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
+ import { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
2
4
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
3
5
  import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
4
6
  import type { AlignmentPluginState } from './pm-plugins/types';
5
7
  export type AlignmentPluginDependencies = [
6
8
  OptionalPlugin<PrimaryToolbarPlugin>,
7
- OptionalPlugin<SelectionToolbarPlugin>
9
+ OptionalPlugin<SelectionToolbarPlugin>,
10
+ OptionalPlugin<AnalyticsPlugin>
8
11
  ];
9
12
  export type AlignmentPlugin = NextEditorPlugin<'alignment', {
10
13
  sharedState: AlignmentPluginState | undefined;
11
14
  dependencies: AlignmentPluginDependencies;
12
15
  }>;
16
+ export type InputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.SHORTCUT;
@@ -1,4 +1,5 @@
1
- import type { Command } from '@atlaskit/editor-common/types';
1
+ import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { AlignmentPlugin, InputMethod } from '../alignmentPluginType';
2
3
  import type { AlignmentState } from '../pm-plugins/types';
3
4
  export declare const isAlignable: (align?: AlignmentState) => Command;
4
- export declare const changeAlignment: (align?: AlignmentState) => Command;
5
+ export declare const changeAlignment: (align?: AlignmentState, api?: ExtractInjectionAPI<AlignmentPlugin>, inputMethod?: InputMethod) => Command;
@@ -1,2 +1,4 @@
1
1
  import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- export declare function keymapPlugin(): SafePlugin;
2
+ import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import { AlignmentPlugin } from '../alignmentPluginType';
4
+ export declare function keymapPlugin(api?: ExtractInjectionAPI<AlignmentPlugin>): SafePlugin;
@@ -1,12 +1,16 @@
1
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
1
2
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
+ import { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
2
4
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
3
5
  import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
4
6
  import type { AlignmentPluginState } from './pm-plugins/types';
5
7
  export type AlignmentPluginDependencies = [
6
8
  OptionalPlugin<PrimaryToolbarPlugin>,
7
- OptionalPlugin<SelectionToolbarPlugin>
9
+ OptionalPlugin<SelectionToolbarPlugin>,
10
+ OptionalPlugin<AnalyticsPlugin>
8
11
  ];
9
12
  export type AlignmentPlugin = NextEditorPlugin<'alignment', {
10
13
  sharedState: AlignmentPluginState | undefined;
11
14
  dependencies: AlignmentPluginDependencies;
12
15
  }>;
16
+ export type InputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.SHORTCUT;
@@ -1,4 +1,5 @@
1
- import type { Command } from '@atlaskit/editor-common/types';
1
+ import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { AlignmentPlugin, InputMethod } from '../alignmentPluginType';
2
3
  import type { AlignmentState } from '../pm-plugins/types';
3
4
  export declare const isAlignable: (align?: AlignmentState) => Command;
4
- export declare const changeAlignment: (align?: AlignmentState) => Command;
5
+ export declare const changeAlignment: (align?: AlignmentState, api?: ExtractInjectionAPI<AlignmentPlugin>, inputMethod?: InputMethod) => Command;
@@ -1,2 +1,4 @@
1
1
  import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- export declare function keymapPlugin(): SafePlugin;
2
+ import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import { AlignmentPlugin } from '../alignmentPluginType';
4
+ export declare function keymapPlugin(api?: ExtractInjectionAPI<AlignmentPlugin>): SafePlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-alignment",
3
- "version": "3.1.8",
3
+ "version": "3.1.9",
4
4
  "description": "Alignment plugin for @atlaskit/editor-core",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -24,14 +24,18 @@
24
24
  "platform-feature-flags": {
25
25
  "platform-visual-refresh-icons": {
26
26
  "type": "boolean"
27
+ },
28
+ "platform_editor_add_alignment_tracking": {
29
+ "type": "boolean"
27
30
  }
28
31
  },
29
32
  "dependencies": {
30
33
  "@atlaskit/adf-schema": "^47.6.0",
31
34
  "@atlaskit/css": "^0.10.0",
32
- "@atlaskit/editor-common": "^103.0.0",
35
+ "@atlaskit/editor-common": "^103.3.0",
36
+ "@atlaskit/editor-plugin-analytics": "^2.2.0",
33
37
  "@atlaskit/editor-plugin-primary-toolbar": "^3.1.0",
34
- "@atlaskit/editor-plugin-selection-toolbar": "^3.1.0",
38
+ "@atlaskit/editor-plugin-selection-toolbar": "^3.3.0",
35
39
  "@atlaskit/editor-prosemirror": "7.0.0",
36
40
  "@atlaskit/editor-tables": "^2.9.0",
37
41
  "@atlaskit/icon": "^25.5.0",