@atlaskit/editor-core 187.7.2 → 187.8.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 +6 -0
- package/dist/cjs/plugins/list/commands/indent-list.js +48 -45
- package/dist/cjs/plugins/list/commands/index.js +120 -109
- package/dist/cjs/plugins/list/commands/join-list-item-forward.js +47 -45
- package/dist/cjs/plugins/list/commands/listBackspace.js +33 -31
- package/dist/cjs/plugins/list/commands/outdent-list.js +51 -49
- package/dist/cjs/plugins/list/index.js +10 -5
- package/dist/cjs/plugins/list/pm-plugins/input-rules/create-list-input-rule.js +3 -4
- package/dist/cjs/plugins/list/pm-plugins/keymap.js +10 -11
- package/dist/cjs/plugins/toolbar-lists-indentation/index.js +4 -1
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/index.js +4 -3
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +44 -41
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/list/commands/indent-list.js +5 -5
- package/dist/es2019/plugins/list/commands/index.js +22 -22
- package/dist/es2019/plugins/list/commands/join-list-item-forward.js +4 -4
- package/dist/es2019/plugins/list/commands/listBackspace.js +4 -4
- package/dist/es2019/plugins/list/commands/outdent-list.js +5 -6
- package/dist/es2019/plugins/list/index.js +13 -6
- package/dist/es2019/plugins/list/pm-plugins/input-rules/create-list-input-rule.js +1 -1
- package/dist/es2019/plugins/list/pm-plugins/keymap.js +11 -11
- package/dist/es2019/plugins/toolbar-lists-indentation/index.js +4 -1
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/index.js +4 -3
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +7 -7
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/list/commands/indent-list.js +46 -44
- package/dist/esm/plugins/list/commands/index.js +115 -103
- package/dist/esm/plugins/list/commands/join-list-item-forward.js +47 -45
- package/dist/esm/plugins/list/commands/listBackspace.js +33 -31
- package/dist/esm/plugins/list/commands/outdent-list.js +49 -48
- package/dist/esm/plugins/list/index.js +11 -6
- package/dist/esm/plugins/list/pm-plugins/input-rules/create-list-input-rule.js +1 -1
- package/dist/esm/plugins/list/pm-plugins/keymap.js +11 -11
- package/dist/esm/plugins/toolbar-lists-indentation/index.js +4 -1
- package/dist/esm/plugins/toolbar-lists-indentation/ui/index.js +4 -3
- package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +42 -40
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/list/commands/indent-list.d.ts +2 -2
- package/dist/types/plugins/list/commands/index.d.ts +7 -7
- package/dist/types/plugins/list/commands/join-list-item-forward.d.ts +2 -1
- package/dist/types/plugins/list/commands/listBackspace.d.ts +7 -6
- package/dist/types/plugins/list/commands/outdent-list.d.ts +2 -2
- package/dist/types/plugins/list/index.d.ts +7 -2
- package/dist/types/plugins/list/pm-plugins/keymap.d.ts +2 -1
- package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +7 -2
- package/dist/types/plugins/toolbar-lists-indentation/types.d.ts +1 -1
- package/dist/types/plugins/toolbar-lists-indentation/ui/index.d.ts +3 -1
- package/dist/types/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +5 -4
- package/dist/types/utils/list-commands.d.ts +5 -5
- package/dist/types-ts4.5/plugins/list/commands/indent-list.d.ts +2 -2
- package/dist/types-ts4.5/plugins/list/commands/index.d.ts +7 -7
- package/dist/types-ts4.5/plugins/list/commands/join-list-item-forward.d.ts +2 -1
- package/dist/types-ts4.5/plugins/list/commands/listBackspace.d.ts +7 -6
- package/dist/types-ts4.5/plugins/list/commands/outdent-list.d.ts +2 -2
- package/dist/types-ts4.5/plugins/list/index.d.ts +5 -2
- package/dist/types-ts4.5/plugins/list/pm-plugins/keymap.d.ts +2 -1
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/index.d.ts +5 -2
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/types.d.ts +1 -1
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +5 -4
- package/dist/types-ts4.5/utils/list-commands.d.ts +5 -5
- package/package.json +1 -1
- package/report.api.md +15 -31
- package/tmp/api-report-tmp.d.ts +4 -22
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { insertContentDeleteRange, isEmptySelectionAtStart, walkPrevNode } from '../../../utils/commands';
|
|
2
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, DELETE_DIRECTION, LIST_TEXT_SCENARIOS
|
|
2
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, DELETE_DIRECTION, LIST_TEXT_SCENARIOS } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { findParentNodeOfType } from 'prosemirror-utils';
|
|
4
4
|
import { isListNode, isParagraphNode } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { isPosInsideList, isPosInsideParagraph } from '../utils/selection';
|
|
@@ -238,7 +238,7 @@ export const calcJoinListScenario = (walkNode, $head, tr) => {
|
|
|
238
238
|
}
|
|
239
239
|
return false;
|
|
240
240
|
};
|
|
241
|
-
export const listBackspace = (state, dispatch) => {
|
|
241
|
+
export const listBackspace = editorAnalyticsAPI => (state, dispatch) => {
|
|
242
242
|
const {
|
|
243
243
|
tr,
|
|
244
244
|
selection: {
|
|
@@ -262,7 +262,7 @@ export const listBackspace = (state, dispatch) => {
|
|
|
262
262
|
if (listParent && listParent.node.type === orderedList) {
|
|
263
263
|
actionSubjectId = ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
|
|
264
264
|
}
|
|
265
|
-
|
|
265
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
266
266
|
action: ACTION.LIST_ITEM_JOINED,
|
|
267
267
|
actionSubject: ACTION_SUBJECT.LIST,
|
|
268
268
|
actionSubjectId,
|
|
@@ -272,6 +272,6 @@ export const listBackspace = (state, dispatch) => {
|
|
|
272
272
|
direction: DELETE_DIRECTION.BACKWARD,
|
|
273
273
|
scenario: scenario[0]
|
|
274
274
|
}
|
|
275
|
-
});
|
|
275
|
+
})(tr);
|
|
276
276
|
return BACKSPACE_COMMANDS[scenario[0]](tr, dispatch, walkNode.$pos, $head, scenario[1]);
|
|
277
277
|
};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { OUTDENT_SCENARIOS } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { addAnalytics, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '../../analytics';
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, OUTDENT_SCENARIOS } from '@atlaskit/editor-common/analytics';
|
|
3
2
|
import { isInsideListItem, isInsideTableCell } from '../utils/selection';
|
|
4
3
|
import { isBulletList } from '../utils/node';
|
|
5
4
|
import { findFirstParentListNode } from '../utils/find';
|
|
6
5
|
import { getCommonListAnalyticsAttributes, getRestartListsAttributes } from '../utils/analytics';
|
|
7
6
|
import { outdentListItemsSelected as outdentListAction } from '../actions/outdent-list-items-selected';
|
|
8
7
|
import { closeHistory } from 'prosemirror-history';
|
|
9
|
-
export
|
|
8
|
+
export const outdentList = editorAnalyticsAPI => (inputMethod = INPUT_METHOD.KEYBOARD, featureFlags) => {
|
|
10
9
|
return function (state, dispatch) {
|
|
11
10
|
if (!isInsideListItem(state)) {
|
|
12
11
|
return false;
|
|
@@ -41,7 +40,7 @@ export function outdentList(inputMethod = INPUT_METHOD.KEYBOARD, featureFlags) {
|
|
|
41
40
|
restartListsAttributes.splitListStartNumber = splitListStartNumber;
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
|
-
|
|
43
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
45
44
|
action: ACTION.OUTDENTED,
|
|
46
45
|
actionSubject: ACTION_SUBJECT.LIST,
|
|
47
46
|
actionSubjectId,
|
|
@@ -51,10 +50,10 @@ export function outdentList(inputMethod = INPUT_METHOD.KEYBOARD, featureFlags) {
|
|
|
51
50
|
...restartListsAttributes,
|
|
52
51
|
inputMethod
|
|
53
52
|
}
|
|
54
|
-
});
|
|
53
|
+
})(customTr);
|
|
55
54
|
if (dispatch) {
|
|
56
55
|
dispatch(customTr);
|
|
57
56
|
}
|
|
58
57
|
return true;
|
|
59
58
|
};
|
|
60
|
-
}
|
|
59
|
+
};
|
|
@@ -4,7 +4,7 @@ import { createPlugin } from './pm-plugins/main';
|
|
|
4
4
|
import inputRulePlugin from './pm-plugins/input-rules';
|
|
5
5
|
import keymapPlugin from './pm-plugins/keymap';
|
|
6
6
|
import { messages } from './messages';
|
|
7
|
-
import {
|
|
7
|
+
import { ACTION, EVENT_TYPE, INPUT_METHOD, ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../analytics';
|
|
8
8
|
import { tooltip, toggleBulletList, toggleOrderedList } from '../../keymaps';
|
|
9
9
|
import { IconList, IconListNumber } from '@atlaskit/editor-common/quick-insert';
|
|
10
10
|
/*
|
|
@@ -12,7 +12,9 @@ import { IconList, IconListNumber } from '@atlaskit/editor-common/quick-insert';
|
|
|
12
12
|
packages/editor/editor-core/src/plugins/toolbar-lists-indentation/ui/Toolbar.tsx
|
|
13
13
|
*/
|
|
14
14
|
const listPlugin = (options, api) => {
|
|
15
|
+
var _api$dependencies$ana;
|
|
15
16
|
const featureFlags = (api === null || api === void 0 ? void 0 : api.dependencies.featureFlags.sharedState.currentState()) || {};
|
|
17
|
+
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions;
|
|
16
18
|
return {
|
|
17
19
|
name: 'list',
|
|
18
20
|
nodes() {
|
|
@@ -41,7 +43,10 @@ const listPlugin = (options, api) => {
|
|
|
41
43
|
}) => inputRulePlugin(schema, featureFlags)
|
|
42
44
|
}, {
|
|
43
45
|
name: 'listKeymap',
|
|
44
|
-
plugin: () =>
|
|
46
|
+
plugin: () => {
|
|
47
|
+
var _api$dependencies$ana2;
|
|
48
|
+
return keymapPlugin(featureFlags, api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions);
|
|
49
|
+
}
|
|
45
50
|
}];
|
|
46
51
|
},
|
|
47
52
|
pluginsOptions: {
|
|
@@ -57,7 +62,7 @@ const listPlugin = (options, api) => {
|
|
|
57
62
|
icon: () => /*#__PURE__*/React.createElement(IconList, null),
|
|
58
63
|
action(insert, state) {
|
|
59
64
|
const tr = insert(state.schema.nodes.bulletList.createChecked({}, state.schema.nodes.listItem.createChecked({}, state.schema.nodes.paragraph.createChecked())));
|
|
60
|
-
|
|
65
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
61
66
|
action: ACTION.INSERTED,
|
|
62
67
|
actionSubject: ACTION_SUBJECT.LIST,
|
|
63
68
|
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_LIST_BULLET,
|
|
@@ -65,7 +70,8 @@ const listPlugin = (options, api) => {
|
|
|
65
70
|
attributes: {
|
|
66
71
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
67
72
|
}
|
|
68
|
-
});
|
|
73
|
+
})(tr);
|
|
74
|
+
return tr;
|
|
69
75
|
}
|
|
70
76
|
}, {
|
|
71
77
|
id: 'orderedList',
|
|
@@ -77,7 +83,7 @@ const listPlugin = (options, api) => {
|
|
|
77
83
|
icon: () => /*#__PURE__*/React.createElement(IconListNumber, null),
|
|
78
84
|
action(insert, state) {
|
|
79
85
|
const tr = insert(state.schema.nodes.orderedList.createChecked({}, state.schema.nodes.listItem.createChecked({}, state.schema.nodes.paragraph.createChecked())));
|
|
80
|
-
|
|
86
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
81
87
|
action: ACTION.INSERTED,
|
|
82
88
|
actionSubject: ACTION_SUBJECT.LIST,
|
|
83
89
|
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER,
|
|
@@ -85,7 +91,8 @@ const listPlugin = (options, api) => {
|
|
|
85
91
|
attributes: {
|
|
86
92
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
87
93
|
}
|
|
88
|
-
});
|
|
94
|
+
})(tr);
|
|
95
|
+
return tr;
|
|
89
96
|
}
|
|
90
97
|
}]
|
|
91
98
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ruleWithAnalytics } from '../../../../utils/input-rules';
|
|
2
2
|
import { createWrappingJoinRule } from './wrapping-join-rule';
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '
|
|
3
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
const getOrder = matchResult => Number(matchResult[1]);
|
|
6
6
|
export function createRuleForListType({
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { keymap } from 'prosemirror-keymap';
|
|
2
2
|
import * as keymaps from '../../../keymaps';
|
|
3
3
|
import { indentList, enterKeyCommand, toggleList, backspaceKeyCommand, deleteKeyCommand } from '../commands';
|
|
4
|
-
import { outdentList } from '../commands
|
|
5
|
-
import { INPUT_METHOD } from '
|
|
6
|
-
export function keymapPlugin(featureFlags) {
|
|
4
|
+
import { outdentList } from '../commands';
|
|
5
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
|
+
export function keymapPlugin(featureFlags, editorAnalyticsAPI) {
|
|
7
7
|
const list = {};
|
|
8
|
-
keymaps.bindKeymapWithCommand(keymaps.findShortcutByKeymap(keymaps.toggleOrderedList), toggleList(INPUT_METHOD.KEYBOARD, 'orderedList'), list);
|
|
9
|
-
keymaps.bindKeymapWithCommand(keymaps.findShortcutByKeymap(keymaps.toggleBulletList), toggleList(INPUT_METHOD.KEYBOARD, 'bulletList'), list);
|
|
10
|
-
keymaps.bindKeymapWithCommand(keymaps.indentList.common, indentList(INPUT_METHOD.KEYBOARD), list);
|
|
11
|
-
keymaps.bindKeymapWithCommand(keymaps.outdentList.common, outdentList(INPUT_METHOD.KEYBOARD, featureFlags), list);
|
|
12
|
-
keymaps.bindKeymapWithCommand(keymaps.enter.common, enterKeyCommand(featureFlags), list);
|
|
13
|
-
keymaps.bindKeymapWithCommand(keymaps.backspace.common, backspaceKeyCommand(featureFlags), list);
|
|
14
|
-
keymaps.bindKeymapWithCommand(keymaps.deleteKey.common, deleteKeyCommand, list);
|
|
8
|
+
keymaps.bindKeymapWithCommand(keymaps.findShortcutByKeymap(keymaps.toggleOrderedList), toggleList(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, 'orderedList'), list);
|
|
9
|
+
keymaps.bindKeymapWithCommand(keymaps.findShortcutByKeymap(keymaps.toggleBulletList), toggleList(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, 'bulletList'), list);
|
|
10
|
+
keymaps.bindKeymapWithCommand(keymaps.indentList.common, indentList(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD), list);
|
|
11
|
+
keymaps.bindKeymapWithCommand(keymaps.outdentList.common, outdentList(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, featureFlags), list);
|
|
12
|
+
keymaps.bindKeymapWithCommand(keymaps.enter.common, enterKeyCommand(editorAnalyticsAPI)(featureFlags), list);
|
|
13
|
+
keymaps.bindKeymapWithCommand(keymaps.backspace.common, backspaceKeyCommand(editorAnalyticsAPI)(featureFlags), list);
|
|
14
|
+
keymaps.bindKeymapWithCommand(keymaps.deleteKey.common, deleteKeyCommand(editorAnalyticsAPI), list);
|
|
15
15
|
|
|
16
16
|
// This shortcut is Mac only
|
|
17
|
-
keymaps.bindKeymapWithCommand(keymaps.findKeyMapForBrowser(keymaps.forwardDelete), deleteKeyCommand, list);
|
|
17
|
+
keymaps.bindKeymapWithCommand(keymaps.findKeyMapForBrowser(keymaps.forwardDelete), deleteKeyCommand(editorAnalyticsAPI), list);
|
|
18
18
|
return keymap(list);
|
|
19
19
|
}
|
|
20
20
|
export default keymapPlugin;
|
|
@@ -8,7 +8,9 @@ const toolbarListsIndentationPlugin = ({
|
|
|
8
8
|
showIndentationButtons,
|
|
9
9
|
allowHeadingAndParagraphIndentation
|
|
10
10
|
}, api) => {
|
|
11
|
+
var _api$dependencies$ana;
|
|
11
12
|
const featureFlags = (api === null || api === void 0 ? void 0 : api.dependencies.featureFlags.sharedState.currentState()) || {};
|
|
13
|
+
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions;
|
|
12
14
|
return {
|
|
13
15
|
name: 'toolbarListsIndentation',
|
|
14
16
|
pmPlugins() {
|
|
@@ -60,7 +62,8 @@ const toolbarListsIndentationPlugin = ({
|
|
|
60
62
|
orderedListDisabled: listState.orderedListDisabled,
|
|
61
63
|
showIndentationButtons: !!showIndentationButtons,
|
|
62
64
|
indentDisabled: indentationState.indentDisabled,
|
|
63
|
-
outdentDisabled: indentationState.outdentDisabled
|
|
65
|
+
outdentDisabled: indentationState.outdentDisabled,
|
|
66
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
64
67
|
});
|
|
65
68
|
}
|
|
66
69
|
});
|
|
@@ -18,7 +18,8 @@ export default function ToolbarListsIndentation(props) {
|
|
|
18
18
|
popupsScrollableElement,
|
|
19
19
|
indentDisabled,
|
|
20
20
|
outdentDisabled,
|
|
21
|
-
featureFlags
|
|
21
|
+
featureFlags,
|
|
22
|
+
editorAnalyticsAPI
|
|
22
23
|
} = props;
|
|
23
24
|
if (isSmall) {
|
|
24
25
|
return jsx(ToolbarDropdown, {
|
|
@@ -35,7 +36,7 @@ export default function ToolbarListsIndentation(props) {
|
|
|
35
36
|
indentDisabled: indentDisabled,
|
|
36
37
|
outdentDisabled: outdentDisabled,
|
|
37
38
|
disabled: disabled,
|
|
38
|
-
onItemActivated: onItemActivated,
|
|
39
|
+
onItemActivated: onItemActivated(editorAnalyticsAPI),
|
|
39
40
|
featureFlags: featureFlags
|
|
40
41
|
});
|
|
41
42
|
}
|
|
@@ -50,7 +51,7 @@ export default function ToolbarListsIndentation(props) {
|
|
|
50
51
|
indentDisabled: indentDisabled,
|
|
51
52
|
outdentDisabled: outdentDisabled,
|
|
52
53
|
disabled: disabled,
|
|
53
|
-
onItemActivated: onItemActivated,
|
|
54
|
+
onItemActivated: onItemActivated(editorAnalyticsAPI),
|
|
54
55
|
featureFlags: featureFlags
|
|
55
56
|
});
|
|
56
57
|
}
|
|
@@ -3,17 +3,17 @@ import { getIndentCommand as indentParagraphOrHeading, getOutdentCommand as outd
|
|
|
3
3
|
import { getIndentCommand as indentTaskList, getUnindentCommand as outdentTaskList } from '../../tasks-and-decisions/pm-plugins/keymaps';
|
|
4
4
|
import { INPUT_METHOD } from '../../analytics';
|
|
5
5
|
import { pluginKey as indentationButtonsPluginKey } from '../pm-plugins/indentation-buttons';
|
|
6
|
-
export
|
|
6
|
+
export const onItemActivated = editorAnalyticsAPI => ({
|
|
7
7
|
buttonName,
|
|
8
8
|
editorView,
|
|
9
9
|
featureFlags
|
|
10
|
-
}) {
|
|
10
|
+
}) => {
|
|
11
11
|
switch (buttonName) {
|
|
12
12
|
case 'bullet_list':
|
|
13
|
-
toggleBulletList(editorView, INPUT_METHOD.TOOLBAR);
|
|
13
|
+
toggleBulletList(editorAnalyticsAPI)(editorView, INPUT_METHOD.TOOLBAR);
|
|
14
14
|
break;
|
|
15
15
|
case 'ordered_list':
|
|
16
|
-
toggleOrderedList(editorView, INPUT_METHOD.TOOLBAR);
|
|
16
|
+
toggleOrderedList(editorAnalyticsAPI)(editorView, INPUT_METHOD.TOOLBAR);
|
|
17
17
|
break;
|
|
18
18
|
case 'indent':
|
|
19
19
|
{
|
|
@@ -23,7 +23,7 @@ export function onItemActivated({
|
|
|
23
23
|
indentParagraphOrHeading(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
24
24
|
}
|
|
25
25
|
if (node === 'list') {
|
|
26
|
-
indentList(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
26
|
+
indentList(editorAnalyticsAPI)(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
27
27
|
}
|
|
28
28
|
if (node === 'taskList') {
|
|
29
29
|
indentTaskList(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
@@ -38,7 +38,7 @@ export function onItemActivated({
|
|
|
38
38
|
outdentParagraphOrHeading(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
39
39
|
}
|
|
40
40
|
if (node === 'list') {
|
|
41
|
-
outdentList(INPUT_METHOD.TOOLBAR, featureFlags)(editorView.state, editorView.dispatch);
|
|
41
|
+
outdentList(editorAnalyticsAPI)(INPUT_METHOD.TOOLBAR, featureFlags)(editorView.state, editorView.dispatch);
|
|
42
42
|
}
|
|
43
43
|
if (node === 'taskList') {
|
|
44
44
|
outdentTaskList(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
@@ -46,4 +46,4 @@ export function onItemActivated({
|
|
|
46
46
|
break;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD
|
|
4
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { hasValidListIndentationLevel } from '../utils/indentation';
|
|
6
6
|
import { indentListItemsSelected as indentListAction } from '../actions/indent-list-items-selected';
|
|
7
7
|
import { isBulletList } from '../utils/node';
|
|
@@ -10,53 +10,55 @@ import { MAX_NESTED_LIST_INDENTATION } from '../types';
|
|
|
10
10
|
import { isInsideListItem, isInsideTableCell, getListItemAttributes } from '../utils/selection';
|
|
11
11
|
import { getCommonListAnalyticsAttributes } from '../utils/analytics';
|
|
12
12
|
import { closeHistory } from 'prosemirror-history';
|
|
13
|
-
export function indentList() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
export var indentList = function indentList(editorAnalyticsAPI) {
|
|
14
|
+
return function () {
|
|
15
|
+
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INPUT_METHOD.KEYBOARD;
|
|
16
|
+
return function (state, dispatch) {
|
|
17
|
+
var tr = state.tr,
|
|
18
|
+
$from = state.selection.$from;
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Save the history, so it could undo/revert to the same state before the indent, see https://product-fabric.atlassian.net/browse/ED-14753
|
|
25
|
-
closeHistory(tr);
|
|
26
|
-
var firstListItemSelectedAttributes = getListItemAttributes($from);
|
|
27
|
-
var parentListNode = findFirstParentListNode($from);
|
|
28
|
-
if (!parentListNode || firstListItemSelectedAttributes && firstListItemSelectedAttributes.indentLevel === 0 && firstListItemSelectedAttributes.itemIndex === 0) {
|
|
29
|
-
if (isInsideTableCell(state)) {
|
|
30
|
-
// dont consume tab, as table-keymap should move cursor to next cell
|
|
20
|
+
// don't indent if selection is not inside a list
|
|
21
|
+
if (!isInsideListItem(state)) {
|
|
31
22
|
return false;
|
|
32
|
-
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Save the history, so it could undo/revert to the same state before the indent, see https://product-fabric.atlassian.net/browse/ED-14753
|
|
26
|
+
closeHistory(tr);
|
|
27
|
+
var firstListItemSelectedAttributes = getListItemAttributes($from);
|
|
28
|
+
var parentListNode = findFirstParentListNode($from);
|
|
29
|
+
if (!parentListNode || firstListItemSelectedAttributes && firstListItemSelectedAttributes.indentLevel === 0 && firstListItemSelectedAttributes.itemIndex === 0) {
|
|
30
|
+
if (isInsideTableCell(state)) {
|
|
31
|
+
// dont consume tab, as table-keymap should move cursor to next cell
|
|
32
|
+
return false;
|
|
33
|
+
} else {
|
|
34
|
+
// Even though this is a non-operation, we don't want to send this event to the browser. Because if we return false, the browser will move the focus to another place
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
var currentListNode = parentListNode.node;
|
|
39
|
+
var actionSubjectId = isBulletList(currentListNode) ? ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
|
|
40
|
+
indentListAction(tr);
|
|
41
|
+
var maximimunNestedLevelReached = !hasValidListIndentationLevel({
|
|
42
|
+
tr: tr,
|
|
43
|
+
maxIndentation: MAX_NESTED_LIST_INDENTATION
|
|
44
|
+
});
|
|
45
|
+
if (maximimunNestedLevelReached || !tr.docChanged) {
|
|
33
46
|
// Even though this is a non-operation, we don't want to send this event to the browser. Because if we return false, the browser will move the focus to another place
|
|
34
47
|
return true;
|
|
35
48
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
50
|
+
action: ACTION.INDENTED,
|
|
51
|
+
actionSubject: ACTION_SUBJECT.LIST,
|
|
52
|
+
actionSubjectId: actionSubjectId,
|
|
53
|
+
eventType: EVENT_TYPE.TRACK,
|
|
54
|
+
attributes: _objectSpread(_objectSpread({}, getCommonListAnalyticsAttributes(state)), {}, {
|
|
55
|
+
inputMethod: inputMethod
|
|
56
|
+
})
|
|
57
|
+
})(tr);
|
|
58
|
+
if (dispatch) {
|
|
59
|
+
dispatch(tr);
|
|
60
|
+
}
|
|
46
61
|
return true;
|
|
47
|
-
}
|
|
48
|
-
addAnalytics(state, tr, {
|
|
49
|
-
action: ACTION.INDENTED,
|
|
50
|
-
actionSubject: ACTION_SUBJECT.LIST,
|
|
51
|
-
actionSubjectId: actionSubjectId,
|
|
52
|
-
eventType: EVENT_TYPE.TRACK,
|
|
53
|
-
attributes: _objectSpread(_objectSpread({}, getCommonListAnalyticsAttributes(state)), {}, {
|
|
54
|
-
inputMethod: inputMethod
|
|
55
|
-
})
|
|
56
|
-
});
|
|
57
|
-
if (dispatch) {
|
|
58
|
-
dispatch(tr);
|
|
59
|
-
}
|
|
60
|
-
return true;
|
|
62
|
+
};
|
|
61
63
|
};
|
|
62
|
-
}
|
|
64
|
+
};
|