@atlaskit/editor-plugin-alignment 4.2.11 → 5.0.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 +16 -0
- package/dist/cjs/ui/FloatingToolbarComponent.js +3 -19
- package/dist/cjs/ui/PrimaryToolbarComponent.js +8 -24
- package/dist/cjs/ui/Toolbar/MenuSection.js +22 -0
- package/dist/cjs/ui/toolbar-components.js +8 -1
- package/dist/es2019/ui/FloatingToolbarComponent.js +5 -23
- package/dist/es2019/ui/PrimaryToolbarComponent.js +8 -26
- package/dist/es2019/ui/Toolbar/MenuSection.js +14 -0
- package/dist/es2019/ui/toolbar-components.js +9 -2
- package/dist/esm/ui/FloatingToolbarComponent.js +4 -20
- package/dist/esm/ui/PrimaryToolbarComponent.js +9 -25
- package/dist/esm/ui/Toolbar/MenuSection.js +15 -0
- package/dist/esm/ui/toolbar-components.js +9 -2
- package/dist/types/ui/Toolbar/MenuSection.d.ts +7 -0
- package/dist/types-ts4.5/ui/Toolbar/MenuSection.d.ts +7 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-alignment
|
|
2
2
|
|
|
3
|
+
## 5.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 4.2.12
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`51f3f2db61f6e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/51f3f2db61f6e) -
|
|
14
|
+
Update toolbar config across plugins
|
|
15
|
+
- [`7c342b45b449f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7c342b45b449f) -
|
|
16
|
+
Cleanup platform_editor_usesharedpluginstateselector in accessibility, alignment
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 4.2.11
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -18,7 +18,9 @@ var FloatingToolbarSettings = {
|
|
|
18
18
|
disabled: false,
|
|
19
19
|
isToolbarReducedSpacing: true
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
function FloatingToolbarComponent(_ref) {
|
|
22
|
+
var api = _ref.api,
|
|
23
|
+
editorView = _ref.editorView;
|
|
22
24
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['alignment'], function (states) {
|
|
23
25
|
var _states$alignmentStat, _states$alignmentStat2;
|
|
24
26
|
return {
|
|
@@ -28,24 +30,6 @@ var useFloatingToolbarComponentPluginState = (0, _hooks.sharedPluginStateHookMig
|
|
|
28
30
|
}),
|
|
29
31
|
align = _useSharedPluginState.align,
|
|
30
32
|
isEnabled = _useSharedPluginState.isEnabled;
|
|
31
|
-
return {
|
|
32
|
-
align: align,
|
|
33
|
-
isEnabled: isEnabled
|
|
34
|
-
};
|
|
35
|
-
}, function (api) {
|
|
36
|
-
var _useSharedPluginState2 = (0, _hooks.useSharedPluginState)(api, ['alignment']),
|
|
37
|
-
alignmentState = _useSharedPluginState2.alignmentState;
|
|
38
|
-
return {
|
|
39
|
-
align: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align,
|
|
40
|
-
isEnabled: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
function FloatingToolbarComponent(_ref) {
|
|
44
|
-
var api = _ref.api,
|
|
45
|
-
editorView = _ref.editorView;
|
|
46
|
-
var _useFloatingToolbarCo = useFloatingToolbarComponentPluginState(api),
|
|
47
|
-
align = _useFloatingToolbarCo.align,
|
|
48
|
-
isEnabled = _useFloatingToolbarCo.isEnabled;
|
|
49
33
|
var changeAlignmentCallback = (0, _react.useCallback)(function (align) {
|
|
50
34
|
return (0, _editorCommands.changeAlignment)(align, api, _analytics.INPUT_METHOD.FLOATING_TB)(editorView.state, editorView.dispatch);
|
|
51
35
|
}, [editorView, api]);
|
|
@@ -13,7 +13,14 @@ var _editorCommands = require("../editor-commands");
|
|
|
13
13
|
var _types = require("../pm-plugins/types");
|
|
14
14
|
var _ToolbarAlignment = _interopRequireDefault(require("./ToolbarAlignment"));
|
|
15
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
16
|
-
|
|
16
|
+
function PrimaryToolbarComponent(_ref) {
|
|
17
|
+
var api = _ref.api,
|
|
18
|
+
editorView = _ref.editorView,
|
|
19
|
+
disabled = _ref.disabled,
|
|
20
|
+
popupsMountPoint = _ref.popupsMountPoint,
|
|
21
|
+
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
22
|
+
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
23
|
+
isToolbarReducedSpacing = _ref.isToolbarReducedSpacing;
|
|
17
24
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['alignment'], function (states) {
|
|
18
25
|
var _states$alignmentStat, _states$alignmentStat2;
|
|
19
26
|
return {
|
|
@@ -23,29 +30,6 @@ var usePrimaryToolbarComponentPluginState = (0, _hooks.sharedPluginStateHookMigr
|
|
|
23
30
|
}),
|
|
24
31
|
align = _useSharedPluginState.align,
|
|
25
32
|
isEnabled = _useSharedPluginState.isEnabled;
|
|
26
|
-
return {
|
|
27
|
-
align: align,
|
|
28
|
-
isEnabled: isEnabled
|
|
29
|
-
};
|
|
30
|
-
}, function (api) {
|
|
31
|
-
var _useSharedPluginState2 = (0, _hooks.useSharedPluginState)(api, ['alignment']),
|
|
32
|
-
alignmentState = _useSharedPluginState2.alignmentState;
|
|
33
|
-
return {
|
|
34
|
-
align: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align,
|
|
35
|
-
isEnabled: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
function PrimaryToolbarComponent(_ref) {
|
|
39
|
-
var api = _ref.api,
|
|
40
|
-
editorView = _ref.editorView,
|
|
41
|
-
disabled = _ref.disabled,
|
|
42
|
-
popupsMountPoint = _ref.popupsMountPoint,
|
|
43
|
-
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
44
|
-
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
45
|
-
isToolbarReducedSpacing = _ref.isToolbarReducedSpacing;
|
|
46
|
-
var _usePrimaryToolbarCom = usePrimaryToolbarComponentPluginState(api),
|
|
47
|
-
align = _usePrimaryToolbarCom.align,
|
|
48
|
-
isEnabled = _usePrimaryToolbarCom.isEnabled;
|
|
49
33
|
var changeAlignmentCallback = (0, _react.useCallback)(function (align) {
|
|
50
34
|
return (0, _editorCommands.changeAlignment)(align, api, _analytics.INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
51
35
|
}, [editorView, api]);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.MenuSection = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
10
|
+
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
11
|
+
var MenuSection = exports.MenuSection = function MenuSection(_ref) {
|
|
12
|
+
var children = _ref.children,
|
|
13
|
+
title = _ref.title,
|
|
14
|
+
parents = _ref.parents;
|
|
15
|
+
var hasSeparator = parents.some(function (parent) {
|
|
16
|
+
return parent.key === _toolbar.TEXT_COLLAPSED_MENU.key;
|
|
17
|
+
});
|
|
18
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
19
|
+
hasSeparator: hasSeparator,
|
|
20
|
+
title: title
|
|
21
|
+
}, children);
|
|
22
|
+
};
|
|
@@ -9,8 +9,10 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
12
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
12
13
|
var _AlignmentMenu = require("./Toolbar/AlignmentMenu");
|
|
13
14
|
var _AlignmentMenuItem = require("./Toolbar/AlignmentMenuItem");
|
|
15
|
+
var _MenuSection = require("./Toolbar/MenuSection");
|
|
14
16
|
var _options = require("./Toolbar/options");
|
|
15
17
|
var getAlignmentMenuItems = function getAlignmentMenuItems(api) {
|
|
16
18
|
return Object.entries((0, _options.alignmentOptions)()).map(function (_ref) {
|
|
@@ -70,6 +72,11 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
|
|
|
70
72
|
type: _toolbar.ALIGNMENT_MENU.type,
|
|
71
73
|
key: _toolbar.ALIGNMENT_MENU.key,
|
|
72
74
|
rank: _toolbar.ALIGNMENT_MENU_RANK[_toolbar.ALIGNMENT_MENU_SECTION.key]
|
|
73
|
-
}]
|
|
75
|
+
}].concat((0, _toConsumableArray2.default)((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? [{
|
|
76
|
+
type: _toolbar.TEXT_COLLAPSED_MENU.type,
|
|
77
|
+
key: _toolbar.TEXT_COLLAPSED_MENU.key,
|
|
78
|
+
rank: _toolbar.TEXT_COLLAPSED_MENU_RANK[_toolbar.ALIGNMENT_MENU_SECTION.key]
|
|
79
|
+
}] : [])),
|
|
80
|
+
component: (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? _MenuSection.MenuSection : undefined
|
|
74
81
|
}].concat((0, _toConsumableArray2.default)(getAlignmentMenuItems(api)));
|
|
75
82
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import {
|
|
3
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
5
|
import { changeAlignment } from '../editor-commands';
|
|
6
6
|
import { ToolbarType } from '../pm-plugins/types';
|
|
@@ -9,7 +9,10 @@ const FloatingToolbarSettings = {
|
|
|
9
9
|
disabled: false,
|
|
10
10
|
isToolbarReducedSpacing: true
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
export function FloatingToolbarComponent({
|
|
13
|
+
api,
|
|
14
|
+
editorView
|
|
15
|
+
}) {
|
|
13
16
|
const {
|
|
14
17
|
align,
|
|
15
18
|
isEnabled
|
|
@@ -20,27 +23,6 @@ const useFloatingToolbarComponentPluginState = sharedPluginStateHookMigratorFact
|
|
|
20
23
|
isEnabled: (_states$alignmentStat2 = states.alignmentState) === null || _states$alignmentStat2 === void 0 ? void 0 : _states$alignmentStat2.isEnabled
|
|
21
24
|
};
|
|
22
25
|
});
|
|
23
|
-
return {
|
|
24
|
-
align,
|
|
25
|
-
isEnabled
|
|
26
|
-
};
|
|
27
|
-
}, api => {
|
|
28
|
-
const {
|
|
29
|
-
alignmentState
|
|
30
|
-
} = useSharedPluginState(api, ['alignment']);
|
|
31
|
-
return {
|
|
32
|
-
align: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align,
|
|
33
|
-
isEnabled: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
export function FloatingToolbarComponent({
|
|
37
|
-
api,
|
|
38
|
-
editorView
|
|
39
|
-
}) {
|
|
40
|
-
const {
|
|
41
|
-
align,
|
|
42
|
-
isEnabled
|
|
43
|
-
} = useFloatingToolbarComponentPluginState(api);
|
|
44
26
|
const changeAlignmentCallback = useCallback(align => {
|
|
45
27
|
return changeAlignment(align, api, INPUT_METHOD.FLOATING_TB)(editorView.state, editorView.dispatch);
|
|
46
28
|
}, [editorView, api]);
|
|
@@ -1,33 +1,9 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import {
|
|
3
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { changeAlignment } from '../editor-commands';
|
|
5
5
|
import { ToolbarType } from '../pm-plugins/types';
|
|
6
6
|
import ToolbarAlignment from './ToolbarAlignment';
|
|
7
|
-
const usePrimaryToolbarComponentPluginState = sharedPluginStateHookMigratorFactory(api => {
|
|
8
|
-
const {
|
|
9
|
-
align,
|
|
10
|
-
isEnabled
|
|
11
|
-
} = useSharedPluginStateWithSelector(api, ['alignment'], states => {
|
|
12
|
-
var _states$alignmentStat, _states$alignmentStat2;
|
|
13
|
-
return {
|
|
14
|
-
align: (_states$alignmentStat = states.alignmentState) === null || _states$alignmentStat === void 0 ? void 0 : _states$alignmentStat.align,
|
|
15
|
-
isEnabled: (_states$alignmentStat2 = states.alignmentState) === null || _states$alignmentStat2 === void 0 ? void 0 : _states$alignmentStat2.isEnabled
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
return {
|
|
19
|
-
align,
|
|
20
|
-
isEnabled
|
|
21
|
-
};
|
|
22
|
-
}, api => {
|
|
23
|
-
const {
|
|
24
|
-
alignmentState
|
|
25
|
-
} = useSharedPluginState(api, ['alignment']);
|
|
26
|
-
return {
|
|
27
|
-
align: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align,
|
|
28
|
-
isEnabled: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
7
|
export function PrimaryToolbarComponent({
|
|
32
8
|
api,
|
|
33
9
|
editorView,
|
|
@@ -40,7 +16,13 @@ export function PrimaryToolbarComponent({
|
|
|
40
16
|
const {
|
|
41
17
|
align,
|
|
42
18
|
isEnabled
|
|
43
|
-
} =
|
|
19
|
+
} = useSharedPluginStateWithSelector(api, ['alignment'], states => {
|
|
20
|
+
var _states$alignmentStat, _states$alignmentStat2;
|
|
21
|
+
return {
|
|
22
|
+
align: (_states$alignmentStat = states.alignmentState) === null || _states$alignmentStat === void 0 ? void 0 : _states$alignmentStat.align,
|
|
23
|
+
isEnabled: (_states$alignmentStat2 = states.alignmentState) === null || _states$alignmentStat2 === void 0 ? void 0 : _states$alignmentStat2.isEnabled
|
|
24
|
+
};
|
|
25
|
+
});
|
|
44
26
|
const changeAlignmentCallback = useCallback(align => changeAlignment(align, api, INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch), [editorView, api]);
|
|
45
27
|
return /*#__PURE__*/React.createElement(ToolbarAlignment, {
|
|
46
28
|
align: align,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TEXT_COLLAPSED_MENU } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
4
|
+
export const MenuSection = ({
|
|
5
|
+
children,
|
|
6
|
+
title,
|
|
7
|
+
parents
|
|
8
|
+
}) => {
|
|
9
|
+
const hasSeparator = parents.some(parent => parent.key === TEXT_COLLAPSED_MENU.key);
|
|
10
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
11
|
+
hasSeparator: hasSeparator,
|
|
12
|
+
title: title
|
|
13
|
+
}, children);
|
|
14
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
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';
|
|
2
|
+
import { ALIGNMENT_GROUP, ALIGNMENT_GROUP_RANK, ALIGNMENT_MENU, ALIGNMENT_MENU_SECTION, TEXT_SECTION, TEXT_SECTION_RANK, ALIGNMENT_MENU_RANK, TEXT_COLLAPSED_MENU_RANK, TEXT_COLLAPSED_MENU } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
4
|
import { AlignmentMenu } from './Toolbar/AlignmentMenu';
|
|
4
5
|
import { AlignmentMenuItem } from './Toolbar/AlignmentMenuItem';
|
|
6
|
+
import { MenuSection } from './Toolbar/MenuSection';
|
|
5
7
|
import { alignmentOptions } from './Toolbar/options';
|
|
6
8
|
const getAlignmentMenuItems = api => {
|
|
7
9
|
return Object.entries(alignmentOptions()).map(([alignment, item]) => {
|
|
@@ -62,6 +64,11 @@ export const getToolbarComponents = api => {
|
|
|
62
64
|
type: ALIGNMENT_MENU.type,
|
|
63
65
|
key: ALIGNMENT_MENU.key,
|
|
64
66
|
rank: ALIGNMENT_MENU_RANK[ALIGNMENT_MENU_SECTION.key]
|
|
65
|
-
}
|
|
67
|
+
}, ...(expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? [{
|
|
68
|
+
type: TEXT_COLLAPSED_MENU.type,
|
|
69
|
+
key: TEXT_COLLAPSED_MENU.key,
|
|
70
|
+
rank: TEXT_COLLAPSED_MENU_RANK[ALIGNMENT_MENU_SECTION.key]
|
|
71
|
+
}] : [])],
|
|
72
|
+
component: expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? MenuSection : undefined
|
|
66
73
|
}, ...getAlignmentMenuItems(api)];
|
|
67
74
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import {
|
|
3
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
5
|
import { changeAlignment } from '../editor-commands';
|
|
6
6
|
import { ToolbarType } from '../pm-plugins/types';
|
|
@@ -9,7 +9,9 @@ var FloatingToolbarSettings = {
|
|
|
9
9
|
disabled: false,
|
|
10
10
|
isToolbarReducedSpacing: true
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
export function FloatingToolbarComponent(_ref) {
|
|
13
|
+
var api = _ref.api,
|
|
14
|
+
editorView = _ref.editorView;
|
|
13
15
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['alignment'], function (states) {
|
|
14
16
|
var _states$alignmentStat, _states$alignmentStat2;
|
|
15
17
|
return {
|
|
@@ -19,24 +21,6 @@ var useFloatingToolbarComponentPluginState = sharedPluginStateHookMigratorFactor
|
|
|
19
21
|
}),
|
|
20
22
|
align = _useSharedPluginState.align,
|
|
21
23
|
isEnabled = _useSharedPluginState.isEnabled;
|
|
22
|
-
return {
|
|
23
|
-
align: align,
|
|
24
|
-
isEnabled: isEnabled
|
|
25
|
-
};
|
|
26
|
-
}, function (api) {
|
|
27
|
-
var _useSharedPluginState2 = useSharedPluginState(api, ['alignment']),
|
|
28
|
-
alignmentState = _useSharedPluginState2.alignmentState;
|
|
29
|
-
return {
|
|
30
|
-
align: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align,
|
|
31
|
-
isEnabled: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
export function FloatingToolbarComponent(_ref) {
|
|
35
|
-
var api = _ref.api,
|
|
36
|
-
editorView = _ref.editorView;
|
|
37
|
-
var _useFloatingToolbarCo = useFloatingToolbarComponentPluginState(api),
|
|
38
|
-
align = _useFloatingToolbarCo.align,
|
|
39
|
-
isEnabled = _useFloatingToolbarCo.isEnabled;
|
|
40
24
|
var changeAlignmentCallback = useCallback(function (align) {
|
|
41
25
|
return changeAlignment(align, api, INPUT_METHOD.FLOATING_TB)(editorView.state, editorView.dispatch);
|
|
42
26
|
}, [editorView, api]);
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import {
|
|
3
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { changeAlignment } from '../editor-commands';
|
|
5
5
|
import { ToolbarType } from '../pm-plugins/types';
|
|
6
6
|
import ToolbarAlignment from './ToolbarAlignment';
|
|
7
|
-
|
|
7
|
+
export function PrimaryToolbarComponent(_ref) {
|
|
8
|
+
var api = _ref.api,
|
|
9
|
+
editorView = _ref.editorView,
|
|
10
|
+
disabled = _ref.disabled,
|
|
11
|
+
popupsMountPoint = _ref.popupsMountPoint,
|
|
12
|
+
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
13
|
+
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
14
|
+
isToolbarReducedSpacing = _ref.isToolbarReducedSpacing;
|
|
8
15
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['alignment'], function (states) {
|
|
9
16
|
var _states$alignmentStat, _states$alignmentStat2;
|
|
10
17
|
return {
|
|
@@ -14,29 +21,6 @@ var usePrimaryToolbarComponentPluginState = sharedPluginStateHookMigratorFactory
|
|
|
14
21
|
}),
|
|
15
22
|
align = _useSharedPluginState.align,
|
|
16
23
|
isEnabled = _useSharedPluginState.isEnabled;
|
|
17
|
-
return {
|
|
18
|
-
align: align,
|
|
19
|
-
isEnabled: isEnabled
|
|
20
|
-
};
|
|
21
|
-
}, function (api) {
|
|
22
|
-
var _useSharedPluginState2 = useSharedPluginState(api, ['alignment']),
|
|
23
|
-
alignmentState = _useSharedPluginState2.alignmentState;
|
|
24
|
-
return {
|
|
25
|
-
align: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align,
|
|
26
|
-
isEnabled: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
export function PrimaryToolbarComponent(_ref) {
|
|
30
|
-
var api = _ref.api,
|
|
31
|
-
editorView = _ref.editorView,
|
|
32
|
-
disabled = _ref.disabled,
|
|
33
|
-
popupsMountPoint = _ref.popupsMountPoint,
|
|
34
|
-
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
35
|
-
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
36
|
-
isToolbarReducedSpacing = _ref.isToolbarReducedSpacing;
|
|
37
|
-
var _usePrimaryToolbarCom = usePrimaryToolbarComponentPluginState(api),
|
|
38
|
-
align = _usePrimaryToolbarCom.align,
|
|
39
|
-
isEnabled = _usePrimaryToolbarCom.isEnabled;
|
|
40
24
|
var changeAlignmentCallback = useCallback(function (align) {
|
|
41
25
|
return changeAlignment(align, api, INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
42
26
|
}, [editorView, api]);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TEXT_COLLAPSED_MENU } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
4
|
+
export var MenuSection = function MenuSection(_ref) {
|
|
5
|
+
var children = _ref.children,
|
|
6
|
+
title = _ref.title,
|
|
7
|
+
parents = _ref.parents;
|
|
8
|
+
var hasSeparator = parents.some(function (parent) {
|
|
9
|
+
return parent.key === TEXT_COLLAPSED_MENU.key;
|
|
10
|
+
});
|
|
11
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
12
|
+
hasSeparator: hasSeparator,
|
|
13
|
+
title: title
|
|
14
|
+
}, children);
|
|
15
|
+
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
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';
|
|
4
|
+
import { ALIGNMENT_GROUP, ALIGNMENT_GROUP_RANK, ALIGNMENT_MENU, ALIGNMENT_MENU_SECTION, TEXT_SECTION, TEXT_SECTION_RANK, ALIGNMENT_MENU_RANK, TEXT_COLLAPSED_MENU_RANK, TEXT_COLLAPSED_MENU } from '@atlaskit/editor-common/toolbar';
|
|
5
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
6
|
import { AlignmentMenu } from './Toolbar/AlignmentMenu';
|
|
6
7
|
import { AlignmentMenuItem } from './Toolbar/AlignmentMenuItem';
|
|
8
|
+
import { MenuSection } from './Toolbar/MenuSection';
|
|
7
9
|
import { alignmentOptions } from './Toolbar/options';
|
|
8
10
|
var getAlignmentMenuItems = function getAlignmentMenuItems(api) {
|
|
9
11
|
return Object.entries(alignmentOptions()).map(function (_ref) {
|
|
@@ -63,6 +65,11 @@ export var getToolbarComponents = function getToolbarComponents(api) {
|
|
|
63
65
|
type: ALIGNMENT_MENU.type,
|
|
64
66
|
key: ALIGNMENT_MENU.key,
|
|
65
67
|
rank: ALIGNMENT_MENU_RANK[ALIGNMENT_MENU_SECTION.key]
|
|
66
|
-
}]
|
|
68
|
+
}].concat(_toConsumableArray(expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? [{
|
|
69
|
+
type: TEXT_COLLAPSED_MENU.type,
|
|
70
|
+
key: TEXT_COLLAPSED_MENU.key,
|
|
71
|
+
rank: TEXT_COLLAPSED_MENU_RANK[ALIGNMENT_MENU_SECTION.key]
|
|
72
|
+
}] : [])),
|
|
73
|
+
component: expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? MenuSection : undefined
|
|
67
74
|
}].concat(_toConsumableArray(getAlignmentMenuItems(api)));
|
|
68
75
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import type { CommonComponentProps } from '@atlaskit/editor-toolbar-model';
|
|
3
|
+
export declare const MenuSection: ({ children, title, parents, }: {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
parents: CommonComponentProps["parents"];
|
|
6
|
+
title?: string;
|
|
7
|
+
}) => React.JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import type { CommonComponentProps } from '@atlaskit/editor-toolbar-model';
|
|
3
|
+
export declare const MenuSection: ({ children, title, parents, }: {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
parents: CommonComponentProps["parents"];
|
|
6
|
+
title?: string;
|
|
7
|
+
}) => React.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-alignment",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Alignment plugin for @atlaskit/editor-core",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -32,22 +32,22 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@atlaskit/adf-schema": "^50.2.3",
|
|
34
34
|
"@atlaskit/css": "^0.12.0",
|
|
35
|
-
"@atlaskit/editor-plugin-analytics": "^
|
|
36
|
-
"@atlaskit/editor-plugin-primary-toolbar": "^
|
|
37
|
-
"@atlaskit/editor-plugin-selection-toolbar": "^
|
|
38
|
-
"@atlaskit/editor-plugin-toolbar": "^0.
|
|
35
|
+
"@atlaskit/editor-plugin-analytics": "^4.0.0",
|
|
36
|
+
"@atlaskit/editor-plugin-primary-toolbar": "^5.0.0",
|
|
37
|
+
"@atlaskit/editor-plugin-selection-toolbar": "^5.0.0",
|
|
38
|
+
"@atlaskit/editor-plugin-toolbar": "^1.0.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
40
40
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
41
|
-
"@atlaskit/editor-toolbar": "^0.
|
|
41
|
+
"@atlaskit/editor-toolbar": "^0.6.0",
|
|
42
42
|
"@atlaskit/icon": "^28.1.0",
|
|
43
43
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
44
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
44
|
+
"@atlaskit/tmp-editor-statsig": "^12.0.0",
|
|
45
45
|
"@atlaskit/tokens": "^6.1.0",
|
|
46
46
|
"@babel/runtime": "^7.0.0",
|
|
47
47
|
"@compiled/react": "^0.18.3"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@atlaskit/editor-common": "^
|
|
50
|
+
"@atlaskit/editor-common": "^108.0.0",
|
|
51
51
|
"react": "^18.2.0",
|
|
52
52
|
"react-dom": "^18.2.0",
|
|
53
53
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@af/integration-testing": "workspace:^",
|
|
57
57
|
"@af/visual-regression": "workspace:^",
|
|
58
|
-
"@atlaskit/editor-plugin-list": "^
|
|
58
|
+
"@atlaskit/editor-plugin-list": "^6.0.0",
|
|
59
59
|
"@atlaskit/ssr": "workspace:^",
|
|
60
60
|
"@testing-library/react": "^13.4.0",
|
|
61
61
|
"@testing-library/user-event": "^14.4.3",
|