@atlaskit/editor-core 189.4.1 → 189.4.2
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 +9 -0
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/presets/universal.js +2 -1
- package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +7 -3
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/presets/universal.js +2 -1
- package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +7 -3
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/presets/universal.js +2 -1
- package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +7 -3
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/package.json +10 -5
- package/dist/cjs/plugins/toolbar-lists-indentation/index.js +0 -91
- package/dist/cjs/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +0 -56
- package/dist/cjs/plugins/toolbar-lists-indentation/types.js +0 -5
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/Toolbar.js +0 -135
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +0 -168
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/index.js +0 -63
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +0 -53
- package/dist/es2019/plugins/toolbar-lists-indentation/index.js +0 -86
- package/dist/es2019/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +0 -53
- package/dist/es2019/plugins/toolbar-lists-indentation/types.js +0 -1
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/Toolbar.js +0 -123
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +0 -158
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/index.js +0 -58
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +0 -46
- package/dist/esm/plugins/toolbar-lists-indentation/index.js +0 -83
- package/dist/esm/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +0 -50
- package/dist/esm/plugins/toolbar-lists-indentation/types.js +0 -1
- package/dist/esm/plugins/toolbar-lists-indentation/ui/Toolbar.js +0 -124
- package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +0 -161
- package/dist/esm/plugins/toolbar-lists-indentation/ui/index.js +0 -56
- package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +0 -47
- package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +0 -33
- package/dist/types/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +0 -19
- package/dist/types/plugins/toolbar-lists-indentation/types.d.ts +0 -20
- package/dist/types/plugins/toolbar-lists-indentation/ui/Toolbar.d.ts +0 -4
- package/dist/types/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.d.ts +0 -9
- package/dist/types/plugins/toolbar-lists-indentation/ui/index.d.ts +0 -26
- package/dist/types/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +0 -9
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/index.d.ts +0 -33
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +0 -19
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/types.d.ts +0 -20
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/Toolbar.d.ts +0 -4
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.d.ts +0 -9
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/index.d.ts +0 -26
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +0 -9
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.ToolbarDropdown = ToolbarDropdown;
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
-
var _react = require("@emotion/react");
|
|
10
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
11
|
-
var _reactIntlNext = require("react-intl-next");
|
|
12
|
-
var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-down"));
|
|
13
|
-
var _bulletList = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/bullet-list"));
|
|
14
|
-
var _keymaps = require("../../../keymaps");
|
|
15
|
-
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
16
|
-
var _ToolbarButton = _interopRequireDefault(require("../../../ui/ToolbarButton"));
|
|
17
|
-
var _styles = require("../../../ui/styles");
|
|
18
|
-
var _styles2 = require("@atlaskit/editor-common/styles");
|
|
19
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
20
|
-
/** @jsx jsx */
|
|
21
|
-
|
|
22
|
-
function ToolbarDropdown(props) {
|
|
23
|
-
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
24
|
-
formatMessage = _useIntl.formatMessage;
|
|
25
|
-
var disabled = props.disabled,
|
|
26
|
-
isReducedSpacing = props.isReducedSpacing,
|
|
27
|
-
bulletListActive = props.bulletListActive,
|
|
28
|
-
orderedListActive = props.orderedListActive,
|
|
29
|
-
popupsMountPoint = props.popupsMountPoint,
|
|
30
|
-
popupsBoundariesElement = props.popupsBoundariesElement,
|
|
31
|
-
popupsScrollableElement = props.popupsScrollableElement,
|
|
32
|
-
onItemActivated = props.onItemActivated;
|
|
33
|
-
var _React$useState = _react2.default.useState(false),
|
|
34
|
-
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
|
|
35
|
-
isDropdownOpen = _React$useState2[0],
|
|
36
|
-
setIsDropdownOpen = _React$useState2[1];
|
|
37
|
-
var _React$useState3 = _react2.default.useState(false),
|
|
38
|
-
_React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
|
|
39
|
-
isOpenedByKeyboard = _React$useState4[0],
|
|
40
|
-
setOpenedByKeyboard = _React$useState4[1];
|
|
41
|
-
var labelLists = formatMessage(_messages.listMessages.lists);
|
|
42
|
-
var onOpenChange = function onOpenChange(attrs) {
|
|
43
|
-
setIsDropdownOpen(attrs.isDropdownOpen);
|
|
44
|
-
};
|
|
45
|
-
var handleTriggerClick = function handleTriggerClick() {
|
|
46
|
-
onOpenChange({
|
|
47
|
-
isDropdownOpen: !isDropdownOpen
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
var handleOnKeyDown = function handleOnKeyDown(event) {
|
|
51
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
52
|
-
event.preventDefault();
|
|
53
|
-
setIsDropdownOpen(!isDropdownOpen);
|
|
54
|
-
setOpenedByKeyboard(true);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
var items = useItems(props);
|
|
58
|
-
var handleOnItemActivated = function handleOnItemActivated(_ref) {
|
|
59
|
-
var item = _ref.item,
|
|
60
|
-
_ref$shouldCloseMenu = _ref.shouldCloseMenu,
|
|
61
|
-
shouldCloseMenu = _ref$shouldCloseMenu === void 0 ? true : _ref$shouldCloseMenu;
|
|
62
|
-
setIsDropdownOpen(!shouldCloseMenu);
|
|
63
|
-
return onItemActivated({
|
|
64
|
-
editorView: props.editorView,
|
|
65
|
-
buttonName: item.value.name
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
return (0, _react.jsx)("span", {
|
|
69
|
-
css: _styles2.wrapperStyle
|
|
70
|
-
}, (0, _react.jsx)(_uiMenu.DropdownMenuWithKeyboardNavigation, {
|
|
71
|
-
items: items,
|
|
72
|
-
onItemActivated: handleOnItemActivated,
|
|
73
|
-
mountTo: popupsMountPoint,
|
|
74
|
-
boundariesElement: popupsBoundariesElement,
|
|
75
|
-
scrollableElement: popupsScrollableElement,
|
|
76
|
-
isOpen: isDropdownOpen,
|
|
77
|
-
onOpenChange: onOpenChange,
|
|
78
|
-
fitHeight: 188,
|
|
79
|
-
fitWidth: 175,
|
|
80
|
-
shouldUseDefaultRole: true,
|
|
81
|
-
shouldFocusFirstItem: function shouldFocusFirstItem() {
|
|
82
|
-
if (isOpenedByKeyboard) {
|
|
83
|
-
setOpenedByKeyboard(false);
|
|
84
|
-
}
|
|
85
|
-
return isOpenedByKeyboard;
|
|
86
|
-
}
|
|
87
|
-
}, (0, _react.jsx)(_ToolbarButton.default, {
|
|
88
|
-
spacing: isReducedSpacing ? 'none' : 'default',
|
|
89
|
-
selected: bulletListActive || orderedListActive,
|
|
90
|
-
"aria-expanded": isDropdownOpen,
|
|
91
|
-
"aria-haspopup": true,
|
|
92
|
-
"aria-label": labelLists,
|
|
93
|
-
disabled: disabled,
|
|
94
|
-
onClick: handleTriggerClick,
|
|
95
|
-
onKeyDown: handleOnKeyDown,
|
|
96
|
-
title: labelLists,
|
|
97
|
-
iconBefore: (0, _react.jsx)("span", {
|
|
98
|
-
css: _styles2.wrapperStyle
|
|
99
|
-
}, (0, _react.jsx)(_bulletList.default, {
|
|
100
|
-
label: labelLists
|
|
101
|
-
}), (0, _react.jsx)("span", {
|
|
102
|
-
css: _styles2.expandIconWrapperStyle
|
|
103
|
-
}, (0, _react.jsx)(_chevronDown.default, {
|
|
104
|
-
label: ""
|
|
105
|
-
})))
|
|
106
|
-
})), (0, _react.jsx)("span", {
|
|
107
|
-
css: _styles2.separatorStyles
|
|
108
|
-
}));
|
|
109
|
-
}
|
|
110
|
-
function useItems(props) {
|
|
111
|
-
var _useIntl2 = (0, _reactIntlNext.useIntl)(),
|
|
112
|
-
formatMessage = _useIntl2.formatMessage;
|
|
113
|
-
var labelUnorderedList = formatMessage(_messages.listMessages.unorderedList);
|
|
114
|
-
var labelOrderedList = formatMessage(_messages.listMessages.orderedList);
|
|
115
|
-
var items = [{
|
|
116
|
-
key: 'unorderedList',
|
|
117
|
-
content: labelUnorderedList,
|
|
118
|
-
value: {
|
|
119
|
-
name: 'bullet_list'
|
|
120
|
-
},
|
|
121
|
-
isDisabled: props.bulletListDisabled,
|
|
122
|
-
isActive: Boolean(props.bulletListActive),
|
|
123
|
-
elemAfter: (0, _react.jsx)("div", {
|
|
124
|
-
css: _styles.shortcutStyle
|
|
125
|
-
}, (0, _keymaps.tooltip)(_keymaps.toggleBulletList))
|
|
126
|
-
}, {
|
|
127
|
-
key: 'orderedList',
|
|
128
|
-
content: labelOrderedList,
|
|
129
|
-
value: {
|
|
130
|
-
name: 'ordered_list'
|
|
131
|
-
},
|
|
132
|
-
isDisabled: props.orderedListDisabled,
|
|
133
|
-
isActive: Boolean(props.orderedListActive),
|
|
134
|
-
elemAfter: (0, _react.jsx)("div", {
|
|
135
|
-
css: _styles.shortcutStyle
|
|
136
|
-
}, (0, _keymaps.tooltip)(_keymaps.toggleOrderedList))
|
|
137
|
-
}];
|
|
138
|
-
if (props.showIndentationButtons) {
|
|
139
|
-
var labelIndent = formatMessage(_messages.indentationMessages.indent);
|
|
140
|
-
var labelOutdent = formatMessage(_messages.indentationMessages.outdent);
|
|
141
|
-
items.push({
|
|
142
|
-
key: 'outdent',
|
|
143
|
-
content: labelOutdent,
|
|
144
|
-
value: {
|
|
145
|
-
name: 'outdent'
|
|
146
|
-
},
|
|
147
|
-
isDisabled: props.outdentDisabled,
|
|
148
|
-
isActive: false,
|
|
149
|
-
elemAfter: (0, _react.jsx)("div", {
|
|
150
|
-
css: _styles.shortcutStyle
|
|
151
|
-
}, (0, _keymaps.tooltip)(_keymaps.outdent))
|
|
152
|
-
}, {
|
|
153
|
-
key: 'indent',
|
|
154
|
-
content: labelIndent,
|
|
155
|
-
value: {
|
|
156
|
-
name: 'indent'
|
|
157
|
-
},
|
|
158
|
-
isDisabled: props.indentDisabled,
|
|
159
|
-
isActive: false,
|
|
160
|
-
elemAfter: (0, _react.jsx)("div", {
|
|
161
|
-
css: _styles.shortcutStyle
|
|
162
|
-
}, (0, _keymaps.tooltip)(_keymaps.indent))
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
return [{
|
|
166
|
-
items: items
|
|
167
|
-
}];
|
|
168
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = ToolbarListsIndentation;
|
|
7
|
-
var _react = require("@emotion/react");
|
|
8
|
-
var _onItemActivated = require("./onItemActivated");
|
|
9
|
-
var _ToolbarDropdown = require("./ToolbarDropdown");
|
|
10
|
-
var _Toolbar = require("./Toolbar");
|
|
11
|
-
/** @jsx jsx */
|
|
12
|
-
|
|
13
|
-
function ToolbarListsIndentation(props) {
|
|
14
|
-
var disabled = props.disabled,
|
|
15
|
-
isSmall = props.isSmall,
|
|
16
|
-
isReducedSpacing = props.isReducedSpacing,
|
|
17
|
-
bulletListActive = props.bulletListActive,
|
|
18
|
-
bulletListDisabled = props.bulletListDisabled,
|
|
19
|
-
orderedListActive = props.orderedListActive,
|
|
20
|
-
orderedListDisabled = props.orderedListDisabled,
|
|
21
|
-
showIndentationButtons = props.showIndentationButtons,
|
|
22
|
-
popupsMountPoint = props.popupsMountPoint,
|
|
23
|
-
popupsBoundariesElement = props.popupsBoundariesElement,
|
|
24
|
-
popupsScrollableElement = props.popupsScrollableElement,
|
|
25
|
-
indentDisabled = props.indentDisabled,
|
|
26
|
-
outdentDisabled = props.outdentDisabled,
|
|
27
|
-
indentationStateNode = props.indentationStateNode,
|
|
28
|
-
featureFlags = props.featureFlags,
|
|
29
|
-
pluginInjectionApi = props.pluginInjectionApi;
|
|
30
|
-
if (isSmall) {
|
|
31
|
-
return (0, _react.jsx)(_ToolbarDropdown.ToolbarDropdown, {
|
|
32
|
-
editorView: props.editorView,
|
|
33
|
-
isReducedSpacing: isReducedSpacing,
|
|
34
|
-
popupsMountPoint: popupsMountPoint,
|
|
35
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
36
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
37
|
-
bulletListActive: bulletListActive,
|
|
38
|
-
bulletListDisabled: bulletListDisabled,
|
|
39
|
-
showIndentationButtons: showIndentationButtons,
|
|
40
|
-
orderedListActive: orderedListActive,
|
|
41
|
-
orderedListDisabled: orderedListDisabled,
|
|
42
|
-
indentDisabled: indentDisabled,
|
|
43
|
-
outdentDisabled: outdentDisabled,
|
|
44
|
-
disabled: disabled,
|
|
45
|
-
onItemActivated: (0, _onItemActivated.onItemActivated)(pluginInjectionApi, indentationStateNode),
|
|
46
|
-
featureFlags: featureFlags
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return (0, _react.jsx)(_Toolbar.Toolbar, {
|
|
50
|
-
editorView: props.editorView,
|
|
51
|
-
isReducedSpacing: isReducedSpacing,
|
|
52
|
-
bulletListActive: bulletListActive,
|
|
53
|
-
bulletListDisabled: bulletListDisabled,
|
|
54
|
-
showIndentationButtons: showIndentationButtons,
|
|
55
|
-
orderedListActive: orderedListActive,
|
|
56
|
-
orderedListDisabled: orderedListDisabled,
|
|
57
|
-
indentDisabled: indentDisabled,
|
|
58
|
-
outdentDisabled: outdentDisabled,
|
|
59
|
-
disabled: disabled,
|
|
60
|
-
onItemActivated: (0, _onItemActivated.onItemActivated)(pluginInjectionApi, indentationStateNode),
|
|
61
|
-
featureFlags: featureFlags
|
|
62
|
-
});
|
|
63
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.onItemActivated = void 0;
|
|
7
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
-
var onItemActivated = exports.onItemActivated = function onItemActivated(pluginInjectionApi, indentationStateNode) {
|
|
9
|
-
return function (_ref) {
|
|
10
|
-
var buttonName = _ref.buttonName,
|
|
11
|
-
editorView = _ref.editorView;
|
|
12
|
-
switch (buttonName) {
|
|
13
|
-
case 'bullet_list':
|
|
14
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.toggleBulletList(_analytics.INPUT_METHOD.TOOLBAR));
|
|
15
|
-
break;
|
|
16
|
-
case 'ordered_list':
|
|
17
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.toggleOrderedList(_analytics.INPUT_METHOD.TOOLBAR));
|
|
18
|
-
break;
|
|
19
|
-
case 'indent':
|
|
20
|
-
{
|
|
21
|
-
var node = indentationStateNode;
|
|
22
|
-
if (node === 'paragraph_heading') {
|
|
23
|
-
var _pluginInjectionApi$i;
|
|
24
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$i = pluginInjectionApi.indentation) === null || _pluginInjectionApi$i === void 0 || _pluginInjectionApi$i.actions.indentParagraphOrHeading(_analytics.INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
25
|
-
}
|
|
26
|
-
if (node === 'list') {
|
|
27
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.indentList(_analytics.INPUT_METHOD.TOOLBAR));
|
|
28
|
-
}
|
|
29
|
-
if (node === 'taskList') {
|
|
30
|
-
var _pluginInjectionApi$t;
|
|
31
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$t = pluginInjectionApi.taskDecision) === null || _pluginInjectionApi$t === void 0 || _pluginInjectionApi$t.actions.indentTaskList(_analytics.INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
32
|
-
}
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
case 'outdent':
|
|
36
|
-
{
|
|
37
|
-
var _node = indentationStateNode;
|
|
38
|
-
if (_node === 'paragraph_heading') {
|
|
39
|
-
var _pluginInjectionApi$i2;
|
|
40
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$i2 = pluginInjectionApi.indentation) === null || _pluginInjectionApi$i2 === void 0 || _pluginInjectionApi$i2.actions.outdentParagraphOrHeading(_analytics.INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
41
|
-
}
|
|
42
|
-
if (_node === 'list') {
|
|
43
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.outdentList(_analytics.INPUT_METHOD.TOOLBAR));
|
|
44
|
-
}
|
|
45
|
-
if (_node === 'taskList') {
|
|
46
|
-
var _pluginInjectionApi$t2;
|
|
47
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$t2 = pluginInjectionApi.taskDecision) === null || _pluginInjectionApi$t2 === void 0 || _pluginInjectionApi$t2.actions.outdentTaskList(_analytics.INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
48
|
-
}
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
-
import ToolbarListsIndentation from './ui';
|
|
4
|
-
import { ToolbarSize } from '../../ui/Toolbar/types';
|
|
5
|
-
import { getIndentationButtonsState } from './pm-plugins/indentation-buttons';
|
|
6
|
-
const toolbarListsIndentationPlugin = ({
|
|
7
|
-
config,
|
|
8
|
-
api
|
|
9
|
-
}) => {
|
|
10
|
-
var _api$featureFlags;
|
|
11
|
-
const {
|
|
12
|
-
showIndentationButtons = false,
|
|
13
|
-
allowHeadingAndParagraphIndentation = false
|
|
14
|
-
} = config !== null && config !== void 0 ? config : {};
|
|
15
|
-
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
16
|
-
return {
|
|
17
|
-
name: 'toolbarListsIndentation',
|
|
18
|
-
primaryToolbarComponent({
|
|
19
|
-
editorView,
|
|
20
|
-
popupsMountPoint,
|
|
21
|
-
popupsBoundariesElement,
|
|
22
|
-
popupsScrollableElement,
|
|
23
|
-
toolbarSize,
|
|
24
|
-
disabled,
|
|
25
|
-
isToolbarReducedSpacing
|
|
26
|
-
}) {
|
|
27
|
-
const isSmall = toolbarSize < ToolbarSize.L;
|
|
28
|
-
return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
|
|
29
|
-
featureFlags: featureFlags,
|
|
30
|
-
popupsMountPoint: popupsMountPoint,
|
|
31
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
32
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
33
|
-
isSmall: isSmall,
|
|
34
|
-
isToolbarReducedSpacing: isToolbarReducedSpacing,
|
|
35
|
-
disabled: disabled,
|
|
36
|
-
editorView: editorView,
|
|
37
|
-
showIndentationButtons: showIndentationButtons,
|
|
38
|
-
pluginInjectionApi: api,
|
|
39
|
-
allowHeadingAndParagraphIndentation: allowHeadingAndParagraphIndentation
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
export function PrimaryToolbarComponent({
|
|
45
|
-
featureFlags,
|
|
46
|
-
popupsMountPoint,
|
|
47
|
-
popupsBoundariesElement,
|
|
48
|
-
popupsScrollableElement,
|
|
49
|
-
isSmall,
|
|
50
|
-
isToolbarReducedSpacing,
|
|
51
|
-
disabled,
|
|
52
|
-
editorView,
|
|
53
|
-
showIndentationButtons,
|
|
54
|
-
pluginInjectionApi,
|
|
55
|
-
allowHeadingAndParagraphIndentation
|
|
56
|
-
}) {
|
|
57
|
-
const {
|
|
58
|
-
listState,
|
|
59
|
-
indentationState,
|
|
60
|
-
taskDecisionState
|
|
61
|
-
} = useSharedPluginState(pluginInjectionApi, ['list', 'indentation', 'taskDecision']);
|
|
62
|
-
const toolbarListsIndentationState = getIndentationButtonsState(editorView.state, allowHeadingAndParagraphIndentation, taskDecisionState, indentationState, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.actions.isInsideListItem);
|
|
63
|
-
if (!listState) {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
return /*#__PURE__*/React.createElement(ToolbarListsIndentation, {
|
|
67
|
-
featureFlags: featureFlags,
|
|
68
|
-
isSmall: isSmall,
|
|
69
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
70
|
-
disabled: disabled,
|
|
71
|
-
editorView: editorView,
|
|
72
|
-
popupsMountPoint: popupsMountPoint,
|
|
73
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
74
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
75
|
-
bulletListActive: listState.bulletListActive,
|
|
76
|
-
bulletListDisabled: listState.bulletListDisabled,
|
|
77
|
-
orderedListActive: listState.orderedListActive,
|
|
78
|
-
orderedListDisabled: listState.orderedListDisabled,
|
|
79
|
-
showIndentationButtons: !!showIndentationButtons,
|
|
80
|
-
indentDisabled: toolbarListsIndentationState.indentDisabled,
|
|
81
|
-
outdentDisabled: toolbarListsIndentationState.outdentDisabled,
|
|
82
|
-
indentationStateNode: toolbarListsIndentationState === null || toolbarListsIndentationState === void 0 ? void 0 : toolbarListsIndentationState.node,
|
|
83
|
-
pluginInjectionApi: pluginInjectionApi
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
export default toolbarListsIndentationPlugin;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
2
|
-
import { getListItemAttributes } from '@atlaskit/editor-common/lists';
|
|
3
|
-
import { MAX_INDENTATION_LEVEL } from '@atlaskit/editor-common/indentation';
|
|
4
|
-
export function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndentation, taskDecisionState, indentationState, isInsideListItem) {
|
|
5
|
-
var _indentationState$isI;
|
|
6
|
-
const state = {
|
|
7
|
-
indentDisabled: true,
|
|
8
|
-
outdentDisabled: true,
|
|
9
|
-
node: null
|
|
10
|
-
};
|
|
11
|
-
const {
|
|
12
|
-
selection
|
|
13
|
-
} = editorState;
|
|
14
|
-
|
|
15
|
-
// Handle bullet and numbered lists seperately as they do
|
|
16
|
-
// not use the indentation mark.
|
|
17
|
-
// Check for lists before paragraphs and headings in case
|
|
18
|
-
// the selection is in a list nested in a layout column.
|
|
19
|
-
if (isInsideListItem !== null && isInsideListItem !== void 0 && isInsideListItem(editorState.tr)) {
|
|
20
|
-
const {
|
|
21
|
-
indentLevel,
|
|
22
|
-
itemIndex
|
|
23
|
-
} = getListItemAttributes(selection.$head);
|
|
24
|
-
return {
|
|
25
|
-
// List indent levels are zero indexed so we need to subtract 1
|
|
26
|
-
indentDisabled: itemIndex === 0 || indentLevel >= MAX_INDENTATION_LEVEL - 1,
|
|
27
|
-
outdentDisabled: false,
|
|
28
|
-
node: 'list'
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Handle tasks seperately as they do not use the indentation mark
|
|
33
|
-
// and have different behaviour for outdent compared to lists
|
|
34
|
-
if (taskDecisionState !== null && taskDecisionState !== void 0 && taskDecisionState.isInsideTask) {
|
|
35
|
-
return {
|
|
36
|
-
indentDisabled: taskDecisionState.indentDisabled,
|
|
37
|
-
outdentDisabled: taskDecisionState.outdentDisabled,
|
|
38
|
-
node: 'taskList'
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
const isTopLevelParagraphOrHeading = selection.$from.depth === 1;
|
|
42
|
-
const isInLayoutNode = hasParentNodeOfType(editorState.schema.nodes.layoutColumn)(selection) &&
|
|
43
|
-
// depth of non-nested paragraphs and headings in layouts will always be 3
|
|
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) {
|
|
46
|
-
return {
|
|
47
|
-
indentDisabled: indentationState.indentDisabled,
|
|
48
|
-
outdentDisabled: indentationState.outdentDisabled,
|
|
49
|
-
node: 'paragraph_heading'
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return state;
|
|
53
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/react';
|
|
3
|
-
import { useIntl } from 'react-intl-next';
|
|
4
|
-
import BulletListIcon from '@atlaskit/icon/glyph/editor/bullet-list';
|
|
5
|
-
import NumberListIcon from '@atlaskit/icon/glyph/editor/number-list';
|
|
6
|
-
import IndentIcon from '@atlaskit/icon/glyph/editor/indent';
|
|
7
|
-
import OutdentIcon from '@atlaskit/icon/glyph/editor/outdent';
|
|
8
|
-
import { toggleBulletList as toggleBulletListKeymap, toggleOrderedList as toggleOrderedListKeymap, indent as toggleIndentKeymap, outdent as toggleOutdentKeymap, ToolTipContent, tooltip } from '../../../keymaps';
|
|
9
|
-
import ToolbarButton, { TOOLBAR_BUTTON } from '../../../ui/ToolbarButton';
|
|
10
|
-
import { listMessages as messages, indentationMessages } from '@atlaskit/editor-common/messages';
|
|
11
|
-
import { separatorStyles, buttonGroupStyle } from '@atlaskit/editor-common/styles';
|
|
12
|
-
import { getAriaKeyshortcuts } from '@atlaskit/editor-common/keymaps';
|
|
13
|
-
import { useEffect, useRef } from 'react';
|
|
14
|
-
export function Toolbar(props) {
|
|
15
|
-
const {
|
|
16
|
-
formatMessage
|
|
17
|
-
} = useIntl();
|
|
18
|
-
const indentButtonRef = useRef(null);
|
|
19
|
-
const outdentButtonRef = useRef(null);
|
|
20
|
-
const {
|
|
21
|
-
disabled,
|
|
22
|
-
isReducedSpacing,
|
|
23
|
-
bulletListActive,
|
|
24
|
-
bulletListDisabled,
|
|
25
|
-
orderedListActive,
|
|
26
|
-
orderedListDisabled,
|
|
27
|
-
showIndentationButtons,
|
|
28
|
-
indentDisabled,
|
|
29
|
-
outdentDisabled,
|
|
30
|
-
onItemActivated
|
|
31
|
-
} = props;
|
|
32
|
-
const labelUnorderedList = formatMessage(messages.unorderedList);
|
|
33
|
-
const labelOrderedList = formatMessage(messages.orderedList);
|
|
34
|
-
const indentMessage = formatMessage(indentationMessages.indent);
|
|
35
|
-
const outdentMessage = formatMessage(indentationMessages.outdent);
|
|
36
|
-
const isIndentButtonFocused = document.activeElement === indentButtonRef.current;
|
|
37
|
-
const isOutdentButtonFocused = document.activeElement === outdentButtonRef.current;
|
|
38
|
-
const handleOnItemActivated = buttonName => event => onItemActivated({
|
|
39
|
-
editorView: props.editorView,
|
|
40
|
-
buttonName
|
|
41
|
-
});
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (isIndentButtonFocused && indentDisabled && outdentButtonRef.current) {
|
|
44
|
-
outdentButtonRef.current.focus();
|
|
45
|
-
}
|
|
46
|
-
}, [indentButtonRef, indentDisabled, isIndentButtonFocused]);
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
if (isOutdentButtonFocused && outdentDisabled && indentButtonRef.current) {
|
|
49
|
-
indentButtonRef.current.focus();
|
|
50
|
-
}
|
|
51
|
-
}, [outdentButtonRef, outdentDisabled, isOutdentButtonFocused]);
|
|
52
|
-
return jsx("span", {
|
|
53
|
-
css: buttonGroupStyle
|
|
54
|
-
}, jsx(ToolbarButton, {
|
|
55
|
-
buttonId: TOOLBAR_BUTTON.BULLET_LIST,
|
|
56
|
-
testId: labelUnorderedList,
|
|
57
|
-
spacing: isReducedSpacing ? 'none' : 'default',
|
|
58
|
-
onClick: handleOnItemActivated('bullet_list'),
|
|
59
|
-
selected: bulletListActive,
|
|
60
|
-
"aria-pressed": bulletListActive,
|
|
61
|
-
"aria-label": tooltip(toggleBulletListKeymap, labelUnorderedList),
|
|
62
|
-
"aria-keyshortcuts": getAriaKeyshortcuts(toggleBulletListKeymap),
|
|
63
|
-
disabled: bulletListDisabled || disabled,
|
|
64
|
-
title: jsx(ToolTipContent, {
|
|
65
|
-
description: labelUnorderedList,
|
|
66
|
-
keymap: toggleBulletListKeymap
|
|
67
|
-
}),
|
|
68
|
-
iconBefore: jsx(BulletListIcon, {
|
|
69
|
-
label: ""
|
|
70
|
-
})
|
|
71
|
-
}), jsx(ToolbarButton, {
|
|
72
|
-
buttonId: TOOLBAR_BUTTON.ORDERED_LIST,
|
|
73
|
-
testId: labelOrderedList,
|
|
74
|
-
spacing: isReducedSpacing ? 'none' : 'default',
|
|
75
|
-
onClick: handleOnItemActivated('ordered_list'),
|
|
76
|
-
selected: orderedListActive,
|
|
77
|
-
"aria-pressed": orderedListActive,
|
|
78
|
-
"aria-label": tooltip(toggleOrderedListKeymap, labelOrderedList),
|
|
79
|
-
"aria-keyshortcuts": getAriaKeyshortcuts(toggleOrderedListKeymap),
|
|
80
|
-
disabled: orderedListDisabled || disabled,
|
|
81
|
-
title: jsx(ToolTipContent, {
|
|
82
|
-
description: labelOrderedList,
|
|
83
|
-
keymap: toggleOrderedListKeymap
|
|
84
|
-
}),
|
|
85
|
-
iconBefore: jsx(NumberListIcon, {
|
|
86
|
-
label: ""
|
|
87
|
-
})
|
|
88
|
-
}), showIndentationButtons && jsx(ToolbarButton, {
|
|
89
|
-
buttonId: TOOLBAR_BUTTON.OUTDENT,
|
|
90
|
-
testId: TOOLBAR_BUTTON.OUTDENT,
|
|
91
|
-
ref: outdentButtonRef,
|
|
92
|
-
spacing: isReducedSpacing ? 'none' : 'default',
|
|
93
|
-
onClick: handleOnItemActivated('outdent'),
|
|
94
|
-
iconBefore: jsx(OutdentIcon, {
|
|
95
|
-
label: ""
|
|
96
|
-
}),
|
|
97
|
-
disabled: outdentDisabled || disabled,
|
|
98
|
-
"aria-label": tooltip(toggleOutdentKeymap, outdentMessage),
|
|
99
|
-
"aria-keyshortcuts": getAriaKeyshortcuts(toggleOutdentKeymap),
|
|
100
|
-
title: jsx(ToolTipContent, {
|
|
101
|
-
description: outdentMessage,
|
|
102
|
-
keymap: toggleOutdentKeymap
|
|
103
|
-
})
|
|
104
|
-
}), showIndentationButtons && jsx(ToolbarButton, {
|
|
105
|
-
buttonId: TOOLBAR_BUTTON.INDENT,
|
|
106
|
-
testId: TOOLBAR_BUTTON.INDENT,
|
|
107
|
-
ref: indentButtonRef,
|
|
108
|
-
spacing: isReducedSpacing ? 'none' : 'default',
|
|
109
|
-
onClick: handleOnItemActivated('indent'),
|
|
110
|
-
iconBefore: jsx(IndentIcon, {
|
|
111
|
-
label: ""
|
|
112
|
-
}),
|
|
113
|
-
disabled: indentDisabled || disabled,
|
|
114
|
-
"aria-label": tooltip(toggleIndentKeymap, indentMessage),
|
|
115
|
-
"aria-keyshortcuts": getAriaKeyshortcuts(toggleIndentKeymap),
|
|
116
|
-
title: jsx(ToolTipContent, {
|
|
117
|
-
description: indentMessage,
|
|
118
|
-
keymap: toggleIndentKeymap
|
|
119
|
-
})
|
|
120
|
-
}), jsx("span", {
|
|
121
|
-
css: separatorStyles
|
|
122
|
-
}));
|
|
123
|
-
}
|