@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
|
@@ -5,24 +5,45 @@ 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 var NumberedListMenuItem = function NumberedListMenuItem(_ref) {
|
|
9
10
|
var api = _ref.api,
|
|
10
11
|
parents = _ref.parents;
|
|
11
12
|
var _useIntl = useIntl(),
|
|
12
13
|
formatMessage = _useIntl.formatMessage;
|
|
13
|
-
var
|
|
14
|
-
|
|
14
|
+
var isMarkdownToolbarEnabled = isMarkdownCompatibleToolbarEnabled();
|
|
15
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['list', 'taskDecision', 'markdownMode'], function (states) {
|
|
16
|
+
var _states$listState, _states$listState2, _states$taskDecisionS, _states$markdownModeS, _states$markdownModeS2, _states$markdownModeS3;
|
|
15
17
|
return {
|
|
16
18
|
orderedListActive: (_states$listState = states.listState) === null || _states$listState === void 0 ? void 0 : _states$listState.orderedListActive,
|
|
17
19
|
orderedListDisabled: (_states$listState2 = states.listState) === null || _states$listState2 === void 0 ? void 0 : _states$listState2.orderedListDisabled,
|
|
18
|
-
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask
|
|
20
|
+
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask,
|
|
21
|
+
markdownView: isMarkdownToolbarEnabled ? (_states$markdownModeS = states.markdownModeState) === null || _states$markdownModeS === void 0 ? void 0 : _states$markdownModeS.view : undefined,
|
|
22
|
+
sourceBlockFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS2 = states.markdownModeState) === null || _states$markdownModeS2 === void 0 ? void 0 : _states$markdownModeS2.sourceBlockFormatState : null,
|
|
23
|
+
sourceListFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS3 = states.markdownModeState) === null || _states$markdownModeS3 === void 0 ? void 0 : _states$markdownModeS3.sourceListFormatState : null
|
|
19
24
|
};
|
|
20
25
|
}),
|
|
21
26
|
orderedListActive = _useSharedPluginState.orderedListActive,
|
|
22
27
|
orderedListDisabled = _useSharedPluginState.orderedListDisabled,
|
|
23
|
-
taskListActive = _useSharedPluginState.taskListActive
|
|
28
|
+
taskListActive = _useSharedPluginState.taskListActive,
|
|
29
|
+
sourceBlockFormatState = _useSharedPluginState.sourceBlockFormatState,
|
|
30
|
+
sourceListFormatState = _useSharedPluginState.sourceListFormatState,
|
|
31
|
+
markdownView = _useSharedPluginState.markdownView;
|
|
32
|
+
var isInSourceView = isMarkdownToolbarEnabled && markdownView === 'syntax';
|
|
33
|
+
var isSourceTaskListActive = Boolean(sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inTaskList);
|
|
24
34
|
var onClick = function onClick() {
|
|
25
35
|
var _api$taskDecision;
|
|
36
|
+
if (isInSourceView) {
|
|
37
|
+
var _api$markdownMode;
|
|
38
|
+
if (sourceBlockFormatState !== null && sourceBlockFormatState !== void 0 && sourceBlockFormatState.inCodeBlock) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (isSourceTaskListActive) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
api === null || api === void 0 || (_api$markdownMode = api.markdownMode) === null || _api$markdownMode === void 0 || _api$markdownMode.actions.toggleSourceOrderedList();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
26
47
|
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(getInputMethodFromParentKeys(parents)));
|
|
27
48
|
};
|
|
28
49
|
var shortcut = formatShortcut(toggleOrderedListKeymap);
|
|
@@ -34,8 +55,8 @@ export var NumberedListMenuItem = function NumberedListMenuItem(_ref) {
|
|
|
34
55
|
elemAfter: shortcut ? /*#__PURE__*/React.createElement(ToolbarKeyboardShortcutHint, {
|
|
35
56
|
shortcut: shortcut
|
|
36
57
|
}) : undefined,
|
|
37
|
-
isSelected: orderedListActive,
|
|
38
|
-
isDisabled: orderedListDisabled && !taskListActive,
|
|
58
|
+
isSelected: isInSourceView ? sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inOrderedList : orderedListActive,
|
|
59
|
+
isDisabled: isInSourceView ? Boolean((sourceBlockFormatState === null || sourceBlockFormatState === void 0 ? void 0 : sourceBlockFormatState.inCodeBlock) || isSourceTaskListActive) : orderedListDisabled && !taskListActive,
|
|
39
60
|
onClick: onClick,
|
|
40
61
|
ariaKeyshortcuts: shortcut
|
|
41
62
|
}, formatMessage(listMessages.orderedList));
|
|
@@ -1,22 +1,51 @@
|
|
|
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 var TaskListMenuItem = function TaskListMenuItem(_ref) {
|
|
9
10
|
var api = _ref.api;
|
|
10
11
|
var _useIntl = useIntl(),
|
|
11
12
|
formatMessage = _useIntl.formatMessage;
|
|
12
13
|
var _useEditorToolbar = useEditorToolbar(),
|
|
13
14
|
editorView = _useEditorToolbar.editorView;
|
|
14
|
-
var
|
|
15
|
+
var isMarkdownToolbarEnabled = isMarkdownCompatibleToolbarEnabled();
|
|
16
|
+
// Mirror the sibling BulletedListMenuItem / NumberedListMenuItem pattern:
|
|
17
|
+
// gate the markdown-mode field reads behind the feature flag inside the
|
|
18
|
+
// selector so we don't trigger re-renders on CM6 state changes for users
|
|
19
|
+
// who don't have the markdown-compatible toolbar enabled.
|
|
20
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['taskDecision', 'markdownMode'], function (states) {
|
|
21
|
+
var _states$taskDecisionS, _states$markdownModeS, _states$markdownModeS2, _states$markdownModeS3;
|
|
22
|
+
return {
|
|
23
|
+
taskListActive: (_states$taskDecisionS = states.taskDecisionState) === null || _states$taskDecisionS === void 0 ? void 0 : _states$taskDecisionS.isInsideTask,
|
|
24
|
+
markdownView: isMarkdownToolbarEnabled ? (_states$markdownModeS = states.markdownModeState) === null || _states$markdownModeS === void 0 ? void 0 : _states$markdownModeS.view : undefined,
|
|
25
|
+
sourceBlockFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS2 = states.markdownModeState) === null || _states$markdownModeS2 === void 0 ? void 0 : _states$markdownModeS2.sourceBlockFormatState : null,
|
|
26
|
+
sourceListFormatState: isMarkdownToolbarEnabled ? (_states$markdownModeS3 = states.markdownModeState) === null || _states$markdownModeS3 === void 0 ? void 0 : _states$markdownModeS3.sourceListFormatState : null
|
|
27
|
+
};
|
|
28
|
+
}),
|
|
29
|
+
taskListActive = _useSharedPluginState.taskListActive,
|
|
30
|
+
markdownView = _useSharedPluginState.markdownView,
|
|
31
|
+
sourceBlockFormatState = _useSharedPluginState.sourceBlockFormatState,
|
|
32
|
+
sourceListFormatState = _useSharedPluginState.sourceListFormatState;
|
|
15
33
|
if (!(editorView !== null && editorView !== void 0 && editorView.state.schema.nodes.taskItem)) {
|
|
16
34
|
return null;
|
|
17
35
|
}
|
|
36
|
+
var isInSourceView = isMarkdownToolbarEnabled && markdownView === 'syntax';
|
|
37
|
+
var isSelected = isInSourceView ? sourceListFormatState === null || sourceListFormatState === void 0 ? void 0 : sourceListFormatState.inTaskList : taskListActive;
|
|
38
|
+
var isDisabled = Boolean(isInSourceView && (sourceBlockFormatState === null || sourceBlockFormatState === void 0 ? void 0 : sourceBlockFormatState.inCodeBlock));
|
|
18
39
|
var handleClick = function handleClick() {
|
|
19
40
|
var _api$taskDecision;
|
|
41
|
+
if (isDisabled) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (isInSourceView) {
|
|
45
|
+
var _api$markdownMode;
|
|
46
|
+
api === null || api === void 0 || (_api$markdownMode = api.markdownMode) === null || _api$markdownMode === void 0 || _api$markdownMode.actions.toggleSourceTaskList();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
20
49
|
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());
|
|
21
50
|
};
|
|
22
51
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
@@ -27,8 +56,8 @@ export var TaskListMenuItem = function TaskListMenuItem(_ref) {
|
|
|
27
56
|
elemAfter: /*#__PURE__*/React.createElement(ToolbarKeyboardShortcutHint, {
|
|
28
57
|
shortcut: "[]"
|
|
29
58
|
}),
|
|
30
|
-
isSelected:
|
|
31
|
-
isDisabled:
|
|
59
|
+
isSelected: isSelected,
|
|
60
|
+
isDisabled: isDisabled,
|
|
32
61
|
onClick: handleClick
|
|
33
62
|
}, formatMessage(tasksAndDecisionsMessages.taskList));
|
|
34
63
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
3
|
+
export var isMarkdownCompatibleToolbarEnabled = function isMarkdownCompatibleToolbarEnabled() {
|
|
4
|
+
return expValEqualsNoExposure('cc-markdown-mode', 'isEnabled', true) && fg('platform_editor_markdown_compatible_toolbar');
|
|
5
|
+
};
|
|
@@ -13,7 +13,32 @@ export type ToolbarListsIndentationPluginOptions = {
|
|
|
13
13
|
allowHeadingAndParagraphIndentation: boolean;
|
|
14
14
|
showIndentationButtons: boolean;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Minimal duck-typed slice of `@atlassian/editor-plugin-markdown-mode`'s
|
|
18
|
+
* `MarkdownModePlugin` covering only the list/task source-view surface this
|
|
19
|
+
* plugin uses. See `editor-plugin-text-formatting/textFormattingPluginType.ts`
|
|
20
|
+
* for the rationale for not importing the real type.
|
|
21
|
+
*/
|
|
22
|
+
type _MarkdownModePluginStub = NextEditorPlugin<'markdownMode', {
|
|
23
|
+
actions: {
|
|
24
|
+
toggleSourceBulletList: () => boolean;
|
|
25
|
+
toggleSourceOrderedList: () => boolean;
|
|
26
|
+
toggleSourceTaskList: () => boolean;
|
|
27
|
+
};
|
|
28
|
+
sharedState: {
|
|
29
|
+
sourceBlockFormatState: {
|
|
30
|
+
inCodeBlock: boolean;
|
|
31
|
+
} | null;
|
|
32
|
+
sourceListFormatState: {
|
|
33
|
+
inBulletList: boolean;
|
|
34
|
+
inOrderedList: boolean;
|
|
35
|
+
inTaskList: boolean;
|
|
36
|
+
} | null;
|
|
37
|
+
view: 'syntax' | 'split-view' | 'preview';
|
|
38
|
+
} | undefined;
|
|
39
|
+
}>;
|
|
16
40
|
export type ToolbarListsIndentationPluginDependencies = [
|
|
41
|
+
OptionalPlugin<_MarkdownModePluginStub>,
|
|
17
42
|
OptionalPlugin<FeatureFlagsPlugin>,
|
|
18
43
|
ListPlugin,
|
|
19
44
|
OptionalPlugin<IndentationPlugin>,
|
|
@@ -29,3 +54,4 @@ export type ToolbarListsIndentationPlugin = NextEditorPlugin<'toolbarListsIndent
|
|
|
29
54
|
dependencies: ToolbarListsIndentationPluginDependencies;
|
|
30
55
|
pluginConfiguration: ToolbarListsIndentationPluginOptions;
|
|
31
56
|
}>;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isMarkdownCompatibleToolbarEnabled: () => boolean;
|
|
@@ -13,7 +13,32 @@ export type ToolbarListsIndentationPluginOptions = {
|
|
|
13
13
|
allowHeadingAndParagraphIndentation: boolean;
|
|
14
14
|
showIndentationButtons: boolean;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Minimal duck-typed slice of `@atlassian/editor-plugin-markdown-mode`'s
|
|
18
|
+
* `MarkdownModePlugin` covering only the list/task source-view surface this
|
|
19
|
+
* plugin uses. See `editor-plugin-text-formatting/textFormattingPluginType.ts`
|
|
20
|
+
* for the rationale for not importing the real type.
|
|
21
|
+
*/
|
|
22
|
+
type _MarkdownModePluginStub = NextEditorPlugin<'markdownMode', {
|
|
23
|
+
actions: {
|
|
24
|
+
toggleSourceBulletList: () => boolean;
|
|
25
|
+
toggleSourceOrderedList: () => boolean;
|
|
26
|
+
toggleSourceTaskList: () => boolean;
|
|
27
|
+
};
|
|
28
|
+
sharedState: {
|
|
29
|
+
sourceBlockFormatState: {
|
|
30
|
+
inCodeBlock: boolean;
|
|
31
|
+
} | null;
|
|
32
|
+
sourceListFormatState: {
|
|
33
|
+
inBulletList: boolean;
|
|
34
|
+
inOrderedList: boolean;
|
|
35
|
+
inTaskList: boolean;
|
|
36
|
+
} | null;
|
|
37
|
+
view: 'syntax' | 'split-view' | 'preview';
|
|
38
|
+
} | undefined;
|
|
39
|
+
}>;
|
|
16
40
|
export type ToolbarListsIndentationPluginDependencies = [
|
|
41
|
+
OptionalPlugin<_MarkdownModePluginStub>,
|
|
17
42
|
OptionalPlugin<FeatureFlagsPlugin>,
|
|
18
43
|
ListPlugin,
|
|
19
44
|
OptionalPlugin<IndentationPlugin>,
|
|
@@ -29,3 +54,4 @@ export type ToolbarListsIndentationPlugin = NextEditorPlugin<'toolbarListsIndent
|
|
|
29
54
|
dependencies: ToolbarListsIndentationPluginDependencies;
|
|
30
55
|
pluginConfiguration: ToolbarListsIndentationPluginOptions;
|
|
31
56
|
}>;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isMarkdownCompatibleToolbarEnabled: () => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-toolbar-lists-indentation",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.2.0",
|
|
4
4
|
"description": "Toolbar lists and indentation plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,25 +38,25 @@
|
|
|
38
38
|
"@atlaskit/editor-plugin-list": "^12.1.0",
|
|
39
39
|
"@atlaskit/editor-plugin-primary-toolbar": "^11.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-selection-toolbar": "^11.3.0",
|
|
41
|
-
"@atlaskit/editor-plugin-tasks-and-decisions": "^13.
|
|
41
|
+
"@atlaskit/editor-plugin-tasks-and-decisions": "^13.3.0",
|
|
42
42
|
"@atlaskit/editor-plugin-toolbar": "^7.3.0",
|
|
43
43
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
44
|
-
"@atlaskit/editor-toolbar": "^1.
|
|
44
|
+
"@atlaskit/editor-toolbar": "^1.8.0",
|
|
45
45
|
"@atlaskit/editor-toolbar-model": "^0.5.0",
|
|
46
46
|
"@atlaskit/icon": "^35.3.0",
|
|
47
47
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
48
|
-
"@atlaskit/tmp-editor-statsig": "^84.
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^84.2.0",
|
|
49
49
|
"@atlaskit/tokens": "^13.0.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@atlaskit/editor-common": "^114.
|
|
53
|
+
"@atlaskit/editor-common": "^114.48.0",
|
|
54
54
|
"react": "^18.2.0",
|
|
55
55
|
"react-dom": "^18.2.0",
|
|
56
56
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@atlaskit/adf-schema": "^52.
|
|
59
|
+
"@atlaskit/adf-schema": "^52.15.0",
|
|
60
60
|
"@testing-library/react": "^16.3.0",
|
|
61
61
|
"react": "^18.2.0",
|
|
62
62
|
"react-dom": "^18.2.0",
|
|
@@ -99,6 +99,9 @@
|
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
101
|
"platform-feature-flags": {
|
|
102
|
+
"platform_editor_markdown_compatible_toolbar": {
|
|
103
|
+
"type": "boolean"
|
|
104
|
+
},
|
|
102
105
|
"platform_editor_use_preferences_plugin": {
|
|
103
106
|
"type": "boolean"
|
|
104
107
|
}
|