@atlaskit/editor-plugin-toolbar-lists-indentation 3.2.3 → 3.2.5
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 +15 -0
- package/dist/cjs/pm-plugins/indentation-buttons.js +1 -1
- package/dist/cjs/toolbarListsIndentationPlugin.js +51 -22
- package/dist/cjs/ui/FloatingToolbarComponent.js +51 -22
- package/dist/es2019/pm-plugins/indentation-buttons.js +1 -1
- package/dist/es2019/toolbarListsIndentationPlugin.js +53 -23
- package/dist/es2019/ui/FloatingToolbarComponent.js +53 -23
- package/dist/esm/pm-plugins/indentation-buttons.js +1 -1
- package/dist/esm/toolbarListsIndentationPlugin.js +52 -23
- package/dist/esm/ui/FloatingToolbarComponent.js +52 -23
- package/dist/types/pm-plugins/indentation-buttons.d.ts +3 -3
- package/dist/types-ts4.5/pm-plugins/indentation-buttons.d.ts +3 -3
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-toolbar-lists-indentation
|
|
2
2
|
|
|
3
|
+
## 3.2.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#154149](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/154149)
|
|
8
|
+
[`4b955e247c793`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4b955e247c793) -
|
|
9
|
+
[ED-27560] Migrate to useSharedPluginStateSelector for text color, toolbar lists indentation,
|
|
10
|
+
type-ahead, undo-redo plugins
|
|
11
|
+
|
|
12
|
+
## 3.2.4
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 3.2.3
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -45,7 +45,7 @@ function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndenta
|
|
|
45
45
|
var isInLayoutNode = (0, _utils.hasParentNodeOfType)(editorState.schema.nodes.layoutColumn)(selection) &&
|
|
46
46
|
// depth of non-nested paragraphs and headings in layouts will always be 3
|
|
47
47
|
selection.$from.depth === 3;
|
|
48
|
-
if (allowHeadingAndParagraphIndentation && ((_indentationState$isI = indentationState === null || indentationState === void 0 ? void 0 : indentationState.isIndentationAllowed) !== null && _indentationState$isI !== void 0 ? _indentationState$isI : false) && (isTopLevelParagraphOrHeading || isInLayoutNode) && indentationState) {
|
|
48
|
+
if (allowHeadingAndParagraphIndentation && ((_indentationState$isI = indentationState === null || indentationState === void 0 ? void 0 : indentationState.isIndentationAllowed) !== null && _indentationState$isI !== void 0 ? _indentationState$isI : false) && (isTopLevelParagraphOrHeading || isInLayoutNode) && (indentationState === null || indentationState === void 0 ? void 0 : indentationState.indentDisabled) !== undefined && (indentationState === null || indentationState === void 0 ? void 0 : indentationState.outdentDisabled) !== undefined) {
|
|
49
49
|
return {
|
|
50
50
|
indentDisabled: indentationState.indentDisabled,
|
|
51
51
|
outdentDisabled: indentationState.outdentDisabled,
|
|
@@ -12,6 +12,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
13
13
|
var _types = require("@atlaskit/editor-common/types");
|
|
14
14
|
var _usePluginStateEffect = require("@atlaskit/editor-common/use-plugin-state-effect");
|
|
15
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
15
16
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
16
17
|
var _indentationButtons = require("./pm-plugins/indentation-buttons");
|
|
17
18
|
var _types2 = require("./types");
|
|
@@ -93,6 +94,37 @@ var toolbarListsIndentationPlugin = exports.toolbarListsIndentationPlugin = func
|
|
|
93
94
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
94
95
|
};
|
|
95
96
|
};
|
|
97
|
+
var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
|
|
98
|
+
var bulletListActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'list.bulletListActive');
|
|
99
|
+
var bulletListDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'list.bulletListDisabled');
|
|
100
|
+
var orderedListActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'list.orderedListActive');
|
|
101
|
+
var orderedListDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'list.orderedListDisabled');
|
|
102
|
+
var isIndentationAllowed = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'indentation.isIndentationAllowed');
|
|
103
|
+
var indentDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'indentation.indentDisabled');
|
|
104
|
+
var outdentDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'indentation.outdentDisabled');
|
|
105
|
+
return {
|
|
106
|
+
bulletListActive: bulletListActive,
|
|
107
|
+
bulletListDisabled: bulletListDisabled,
|
|
108
|
+
orderedListActive: orderedListActive,
|
|
109
|
+
orderedListDisabled: orderedListDisabled,
|
|
110
|
+
isIndentationAllowed: isIndentationAllowed,
|
|
111
|
+
indentDisabled: indentDisabled,
|
|
112
|
+
outdentDisabled: outdentDisabled
|
|
113
|
+
};
|
|
114
|
+
}, function (api) {
|
|
115
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['list', 'indentation']),
|
|
116
|
+
listState = _useSharedPluginState.listState,
|
|
117
|
+
indentationState = _useSharedPluginState.indentationState;
|
|
118
|
+
return {
|
|
119
|
+
bulletListActive: listState === null || listState === void 0 ? void 0 : listState.bulletListActive,
|
|
120
|
+
bulletListDisabled: listState === null || listState === void 0 ? void 0 : listState.bulletListDisabled,
|
|
121
|
+
orderedListActive: listState === null || listState === void 0 ? void 0 : listState.orderedListActive,
|
|
122
|
+
orderedListDisabled: listState === null || listState === void 0 ? void 0 : listState.orderedListDisabled,
|
|
123
|
+
isIndentationAllowed: indentationState === null || indentationState === void 0 ? void 0 : indentationState.isIndentationAllowed,
|
|
124
|
+
indentDisabled: indentationState === null || indentationState === void 0 ? void 0 : indentationState.indentDisabled,
|
|
125
|
+
outdentDisabled: indentationState === null || indentationState === void 0 ? void 0 : indentationState.outdentDisabled
|
|
126
|
+
};
|
|
127
|
+
});
|
|
96
128
|
function PrimaryToolbarComponent(_ref4) {
|
|
97
129
|
var _pluginInjectionApi$l;
|
|
98
130
|
var featureFlags = _ref4.featureFlags,
|
|
@@ -106,9 +138,14 @@ function PrimaryToolbarComponent(_ref4) {
|
|
|
106
138
|
showIndentationButtons = _ref4.showIndentationButtons,
|
|
107
139
|
pluginInjectionApi = _ref4.pluginInjectionApi,
|
|
108
140
|
allowHeadingAndParagraphIndentation = _ref4.allowHeadingAndParagraphIndentation;
|
|
109
|
-
var
|
|
110
|
-
|
|
111
|
-
|
|
141
|
+
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
142
|
+
bulletListActive = _useSharedState.bulletListActive,
|
|
143
|
+
bulletListDisabled = _useSharedState.bulletListDisabled,
|
|
144
|
+
orderedListActive = _useSharedState.orderedListActive,
|
|
145
|
+
orderedListDisabled = _useSharedState.orderedListDisabled,
|
|
146
|
+
isIndentationAllowed = _useSharedState.isIndentationAllowed,
|
|
147
|
+
indentDisabled = _useSharedState.indentDisabled,
|
|
148
|
+
outdentDisabled = _useSharedState.outdentDisabled;
|
|
112
149
|
var _useState = (0, _react.useState)(),
|
|
113
150
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
114
151
|
taskDecisionState = _useState2[0],
|
|
@@ -123,8 +160,12 @@ function PrimaryToolbarComponent(_ref4) {
|
|
|
123
160
|
});
|
|
124
161
|
}
|
|
125
162
|
});
|
|
126
|
-
var toolbarListsIndentationState = (0, _indentationButtons.getIndentationButtonsState)(editorView.state, allowHeadingAndParagraphIndentation, taskDecisionState,
|
|
127
|
-
|
|
163
|
+
var toolbarListsIndentationState = (0, _indentationButtons.getIndentationButtonsState)(editorView.state, allowHeadingAndParagraphIndentation, taskDecisionState, {
|
|
164
|
+
isIndentationAllowed: isIndentationAllowed,
|
|
165
|
+
indentDisabled: indentDisabled,
|
|
166
|
+
outdentDisabled: outdentDisabled
|
|
167
|
+
}, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$l = pluginInjectionApi.list) === null || _pluginInjectionApi$l === void 0 ? void 0 : _pluginInjectionApi$l.actions.isInsideListItem);
|
|
168
|
+
if (bulletListActive === undefined || bulletListDisabled === undefined || orderedListActive === undefined || orderedListDisabled === undefined) {
|
|
128
169
|
return null;
|
|
129
170
|
}
|
|
130
171
|
return /*#__PURE__*/_react.default.createElement(_ui.default, {
|
|
@@ -135,23 +176,11 @@ function PrimaryToolbarComponent(_ref4) {
|
|
|
135
176
|
editorView: editorView,
|
|
136
177
|
popupsMountPoint: popupsMountPoint,
|
|
137
178
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
138
|
-
popupsScrollableElement: popupsScrollableElement
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
,
|
|
142
|
-
|
|
143
|
-
// Ignored via go/ees005
|
|
144
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
145
|
-
,
|
|
146
|
-
bulletListDisabled: listState.bulletListDisabled
|
|
147
|
-
// Ignored via go/ees005
|
|
148
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
149
|
-
,
|
|
150
|
-
orderedListActive: listState.orderedListActive
|
|
151
|
-
// Ignored via go/ees005
|
|
152
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
153
|
-
,
|
|
154
|
-
orderedListDisabled: listState.orderedListDisabled,
|
|
179
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
180
|
+
bulletListActive: bulletListActive,
|
|
181
|
+
bulletListDisabled: bulletListDisabled,
|
|
182
|
+
orderedListActive: orderedListActive,
|
|
183
|
+
orderedListDisabled: orderedListDisabled,
|
|
155
184
|
showIndentationButtons: !!showIndentationButtons
|
|
156
185
|
// Ignored via go/ees005
|
|
157
186
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -10,6 +10,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
12
12
|
var _usePluginStateEffect = require("@atlaskit/editor-common/use-plugin-state-effect");
|
|
13
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
13
14
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
14
15
|
var _indentationButtons = require("../pm-plugins/indentation-buttons");
|
|
15
16
|
var _types = require("../types");
|
|
@@ -21,6 +22,37 @@ var FloatingToolbarSettings = {
|
|
|
21
22
|
isToolbarReducedSpacing: true,
|
|
22
23
|
isSmall: true
|
|
23
24
|
};
|
|
25
|
+
var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
|
|
26
|
+
var bulletListActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'list.bulletListActive');
|
|
27
|
+
var bulletListDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'list.bulletListDisabled');
|
|
28
|
+
var orderedListActive = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'list.orderedListActive');
|
|
29
|
+
var orderedListDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'list.orderedListDisabled');
|
|
30
|
+
var isIndentationAllowed = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'indentation.isIndentationAllowed');
|
|
31
|
+
var indentDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'indentation.indentDisabled');
|
|
32
|
+
var outdentDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'indentation.outdentDisabled');
|
|
33
|
+
return {
|
|
34
|
+
bulletListActive: bulletListActive,
|
|
35
|
+
bulletListDisabled: bulletListDisabled,
|
|
36
|
+
orderedListActive: orderedListActive,
|
|
37
|
+
orderedListDisabled: orderedListDisabled,
|
|
38
|
+
isIndentationAllowed: isIndentationAllowed,
|
|
39
|
+
indentDisabled: indentDisabled,
|
|
40
|
+
outdentDisabled: outdentDisabled
|
|
41
|
+
};
|
|
42
|
+
}, function (api) {
|
|
43
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['list', 'indentation']),
|
|
44
|
+
listState = _useSharedPluginState.listState,
|
|
45
|
+
indentationState = _useSharedPluginState.indentationState;
|
|
46
|
+
return {
|
|
47
|
+
bulletListActive: listState === null || listState === void 0 ? void 0 : listState.bulletListActive,
|
|
48
|
+
bulletListDisabled: listState === null || listState === void 0 ? void 0 : listState.bulletListDisabled,
|
|
49
|
+
orderedListActive: listState === null || listState === void 0 ? void 0 : listState.orderedListActive,
|
|
50
|
+
orderedListDisabled: listState === null || listState === void 0 ? void 0 : listState.orderedListDisabled,
|
|
51
|
+
isIndentationAllowed: indentationState === null || indentationState === void 0 ? void 0 : indentationState.isIndentationAllowed,
|
|
52
|
+
indentDisabled: indentationState === null || indentationState === void 0 ? void 0 : indentationState.indentDisabled,
|
|
53
|
+
outdentDisabled: indentationState === null || indentationState === void 0 ? void 0 : indentationState.outdentDisabled
|
|
54
|
+
};
|
|
55
|
+
});
|
|
24
56
|
function FloatingToolbarComponent(_ref) {
|
|
25
57
|
var _pluginInjectionApi$l;
|
|
26
58
|
var featureFlags = _ref.featureFlags,
|
|
@@ -28,9 +60,14 @@ function FloatingToolbarComponent(_ref) {
|
|
|
28
60
|
showIndentationButtons = _ref.showIndentationButtons,
|
|
29
61
|
pluginInjectionApi = _ref.pluginInjectionApi,
|
|
30
62
|
allowHeadingAndParagraphIndentation = _ref.allowHeadingAndParagraphIndentation;
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
63
|
+
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
64
|
+
bulletListActive = _useSharedState.bulletListActive,
|
|
65
|
+
bulletListDisabled = _useSharedState.bulletListDisabled,
|
|
66
|
+
orderedListActive = _useSharedState.orderedListActive,
|
|
67
|
+
orderedListDisabled = _useSharedState.orderedListDisabled,
|
|
68
|
+
isIndentationAllowed = _useSharedState.isIndentationAllowed,
|
|
69
|
+
indentDisabled = _useSharedState.indentDisabled,
|
|
70
|
+
outdentDisabled = _useSharedState.outdentDisabled;
|
|
34
71
|
var _useState = (0, _react.useState)(),
|
|
35
72
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
36
73
|
taskDecisionState = _useState2[0],
|
|
@@ -45,8 +82,12 @@ function FloatingToolbarComponent(_ref) {
|
|
|
45
82
|
});
|
|
46
83
|
}
|
|
47
84
|
});
|
|
48
|
-
var toolbarListsIndentationState = (0, _indentationButtons.getIndentationButtonsState)(editorView.state, allowHeadingAndParagraphIndentation, taskDecisionState,
|
|
49
|
-
|
|
85
|
+
var toolbarListsIndentationState = (0, _indentationButtons.getIndentationButtonsState)(editorView.state, allowHeadingAndParagraphIndentation, taskDecisionState, {
|
|
86
|
+
isIndentationAllowed: isIndentationAllowed,
|
|
87
|
+
indentDisabled: indentDisabled,
|
|
88
|
+
outdentDisabled: outdentDisabled
|
|
89
|
+
}, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$l = pluginInjectionApi.list) === null || _pluginInjectionApi$l === void 0 ? void 0 : _pluginInjectionApi$l.actions.isInsideListItem);
|
|
90
|
+
if (bulletListActive === undefined || bulletListDisabled === undefined || orderedListActive === undefined || orderedListDisabled === undefined) {
|
|
50
91
|
return null;
|
|
51
92
|
}
|
|
52
93
|
return /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
@@ -54,23 +95,11 @@ function FloatingToolbarComponent(_ref) {
|
|
|
54
95
|
isSmall: FloatingToolbarSettings.isSmall,
|
|
55
96
|
isReducedSpacing: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? false : FloatingToolbarSettings.isToolbarReducedSpacing,
|
|
56
97
|
disabled: FloatingToolbarSettings.disabled,
|
|
57
|
-
editorView: editorView
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
,
|
|
61
|
-
|
|
62
|
-
// Ignored via go/ees005
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
64
|
-
,
|
|
65
|
-
bulletListDisabled: listState.bulletListDisabled
|
|
66
|
-
// Ignored via go/ees005
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
68
|
-
,
|
|
69
|
-
orderedListActive: listState.orderedListActive
|
|
70
|
-
// Ignored via go/ees005
|
|
71
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
72
|
-
,
|
|
73
|
-
orderedListDisabled: listState.orderedListDisabled,
|
|
98
|
+
editorView: editorView,
|
|
99
|
+
bulletListActive: bulletListActive,
|
|
100
|
+
bulletListDisabled: bulletListDisabled,
|
|
101
|
+
orderedListActive: orderedListActive,
|
|
102
|
+
orderedListDisabled: orderedListDisabled,
|
|
74
103
|
showIndentationButtons: !!showIndentationButtons
|
|
75
104
|
// Ignored via go/ees005
|
|
76
105
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -42,7 +42,7 @@ export function getIndentationButtonsState(editorState, allowHeadingAndParagraph
|
|
|
42
42
|
const isInLayoutNode = hasParentNodeOfType(editorState.schema.nodes.layoutColumn)(selection) &&
|
|
43
43
|
// depth of non-nested paragraphs and headings in layouts will always be 3
|
|
44
44
|
selection.$from.depth === 3;
|
|
45
|
-
if (allowHeadingAndParagraphIndentation && ((_indentationState$isI = indentationState === null || indentationState === void 0 ? void 0 : indentationState.isIndentationAllowed) !== null && _indentationState$isI !== void 0 ? _indentationState$isI : false) && (isTopLevelParagraphOrHeading || isInLayoutNode) && indentationState) {
|
|
45
|
+
if (allowHeadingAndParagraphIndentation && ((_indentationState$isI = indentationState === null || indentationState === void 0 ? void 0 : indentationState.isIndentationAllowed) !== null && _indentationState$isI !== void 0 ? _indentationState$isI : false) && (isTopLevelParagraphOrHeading || isInLayoutNode) && (indentationState === null || indentationState === void 0 ? void 0 : indentationState.indentDisabled) !== undefined && (indentationState === null || indentationState === void 0 ? void 0 : indentationState.outdentDisabled) !== undefined) {
|
|
46
46
|
return {
|
|
47
47
|
indentDisabled: indentationState.indentDisabled,
|
|
48
48
|
outdentDisabled: indentationState.outdentDisabled,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
2
|
+
import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
4
4
|
import { usePluginStateEffect } from '@atlaskit/editor-common/use-plugin-state-effect';
|
|
5
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
5
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
7
|
import { getIndentationButtonsState } from './pm-plugins/indentation-buttons';
|
|
7
8
|
import { ToolbarType } from './types';
|
|
@@ -82,6 +83,38 @@ export const toolbarListsIndentationPlugin = ({
|
|
|
82
83
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
83
84
|
};
|
|
84
85
|
};
|
|
86
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
87
|
+
const bulletListActive = useSharedPluginStateSelector(api, 'list.bulletListActive');
|
|
88
|
+
const bulletListDisabled = useSharedPluginStateSelector(api, 'list.bulletListDisabled');
|
|
89
|
+
const orderedListActive = useSharedPluginStateSelector(api, 'list.orderedListActive');
|
|
90
|
+
const orderedListDisabled = useSharedPluginStateSelector(api, 'list.orderedListDisabled');
|
|
91
|
+
const isIndentationAllowed = useSharedPluginStateSelector(api, 'indentation.isIndentationAllowed');
|
|
92
|
+
const indentDisabled = useSharedPluginStateSelector(api, 'indentation.indentDisabled');
|
|
93
|
+
const outdentDisabled = useSharedPluginStateSelector(api, 'indentation.outdentDisabled');
|
|
94
|
+
return {
|
|
95
|
+
bulletListActive,
|
|
96
|
+
bulletListDisabled,
|
|
97
|
+
orderedListActive,
|
|
98
|
+
orderedListDisabled,
|
|
99
|
+
isIndentationAllowed,
|
|
100
|
+
indentDisabled,
|
|
101
|
+
outdentDisabled
|
|
102
|
+
};
|
|
103
|
+
}, api => {
|
|
104
|
+
const {
|
|
105
|
+
listState,
|
|
106
|
+
indentationState
|
|
107
|
+
} = useSharedPluginState(api, ['list', 'indentation']);
|
|
108
|
+
return {
|
|
109
|
+
bulletListActive: listState === null || listState === void 0 ? void 0 : listState.bulletListActive,
|
|
110
|
+
bulletListDisabled: listState === null || listState === void 0 ? void 0 : listState.bulletListDisabled,
|
|
111
|
+
orderedListActive: listState === null || listState === void 0 ? void 0 : listState.orderedListActive,
|
|
112
|
+
orderedListDisabled: listState === null || listState === void 0 ? void 0 : listState.orderedListDisabled,
|
|
113
|
+
isIndentationAllowed: indentationState === null || indentationState === void 0 ? void 0 : indentationState.isIndentationAllowed,
|
|
114
|
+
indentDisabled: indentationState === null || indentationState === void 0 ? void 0 : indentationState.indentDisabled,
|
|
115
|
+
outdentDisabled: indentationState === null || indentationState === void 0 ? void 0 : indentationState.outdentDisabled
|
|
116
|
+
};
|
|
117
|
+
});
|
|
85
118
|
export function PrimaryToolbarComponent({
|
|
86
119
|
featureFlags,
|
|
87
120
|
popupsMountPoint,
|
|
@@ -97,9 +130,14 @@ export function PrimaryToolbarComponent({
|
|
|
97
130
|
}) {
|
|
98
131
|
var _pluginInjectionApi$l;
|
|
99
132
|
const {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
133
|
+
bulletListActive,
|
|
134
|
+
bulletListDisabled,
|
|
135
|
+
orderedListActive,
|
|
136
|
+
orderedListDisabled,
|
|
137
|
+
isIndentationAllowed,
|
|
138
|
+
indentDisabled,
|
|
139
|
+
outdentDisabled
|
|
140
|
+
} = useSharedState(pluginInjectionApi);
|
|
103
141
|
const [taskDecisionState, setTaskDecisionState] = useState();
|
|
104
142
|
usePluginStateEffect(pluginInjectionApi, ['taskDecision'], ({
|
|
105
143
|
taskDecisionState: newTaskDecisionState
|
|
@@ -112,8 +150,12 @@ export function PrimaryToolbarComponent({
|
|
|
112
150
|
});
|
|
113
151
|
}
|
|
114
152
|
});
|
|
115
|
-
const toolbarListsIndentationState = getIndentationButtonsState(editorView.state, allowHeadingAndParagraphIndentation, taskDecisionState,
|
|
116
|
-
|
|
153
|
+
const toolbarListsIndentationState = getIndentationButtonsState(editorView.state, allowHeadingAndParagraphIndentation, taskDecisionState, {
|
|
154
|
+
isIndentationAllowed,
|
|
155
|
+
indentDisabled,
|
|
156
|
+
outdentDisabled
|
|
157
|
+
}, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$l = pluginInjectionApi.list) === null || _pluginInjectionApi$l === void 0 ? void 0 : _pluginInjectionApi$l.actions.isInsideListItem);
|
|
158
|
+
if (bulletListActive === undefined || bulletListDisabled === undefined || orderedListActive === undefined || orderedListDisabled === undefined) {
|
|
117
159
|
return null;
|
|
118
160
|
}
|
|
119
161
|
return /*#__PURE__*/React.createElement(ToolbarListsIndentation, {
|
|
@@ -124,23 +166,11 @@ export function PrimaryToolbarComponent({
|
|
|
124
166
|
editorView: editorView,
|
|
125
167
|
popupsMountPoint: popupsMountPoint,
|
|
126
168
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
127
|
-
popupsScrollableElement: popupsScrollableElement
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
,
|
|
131
|
-
|
|
132
|
-
// Ignored via go/ees005
|
|
133
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
134
|
-
,
|
|
135
|
-
bulletListDisabled: listState.bulletListDisabled
|
|
136
|
-
// Ignored via go/ees005
|
|
137
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
138
|
-
,
|
|
139
|
-
orderedListActive: listState.orderedListActive
|
|
140
|
-
// Ignored via go/ees005
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
142
|
-
,
|
|
143
|
-
orderedListDisabled: listState.orderedListDisabled,
|
|
169
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
170
|
+
bulletListActive: bulletListActive,
|
|
171
|
+
bulletListDisabled: bulletListDisabled,
|
|
172
|
+
orderedListActive: orderedListActive,
|
|
173
|
+
orderedListDisabled: orderedListDisabled,
|
|
144
174
|
showIndentationButtons: !!showIndentationButtons
|
|
145
175
|
// Ignored via go/ees005
|
|
146
176
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
2
|
+
import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { usePluginStateEffect } from '@atlaskit/editor-common/use-plugin-state-effect';
|
|
4
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
4
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
6
|
import { getIndentationButtonsState } from '../pm-plugins/indentation-buttons';
|
|
6
7
|
import { ToolbarType } from '../types';
|
|
@@ -10,6 +11,38 @@ const FloatingToolbarSettings = {
|
|
|
10
11
|
isToolbarReducedSpacing: true,
|
|
11
12
|
isSmall: true
|
|
12
13
|
};
|
|
14
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(api => {
|
|
15
|
+
const bulletListActive = useSharedPluginStateSelector(api, 'list.bulletListActive');
|
|
16
|
+
const bulletListDisabled = useSharedPluginStateSelector(api, 'list.bulletListDisabled');
|
|
17
|
+
const orderedListActive = useSharedPluginStateSelector(api, 'list.orderedListActive');
|
|
18
|
+
const orderedListDisabled = useSharedPluginStateSelector(api, 'list.orderedListDisabled');
|
|
19
|
+
const isIndentationAllowed = useSharedPluginStateSelector(api, 'indentation.isIndentationAllowed');
|
|
20
|
+
const indentDisabled = useSharedPluginStateSelector(api, 'indentation.indentDisabled');
|
|
21
|
+
const outdentDisabled = useSharedPluginStateSelector(api, 'indentation.outdentDisabled');
|
|
22
|
+
return {
|
|
23
|
+
bulletListActive,
|
|
24
|
+
bulletListDisabled,
|
|
25
|
+
orderedListActive,
|
|
26
|
+
orderedListDisabled,
|
|
27
|
+
isIndentationAllowed,
|
|
28
|
+
indentDisabled,
|
|
29
|
+
outdentDisabled
|
|
30
|
+
};
|
|
31
|
+
}, api => {
|
|
32
|
+
const {
|
|
33
|
+
listState,
|
|
34
|
+
indentationState
|
|
35
|
+
} = useSharedPluginState(api, ['list', 'indentation']);
|
|
36
|
+
return {
|
|
37
|
+
bulletListActive: listState === null || listState === void 0 ? void 0 : listState.bulletListActive,
|
|
38
|
+
bulletListDisabled: listState === null || listState === void 0 ? void 0 : listState.bulletListDisabled,
|
|
39
|
+
orderedListActive: listState === null || listState === void 0 ? void 0 : listState.orderedListActive,
|
|
40
|
+
orderedListDisabled: listState === null || listState === void 0 ? void 0 : listState.orderedListDisabled,
|
|
41
|
+
isIndentationAllowed: indentationState === null || indentationState === void 0 ? void 0 : indentationState.isIndentationAllowed,
|
|
42
|
+
indentDisabled: indentationState === null || indentationState === void 0 ? void 0 : indentationState.indentDisabled,
|
|
43
|
+
outdentDisabled: indentationState === null || indentationState === void 0 ? void 0 : indentationState.outdentDisabled
|
|
44
|
+
};
|
|
45
|
+
});
|
|
13
46
|
export function FloatingToolbarComponent({
|
|
14
47
|
featureFlags,
|
|
15
48
|
editorView,
|
|
@@ -19,9 +52,14 @@ export function FloatingToolbarComponent({
|
|
|
19
52
|
}) {
|
|
20
53
|
var _pluginInjectionApi$l;
|
|
21
54
|
const {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
55
|
+
bulletListActive,
|
|
56
|
+
bulletListDisabled,
|
|
57
|
+
orderedListActive,
|
|
58
|
+
orderedListDisabled,
|
|
59
|
+
isIndentationAllowed,
|
|
60
|
+
indentDisabled,
|
|
61
|
+
outdentDisabled
|
|
62
|
+
} = useSharedState(pluginInjectionApi);
|
|
25
63
|
const [taskDecisionState, setTaskDecisionState] = useState();
|
|
26
64
|
usePluginStateEffect(pluginInjectionApi, ['taskDecision'], ({
|
|
27
65
|
taskDecisionState: newTaskDecisionState
|
|
@@ -34,8 +72,12 @@ export function FloatingToolbarComponent({
|
|
|
34
72
|
});
|
|
35
73
|
}
|
|
36
74
|
});
|
|
37
|
-
const toolbarListsIndentationState = getIndentationButtonsState(editorView.state, allowHeadingAndParagraphIndentation, taskDecisionState,
|
|
38
|
-
|
|
75
|
+
const toolbarListsIndentationState = getIndentationButtonsState(editorView.state, allowHeadingAndParagraphIndentation, taskDecisionState, {
|
|
76
|
+
isIndentationAllowed,
|
|
77
|
+
indentDisabled,
|
|
78
|
+
outdentDisabled
|
|
79
|
+
}, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$l = pluginInjectionApi.list) === null || _pluginInjectionApi$l === void 0 ? void 0 : _pluginInjectionApi$l.actions.isInsideListItem);
|
|
80
|
+
if (bulletListActive === undefined || bulletListDisabled === undefined || orderedListActive === undefined || orderedListDisabled === undefined) {
|
|
39
81
|
return null;
|
|
40
82
|
}
|
|
41
83
|
return /*#__PURE__*/React.createElement(ToolbarListsIndentation, {
|
|
@@ -43,23 +85,11 @@ export function FloatingToolbarComponent({
|
|
|
43
85
|
isSmall: FloatingToolbarSettings.isSmall,
|
|
44
86
|
isReducedSpacing: editorExperiment('platform_editor_controls', 'variant1') ? false : FloatingToolbarSettings.isToolbarReducedSpacing,
|
|
45
87
|
disabled: FloatingToolbarSettings.disabled,
|
|
46
|
-
editorView: editorView
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
,
|
|
50
|
-
|
|
51
|
-
// Ignored via go/ees005
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
53
|
-
,
|
|
54
|
-
bulletListDisabled: listState.bulletListDisabled
|
|
55
|
-
// Ignored via go/ees005
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
57
|
-
,
|
|
58
|
-
orderedListActive: listState.orderedListActive
|
|
59
|
-
// Ignored via go/ees005
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
61
|
-
,
|
|
62
|
-
orderedListDisabled: listState.orderedListDisabled,
|
|
88
|
+
editorView: editorView,
|
|
89
|
+
bulletListActive: bulletListActive,
|
|
90
|
+
bulletListDisabled: bulletListDisabled,
|
|
91
|
+
orderedListActive: orderedListActive,
|
|
92
|
+
orderedListDisabled: orderedListDisabled,
|
|
63
93
|
showIndentationButtons: !!showIndentationButtons
|
|
64
94
|
// Ignored via go/ees005
|
|
65
95
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -39,7 +39,7 @@ export function getIndentationButtonsState(editorState, allowHeadingAndParagraph
|
|
|
39
39
|
var isInLayoutNode = hasParentNodeOfType(editorState.schema.nodes.layoutColumn)(selection) &&
|
|
40
40
|
// depth of non-nested paragraphs and headings in layouts will always be 3
|
|
41
41
|
selection.$from.depth === 3;
|
|
42
|
-
if (allowHeadingAndParagraphIndentation && ((_indentationState$isI = indentationState === null || indentationState === void 0 ? void 0 : indentationState.isIndentationAllowed) !== null && _indentationState$isI !== void 0 ? _indentationState$isI : false) && (isTopLevelParagraphOrHeading || isInLayoutNode) && indentationState) {
|
|
42
|
+
if (allowHeadingAndParagraphIndentation && ((_indentationState$isI = indentationState === null || indentationState === void 0 ? void 0 : indentationState.isIndentationAllowed) !== null && _indentationState$isI !== void 0 ? _indentationState$isI : false) && (isTopLevelParagraphOrHeading || isInLayoutNode) && (indentationState === null || indentationState === void 0 ? void 0 : indentationState.indentDisabled) !== undefined && (indentationState === null || indentationState === void 0 ? void 0 : indentationState.outdentDisabled) !== undefined) {
|
|
43
43
|
return {
|
|
44
44
|
indentDisabled: indentationState.indentDisabled,
|
|
45
45
|
outdentDisabled: indentationState.outdentDisabled,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
5
5
|
import { usePluginStateEffect } from '@atlaskit/editor-common/use-plugin-state-effect';
|
|
6
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
6
7
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
8
|
import { getIndentationButtonsState } from './pm-plugins/indentation-buttons';
|
|
8
9
|
import { ToolbarType } from './types';
|
|
@@ -82,6 +83,37 @@ export var toolbarListsIndentationPlugin = function toolbarListsIndentationPlugi
|
|
|
82
83
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
83
84
|
};
|
|
84
85
|
};
|
|
86
|
+
var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
|
|
87
|
+
var bulletListActive = useSharedPluginStateSelector(api, 'list.bulletListActive');
|
|
88
|
+
var bulletListDisabled = useSharedPluginStateSelector(api, 'list.bulletListDisabled');
|
|
89
|
+
var orderedListActive = useSharedPluginStateSelector(api, 'list.orderedListActive');
|
|
90
|
+
var orderedListDisabled = useSharedPluginStateSelector(api, 'list.orderedListDisabled');
|
|
91
|
+
var isIndentationAllowed = useSharedPluginStateSelector(api, 'indentation.isIndentationAllowed');
|
|
92
|
+
var indentDisabled = useSharedPluginStateSelector(api, 'indentation.indentDisabled');
|
|
93
|
+
var outdentDisabled = useSharedPluginStateSelector(api, 'indentation.outdentDisabled');
|
|
94
|
+
return {
|
|
95
|
+
bulletListActive: bulletListActive,
|
|
96
|
+
bulletListDisabled: bulletListDisabled,
|
|
97
|
+
orderedListActive: orderedListActive,
|
|
98
|
+
orderedListDisabled: orderedListDisabled,
|
|
99
|
+
isIndentationAllowed: isIndentationAllowed,
|
|
100
|
+
indentDisabled: indentDisabled,
|
|
101
|
+
outdentDisabled: outdentDisabled
|
|
102
|
+
};
|
|
103
|
+
}, function (api) {
|
|
104
|
+
var _useSharedPluginState = useSharedPluginState(api, ['list', 'indentation']),
|
|
105
|
+
listState = _useSharedPluginState.listState,
|
|
106
|
+
indentationState = _useSharedPluginState.indentationState;
|
|
107
|
+
return {
|
|
108
|
+
bulletListActive: listState === null || listState === void 0 ? void 0 : listState.bulletListActive,
|
|
109
|
+
bulletListDisabled: listState === null || listState === void 0 ? void 0 : listState.bulletListDisabled,
|
|
110
|
+
orderedListActive: listState === null || listState === void 0 ? void 0 : listState.orderedListActive,
|
|
111
|
+
orderedListDisabled: listState === null || listState === void 0 ? void 0 : listState.orderedListDisabled,
|
|
112
|
+
isIndentationAllowed: indentationState === null || indentationState === void 0 ? void 0 : indentationState.isIndentationAllowed,
|
|
113
|
+
indentDisabled: indentationState === null || indentationState === void 0 ? void 0 : indentationState.indentDisabled,
|
|
114
|
+
outdentDisabled: indentationState === null || indentationState === void 0 ? void 0 : indentationState.outdentDisabled
|
|
115
|
+
};
|
|
116
|
+
});
|
|
85
117
|
export function PrimaryToolbarComponent(_ref4) {
|
|
86
118
|
var _pluginInjectionApi$l;
|
|
87
119
|
var featureFlags = _ref4.featureFlags,
|
|
@@ -95,9 +127,14 @@ export function PrimaryToolbarComponent(_ref4) {
|
|
|
95
127
|
showIndentationButtons = _ref4.showIndentationButtons,
|
|
96
128
|
pluginInjectionApi = _ref4.pluginInjectionApi,
|
|
97
129
|
allowHeadingAndParagraphIndentation = _ref4.allowHeadingAndParagraphIndentation;
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
|
|
130
|
+
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
131
|
+
bulletListActive = _useSharedState.bulletListActive,
|
|
132
|
+
bulletListDisabled = _useSharedState.bulletListDisabled,
|
|
133
|
+
orderedListActive = _useSharedState.orderedListActive,
|
|
134
|
+
orderedListDisabled = _useSharedState.orderedListDisabled,
|
|
135
|
+
isIndentationAllowed = _useSharedState.isIndentationAllowed,
|
|
136
|
+
indentDisabled = _useSharedState.indentDisabled,
|
|
137
|
+
outdentDisabled = _useSharedState.outdentDisabled;
|
|
101
138
|
var _useState = useState(),
|
|
102
139
|
_useState2 = _slicedToArray(_useState, 2),
|
|
103
140
|
taskDecisionState = _useState2[0],
|
|
@@ -112,8 +149,12 @@ export function PrimaryToolbarComponent(_ref4) {
|
|
|
112
149
|
});
|
|
113
150
|
}
|
|
114
151
|
});
|
|
115
|
-
var toolbarListsIndentationState = getIndentationButtonsState(editorView.state, allowHeadingAndParagraphIndentation, taskDecisionState,
|
|
116
|
-
|
|
152
|
+
var toolbarListsIndentationState = getIndentationButtonsState(editorView.state, allowHeadingAndParagraphIndentation, taskDecisionState, {
|
|
153
|
+
isIndentationAllowed: isIndentationAllowed,
|
|
154
|
+
indentDisabled: indentDisabled,
|
|
155
|
+
outdentDisabled: outdentDisabled
|
|
156
|
+
}, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$l = pluginInjectionApi.list) === null || _pluginInjectionApi$l === void 0 ? void 0 : _pluginInjectionApi$l.actions.isInsideListItem);
|
|
157
|
+
if (bulletListActive === undefined || bulletListDisabled === undefined || orderedListActive === undefined || orderedListDisabled === undefined) {
|
|
117
158
|
return null;
|
|
118
159
|
}
|
|
119
160
|
return /*#__PURE__*/React.createElement(ToolbarListsIndentation, {
|
|
@@ -124,23 +165,11 @@ export function PrimaryToolbarComponent(_ref4) {
|
|
|
124
165
|
editorView: editorView,
|
|
125
166
|
popupsMountPoint: popupsMountPoint,
|
|
126
167
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
127
|
-
popupsScrollableElement: popupsScrollableElement
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
,
|
|
131
|
-
|
|
132
|
-
// Ignored via go/ees005
|
|
133
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
134
|
-
,
|
|
135
|
-
bulletListDisabled: listState.bulletListDisabled
|
|
136
|
-
// Ignored via go/ees005
|
|
137
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
138
|
-
,
|
|
139
|
-
orderedListActive: listState.orderedListActive
|
|
140
|
-
// Ignored via go/ees005
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
142
|
-
,
|
|
143
|
-
orderedListDisabled: listState.orderedListDisabled,
|
|
168
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
169
|
+
bulletListActive: bulletListActive,
|
|
170
|
+
bulletListDisabled: bulletListDisabled,
|
|
171
|
+
orderedListActive: orderedListActive,
|
|
172
|
+
orderedListDisabled: orderedListDisabled,
|
|
144
173
|
showIndentationButtons: !!showIndentationButtons
|
|
145
174
|
// Ignored via go/ees005
|
|
146
175
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { usePluginStateEffect } from '@atlaskit/editor-common/use-plugin-state-effect';
|
|
5
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
5
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
7
|
import { getIndentationButtonsState } from '../pm-plugins/indentation-buttons';
|
|
7
8
|
import { ToolbarType } from '../types';
|
|
@@ -11,6 +12,37 @@ var FloatingToolbarSettings = {
|
|
|
11
12
|
isToolbarReducedSpacing: true,
|
|
12
13
|
isSmall: true
|
|
13
14
|
};
|
|
15
|
+
var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
|
|
16
|
+
var bulletListActive = useSharedPluginStateSelector(api, 'list.bulletListActive');
|
|
17
|
+
var bulletListDisabled = useSharedPluginStateSelector(api, 'list.bulletListDisabled');
|
|
18
|
+
var orderedListActive = useSharedPluginStateSelector(api, 'list.orderedListActive');
|
|
19
|
+
var orderedListDisabled = useSharedPluginStateSelector(api, 'list.orderedListDisabled');
|
|
20
|
+
var isIndentationAllowed = useSharedPluginStateSelector(api, 'indentation.isIndentationAllowed');
|
|
21
|
+
var indentDisabled = useSharedPluginStateSelector(api, 'indentation.indentDisabled');
|
|
22
|
+
var outdentDisabled = useSharedPluginStateSelector(api, 'indentation.outdentDisabled');
|
|
23
|
+
return {
|
|
24
|
+
bulletListActive: bulletListActive,
|
|
25
|
+
bulletListDisabled: bulletListDisabled,
|
|
26
|
+
orderedListActive: orderedListActive,
|
|
27
|
+
orderedListDisabled: orderedListDisabled,
|
|
28
|
+
isIndentationAllowed: isIndentationAllowed,
|
|
29
|
+
indentDisabled: indentDisabled,
|
|
30
|
+
outdentDisabled: outdentDisabled
|
|
31
|
+
};
|
|
32
|
+
}, function (api) {
|
|
33
|
+
var _useSharedPluginState = useSharedPluginState(api, ['list', 'indentation']),
|
|
34
|
+
listState = _useSharedPluginState.listState,
|
|
35
|
+
indentationState = _useSharedPluginState.indentationState;
|
|
36
|
+
return {
|
|
37
|
+
bulletListActive: listState === null || listState === void 0 ? void 0 : listState.bulletListActive,
|
|
38
|
+
bulletListDisabled: listState === null || listState === void 0 ? void 0 : listState.bulletListDisabled,
|
|
39
|
+
orderedListActive: listState === null || listState === void 0 ? void 0 : listState.orderedListActive,
|
|
40
|
+
orderedListDisabled: listState === null || listState === void 0 ? void 0 : listState.orderedListDisabled,
|
|
41
|
+
isIndentationAllowed: indentationState === null || indentationState === void 0 ? void 0 : indentationState.isIndentationAllowed,
|
|
42
|
+
indentDisabled: indentationState === null || indentationState === void 0 ? void 0 : indentationState.indentDisabled,
|
|
43
|
+
outdentDisabled: indentationState === null || indentationState === void 0 ? void 0 : indentationState.outdentDisabled
|
|
44
|
+
};
|
|
45
|
+
});
|
|
14
46
|
export function FloatingToolbarComponent(_ref) {
|
|
15
47
|
var _pluginInjectionApi$l;
|
|
16
48
|
var featureFlags = _ref.featureFlags,
|
|
@@ -18,9 +50,14 @@ export function FloatingToolbarComponent(_ref) {
|
|
|
18
50
|
showIndentationButtons = _ref.showIndentationButtons,
|
|
19
51
|
pluginInjectionApi = _ref.pluginInjectionApi,
|
|
20
52
|
allowHeadingAndParagraphIndentation = _ref.allowHeadingAndParagraphIndentation;
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
53
|
+
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
54
|
+
bulletListActive = _useSharedState.bulletListActive,
|
|
55
|
+
bulletListDisabled = _useSharedState.bulletListDisabled,
|
|
56
|
+
orderedListActive = _useSharedState.orderedListActive,
|
|
57
|
+
orderedListDisabled = _useSharedState.orderedListDisabled,
|
|
58
|
+
isIndentationAllowed = _useSharedState.isIndentationAllowed,
|
|
59
|
+
indentDisabled = _useSharedState.indentDisabled,
|
|
60
|
+
outdentDisabled = _useSharedState.outdentDisabled;
|
|
24
61
|
var _useState = useState(),
|
|
25
62
|
_useState2 = _slicedToArray(_useState, 2),
|
|
26
63
|
taskDecisionState = _useState2[0],
|
|
@@ -35,8 +72,12 @@ export function FloatingToolbarComponent(_ref) {
|
|
|
35
72
|
});
|
|
36
73
|
}
|
|
37
74
|
});
|
|
38
|
-
var toolbarListsIndentationState = getIndentationButtonsState(editorView.state, allowHeadingAndParagraphIndentation, taskDecisionState,
|
|
39
|
-
|
|
75
|
+
var toolbarListsIndentationState = getIndentationButtonsState(editorView.state, allowHeadingAndParagraphIndentation, taskDecisionState, {
|
|
76
|
+
isIndentationAllowed: isIndentationAllowed,
|
|
77
|
+
indentDisabled: indentDisabled,
|
|
78
|
+
outdentDisabled: outdentDisabled
|
|
79
|
+
}, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$l = pluginInjectionApi.list) === null || _pluginInjectionApi$l === void 0 ? void 0 : _pluginInjectionApi$l.actions.isInsideListItem);
|
|
80
|
+
if (bulletListActive === undefined || bulletListDisabled === undefined || orderedListActive === undefined || orderedListDisabled === undefined) {
|
|
40
81
|
return null;
|
|
41
82
|
}
|
|
42
83
|
return /*#__PURE__*/React.createElement(ToolbarListsIndentation, {
|
|
@@ -44,23 +85,11 @@ export function FloatingToolbarComponent(_ref) {
|
|
|
44
85
|
isSmall: FloatingToolbarSettings.isSmall,
|
|
45
86
|
isReducedSpacing: editorExperiment('platform_editor_controls', 'variant1') ? false : FloatingToolbarSettings.isToolbarReducedSpacing,
|
|
46
87
|
disabled: FloatingToolbarSettings.disabled,
|
|
47
|
-
editorView: editorView
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
,
|
|
51
|
-
|
|
52
|
-
// Ignored via go/ees005
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
54
|
-
,
|
|
55
|
-
bulletListDisabled: listState.bulletListDisabled
|
|
56
|
-
// Ignored via go/ees005
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
58
|
-
,
|
|
59
|
-
orderedListActive: listState.orderedListActive
|
|
60
|
-
// Ignored via go/ees005
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
62
|
-
,
|
|
63
|
-
orderedListDisabled: listState.orderedListDisabled,
|
|
88
|
+
editorView: editorView,
|
|
89
|
+
bulletListActive: bulletListActive,
|
|
90
|
+
bulletListDisabled: bulletListDisabled,
|
|
91
|
+
orderedListActive: orderedListActive,
|
|
92
|
+
orderedListDisabled: orderedListDisabled,
|
|
64
93
|
showIndentationButtons: !!showIndentationButtons
|
|
65
94
|
// Ignored via go/ees005
|
|
66
95
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -11,9 +11,9 @@ export interface TaskDecisionState {
|
|
|
11
11
|
outdentDisabled: boolean;
|
|
12
12
|
}
|
|
13
13
|
interface IndentationState {
|
|
14
|
-
isIndentationAllowed
|
|
15
|
-
indentDisabled
|
|
16
|
-
outdentDisabled
|
|
14
|
+
isIndentationAllowed?: boolean;
|
|
15
|
+
indentDisabled?: boolean;
|
|
16
|
+
outdentDisabled?: boolean;
|
|
17
17
|
}
|
|
18
18
|
export declare function getIndentationButtonsState(editorState: EditorState, allowHeadingAndParagraphIndentation: boolean, taskDecisionState: TaskDecisionState | undefined, indentationState: IndentationState | undefined, isInsideListItem: ((tr: Transaction) => boolean | undefined) | undefined): IndentationButtons;
|
|
19
19
|
export {};
|
|
@@ -11,9 +11,9 @@ export interface TaskDecisionState {
|
|
|
11
11
|
outdentDisabled: boolean;
|
|
12
12
|
}
|
|
13
13
|
interface IndentationState {
|
|
14
|
-
isIndentationAllowed
|
|
15
|
-
indentDisabled
|
|
16
|
-
outdentDisabled
|
|
14
|
+
isIndentationAllowed?: boolean;
|
|
15
|
+
indentDisabled?: boolean;
|
|
16
|
+
outdentDisabled?: boolean;
|
|
17
17
|
}
|
|
18
18
|
export declare function getIndentationButtonsState(editorState: EditorState, allowHeadingAndParagraphIndentation: boolean, taskDecisionState: TaskDecisionState | undefined, indentationState: IndentationState | undefined, isInsideListItem: ((tr: Transaction) => boolean | undefined) | undefined): IndentationButtons;
|
|
19
19
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-toolbar-lists-indentation",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.5",
|
|
4
4
|
"description": "Toolbar lists and indentation plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/css": "^0.10.0",
|
|
37
|
-
"@atlaskit/editor-common": "^
|
|
38
|
-
"@atlaskit/editor-plugin-analytics": "^2.
|
|
37
|
+
"@atlaskit/editor-common": "^105.2.0",
|
|
38
|
+
"@atlaskit/editor-plugin-analytics": "^2.3.0",
|
|
39
39
|
"@atlaskit/editor-plugin-block-type": "^5.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-feature-flags": "^1.4.0",
|
|
41
41
|
"@atlaskit/editor-plugin-indentation": "^2.1.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
48
48
|
"@atlaskit/icon": "^26.0.0",
|
|
49
49
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
50
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
50
|
+
"@atlaskit/tmp-editor-statsig": "^4.21.0",
|
|
51
51
|
"@atlaskit/tokens": "^4.8.0",
|
|
52
52
|
"@babel/runtime": "^7.0.0"
|
|
53
53
|
},
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@af/visual-regression": "workspace:^",
|
|
62
62
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
63
63
|
"@atlaskit/analytics-next": "^11.0.0",
|
|
64
|
-
"@atlaskit/editor-plugin-base": "^
|
|
64
|
+
"@atlaskit/editor-plugin-base": "^3.0.0",
|
|
65
65
|
"@atlaskit/editor-plugin-text-formatting": "^2.2.0",
|
|
66
66
|
"@atlaskit/ssr": "workspace:^",
|
|
67
67
|
"@atlaskit/visual-regression": "workspace:^",
|