@atlaskit/editor-plugin-alignment 1.3.1 → 1.4.0

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,20 @@
1
1
  # @atlaskit/editor-plugin-alignment
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#101406](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101406)
8
+ [`6daffd65aec4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6daffd65aec4) -
9
+ [ED-23298] Extract primary toolbar components to editor plugin to allow for custom ordering
10
+
11
+ ### Patch Changes
12
+
13
+ - [#102478](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102478)
14
+ [`3378951608b0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3378951608b0) -
15
+ [ED-23332] Update adf-schema package to 36.10.1
16
+ - Updated dependencies
17
+
3
18
  ## 1.3.1
4
19
 
5
20
  ### Patch Changes
@@ -15,6 +15,23 @@ var defaultConfig = exports.defaultConfig = {
15
15
  };
16
16
  var alignmentPlugin = exports.alignmentPlugin = function alignmentPlugin(_ref) {
17
17
  var api = _ref.api;
18
+ var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
19
+ var editorView = _ref2.editorView,
20
+ popupsMountPoint = _ref2.popupsMountPoint,
21
+ popupsBoundariesElement = _ref2.popupsBoundariesElement,
22
+ popupsScrollableElement = _ref2.popupsScrollableElement,
23
+ disabled = _ref2.disabled,
24
+ isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing;
25
+ return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponent, {
26
+ api: api,
27
+ editorView: editorView,
28
+ disabled: disabled,
29
+ popupsMountPoint: popupsMountPoint,
30
+ popupsBoundariesElement: popupsBoundariesElement,
31
+ popupsScrollableElement: popupsScrollableElement,
32
+ isToolbarReducedSpacing: isToolbarReducedSpacing
33
+ });
34
+ };
18
35
  return {
19
36
  name: 'alignment',
20
37
  marks: function marks() {
@@ -36,8 +53,8 @@ var alignmentPlugin = exports.alignmentPlugin = function alignmentPlugin(_ref) {
36
53
  pmPlugins: function pmPlugins() {
37
54
  return [{
38
55
  name: 'alignmentPlugin',
39
- plugin: function plugin(_ref2) {
40
- var dispatch = _ref2.dispatch;
56
+ plugin: function plugin(_ref3) {
57
+ var dispatch = _ref3.dispatch;
41
58
  return (0, _main.createPlugin)(dispatch, defaultConfig);
42
59
  }
43
60
  }, {
@@ -47,22 +64,13 @@ var alignmentPlugin = exports.alignmentPlugin = function alignmentPlugin(_ref) {
47
64
  }
48
65
  }];
49
66
  },
50
- primaryToolbarComponent: function primaryToolbarComponent(_ref3) {
51
- var editorView = _ref3.editorView,
52
- popupsMountPoint = _ref3.popupsMountPoint,
53
- popupsBoundariesElement = _ref3.popupsBoundariesElement,
54
- popupsScrollableElement = _ref3.popupsScrollableElement,
55
- disabled = _ref3.disabled,
56
- isToolbarReducedSpacing = _ref3.isToolbarReducedSpacing;
57
- return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponent, {
58
- api: api,
59
- editorView: editorView,
60
- disabled: disabled,
61
- popupsMountPoint: popupsMountPoint,
62
- popupsBoundariesElement: popupsBoundariesElement,
63
- popupsScrollableElement: popupsScrollableElement,
64
- isToolbarReducedSpacing: isToolbarReducedSpacing
65
- });
66
- }
67
+ usePluginHook: function usePluginHook() {
68
+ var _api$core, _api$primaryToolbar;
69
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.commands.registerComponent({
70
+ name: 'alignment',
71
+ component: primaryToolbarComponent
72
+ }));
73
+ },
74
+ primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
67
75
  };
68
76
  };
@@ -32,6 +32,7 @@ function PrimaryToolbarComponent(_ref) {
32
32
  disabled: disabled || !alignmentState.isEnabled,
33
33
  popupsMountPoint: popupsMountPoint,
34
34
  popupsBoundariesElement: popupsBoundariesElement,
35
- popupsScrollableElement: popupsScrollableElement
35
+ popupsScrollableElement: popupsScrollableElement,
36
+ api: api
36
37
  });
37
38
  }
