@atlaskit/editor-plugin-toolbar-lists-indentation 11.1.6 → 11.2.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 +17 -0
- package/dist/cjs/ui/onItemActivated.js +13 -1
- package/dist/cjs/ui/toolbar-components/BulletedListMenuItem.js +27 -6
- package/dist/cjs/ui/toolbar-components/ListsIndentationHeroButton.js +52 -53
- package/dist/cjs/ui/toolbar-components/ListsIndentationMenu.js +10 -5
- package/dist/cjs/ui/toolbar-components/NumberedListMenuItem.js +27 -6
- package/dist/cjs/ui/toolbar-components/TaskListMenuItem.js +33 -4
- package/dist/cjs/ui/utils/markdown-compatible-toolbar.js +11 -0
- package/dist/es2019/ui/onItemActivated.js +13 -1
- package/dist/es2019/ui/toolbar-components/BulletedListMenuItem.js +27 -6
- package/dist/es2019/ui/toolbar-components/ListsIndentationHeroButton.js +52 -54
- package/dist/es2019/ui/toolbar-components/ListsIndentationMenu.js +10 -5
- package/dist/es2019/ui/toolbar-components/NumberedListMenuItem.js +27 -6
- package/dist/es2019/ui/toolbar-components/TaskListMenuItem.js +34 -4
- package/dist/es2019/ui/utils/markdown-compatible-toolbar.js +3 -0
- package/dist/esm/ui/onItemActivated.js +13 -1
- package/dist/esm/ui/toolbar-components/BulletedListMenuItem.js +27 -6
- package/dist/esm/ui/toolbar-components/ListsIndentationHeroButton.js +52 -53
- package/dist/esm/ui/toolbar-components/ListsIndentationMenu.js +10 -5
- package/dist/esm/ui/toolbar-components/NumberedListMenuItem.js +27 -6
- package/dist/esm/ui/toolbar-components/TaskListMenuItem.js +33 -4
- package/dist/esm/ui/utils/markdown-compatible-toolbar.js +5 -0
- package/dist/types/toolbarListsIndentationPluginType.d.ts +26 -0
- package/dist/types/ui/utils/markdown-compatible-toolbar.d.ts +1 -0
- package/dist/types-ts4.5/toolbarListsIndentationPluginType.d.ts +26 -0
- package/dist/types-ts4.5/ui/utils/markdown-compatible-toolbar.d.ts +1 -0
- package/package.json +10 -7
|
@@ -7,6 +7,7 @@ import { getInputMethodFromParentKeys } from '@atlaskit/editor-common/toolbar';
|
|
|
7
7
|
import { ListBulletedIcon, ListNumberedIcon, ToolbarButton, ToolbarTooltip } from '@atlaskit/editor-toolbar';
|
|
8
8
|
import TaskIcon from '@atlaskit/icon/core/task';
|
|
9
9
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
10
|
+
import { isMarkdownCompatibleToolbarEnabled } from '../utils/markdown-compatible-toolbar';
|
|
10
11
|
function useListsIndentationHeroButtonInfo({
|
|
11
12
|
api,
|
|
12
13
|
parents,
|
|
@@ -15,22 +16,33 @@ function useListsIndentationHeroButtonInfo({
|
|
|
15
16
|
const {
|
|
16
17
|
formatMessage
|
|
17
18
|
} = useIntl();
|
|
19
|
+
const isMarkdownToolbarEnabled = isMarkdownCompatibleToolbarEnabled();
|
|
18
20
|
const {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
pmBulletListActive,
|
|
22
|
+
pmBulletListDisabled,
|
|
23
|
+
pmOrderedListActive,
|
|
24
|
+
pmTaskListActive,
|
|
25
|
+
sourceBlockFormatState,
|
|
26
|
+
sourceListFormatState,
|
|
27
|
+
markdownView
|
|
28
|
+
} = useSharedPluginStateWithSelector(api, ['list', 'taskDecision', 'interaction', 'markdownMode'], states => {
|
|
29
|
+
var _states$interactionSt, _states$listState, _states$listState2, _states$listState3, _states$taskDecisionS, _states$markdownModeS, _states$markdownModeS2, _states$markdownModeS3;
|
|
25
30
|
const useDefaultToolbarState = ((_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState) === 'hasNotHadInteraction' && expValEquals('platform_editor_default_toolbar_state', 'isEnabled', true);
|
|
26
31
|
return {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
pmBulletListActive: useDefaultToolbarState ? false : (_states$listState = states.listState) === null || _states$listState === void 0 ? void 0 : _states$listState.bulletListActive,
|
|
33
|
+
pmBulletListDisabled: (_states$listState2 = states.listState) === null || _states$listState2 === void 0 ? void 0 : _states$listState2.bulletListDisabled,
|
|
34
|
+
pmOrderedListActive: useDefaultToolbarState ? false : (_states$listState3 = states.listState) === null || _states$listState3 === void 0 ? void 0 : _states$listState3.orderedListActive,
|
|
35
|
+
pmTaskListActive: useDefaultToolbarState ? false : (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask,
|
|
36
|
+
markdownView: isMarkdownToolbarEnabled ? (_states$markdownModeS = states.markdownModeState) === null || _states$markdownModeS === void 0 ? void 0 : _states$markdownModeS.view : undefined,
|
|
37
|
+
sourceBlockFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS2 = states.markdownModeState) === null || _states$markdownModeS2 === void 0 ? void 0 : _states$markdownModeS2.sourceBlockFormatState : null,
|
|
38
|
+
sourceListFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS3 = states.markdownModeState) === null || _states$markdownModeS3 === void 0 ? void 0 : _states$markdownModeS3.sourceListFormatState : null
|
|
31
39
|
};
|
|
32
40
|
});
|
|
33
|
-
const
|
|
41
|
+
const isInSourceView = isMarkdownToolbarEnabled && markdownView === 'syntax';
|
|
42
|
+
const isBulletListActive = isInSourceView ? sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inBulletList : pmBulletListActive;
|
|
43
|
+
const isOrderedListActive = isInSourceView ? sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inOrderedList : pmOrderedListActive;
|
|
44
|
+
const taskListActive = isInSourceView ? Boolean(sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inTaskList) : pmTaskListActive;
|
|
45
|
+
const getListType = taskListActive ? 'taskList' : isOrderedListActive ? 'orderedList' : defaultListType;
|
|
34
46
|
const taskListKeymap = toggleTaskListKeymap;
|
|
35
47
|
const getKeymap = getListType === 'taskList' ? taskListKeymap : getListType === 'orderedList' ? toggleOrderedListKeymap : toggleBulletListKeymap;
|
|
36
48
|
const shortcut = formatShortcut(getKeymap);
|
|
@@ -38,6 +50,19 @@ function useListsIndentationHeroButtonInfo({
|
|
|
38
50
|
const message = getListType === 'taskList' ? formatMessage(tasksAndDecisionsMessages.taskList) : getListType === 'orderedList' ? formatMessage(listMessages.orderedList) : formatMessage(listMessages.bulletedList);
|
|
39
51
|
const onClick = () => {
|
|
40
52
|
const inputMethod = getInputMethodFromParentKeys(parents);
|
|
53
|
+
if (isInSourceView) {
|
|
54
|
+
if (sourceBlockFormatState !== null && sourceBlockFormatState !== void 0 && sourceBlockFormatState.inCodeBlock || getListType === 'taskList') {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (getListType === 'orderedList') {
|
|
58
|
+
var _api$markdownMode;
|
|
59
|
+
api === null || api === void 0 ? void 0 : (_api$markdownMode = api.markdownMode) === null || _api$markdownMode === void 0 ? void 0 : _api$markdownMode.actions.toggleSourceOrderedList();
|
|
60
|
+
} else {
|
|
61
|
+
var _api$markdownMode2;
|
|
62
|
+
api === null || api === void 0 ? void 0 : (_api$markdownMode2 = api.markdownMode) === null || _api$markdownMode2 === void 0 ? void 0 : _api$markdownMode2.actions.toggleSourceBulletList();
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
41
66
|
if (getListType === 'taskList') {
|
|
42
67
|
var _api$taskDecision;
|
|
43
68
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$taskDecision = api.taskDecision) === null || _api$taskDecision === void 0 ? void 0 : _api$taskDecision.commands.toggleTaskList());
|
|
@@ -57,8 +82,8 @@ function useListsIndentationHeroButtonInfo({
|
|
|
57
82
|
label: formatMessage(listMessages.bulletedList),
|
|
58
83
|
size: "small"
|
|
59
84
|
});
|
|
60
|
-
const isSelected = getListType === 'bulletList' ?
|
|
61
|
-
const isDisabled = !
|
|
85
|
+
const isSelected = getListType === 'bulletList' ? isBulletListActive : getListType === 'orderedList' ? isOrderedListActive : taskListActive;
|
|
86
|
+
const isDisabled = isInSourceView ? Boolean((sourceBlockFormatState === null || sourceBlockFormatState === void 0 ? void 0 : sourceBlockFormatState.inCodeBlock) || taskListActive) : !isOrderedListActive && !taskListActive && pmBulletListDisabled;
|
|
62
87
|
return {
|
|
63
88
|
shortcut,
|
|
64
89
|
keymap,
|
|
@@ -134,50 +159,23 @@ export const ListsIndentationHeroButton = ({
|
|
|
134
159
|
parents
|
|
135
160
|
}) => {
|
|
136
161
|
const {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
bulletListActive: (_states$listState4 = states.listState) === null || _states$listState4 === void 0 ? void 0 : _states$listState4.bulletListActive,
|
|
148
|
-
bulletListDisabled: (_states$listState5 = states.listState) === null || _states$listState5 === void 0 ? void 0 : _states$listState5.bulletListDisabled,
|
|
149
|
-
orderedListActive: (_states$listState6 = states.listState) === null || _states$listState6 === void 0 ? void 0 : _states$listState6.orderedListActive,
|
|
150
|
-
taskListActive: (_states$taskDecisionS2 = states.taskDecisionState) === null || _states$taskDecisionS2 === void 0 ? void 0 : _states$taskDecisionS2.isInsideTask
|
|
151
|
-
};
|
|
162
|
+
shortcut,
|
|
163
|
+
message,
|
|
164
|
+
onClick,
|
|
165
|
+
iconBefore,
|
|
166
|
+
isSelected,
|
|
167
|
+
isDisabled
|
|
168
|
+
} = useListsIndentationHeroButtonInfo({
|
|
169
|
+
api,
|
|
170
|
+
parents,
|
|
171
|
+
defaultListType: 'bulletList'
|
|
152
172
|
});
|
|
153
|
-
const taskListKeymap = toggleTaskListKeymap;
|
|
154
|
-
const shortcut = taskListActive ? formatShortcut(taskListKeymap) : orderedListActive ? formatShortcut(toggleOrderedListKeymap) : formatShortcut(toggleBulletListKeymap);
|
|
155
|
-
const onClick = () => {
|
|
156
|
-
const inputMethod = getInputMethodFromParentKeys(parents);
|
|
157
|
-
if (taskListActive) {
|
|
158
|
-
var _api$taskDecision2;
|
|
159
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$taskDecision2 = api.taskDecision) === null || _api$taskDecision2 === void 0 ? void 0 : _api$taskDecision2.commands.toggleTaskList());
|
|
160
|
-
} else if (orderedListActive) {
|
|
161
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.list.commands.toggleOrderedList(inputMethod));
|
|
162
|
-
} else {
|
|
163
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.list.commands.toggleBulletList(inputMethod));
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
173
|
return /*#__PURE__*/React.createElement(ToolbarTooltip, {
|
|
167
|
-
content:
|
|
174
|
+
content: message
|
|
168
175
|
}, /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
169
|
-
iconBefore:
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}) : orderedListActive ? /*#__PURE__*/React.createElement(ListNumberedIcon, {
|
|
173
|
-
label: formatMessage(listMessages.orderedList),
|
|
174
|
-
size: "small"
|
|
175
|
-
}) : /*#__PURE__*/React.createElement(ListBulletedIcon, {
|
|
176
|
-
label: formatMessage(listMessages.bulletedList),
|
|
177
|
-
size: "small"
|
|
178
|
-
}),
|
|
179
|
-
isSelected: bulletListActive || orderedListActive || taskListActive,
|
|
180
|
-
isDisabled: !orderedListActive && !taskListActive && bulletListDisabled,
|
|
176
|
+
iconBefore: iconBefore,
|
|
177
|
+
isSelected: isSelected,
|
|
178
|
+
isDisabled: isDisabled,
|
|
181
179
|
ariaKeyshortcuts: shortcut,
|
|
182
180
|
onClick: onClick
|
|
183
181
|
}));
|
|
@@ -5,6 +5,7 @@ import { messages } from '@atlaskit/editor-common/lists';
|
|
|
5
5
|
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
6
6
|
import { MoreItemsIcon, ToolbarDropdownMenu, ToolbarTooltip } from '@atlaskit/editor-toolbar';
|
|
7
7
|
import { useIndentationState } from '../utils/hooks';
|
|
8
|
+
import { isMarkdownCompatibleToolbarEnabled } from '../utils/markdown-compatible-toolbar';
|
|
8
9
|
export const ListsIndentationMenu = ({
|
|
9
10
|
children,
|
|
10
11
|
api,
|
|
@@ -21,19 +22,23 @@ export const ListsIndentationMenu = ({
|
|
|
21
22
|
allowHeadingAndParagraphIndentation,
|
|
22
23
|
state: editorView === null || editorView === void 0 ? void 0 : editorView.state
|
|
23
24
|
});
|
|
25
|
+
const isMarkdownToolbarEnabled = isMarkdownCompatibleToolbarEnabled();
|
|
24
26
|
const {
|
|
25
27
|
bulletListDisabled,
|
|
26
28
|
orderedListDisabled,
|
|
27
|
-
taskListActive
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
taskListActive,
|
|
30
|
+
markdownView
|
|
31
|
+
} = useSharedPluginStateWithSelector(api, ['list', 'taskDecision', 'markdownMode'], states => {
|
|
32
|
+
var _states$listState, _states$listState2, _states$taskDecisionS, _states$markdownModeS;
|
|
30
33
|
return {
|
|
31
34
|
bulletListDisabled: (_states$listState = states.listState) === null || _states$listState === void 0 ? void 0 : _states$listState.bulletListDisabled,
|
|
32
35
|
orderedListDisabled: (_states$listState2 = states.listState) === null || _states$listState2 === void 0 ? void 0 : _states$listState2.orderedListDisabled,
|
|
33
|
-
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask
|
|
36
|
+
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask,
|
|
37
|
+
markdownView: isMarkdownToolbarEnabled ? (_states$markdownModeS = states.markdownModeState) === null || _states$markdownModeS === void 0 ? void 0 : _states$markdownModeS.view : undefined
|
|
34
38
|
};
|
|
35
39
|
});
|
|
36
|
-
const
|
|
40
|
+
const isInSourceView = isMarkdownToolbarEnabled && markdownView === 'syntax';
|
|
41
|
+
const allItemsDisabled = !isInSourceView && bulletListDisabled && orderedListDisabled && (indentationState === null || indentationState === void 0 ? void 0 : indentationState.indentDisabled) && (indentationState === null || indentationState === void 0 ? void 0 : indentationState.outdentDisabled) && !taskListActive;
|
|
37
42
|
return /*#__PURE__*/React.createElement(ToolbarDropdownMenu, {
|
|
38
43
|
iconBefore: /*#__PURE__*/React.createElement(MoreItemsIcon, {
|
|
39
44
|
label: formatMessage(messages.lists)
|
|
@@ -5,6 +5,7 @@ import { toggleOrderedList as toggleOrderedListKeymap, formatShortcut } from '@a
|
|
|
5
5
|
import { listMessages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { getInputMethodFromParentKeys } from '@atlaskit/editor-common/toolbar';
|
|
7
7
|
import { ListNumberedIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
8
|
+
import { isMarkdownCompatibleToolbarEnabled } from '../utils/markdown-compatible-toolbar';
|
|
8
9
|
export const NumberedListMenuItem = ({
|
|
9
10
|
api,
|
|
10
11
|
parents
|
|
@@ -12,20 +13,40 @@ export const NumberedListMenuItem = ({
|
|
|
12
13
|
const {
|
|
13
14
|
formatMessage
|
|
14
15
|
} = useIntl();
|
|
16
|
+
const isMarkdownToolbarEnabled = isMarkdownCompatibleToolbarEnabled();
|
|
15
17
|
const {
|
|
16
18
|
orderedListActive,
|
|
17
19
|
orderedListDisabled,
|
|
18
|
-
taskListActive
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
taskListActive,
|
|
21
|
+
sourceBlockFormatState,
|
|
22
|
+
sourceListFormatState,
|
|
23
|
+
markdownView
|
|
24
|
+
} = useSharedPluginStateWithSelector(api, ['list', 'taskDecision', 'markdownMode'], states => {
|
|
25
|
+
var _states$listState, _states$listState2, _states$taskDecisionS, _states$markdownModeS, _states$markdownModeS2, _states$markdownModeS3;
|
|
21
26
|
return {
|
|
22
27
|
orderedListActive: (_states$listState = states.listState) === null || _states$listState === void 0 ? void 0 : _states$listState.orderedListActive,
|
|
23
28
|
orderedListDisabled: (_states$listState2 = states.listState) === null || _states$listState2 === void 0 ? void 0 : _states$listState2.orderedListDisabled,
|
|
24
|
-
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask
|
|
29
|
+
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask,
|
|
30
|
+
markdownView: isMarkdownToolbarEnabled ? (_states$markdownModeS = states.markdownModeState) === null || _states$markdownModeS === void 0 ? void 0 : _states$markdownModeS.view : undefined,
|
|
31
|
+
sourceBlockFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS2 = states.markdownModeState) === null || _states$markdownModeS2 === void 0 ? void 0 : _states$markdownModeS2.sourceBlockFormatState : null,
|
|
32
|
+
sourceListFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS3 = states.markdownModeState) === null || _states$markdownModeS3 === void 0 ? void 0 : _states$markdownModeS3.sourceListFormatState : null
|
|
25
33
|
};
|
|
26
34
|
});
|
|
35
|
+
const isInSourceView = isMarkdownToolbarEnabled && markdownView === 'syntax';
|
|
36
|
+
const isSourceTaskListActive = Boolean(sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inTaskList);
|
|
27
37
|
const onClick = () => {
|
|
28
38
|
var _api$taskDecision;
|
|
39
|
+
if (isInSourceView) {
|
|
40
|
+
var _api$markdownMode;
|
|
41
|
+
if (sourceBlockFormatState !== null && sourceBlockFormatState !== void 0 && sourceBlockFormatState.inCodeBlock) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (isSourceTaskListActive) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
api === null || api === void 0 ? void 0 : (_api$markdownMode = api.markdownMode) === null || _api$markdownMode === void 0 ? void 0 : _api$markdownMode.actions.toggleSourceOrderedList();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
29
50
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(taskListActive ? api === null || api === void 0 ? void 0 : (_api$taskDecision = api.taskDecision) === null || _api$taskDecision === void 0 ? void 0 : _api$taskDecision.commands.toggleTaskList('orderedList') : api === null || api === void 0 ? void 0 : api.list.commands.toggleOrderedList(getInputMethodFromParentKeys(parents)));
|
|
30
51
|
};
|
|
31
52
|
const shortcut = formatShortcut(toggleOrderedListKeymap);
|
|
@@ -37,8 +58,8 @@ export const NumberedListMenuItem = ({
|
|
|
37
58
|
elemAfter: shortcut ? /*#__PURE__*/React.createElement(ToolbarKeyboardShortcutHint, {
|
|
38
59
|
shortcut: shortcut
|
|
39
60
|
}) : undefined,
|
|
40
|
-
isSelected: orderedListActive,
|
|
41
|
-
isDisabled: orderedListDisabled && !taskListActive,
|
|
61
|
+
isSelected: isInSourceView ? sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inOrderedList : orderedListActive,
|
|
62
|
+
isDisabled: isInSourceView ? Boolean((sourceBlockFormatState === null || sourceBlockFormatState === void 0 ? void 0 : sourceBlockFormatState.inCodeBlock) || isSourceTaskListActive) : orderedListDisabled && !taskListActive,
|
|
42
63
|
onClick: onClick,
|
|
43
64
|
ariaKeyshortcuts: shortcut
|
|
44
65
|
}, formatMessage(listMessages.orderedList));
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
4
|
import { tasksAndDecisionsMessages } from '@atlaskit/editor-common/messages';
|
|
4
5
|
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
5
|
-
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
6
6
|
import { ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
7
7
|
import TaskIcon from '@atlaskit/icon/core/task';
|
|
8
|
+
import { isMarkdownCompatibleToolbarEnabled } from '../utils/markdown-compatible-toolbar';
|
|
8
9
|
export const TaskListMenuItem = ({
|
|
9
10
|
api
|
|
10
11
|
}) => {
|
|
@@ -14,12 +15,41 @@ export const TaskListMenuItem = ({
|
|
|
14
15
|
const {
|
|
15
16
|
editorView
|
|
16
17
|
} = useEditorToolbar();
|
|
17
|
-
const
|
|
18
|
+
const isMarkdownToolbarEnabled = isMarkdownCompatibleToolbarEnabled();
|
|
19
|
+
// Mirror the sibling BulletedListMenuItem / NumberedListMenuItem pattern:
|
|
20
|
+
// gate the markdown-mode field reads behind the feature flag inside the
|
|
21
|
+
// selector so we don't trigger re-renders on CM6 state changes for users
|
|
22
|
+
// who don't have the markdown-compatible toolbar enabled.
|
|
23
|
+
const {
|
|
24
|
+
taskListActive,
|
|
25
|
+
markdownView,
|
|
26
|
+
sourceBlockFormatState,
|
|
27
|
+
sourceListFormatState
|
|
28
|
+
} = useSharedPluginStateWithSelector(api, ['taskDecision', 'markdownMode'], states => {
|
|
29
|
+
var _states$taskDecisionS, _states$markdownModeS, _states$markdownModeS2, _states$markdownModeS3;
|
|
30
|
+
return {
|
|
31
|
+
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask,
|
|
32
|
+
markdownView: isMarkdownToolbarEnabled ? (_states$markdownModeS = states.markdownModeState) === null || _states$markdownModeS === void 0 ? void 0 : _states$markdownModeS.view : undefined,
|
|
33
|
+
sourceBlockFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS2 = states.markdownModeState) === null || _states$markdownModeS2 === void 0 ? void 0 : _states$markdownModeS2.sourceBlockFormatState : null,
|
|
34
|
+
sourceListFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS3 = states.markdownModeState) === null || _states$markdownModeS3 === void 0 ? void 0 : _states$markdownModeS3.sourceListFormatState : null
|
|
35
|
+
};
|
|
36
|
+
});
|
|
18
37
|
if (!(editorView !== null && editorView !== void 0 && editorView.state.schema.nodes.taskItem)) {
|
|
19
38
|
return null;
|
|
20
39
|
}
|
|
40
|
+
const isInSourceView = isMarkdownToolbarEnabled && markdownView === 'syntax';
|
|
41
|
+
const isSelected = isInSourceView ? sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inTaskList : taskListActive;
|
|
42
|
+
const isDisabled = Boolean(isInSourceView && (sourceBlockFormatState === null || sourceBlockFormatState === void 0 ? void 0 : sourceBlockFormatState.inCodeBlock));
|
|
21
43
|
const handleClick = () => {
|
|
22
44
|
var _api$taskDecision;
|
|
45
|
+
if (isDisabled) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (isInSourceView) {
|
|
49
|
+
var _api$markdownMode;
|
|
50
|
+
api === null || api === void 0 ? void 0 : (_api$markdownMode = api.markdownMode) === null || _api$markdownMode === void 0 ? void 0 : _api$markdownMode.actions.toggleSourceTaskList();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
23
53
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$taskDecision = api.taskDecision) === null || _api$taskDecision === void 0 ? void 0 : _api$taskDecision.commands.toggleTaskList());
|
|
24
54
|
};
|
|
25
55
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
@@ -30,8 +60,8 @@ export const TaskListMenuItem = ({
|
|
|
30
60
|
elemAfter: /*#__PURE__*/React.createElement(ToolbarKeyboardShortcutHint, {
|
|
31
61
|
shortcut: "[]"
|
|
32
62
|
}),
|
|
33
|
-
isSelected:
|
|
34
|
-
isDisabled:
|
|
63
|
+
isSelected: isSelected,
|
|
64
|
+
isDisabled: isDisabled,
|
|
35
65
|
onClick: handleClick
|
|
36
66
|
}, formatMessage(tasksAndDecisionsMessages.taskList));
|
|
37
67
|
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
3
|
+
export const isMarkdownCompatibleToolbarEnabled = () => expValEqualsNoExposure('cc-markdown-mode', 'isEnabled', true) && fg('platform_editor_markdown_compatible_toolbar');
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
+
import { isMarkdownCompatibleToolbarEnabled } from './utils/markdown-compatible-toolbar';
|
|
1
2
|
export var onItemActivated = function onItemActivated(pluginInjectionApi, indentationStateNode, inputMethod) {
|
|
2
3
|
return function (_ref) {
|
|
3
|
-
var _pluginInjectionApi$c, _pluginInjectionApi$l, _pluginInjectionApi$c2, _pluginInjectionApi$l2;
|
|
4
|
+
var _pluginInjectionApi$m, _pluginInjectionApi$c, _pluginInjectionApi$l, _pluginInjectionApi$c2, _pluginInjectionApi$l2;
|
|
4
5
|
var buttonName = _ref.buttonName,
|
|
5
6
|
editorView = _ref.editorView;
|
|
7
|
+
var isInSourceView = isMarkdownCompatibleToolbarEnabled() && (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.markdownMode) === null || _pluginInjectionApi$m === void 0 || (_pluginInjectionApi$m = _pluginInjectionApi$m.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.view) === 'syntax';
|
|
6
8
|
switch (buttonName) {
|
|
7
9
|
case 'bullet_list':
|
|
10
|
+
if (isInSourceView) {
|
|
11
|
+
var _pluginInjectionApi$m2;
|
|
12
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m2 = pluginInjectionApi.markdownMode) === null || _pluginInjectionApi$m2 === void 0 || _pluginInjectionApi$m2.actions.toggleSourceBulletList();
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
8
15
|
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.core) === null || _pluginInjectionApi$c === void 0 || _pluginInjectionApi$c.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$l = pluginInjectionApi.list) === null || _pluginInjectionApi$l === void 0 ? void 0 : _pluginInjectionApi$l.commands.toggleBulletList(inputMethod));
|
|
9
16
|
break;
|
|
10
17
|
case 'ordered_list':
|
|
18
|
+
if (isInSourceView) {
|
|
19
|
+
var _pluginInjectionApi$m3;
|
|
20
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m3 = pluginInjectionApi.markdownMode) === null || _pluginInjectionApi$m3 === void 0 || _pluginInjectionApi$m3.actions.toggleSourceOrderedList();
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
11
23
|
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 || _pluginInjectionApi$c2.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$l2 = pluginInjectionApi.list) === null || _pluginInjectionApi$l2 === void 0 ? void 0 : _pluginInjectionApi$l2.commands.toggleOrderedList(inputMethod));
|
|
12
24
|
break;
|
|
13
25
|
case 'indent':
|
|
@@ -5,34 +5,55 @@ import { toggleBulletList as toggleBulletListKeymap, formatShortcut } from '@atl
|
|
|
5
5
|
import { listMessages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { getInputMethodFromParentKeys } from '@atlaskit/editor-common/toolbar';
|
|
7
7
|
import { ListBulletedIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
8
|
+
import { isMarkdownCompatibleToolbarEnabled } from '../utils/markdown-compatible-toolbar';
|
|
8
9
|
export var useBulletedListInfo = function useBulletedListInfo(_ref) {
|
|
9
10
|
var api = _ref.api,
|
|
10
11
|
parents = _ref.parents;
|
|
11
12
|
var _useIntl = useIntl(),
|
|
12
13
|
formatMessage = _useIntl.formatMessage;
|
|
13
14
|
var bulletMessage = formatMessage(listMessages.bulletedList);
|
|
14
|
-
var
|
|
15
|
-
|
|
15
|
+
var isMarkdownToolbarEnabled = isMarkdownCompatibleToolbarEnabled();
|
|
16
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['list', 'taskDecision', 'markdownMode'], function (states) {
|
|
17
|
+
var _states$listState, _states$listState2, _states$taskDecisionS, _states$markdownModeS, _states$markdownModeS2, _states$markdownModeS3;
|
|
16
18
|
return {
|
|
17
19
|
bulletListActive: (_states$listState = states.listState) === null || _states$listState === void 0 ? void 0 : _states$listState.bulletListActive,
|
|
18
20
|
bulletListDisabled: (_states$listState2 = states.listState) === null || _states$listState2 === void 0 ? void 0 : _states$listState2.bulletListDisabled,
|
|
19
|
-
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask
|
|
21
|
+
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask,
|
|
22
|
+
markdownView: isMarkdownToolbarEnabled ? (_states$markdownModeS = states.markdownModeState) === null || _states$markdownModeS === void 0 ? void 0 : _states$markdownModeS.view : undefined,
|
|
23
|
+
sourceBlockFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS2 = states.markdownModeState) === null || _states$markdownModeS2 === void 0 ? void 0 : _states$markdownModeS2.sourceBlockFormatState : null,
|
|
24
|
+
sourceListFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS3 = states.markdownModeState) === null || _states$markdownModeS3 === void 0 ? void 0 : _states$markdownModeS3.sourceListFormatState : null
|
|
20
25
|
};
|
|
21
26
|
}),
|
|
22
27
|
bulletListActive = _useSharedPluginState.bulletListActive,
|
|
23
28
|
bulletListDisabled = _useSharedPluginState.bulletListDisabled,
|
|
24
|
-
taskListActive = _useSharedPluginState.taskListActive
|
|
29
|
+
taskListActive = _useSharedPluginState.taskListActive,
|
|
30
|
+
sourceBlockFormatState = _useSharedPluginState.sourceBlockFormatState,
|
|
31
|
+
sourceListFormatState = _useSharedPluginState.sourceListFormatState,
|
|
32
|
+
markdownView = _useSharedPluginState.markdownView;
|
|
33
|
+
var isInSourceView = isMarkdownToolbarEnabled && markdownView === 'syntax';
|
|
34
|
+
var isSourceTaskListActive = Boolean(sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inTaskList);
|
|
35
|
+
var isDisabled = isInSourceView ? Boolean((sourceBlockFormatState === null || sourceBlockFormatState === void 0 ? void 0 : sourceBlockFormatState.inCodeBlock) || isSourceTaskListActive) : bulletListDisabled && !taskListActive;
|
|
25
36
|
var onClick = function onClick() {
|
|
26
37
|
var _api$taskDecision;
|
|
38
|
+
if (isInSourceView) {
|
|
39
|
+
var _api$markdownMode;
|
|
40
|
+
if (sourceBlockFormatState !== null && sourceBlockFormatState !== void 0 && sourceBlockFormatState.inCodeBlock) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (isSourceTaskListActive) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
api === null || api === void 0 || (_api$markdownMode = api.markdownMode) === null || _api$markdownMode === void 0 || _api$markdownMode.actions.toggleSourceBulletList();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
27
49
|
api === null || api === void 0 || api.core.actions.execute(taskListActive ? api === null || api === void 0 || (_api$taskDecision = api.taskDecision) === null || _api$taskDecision === void 0 ? void 0 : _api$taskDecision.commands.toggleTaskList('bulletList') : api === null || api === void 0 ? void 0 : api.list.commands.toggleBulletList(getInputMethodFromParentKeys(parents)));
|
|
28
50
|
};
|
|
29
|
-
var isDisabled = bulletListDisabled && !taskListActive;
|
|
30
51
|
var shortcut = formatShortcut(toggleBulletListKeymap);
|
|
31
52
|
return {
|
|
32
53
|
bulletMessage: bulletMessage,
|
|
33
54
|
onClick: onClick,
|
|
34
55
|
isDisabled: isDisabled,
|
|
35
|
-
isSelected: bulletListActive,
|
|
56
|
+
isSelected: isInSourceView ? sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inBulletList : bulletListActive,
|
|
36
57
|
shortcut: shortcut
|
|
37
58
|
};
|
|
38
59
|
};
|
|
@@ -7,27 +7,39 @@ import { getInputMethodFromParentKeys } from '@atlaskit/editor-common/toolbar';
|
|
|
7
7
|
import { ListBulletedIcon, ListNumberedIcon, ToolbarButton, ToolbarTooltip } from '@atlaskit/editor-toolbar';
|
|
8
8
|
import TaskIcon from '@atlaskit/icon/core/task';
|
|
9
9
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
10
|
+
import { isMarkdownCompatibleToolbarEnabled } from '../utils/markdown-compatible-toolbar';
|
|
10
11
|
function useListsIndentationHeroButtonInfo(_ref) {
|
|
11
12
|
var api = _ref.api,
|
|
12
13
|
parents = _ref.parents,
|
|
13
14
|
defaultListType = _ref.defaultListType;
|
|
14
15
|
var _useIntl = useIntl(),
|
|
15
16
|
formatMessage = _useIntl.formatMessage;
|
|
16
|
-
var
|
|
17
|
-
|
|
17
|
+
var isMarkdownToolbarEnabled = isMarkdownCompatibleToolbarEnabled();
|
|
18
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['list', 'taskDecision', 'interaction', 'markdownMode'], function (states) {
|
|
19
|
+
var _states$interactionSt, _states$listState, _states$listState2, _states$listState3, _states$taskDecisionS, _states$markdownModeS, _states$markdownModeS2, _states$markdownModeS3;
|
|
18
20
|
var useDefaultToolbarState = ((_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState) === 'hasNotHadInteraction' && expValEquals('platform_editor_default_toolbar_state', 'isEnabled', true);
|
|
19
21
|
return {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
pmBulletListActive: useDefaultToolbarState ? false : (_states$listState = states.listState) === null || _states$listState === void 0 ? void 0 : _states$listState.bulletListActive,
|
|
23
|
+
pmBulletListDisabled: (_states$listState2 = states.listState) === null || _states$listState2 === void 0 ? void 0 : _states$listState2.bulletListDisabled,
|
|
24
|
+
pmOrderedListActive: useDefaultToolbarState ? false : (_states$listState3 = states.listState) === null || _states$listState3 === void 0 ? void 0 : _states$listState3.orderedListActive,
|
|
25
|
+
pmTaskListActive: useDefaultToolbarState ? false : (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask,
|
|
26
|
+
markdownView: isMarkdownToolbarEnabled ? (_states$markdownModeS = states.markdownModeState) === null || _states$markdownModeS === void 0 ? void 0 : _states$markdownModeS.view : undefined,
|
|
27
|
+
sourceBlockFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS2 = states.markdownModeState) === null || _states$markdownModeS2 === void 0 ? void 0 : _states$markdownModeS2.sourceBlockFormatState : null,
|
|
28
|
+
sourceListFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS3 = states.markdownModeState) === null || _states$markdownModeS3 === void 0 ? void 0 : _states$markdownModeS3.sourceListFormatState : null
|
|
24
29
|
};
|
|
25
30
|
}),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
pmBulletListActive = _useSharedPluginState.pmBulletListActive,
|
|
32
|
+
pmBulletListDisabled = _useSharedPluginState.pmBulletListDisabled,
|
|
33
|
+
pmOrderedListActive = _useSharedPluginState.pmOrderedListActive,
|
|
34
|
+
pmTaskListActive = _useSharedPluginState.pmTaskListActive,
|
|
35
|
+
sourceBlockFormatState = _useSharedPluginState.sourceBlockFormatState,
|
|
36
|
+
sourceListFormatState = _useSharedPluginState.sourceListFormatState,
|
|
37
|
+
markdownView = _useSharedPluginState.markdownView;
|
|
38
|
+
var isInSourceView = isMarkdownToolbarEnabled && markdownView === 'syntax';
|
|
39
|
+
var isBulletListActive = isInSourceView ? sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inBulletList : pmBulletListActive;
|
|
40
|
+
var isOrderedListActive = isInSourceView ? sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inOrderedList : pmOrderedListActive;
|
|
41
|
+
var taskListActive = isInSourceView ? Boolean(sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inTaskList) : pmTaskListActive;
|
|
42
|
+
var getListType = taskListActive ? 'taskList' : isOrderedListActive ? 'orderedList' : defaultListType;
|
|
31
43
|
var taskListKeymap = toggleTaskListKeymap;
|
|
32
44
|
var getKeymap = getListType === 'taskList' ? taskListKeymap : getListType === 'orderedList' ? toggleOrderedListKeymap : toggleBulletListKeymap;
|
|
33
45
|
var shortcut = formatShortcut(getKeymap);
|
|
@@ -35,6 +47,19 @@ function useListsIndentationHeroButtonInfo(_ref) {
|
|
|
35
47
|
var message = getListType === 'taskList' ? formatMessage(tasksAndDecisionsMessages.taskList) : getListType === 'orderedList' ? formatMessage(listMessages.orderedList) : formatMessage(listMessages.bulletedList);
|
|
36
48
|
var onClick = function onClick() {
|
|
37
49
|
var inputMethod = getInputMethodFromParentKeys(parents);
|
|
50
|
+
if (isInSourceView) {
|
|
51
|
+
if (sourceBlockFormatState !== null && sourceBlockFormatState !== void 0 && sourceBlockFormatState.inCodeBlock || getListType === 'taskList') {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (getListType === 'orderedList') {
|
|
55
|
+
var _api$markdownMode;
|
|
56
|
+
api === null || api === void 0 || (_api$markdownMode = api.markdownMode) === null || _api$markdownMode === void 0 || _api$markdownMode.actions.toggleSourceOrderedList();
|
|
57
|
+
} else {
|
|
58
|
+
var _api$markdownMode2;
|
|
59
|
+
api === null || api === void 0 || (_api$markdownMode2 = api.markdownMode) === null || _api$markdownMode2 === void 0 || _api$markdownMode2.actions.toggleSourceBulletList();
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
38
63
|
if (getListType === 'taskList') {
|
|
39
64
|
var _api$taskDecision;
|
|
40
65
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$taskDecision = api.taskDecision) === null || _api$taskDecision === void 0 ? void 0 : _api$taskDecision.commands.toggleTaskList());
|
|
@@ -54,8 +79,8 @@ function useListsIndentationHeroButtonInfo(_ref) {
|
|
|
54
79
|
label: formatMessage(listMessages.bulletedList),
|
|
55
80
|
size: "small"
|
|
56
81
|
});
|
|
57
|
-
var isSelected = getListType === 'bulletList' ?
|
|
58
|
-
var isDisabled = !
|
|
82
|
+
var isSelected = getListType === 'bulletList' ? isBulletListActive : getListType === 'orderedList' ? isOrderedListActive : taskListActive;
|
|
83
|
+
var isDisabled = isInSourceView ? Boolean((sourceBlockFormatState === null || sourceBlockFormatState === void 0 ? void 0 : sourceBlockFormatState.inCodeBlock) || taskListActive) : !isOrderedListActive && !taskListActive && pmBulletListDisabled;
|
|
59
84
|
return {
|
|
60
85
|
shortcut: shortcut,
|
|
61
86
|
keymap: keymap,
|
|
@@ -125,49 +150,23 @@ export var ListsIndentationHeroButtonNew = function ListsIndentationHeroButtonNe
|
|
|
125
150
|
export var ListsIndentationHeroButton = function ListsIndentationHeroButton(_ref4) {
|
|
126
151
|
var api = _ref4.api,
|
|
127
152
|
parents = _ref4.parents;
|
|
128
|
-
var
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return {
|
|
133
|
-
bulletListActive: (_states$listState4 = states.listState) === null || _states$listState4 === void 0 ? void 0 : _states$listState4.bulletListActive,
|
|
134
|
-
bulletListDisabled: (_states$listState5 = states.listState) === null || _states$listState5 === void 0 ? void 0 : _states$listState5.bulletListDisabled,
|
|
135
|
-
orderedListActive: (_states$listState6 = states.listState) === null || _states$listState6 === void 0 ? void 0 : _states$listState6.orderedListActive,
|
|
136
|
-
taskListActive: (_states$taskDecisionS2 = states.taskDecisionState) === null || _states$taskDecisionS2 === void 0 ? void 0 : _states$taskDecisionS2.isInsideTask
|
|
137
|
-
};
|
|
153
|
+
var _useListsIndentationH3 = useListsIndentationHeroButtonInfo({
|
|
154
|
+
api: api,
|
|
155
|
+
parents: parents,
|
|
156
|
+
defaultListType: 'bulletList'
|
|
138
157
|
}),
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
var onClick = function onClick() {
|
|
146
|
-
var inputMethod = getInputMethodFromParentKeys(parents);
|
|
147
|
-
if (taskListActive) {
|
|
148
|
-
var _api$taskDecision2;
|
|
149
|
-
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$taskDecision2 = api.taskDecision) === null || _api$taskDecision2 === void 0 ? void 0 : _api$taskDecision2.commands.toggleTaskList());
|
|
150
|
-
} else if (orderedListActive) {
|
|
151
|
-
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.list.commands.toggleOrderedList(inputMethod));
|
|
152
|
-
} else {
|
|
153
|
-
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.list.commands.toggleBulletList(inputMethod));
|
|
154
|
-
}
|
|
155
|
-
};
|
|
158
|
+
shortcut = _useListsIndentationH3.shortcut,
|
|
159
|
+
message = _useListsIndentationH3.message,
|
|
160
|
+
onClick = _useListsIndentationH3.onClick,
|
|
161
|
+
iconBefore = _useListsIndentationH3.iconBefore,
|
|
162
|
+
isSelected = _useListsIndentationH3.isSelected,
|
|
163
|
+
isDisabled = _useListsIndentationH3.isDisabled;
|
|
156
164
|
return /*#__PURE__*/React.createElement(ToolbarTooltip, {
|
|
157
|
-
content:
|
|
165
|
+
content: message
|
|
158
166
|
}, /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
159
|
-
iconBefore:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}) : orderedListActive ? /*#__PURE__*/React.createElement(ListNumberedIcon, {
|
|
163
|
-
label: formatMessage(listMessages.orderedList),
|
|
164
|
-
size: "small"
|
|
165
|
-
}) : /*#__PURE__*/React.createElement(ListBulletedIcon, {
|
|
166
|
-
label: formatMessage(listMessages.bulletedList),
|
|
167
|
-
size: "small"
|
|
168
|
-
}),
|
|
169
|
-
isSelected: bulletListActive || orderedListActive || taskListActive,
|
|
170
|
-
isDisabled: !orderedListActive && !taskListActive && bulletListDisabled,
|
|
167
|
+
iconBefore: iconBefore,
|
|
168
|
+
isSelected: isSelected,
|
|
169
|
+
isDisabled: isDisabled,
|
|
171
170
|
ariaKeyshortcuts: shortcut,
|
|
172
171
|
onClick: onClick
|
|
173
172
|
}));
|
|
@@ -5,6 +5,7 @@ import { messages } from '@atlaskit/editor-common/lists';
|
|
|
5
5
|
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
6
6
|
import { MoreItemsIcon, ToolbarDropdownMenu, ToolbarTooltip } from '@atlaskit/editor-toolbar';
|
|
7
7
|
import { useIndentationState } from '../utils/hooks';
|
|
8
|
+
import { isMarkdownCompatibleToolbarEnabled } from '../utils/markdown-compatible-toolbar';
|
|
8
9
|
export var ListsIndentationMenu = function ListsIndentationMenu(_ref) {
|
|
9
10
|
var children = _ref.children,
|
|
10
11
|
api = _ref.api,
|
|
@@ -18,18 +19,22 @@ export var ListsIndentationMenu = function ListsIndentationMenu(_ref) {
|
|
|
18
19
|
allowHeadingAndParagraphIndentation: allowHeadingAndParagraphIndentation,
|
|
19
20
|
state: editorView === null || editorView === void 0 ? void 0 : editorView.state
|
|
20
21
|
});
|
|
21
|
-
var
|
|
22
|
-
|
|
22
|
+
var isMarkdownToolbarEnabled = isMarkdownCompatibleToolbarEnabled();
|
|
23
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['list', 'taskDecision', 'markdownMode'], function (states) {
|
|
24
|
+
var _states$listState, _states$listState2, _states$taskDecisionS, _states$markdownModeS;
|
|
23
25
|
return {
|
|
24
26
|
bulletListDisabled: (_states$listState = states.listState) === null || _states$listState === void 0 ? void 0 : _states$listState.bulletListDisabled,
|
|
25
27
|
orderedListDisabled: (_states$listState2 = states.listState) === null || _states$listState2 === void 0 ? void 0 : _states$listState2.orderedListDisabled,
|
|
26
|
-
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask
|
|
28
|
+
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask,
|
|
29
|
+
markdownView: isMarkdownToolbarEnabled ? (_states$markdownModeS = states.markdownModeState) === null || _states$markdownModeS === void 0 ? void 0 : _states$markdownModeS.view : undefined
|
|
27
30
|
};
|
|
28
31
|
}),
|
|
29
32
|
bulletListDisabled = _useSharedPluginState.bulletListDisabled,
|
|
30
33
|
orderedListDisabled = _useSharedPluginState.orderedListDisabled,
|
|
31
|
-
taskListActive = _useSharedPluginState.taskListActive
|
|
32
|
-
|
|
34
|
+
taskListActive = _useSharedPluginState.taskListActive,
|
|
35
|
+
markdownView = _useSharedPluginState.markdownView;
|
|
36
|
+
var isInSourceView = isMarkdownToolbarEnabled && markdownView === 'syntax';
|
|
37
|
+
var allItemsDisabled = !isInSourceView && bulletListDisabled && orderedListDisabled && (indentationState === null || indentationState === void 0 ? void 0 : indentationState.indentDisabled) && (indentationState === null || indentationState === void 0 ? void 0 : indentationState.outdentDisabled) && !taskListActive;
|
|
33
38
|
return /*#__PURE__*/React.createElement(ToolbarDropdownMenu, {
|
|
34
39
|
iconBefore: /*#__PURE__*/React.createElement(MoreItemsIcon, {
|
|
35
40
|
label: formatMessage(messages.lists)
|