@atlaskit/editor-core 189.3.29 → 189.3.30
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 +7 -0
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/presets/universal.js +2 -1
- package/dist/cjs/utils/document.js +0 -6
- package/dist/cjs/utils/index.js +0 -6
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/presets/universal.js +2 -1
- package/dist/es2019/utils/document.js +1 -1
- package/dist/es2019/utils/index.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/presets/universal.js +2 -1
- package/dist/esm/utils/document.js +1 -1
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/insert-block/types.d.ts +2 -2
- package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +2 -2
- package/dist/types/utils/document.d.ts +1 -1
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +2 -2
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/index.d.ts +2 -2
- package/dist/types-ts4.5/utils/document.d.ts +1 -1
- package/dist/types-ts4.5/utils/index.d.ts +1 -1
- package/package.json +4 -4
- package/dist/cjs/plugins/tasks-and-decisions/commands.js +0 -288
- package/dist/cjs/plugins/tasks-and-decisions/index.js +0 -166
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +0 -117
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +0 -40
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +0 -211
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/commands.js +0 -96
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/helpers.js +0 -299
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/input-rules.js +0 -94
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/keymaps.js +0 -376
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/main.js +0 -263
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/plugin-key.js +0 -8
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/types.js +0 -11
- package/dist/cjs/plugins/tasks-and-decisions/types.js +0 -5
- package/dist/cjs/plugins/tasks-and-decisions/ui/Decision/index.js +0 -51
- package/dist/cjs/plugins/tasks-and-decisions/ui/Task/index.js +0 -80
- package/dist/cjs/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.js +0 -137
- package/dist/cjs/plugins/tasks-and-decisions/ui/ToolbarDecision/index.js +0 -76
- package/dist/cjs/plugins/tasks-and-decisions/ui/ToolbarTask/index.js +0 -75
- package/dist/cjs/plugins/tasks-and-decisions/utils.js +0 -41
- package/dist/es2019/plugins/tasks-and-decisions/commands.js +0 -279
- package/dist/es2019/plugins/tasks-and-decisions/index.js +0 -155
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +0 -76
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +0 -36
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +0 -173
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/commands.js +0 -94
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/helpers.js +0 -316
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/input-rules.js +0 -91
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +0 -370
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/main.js +0 -262
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/plugin-key.js +0 -2
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/types.js +0 -5
- package/dist/es2019/plugins/tasks-and-decisions/types.js +0 -1
- package/dist/es2019/plugins/tasks-and-decisions/ui/Decision/index.js +0 -30
- package/dist/es2019/plugins/tasks-and-decisions/ui/Task/index.js +0 -54
- package/dist/es2019/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.js +0 -71
- package/dist/es2019/plugins/tasks-and-decisions/ui/ToolbarDecision/index.js +0 -52
- package/dist/es2019/plugins/tasks-and-decisions/ui/ToolbarTask/index.js +0 -51
- package/dist/es2019/plugins/tasks-and-decisions/utils.js +0 -32
- package/dist/esm/plugins/tasks-and-decisions/commands.js +0 -281
- package/dist/esm/plugins/tasks-and-decisions/index.js +0 -156
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +0 -110
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +0 -34
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +0 -204
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/commands.js +0 -90
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/helpers.js +0 -285
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/input-rules.js +0 -87
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +0 -368
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/main.js +0 -256
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/plugin-key.js +0 -2
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/types.js +0 -5
- package/dist/esm/plugins/tasks-and-decisions/types.js +0 -1
- package/dist/esm/plugins/tasks-and-decisions/ui/Decision/index.js +0 -44
- package/dist/esm/plugins/tasks-and-decisions/ui/Task/index.js +0 -70
- package/dist/esm/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.js +0 -128
- package/dist/esm/plugins/tasks-and-decisions/ui/ToolbarDecision/index.js +0 -66
- package/dist/esm/plugins/tasks-and-decisions/ui/ToolbarTask/index.js +0 -65
- package/dist/esm/plugins/tasks-and-decisions/utils.js +0 -30
- package/dist/types/plugins/tasks-and-decisions/commands.d.ts +0 -16
- package/dist/types/plugins/tasks-and-decisions/index.d.ts +0 -3
- package/dist/types/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +0 -10
- package/dist/types/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.d.ts +0 -11
- package/dist/types/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +0 -14
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/commands.d.ts +0 -15
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +0 -76
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/input-rules.d.ts +0 -6
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/keymaps.d.ts +0 -11
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/main.d.ts +0 -7
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/plugin-key.d.ts +0 -2
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/types.d.ts +0 -8
- package/dist/types/plugins/tasks-and-decisions/types.d.ts +0 -49
- package/dist/types/plugins/tasks-and-decisions/ui/Decision/index.d.ts +0 -14
- package/dist/types/plugins/tasks-and-decisions/ui/Task/index.d.ts +0 -28
- package/dist/types/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.d.ts +0 -29
- package/dist/types/plugins/tasks-and-decisions/ui/ToolbarDecision/index.d.ts +0 -23
- package/dist/types/plugins/tasks-and-decisions/ui/ToolbarTask/index.d.ts +0 -23
- package/dist/types/plugins/tasks-and-decisions/utils.d.ts +0 -4
- package/dist/types-ts4.5/plugins/tasks-and-decisions/commands.d.ts +0 -16
- package/dist/types-ts4.5/plugins/tasks-and-decisions/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +0 -10
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.d.ts +0 -11
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +0 -14
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/commands.d.ts +0 -15
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +0 -76
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/input-rules.d.ts +0 -6
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/keymaps.d.ts +0 -11
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/main.d.ts +0 -7
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/plugin-key.d.ts +0 -2
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/types.d.ts +0 -8
- package/dist/types-ts4.5/plugins/tasks-and-decisions/types.d.ts +0 -49
- package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/Decision/index.d.ts +0 -14
- package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/Task/index.d.ts +0 -28
- package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.d.ts +0 -29
- package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/ToolbarDecision/index.d.ts +0 -23
- package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/ToolbarTask/index.d.ts +0 -23
- package/dist/types-ts4.5/plugins/tasks-and-decisions/utils.d.ts +0 -4
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
import { autoJoin, chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
2
|
-
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
|
-
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
6
|
-
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
-
import { uuid } from '@atlaskit/adf-schema';
|
|
8
|
-
import { filterCommand as filter, isEmptySelectionAtStart, isEmptySelectionAtEnd, deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
|
|
9
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
10
|
-
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
11
|
-
import { insertTaskDecisionWithAnalytics } from '../commands';
|
|
12
|
-
import { joinAtCut, liftSelection, wrapSelectionInTaskList } from './commands';
|
|
13
|
-
import { getBlockRange, getCurrentIndentLevel, isActionOrDecisionItem, isActionOrDecisionList, isEmptyTaskDecision, isInsideTask, isInsideTaskOrDecisionItem, liftBlock, walkOut, getTaskItemIndex, isInsideDecision, isTable } from './helpers';
|
|
14
|
-
import { normalizeTaskItemsSelection } from '../utils';
|
|
15
|
-
import { toggleTaskItemCheckbox } from '../../../keymaps';
|
|
16
|
-
const indentationAnalytics = (curIndentLevel, direction, inputMethod) => ({
|
|
17
|
-
action: ACTION.FORMATTED,
|
|
18
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
19
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_INDENT,
|
|
20
|
-
eventType: EVENT_TYPE.TRACK,
|
|
21
|
-
attributes: {
|
|
22
|
-
inputMethod,
|
|
23
|
-
previousIndentationLevel: curIndentLevel,
|
|
24
|
-
newIndentLevel: direction === INDENT_DIRECTION.OUTDENT ? curIndentLevel - 1 : curIndentLevel + 1,
|
|
25
|
-
direction,
|
|
26
|
-
indentType: INDENT_TYPE.TASK_LIST
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
const nodeAfter = $pos => $pos.doc.resolve($pos.end()).nodeAfter;
|
|
30
|
-
const actionDecisionFollowsOrNothing = $pos => {
|
|
31
|
-
const after = nodeAfter($pos);
|
|
32
|
-
return !after || isActionOrDecisionItem(after);
|
|
33
|
-
};
|
|
34
|
-
const joinTaskDecisionFollowing = (state, dispatch) => {
|
|
35
|
-
// only run if selection is at end of text, and inside a task or decision item
|
|
36
|
-
if (!isEmptySelectionAtEnd(state) || !isInsideTaskOrDecisionItem(state) || !dispatch) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
// look for the node after this current one
|
|
40
|
-
const $next = walkOut(state.selection.$from);
|
|
41
|
-
|
|
42
|
-
// if there's no taskItem or taskList following, then
|
|
43
|
-
// we just do the normal behaviour
|
|
44
|
-
const {
|
|
45
|
-
taskList,
|
|
46
|
-
taskItem,
|
|
47
|
-
decisionList,
|
|
48
|
-
decisionItem,
|
|
49
|
-
paragraph,
|
|
50
|
-
bulletList,
|
|
51
|
-
orderedList,
|
|
52
|
-
listItem
|
|
53
|
-
} = state.schema.nodes;
|
|
54
|
-
const parentList = findParentNodeOfTypeClosestToPos($next, [taskList, taskItem, decisionList, decisionItem]);
|
|
55
|
-
if (!parentList) {
|
|
56
|
-
if ($next.parent.type === paragraph) {
|
|
57
|
-
// try to join paragraph and taskList when backspacing
|
|
58
|
-
return joinAtCut($next.doc.resolve($next.pos))(state, dispatch);
|
|
59
|
-
}
|
|
60
|
-
// If the item we are joining is a list
|
|
61
|
-
if ($next.parent.type === bulletList || $next.parent.type === orderedList) {
|
|
62
|
-
// If the list has an item
|
|
63
|
-
if ($next.parent.firstChild && $next.parent.firstChild.type === listItem) {
|
|
64
|
-
// Place the cursor at the first listItem
|
|
65
|
-
const resolvedStartPos = state.doc.resolve($next.pos + 1);
|
|
66
|
-
// Unindent the first listItem.
|
|
67
|
-
// As if placing your cursor just after the first dot of the list (before the text)
|
|
68
|
-
// and pressing Shift-Tab.
|
|
69
|
-
const tr = liftBlock(state.tr, resolvedStartPos, resolvedStartPos);
|
|
70
|
-
|
|
71
|
-
// If autoJoin not used, two ul/ol elements appear rather than one with multiple li elements
|
|
72
|
-
return autoJoin((state, dispatch) => {
|
|
73
|
-
if (tr) {
|
|
74
|
-
if (dispatch) {
|
|
75
|
-
dispatch(tr);
|
|
76
|
-
}
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
return false;
|
|
80
|
-
}, ['bulletList', 'orderedList'])(state, dispatch);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return false;
|
|
85
|
-
};
|
|
86
|
-
export const getUnindentCommand = editorAnalyticsAPI => (inputMethod = INPUT_METHOD.KEYBOARD) => filter(isInsideTask, (state, dispatch) => {
|
|
87
|
-
const normalizedSelection = normalizeTaskItemsSelection(state.selection);
|
|
88
|
-
const curIndentLevel = getCurrentIndentLevel(normalizedSelection);
|
|
89
|
-
if (!curIndentLevel || curIndentLevel === 1) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
return withAnalytics(editorAnalyticsAPI, indentationAnalytics(curIndentLevel, INDENT_DIRECTION.OUTDENT, inputMethod))(autoJoin(liftSelection, ['taskList']))(state, dispatch);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// if selection is decision item or first action item in table cell
|
|
96
|
-
// then dont consume the Tab, as table-keymap should tab to the next cell
|
|
97
|
-
const shouldLetTabThroughInTable = state => {
|
|
98
|
-
const curIndentLevel = getCurrentIndentLevel(state.selection);
|
|
99
|
-
const curIndex = getTaskItemIndex(state);
|
|
100
|
-
const {
|
|
101
|
-
tableCell,
|
|
102
|
-
tableHeader
|
|
103
|
-
} = state.schema.nodes;
|
|
104
|
-
const cell = findParentNodeOfType([tableCell, tableHeader])(state.selection);
|
|
105
|
-
if ((curIndentLevel === 1 && curIndex === 0 || isInsideDecision(state)) && cell) {
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
return false;
|
|
109
|
-
};
|
|
110
|
-
export const getIndentCommand = editorAnalyticsAPI => (inputMethod = INPUT_METHOD.KEYBOARD) => filter(isInsideTask, (state, dispatch) => {
|
|
111
|
-
const normalizedSelection = normalizeTaskItemsSelection(state.selection);
|
|
112
|
-
const curIndentLevel = getCurrentIndentLevel(normalizedSelection);
|
|
113
|
-
if (!curIndentLevel || curIndentLevel >= 6) {
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
return withAnalytics(editorAnalyticsAPI, indentationAnalytics(curIndentLevel, INDENT_DIRECTION.INDENT, inputMethod))(autoJoin(wrapSelectionInTaskList, ['taskList']))(state, dispatch);
|
|
117
|
-
});
|
|
118
|
-
const backspaceFrom = editorAnalyticsAPI => $from => (state, dispatch) => {
|
|
119
|
-
// previous was empty, just delete backwards
|
|
120
|
-
const taskBefore = $from.doc.resolve($from.before());
|
|
121
|
-
if (taskBefore.nodeBefore && isActionOrDecisionItem(taskBefore.nodeBefore) && taskBefore.nodeBefore.nodeSize === 2) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// if nested, just unindent
|
|
126
|
-
const {
|
|
127
|
-
taskList,
|
|
128
|
-
paragraph
|
|
129
|
-
} = state.schema.nodes;
|
|
130
|
-
if ($from.node($from.depth - 2).type === taskList) {
|
|
131
|
-
return getUnindentCommand(editorAnalyticsAPI)()(state, dispatch);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// bottom level, should "unwrap" taskItem contents into paragraph
|
|
135
|
-
// we achieve this by slicing the content out, and replacing
|
|
136
|
-
if (actionDecisionFollowsOrNothing($from)) {
|
|
137
|
-
if (dispatch) {
|
|
138
|
-
const taskContent = state.doc.slice($from.start(), $from.end()).content;
|
|
139
|
-
|
|
140
|
-
// might be end of document after
|
|
141
|
-
const slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : paragraph.createChecked();
|
|
142
|
-
dispatch(splitListItemWith(state.tr, slice, $from, true));
|
|
143
|
-
}
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
return false;
|
|
147
|
-
};
|
|
148
|
-
const backspace = editorAnalyticsAPI => filter(isEmptySelectionAtStart, autoJoin(chainCommands((state, dispatch) => joinAtCut(state.selection.$from)(state, dispatch), filter(isInsideTaskOrDecisionItem, (state, dispatch) => backspaceFrom(editorAnalyticsAPI)(state.selection.$from)(state, dispatch))), ['taskList', 'decisionList']));
|
|
149
|
-
const unindentTaskOrUnwrapTaskDecisionFollowing = (state, dispatch) => {
|
|
150
|
-
const {
|
|
151
|
-
selection: {
|
|
152
|
-
$from
|
|
153
|
-
},
|
|
154
|
-
schema: {
|
|
155
|
-
nodes: {
|
|
156
|
-
taskList,
|
|
157
|
-
doc,
|
|
158
|
-
paragraph
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
tr
|
|
162
|
-
} = state;
|
|
163
|
-
|
|
164
|
-
// only run if cursor is at the end of the node
|
|
165
|
-
if (!isEmptySelectionAtEnd(state) || !dispatch) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// look for the node after this current one
|
|
170
|
-
const $next = walkOut($from);
|
|
171
|
-
|
|
172
|
-
// this is a top-level node it wont have $next.before()
|
|
173
|
-
if (!$next.parent || $next.parent.type === doc) {
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// if nested, just unindent
|
|
178
|
-
if ($next.node($next.depth - 2).type === taskList ||
|
|
179
|
-
// this is for the case when we are on a non-nested item and next one is nested
|
|
180
|
-
$next.node($next.depth - 1).type === taskList && $next.parent.type === taskList) {
|
|
181
|
-
liftBlock(tr, $next, $next);
|
|
182
|
-
dispatch(tr);
|
|
183
|
-
return true;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// if next node is of same type, remove the node wrapping and create paragraph
|
|
187
|
-
if (!isTable($next.nodeAfter) && isActionOrDecisionItem($from.parent) && actionDecisionFollowsOrNothing($from) &&
|
|
188
|
-
// only forward delete if the node is same type
|
|
189
|
-
$next.node().type.name === $from.node().type.name) {
|
|
190
|
-
const taskContent = state.doc.slice($next.start(), $next.end()).content;
|
|
191
|
-
|
|
192
|
-
// might be end of document after
|
|
193
|
-
const slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : [];
|
|
194
|
-
dispatch(splitListItemWith(tr, slice, $next, false));
|
|
195
|
-
return true;
|
|
196
|
-
}
|
|
197
|
-
return false;
|
|
198
|
-
};
|
|
199
|
-
const deleteForwards = autoJoin(chainCommands(deleteEmptyParagraphAndMoveBlockUp(isActionOrDecisionList), joinTaskDecisionFollowing, unindentTaskOrUnwrapTaskDecisionFollowing), ['taskList', 'decisionList']);
|
|
200
|
-
const splitListItemWith = (tr, content, $from, setSelection) => {
|
|
201
|
-
const origDoc = tr.doc;
|
|
202
|
-
|
|
203
|
-
// split just before the current item
|
|
204
|
-
// we can only split if there was a list item before us
|
|
205
|
-
const container = $from.node($from.depth - 2);
|
|
206
|
-
const posInList = $from.index($from.depth - 1);
|
|
207
|
-
const shouldSplit = !(!isActionOrDecisionList(container) && posInList === 0);
|
|
208
|
-
if (shouldSplit) {
|
|
209
|
-
// this only splits a node to delete it, so we probably don't need a random uuid
|
|
210
|
-
// but generate one anyway for correctness
|
|
211
|
-
tr = tr.split($from.pos, 1, [{
|
|
212
|
-
type: $from.parent.type,
|
|
213
|
-
attrs: {
|
|
214
|
-
localId: uuid.generate()
|
|
215
|
-
}
|
|
216
|
-
}]);
|
|
217
|
-
}
|
|
218
|
-
// and delete the action at the current pos
|
|
219
|
-
// we can do this because we know either first new child will be taskItem or nothing at all
|
|
220
|
-
const frag = Fragment.from(content);
|
|
221
|
-
tr = tr.replace(tr.mapping.map($from.start() - 2), tr.mapping.map($from.end() + 2), frag.size ? new Slice(frag, 0, 0) : Slice.empty);
|
|
222
|
-
|
|
223
|
-
// put cursor inside paragraph
|
|
224
|
-
if (setSelection) {
|
|
225
|
-
tr = tr.setSelection(new TextSelection(tr.doc.resolve($from.pos + 1 - (shouldSplit ? 0 : 2))));
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// lift list up if the node after the initial one was a taskList
|
|
229
|
-
// which means it would have empty placeholder content if we just immediately delete it
|
|
230
|
-
//
|
|
231
|
-
// if it's a taskItem then it can stand alone, so it's fine
|
|
232
|
-
const $oldAfter = origDoc.resolve($from.after());
|
|
233
|
-
|
|
234
|
-
// if different levels then we shouldn't lift
|
|
235
|
-
if ($oldAfter.depth === $from.depth - 1) {
|
|
236
|
-
if ($oldAfter.nodeAfter && isActionOrDecisionList($oldAfter.nodeAfter)) {
|
|
237
|
-
// getBlockRange expects to be inside the taskItem
|
|
238
|
-
const pos = tr.mapping.map($oldAfter.pos + 2);
|
|
239
|
-
const $after = tr.doc.resolve(pos);
|
|
240
|
-
const blockRange = getBlockRange($after, tr.doc.resolve($after.after($after.depth - 1) - 1));
|
|
241
|
-
if (blockRange) {
|
|
242
|
-
tr = tr.lift(blockRange, blockRange.depth - 1).scrollIntoView();
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// we delete 1 past the range of the empty taskItem
|
|
246
|
-
// otherwise we hit a bug in prosemirror-transform:
|
|
247
|
-
// Cannot read property 'content' of undefined
|
|
248
|
-
tr = tr.deleteRange(pos - 3, pos - 1);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return tr;
|
|
252
|
-
};
|
|
253
|
-
const splitListItem = (state, dispatch) => {
|
|
254
|
-
let {
|
|
255
|
-
tr,
|
|
256
|
-
selection: {
|
|
257
|
-
$from
|
|
258
|
-
}
|
|
259
|
-
} = state;
|
|
260
|
-
const {
|
|
261
|
-
schema: {
|
|
262
|
-
nodes: {
|
|
263
|
-
paragraph
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
} = state;
|
|
267
|
-
if (actionDecisionFollowsOrNothing($from)) {
|
|
268
|
-
if (dispatch) {
|
|
269
|
-
dispatch(splitListItemWith(tr, paragraph.createChecked(), $from, true));
|
|
270
|
-
}
|
|
271
|
-
return true;
|
|
272
|
-
}
|
|
273
|
-
return false;
|
|
274
|
-
};
|
|
275
|
-
const enter = editorAnalyticsAPI => filter(isInsideTaskOrDecisionItem, chainCommands(filter(isEmptyTaskDecision, chainCommands(getUnindentCommand(editorAnalyticsAPI)(), splitListItem)), (state, dispatch) => {
|
|
276
|
-
const {
|
|
277
|
-
selection,
|
|
278
|
-
schema
|
|
279
|
-
} = state;
|
|
280
|
-
const {
|
|
281
|
-
taskItem
|
|
282
|
-
} = schema.nodes;
|
|
283
|
-
const {
|
|
284
|
-
$from,
|
|
285
|
-
$to
|
|
286
|
-
} = selection;
|
|
287
|
-
const node = $from.node($from.depth);
|
|
288
|
-
const nodeType = node && node.type;
|
|
289
|
-
const listType = nodeType === taskItem ? 'taskList' : 'decisionList';
|
|
290
|
-
const addItem = ({
|
|
291
|
-
tr,
|
|
292
|
-
itemLocalId
|
|
293
|
-
}) => {
|
|
294
|
-
// ED-8932: When cursor is at the beginning of a task item, instead of split, we insert above.
|
|
295
|
-
if ($from.pos === $to.pos && $from.parentOffset === 0) {
|
|
296
|
-
const newTask = nodeType.createAndFill({
|
|
297
|
-
localId: itemLocalId
|
|
298
|
-
});
|
|
299
|
-
if (newTask) {
|
|
300
|
-
// Current position will point to text node, but we want to insert above the taskItem node
|
|
301
|
-
return tr.insert($from.pos - 1, newTask);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return tr.split($from.pos, 1, [{
|
|
305
|
-
type: nodeType,
|
|
306
|
-
attrs: {
|
|
307
|
-
localId: itemLocalId
|
|
308
|
-
}
|
|
309
|
-
}]);
|
|
310
|
-
};
|
|
311
|
-
const insertTr = insertTaskDecisionWithAnalytics(editorAnalyticsAPI)(state, listType, INPUT_METHOD.KEYBOARD, addItem);
|
|
312
|
-
if (insertTr && dispatch) {
|
|
313
|
-
insertTr.scrollIntoView();
|
|
314
|
-
dispatch(insertTr);
|
|
315
|
-
}
|
|
316
|
-
return true;
|
|
317
|
-
}));
|
|
318
|
-
const cmdOptEnter = filter(isInsideTaskOrDecisionItem, (state, dispatch) => {
|
|
319
|
-
const {
|
|
320
|
-
selection,
|
|
321
|
-
schema
|
|
322
|
-
} = state;
|
|
323
|
-
const {
|
|
324
|
-
taskItem
|
|
325
|
-
} = schema.nodes;
|
|
326
|
-
const {
|
|
327
|
-
$from
|
|
328
|
-
} = selection;
|
|
329
|
-
const node = $from.node($from.depth);
|
|
330
|
-
const nodeType = node && node.type;
|
|
331
|
-
const nodePos = $from.before($from.depth);
|
|
332
|
-
if (nodeType === taskItem) {
|
|
333
|
-
const tr = state.tr;
|
|
334
|
-
tr.step(new SetAttrsStep(nodePos, {
|
|
335
|
-
state: node.attrs.state === 'TODO' ? 'DONE' : 'TODO',
|
|
336
|
-
localId: node.attrs.localId
|
|
337
|
-
}));
|
|
338
|
-
if (tr && dispatch) {
|
|
339
|
-
dispatch(tr);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
return true;
|
|
343
|
-
});
|
|
344
|
-
export function keymapPlugin(schema, api, allowNestedTasks, consumeTabs) {
|
|
345
|
-
var _api$analytics3, _api$analytics4;
|
|
346
|
-
const indentHandlers = {
|
|
347
|
-
'Shift-Tab': filter([isInsideTaskOrDecisionItem, state => !shouldLetTabThroughInTable(state)], (state, dispatch) => {
|
|
348
|
-
var _api$analytics;
|
|
349
|
-
return getUnindentCommand(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(INPUT_METHOD.KEYBOARD)(state, dispatch) || !!consumeTabs;
|
|
350
|
-
}),
|
|
351
|
-
Tab: filter([isInsideTaskOrDecisionItem, state => !shouldLetTabThroughInTable(state)], (state, dispatch) => {
|
|
352
|
-
var _api$analytics2;
|
|
353
|
-
return getIndentCommand(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(INPUT_METHOD.KEYBOARD)(state, dispatch) || !!consumeTabs;
|
|
354
|
-
})
|
|
355
|
-
};
|
|
356
|
-
const defaultHandlers = consumeTabs ? {
|
|
357
|
-
'Shift-Tab': isInsideTaskOrDecisionItem,
|
|
358
|
-
Tab: isInsideTaskOrDecisionItem
|
|
359
|
-
} : {};
|
|
360
|
-
const keymaps = {
|
|
361
|
-
Backspace: backspace(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
|
|
362
|
-
Delete: deleteForwards,
|
|
363
|
-
'Ctrl-d': deleteForwards,
|
|
364
|
-
Enter: enter(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions),
|
|
365
|
-
[toggleTaskItemCheckbox.common]: cmdOptEnter,
|
|
366
|
-
...(allowNestedTasks ? indentHandlers : defaultHandlers)
|
|
367
|
-
};
|
|
368
|
-
return keymap(keymaps);
|
|
369
|
-
}
|
|
370
|
-
export default keymapPlugin;
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { uuid } from '@atlaskit/adf-schema';
|
|
4
|
-
import { getStepRange } from '@atlaskit/editor-common/utils';
|
|
5
|
-
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
6
|
-
import { createSelectionClickHandler, GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
7
|
-
import { decisionItemNodeView } from '../nodeviews/decisionItem';
|
|
8
|
-
import { taskItemNodeViewFactory } from '../nodeviews/taskItem';
|
|
9
|
-
import { stateKey } from './plugin-key';
|
|
10
|
-
import { getTaskItemDataToFocus, getTaskItemDataAtPos, focusCheckboxAndUpdateSelection, removeCheckboxFocus } from './helpers';
|
|
11
|
-
import { ACTIONS } from './types';
|
|
12
|
-
function nodesBetweenChanged(tr, f, startPos) {
|
|
13
|
-
const stepRange = getStepRange(tr);
|
|
14
|
-
if (!stepRange) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
tr.doc.nodesBetween(stepRange.from, stepRange.to, f, startPos);
|
|
18
|
-
}
|
|
19
|
-
const setContextIdentifierProvider = provider => (state, dispatch) => {
|
|
20
|
-
if (dispatch) {
|
|
21
|
-
dispatch(state.tr.setMeta(stateKey, {
|
|
22
|
-
action: ACTIONS.SET_CONTEXT_PROVIDER,
|
|
23
|
-
data: provider
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
return true;
|
|
27
|
-
};
|
|
28
|
-
export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection = false) {
|
|
29
|
-
return new SafePlugin({
|
|
30
|
-
props: {
|
|
31
|
-
nodeViews: {
|
|
32
|
-
taskItem: taskItemNodeViewFactory(portalProviderAPI, eventDispatcher, providerFactory, api),
|
|
33
|
-
decisionItem: decisionItemNodeView(portalProviderAPI, eventDispatcher, api)
|
|
34
|
-
},
|
|
35
|
-
handleTextInput(view, from, to, text) {
|
|
36
|
-
// When a decision item is selected and the user starts typing, the entire node
|
|
37
|
-
// should be replaced with what was just typed. This custom text input handler
|
|
38
|
-
// is needed to implement that behaviour.
|
|
39
|
-
|
|
40
|
-
// TODO: ProseMirror should already do this by default
|
|
41
|
-
// Tech debt to investigate why we need a custom handler here:
|
|
42
|
-
// https://product-fabric.atlassian.net/browse/ED-9278
|
|
43
|
-
|
|
44
|
-
const {
|
|
45
|
-
state,
|
|
46
|
-
dispatch
|
|
47
|
-
} = view;
|
|
48
|
-
const {
|
|
49
|
-
tr
|
|
50
|
-
} = state;
|
|
51
|
-
if (state.selection instanceof NodeSelection && state.selection.node.type === view.state.schema.nodes.decisionItem) {
|
|
52
|
-
state.selection.replace(tr);
|
|
53
|
-
tr.insertText(text);
|
|
54
|
-
if (dispatch) {
|
|
55
|
-
dispatch(tr);
|
|
56
|
-
}
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
},
|
|
61
|
-
handleClickOn: createSelectionClickHandler(['decisionItem'], target => target.hasAttribute('data-decision-wrapper') || target.getAttribute('aria-label') === 'Decision', {
|
|
62
|
-
useLongPressSelection
|
|
63
|
-
}),
|
|
64
|
-
handleKeyDown: (view, event) => {
|
|
65
|
-
const {
|
|
66
|
-
state,
|
|
67
|
-
dispatch
|
|
68
|
-
} = view;
|
|
69
|
-
const {
|
|
70
|
-
selection,
|
|
71
|
-
schema
|
|
72
|
-
} = state;
|
|
73
|
-
const {
|
|
74
|
-
$from,
|
|
75
|
-
$to
|
|
76
|
-
} = selection;
|
|
77
|
-
const parentOffset = $from.parentOffset;
|
|
78
|
-
const isInTaskItem = $from.node().type === schema.nodes.taskItem;
|
|
79
|
-
const focusedTaskItemLocalId = stateKey.getState(state).focusedTaskItemLocalId;
|
|
80
|
-
const currentTaskItemData = getTaskItemDataAtPos(view);
|
|
81
|
-
const currentTaskItemFocused = focusedTaskItemLocalId === (currentTaskItemData === null || currentTaskItemData === void 0 ? void 0 : currentTaskItemData.localId);
|
|
82
|
-
|
|
83
|
-
// if task item checkbox not focused and arrow key is not pressed
|
|
84
|
-
// then we don't want to handle event.
|
|
85
|
-
if (!['ArrowUp', 'ArrowDown', 'ArrowRight', 'ArrowLeft'].includes(event.key)) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// We want to handle arrow up, down and left key only
|
|
90
|
-
// when selection is inside task item and no text is selected.
|
|
91
|
-
if (['ArrowUp', 'ArrowDown', 'ArrowLeft'].includes(event.key) && (!isInTaskItem || $from.pos !== $to.pos)) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Arrow keys are pressed and shift, ctrl or meta is pressed as well.
|
|
96
|
-
// along with arrow keys and task item checkbox is focused
|
|
97
|
-
// then first move focus to view and proceed with default event handling.
|
|
98
|
-
if (event.shiftKey || event.ctrlKey || event.metaKey) {
|
|
99
|
-
currentTaskItemFocused && removeCheckboxFocus(view);
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// task item checkbox is already focused
|
|
104
|
-
if (focusedTaskItemLocalId) {
|
|
105
|
-
if (event.key === 'ArrowLeft') {
|
|
106
|
-
// Move focus to view and proceed with default keyboard handler.
|
|
107
|
-
// Which will move cursor to previous position.
|
|
108
|
-
removeCheckboxFocus(view);
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
if (event.key === 'ArrowRight') {
|
|
112
|
-
// Move focus to view and DON'T proceed with default handler.
|
|
113
|
-
// We have assumed that selection is already before first character of task item.
|
|
114
|
-
removeCheckboxFocus(view);
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
118
|
-
const taskItemData = getTaskItemDataToFocus(view, event.key === 'ArrowUp' ? 'previous' : 'next');
|
|
119
|
-
if (taskItemData) {
|
|
120
|
-
focusCheckboxAndUpdateSelection(view, taskItemData);
|
|
121
|
-
return true;
|
|
122
|
-
} else {
|
|
123
|
-
// If any how checkbox input not found, then move focus to view
|
|
124
|
-
// and proceed with default keyboard handler.
|
|
125
|
-
removeCheckboxFocus(view);
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// If left arrow key is pressed and cursor is at first position in task-item
|
|
132
|
-
// then focus checkbox and DON'T proceed with default keyboard handler
|
|
133
|
-
if (event.key === 'ArrowLeft' && parentOffset === 0) {
|
|
134
|
-
// here we are not using focusCheckboxAndUpdateSelection() method
|
|
135
|
-
// because it is working incorretly when we are placing is inside the nested items
|
|
136
|
-
dispatch(state.tr.setMeta(stateKey, {
|
|
137
|
-
action: ACTIONS.FOCUS_BY_LOCALID,
|
|
138
|
-
data: currentTaskItemData === null || currentTaskItemData === void 0 ? void 0 : currentTaskItemData.localId
|
|
139
|
-
}));
|
|
140
|
-
return true;
|
|
141
|
-
}
|
|
142
|
-
if (event.key === 'ArrowRight') {
|
|
143
|
-
var _$from$nodeAfter;
|
|
144
|
-
// If gap cursor is just before task list then focus first task item in list.
|
|
145
|
-
if (selection instanceof GapCursorSelection && selection.side === 'left' && ((_$from$nodeAfter = $from.nodeAfter) === null || _$from$nodeAfter === void 0 ? void 0 : _$from$nodeAfter.type) === schema.nodes.taskList) {
|
|
146
|
-
const taskList = $from.nodeAfter;
|
|
147
|
-
const firstTaskItemNode = taskList.child(0);
|
|
148
|
-
const taskItemPos = $from.pos + 1;
|
|
149
|
-
focusCheckboxAndUpdateSelection(view, {
|
|
150
|
-
pos: taskItemPos,
|
|
151
|
-
localId: firstTaskItemNode.attrs.localId
|
|
152
|
-
});
|
|
153
|
-
return true;
|
|
154
|
-
}
|
|
155
|
-
// if cursor is at then end of task item text then focus next task item checkbox
|
|
156
|
-
else if (isInTaskItem && $from.node().content.size === parentOffset) {
|
|
157
|
-
const nextTaskItemData = getTaskItemDataToFocus(view, 'next');
|
|
158
|
-
if (nextTaskItemData) {
|
|
159
|
-
focusCheckboxAndUpdateSelection(view, nextTaskItemData);
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
} else {
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
state: {
|
|
169
|
-
init() {
|
|
170
|
-
return {
|
|
171
|
-
insideTaskDecisionItem: false
|
|
172
|
-
};
|
|
173
|
-
},
|
|
174
|
-
apply(tr, pluginState) {
|
|
175
|
-
const {
|
|
176
|
-
action,
|
|
177
|
-
data
|
|
178
|
-
} = tr.getMeta(stateKey) || {
|
|
179
|
-
action: null,
|
|
180
|
-
data: null
|
|
181
|
-
};
|
|
182
|
-
let newPluginState = pluginState;
|
|
183
|
-
switch (action) {
|
|
184
|
-
case ACTIONS.SET_CONTEXT_PROVIDER:
|
|
185
|
-
newPluginState = {
|
|
186
|
-
...pluginState,
|
|
187
|
-
contextIdentifierProvider: data
|
|
188
|
-
};
|
|
189
|
-
break;
|
|
190
|
-
case ACTIONS.FOCUS_BY_LOCALID:
|
|
191
|
-
newPluginState = {
|
|
192
|
-
...pluginState,
|
|
193
|
-
focusedTaskItemLocalId: data
|
|
194
|
-
};
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
|
-
dispatch(stateKey, newPluginState);
|
|
198
|
-
return newPluginState;
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
view(editorView) {
|
|
202
|
-
const providerHandler = (name, providerPromise) => {
|
|
203
|
-
if (name === 'contextIdentifierProvider') {
|
|
204
|
-
if (!providerPromise) {
|
|
205
|
-
setContextIdentifierProvider(undefined)(editorView.state, editorView.dispatch);
|
|
206
|
-
} else {
|
|
207
|
-
providerPromise.then(provider => {
|
|
208
|
-
setContextIdentifierProvider(provider)(editorView.state, editorView.dispatch);
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
providerFactory.subscribe('contextIdentifierProvider', providerHandler);
|
|
214
|
-
return {};
|
|
215
|
-
},
|
|
216
|
-
key: stateKey,
|
|
217
|
-
/*
|
|
218
|
-
* After each transaction, we search through the document for any decisionList/Item & taskList/Item nodes
|
|
219
|
-
* that do not have the localId attribute set and generate a random UUID to use. This is to replace a previous
|
|
220
|
-
* Prosemirror capabibility where node attributes could be generated dynamically.
|
|
221
|
-
* See https://discuss.prosemirror.net/t/release-0-23-0-possibly-to-be-1-0-0/959/17 for a discussion of this approach.
|
|
222
|
-
*
|
|
223
|
-
* Note: we currently do not handle the edge case where two nodes may have the same localId
|
|
224
|
-
*/
|
|
225
|
-
appendTransaction: (transactions, _oldState, newState) => {
|
|
226
|
-
const tr = newState.tr;
|
|
227
|
-
let modified = false;
|
|
228
|
-
transactions.forEach(transaction => {
|
|
229
|
-
if (!transaction.docChanged) {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// Adds a unique id to a node
|
|
234
|
-
nodesBetweenChanged(transaction, (node, pos) => {
|
|
235
|
-
const {
|
|
236
|
-
decisionList,
|
|
237
|
-
decisionItem,
|
|
238
|
-
taskList,
|
|
239
|
-
taskItem
|
|
240
|
-
} = newState.schema.nodes;
|
|
241
|
-
if (!!node.type && (node.type === decisionList || node.type === decisionItem || node.type === taskList || node.type === taskItem)) {
|
|
242
|
-
const {
|
|
243
|
-
localId,
|
|
244
|
-
...rest
|
|
245
|
-
} = node.attrs;
|
|
246
|
-
if (localId === undefined || localId === null || localId === '') {
|
|
247
|
-
tr.step(new SetAttrsStep(pos, {
|
|
248
|
-
localId: uuid.generate(),
|
|
249
|
-
...rest
|
|
250
|
-
}));
|
|
251
|
-
modified = true;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
if (modified) {
|
|
257
|
-
return tr.setMeta('addToHistory', false);
|
|
258
|
-
}
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { defineMessages, injectIntl } from 'react-intl-next';
|
|
4
|
-
import { DecisionItem } from '@atlaskit/task-decision';
|
|
5
|
-
const messages = defineMessages({
|
|
6
|
-
placeholder: {
|
|
7
|
-
id: 'fabric.editor.decisionPlaceholder',
|
|
8
|
-
defaultMessage: 'Add a decision…',
|
|
9
|
-
description: 'Placeholder description for an empty decision in the editor'
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
export class Decision extends React.Component {
|
|
13
|
-
render() {
|
|
14
|
-
const {
|
|
15
|
-
contentRef,
|
|
16
|
-
showPlaceholder,
|
|
17
|
-
intl: {
|
|
18
|
-
formatMessage
|
|
19
|
-
}
|
|
20
|
-
} = this.props;
|
|
21
|
-
const placeholder = formatMessage(messages.placeholder);
|
|
22
|
-
return /*#__PURE__*/React.createElement(DecisionItem, {
|
|
23
|
-
contentRef: contentRef,
|
|
24
|
-
placeholder: placeholder,
|
|
25
|
-
showPlaceholder: showPlaceholder
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
_defineProperty(Decision, "displayName", 'Decision');
|
|
30
|
-
export default injectIntl(Decision);
|