@atlaskit/editor-plugin-alignment 4.1.3 → 4.1.4

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 (39) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/alignmentPlugin.js +15 -7
  3. package/dist/cjs/editor-commands/index.js +71 -3
  4. package/dist/cjs/ui/Toolbar/AlignmentMenu.js +41 -0
  5. package/dist/cjs/ui/Toolbar/AlignmentMenuItem.js +46 -0
  6. package/dist/cjs/ui/Toolbar/options.js +38 -0
  7. package/dist/cjs/ui/Toolbar/types.js +5 -0
  8. package/dist/cjs/ui/toolbar-components.js +75 -0
  9. package/dist/es2019/alignmentPlugin.js +15 -7
  10. package/dist/es2019/editor-commands/index.js +70 -3
  11. package/dist/es2019/ui/Toolbar/AlignmentMenu.js +38 -0
  12. package/dist/es2019/ui/Toolbar/AlignmentMenuItem.js +43 -0
  13. package/dist/es2019/ui/Toolbar/options.js +30 -0
  14. package/dist/es2019/ui/Toolbar/types.js +1 -0
  15. package/dist/es2019/ui/toolbar-components.js +67 -0
  16. package/dist/esm/alignmentPlugin.js +15 -7
  17. package/dist/esm/editor-commands/index.js +71 -3
  18. package/dist/esm/ui/Toolbar/AlignmentMenu.js +34 -0
  19. package/dist/esm/ui/Toolbar/AlignmentMenuItem.js +39 -0
  20. package/dist/esm/ui/Toolbar/options.js +32 -0
  21. package/dist/esm/ui/Toolbar/types.js +1 -0
  22. package/dist/esm/ui/toolbar-components.js +68 -0
  23. package/dist/types/alignmentPluginType.d.ts +3 -1
  24. package/dist/types/editor-commands/index.d.ts +6 -1
  25. package/dist/types/ui/Alignment/index.d.ts +0 -1
  26. package/dist/types/ui/Toolbar/AlignmentMenu.d.ts +7 -0
  27. package/dist/types/ui/Toolbar/AlignmentMenuItem.d.ts +12 -0
  28. package/dist/types/ui/Toolbar/options.d.ts +3 -0
  29. package/dist/types/ui/Toolbar/types.d.ts +11 -0
  30. package/dist/types/ui/toolbar-components.d.ts +4 -0
  31. package/dist/types-ts4.5/alignmentPluginType.d.ts +3 -1
  32. package/dist/types-ts4.5/editor-commands/index.d.ts +6 -1
  33. package/dist/types-ts4.5/ui/Alignment/index.d.ts +0 -1
  34. package/dist/types-ts4.5/ui/Toolbar/AlignmentMenu.d.ts +7 -0
  35. package/dist/types-ts4.5/ui/Toolbar/AlignmentMenuItem.d.ts +12 -0
  36. package/dist/types-ts4.5/ui/Toolbar/options.d.ts +3 -0
  37. package/dist/types-ts4.5/ui/Toolbar/types.d.ts +11 -0
  38. package/dist/types-ts4.5/ui/toolbar-components.d.ts +4 -0
  39. package/package.json +7 -6
