@atlaskit/editor-plugin-toolbar-lists-indentation 11.1.7 → 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 +11 -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 +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-toolbar-lists-indentation
|
|
2
2
|
|
|
3
|
+
## 11.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`3b79e10490ac2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3b79e10490ac2) -
|
|
8
|
+
Support markdown source view list and task toolbar actions
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 11.1.7
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -4,16 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.onItemActivated = void 0;
|
|
7
|
+
var _markdownCompatibleToolbar = require("./utils/markdown-compatible-toolbar");
|
|
7
8
|
var onItemActivated = exports.onItemActivated = function onItemActivated(pluginInjectionApi, indentationStateNode, inputMethod) {
|
|
8
9
|
return function (_ref) {
|
|
9
|
-
var _pluginInjectionApi$c, _pluginInjectionApi$l, _pluginInjectionApi$c2, _pluginInjectionApi$l2;
|
|
10
|
+
var _pluginInjectionApi$m, _pluginInjectionApi$c, _pluginInjectionApi$l, _pluginInjectionApi$c2, _pluginInjectionApi$l2;
|
|
10
11
|
var buttonName = _ref.buttonName,
|
|
11
12
|
editorView = _ref.editorView;
|
|
13
|
+
var isInSourceView = (0, _markdownCompatibleToolbar.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';
|
|
12
14
|
switch (buttonName) {
|
|
13
15
|
case 'bullet_list':
|
|
16
|
+
if (isInSourceView) {
|
|
17
|
+
var _pluginInjectionApi$m2;
|
|
18
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m2 = pluginInjectionApi.markdownMode) === null || _pluginInjectionApi$m2 === void 0 || _pluginInjectionApi$m2.actions.toggleSourceBulletList();
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
14
21
|
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));
|
|
15
22
|
break;
|
|
16
23
|
case 'ordered_list':
|
|
24
|
+
if (isInSourceView) {
|
|
25
|
+
var _pluginInjectionApi$m3;
|
|
26
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m3 = pluginInjectionApi.markdownMode) === null || _pluginInjectionApi$m3 === void 0 || _pluginInjectionApi$m3.actions.toggleSourceOrderedList();
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
17
29
|
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));
|
|
18
30
|
break;
|
|
19
31
|
case 'indent':
|
|
@@ -12,34 +12,55 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
|
12
12
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
13
|
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
14
14
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
15
|
+
var _markdownCompatibleToolbar = require("../utils/markdown-compatible-toolbar");
|
|
15
16
|
var useBulletedListInfo = exports.useBulletedListInfo = function useBulletedListInfo(_ref) {
|
|
16
17
|
var api = _ref.api,
|
|
17
18
|
parents = _ref.parents;
|
|
18
19
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
19
20
|
formatMessage = _useIntl.formatMessage;
|
|
20
21
|
var bulletMessage = formatMessage(_messages.listMessages.bulletedList);
|
|
21
|
-
var
|
|
22
|
-
|
|
22
|
+
var isMarkdownToolbarEnabled = (0, _markdownCompatibleToolbar.isMarkdownCompatibleToolbarEnabled)();
|
|
23
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['list', 'taskDecision', 'markdownMode'], function (states) {
|
|
24
|
+
var _states$listState, _states$listState2, _states$taskDecisionS, _states$markdownModeS, _states$markdownModeS2, _states$markdownModeS3;
|
|
23
25
|
return {
|
|
24
26
|
bulletListActive: (_states$listState = states.listState) === null || _states$listState === void 0 ? void 0 : _states$listState.bulletListActive,
|
|
25
27
|
bulletListDisabled: (_states$listState2 = states.listState) === null || _states$listState2 === void 0 ? void 0 : _states$listState2.bulletListDisabled,
|
|
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,
|
|
30
|
+
sourceBlockFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS2 = states.markdownModeState) === null || _states$markdownModeS2 === void 0 ? void 0 : _states$markdownModeS2.sourceBlockFormatState : null,
|
|
31
|
+
sourceListFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS3 = states.markdownModeState) === null || _states$markdownModeS3 === void 0 ? void 0 : _states$markdownModeS3.sourceListFormatState : null
|
|
27
32
|
};
|
|
28
33
|
}),
|
|
29
34
|
bulletListActive = _useSharedPluginState.bulletListActive,
|
|
30
35
|
bulletListDisabled = _useSharedPluginState.bulletListDisabled,
|
|
31
|
-
taskListActive = _useSharedPluginState.taskListActive
|
|
36
|
+
taskListActive = _useSharedPluginState.taskListActive,
|
|
37
|
+
sourceBlockFormatState = _useSharedPluginState.sourceBlockFormatState,
|
|
38
|
+
sourceListFormatState = _useSharedPluginState.sourceListFormatState,
|
|
39
|
+
markdownView = _useSharedPluginState.markdownView;
|
|
40
|
+
var isInSourceView = isMarkdownToolbarEnabled && markdownView === 'syntax';
|
|
41
|
+
var isSourceTaskListActive = Boolean(sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inTaskList);
|
|
42
|
+
var isDisabled = isInSourceView ? Boolean((sourceBlockFormatState === null || sourceBlockFormatState === void 0 ? void 0 : sourceBlockFormatState.inCodeBlock) || isSourceTaskListActive) : bulletListDisabled && !taskListActive;
|
|
32
43
|
var onClick = function onClick() {
|
|
33
44
|
var _api$taskDecision;
|
|
45
|
+
if (isInSourceView) {
|
|
46
|
+
var _api$markdownMode;
|
|
47
|
+
if (sourceBlockFormatState !== null && sourceBlockFormatState !== void 0 && sourceBlockFormatState.inCodeBlock) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (isSourceTaskListActive) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
api === null || api === void 0 || (_api$markdownMode = api.markdownMode) === null || _api$markdownMode === void 0 || _api$markdownMode.actions.toggleSourceBulletList();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
34
56
|
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((0, _toolbar.getInputMethodFromParentKeys)(parents)));
|
|
35
57
|
};
|
|
36
|
-
var isDisabled = bulletListDisabled && !taskListActive;
|
|
37
58
|
var shortcut = (0, _keymaps.formatShortcut)(_keymaps.toggleBulletList);
|
|
38
59
|
return {
|
|
39
60
|
bulletMessage: bulletMessage,
|
|
40
61
|
onClick: onClick,
|
|
41
62
|
isDisabled: isDisabled,
|
|
42
|
-
isSelected: bulletListActive,
|
|
63
|
+
isSelected: isInSourceView ? sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inBulletList : bulletListActive,
|
|
43
64
|
shortcut: shortcut
|
|
44
65
|
};
|
|
45
66
|
};
|
|
@@ -14,27 +14,39 @@ var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
|
14
14
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
15
15
|
var _task = _interopRequireDefault(require("@atlaskit/icon/core/task"));
|
|
16
16
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
17
|
+
var _markdownCompatibleToolbar = require("../utils/markdown-compatible-toolbar");
|
|
17
18
|
function useListsIndentationHeroButtonInfo(_ref) {
|
|
18
19
|
var api = _ref.api,
|
|
19
20
|
parents = _ref.parents,
|
|
20
21
|
defaultListType = _ref.defaultListType;
|
|
21
22
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
22
23
|
formatMessage = _useIntl.formatMessage;
|
|
23
|
-
var
|
|
24
|
-
|
|
24
|
+
var isMarkdownToolbarEnabled = (0, _markdownCompatibleToolbar.isMarkdownCompatibleToolbarEnabled)();
|
|
25
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['list', 'taskDecision', 'interaction', 'markdownMode'], function (states) {
|
|
26
|
+
var _states$interactionSt, _states$listState, _states$listState2, _states$listState3, _states$taskDecisionS, _states$markdownModeS, _states$markdownModeS2, _states$markdownModeS3;
|
|
25
27
|
var useDefaultToolbarState = ((_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState) === 'hasNotHadInteraction' && (0, _expValEquals.expValEquals)('platform_editor_default_toolbar_state', 'isEnabled', true);
|
|
26
28
|
return {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
pmBulletListActive: useDefaultToolbarState ? false : (_states$listState = states.listState) === null || _states$listState === void 0 ? void 0 : _states$listState.bulletListActive,
|
|
30
|
+
pmBulletListDisabled: (_states$listState2 = states.listState) === null || _states$listState2 === void 0 ? void 0 : _states$listState2.bulletListDisabled,
|
|
31
|
+
pmOrderedListActive: useDefaultToolbarState ? false : (_states$listState3 = states.listState) === null || _states$listState3 === void 0 ? void 0 : _states$listState3.orderedListActive,
|
|
32
|
+
pmTaskListActive: useDefaultToolbarState ? false : (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask,
|
|
33
|
+
markdownView: isMarkdownToolbarEnabled ? (_states$markdownModeS = states.markdownModeState) === null || _states$markdownModeS === void 0 ? void 0 : _states$markdownModeS.view : undefined,
|
|
34
|
+
sourceBlockFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS2 = states.markdownModeState) === null || _states$markdownModeS2 === void 0 ? void 0 : _states$markdownModeS2.sourceBlockFormatState : null,
|
|
35
|
+
sourceListFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS3 = states.markdownModeState) === null || _states$markdownModeS3 === void 0 ? void 0 : _states$markdownModeS3.sourceListFormatState : null
|
|
31
36
|
};
|
|
32
37
|
}),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
pmBulletListActive = _useSharedPluginState.pmBulletListActive,
|
|
39
|
+
pmBulletListDisabled = _useSharedPluginState.pmBulletListDisabled,
|
|
40
|
+
pmOrderedListActive = _useSharedPluginState.pmOrderedListActive,
|
|
41
|
+
pmTaskListActive = _useSharedPluginState.pmTaskListActive,
|
|
42
|
+
sourceBlockFormatState = _useSharedPluginState.sourceBlockFormatState,
|
|
43
|
+
sourceListFormatState = _useSharedPluginState.sourceListFormatState,
|
|
44
|
+
markdownView = _useSharedPluginState.markdownView;
|
|
45
|
+
var isInSourceView = isMarkdownToolbarEnabled && markdownView === 'syntax';
|
|
46
|
+
var isBulletListActive = isInSourceView ? sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inBulletList : pmBulletListActive;
|
|
47
|
+
var isOrderedListActive = isInSourceView ? sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inOrderedList : pmOrderedListActive;
|
|
48
|
+
var taskListActive = isInSourceView ? Boolean(sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inTaskList) : pmTaskListActive;
|
|
49
|
+
var getListType = taskListActive ? 'taskList' : isOrderedListActive ? 'orderedList' : defaultListType;
|
|
38
50
|
var taskListKeymap = _keymaps.toggleTaskList;
|
|
39
51
|
var getKeymap = getListType === 'taskList' ? taskListKeymap : getListType === 'orderedList' ? _keymaps.toggleOrderedList : _keymaps.toggleBulletList;
|
|
40
52
|
var shortcut = (0, _keymaps.formatShortcut)(getKeymap);
|
|
@@ -42,6 +54,19 @@ function useListsIndentationHeroButtonInfo(_ref) {
|
|
|
42
54
|
var message = getListType === 'taskList' ? formatMessage(_messages.tasksAndDecisionsMessages.taskList) : getListType === 'orderedList' ? formatMessage(_messages.listMessages.orderedList) : formatMessage(_messages.listMessages.bulletedList);
|
|
43
55
|
var onClick = function onClick() {
|
|
44
56
|
var inputMethod = (0, _toolbar.getInputMethodFromParentKeys)(parents);
|
|
57
|
+
if (isInSourceView) {
|
|
58
|
+
if (sourceBlockFormatState !== null && sourceBlockFormatState !== void 0 && sourceBlockFormatState.inCodeBlock || getListType === 'taskList') {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (getListType === 'orderedList') {
|
|
62
|
+
var _api$markdownMode;
|
|
63
|
+
api === null || api === void 0 || (_api$markdownMode = api.markdownMode) === null || _api$markdownMode === void 0 || _api$markdownMode.actions.toggleSourceOrderedList();
|
|
64
|
+
} else {
|
|
65
|
+
var _api$markdownMode2;
|
|
66
|
+
api === null || api === void 0 || (_api$markdownMode2 = api.markdownMode) === null || _api$markdownMode2 === void 0 || _api$markdownMode2.actions.toggleSourceBulletList();
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
45
70
|
if (getListType === 'taskList') {
|
|
46
71
|
var _api$taskDecision;
|
|
47
72
|
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());
|
|
@@ -61,8 +86,8 @@ function useListsIndentationHeroButtonInfo(_ref) {
|
|
|
61
86
|
label: formatMessage(_messages.listMessages.bulletedList),
|
|
62
87
|
size: "small"
|
|
63
88
|
});
|
|
64
|
-
var isSelected = getListType === 'bulletList' ?
|
|
65
|
-
var isDisabled = !
|
|
89
|
+
var isSelected = getListType === 'bulletList' ? isBulletListActive : getListType === 'orderedList' ? isOrderedListActive : taskListActive;
|
|
90
|
+
var isDisabled = isInSourceView ? Boolean((sourceBlockFormatState === null || sourceBlockFormatState === void 0 ? void 0 : sourceBlockFormatState.inCodeBlock) || taskListActive) : !isOrderedListActive && !taskListActive && pmBulletListDisabled;
|
|
66
91
|
return {
|
|
67
92
|
shortcut: shortcut,
|
|
68
93
|
keymap: keymap,
|
|
@@ -132,49 +157,23 @@ var ListsIndentationHeroButtonNew = exports.ListsIndentationHeroButtonNew = func
|
|
|
132
157
|
var ListsIndentationHeroButton = exports.ListsIndentationHeroButton = function ListsIndentationHeroButton(_ref4) {
|
|
133
158
|
var api = _ref4.api,
|
|
134
159
|
parents = _ref4.parents;
|
|
135
|
-
var
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
bulletListActive: (_states$listState4 = states.listState) === null || _states$listState4 === void 0 ? void 0 : _states$listState4.bulletListActive,
|
|
141
|
-
bulletListDisabled: (_states$listState5 = states.listState) === null || _states$listState5 === void 0 ? void 0 : _states$listState5.bulletListDisabled,
|
|
142
|
-
orderedListActive: (_states$listState6 = states.listState) === null || _states$listState6 === void 0 ? void 0 : _states$listState6.orderedListActive,
|
|
143
|
-
taskListActive: (_states$taskDecisionS2 = states.taskDecisionState) === null || _states$taskDecisionS2 === void 0 ? void 0 : _states$taskDecisionS2.isInsideTask
|
|
144
|
-
};
|
|
160
|
+
var _useListsIndentationH3 = useListsIndentationHeroButtonInfo({
|
|
161
|
+
api: api,
|
|
162
|
+
parents: parents,
|
|
163
|
+
defaultListType: 'bulletList'
|
|
145
164
|
}),
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
var onClick = function onClick() {
|
|
153
|
-
var inputMethod = (0, _toolbar.getInputMethodFromParentKeys)(parents);
|
|
154
|
-
if (taskListActive) {
|
|
155
|
-
var _api$taskDecision2;
|
|
156
|
-
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());
|
|
157
|
-
} else if (orderedListActive) {
|
|
158
|
-
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.list.commands.toggleOrderedList(inputMethod));
|
|
159
|
-
} else {
|
|
160
|
-
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.list.commands.toggleBulletList(inputMethod));
|
|
161
|
-
}
|
|
162
|
-
};
|
|
165
|
+
shortcut = _useListsIndentationH3.shortcut,
|
|
166
|
+
message = _useListsIndentationH3.message,
|
|
167
|
+
onClick = _useListsIndentationH3.onClick,
|
|
168
|
+
iconBefore = _useListsIndentationH3.iconBefore,
|
|
169
|
+
isSelected = _useListsIndentationH3.isSelected,
|
|
170
|
+
isDisabled = _useListsIndentationH3.isDisabled;
|
|
163
171
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarTooltip, {
|
|
164
|
-
content:
|
|
172
|
+
content: message
|
|
165
173
|
}, /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarButton, {
|
|
166
|
-
iconBefore:
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}) : orderedListActive ? /*#__PURE__*/_react.default.createElement(_editorToolbar.ListNumberedIcon, {
|
|
170
|
-
label: formatMessage(_messages.listMessages.orderedList),
|
|
171
|
-
size: "small"
|
|
172
|
-
}) : /*#__PURE__*/_react.default.createElement(_editorToolbar.ListBulletedIcon, {
|
|
173
|
-
label: formatMessage(_messages.listMessages.bulletedList),
|
|
174
|
-
size: "small"
|
|
175
|
-
}),
|
|
176
|
-
isSelected: bulletListActive || orderedListActive || taskListActive,
|
|
177
|
-
isDisabled: !orderedListActive && !taskListActive && bulletListDisabled,
|
|
174
|
+
iconBefore: iconBefore,
|
|
175
|
+
isSelected: isSelected,
|
|
176
|
+
isDisabled: isDisabled,
|
|
178
177
|
ariaKeyshortcuts: shortcut,
|
|
179
178
|
onClick: onClick
|
|
180
179
|
}));
|
|
@@ -12,6 +12,7 @@ var _lists = require("@atlaskit/editor-common/lists");
|
|
|
12
12
|
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
13
13
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
14
14
|
var _hooks2 = require("../utils/hooks");
|
|
15
|
+
var _markdownCompatibleToolbar = require("../utils/markdown-compatible-toolbar");
|
|
15
16
|
var ListsIndentationMenu = exports.ListsIndentationMenu = function ListsIndentationMenu(_ref) {
|
|
16
17
|
var children = _ref.children,
|
|
17
18
|
api = _ref.api,
|
|
@@ -25,18 +26,22 @@ var ListsIndentationMenu = exports.ListsIndentationMenu = function ListsIndentat
|
|
|
25
26
|
allowHeadingAndParagraphIndentation: allowHeadingAndParagraphIndentation,
|
|
26
27
|
state: editorView === null || editorView === void 0 ? void 0 : editorView.state
|
|
27
28
|
});
|
|
28
|
-
var
|
|
29
|
-
|
|
29
|
+
var isMarkdownToolbarEnabled = (0, _markdownCompatibleToolbar.isMarkdownCompatibleToolbarEnabled)();
|
|
30
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['list', 'taskDecision', 'markdownMode'], function (states) {
|
|
31
|
+
var _states$listState, _states$listState2, _states$taskDecisionS, _states$markdownModeS;
|
|
30
32
|
return {
|
|
31
33
|
bulletListDisabled: (_states$listState = states.listState) === null || _states$listState === void 0 ? void 0 : _states$listState.bulletListDisabled,
|
|
32
34
|
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
|
|
35
|
+
taskListActive: (_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
|
|
34
37
|
};
|
|
35
38
|
}),
|
|
36
39
|
bulletListDisabled = _useSharedPluginState.bulletListDisabled,
|
|
37
40
|
orderedListDisabled = _useSharedPluginState.orderedListDisabled,
|
|
38
|
-
taskListActive = _useSharedPluginState.taskListActive
|
|
39
|
-
|
|
41
|
+
taskListActive = _useSharedPluginState.taskListActive,
|
|
42
|
+
markdownView = _useSharedPluginState.markdownView;
|
|
43
|
+
var isInSourceView = isMarkdownToolbarEnabled && markdownView === 'syntax';
|
|
44
|
+
var allItemsDisabled = !isInSourceView && bulletListDisabled && orderedListDisabled && (indentationState === null || indentationState === void 0 ? void 0 : indentationState.indentDisabled) && (indentationState === null || indentationState === void 0 ? void 0 : indentationState.outdentDisabled) && !taskListActive;
|
|
40
45
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownMenu, {
|
|
41
46
|
iconBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.MoreItemsIcon, {
|
|
42
47
|
label: formatMessage(_lists.messages.lists)
|
|
@@ -12,24 +12,45 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
|
12
12
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
13
|
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
14
14
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
15
|
+
var _markdownCompatibleToolbar = require("../utils/markdown-compatible-toolbar");
|
|
15
16
|
var NumberedListMenuItem = exports.NumberedListMenuItem = function NumberedListMenuItem(_ref) {
|
|
16
17
|
var api = _ref.api,
|
|
17
18
|
parents = _ref.parents;
|
|
18
19
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
19
20
|
formatMessage = _useIntl.formatMessage;
|
|
20
|
-
var
|
|
21
|
-
|
|
21
|
+
var isMarkdownToolbarEnabled = (0, _markdownCompatibleToolbar.isMarkdownCompatibleToolbarEnabled)();
|
|
22
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['list', 'taskDecision', 'markdownMode'], function (states) {
|
|
23
|
+
var _states$listState, _states$listState2, _states$taskDecisionS, _states$markdownModeS, _states$markdownModeS2, _states$markdownModeS3;
|
|
22
24
|
return {
|
|
23
25
|
orderedListActive: (_states$listState = states.listState) === null || _states$listState === void 0 ? void 0 : _states$listState.orderedListActive,
|
|
24
26
|
orderedListDisabled: (_states$listState2 = states.listState) === null || _states$listState2 === void 0 ? void 0 : _states$listState2.orderedListDisabled,
|
|
25
|
-
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask
|
|
27
|
+
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask,
|
|
28
|
+
markdownView: isMarkdownToolbarEnabled ? (_states$markdownModeS = states.markdownModeState) === null || _states$markdownModeS === void 0 ? void 0 : _states$markdownModeS.view : undefined,
|
|
29
|
+
sourceBlockFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS2 = states.markdownModeState) === null || _states$markdownModeS2 === void 0 ? void 0 : _states$markdownModeS2.sourceBlockFormatState : null,
|
|
30
|
+
sourceListFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS3 = states.markdownModeState) === null || _states$markdownModeS3 === void 0 ? void 0 : _states$markdownModeS3.sourceListFormatState : null
|
|
26
31
|
};
|
|
27
32
|
}),
|
|
28
33
|
orderedListActive = _useSharedPluginState.orderedListActive,
|
|
29
34
|
orderedListDisabled = _useSharedPluginState.orderedListDisabled,
|
|
30
|
-
taskListActive = _useSharedPluginState.taskListActive
|
|
35
|
+
taskListActive = _useSharedPluginState.taskListActive,
|
|
36
|
+
sourceBlockFormatState = _useSharedPluginState.sourceBlockFormatState,
|
|
37
|
+
sourceListFormatState = _useSharedPluginState.sourceListFormatState,
|
|
38
|
+
markdownView = _useSharedPluginState.markdownView;
|
|
39
|
+
var isInSourceView = isMarkdownToolbarEnabled && markdownView === 'syntax';
|
|
40
|
+
var isSourceTaskListActive = Boolean(sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inTaskList);
|
|
31
41
|
var onClick = function onClick() {
|
|
32
42
|
var _api$taskDecision;
|
|
43
|
+
if (isInSourceView) {
|
|
44
|
+
var _api$markdownMode;
|
|
45
|
+
if (sourceBlockFormatState !== null && sourceBlockFormatState !== void 0 && sourceBlockFormatState.inCodeBlock) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (isSourceTaskListActive) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
api === null || api === void 0 || (_api$markdownMode = api.markdownMode) === null || _api$markdownMode === void 0 || _api$markdownMode.actions.toggleSourceOrderedList();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
33
54
|
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('orderedList') : api === null || api === void 0 ? void 0 : api.list.commands.toggleOrderedList((0, _toolbar.getInputMethodFromParentKeys)(parents)));
|
|
34
55
|
};
|
|
35
56
|
var shortcut = (0, _keymaps.formatShortcut)(_keymaps.toggleOrderedList);
|
|
@@ -41,8 +62,8 @@ var NumberedListMenuItem = exports.NumberedListMenuItem = function NumberedListM
|
|
|
41
62
|
elemAfter: shortcut ? /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarKeyboardShortcutHint, {
|
|
42
63
|
shortcut: shortcut
|
|
43
64
|
}) : undefined,
|
|
44
|
-
isSelected: orderedListActive,
|
|
45
|
-
isDisabled: orderedListDisabled && !taskListActive,
|
|
65
|
+
isSelected: isInSourceView ? sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inOrderedList : orderedListActive,
|
|
66
|
+
isDisabled: isInSourceView ? Boolean((sourceBlockFormatState === null || sourceBlockFormatState === void 0 ? void 0 : sourceBlockFormatState.inCodeBlock) || isSourceTaskListActive) : orderedListDisabled && !taskListActive,
|
|
46
67
|
onClick: onClick,
|
|
47
68
|
ariaKeyshortcuts: shortcut
|
|
48
69
|
}, formatMessage(_messages.listMessages.orderedList));
|
|
@@ -7,23 +7,52 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.TaskListMenuItem = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactIntl = require("react-intl");
|
|
10
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
11
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
12
|
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
12
|
-
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
13
13
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
14
14
|
var _task = _interopRequireDefault(require("@atlaskit/icon/core/task"));
|
|
15
|
+
var _markdownCompatibleToolbar = require("../utils/markdown-compatible-toolbar");
|
|
15
16
|
var TaskListMenuItem = exports.TaskListMenuItem = function TaskListMenuItem(_ref) {
|
|
16
17
|
var api = _ref.api;
|
|
17
18
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
18
19
|
formatMessage = _useIntl.formatMessage;
|
|
19
20
|
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
20
21
|
editorView = _useEditorToolbar.editorView;
|
|
21
|
-
var
|
|
22
|
+
var isMarkdownToolbarEnabled = (0, _markdownCompatibleToolbar.isMarkdownCompatibleToolbarEnabled)();
|
|
23
|
+
// Mirror the sibling BulletedListMenuItem / NumberedListMenuItem pattern:
|
|
24
|
+
// gate the markdown-mode field reads behind the feature flag inside the
|
|
25
|
+
// selector so we don't trigger re-renders on CM6 state changes for users
|
|
26
|
+
// who don't have the markdown-compatible toolbar enabled.
|
|
27
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['taskDecision', 'markdownMode'], function (states) {
|
|
28
|
+
var _states$taskDecisionS, _states$markdownModeS, _states$markdownModeS2, _states$markdownModeS3;
|
|
29
|
+
return {
|
|
30
|
+
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask,
|
|
31
|
+
markdownView: isMarkdownToolbarEnabled ? (_states$markdownModeS = states.markdownModeState) === null || _states$markdownModeS === void 0 ? void 0 : _states$markdownModeS.view : undefined,
|
|
32
|
+
sourceBlockFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS2 = states.markdownModeState) === null || _states$markdownModeS2 === void 0 ? void 0 : _states$markdownModeS2.sourceBlockFormatState : null,
|
|
33
|
+
sourceListFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS3 = states.markdownModeState) === null || _states$markdownModeS3 === void 0 ? void 0 : _states$markdownModeS3.sourceListFormatState : null
|
|
34
|
+
};
|
|
35
|
+
}),
|
|
36
|
+
taskListActive = _useSharedPluginState.taskListActive,
|
|
37
|
+
markdownView = _useSharedPluginState.markdownView,
|
|
38
|
+
sourceBlockFormatState = _useSharedPluginState.sourceBlockFormatState,
|
|
39
|
+
sourceListFormatState = _useSharedPluginState.sourceListFormatState;
|
|
22
40
|
if (!(editorView !== null && editorView !== void 0 && editorView.state.schema.nodes.taskItem)) {
|
|
23
41
|
return null;
|
|
24
42
|
}
|
|
43
|
+
var isInSourceView = isMarkdownToolbarEnabled && markdownView === 'syntax';
|
|
44
|
+
var isSelected = isInSourceView ? sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inTaskList : taskListActive;
|
|
45
|
+
var isDisabled = Boolean(isInSourceView && (sourceBlockFormatState === null || sourceBlockFormatState === void 0 ? void 0 : sourceBlockFormatState.inCodeBlock));
|
|
25
46
|
var handleClick = function handleClick() {
|
|
26
47
|
var _api$taskDecision;
|
|
48
|
+
if (isDisabled) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (isInSourceView) {
|
|
52
|
+
var _api$markdownMode;
|
|
53
|
+
api === null || api === void 0 || (_api$markdownMode = api.markdownMode) === null || _api$markdownMode === void 0 || _api$markdownMode.actions.toggleSourceTaskList();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
27
56
|
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());
|
|
28
57
|
};
|
|
29
58
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
@@ -34,8 +63,8 @@ var TaskListMenuItem = exports.TaskListMenuItem = function TaskListMenuItem(_ref
|
|
|
34
63
|
elemAfter: /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarKeyboardShortcutHint, {
|
|
35
64
|
shortcut: "[]"
|
|
36
65
|
}),
|
|
37
|
-
isSelected:
|
|
38
|
-
isDisabled:
|
|
66
|
+
isSelected: isSelected,
|
|
67
|
+
isDisabled: isDisabled,
|
|
39
68
|
onClick: handleClick
|
|
40
69
|
}, formatMessage(_messages.tasksAndDecisionsMessages.taskList));
|
|
41
70
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isMarkdownCompatibleToolbarEnabled = void 0;
|
|
7
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
|
+
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
9
|
+
var isMarkdownCompatibleToolbarEnabled = exports.isMarkdownCompatibleToolbarEnabled = function isMarkdownCompatibleToolbarEnabled() {
|
|
10
|
+
return (0, _expValEqualsNoExposure.expValEqualsNoExposure)('cc-markdown-mode', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('platform_editor_markdown_compatible_toolbar');
|
|
11
|
+
};
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
+
import { isMarkdownCompatibleToolbarEnabled } from './utils/markdown-compatible-toolbar';
|
|
1
2
|
export const onItemActivated = (pluginInjectionApi, indentationStateNode, inputMethod) => ({
|
|
2
3
|
buttonName,
|
|
3
4
|
editorView
|
|
4
5
|
}) => {
|
|
5
|
-
var _pluginInjectionApi$c, _pluginInjectionApi$l, _pluginInjectionApi$c2, _pluginInjectionApi$l2;
|
|
6
|
+
var _pluginInjectionApi$m, _pluginInjectionApi$m2, _pluginInjectionApi$c, _pluginInjectionApi$l, _pluginInjectionApi$c2, _pluginInjectionApi$l2;
|
|
7
|
+
const isInSourceView = isMarkdownCompatibleToolbarEnabled() && (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.markdownMode) === null || _pluginInjectionApi$m === void 0 ? void 0 : (_pluginInjectionApi$m2 = _pluginInjectionApi$m.sharedState.currentState()) === null || _pluginInjectionApi$m2 === void 0 ? void 0 : _pluginInjectionApi$m2.view) === 'syntax';
|
|
6
8
|
switch (buttonName) {
|
|
7
9
|
case 'bullet_list':
|
|
10
|
+
if (isInSourceView) {
|
|
11
|
+
var _pluginInjectionApi$m3;
|
|
12
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m3 = pluginInjectionApi.markdownMode) === null || _pluginInjectionApi$m3 === void 0 ? void 0 : _pluginInjectionApi$m3.actions.toggleSourceBulletList();
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
8
15
|
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.core) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? 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$m4;
|
|
20
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m4 = pluginInjectionApi.markdownMode) === null || _pluginInjectionApi$m4 === void 0 ? void 0 : _pluginInjectionApi$m4.actions.toggleSourceOrderedList();
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
11
23
|
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? 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,6 +5,7 @@ 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 const useBulletedListInfo = ({
|
|
9
10
|
api,
|
|
10
11
|
parents
|
|
@@ -13,29 +14,49 @@ export const useBulletedListInfo = ({
|
|
|
13
14
|
formatMessage
|
|
14
15
|
} = useIntl();
|
|
15
16
|
const bulletMessage = formatMessage(listMessages.bulletedList);
|
|
17
|
+
const isMarkdownToolbarEnabled = isMarkdownCompatibleToolbarEnabled();
|
|
16
18
|
const {
|
|
17
19
|
bulletListActive,
|
|
18
20
|
bulletListDisabled,
|
|
19
|
-
taskListActive
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
taskListActive,
|
|
22
|
+
sourceBlockFormatState,
|
|
23
|
+
sourceListFormatState,
|
|
24
|
+
markdownView
|
|
25
|
+
} = useSharedPluginStateWithSelector(api, ['list', 'taskDecision', 'markdownMode'], states => {
|
|
26
|
+
var _states$listState, _states$listState2, _states$taskDecisionS, _states$markdownModeS, _states$markdownModeS2, _states$markdownModeS3;
|
|
22
27
|
return {
|
|
23
28
|
bulletListActive: (_states$listState = states.listState) === null || _states$listState === void 0 ? void 0 : _states$listState.bulletListActive,
|
|
24
29
|
bulletListDisabled: (_states$listState2 = states.listState) === null || _states$listState2 === void 0 ? void 0 : _states$listState2.bulletListDisabled,
|
|
25
|
-
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask
|
|
30
|
+
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask,
|
|
31
|
+
markdownView: isMarkdownToolbarEnabled ? (_states$markdownModeS = states.markdownModeState) === null || _states$markdownModeS === void 0 ? void 0 : _states$markdownModeS.view : undefined,
|
|
32
|
+
sourceBlockFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS2 = states.markdownModeState) === null || _states$markdownModeS2 === void 0 ? void 0 : _states$markdownModeS2.sourceBlockFormatState : null,
|
|
33
|
+
sourceListFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS3 = states.markdownModeState) === null || _states$markdownModeS3 === void 0 ? void 0 : _states$markdownModeS3.sourceListFormatState : null
|
|
26
34
|
};
|
|
27
35
|
});
|
|
36
|
+
const isInSourceView = isMarkdownToolbarEnabled && markdownView === 'syntax';
|
|
37
|
+
const isSourceTaskListActive = Boolean(sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inTaskList);
|
|
38
|
+
const isDisabled = isInSourceView ? Boolean((sourceBlockFormatState === null || sourceBlockFormatState === void 0 ? void 0 : sourceBlockFormatState.inCodeBlock) || isSourceTaskListActive) : bulletListDisabled && !taskListActive;
|
|
28
39
|
const onClick = () => {
|
|
29
40
|
var _api$taskDecision;
|
|
41
|
+
if (isInSourceView) {
|
|
42
|
+
var _api$markdownMode;
|
|
43
|
+
if (sourceBlockFormatState !== null && sourceBlockFormatState !== void 0 && sourceBlockFormatState.inCodeBlock) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (isSourceTaskListActive) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
api === null || api === void 0 ? void 0 : (_api$markdownMode = api.markdownMode) === null || _api$markdownMode === void 0 ? void 0 : _api$markdownMode.actions.toggleSourceBulletList();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
30
52
|
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('bulletList') : api === null || api === void 0 ? void 0 : api.list.commands.toggleBulletList(getInputMethodFromParentKeys(parents)));
|
|
31
53
|
};
|
|
32
|
-
const isDisabled = bulletListDisabled && !taskListActive;
|
|
33
54
|
const shortcut = formatShortcut(toggleBulletListKeymap);
|
|
34
55
|
return {
|
|
35
56
|
bulletMessage,
|
|
36
57
|
onClick,
|
|
37
58
|
isDisabled,
|
|
38
|
-
isSelected: bulletListActive,
|
|
59
|
+
isSelected: isInSourceView ? sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inBulletList : bulletListActive,
|
|
39
60
|
shortcut
|
|
40
61
|
};
|
|
41
62
|
};
|