@atlaskit/editor-plugin-alignment 1.13.8 → 1.14.1
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 +22 -0
- package/dist/cjs/alignmentPlugin.js +29 -0
- package/dist/cjs/pm-plugins/types.js +11 -1
- package/dist/cjs/ui/Alignment/AlignmentButton/index.js +2 -1
- package/dist/cjs/ui/FloatingToolbarComponent.js +36 -0
- package/dist/cjs/ui/PrimaryToolbarComponent.js +3 -1
- package/dist/cjs/ui/ToolbarAlignment/index.js +2 -1
- package/dist/es2019/alignmentPlugin.js +29 -0
- package/dist/es2019/pm-plugins/types.js +5 -0
- package/dist/es2019/ui/Alignment/AlignmentButton/index.js +2 -1
- package/dist/es2019/ui/FloatingToolbarComponent.js +28 -0
- package/dist/es2019/ui/PrimaryToolbarComponent.js +3 -1
- package/dist/es2019/ui/ToolbarAlignment/index.js +2 -1
- package/dist/esm/alignmentPlugin.js +29 -0
- package/dist/esm/pm-plugins/types.js +5 -0
- package/dist/esm/ui/Alignment/AlignmentButton/index.js +2 -1
- package/dist/esm/ui/FloatingToolbarComponent.js +26 -0
- package/dist/esm/ui/PrimaryToolbarComponent.js +3 -1
- package/dist/esm/ui/ToolbarAlignment/index.js +2 -1
- package/dist/types/pm-plugins/types.d.ts +4 -0
- package/dist/types/ui/FloatingToolbarComponent.d.ts +10 -0
- package/dist/types/ui/ToolbarAlignment/index.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/types.d.ts +4 -0
- package/dist/types-ts4.5/ui/FloatingToolbarComponent.d.ts +10 -0
- package/dist/types-ts4.5/ui/ToolbarAlignment/index.d.ts +2 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-alignment
|
|
2
2
|
|
|
3
|
+
## 1.14.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 1.14.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#170744](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/170744)
|
|
14
|
+
[`115a1beee1131`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/115a1beee1131) -
|
|
15
|
+
[ux] Adds text alignment to the selection toolbar
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#171994](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/171994)
|
|
20
|
+
[`be58e4bb2e387`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/be58e4bb2e387) -
|
|
21
|
+
Migrating usages of UNSAFE types and entrypoints that have been renamed in `@atlaskit/icon` and
|
|
22
|
+
`@atlaskit/icon-lab`.
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 1.13.8
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -7,8 +7,10 @@ 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 _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
10
11
|
var _keymap = require("./pm-plugins/keymap");
|
|
11
12
|
var _main = require("./pm-plugins/main");
|
|
13
|
+
var _FloatingToolbarComponent = require("./ui/FloatingToolbarComponent");
|
|
12
14
|
var _PrimaryToolbarComponent = require("./ui/PrimaryToolbarComponent");
|
|
13
15
|
var defaultConfig = exports.defaultConfig = {
|
|
14
16
|
align: 'start'
|
|
@@ -69,6 +71,33 @@ var alignmentPlugin = exports.alignmentPlugin = function alignmentPlugin(_ref) {
|
|
|
69
71
|
}
|
|
70
72
|
}];
|
|
71
73
|
},
|
|
74
|
+
pluginsOptions: {
|
|
75
|
+
selectionToolbar: function selectionToolbar() {
|
|
76
|
+
if ((0, _experiments.editorExperiment)('contextual_formatting_toolbar', true, {
|
|
77
|
+
exposure: true
|
|
78
|
+
})) {
|
|
79
|
+
var toolbarCustom = {
|
|
80
|
+
type: 'custom',
|
|
81
|
+
render: function render(view) {
|
|
82
|
+
if (!view) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
return /*#__PURE__*/_react.default.createElement(_FloatingToolbarComponent.FloatingToolbarComponent, {
|
|
86
|
+
api: api,
|
|
87
|
+
editorView: view
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
fallback: []
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
isToolbarAbove: true,
|
|
94
|
+
items: [toolbarCustom]
|
|
95
|
+
};
|
|
96
|
+
} else {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
72
101
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
73
102
|
};
|
|
74
103
|
};
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ToolbarType = void 0;
|
|
7
|
+
var ToolbarType = exports.ToolbarType = /*#__PURE__*/function (ToolbarType) {
|
|
8
|
+
ToolbarType["PRIMARY"] = "primaryToolbar";
|
|
9
|
+
ToolbarType["FLOATING"] = "floatingToolbar";
|
|
10
|
+
return ToolbarType;
|
|
11
|
+
}({});
|
|
@@ -32,7 +32,8 @@ function AlignmentButton(_ref) {
|
|
|
32
32
|
"aria-pressed": isSelected,
|
|
33
33
|
"aria-keyshortcuts": (0, _keymaps.getAriaKeyshortcuts)(shortcut),
|
|
34
34
|
onClick: onClickCallback,
|
|
35
|
-
iconBefore: content
|
|
35
|
+
iconBefore: content,
|
|
36
|
+
titlePosition: 'bottom'
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
39
|
var _default = exports.default = AlignmentButton;
|
|
@@ -0,0 +1,36 @@
|
|
|
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.FloatingToolbarComponent = FloatingToolbarComponent;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
|
+
var _editorCommands = require("../editor-commands");
|
|
12
|
+
var _types = require("../pm-plugins/types");
|
|
13
|
+
var _ToolbarAlignment = _interopRequireDefault(require("./ToolbarAlignment"));
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
var FloatingToolbarSettings = {
|
|
17
|
+
disabled: false,
|
|
18
|
+
isToolbarReducedSpacing: true
|
|
19
|
+
};
|
|
20
|
+
function FloatingToolbarComponent(_ref) {
|
|
21
|
+
var api = _ref.api,
|
|
22
|
+
editorView = _ref.editorView;
|
|
23
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['alignment']),
|
|
24
|
+
alignmentState = _useSharedPluginState.alignmentState;
|
|
25
|
+
var changeAlignmentCallback = (0, _react.useCallback)(function (align) {
|
|
26
|
+
return (0, _editorCommands.changeAlignment)(align)(editorView.state, editorView.dispatch);
|
|
27
|
+
}, [editorView]);
|
|
28
|
+
return /*#__PURE__*/_react.default.createElement(_ToolbarAlignment.default, {
|
|
29
|
+
pluginState: alignmentState,
|
|
30
|
+
isReducedSpacing: FloatingToolbarSettings.isToolbarReducedSpacing,
|
|
31
|
+
changeAlignment: changeAlignmentCallback,
|
|
32
|
+
disabled: FloatingToolbarSettings.disabled || !alignmentState.isEnabled,
|
|
33
|
+
toolbarType: _types.ToolbarType.FLOATING,
|
|
34
|
+
api: api
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -9,6 +9,7 @@ exports.PrimaryToolbarComponent = PrimaryToolbarComponent;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
11
|
var _editorCommands = require("../editor-commands");
|
|
12
|
+
var _types = require("../pm-plugins/types");
|
|
12
13
|
var _ToolbarAlignment = _interopRequireDefault(require("./ToolbarAlignment"));
|
|
13
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -33,6 +34,7 @@ function PrimaryToolbarComponent(_ref) {
|
|
|
33
34
|
popupsMountPoint: popupsMountPoint,
|
|
34
35
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
35
36
|
popupsScrollableElement: popupsScrollableElement,
|
|
36
|
-
api: api
|
|
37
|
+
api: api,
|
|
38
|
+
toolbarType: _types.ToolbarType.PRIMARY
|
|
37
39
|
});
|
|
38
40
|
}
|
|
@@ -20,6 +20,7 @@ var _styles = require("@atlaskit/editor-common/styles");
|
|
|
20
20
|
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
21
21
|
var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/utility/migration/chevron-down"));
|
|
22
22
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
23
|
+
var _types = require("../../pm-plugins/types");
|
|
23
24
|
var _Alignment = _interopRequireDefault(require("../Alignment"));
|
|
24
25
|
var _iconMap = require("./icon-map");
|
|
25
26
|
var _styles2 = require("./styles");
|
|
@@ -179,7 +180,7 @@ var AlignmentToolbar = exports.AlignmentToolbar = /*#__PURE__*/function (_React$
|
|
|
179
180
|
key: "componentDidUpdate",
|
|
180
181
|
value: function componentDidUpdate(prevProps) {
|
|
181
182
|
var _this3 = this;
|
|
182
|
-
if (this.state.isOpen) {
|
|
183
|
+
if (this.props.toolbarType !== _types.ToolbarType.FLOATING && this.state.isOpen) {
|
|
183
184
|
// by triggering the keyboard event with a setTimeout, we ensure that the tooltip
|
|
184
185
|
// associated with the alignment button doesn't render until the next render cycle
|
|
185
186
|
// where the popup will be correctly positioned and the relative position of the tooltip
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { alignment } from '@atlaskit/adf-schema';
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
4
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
4
5
|
import { createPlugin, pluginKey } from './pm-plugins/main';
|
|
6
|
+
import { FloatingToolbarComponent } from './ui/FloatingToolbarComponent';
|
|
5
7
|
import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
|
|
6
8
|
export const defaultConfig = {
|
|
7
9
|
align: 'start'
|
|
@@ -61,6 +63,33 @@ export const alignmentPlugin = ({
|
|
|
61
63
|
plugin: () => keymapPlugin()
|
|
62
64
|
}];
|
|
63
65
|
},
|
|
66
|
+
pluginsOptions: {
|
|
67
|
+
selectionToolbar: () => {
|
|
68
|
+
if (editorExperiment('contextual_formatting_toolbar', true, {
|
|
69
|
+
exposure: true
|
|
70
|
+
})) {
|
|
71
|
+
const toolbarCustom = {
|
|
72
|
+
type: 'custom',
|
|
73
|
+
render: view => {
|
|
74
|
+
if (!view) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
return /*#__PURE__*/React.createElement(FloatingToolbarComponent, {
|
|
78
|
+
api: api,
|
|
79
|
+
editorView: view
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
fallback: []
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
isToolbarAbove: true,
|
|
86
|
+
items: [toolbarCustom]
|
|
87
|
+
};
|
|
88
|
+
} else {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
64
93
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
65
94
|
};
|
|
66
95
|
};
|
|
@@ -26,7 +26,8 @@ function AlignmentButton({
|
|
|
26
26
|
"aria-pressed": isSelected,
|
|
27
27
|
"aria-keyshortcuts": getAriaKeyshortcuts(shortcut),
|
|
28
28
|
onClick: onClickCallback,
|
|
29
|
-
iconBefore: content
|
|
29
|
+
iconBefore: content,
|
|
30
|
+
titlePosition: 'bottom'
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
export default AlignmentButton;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { changeAlignment } from '../editor-commands';
|
|
4
|
+
import { ToolbarType } from '../pm-plugins/types';
|
|
5
|
+
import ToolbarAlignment from './ToolbarAlignment';
|
|
6
|
+
const FloatingToolbarSettings = {
|
|
7
|
+
disabled: false,
|
|
8
|
+
isToolbarReducedSpacing: true
|
|
9
|
+
};
|
|
10
|
+
export function FloatingToolbarComponent({
|
|
11
|
+
api,
|
|
12
|
+
editorView
|
|
13
|
+
}) {
|
|
14
|
+
const {
|
|
15
|
+
alignmentState
|
|
16
|
+
} = useSharedPluginState(api, ['alignment']);
|
|
17
|
+
const changeAlignmentCallback = useCallback(align => {
|
|
18
|
+
return changeAlignment(align)(editorView.state, editorView.dispatch);
|
|
19
|
+
}, [editorView]);
|
|
20
|
+
return /*#__PURE__*/React.createElement(ToolbarAlignment, {
|
|
21
|
+
pluginState: alignmentState,
|
|
22
|
+
isReducedSpacing: FloatingToolbarSettings.isToolbarReducedSpacing,
|
|
23
|
+
changeAlignment: changeAlignmentCallback,
|
|
24
|
+
disabled: FloatingToolbarSettings.disabled || !alignmentState.isEnabled,
|
|
25
|
+
toolbarType: ToolbarType.FLOATING,
|
|
26
|
+
api: api
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { changeAlignment } from '../editor-commands';
|
|
4
|
+
import { ToolbarType } from '../pm-plugins/types';
|
|
4
5
|
import ToolbarAlignment from './ToolbarAlignment';
|
|
5
6
|
export function PrimaryToolbarComponent({
|
|
6
7
|
api,
|
|
@@ -23,6 +24,7 @@ export function PrimaryToolbarComponent({
|
|
|
23
24
|
popupsMountPoint: popupsMountPoint,
|
|
24
25
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
25
26
|
popupsScrollableElement: popupsScrollableElement,
|
|
26
|
-
api: api
|
|
27
|
+
api: api,
|
|
28
|
+
toolbarType: ToolbarType.PRIMARY
|
|
27
29
|
});
|
|
28
30
|
}
|
|
@@ -13,6 +13,7 @@ import { expandIconContainerStyle, separatorStyles, triggerWrapperStylesWithPadd
|
|
|
13
13
|
import { ArrowKeyNavigationType, DropdownContainer as Dropdown, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
14
14
|
import ChevronDownIcon from '@atlaskit/icon/utility/migration/chevron-down';
|
|
15
15
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
|
+
import { ToolbarType } from '../../pm-plugins/types';
|
|
16
17
|
import Alignment from '../Alignment';
|
|
17
18
|
import { IconMap } from './icon-map';
|
|
18
19
|
import { triggerWrapper, wrapper } from './styles';
|
|
@@ -154,7 +155,7 @@ export class AlignmentToolbar extends React.Component {
|
|
|
154
155
|
);
|
|
155
156
|
}
|
|
156
157
|
componentDidUpdate(prevProps) {
|
|
157
|
-
if (this.state.isOpen) {
|
|
158
|
+
if (this.props.toolbarType !== ToolbarType.FLOATING && this.state.isOpen) {
|
|
158
159
|
// by triggering the keyboard event with a setTimeout, we ensure that the tooltip
|
|
159
160
|
// associated with the alignment button doesn't render until the next render cycle
|
|
160
161
|
// where the popup will be correctly positioned and the relative position of the tooltip
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { alignment } from '@atlaskit/adf-schema';
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
4
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
4
5
|
import { createPlugin, pluginKey } from './pm-plugins/main';
|
|
6
|
+
import { FloatingToolbarComponent } from './ui/FloatingToolbarComponent';
|
|
5
7
|
import { PrimaryToolbarComponent } from './ui/PrimaryToolbarComponent';
|
|
6
8
|
export var defaultConfig = {
|
|
7
9
|
align: 'start'
|
|
@@ -62,6 +64,33 @@ export var alignmentPlugin = function alignmentPlugin(_ref) {
|
|
|
62
64
|
}
|
|
63
65
|
}];
|
|
64
66
|
},
|
|
67
|
+
pluginsOptions: {
|
|
68
|
+
selectionToolbar: function selectionToolbar() {
|
|
69
|
+
if (editorExperiment('contextual_formatting_toolbar', true, {
|
|
70
|
+
exposure: true
|
|
71
|
+
})) {
|
|
72
|
+
var toolbarCustom = {
|
|
73
|
+
type: 'custom',
|
|
74
|
+
render: function render(view) {
|
|
75
|
+
if (!view) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
return /*#__PURE__*/React.createElement(FloatingToolbarComponent, {
|
|
79
|
+
api: api,
|
|
80
|
+
editorView: view
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
fallback: []
|
|
84
|
+
};
|
|
85
|
+
return {
|
|
86
|
+
isToolbarAbove: true,
|
|
87
|
+
items: [toolbarCustom]
|
|
88
|
+
};
|
|
89
|
+
} else {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
65
94
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
66
95
|
};
|
|
67
96
|
};
|
|
@@ -25,7 +25,8 @@ function AlignmentButton(_ref) {
|
|
|
25
25
|
"aria-pressed": isSelected,
|
|
26
26
|
"aria-keyshortcuts": getAriaKeyshortcuts(shortcut),
|
|
27
27
|
onClick: onClickCallback,
|
|
28
|
-
iconBefore: content
|
|
28
|
+
iconBefore: content,
|
|
29
|
+
titlePosition: 'bottom'
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
export default AlignmentButton;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { changeAlignment } from '../editor-commands';
|
|
4
|
+
import { ToolbarType } from '../pm-plugins/types';
|
|
5
|
+
import ToolbarAlignment from './ToolbarAlignment';
|
|
6
|
+
var FloatingToolbarSettings = {
|
|
7
|
+
disabled: false,
|
|
8
|
+
isToolbarReducedSpacing: true
|
|
9
|
+
};
|
|
10
|
+
export function FloatingToolbarComponent(_ref) {
|
|
11
|
+
var api = _ref.api,
|
|
12
|
+
editorView = _ref.editorView;
|
|
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: FloatingToolbarSettings.isToolbarReducedSpacing,
|
|
21
|
+
changeAlignment: changeAlignmentCallback,
|
|
22
|
+
disabled: FloatingToolbarSettings.disabled || !alignmentState.isEnabled,
|
|
23
|
+
toolbarType: ToolbarType.FLOATING,
|
|
24
|
+
api: api
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { changeAlignment } from '../editor-commands';
|
|
4
|
+
import { ToolbarType } from '../pm-plugins/types';
|
|
4
5
|
import ToolbarAlignment from './ToolbarAlignment';
|
|
5
6
|
export function PrimaryToolbarComponent(_ref) {
|
|
6
7
|
var api = _ref.api,
|
|
@@ -23,6 +24,7 @@ export function PrimaryToolbarComponent(_ref) {
|
|
|
23
24
|
popupsMountPoint: popupsMountPoint,
|
|
24
25
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
25
26
|
popupsScrollableElement: popupsScrollableElement,
|
|
26
|
-
api: api
|
|
27
|
+
api: api,
|
|
28
|
+
toolbarType: ToolbarType.PRIMARY
|
|
27
29
|
});
|
|
28
30
|
}
|
|
@@ -21,6 +21,7 @@ import { expandIconContainerStyle, separatorStyles, triggerWrapperStylesWithPadd
|
|
|
21
21
|
import { ArrowKeyNavigationType, DropdownContainer as Dropdown, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
22
22
|
import ChevronDownIcon from '@atlaskit/icon/utility/migration/chevron-down';
|
|
23
23
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
24
|
+
import { ToolbarType } from '../../pm-plugins/types';
|
|
24
25
|
import Alignment from '../Alignment';
|
|
25
26
|
import { IconMap } from './icon-map';
|
|
26
27
|
import { triggerWrapper, wrapper } from './styles';
|
|
@@ -175,7 +176,7 @@ export var AlignmentToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
175
176
|
key: "componentDidUpdate",
|
|
176
177
|
value: function componentDidUpdate(prevProps) {
|
|
177
178
|
var _this3 = this;
|
|
178
|
-
if (this.state.isOpen) {
|
|
179
|
+
if (this.props.toolbarType !== ToolbarType.FLOATING && this.state.isOpen) {
|
|
179
180
|
// by triggering the keyboard event with a setTimeout, we ensure that the tooltip
|
|
180
181
|
// associated with the alignment button doesn't render until the next render cycle
|
|
181
182
|
// where the popup will be correctly positioned and the relative position of the tooltip
|
|
@@ -0,0 +1,10 @@
|
|
|
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 '../alignmentPluginType';
|
|
5
|
+
interface FloatingToolbarComponentProps {
|
|
6
|
+
api: ExtractInjectionAPI<AlignmentPlugin> | undefined;
|
|
7
|
+
editorView: EditorView;
|
|
8
|
+
}
|
|
9
|
+
export declare function FloatingToolbarComponent({ api, editorView }: FloatingToolbarComponentProps): JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -7,7 +7,7 @@ import { jsx } from '@emotion/react';
|
|
|
7
7
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
8
8
|
import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
9
9
|
import type { AlignmentPlugin } from '../../alignmentPluginType';
|
|
10
|
-
import type
|
|
10
|
+
import { type AlignmentPluginState, type AlignmentState, ToolbarType } from '../../pm-plugins/types';
|
|
11
11
|
export interface State {
|
|
12
12
|
isOpen: boolean;
|
|
13
13
|
}
|
|
@@ -20,6 +20,7 @@ export interface Props {
|
|
|
20
20
|
isReducedSpacing?: boolean;
|
|
21
21
|
disabled?: boolean;
|
|
22
22
|
api: ExtractInjectionAPI<AlignmentPlugin> | undefined;
|
|
23
|
+
toolbarType: ToolbarType;
|
|
23
24
|
}
|
|
24
25
|
export declare class AlignmentToolbar extends React.Component<Props & WrappedComponentProps, State> {
|
|
25
26
|
static displayName: string;
|
|
@@ -0,0 +1,10 @@
|
|
|
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 '../alignmentPluginType';
|
|
5
|
+
interface FloatingToolbarComponentProps {
|
|
6
|
+
api: ExtractInjectionAPI<AlignmentPlugin> | undefined;
|
|
7
|
+
editorView: EditorView;
|
|
8
|
+
}
|
|
9
|
+
export declare function FloatingToolbarComponent({ api, editorView }: FloatingToolbarComponentProps): JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -7,7 +7,7 @@ import { jsx } from '@emotion/react';
|
|
|
7
7
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
8
8
|
import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
9
9
|
import type { AlignmentPlugin } from '../../alignmentPluginType';
|
|
10
|
-
import type
|
|
10
|
+
import { type AlignmentPluginState, type AlignmentState, ToolbarType } from '../../pm-plugins/types';
|
|
11
11
|
export interface State {
|
|
12
12
|
isOpen: boolean;
|
|
13
13
|
}
|
|
@@ -20,6 +20,7 @@ export interface Props {
|
|
|
20
20
|
isReducedSpacing?: boolean;
|
|
21
21
|
disabled?: boolean;
|
|
22
22
|
api: ExtractInjectionAPI<AlignmentPlugin> | undefined;
|
|
23
|
+
toolbarType: ToolbarType;
|
|
23
24
|
}
|
|
24
25
|
export declare class AlignmentToolbar extends React.Component<Props & WrappedComponentProps, State> {
|
|
25
26
|
static displayName: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-alignment",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.1",
|
|
4
4
|
"description": "Alignment plugin for @atlaskit/editor-core",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -21,12 +21,13 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
24
|
-
"@atlaskit/editor-common": "^
|
|
24
|
+
"@atlaskit/editor-common": "^96.0.0",
|
|
25
25
|
"@atlaskit/editor-plugin-primary-toolbar": "^2.0.0",
|
|
26
26
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
27
27
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
28
|
-
"@atlaskit/icon": "^
|
|
28
|
+
"@atlaskit/icon": "^23.0.0",
|
|
29
29
|
"@atlaskit/platform-feature-flags": "0.3.0",
|
|
30
|
+
"@atlaskit/tmp-editor-statsig": "^2.22.0",
|
|
30
31
|
"@atlaskit/tokens": "^2.4.0",
|
|
31
32
|
"@babel/runtime": "^7.0.0",
|
|
32
33
|
"@emotion/react": "^11.7.1"
|