@atlaskit/editor-plugin-alignment 0.1.2 → 0.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.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/plugin.js +30 -31
- package/dist/cjs/ui/PrimaryToolbarComponent.js +37 -0
- package/dist/cjs/ui/ToolbarAlignment/index.js +5 -3
- package/dist/es2019/plugin.js +22 -21
- package/dist/es2019/ui/PrimaryToolbarComponent.js +27 -0
- package/dist/es2019/ui/ToolbarAlignment/index.js +4 -2
- package/dist/esm/plugin.js +30 -31
- package/dist/esm/ui/PrimaryToolbarComponent.js +27 -0
- package/dist/esm/ui/ToolbarAlignment/index.js +5 -3
- package/dist/types/plugin.d.ts +3 -1
- package/dist/types/ui/PrimaryToolbarComponent.d.ts +15 -0
- package/dist/types/ui/ToolbarAlignment/index.d.ts +1 -1
- package/dist/types-ts4.5/plugin.d.ts +3 -1
- package/dist/types-ts4.5/ui/PrimaryToolbarComponent.d.ts +15 -0
- package/dist/types-ts4.5/ui/ToolbarAlignment/index.d.ts +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-alignment
|
|
2
2
|
|
|
3
|
+
## 0.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#67814](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67814) [`b9ae9606c2e0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b9ae9606c2e0) - Migrate status and alignment plugins to use useSharedPluginState rather than WithPluginState
|
|
8
|
+
|
|
9
|
+
## 0.1.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#67238](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67238) [`40533849b2ec`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/40533849b2ec) - [ED-21835] Change EditorAPI type to always union with undefined
|
|
14
|
+
|
|
3
15
|
## 0.1.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -7,15 +7,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.defaultConfig = exports.alignmentPlugin = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
|
-
var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
|
|
11
|
-
var _commands = require("./commands");
|
|
12
10
|
var _keymap = require("./pm-plugins/keymap");
|
|
13
11
|
var _main = require("./pm-plugins/main");
|
|
14
|
-
var
|
|
12
|
+
var _PrimaryToolbarComponent = require("./ui/PrimaryToolbarComponent");
|
|
15
13
|
var defaultConfig = exports.defaultConfig = {
|
|
16
14
|
align: 'start'
|
|
17
15
|
};
|
|
18
|
-
var alignmentPlugin = exports.alignmentPlugin = function alignmentPlugin() {
|
|
16
|
+
var alignmentPlugin = exports.alignmentPlugin = function alignmentPlugin(_ref) {
|
|
17
|
+
var api = _ref.api;
|
|
19
18
|
return {
|
|
20
19
|
name: 'alignment',
|
|
21
20
|
marks: function marks() {
|
|
@@ -24,11 +23,21 @@ var alignmentPlugin = exports.alignmentPlugin = function alignmentPlugin() {
|
|
|
24
23
|
mark: _adfSchema.alignment
|
|
25
24
|
}];
|
|
26
25
|
},
|
|
26
|
+
getSharedState: function getSharedState(editorState) {
|
|
27
|
+
if (!editorState) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
var pluginState = _main.pluginKey.getState(editorState);
|
|
31
|
+
return pluginState ? {
|
|
32
|
+
align: pluginState.align,
|
|
33
|
+
isEnabled: pluginState.isEnabled
|
|
34
|
+
} : undefined;
|
|
35
|
+
},
|
|
27
36
|
pmPlugins: function pmPlugins() {
|
|
28
37
|
return [{
|
|
29
38
|
name: 'alignmentPlugin',
|
|
30
|
-
plugin: function plugin(
|
|
31
|
-
var dispatch =
|
|
39
|
+
plugin: function plugin(_ref2) {
|
|
40
|
+
var dispatch = _ref2.dispatch;
|
|
32
41
|
return (0, _main.createPlugin)(dispatch, defaultConfig);
|
|
33
42
|
}
|
|
34
43
|
}, {
|
|
@@ -38,31 +47,21 @@ var alignmentPlugin = exports.alignmentPlugin = function alignmentPlugin() {
|
|
|
38
47
|
}
|
|
39
48
|
}];
|
|
40
49
|
},
|
|
41
|
-
primaryToolbarComponent: function primaryToolbarComponent(
|
|
42
|
-
var editorView =
|
|
43
|
-
popupsMountPoint =
|
|
44
|
-
popupsBoundariesElement =
|
|
45
|
-
popupsScrollableElement =
|
|
46
|
-
disabled =
|
|
47
|
-
isToolbarReducedSpacing =
|
|
48
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
57
|
-
changeAlignment: function changeAlignment(align) {
|
|
58
|
-
return (0, _commands.changeAlignment)(align)(editorView.state, editorView.dispatch);
|
|
59
|
-
},
|
|
60
|
-
disabled: disabled || !align.isEnabled,
|
|
61
|
-
popupsMountPoint: popupsMountPoint,
|
|
62
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
63
|
-
popupsScrollableElement: popupsScrollableElement
|
|
64
|
-
});
|
|
65
|
-
}
|
|
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
|
|
66
65
|
});
|
|
67
66
|
}
|
|
68
67
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.PrimaryToolbarComponent = PrimaryToolbarComponent;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
|
+
var _commands = require("../commands");
|
|
12
|
+
var _ToolbarAlignment = _interopRequireDefault(require("./ToolbarAlignment"));
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
function PrimaryToolbarComponent(_ref) {
|
|
16
|
+
var api = _ref.api,
|
|
17
|
+
editorView = _ref.editorView,
|
|
18
|
+
disabled = _ref.disabled,
|
|
19
|
+
popupsMountPoint = _ref.popupsMountPoint,
|
|
20
|
+
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
21
|
+
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
22
|
+
isToolbarReducedSpacing = _ref.isToolbarReducedSpacing;
|
|
23
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['alignment']),
|
|
24
|
+
alignmentState = _useSharedPluginState.alignmentState;
|
|
25
|
+
var changeAlignmentCallback = (0, _react.useCallback)(function (align) {
|
|
26
|
+
return (0, _commands.changeAlignment)(align)(editorView.state, editorView.dispatch);
|
|
27
|
+
}, [editorView]);
|
|
28
|
+
return /*#__PURE__*/_react.default.createElement(_ToolbarAlignment.default, {
|
|
29
|
+
pluginState: alignmentState,
|
|
30
|
+
isReducedSpacing: isToolbarReducedSpacing,
|
|
31
|
+
changeAlignment: changeAlignmentCallback,
|
|
32
|
+
disabled: disabled || !alignmentState.isEnabled,
|
|
33
|
+
popupsMountPoint: popupsMountPoint,
|
|
34
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
35
|
+
popupsScrollableElement: popupsScrollableElement
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -79,7 +79,8 @@ var AlignmentToolbar = exports.AlignmentToolbar = /*#__PURE__*/function (_React$
|
|
|
79
79
|
(0, _createClass2.default)(AlignmentToolbar, [{
|
|
80
80
|
key: "render",
|
|
81
81
|
value: function render() {
|
|
82
|
-
var
|
|
82
|
+
var _pluginState$align,
|
|
83
|
+
_this2 = this;
|
|
83
84
|
var isOpen = this.state.isOpen;
|
|
84
85
|
var _this$props = this.props,
|
|
85
86
|
popupsMountPoint = _this$props.popupsMountPoint,
|
|
@@ -89,6 +90,7 @@ var AlignmentToolbar = exports.AlignmentToolbar = /*#__PURE__*/function (_React$
|
|
|
89
90
|
pluginState = _this$props.pluginState,
|
|
90
91
|
disabled = _this$props.disabled,
|
|
91
92
|
intl = _this$props.intl;
|
|
93
|
+
var alignment = (_pluginState$align = pluginState === null || pluginState === void 0 ? void 0 : pluginState.align) !== null && _pluginState$align !== void 0 ? _pluginState$align : 'start';
|
|
92
94
|
var title = intl.formatMessage(_messages.messages.alignment);
|
|
93
95
|
return (
|
|
94
96
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
@@ -130,7 +132,7 @@ var AlignmentToolbar = exports.AlignmentToolbar = /*#__PURE__*/function (_React$
|
|
|
130
132
|
(0, _react2.jsx)("div", {
|
|
131
133
|
css: _styles2.triggerWrapper
|
|
132
134
|
}, (0, _react2.jsx)(_iconMap.IconMap, {
|
|
133
|
-
alignment:
|
|
135
|
+
alignment: alignment
|
|
134
136
|
}), (0, _react2.jsx)("span", {
|
|
135
137
|
css: _styles2.expandIconWrapper
|
|
136
138
|
}, (0, _react2.jsx)(_chevronDown.default, {
|
|
@@ -142,7 +144,7 @@ var AlignmentToolbar = exports.AlignmentToolbar = /*#__PURE__*/function (_React$
|
|
|
142
144
|
onClick: function onClick(align) {
|
|
143
145
|
return _this2.changeAlignment(align, false);
|
|
144
146
|
},
|
|
145
|
-
selectedAlignment:
|
|
147
|
+
selectedAlignment: alignment
|
|
146
148
|
})), (0, _react2.jsx)("span", {
|
|
147
149
|
css: _styles.separatorStyles
|
|
148
150
|
}))
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { alignment } from '@atlaskit/adf-schema';
|
|
3
|
-
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
4
|
-
import { changeAlignment } from './commands';
|
|
5
3
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
6
4
|
import { createPlugin, pluginKey } from './pm-plugins/main';
|
|
7
|
-
import
|
|
5
|
+
import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
|
|
8
6
|
export const defaultConfig = {
|
|
9
7
|
align: 'start'
|
|
10
8
|
};
|
|
11
|
-
export const alignmentPlugin = (
|
|
9
|
+
export const alignmentPlugin = ({
|
|
10
|
+
api
|
|
11
|
+
}) => ({
|
|
12
12
|
name: 'alignment',
|
|
13
13
|
marks() {
|
|
14
14
|
return [{
|
|
@@ -16,6 +16,16 @@ export const alignmentPlugin = () => ({
|
|
|
16
16
|
mark: alignment
|
|
17
17
|
}];
|
|
18
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
|
+
},
|
|
19
29
|
pmPlugins() {
|
|
20
30
|
return [{
|
|
21
31
|
name: 'alignmentPlugin',
|
|
@@ -35,23 +45,14 @@ export const alignmentPlugin = () => ({
|
|
|
35
45
|
disabled,
|
|
36
46
|
isToolbarReducedSpacing
|
|
37
47
|
}) {
|
|
38
|
-
return /*#__PURE__*/React.createElement(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
pluginState: align,
|
|
47
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
48
|
-
changeAlignment: align => changeAlignment(align)(editorView.state, editorView.dispatch),
|
|
49
|
-
disabled: disabled || !align.isEnabled,
|
|
50
|
-
popupsMountPoint: popupsMountPoint,
|
|
51
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
52
|
-
popupsScrollableElement: popupsScrollableElement
|
|
53
|
-
});
|
|
54
|
-
}
|
|
48
|
+
return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
|
|
49
|
+
api: api,
|
|
50
|
+
editorView: editorView,
|
|
51
|
+
disabled: disabled,
|
|
52
|
+
popupsMountPoint: popupsMountPoint,
|
|
53
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
54
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
55
|
+
isToolbarReducedSpacing: isToolbarReducedSpacing
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
58
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { changeAlignment } from '../commands';
|
|
4
|
+
import ToolbarAlignment from './ToolbarAlignment';
|
|
5
|
+
export function PrimaryToolbarComponent({
|
|
6
|
+
api,
|
|
7
|
+
editorView,
|
|
8
|
+
disabled,
|
|
9
|
+
popupsMountPoint,
|
|
10
|
+
popupsBoundariesElement,
|
|
11
|
+
popupsScrollableElement,
|
|
12
|
+
isToolbarReducedSpacing
|
|
13
|
+
}) {
|
|
14
|
+
const {
|
|
15
|
+
alignmentState
|
|
16
|
+
} = useSharedPluginState(api, ['alignment']);
|
|
17
|
+
const changeAlignmentCallback = useCallback(align => changeAlignment(align)(editorView.state, editorView.dispatch), [editorView]);
|
|
18
|
+
return /*#__PURE__*/React.createElement(ToolbarAlignment, {
|
|
19
|
+
pluginState: alignmentState,
|
|
20
|
+
isReducedSpacing: isToolbarReducedSpacing,
|
|
21
|
+
changeAlignment: changeAlignmentCallback,
|
|
22
|
+
disabled: disabled || !alignmentState.isEnabled,
|
|
23
|
+
popupsMountPoint: popupsMountPoint,
|
|
24
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
25
|
+
popupsScrollableElement: popupsScrollableElement
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -55,6 +55,7 @@ export class AlignmentToolbar extends React.Component {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
render() {
|
|
58
|
+
var _pluginState$align;
|
|
58
59
|
const {
|
|
59
60
|
isOpen
|
|
60
61
|
} = this.state;
|
|
@@ -67,6 +68,7 @@ export class AlignmentToolbar extends React.Component {
|
|
|
67
68
|
disabled,
|
|
68
69
|
intl
|
|
69
70
|
} = this.props;
|
|
71
|
+
const alignment = (_pluginState$align = pluginState === null || pluginState === void 0 ? void 0 : pluginState.align) !== null && _pluginState$align !== void 0 ? _pluginState$align : 'start';
|
|
70
72
|
const title = intl.formatMessage(messages.alignment);
|
|
71
73
|
return (
|
|
72
74
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
@@ -108,7 +110,7 @@ export class AlignmentToolbar extends React.Component {
|
|
|
108
110
|
jsx("div", {
|
|
109
111
|
css: triggerWrapper
|
|
110
112
|
}, jsx(IconMap, {
|
|
111
|
-
alignment:
|
|
113
|
+
alignment: alignment
|
|
112
114
|
}), jsx("span", {
|
|
113
115
|
css: expandIconWrapper
|
|
114
116
|
}, jsx(ExpandIcon, {
|
|
@@ -118,7 +120,7 @@ export class AlignmentToolbar extends React.Component {
|
|
|
118
120
|
})
|
|
119
121
|
}, jsx(Alignment, {
|
|
120
122
|
onClick: align => this.changeAlignment(align, false),
|
|
121
|
-
selectedAlignment:
|
|
123
|
+
selectedAlignment: alignment
|
|
122
124
|
})), jsx("span", {
|
|
123
125
|
css: separatorStyles
|
|
124
126
|
}))
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { alignment } from '@atlaskit/adf-schema';
|
|
3
|
-
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
4
|
-
import { changeAlignment as _changeAlignment } from './commands';
|
|
5
3
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
6
4
|
import { createPlugin, pluginKey } from './pm-plugins/main';
|
|
7
|
-
import
|
|
5
|
+
import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
|
|
8
6
|
export var defaultConfig = {
|
|
9
7
|
align: 'start'
|
|
10
8
|
};
|
|
11
|
-
export var alignmentPlugin = function alignmentPlugin() {
|
|
9
|
+
export var alignmentPlugin = function alignmentPlugin(_ref) {
|
|
10
|
+
var api = _ref.api;
|
|
12
11
|
return {
|
|
13
12
|
name: 'alignment',
|
|
14
13
|
marks: function marks() {
|
|
@@ -17,11 +16,21 @@ export var alignmentPlugin = function alignmentPlugin() {
|
|
|
17
16
|
mark: alignment
|
|
18
17
|
}];
|
|
19
18
|
},
|
|
19
|
+
getSharedState: function getSharedState(editorState) {
|
|
20
|
+
if (!editorState) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
var pluginState = pluginKey.getState(editorState);
|
|
24
|
+
return pluginState ? {
|
|
25
|
+
align: pluginState.align,
|
|
26
|
+
isEnabled: pluginState.isEnabled
|
|
27
|
+
} : undefined;
|
|
28
|
+
},
|
|
20
29
|
pmPlugins: function pmPlugins() {
|
|
21
30
|
return [{
|
|
22
31
|
name: 'alignmentPlugin',
|
|
23
|
-
plugin: function plugin(
|
|
24
|
-
var dispatch =
|
|
32
|
+
plugin: function plugin(_ref2) {
|
|
33
|
+
var dispatch = _ref2.dispatch;
|
|
25
34
|
return createPlugin(dispatch, defaultConfig);
|
|
26
35
|
}
|
|
27
36
|
}, {
|
|
@@ -31,31 +40,21 @@ export var alignmentPlugin = function alignmentPlugin() {
|
|
|
31
40
|
}
|
|
32
41
|
}];
|
|
33
42
|
},
|
|
34
|
-
primaryToolbarComponent: function primaryToolbarComponent(
|
|
35
|
-
var editorView =
|
|
36
|
-
popupsMountPoint =
|
|
37
|
-
popupsBoundariesElement =
|
|
38
|
-
popupsScrollableElement =
|
|
39
|
-
disabled =
|
|
40
|
-
isToolbarReducedSpacing =
|
|
41
|
-
return /*#__PURE__*/React.createElement(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
50
|
-
changeAlignment: function changeAlignment(align) {
|
|
51
|
-
return _changeAlignment(align)(editorView.state, editorView.dispatch);
|
|
52
|
-
},
|
|
53
|
-
disabled: disabled || !align.isEnabled,
|
|
54
|
-
popupsMountPoint: popupsMountPoint,
|
|
55
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
56
|
-
popupsScrollableElement: popupsScrollableElement
|
|
57
|
-
});
|
|
58
|
-
}
|
|
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
|
|
59
58
|
});
|
|
60
59
|
}
|
|
61
60
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { changeAlignment } from '../commands';
|
|
4
|
+
import ToolbarAlignment from './ToolbarAlignment';
|
|
5
|
+
export function PrimaryToolbarComponent(_ref) {
|
|
6
|
+
var api = _ref.api,
|
|
7
|
+
editorView = _ref.editorView,
|
|
8
|
+
disabled = _ref.disabled,
|
|
9
|
+
popupsMountPoint = _ref.popupsMountPoint,
|
|
10
|
+
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
11
|
+
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
12
|
+
isToolbarReducedSpacing = _ref.isToolbarReducedSpacing;
|
|
13
|
+
var _useSharedPluginState = useSharedPluginState(api, ['alignment']),
|
|
14
|
+
alignmentState = _useSharedPluginState.alignmentState;
|
|
15
|
+
var changeAlignmentCallback = useCallback(function (align) {
|
|
16
|
+
return changeAlignment(align)(editorView.state, editorView.dispatch);
|
|
17
|
+
}, [editorView]);
|
|
18
|
+
return /*#__PURE__*/React.createElement(ToolbarAlignment, {
|
|
19
|
+
pluginState: alignmentState,
|
|
20
|
+
isReducedSpacing: isToolbarReducedSpacing,
|
|
21
|
+
changeAlignment: changeAlignmentCallback,
|
|
22
|
+
disabled: disabled || !alignmentState.isEnabled,
|
|
23
|
+
popupsMountPoint: popupsMountPoint,
|
|
24
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
25
|
+
popupsScrollableElement: popupsScrollableElement
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -73,7 +73,8 @@ export var AlignmentToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
73
73
|
_createClass(AlignmentToolbar, [{
|
|
74
74
|
key: "render",
|
|
75
75
|
value: function render() {
|
|
76
|
-
var
|
|
76
|
+
var _pluginState$align,
|
|
77
|
+
_this2 = this;
|
|
77
78
|
var isOpen = this.state.isOpen;
|
|
78
79
|
var _this$props = this.props,
|
|
79
80
|
popupsMountPoint = _this$props.popupsMountPoint,
|
|
@@ -83,6 +84,7 @@ export var AlignmentToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
83
84
|
pluginState = _this$props.pluginState,
|
|
84
85
|
disabled = _this$props.disabled,
|
|
85
86
|
intl = _this$props.intl;
|
|
87
|
+
var alignment = (_pluginState$align = pluginState === null || pluginState === void 0 ? void 0 : pluginState.align) !== null && _pluginState$align !== void 0 ? _pluginState$align : 'start';
|
|
86
88
|
var title = intl.formatMessage(messages.alignment);
|
|
87
89
|
return (
|
|
88
90
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
@@ -124,7 +126,7 @@ export var AlignmentToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
124
126
|
jsx("div", {
|
|
125
127
|
css: triggerWrapper
|
|
126
128
|
}, jsx(IconMap, {
|
|
127
|
-
alignment:
|
|
129
|
+
alignment: alignment
|
|
128
130
|
}), jsx("span", {
|
|
129
131
|
css: expandIconWrapper
|
|
130
132
|
}, jsx(ExpandIcon, {
|
|
@@ -136,7 +138,7 @@ export var AlignmentToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
136
138
|
onClick: function onClick(align) {
|
|
137
139
|
return _this2.changeAlignment(align, false);
|
|
138
140
|
},
|
|
139
|
-
selectedAlignment:
|
|
141
|
+
selectedAlignment: alignment
|
|
140
142
|
})), jsx("span", {
|
|
141
143
|
css: separatorStyles
|
|
142
144
|
}))
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AlignmentPluginState } from './pm-plugins/types';
|
|
3
3
|
export declare const defaultConfig: AlignmentPluginState;
|
|
4
|
-
export type AlignmentPlugin = NextEditorPlugin<'alignment'
|
|
4
|
+
export type AlignmentPlugin = NextEditorPlugin<'alignment', {
|
|
5
|
+
sharedState: AlignmentPluginState | undefined;
|
|
6
|
+
}>;
|
|
5
7
|
export declare const alignmentPlugin: AlignmentPlugin;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { AlignmentPlugin } from '../plugin';
|
|
5
|
+
interface PrimaryToolbarComponentProps {
|
|
6
|
+
api: ExtractInjectionAPI<AlignmentPlugin> | undefined;
|
|
7
|
+
editorView: EditorView;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
popupsMountPoint?: HTMLElement;
|
|
10
|
+
popupsBoundariesElement?: HTMLElement;
|
|
11
|
+
popupsScrollableElement?: HTMLElement;
|
|
12
|
+
isToolbarReducedSpacing: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function PrimaryToolbarComponent({ api, editorView, disabled, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, isToolbarReducedSpacing, }: PrimaryToolbarComponentProps): JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -7,7 +7,7 @@ export interface State {
|
|
|
7
7
|
isOpen: boolean;
|
|
8
8
|
}
|
|
9
9
|
export interface Props {
|
|
10
|
-
pluginState: AlignmentPluginState;
|
|
10
|
+
pluginState: AlignmentPluginState | undefined;
|
|
11
11
|
changeAlignment: (align: AlignmentState) => void;
|
|
12
12
|
popupsMountPoint?: HTMLElement;
|
|
13
13
|
popupsBoundariesElement?: HTMLElement;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AlignmentPluginState } from './pm-plugins/types';
|
|
3
3
|
export declare const defaultConfig: AlignmentPluginState;
|
|
4
|
-
export type AlignmentPlugin = NextEditorPlugin<'alignment'
|
|
4
|
+
export type AlignmentPlugin = NextEditorPlugin<'alignment', {
|
|
5
|
+
sharedState: AlignmentPluginState | undefined;
|
|
6
|
+
}>;
|
|
5
7
|
export declare const alignmentPlugin: AlignmentPlugin;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { AlignmentPlugin } from '../plugin';
|
|
5
|
+
interface PrimaryToolbarComponentProps {
|
|
6
|
+
api: ExtractInjectionAPI<AlignmentPlugin> | undefined;
|
|
7
|
+
editorView: EditorView;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
popupsMountPoint?: HTMLElement;
|
|
10
|
+
popupsBoundariesElement?: HTMLElement;
|
|
11
|
+
popupsScrollableElement?: HTMLElement;
|
|
12
|
+
isToolbarReducedSpacing: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function PrimaryToolbarComponent({ api, editorView, disabled, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, isToolbarReducedSpacing, }: PrimaryToolbarComponentProps): JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -7,7 +7,7 @@ export interface State {
|
|
|
7
7
|
isOpen: boolean;
|
|
8
8
|
}
|
|
9
9
|
export interface Props {
|
|
10
|
-
pluginState: AlignmentPluginState;
|
|
10
|
+
pluginState: AlignmentPluginState | undefined;
|
|
11
11
|
changeAlignment: (align: AlignmentState) => void;
|
|
12
12
|
popupsMountPoint?: HTMLElement;
|
|
13
13
|
popupsBoundariesElement?: HTMLElement;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-alignment",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Alignment plugin for @atlaskit/editor-core",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
7
7
|
},
|
|
8
|
-
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
8
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
9
9
|
"author": "Atlassian Pty Ltd",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"main": "dist/cjs/index.js",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@atlaskit/adf-schema": "^35.3.0",
|
|
25
|
-
"@atlaskit/editor-common": "^76.
|
|
25
|
+
"@atlaskit/editor-common": "^76.41.0",
|
|
26
26
|
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
27
|
-
"@atlaskit/editor-tables": "^2.
|
|
27
|
+
"@atlaskit/editor-tables": "^2.4.0",
|
|
28
28
|
"@atlaskit/icon": "^22.0.0",
|
|
29
|
-
"@atlaskit/tokens": "^1.
|
|
29
|
+
"@atlaskit/tokens": "^1.34.0",
|
|
30
30
|
"@babel/runtime": "^7.0.0",
|
|
31
31
|
"@emotion/react": "^11.7.1"
|
|
32
32
|
},
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"@atlaskit/editor-plugin-list": "^3.1.0",
|
|
41
41
|
"@atlaskit/ssr": "*",
|
|
42
42
|
"@atlaskit/visual-regression": "*",
|
|
43
|
-
"@atlaskit/webdriver-runner": "*",
|
|
44
43
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
45
44
|
"@testing-library/react": "^12.1.5",
|
|
45
|
+
"@testing-library/user-event": "^14.4.3",
|
|
46
46
|
"react-dom": "^16.8.0",
|
|
47
47
|
"typescript": "~4.9.5",
|
|
48
48
|
"wait-for-expect": "^1.2.0"
|