@@ -0,0 +1,67 @@
1
+ import React from 'react';
2
+ import { ALIGNMENT_GROUP, ALIGNMENT_GROUP_RANK, ALIGNMENT_MENU, ALIGNMENT_MENU_SECTION, TEXT_SECTION, TEXT_SECTION_RANK, ALIGNMENT_MENU_RANK } from '@atlaskit/editor-common/toolbar';
3
+ import { AlignmentMenu } from './Toolbar/AlignmentMenu';
4
+ import { AlignmentMenuItem } from './Toolbar/AlignmentMenuItem';
5
+ import { alignmentOptions } from './Toolbar/options';
6
+ const getAlignmentMenuItems = api => {
7
+ return Object.entries(alignmentOptions()).map(([alignment, item]) => {
8
+ const {
9
+ key,
10
+ type,
11
+ rank
12
+ } = item;
13
+ return {
14
+ type,
15
+ key,
16
+ parents: [{
17
+ type: ALIGNMENT_MENU_SECTION.type,
18
+ key: ALIGNMENT_MENU_SECTION.key,
19
+ rank
20
+ }],
21
+ component: ({
22
+ parents
23
+ }) => {
24
+ return /*#__PURE__*/React.createElement(AlignmentMenuItem, {
25
+ api: api,
26
+ option: item,
27
+ alignment: alignment,
28
+ parents: parents
29
+ });
30
+ }
31
+ };
32
+ });
33
+ };
34
+ export const getToolbarComponents = api => {
35
+ return [{
36
+ type: ALIGNMENT_GROUP.type,
37
+ key: ALIGNMENT_GROUP.key,
38
+ parents: [{
39
+ type: TEXT_SECTION.type,
40
+ key: TEXT_SECTION.key,
41
+ rank: TEXT_SECTION_RANK[ALIGNMENT_GROUP.key]
42
+ }]
43
+ }, {
44
+ type: ALIGNMENT_MENU.type,
45
+ key: ALIGNMENT_MENU.key,
46
+ parents: [{
47
+ type: ALIGNMENT_GROUP.type,
48
+ key: ALIGNMENT_GROUP.key,
49
+ rank: ALIGNMENT_GROUP_RANK[ALIGNMENT_MENU.key]
50
+ }],
51
+ component: ({
52
+ children
53
+ }) => {
54
+ return /*#__PURE__*/React.createElement(AlignmentMenu, {
55
+ api: api
56
+ }, children);
57
+ }
58
+ }, {
59
+ type: ALIGNMENT_MENU_SECTION.type,
60
+ key: ALIGNMENT_MENU_SECTION.key,
61
+ parents: [{
62
+ type: ALIGNMENT_MENU.type,
63
+ key: ALIGNMENT_MENU.key,
64
+ rank: ALIGNMENT_MENU_RANK[ALIGNMENT_MENU_SECTION.key]
65
+ }]
66
+ }, ...getAlignmentMenuItems(api)];
67
+ };
@@ -1,17 +1,19 @@
1
1
  import React from 'react';
2
2
  import { alignment } from '@atlaskit/adf-schema';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
6
  import { keymapPlugin } from './pm-plugins/keymap';
6
7
  import { createPlugin, pluginKey } from './pm-plugins/main';
7
8
  import { FloatingToolbarComponent } from './ui/FloatingToolbarComponent';
8
9
  import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
10
+ import { getToolbarComponents } from './ui/toolbar-components';
9
11
  export var defaultConfig = {
10
12
  align: 'start'
11
13
  };
12
14
  export var alignmentPlugin = function alignmentPlugin(_ref) {
13
- var _api$primaryToolbar;
14
15
  var api = _ref.api;
16
+ var isToolbarAIFCEnabled = expValEquals('platform_editor_toolbar_aifc', 'isEnabled', true);
15
17
  var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
16
18
  var editorView = _ref2.editorView,
17
19
  popupsMountPoint = _ref2.popupsMountPoint,
@@ -29,10 +31,16 @@ export var alignmentPlugin = function alignmentPlugin(_ref) {
29
31
  isToolbarReducedSpacing: isToolbarReducedSpacing
30
32
  });
31
33
  };
32
- api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
33
- name: 'alignment',
34
- component: primaryToolbarComponent
35
- });
34
+ if (isToolbarAIFCEnabled) {
35
+ var _api$toolbar;
36
+ api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents(getToolbarComponents(api));
37
+ } else {
38
+ var _api$primaryToolbar;
39
+ api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
40
+ name: 'alignment',
41
+ component: primaryToolbarComponent
42
+ });
43
+ }
36
44
  return {
37
45
  name: 'alignment',
38
46
  marks: function marks() {
@@ -66,7 +74,7 @@ export var alignmentPlugin = function alignmentPlugin(_ref) {
66
74
  }];
67
75
  },