@@ -89,7 +89,8 @@ var AlignmentToolbar = exports.AlignmentToolbar = /*#__PURE__*/function (_React$
89
89
  isReducedSpacing = _this$props.isReducedSpacing,
90
90
  pluginState = _this$props.pluginState,
91
91
  disabled = _this$props.disabled,
92
- intl = _this$props.intl;
92
+ intl = _this$props.intl,
93
+ api = _this$props.api;
93
94
  var alignment = (_pluginState$align = pluginState === null || pluginState === void 0 ? void 0 : pluginState.align) !== null && _pluginState$align !== void 0 ? _pluginState$align : 'start';
94
95
  var title = intl.formatMessage(_messages.alignmentMessages.alignment);
95
96
  return (
@@ -145,7 +146,8 @@ var AlignmentToolbar = exports.AlignmentToolbar = /*#__PURE__*/function (_React$
145
146
  return _this2.changeAlignment(align, false);
146
147
  },
147
148
  selectedAlignment: alignment
148
- })), (0, _react2.jsx)("span", {
149
+ })), !(api !== null && api !== void 0 && api.primaryToolbar) && /* eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage */
150
+ (0, _react2.jsx)("span", {
149
151
  css: _styles.separatorStyles
150
152
  }))
151
153
  );
@@ -8,43 +8,15 @@ export const defaultConfig = {
8
8
  };
9
9
  export const alignmentPlugin = ({
10
10
  api
11
- }) => ({
12
- name: 'alignment',
13
- marks() {
14
- return [{
15
- name: 'alignment',
16
- mark: alignment
17
- }];
18
- },
19
- getSharedState(editorState) {
20
- if (!editorState) {
21
- return undefined;
22
- }
23
- const pluginState = pluginKey.getState(editorState);
24
- return pluginState ? {
25
- align: pluginState.align,
26
- isEnabled: pluginState.isEnabled
27
- } : undefined;
28
- },
29
- pmPlugins() {
30
- return [{
31
- name: 'alignmentPlugin',
32
- plugin: ({
33
- dispatch
34
- }) => createPlugin(dispatch, defaultConfig)
35
- }, {
36
- name: 'annotationKeymap',
37
- plugin: () => keymapPlugin()
38
- }];
39
- },
40
- primaryToolbarComponent({
11
+ }) => {
12
+ const primaryToolbarComponent = ({
41
13
  editorView,
42
14
  popupsMountPoint,
43
15
  popupsBoundariesElement,
44
16
  popupsScrollableElement,
45
17
  disabled,
46
18
  isToolbarReducedSpacing
47
- }) {
19
+ }) => {
48
20
  return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
49
21
  api: api,
50
22
  editorView: editorView,
@@ -54,5 +26,43 @@ export const alignmentPlugin = ({
54
26
  popupsScrollableElement: popupsScrollableElement,
55
27
  isToolbarReducedSpacing: isToolbarReducedSpacing
56
28
  });
57
- }
58
- });
29
+ };
30
+ return {
31
+ name: 'alignment',
32
+ marks() {
33
+ return [{
34
+ name: 'alignment',
35
+ mark: alignment
36
+ }];
37
+ },
38
+ getSharedState(editorState) {
39
+ if (!editorState) {
40
+ return undefined;
41
+ }
42
+ const pluginState = pluginKey.getState(editorState);
43
+ return pluginState ? {
44
+ align: pluginState.align,
45
+ isEnabled: pluginState.isEnabled
46
+ } : undefined;
47
+ },
48
+ pmPlugins() {
49
+ return [{
50
+ name: 'alignmentPlugin',
51
+ plugin: ({
52
+ dispatch
53
+ }) => createPlugin(dispatch, defaultConfig)
54
+ }, {
55
+ name: 'annotationKeymap',
56
+ plugin: () => keymapPlugin()
57
+ }];
58
+ },
59
+ usePluginHook: () => {
60
+ var _api$core, _api$primaryToolbar;
61
+ api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.commands.registerComponent({
62
+ name: 'alignment',
63
+ component: primaryToolbarComponent
64
+ }));
65
+ },
66
+ primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
67
+ };
68
+ };
@@ -22,6 +22,7 @@ export function PrimaryToolbarComponent({
22
22
  disabled: disabled || !alignmentState.isEnabled,
23
23
  popupsMountPoint: popupsMountPoint,
24
24
  popupsBoundariesElement: popupsBoundariesElement,
25
- popupsScrollableElement: popupsScrollableElement
25
+ popupsScrollableElement: popupsScrollableElement,
26
+ api: api
26
27
  });
27
28
  }
@@ -66,7 +66,8 @@ export class AlignmentToolbar extends React.Component {
66
66
  isReducedSpacing,
67
67
  pluginState,
68
68
  disabled,
69
- intl
69
+ intl,
70
+ api
70
71
  } = this.props;
71
72
  const alignment = (_pluginState$align = pluginState === null || pluginState === void 0 ? void 0 : pluginState.align) !== null && _pluginState$align !== void 0 ? _pluginState$align : 'start';
