@atlaskit/editor-core 187.7.1 → 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 +12 -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 +5 -2
- package/report.api.md +15 -31
- package/tmp/api-report-tmp.d.ts +4 -22
|
@@ -5,13 +5,13 @@ import { Fragment, Slice } from 'prosemirror-model';
|
|
|
5
5
|
import { NodeSelection, TextSelection } from 'prosemirror-state';
|
|
6
6
|
import * as baseCommand from 'prosemirror-commands';
|
|
7
7
|
import { hasParentNodeOfType, findPositionOfNodeBefore } from 'prosemirror-utils';
|
|
8
|
-
import { hasVisibleContent } from '../../../utils
|
|
8
|
+
import { hasVisibleContent } from '../../../utils';
|
|
9
9
|
import { findCutBefore, isEmptySelectionAtStart, isFirstChildOfParent } from '../../../utils/commands';
|
|
10
10
|
import { filterCommands as filter } from '@atlaskit/editor-common/utils';
|
|
11
11
|
import { sanitiseMarksInSelection } from '../../../utils';
|
|
12
12
|
import { liftFollowingList, liftTextSelectionList, liftNodeSelectionList } from '../transforms';
|
|
13
13
|
import { GapCursorSelection } from '../../selection/gap-cursor-selection';
|
|
14
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD
|
|
14
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
15
15
|
import { isInsideListItem, canJoinToPreviousListItem, selectionContainsList } from '../utils/selection';
|
|
16
16
|
import { getCommonListAnalyticsAttributes } from '../utils/analytics';
|
|
17
17
|
import { listBackspace } from './listBackspace';
|
|
@@ -22,42 +22,48 @@ import { outdentList } from './outdent-list';
|
|
|
22
22
|
import { indentList } from './indent-list';
|
|
23
23
|
import { moveTargetIntoList } from '../utils/replace-content';
|
|
24
24
|
export { outdentList, indentList };
|
|
25
|
-
export var enterKeyCommand = function enterKeyCommand(
|
|
26
|
-
return function (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
25
|
+
export var enterKeyCommand = function enterKeyCommand(editorAnalyticsAPI) {
|
|
26
|
+
return function (featureFlags) {
|
|
27
|
+
return function (state, dispatch) {
|
|
28
|
+
var selection = state.selection;
|
|
29
|
+
if (selection.empty) {
|
|
30
|
+
var $from = selection.$from;
|
|
31
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
32
|
+
listItem = _state$schema$nodes.listItem,
|
|
33
|
+
codeBlock = _state$schema$nodes.codeBlock;
|
|
34
|
+
var wrapper = $from.node($from.depth - 1);
|
|
35
|
+
if (wrapper && wrapper.type === listItem) {
|
|
36
|
+
/** Check if the wrapper has any visible content */
|
|
37
|
+
var wrapperHasContent = hasVisibleContent(wrapper);
|
|
38
|
+
if (!wrapperHasContent) {
|
|
39
|
+
return outdentList(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, featureFlags)(state, dispatch);
|
|
40
|
+
} else if (!hasParentNodeOfType(codeBlock)(selection)) {
|
|
41
|
+
return splitListItem(listItem)(state, dispatch);
|
|
42
|
+
}
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
return false;
|
|
46
|
+
};
|
|
45
47
|
};
|
|
46
48
|
};
|
|
47
|
-
export var backspaceKeyCommand = function backspaceKeyCommand(
|
|
48
|
-
return function (
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
export var backspaceKeyCommand = function backspaceKeyCommand(editorAnalyticsAPI) {
|
|
50
|
+
return function (featureFlags) {
|
|
51
|
+
return function (state, dispatch) {
|
|
52
|
+
return baseCommand.chainCommands(listBackspace(editorAnalyticsAPI),
|
|
53
|
+
// if we're at the start of a list item, we need to either backspace
|
|
54
|
+
// directly to an empty list item above, or outdent this node
|
|
55
|
+
filter([isEmptySelectionAtStart,
|
|
56
|
+
// list items might have multiple paragraphs; only do this at the first one
|
|
57
|
+
isFirstChildOfParent, isInsideListItem], baseCommand.chainCommands(deletePreviousEmptyListItem, outdentList(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, featureFlags))),
|
|
58
|
+
// if we're just inside a paragraph node (or gapcursor is shown) and backspace, then try to join
|
|
59
|
+
// the text to the previous list item, if one exists
|
|
60
|
+
filter([isEmptySelectionAtStart, canJoinToPreviousListItem], joinToPreviousListItem))(state, dispatch);
|
|
61
|
+
};
|
|
58
62
|
};
|
|
59
63
|
};
|
|
60
|
-
export var deleteKeyCommand =
|
|
64
|
+
export var deleteKeyCommand = function deleteKeyCommand(editorAnalyticsAPI) {
|
|
65
|
+
return joinListItemForward(editorAnalyticsAPI);
|
|
66
|
+
};
|
|
61
67
|
|
|
62
68
|
// Get the depth of the nearest ancestor list
|
|
63
69
|
export var rootListDepth = function rootListDepth(pos, nodes) {
|
|
@@ -86,88 +92,94 @@ function untoggleSelectedList(tr) {
|
|
|
86
92
|
}
|
|
87
93
|
return liftTextSelectionList(selection, tr);
|
|
88
94
|
}
|
|
89
|
-
export function toggleList(
|
|
90
|
-
return function (
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
export var toggleList = function toggleList(editorAnalyticsAPI) {
|
|
96
|
+
return function (inputMethod, listType) {
|
|
97
|
+
return function (state, dispatch) {
|
|
98
|
+
var tr = state.tr;
|
|
99
|
+
var listInsideSelection = selectionContainsList(tr);
|
|
100
|
+
var listNodeType = state.schema.nodes[listType];
|
|
101
|
+
var actionSubjectId = listType === 'bulletList' ? ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
|
|
102
|
+
if (listInsideSelection) {
|
|
103
|
+
var selection = state.selection;
|
|
97
104
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
// for gap cursor or node selection - list is expected 1 level up (listItem -> list)
|
|
106
|
+
// for text selection - list is expected 2 levels up (paragraph -> listItem -> list)
|
|
107
|
+
var positionDiff = selection instanceof GapCursorSelection || selection instanceof NodeSelection ? 1 : 2;
|
|
108
|
+
var fromNode = selection.$from.node(selection.$from.depth - positionDiff);
|
|
109
|
+
var toNode = selection.$to.node(selection.$to.depth - positionDiff);
|
|
110
|
+
var transformedFrom = listInsideSelection.type.name === 'bulletList' ? ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
|
|
111
|
+
if ((fromNode === null || fromNode === void 0 ? void 0 : fromNode.type.name) === listType && (toNode === null || toNode === void 0 ? void 0 : toNode.type.name) === listType) {
|
|
112
|
+
var _tr2 = state.tr;
|
|
113
|
+
untoggleSelectedList(_tr2);
|
|
114
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
115
|
+
action: ACTION.CONVERTED,
|
|
116
|
+
actionSubject: ACTION_SUBJECT.LIST,
|
|
117
|
+
actionSubjectId: ACTION_SUBJECT_ID.TEXT,
|
|
118
|
+
eventType: EVENT_TYPE.TRACK,
|
|
119
|
+
attributes: _objectSpread(_objectSpread({}, getCommonListAnalyticsAttributes(state)), {}, {
|
|
120
|
+
transformedFrom: transformedFrom,
|
|
121
|
+
inputMethod: inputMethod
|
|
122
|
+
})
|
|
123
|
+
})(_tr2);
|
|
124
|
+
if (dispatch) {
|
|
125
|
+
dispatch(_tr2);
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
convertListType({
|
|
130
|
+
tr: tr,
|
|
131
|
+
nextListNodeType: listNodeType
|
|
132
|
+
});
|
|
133
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
108
134
|
action: ACTION.CONVERTED,
|
|
109
135
|
actionSubject: ACTION_SUBJECT.LIST,
|
|
110
|
-
actionSubjectId:
|
|
136
|
+
actionSubjectId: actionSubjectId,
|
|
111
137
|
eventType: EVENT_TYPE.TRACK,
|
|
112
138
|
attributes: _objectSpread(_objectSpread({}, getCommonListAnalyticsAttributes(state)), {}, {
|
|
113
139
|
transformedFrom: transformedFrom,
|
|
114
140
|
inputMethod: inputMethod
|
|
115
141
|
})
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
142
|
+
})(tr);
|
|
143
|
+
} else {
|
|
144
|
+
// Need to have this before wrapInList so the wrapping is done with valid content
|
|
145
|
+
// For example, if trying to convert centre or right aligned paragraphs to lists
|
|
146
|
+
sanitiseMarksInSelection(tr, listNodeType);
|
|
147
|
+
wrapInListAndJoin(listNodeType, tr);
|
|
148
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
149
|
+
action: ACTION.INSERTED,
|
|
150
|
+
actionSubject: ACTION_SUBJECT.LIST,
|
|
151
|
+
actionSubjectId: actionSubjectId,
|
|
152
|
+
eventType: EVENT_TYPE.TRACK,
|
|
153
|
+
attributes: {
|
|
154
|
+
inputMethod: inputMethod
|
|
155
|
+
}
|
|
156
|
+
})(tr);
|
|
121
157
|
}
|
|
122
|
-
convertListType({
|
|
123
|
-
tr: tr,
|
|
124
|
-
nextListNodeType: listNodeType
|
|
125
|
-
});
|
|
126
|
-
addAnalytics(state, tr, {
|
|
127
|
-
action: ACTION.CONVERTED,
|
|
128
|
-
actionSubject: ACTION_SUBJECT.LIST,
|
|
129
|
-
actionSubjectId: actionSubjectId,
|
|
130
|
-
eventType: EVENT_TYPE.TRACK,
|
|
131
|
-
attributes: _objectSpread(_objectSpread({}, getCommonListAnalyticsAttributes(state)), {}, {
|
|
132
|
-
transformedFrom: transformedFrom,
|
|
133
|
-
inputMethod: inputMethod
|
|
134
|
-
})
|
|
135
|
-
});
|
|
136
|
-
} else {
|
|
137
|
-
// Need to have this before wrapInList so the wrapping is done with valid content
|
|
138
|
-
// For example, if trying to convert centre or right aligned paragraphs to lists
|
|
139
|
-
sanitiseMarksInSelection(tr, listNodeType);
|
|
140
|
-
wrapInListAndJoin(listNodeType, tr);
|
|
141
|
-
addAnalytics(state, tr, {
|
|
142
|
-
action: ACTION.INSERTED,
|
|
143
|
-
actionSubject: ACTION_SUBJECT.LIST,
|
|
144
|
-
actionSubjectId: actionSubjectId,
|
|
145
|
-
eventType: EVENT_TYPE.TRACK,
|
|
146
|
-
attributes: {
|
|
147
|
-
inputMethod: inputMethod
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
158
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
// If document wasn't changed, return false from the command to indicate that the
|
|
160
|
+
// editing action failed
|
|
161
|
+
if (!tr.docChanged) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
if (dispatch) {
|
|
165
|
+
dispatch(tr);
|
|
166
|
+
}
|
|
167
|
+
return true;
|
|
168
|
+
};
|
|
161
169
|
};
|
|
162
|
-
}
|
|
163
|
-
export function toggleBulletList(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
170
|
+
};
|
|
171
|
+
export var toggleBulletList = function toggleBulletList(editorAnalyticsAPI) {
|
|
172
|
+
return function (view) {
|
|
173
|
+
var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INPUT_METHOD.TOOLBAR;
|
|
174
|
+
return toggleList(editorAnalyticsAPI)(inputMethod, 'bulletList')(view.state, view.dispatch);
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
export var toggleOrderedList = function toggleOrderedList(editorAnalyticsAPI) {
|
|
178
|
+
return function (view) {
|
|
179
|
+
var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INPUT_METHOD.TOOLBAR;
|
|
180
|
+
return toggleList(editorAnalyticsAPI)(inputMethod, 'orderedList')(view.state, view.dispatch);
|
|
181
|
+
};
|
|
182
|
+
};
|
|
171
183
|
|
|
172
184
|
/**
|
|
173
185
|
* Implementation taken and modified for our needs from PM
|
|
@@ -1,51 +1,53 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import { isEmptySelectionAtEnd, walkNextNode } from '../../../utils/commands';
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, DELETE_DIRECTION
|
|
3
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, DELETE_DIRECTION } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { findParentNodeOfType } from 'prosemirror-utils';
|
|
5
5
|
import { calcJoinListScenario } from '../actions/join-list-items-forward';
|
|
6
|
-
export var joinListItemForward = function joinListItemForward(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var scenarios = calcJoinListScenario(walkNode, $head);
|
|
14
|
-
if (!scenarios) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
var _scenarios = _slicedToArray(scenarios, 2),
|
|
18
|
-
scenario = _scenarios[0],
|
|
19
|
-
action = _scenarios[1];
|
|
20
|
-
var result = action({
|
|
21
|
-
tr: tr,
|
|
22
|
-
$next: walkNode.$pos,
|
|
23
|
-
$head: $head
|
|
24
|
-
});
|
|
25
|
-
if (!result) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
29
|
-
bulletList = _state$schema$nodes.bulletList,
|
|
30
|
-
orderedList = _state$schema$nodes.orderedList;
|
|
31
|
-
var listParent = findParentNodeOfType([bulletList, orderedList])(tr.selection);
|
|
32
|
-
var actionSubjectId = ACTION_SUBJECT_ID.FORMAT_LIST_BULLET;
|
|
33
|
-
if (listParent && listParent.node.type === orderedList) {
|
|
34
|
-
actionSubjectId = ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
|
|
35
|
-
}
|
|
36
|
-
addAnalytics(state, tr, {
|
|
37
|
-
action: ACTION.LIST_ITEM_JOINED,
|
|
38
|
-
actionSubject: ACTION_SUBJECT.LIST,
|
|
39
|
-
actionSubjectId: actionSubjectId,
|
|
40
|
-
eventType: EVENT_TYPE.TRACK,
|
|
41
|
-
attributes: {
|
|
42
|
-
inputMethod: INPUT_METHOD.KEYBOARD,
|
|
43
|
-
direction: DELETE_DIRECTION.FORWARD,
|
|
44
|
-
scenario: scenario
|
|
6
|
+
export var joinListItemForward = function joinListItemForward(editorAnalyticsAPI) {
|
|
7
|
+
return function (state, dispatch) {
|
|
8
|
+
var tr = state.tr,
|
|
9
|
+
$head = state.selection.$head;
|
|
10
|
+
var walkNode = walkNextNode($head);
|
|
11
|
+
if (!isEmptySelectionAtEnd(state)) {
|
|
12
|
+
return false;
|
|
45
13
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
14
|
+
var scenarios = calcJoinListScenario(walkNode, $head);
|
|
15
|
+
if (!scenarios) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
var _scenarios = _slicedToArray(scenarios, 2),
|
|
19
|
+
scenario = _scenarios[0],
|
|
20
|
+
action = _scenarios[1];
|
|
21
|
+
var result = action({
|
|
22
|
+
tr: tr,
|
|
23
|
+
$next: walkNode.$pos,
|
|
24
|
+
$head: $head
|
|
25
|
+
});
|
|
26
|
+
if (!result) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
30
|
+
bulletList = _state$schema$nodes.bulletList,
|
|
31
|
+
orderedList = _state$schema$nodes.orderedList;
|
|
32
|
+
var listParent = findParentNodeOfType([bulletList, orderedList])(tr.selection);
|
|
33
|
+
var actionSubjectId = ACTION_SUBJECT_ID.FORMAT_LIST_BULLET;
|
|
34
|
+
if (listParent && listParent.node.type === orderedList) {
|
|
35
|
+
actionSubjectId = ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
|
|
36
|
+
}
|
|
37
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
38
|
+
action: ACTION.LIST_ITEM_JOINED,
|
|
39
|
+
actionSubject: ACTION_SUBJECT.LIST,
|
|
40
|
+
actionSubjectId: actionSubjectId,
|
|
41
|
+
eventType: EVENT_TYPE.TRACK,
|
|
42
|
+
attributes: {
|
|
43
|
+
inputMethod: INPUT_METHOD.KEYBOARD,
|
|
44
|
+
direction: DELETE_DIRECTION.FORWARD,
|
|
45
|
+
scenario: scenario
|
|
46
|
+
}
|
|
47
|
+
})(tr);
|
|
48
|
+
if (dispatch) {
|
|
49
|
+
dispatch(tr);
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
};
|
|
51
53
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
var _BACKSPACE_COMMANDS;
|
|
3
3
|
import { insertContentDeleteRange, isEmptySelectionAtStart, walkPrevNode } from '../../../utils/commands';
|
|
4
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, DELETE_DIRECTION, LIST_TEXT_SCENARIOS
|
|
4
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, DELETE_DIRECTION, LIST_TEXT_SCENARIOS } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { findParentNodeOfType } from 'prosemirror-utils';
|
|
6
6
|
import { isListNode, isParagraphNode } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import { isPosInsideList, isPosInsideParagraph } from '../utils/selection';
|
|
@@ -240,35 +240,37 @@ export var calcJoinListScenario = function calcJoinListScenario(walkNode, $head,
|
|
|
240
240
|
}
|
|
241
241
|
return false;
|
|
242
242
|
};
|
|
243
|
-
export var listBackspace = function listBackspace(
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
addAnalytics(state, tr, {
|
|
263
|
-
action: ACTION.LIST_ITEM_JOINED,
|
|
264
|
-
actionSubject: ACTION_SUBJECT.LIST,
|
|
265
|
-
actionSubjectId: actionSubjectId,
|
|
266
|
-
eventType: EVENT_TYPE.TRACK,
|
|
267
|
-
attributes: {
|
|
268
|
-
inputMethod: INPUT_METHOD.KEYBOARD,
|
|
269
|
-
direction: DELETE_DIRECTION.BACKWARD,
|
|
270
|
-
scenario: scenario[0]
|
|
243
|
+
export var listBackspace = function listBackspace(editorAnalyticsAPI) {
|
|
244
|
+
return function (state, dispatch) {
|
|
245
|
+
var tr = state.tr,
|
|
246
|
+
$head = state.selection.$head;
|
|
247
|
+
var walkNode = walkPrevNode($head);
|
|
248
|
+
if (!isEmptySelectionAtStart(state)) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
var scenario = calcJoinListScenario(walkNode, $head, tr);
|
|
252
|
+
if (!scenario) {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
256
|
+
bulletList = _state$schema$nodes.bulletList,
|
|
257
|
+
orderedList = _state$schema$nodes.orderedList;
|
|
258
|
+
var listParent = findParentNodeOfType([bulletList, orderedList])(tr.selection);
|
|
259
|
+
var actionSubjectId = ACTION_SUBJECT_ID.FORMAT_LIST_BULLET;
|
|
260
|
+
if (listParent && listParent.node.type === orderedList) {
|
|
261
|
+
actionSubjectId = ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
|
|
271
262
|
}
|
|
272
|
-
|
|
273
|
-
|
|
263
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
264
|
+
action: ACTION.LIST_ITEM_JOINED,
|
|
265
|
+
actionSubject: ACTION_SUBJECT.LIST,
|
|
266
|
+
actionSubjectId: actionSubjectId,
|
|
267
|
+
eventType: EVENT_TYPE.TRACK,
|
|
268
|
+
attributes: {
|
|
269
|
+
inputMethod: INPUT_METHOD.KEYBOARD,
|
|
270
|
+
direction: DELETE_DIRECTION.BACKWARD,
|
|
271
|
+
scenario: scenario[0]
|
|
272
|
+
}
|
|
273
|
+
})(tr);
|
|
274
|
+
return BACKSPACE_COMMANDS[scenario[0]](tr, dispatch, walkNode.$pos, $head, scenario[1]);
|
|
275
|
+
};
|
|
274
276
|
};
|
|
@@ -1,60 +1,61 @@
|
|
|
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 { OUTDENT_SCENARIOS } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
import { addAnalytics, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '../../analytics';
|
|
4
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, OUTDENT_SCENARIOS } from '@atlaskit/editor-common/analytics';
|
|
6
5
|
import { isInsideListItem, isInsideTableCell } from '../utils/selection';
|
|
7
6
|
import { isBulletList } from '../utils/node';
|
|
8
7
|
import { findFirstParentListNode } from '../utils/find';
|
|
9
8
|
import { getCommonListAnalyticsAttributes, getRestartListsAttributes } from '../utils/analytics';
|
|
10
9
|
import { outdentListItemsSelected as outdentListAction } from '../actions/outdent-list-items-selected';
|
|
11
10
|
import { closeHistory } from 'prosemirror-history';
|
|
12
|
-
export function outdentList() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
export var outdentList = function outdentList(editorAnalyticsAPI) {
|
|
12
|
+
return function () {
|
|
13
|
+
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INPUT_METHOD.KEYBOARD;
|
|
14
|
+
var featureFlags = arguments.length > 1 ? arguments[1] : undefined;
|
|
15
|
+
return function (state, dispatch) {
|
|
16
|
+
if (!isInsideListItem(state)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
var $from = state.selection.$from;
|
|
20
|
+
var parentListNode = findFirstParentListNode($from);
|
|
21
|
+
if (!parentListNode) {
|
|
22
|
+
// 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
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
var restartListsAttributes = {};
|
|
37
|
-
if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
|
|
38
|
-
var _getRestartListsAttri = getRestartListsAttributes(customTr),
|
|
39
|
-
outdentScenario = _getRestartListsAttri.outdentScenario,
|
|
40
|
-
splitListStartNumber = _getRestartListsAttri.splitListStartNumber;
|
|
41
|
-
if (outdentScenario === OUTDENT_SCENARIOS.SPLIT_LIST) {
|
|
42
|
-
restartListsAttributes.outdentScenario = outdentScenario;
|
|
43
|
-
restartListsAttributes.splitListStartNumber = splitListStartNumber;
|
|
26
|
+
// Save the history, so it could undo/revert to the same state before the outdent, see https://product-fabric.atlassian.net/browse/ED-14753
|
|
27
|
+
closeHistory(state.tr);
|
|
28
|
+
var actionSubjectId = isBulletList(parentListNode.node) ? ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
|
|
29
|
+
var customTr = state.tr;
|
|
30
|
+
outdentListAction(customTr, state, featureFlags);
|
|
31
|
+
if (!customTr || !customTr.docChanged) {
|
|
32
|
+
// 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
|
|
33
|
+
// If inside table cell and can't outdent list, then let it handle by table keymap
|
|
34
|
+
return !isInsideTableCell(state);
|
|
44
35
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
36
|
+
var restartListsAttributes = {};
|
|
37
|
+
if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
|
|
38
|
+
var _getRestartListsAttri = getRestartListsAttributes(customTr),
|
|
39
|
+
outdentScenario = _getRestartListsAttri.outdentScenario,
|
|
40
|
+
splitListStartNumber = _getRestartListsAttri.splitListStartNumber;
|
|
41
|
+
if (outdentScenario === OUTDENT_SCENARIOS.SPLIT_LIST) {
|
|
42
|
+
restartListsAttributes.outdentScenario = outdentScenario;
|
|
43
|
+
restartListsAttributes.splitListStartNumber = splitListStartNumber;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
47
|
+
action: ACTION.OUTDENTED,
|
|
48
|
+
actionSubject: ACTION_SUBJECT.LIST,
|
|
49
|
+
actionSubjectId: actionSubjectId,
|
|
50
|
+
eventType: EVENT_TYPE.TRACK,
|
|
51
|
+
attributes: _objectSpread(_objectSpread(_objectSpread({}, getCommonListAnalyticsAttributes(state)), restartListsAttributes), {}, {
|
|
52
|
+
inputMethod: inputMethod
|
|
53
|
+
})
|
|
54
|
+
})(customTr);
|
|
55
|
+
if (dispatch) {
|
|
56
|
+
dispatch(customTr);
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
};
|
|
59
60
|
};
|
|
60
|
-
}
|
|
61
|
+
};
|
|
@@ -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
|
var listPlugin = function listPlugin(options, api) {
|
|
15
|
+
var _api$dependencies$ana;
|
|
15
16
|
var featureFlags = (api === null || api === void 0 ? void 0 : api.dependencies.featureFlags.sharedState.currentState()) || {};
|
|
17
|
+
var 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: function nodes() {
|
|
@@ -44,7 +46,8 @@ var listPlugin = function listPlugin(options, api) {
|
|
|
44
46
|
}, {
|
|
45
47
|
name: 'listKeymap',
|
|
46
48
|
plugin: function plugin() {
|
|
47
|
-
|
|
49
|
+
var _api$dependencies$ana2;
|
|
50
|
+
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);
|
|
48
51
|
}
|
|
49
52
|
}];
|
|
50
53
|
},
|
|
@@ -63,7 +66,7 @@ var listPlugin = function listPlugin(options, api) {
|
|
|
63
66
|
},
|
|
64
67
|
action: function action(insert, state) {
|
|
65
68
|
var tr = insert(state.schema.nodes.bulletList.createChecked({}, state.schema.nodes.listItem.createChecked({}, state.schema.nodes.paragraph.createChecked())));
|
|
66
|
-
|
|
69
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
67
70
|
action: ACTION.INSERTED,
|
|
68
71
|
actionSubject: ACTION_SUBJECT.LIST,
|
|
69
72
|
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_LIST_BULLET,
|
|
@@ -71,7 +74,8 @@ var listPlugin = function listPlugin(options, api) {
|
|
|
71
74
|
attributes: {
|
|
72
75
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
73
76
|
}
|
|
74
|
-
});
|
|
77
|
+
})(tr);
|
|
78
|
+
return tr;
|
|
75
79
|
}
|
|
76
80
|
}, {
|
|
77
81
|
id: 'orderedList',
|
|
@@ -85,7 +89,7 @@ var listPlugin = function listPlugin(options, api) {
|
|
|
85
89
|
},
|
|
86
90
|
action: function action(insert, state) {
|
|
87
91
|
var tr = insert(state.schema.nodes.orderedList.createChecked({}, state.schema.nodes.listItem.createChecked({}, state.schema.nodes.paragraph.createChecked())));
|
|
88
|
-
|
|
92
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
89
93
|
action: ACTION.INSERTED,
|
|
90
94
|
actionSubject: ACTION_SUBJECT.LIST,
|
|
91
95
|
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER,
|
|
@@ -93,7 +97,8 @@ var listPlugin = function listPlugin(options, api) {
|
|
|
93
97
|
attributes: {
|
|
94
98
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
95
99
|
}
|
|
96
|
-
});
|
|
100
|
+
})(tr);
|
|
101
|
+
return tr;
|
|
97
102
|
}
|
|
98
103
|
}];
|
|
99
104
|
}
|
|
@@ -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
|
var getOrder = function getOrder(matchResult) {
|
|
6
6
|
return Number(matchResult[1]);
|