68
76
  pluginsOptions: {
69
- selectionToolbar: function selectionToolbar() {
77
+ selectionToolbar: isToolbarAIFCEnabled ? undefined : function () {
70
78
  var _api$userPreferences, _api$selectionToolbar;
71
79
  var toolbarDocking = fg('platform_editor_use_preferences_plugin') ? api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.preferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.toolbarDockingPosition : api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.currentState()) === null || _api$selectionToolbar === void 0 ? void 0 : _api$selectionToolbar.toolbarDocking;
72
80
  if (toolbarDocking === 'none' && editorExperiment('platform_editor_controls', 'variant1', {
@@ -96,6 +104,6 @@ export var alignmentPlugin = function alignmentPlugin(_ref) {
96
104
  }
97
105
  }
98
106
  },
99
- primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
107
+ primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) && !isToolbarAIFCEnabled ? primaryToolbarComponent : undefined
100
108
  };
101
109
  };
@@ -1,5 +1,5 @@
1
1
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
- import { changeImageAlignment, toggleBlockMark } from '@atlaskit/editor-common/commands';
2
+ import { changeImageAlignment, changeImageAlignmentNext, toggleBlockMark, toggleBlockMarkNext } from '@atlaskit/editor-common/commands';
3
3
  import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
4
4
  import { Selection } from '@atlaskit/editor-prosemirror/state';