72
73
  const title = intl.formatMessage(messages.alignment);
@@ -121,7 +122,8 @@ export class AlignmentToolbar extends React.Component {
121
122
  }, jsx(Alignment, {
122
123
  onClick: align => this.changeAlignment(align, false),
123
124
  selectedAlignment: alignment
124
- })), jsx("span", {
125
+ })), !(api !== null && api !== void 0 && api.primaryToolbar) && /* eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage */
126
+ jsx("span", {
125
127
  css: separatorStyles
126
128
  }))
127
129
  );
@@ -8,6 +8,23 @@ export var defaultConfig = {
8
8
  };
9
9
  export var alignmentPlugin = function alignmentPlugin(_ref) {
10
10
  var api = _ref.api;
11
+ var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
12
+ var editorView = _ref2.editorView,
13
+ popupsMountPoint = _ref2.popupsMountPoint,
14
+ popupsBoundariesElement = _ref2.popupsBoundariesElement,
15
+ popupsScrollableElement = _ref2.popupsScrollableElement,
16
+ disabled = _ref2.disabled,
17
+ isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing;
18
+ return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
19
+ api: api,
20
+ editorView: editorView,
21
+ disabled: disabled,
22
+ popupsMountPoint: popupsMountPoint,
23
+ popupsBoundariesElement: popupsBoundariesElement,
24
+ popupsScrollableElement: popupsScrollableElement,
25
+ isToolbarReducedSpacing: isToolbarReducedSpacing
26
+ });
27
+ };
11
28
  return {
12
29
  name: 'alignment',
13
30
  marks: function marks() {
@@ -29,8 +46,8 @@ export var alignmentPlugin = function alignmentPlugin(_ref) {
29
46
  pmPlugins: function pmPlugins() {
30
47
  return [{
31
48
  name: 'alignmentPlugin',
32
- plugin: function plugin(_ref2) {
33
- var dispatch = _ref2.dispatch;
49
+ plugin: function plugin(_ref3) {
50
+ var dispatch = _ref3.dispatch;
34
51
  return createPlugin(dispatch, defaultConfig);
35
52
  }
36
53
  }, {
@@ -40,22 +57,13 @@ export var alignmentPlugin = function alignmentPlugin(_ref) {
40
57
  }
41
58
  }];
42
59
  },
43
- primaryToolbarComponent: function primaryToolbarComponent(_ref3) {
44
- var editorView = _ref3.editorView,
45
- popupsMountPoint = _ref3.popupsMountPoint,
46
- popupsBoundariesElement = _ref3.popupsBoundariesElement,
47
- popupsScrollableElement = _ref3.popupsScrollableElement,
48
- disabled = _ref3.disabled,
49
- isToolbarReducedSpacing = _ref3.isToolbarReducedSpacing;
50
- return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
51
- api: api,
52
- editorView: editorView,
53
- disabled: disabled,
54
- popupsMountPoint: popupsMountPoint,
55
- popupsBoundariesElement: popupsBoundariesElement,
56
- popupsScrollableElement: popupsScrollableElement,
57
- isToolbarReducedSpacing: isToolbarReducedSpacing
58
- });
59
- }
60
+ usePluginHook: function usePluginHook() {
61
+ var _api$core, _api$primaryToolbar;
62
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.commands.registerComponent({
63
+ name: 'alignment',
64
+ component: primaryToolbarComponent
65
+ }));
66
+ },
67
+ primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
60
68
  };
61
69
  };
@@ -22,6 +22,7 @@ export function PrimaryToolbarComponent(_ref) {
22
22
  disabled: disabled || !alignmentState.isEnabled,
23
23
  popupsMountPoint: popupsMountPoint,
24
24
  popupsBoundariesElement: popupsBoundariesElement,
25
- popupsScrollableElement: popupsScrollableElement
25
+ popupsScrollableElement: popupsScrollableElement,
26
+ api: api
26
27
  });
27
28
  }
@@ -83,7 +83,8 @@ export var AlignmentToolbar = /*#__PURE__*/function (_React$Component) {
83
83
  isReducedSpacing = _this$props.isReducedSpacing,
84
84
  pluginState = _this$props.pluginState,
85
85
  disabled = _this$props.disabled,
86
- intl = _this$props.intl;
86
+ intl = _this$props.intl,
87
+ api = _this$props.api;
87
88
  var alignment = (_pluginState$align = pluginState === null || pluginState === void 0 ? void 0 : pluginState.align) !== null && _pluginState$align !== void 0 ? _pluginState$align : 'start';
88
89
  var title = intl.formatMessage(messages.alignment);
89
90
  return (
@@ -139,7 +140,8 @@ export var AlignmentToolbar = /*#__PURE__*/function (_React$Component) {
139
140
  return _this2.changeAlignment(align, false);
140
141
  },
141
142
  selectedAlignment: alignment
142
- })), jsx("span", {
143
+ })), !(api !== null && api !== void 0 && api.primaryToolbar) && /* eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage */
144
+ jsx("span", {
143
145
  css: separatorStyles
144
146
  }))
145
147
  );
@@ -1,7 +1,9 @@
1
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
1
+ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
2
3
  import type { AlignmentPluginState } from './pm-plugins/types';
3
4
  export declare const defaultConfig: AlignmentPluginState;
4
5
  export type AlignmentPlugin = NextEditorPlugin<'alignment', {
5
6
  sharedState: AlignmentPluginState | undefined;
7
+ dependencies: [OptionalPlugin<PrimaryToolbarPlugin>];
6
8
  }>;
7
9
  export declare const alignmentPlugin: AlignmentPlugin;
@@ -2,6 +2,8 @@
2
2
  import React from 'react';
3
3
  import { jsx } from '@emotion/react';
4
4
  import type { WrappedComponentProps } from 'react-intl-next';
5
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
+ import type { AlignmentPlugin } from '../../plugin';
5
7
  import type { AlignmentPluginState, AlignmentState } from '../../pm-plugins/types';
6
8
  export interface State {
7
9
  isOpen: boolean;
@@ -14,6 +16,7 @@ export interface Props {
14
16
  popupsScrollableElement?: HTMLElement;
15
17
  isReducedSpacing?: boolean;
16
18
  disabled?: boolean;
19
+ api: ExtractInjectionAPI<AlignmentPlugin> | undefined;
17
20
  }
18
21
  export declare class AlignmentToolbar extends React.Component<Props & WrappedComponentProps, State> {
19
22
  static displayName: string;
@@ -1,7 +1,11 @@
1
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
1
+ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
2
3
  import type { AlignmentPluginState } from './pm-plugins/types';
3
4
  export declare const defaultConfig: AlignmentPluginState;
4
5
  export type AlignmentPlugin = NextEditorPlugin<'alignment', {
5
6
  sharedState: AlignmentPluginState | undefined;
7
+ dependencies: [
8
+ OptionalPlugin<PrimaryToolbarPlugin>
9
+ ];
6
10
  }>;
7
11
  export declare const alignmentPlugin: AlignmentPlugin;
@@ -2,6 +2,8 @@
2
2
  import React from 'react';
3
3
  import { jsx } from '@emotion/react';
4
4
  import type { WrappedComponentProps } from 'react-intl-next';
5
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
+ import type { AlignmentPlugin } from '../../plugin';
5
7
  import type { AlignmentPluginState, AlignmentState } from '../../pm-plugins/types';
6
8
  export interface State {
7
9
  isOpen: boolean;
@@ -14,6 +16,7 @@ export interface Props {
14
16
  popupsScrollableElement?: HTMLElement;
15
17
  isReducedSpacing?: boolean;
16
18
  disabled?: boolean;
19
+ api: ExtractInjectionAPI<AlignmentPlugin> | undefined;
17
20
  }
18
21
  export declare class AlignmentToolbar extends React.Component<Props & WrappedComponentProps, State> {
19
22
  static displayName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-alignment",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "Alignment plugin for @atlaskit/editor-core",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -21,13 +21,14 @@
21
21
  "runReact18": false
22
22
  },
23
23
  "dependencies": {
24
- "@atlaskit/adf-schema": "^36.8.0",
25
- "@atlaskit/editor-common": "^80.4.0",
24
+ "@atlaskit/adf-schema": "^36.10.7",
25
+ "@atlaskit/editor-common": "^81.0.0",
26
+ "@atlaskit/editor-plugin-primary-toolbar": "^1.1.0",
26
27
  "@atlaskit/editor-prosemirror": "4.0.1",
27
28
  "@atlaskit/editor-tables": "^2.7.0",
28
- "@atlaskit/icon": "^22.2.0",
29
+ "@atlaskit/icon": "^22.3.0",
29
30
  "@atlaskit/platform-feature-flags": "^0.2.0",
30
- "@atlaskit/tokens": "^1.48.0",
31
+ "@atlaskit/tokens": "^1.49.0",
31
32
  "@babel/runtime": "^7.0.0",
32
33
  "@emotion/react": "^11.7.1"
33
34
  },