5
5
  /**
@@ -65,6 +65,35 @@ var changeBlockAlignmentWithAnalytics = function changeBlockAlignmentWithAnalyti
65
65
  }, [paragraph, heading]))(state, dispatch);
66
66
  };
67
67
  };
68
+ var changeBlockAlignmentWithAnalyticsTr = function changeBlockAlignmentWithAnalyticsTr(api, align, inputMethod) {
69
+ return function (_ref) {
70
+ var tr = _ref.tr;
71
+ var _tr$doc$type$schema = tr.doc.type.schema,
72
+ _tr$doc$type$schema$n = _tr$doc$type$schema.nodes,
73
+ paragraph = _tr$doc$type$schema$n.paragraph,
74
+ heading = _tr$doc$type$schema$n.heading,
75
+ alignment = _tr$doc$type$schema.marks.alignment;
76
+ var alignmentApplied = toggleBlockMarkNext(alignment, function () {
77
+ return !align ? undefined : align === 'start' ? false : {
78
+ align: align
79
+ };
80
+ }, [paragraph, heading])(tr);
81
+ if (alignmentApplied) {
82
+ var _api$analytics;
83
+ api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
84
+ eventType: EVENT_TYPE.TRACK,
85
+ actionSubject: ACTION_SUBJECT.ALIGNMENT,
86
+ action: ACTION.UPDATED,
87
+ actionSubjectId: ACTION_SUBJECT_ID.TEXT,
88
+ attributes: {
89
+ alignmentType: align,
90
+ inputMethod: inputMethod
91
+ }
92
+ })(tr);
93
+ }
94
+ return tr;
95
+ };
96
+ };
68
97
  var changeImageAlignmentWithAnalytics = function changeImageAlignmentWithAnalytics(editorAnalyticsApi, align, inputMethod) {
69
98
  return function (state, dispatch) {
70
99
  return withAnalytics(editorAnalyticsApi, {
@@ -79,9 +108,48 @@ var changeImageAlignmentWithAnalytics = function changeImageAlignmentWithAnalyti
79
108
  })(changeImageAlignment(align))(state, dispatch);
80
109
  };
81
110
  };
111
+ var changeImageAlignmentWithAnalyticsTr = function changeImageAlignmentWithAnalyticsTr(api, align, inputMethod) {
112
+ return function (_ref2) {
113
+ var tr = _ref2.tr;
114
+ var alignmentApplied = changeImageAlignmentNext(align)(tr);
115
+ if (alignmentApplied) {
116
+ var _api$analytics2;
117
+ api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
118
+ eventType: EVENT_TYPE.TRACK,
119
+ actionSubject: ACTION_SUBJECT.ALIGNMENT,
120
+ action: ACTION.UPDATED,
121
+ actionSubjectId: ACTION_SUBJECT_ID.MEDIA_SINGLE,
122
+ attributes: {
123
+ alignmentType: align,
124
+ inputMethod: inputMethod
125
+ }
126
+ })(tr);
127
+ }
128
+ return tr;
129
+ };
130
+ };
131
+
132
+ // Remove this when cleaning up platform_editor_toolbar_aifc
133
+ // eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required
134
+ /**
135
+ *
136
+ * @deprecated use changeAlignmentTr instead
137
+ */
82
138
  export var changeAlignment = function changeAlignment(align, api, inputMethod) {
83
139
  return function (state, dispatch) {
84
- var _api$analytics, _api$analytics2;
85
- return cascadeCommands([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)])(state, dispatch);
140
+ var _api$analytics3, _api$analytics4;
141
+ return cascadeCommands([changeImageAlignmentWithAnalytics(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, align, inputMethod), changeBlockAlignmentWithAnalytics(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, align, inputMethod)])(state, dispatch);
142
+ };
143
+ };
144
+ export var changeAlignmentTr = function changeAlignmentTr(api, align, inputMethod) {
145
+ return function (_ref3) {
146
+ var tr = _ref3.tr;
147
+ changeBlockAlignmentWithAnalyticsTr(api, align, inputMethod)({
148
+ tr: tr
149
+ });
150
+ changeImageAlignmentWithAnalyticsTr(api, align, inputMethod)({
151
+ tr: tr
152
+ });
153
+ return tr;
86
154
  };
87
155
  };
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { useIntl } from 'react-intl-next';
3
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
+ import { alignmentMessages as messages } from '@atlaskit/editor-common/messages';
5
+ import { ToolbarDropdownMenu, ToolbarTooltip } from '@atlaskit/editor-toolbar';
6
+ import { alignmentOptions } from './options';
7
+ export var AlignmentMenu = function AlignmentMenu(_ref) {
8
+ var children = _ref.children,
9
+ api = _ref.api;
10
+ var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['alignment'], function (states) {
11
+ var _states$alignmentStat, _states$alignmentStat2;
12
+ return {
13
+ align: (_states$alignmentStat = states.alignmentState) === null || _states$alignmentStat === void 0 ? void 0 : _states$alignmentStat.align,
14
+ isEnabled: (_states$alignmentStat2 = states.alignmentState) === null || _states$alignmentStat2 === void 0 ? void 0 : _states$alignmentStat2.isEnabled
15
+ };
16
+ }),
17
+ _useSharedPluginState2 = _useSharedPluginState.align,
18
+ align = _useSharedPluginState2 === void 0 ? 'start' : _useSharedPluginState2,
19
+ isEnabled = _useSharedPluginState.isEnabled;
20
+ var Icon = alignmentOptions()[align].icon;
21
+ var _useIntl = useIntl(),
22
+ formatMessage = _useIntl.formatMessage;
23
+ var title = formatMessage(messages.alignment);
24
+ return /*#__PURE__*/React.createElement(ToolbarTooltip, {
25
+ content: title
26
+ }, /*#__PURE__*/React.createElement(ToolbarDropdownMenu, {
27
+ iconBefore: /*#__PURE__*/React.createElement(Icon, {
28
+ label: ""
29
+ }),
30
+ isDisabled: !isEnabled,
31
+ testId: "text-alignment-menu",
32
+ label: title
33
+ }, children));
34
+ };
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import { useIntl } from 'react-intl-next';
3
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
+ import { getAriaKeyshortcuts, tooltip } from '@atlaskit/editor-common/keymaps';
5
+ import { getInputMethodFromParentKeys } from '@atlaskit/editor-common/toolbar';
6
+ import { ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
7
+ import { changeAlignmentTr } from '../../editor-commands';
8
+ export var AlignmentMenuItem = function AlignmentMenuItem(_ref) {
9
+ var _ref$option = _ref.option,
10
+ label = _ref$option.label,
11
+ Icon = _ref$option.icon,
12
+ keymap = _ref$option.keymap,
13
+ api = _ref.api,
14
+ alignment = _ref.alignment,
15
+ parents = _ref.parents;
16
+ var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['alignment'], function (states) {
17
+ var _states$alignmentStat;
18
+ return {
19
+ align: (_states$alignmentStat = states.alignmentState) === null || _states$alignmentStat === void 0 ? void 0 : _states$alignmentStat.align
20
+ };
21
+ }),
22
+ align = _useSharedPluginState.align;
23
+ var _useIntl = useIntl(),
24
+ formatMessage = _useIntl.formatMessage;
25
+ var shortcut = tooltip(keymap);
26
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
27
+ isSelected: align === alignment,
28
+ elemBefore: /*#__PURE__*/React.createElement(Icon, {
29
+ label: ""
30
+ }),
31
+ elemAfter: shortcut && /*#__PURE__*/React.createElement(ToolbarKeyboardShortcutHint, {
32
+ shortcut: shortcut
33
+ }),
34
+ ariaKeyshortcuts: getAriaKeyshortcuts(keymap),
35
+ onClick: function onClick() {
36
+ api === null || api === void 0 || api.core.actions.execute(changeAlignmentTr(api, alignment, getInputMethodFromParentKeys(parents)));
37
+ }
38
+ }, formatMessage(label));
39
+ };
@@ -0,0 +1,32 @@
1
+ import { alignCenter, alignLeft, alignRight } from '@atlaskit/editor-common/keymaps';
2
+ import { alignmentMessages as messages } from '@atlaskit/editor-common/messages';
3
+ import { ALIGN_LEFT_MENU_ITEM, ALIGN_CENTER_MENU_ITEM, ALIGN_RIGHT_MENU_ITEM, ALIGNMENT_MENU_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
4
+ import { AlignTextLeftIcon, AlignTextCenterIcon, AlignTextRightIcon } from '@atlaskit/editor-toolbar';
5
+ export var alignmentOptions = function alignmentOptions() {
6
+ return {
7
+ start: {
8
+ key: ALIGN_LEFT_MENU_ITEM.key,
9
+ type: ALIGN_LEFT_MENU_ITEM.type,
10
+ rank: ALIGNMENT_MENU_SECTION_RANK[ALIGN_LEFT_MENU_ITEM.key],
11
+ label: messages.alignLeft,
12
+ icon: AlignTextLeftIcon,
13
+ keymap: alignLeft
14
+ },
15
+ center: {
16
+ key: ALIGN_CENTER_MENU_ITEM.key,
17
+ type: ALIGN_CENTER_MENU_ITEM.type,
18
+ rank: ALIGNMENT_MENU_SECTION_RANK[ALIGN_CENTER_MENU_ITEM.key],
19
+ label: messages.alignCenter,
20
+ icon: AlignTextCenterIcon,
21
+ keymap: alignCenter
22
+ },
23
+ end: {
24
+ key: ALIGN_RIGHT_MENU_ITEM.key,
25
+ type: ALIGN_RIGHT_MENU_ITEM.type,
26
+ rank: ALIGNMENT_MENU_SECTION_RANK[ALIGN_RIGHT_MENU_ITEM.key],
27
+ label: messages.alignRight,
28
+ icon: AlignTextRightIcon,
29
+ keymap: alignRight
30
+ }
31
+ };
32
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,68 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import React from 'react';
4
+ import { ALIGNMENT_GROUP, ALIGNMENT_GROUP_RANK, ALIGNMENT_MENU, ALIGNMENT_MENU_SECTION, TEXT_SECTION, TEXT_SECTION_RANK, ALIGNMENT_MENU_RANK } from '@atlaskit/editor-common/toolbar';
5
+ import { AlignmentMenu } from './Toolbar/AlignmentMenu';
6
+ import { AlignmentMenuItem } from './Toolbar/AlignmentMenuItem';
7
+ import { alignmentOptions } from './Toolbar/options';
8
+ var getAlignmentMenuItems = function getAlignmentMenuItems(api) {
9
+ return Object.entries(alignmentOptions()).map(function (_ref) {
10
+ var _ref2 = _slicedToArray(_ref, 2),
11
+ alignment = _ref2[0],
12
+ item = _ref2[1];
13
+ var key = item.key,
14
+ type = item.type,
15
+ rank = item.rank;
16
+ return {
17
+ type: type,
18
+ key: key,
19
+ parents: [{
20
+ type: ALIGNMENT_MENU_SECTION.type,
21
+ key: ALIGNMENT_MENU_SECTION.key,
22
+ rank: rank
23
+ }],
24
+ component: function component(_ref3) {
25
+ var parents = _ref3.parents;
26
+ return /*#__PURE__*/React.createElement(AlignmentMenuItem, {
27
+ api: api,
28
+ option: item,
29
+ alignment: alignment,
30
+ parents: parents
31
+ });
32
+ }
33
+ };
34
+ });
35
+ };
36
+ export var getToolbarComponents = function getToolbarComponents(api) {
37
+ return [{
38
+ type: ALIGNMENT_GROUP.type,
39
+ key: ALIGNMENT_GROUP.key,
40
+ parents: [{
41
+ type: TEXT_SECTION.type,
42
+ key: TEXT_SECTION.key,
43
+ rank: TEXT_SECTION_RANK[ALIGNMENT_GROUP.key]
44
+ }]
45
+ }, {
46
+ type: ALIGNMENT_MENU.type,
47
+ key: ALIGNMENT_MENU.key,
48
+ parents: [{
49
+ type: ALIGNMENT_GROUP.type,
50
+ key: ALIGNMENT_GROUP.key,
51
+ rank: ALIGNMENT_GROUP_RANK[ALIGNMENT_MENU.key]
52
+ }],
53
+ component: function component(_ref4) {
54
+ var children = _ref4.children;
55
+ return /*#__PURE__*/React.createElement(AlignmentMenu, {
56
+ api: api
57
+ }, children);
58
+ }
59
+ }, {
60
+ type: ALIGNMENT_MENU_SECTION.type,
61
+ key: ALIGNMENT_MENU_SECTION.key,
62
+ parents: [{
63
+ type: ALIGNMENT_MENU.type,
64
+ key: ALIGNMENT_MENU.key,
65
+ rank: ALIGNMENT_MENU_RANK[ALIGNMENT_MENU_SECTION.key]
66
+ }]
67
+ }].concat(_toConsumableArray(getAlignmentMenuItems(api)));
68
+ };
@@ -3,13 +3,15 @@ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/t
3
3
  import { type AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
4
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
5
5
  import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
6
+ import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
6
7
  import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
7
8
  import type { AlignmentPluginState } from './pm-plugins/types';
8
9
  export type AlignmentPluginDependencies = [
9
10
  OptionalPlugin<PrimaryToolbarPlugin>,
10
11
  OptionalPlugin<SelectionToolbarPlugin>,
11
12
  OptionalPlugin<AnalyticsPlugin>,
12
- OptionalPlugin<UserPreferencesPlugin>
13
+ OptionalPlugin<UserPreferencesPlugin>,
14
+ OptionalPlugin<ToolbarPlugin>
13
15
  ];
14
16
  export type AlignmentPlugin = NextEditorPlugin<'alignment', {
15
17
  sharedState: AlignmentPluginState | undefined;
@@ -1,5 +1,10 @@
1
- import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
1
+ import type { Command, EditorCommand, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
2
  import type { AlignmentPlugin, InputMethod } from '../alignmentPluginType';
3
3
  import type { AlignmentState } from '../pm-plugins/types';
4
4
  export declare const isAlignable: (align?: AlignmentState) => Command;
5
+ /**
6
+ *
7
+ * @deprecated use changeAlignmentTr instead
8
+ */
5
9
  export declare const changeAlignment: (align?: AlignmentState, api?: ExtractInjectionAPI<AlignmentPlugin>, inputMethod?: InputMethod) => Command;
10
+ export declare const changeAlignmentTr: (api: ExtractInjectionAPI<AlignmentPlugin> | undefined, align?: AlignmentState, inputMethod?: InputMethod) => EditorCommand;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { WrappedComponentProps } from 'react-intl-next';
3
2
  import type { AlignmentState } from '../../pm-plugins/types';
4
3
  export interface Props {
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import { type AlignmentPlugin } from '../../alignmentPluginType';
4
+ export declare const AlignmentMenu: ({ children, api, }: {
5
+ children?: React.ReactNode;
6
+ api: ExtractInjectionAPI<AlignmentPlugin> | undefined;
7
+ }) => React.JSX.Element;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { ToolbarComponentTypes } from '@atlaskit/editor-toolbar-model';
4
+ import type { AlignmentPlugin } from '../../alignmentPluginType';
5
+ import type { AlignmentState } from '../../pm-plugins/types';
6
+ import type { OptionInfo } from './types';
7
+ export declare const AlignmentMenuItem: ({ option: { label, icon: Icon, keymap }, api, alignment, parents, }: {
8
+ option: OptionInfo;
9
+ api: ExtractInjectionAPI<AlignmentPlugin> | undefined;
10
+ alignment: AlignmentState;
11
+ parents: ToolbarComponentTypes;
12
+ }) => React.JSX.Element;
@@ -0,0 +1,3 @@
1
+ import type { AlignmentState } from '../../pm-plugins/types';
2
+ import type { OptionInfo } from './types';
3
+ export declare const alignmentOptions: () => Record<AlignmentState, OptionInfo>;
@@ -0,0 +1,11 @@
1
+ import type { MessageDescriptor } from 'react-intl-next';
2
+ import type { Keymap } from '@atlaskit/editor-common/keymaps';
3
+ import type { IconComponent } from '@atlaskit/editor-toolbar';
4
+ export type OptionInfo = {
5
+ key: string;
6
+ type: 'menu-item';
7
+ label: MessageDescriptor;
8
+ icon: IconComponent;
9
+ keymap: Keymap;
10
+ rank: number;
11
+ };
@@ -0,0 +1,4 @@
1
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
3
+ import { type AlignmentPlugin } from '../alignmentPluginType';
4
+ export declare const getToolbarComponents: (api: ExtractInjectionAPI<AlignmentPlugin> | undefined) => RegisterComponent[];
@@ -3,13 +3,15 @@ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/t
3
3
  import { type AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
4
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
5
5
  import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
6
+ import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
6
7
  import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
7
8
  import type { AlignmentPluginState } from './pm-plugins/types';
8
9
  export type AlignmentPluginDependencies = [
9
10
  OptionalPlugin<PrimaryToolbarPlugin>,
10
11
  OptionalPlugin<SelectionToolbarPlugin>,
11
12
  OptionalPlugin<AnalyticsPlugin>,
12
- OptionalPlugin<UserPreferencesPlugin>
13
+ OptionalPlugin<UserPreferencesPlugin>,
14
+ OptionalPlugin<ToolbarPlugin>
13
15
  ];
14
16
  export type AlignmentPlugin = NextEditorPlugin<'alignment', {
15
17
  sharedState: AlignmentPluginState | undefined;
@@ -1,5 +1,10 @@
1
- import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
1
+ import type { Command, EditorCommand, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
2
  import type { AlignmentPlugin, InputMethod } from '../alignmentPluginType';
3
3
  import type { AlignmentState } from '../pm-plugins/types';
4
4
  export declare const isAlignable: (align?: AlignmentState) => Command;
5
+ /**
6
+ *
7
+ * @deprecated use changeAlignmentTr instead
8
+ */
5
9
  export declare const changeAlignment: (align?: AlignmentState, api?: ExtractInjectionAPI<AlignmentPlugin>, inputMethod?: InputMethod) => Command;
10
+ export declare const changeAlignmentTr: (api: ExtractInjectionAPI<AlignmentPlugin> | undefined, align?: AlignmentState, inputMethod?: InputMethod) => EditorCommand;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { WrappedComponentProps } from 'react-intl-next';
3
2
  import type { AlignmentState } from '../../pm-plugins/types';
4
3
  export interface Props {
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import { type AlignmentPlugin } from '../../alignmentPluginType';
4
+ export declare const AlignmentMenu: ({ children, api, }: {
5
+ children?: React.ReactNode;
6
+ api: ExtractInjectionAPI<AlignmentPlugin> | undefined;
7
+ }) => React.JSX.Element;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { ToolbarComponentTypes } from '@atlaskit/editor-toolbar-model';
4
+ import type { AlignmentPlugin } from '../../alignmentPluginType';
5
+ import type { AlignmentState } from '../../pm-plugins/types';
6
+ import type { OptionInfo } from './types';
7
+ export declare const AlignmentMenuItem: ({ option: { label, icon: Icon, keymap }, api, alignment, parents, }: {
8
+ option: OptionInfo;
9
+ api: ExtractInjectionAPI<AlignmentPlugin> | undefined;
10
+ alignment: AlignmentState;
11
+ parents: ToolbarComponentTypes;
12
+ }) => React.JSX.Element;
@@ -0,0 +1,3 @@
1
+ import type { AlignmentState } from '../../pm-plugins/types';
2
+ import type { OptionInfo } from './types';
3
+ export declare const alignmentOptions: () => Record<AlignmentState, OptionInfo>;
@@ -0,0 +1,11 @@
1
+ import type { MessageDescriptor } from 'react-intl-next';
2
+ import type { Keymap } from '@atlaskit/editor-common/keymaps';
3
+ import type { IconComponent } from '@atlaskit/editor-toolbar';
4
+ export type OptionInfo = {
5
+ key: string;
6
+ type: 'menu-item';
7
+ label: MessageDescriptor;
8
+ icon: IconComponent;
9
+ keymap: Keymap;
10
+ rank: number;
11
+ };
@@ -0,0 +1,4 @@
1
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
3
+ import { type AlignmentPlugin } from '../alignmentPluginType';
4
+ export declare const getToolbarComponents: (api: ExtractInjectionAPI<AlignmentPlugin> | undefined) => RegisterComponent[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-alignment",
3
- "version": "4.1.3",
3
+ "version": "4.1.4",
4
4
  "description": "Alignment plugin for @atlaskit/editor-core",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -34,18 +34,20 @@
34
34
  "@atlaskit/css": "^0.12.0",
35
35
  "@atlaskit/editor-plugin-analytics": "^3.0.0",
36
36
  "@atlaskit/editor-plugin-primary-toolbar": "^4.1.0",
37
- "@atlaskit/editor-plugin-selection-toolbar": "^4.2.0",
37
+ "@atlaskit/editor-plugin-selection-toolbar": "^4.3.0",
38
+ "@atlaskit/editor-plugin-toolbar": "^0.2.0",
38
39
  "@atlaskit/editor-prosemirror": "7.0.0",
39
40
  "@atlaskit/editor-tables": "^2.9.0",
40
- "@atlaskit/icon": "^27.9.0",
41
+ "@atlaskit/editor-toolbar": "^0.2.0",
42
+ "@atlaskit/icon": "^27.11.0",
41
43
  "@atlaskit/platform-feature-flags": "^1.1.0",
42
- "@atlaskit/tmp-editor-statsig": "^9.22.0",
44
+ "@atlaskit/tmp-editor-statsig": "^9.27.0",
43
45
  "@atlaskit/tokens": "^6.0.0",
44
46
  "@babel/runtime": "^7.0.0",
45
47
  "@compiled/react": "^0.18.3"
46
48
  },
47
49
  "peerDependencies": {
48
- "@atlaskit/editor-common": "^107.16.0",
50
+ "@atlaskit/editor-common": "^107.21.0",
49
51
  "react": "^18.2.0",
50
52
  "react-dom": "^18.2.0",
51
53
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -58,7 +60,6 @@
58
60
  "@atlaskit/visual-regression": "workspace:^",
59
61
  "@testing-library/react": "^13.4.0",
60
62
  "@testing-library/user-event": "^14.4.3",
61
- "typescript": "~5.4.2",
62
63
  "wait-for-expect": "^1.2.0"
63
64
  },
64
65
  "techstack": {