@atlaskit/editor-plugin-tasks-and-decisions 21.0.10 → 22.0.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 +29 -0
- package/dist/cjs/pm-plugins/commands.js +1 -74
- package/dist/cjs/pm-plugins/helpers.js +1 -51
- package/dist/cjs/pm-plugins/keymaps.js +25 -39
- package/dist/cjs/pm-plugins/main.js +0 -20
- package/dist/cjs/pm-plugins/task-list-indentation.js +3 -34
- package/dist/cjs/tasksAndDecisionsPlugin.js +2 -5
- package/dist/cjs/ui/quick-insert/TasksAndDecisionsQuickInsertMenuItem.js +3 -1
- package/dist/cjs/ui/quick-insert/getTasksAndDecisionsQuickInsertComponents.js +12 -2
- package/dist/es2019/pm-plugins/commands.js +2 -80
- package/dist/es2019/pm-plugins/helpers.js +0 -48
- package/dist/es2019/pm-plugins/keymaps.js +28 -42
- package/dist/es2019/pm-plugins/main.js +0 -18
- package/dist/es2019/pm-plugins/task-list-indentation.js +3 -32
- package/dist/es2019/tasksAndDecisionsPlugin.js +3 -6
- package/dist/es2019/ui/quick-insert/TasksAndDecisionsQuickInsertMenuItem.js +3 -1
- package/dist/es2019/ui/quick-insert/getTasksAndDecisionsQuickInsertComponents.js +12 -2
- package/dist/esm/pm-plugins/commands.js +2 -74
- package/dist/esm/pm-plugins/helpers.js +0 -50
- package/dist/esm/pm-plugins/keymaps.js +26 -40
- package/dist/esm/pm-plugins/main.js +0 -20
- package/dist/esm/pm-plugins/task-list-indentation.js +3 -35
- package/dist/esm/tasksAndDecisionsPlugin.js +3 -6
- package/dist/esm/ui/quick-insert/TasksAndDecisionsQuickInsertMenuItem.js +3 -1
- package/dist/esm/ui/quick-insert/getTasksAndDecisionsQuickInsertComponents.js +12 -2
- package/dist/types/pm-plugins/commands.d.ts +0 -19
- package/dist/types/pm-plugins/helpers.d.ts +1 -14
- package/dist/types/ui/quick-insert/TasksAndDecisionsQuickInsertMenuItem.d.ts +3 -1
- package/package.json +17 -15
- package/dist/cjs/pm-plugins/transforms.js +0 -150
- package/dist/es2019/pm-plugins/transforms.js +0 -104
- package/dist/esm/pm-plugins/transforms.js +0 -143
- package/dist/types/pm-plugins/transforms.d.ts +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-tasks-and-decisions
|
|
2
2
|
|
|
3
|
+
## 22.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`3b3e57040d2d0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3b3e57040d2d0) -
|
|
8
|
+
Remove retired flexible-list feature controls and schema styles while preserving shipped list
|
|
9
|
+
normalization, hidden-marker rendering for wrapper list items, task paste and task-list tab
|
|
10
|
+
behavior, and toolbar indentation behavior.
|
|
11
|
+
|
|
12
|
+
Remove unused legacy list utilities after the flexible-list rollout: `flattenList`,
|
|
13
|
+
`normalizeListItemsSelection`, `hasValidListIndentationLevel`,
|
|
14
|
+
`processNestedTaskListsInSameLevel`, and `wrapTaskListIntoListAbove`. The
|
|
15
|
+
`@atlaskit/editor-common/lists/indentation` entrypoint is also removed.
|
|
16
|
+
|
|
17
|
+
Consumers of the removed runtime helpers should use the editor list plugin's indent/outdent
|
|
18
|
+
commands. The shared `FlattenedItem`, `FlattenListOptions`, and `FlattenListResult` types remain
|
|
19
|
+
available for the active list implementations.
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
23
|
+
## 21.0.11
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- [`88fb7a8d4013a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/88fb7a8d4013a) -
|
|
28
|
+
[ux] Add optional light and dark preview URLs to slash-command menu items and pass theme-aware
|
|
29
|
+
previews to supported commands when the `platform_editor_slash_command` experiment is enabled.
|
|
30
|
+
- Updated dependencies
|
|
31
|
+
|
|
3
32
|
## 21.0.10
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
|
@@ -3,86 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.joinAtCut = void 0;
|
|
7
7
|
var _commands = require("@atlaskit/editor-common/commands");
|
|
8
8
|
var _lists = require("@atlaskit/editor-common/lists");
|
|
9
9
|
var _transforms = require("@atlaskit/editor-common/transforms");
|
|
10
10
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
11
11
|
var _helpers = require("./helpers");
|
|
12
|
-
var _utils = require("./utils");
|
|
13
12
|
var _paste = require("./utils/paste");
|
|
14
|
-
var liftSelection = exports.liftSelection = function liftSelection(state, dispatch) {
|
|
15
|
-
var normalizedSelection = (0, _utils.normalizeTaskItemsSelection)(state.selection);
|
|
16
|
-
var $from = normalizedSelection.$from,
|
|
17
|
-
$to = normalizedSelection.$to;
|
|
18
|
-
var tr = (0, _helpers.liftBlock)(state.tr, $from, $to);
|
|
19
|
-
if (dispatch && tr) {
|
|
20
|
-
dispatch(tr);
|
|
21
|
-
}
|
|
22
|
-
return !!tr;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Wraps the current selection in a task list, respecting a maximum indentation depth of 6 levels.
|
|
27
|
-
*
|
|
28
|
-
* - Normalizes the selection to ensure it covers complete task items.
|
|
29
|
-
* - Determines the maximum depth of task list nesting within the selection.
|
|
30
|
-
* - If the selection is already nested at or beyond the maximum depth, the command does nothing.
|
|
31
|
-
* - Calculates the block range to wrap, handling both regular and block task items.
|
|
32
|
-
* - Wraps the block in a task list to increase indentation or create a new task list if necessary.
|
|
33
|
-
*
|
|
34
|
-
* @param state - The current editor state.
|
|
35
|
-
* @param dispatch - The dispatch function to apply the transaction.
|
|
36
|
-
* @returns `true` if the command was handled (even if no changes were made), otherwise `false`.
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* autoJoin(wrapSelectionInTaskList, ['taskList']))(state, dispatch);
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
var wrapSelectionInTaskList = exports.wrapSelectionInTaskList = function wrapSelectionInTaskList(state, dispatch) {
|
|
43
|
-
var _normalizeTaskItemsSe = (0, _utils.normalizeTaskItemsSelection)(state.selection),
|
|
44
|
-
$from = _normalizeTaskItemsSe.$from,
|
|
45
|
-
$to = _normalizeTaskItemsSe.$to;
|
|
46
|
-
|
|
47
|
-
// limit ui indentation to 6 levels
|
|
48
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
49
|
-
taskList = _state$schema$nodes.taskList,
|
|
50
|
-
taskItem = _state$schema$nodes.taskItem,
|
|
51
|
-
blockTaskItem = _state$schema$nodes.blockTaskItem;
|
|
52
|
-
var maxDepth = (0, _helpers.subtreeHeight)($from, $to, [taskList, taskItem]);
|
|
53
|
-
if (blockTaskItem) {
|
|
54
|
-
var resultOfFindBlockTaskItem = (0, _utils.findBlockTaskItem)($from);
|
|
55
|
-
if (resultOfFindBlockTaskItem) {
|
|
56
|
-
var hasParagraph = resultOfFindBlockTaskItem.hasParagraph;
|
|
57
|
-
// If the selection is inside a nested node inside the blockTaskItem
|
|
58
|
-
// Remove the difference in depth between the selection and the blockTaskItemNode
|
|
59
|
-
if (hasParagraph) {
|
|
60
|
-
maxDepth = (0, _helpers.subtreeHeight)($from, $to, [taskList, blockTaskItem]) - 1;
|
|
61
|
-
} else {
|
|
62
|
-
maxDepth = (0, _helpers.subtreeHeight)($from, $to, [taskList, blockTaskItem]);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (maxDepth >= 6) {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
var blockRange = (0, _helpers.getBlockRange)({
|
|
70
|
-
$from: $from,
|
|
71
|
-
$to: $to
|
|
72
|
-
});
|
|
73
|
-
if (!blockRange) {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
var wrapping = (0, _transform.findWrapping)(blockRange, state.schema.nodes.taskList);
|
|
77
|
-
if (!wrapping) {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
if (dispatch) {
|
|
81
|
-
dispatch(state.tr.wrap(blockRange, wrapping).scrollIntoView());
|
|
82
|
-
}
|
|
83
|
-
return true;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
13
|
/**
|
|
87
14
|
* Tries to move the paragraph content near the given position into the taskItem or decisionItem
|
|
88
15
|
* before it.
|
|
@@ -15,7 +15,7 @@ exports.getTaskItemDataToFocus = getTaskItemDataToFocus;
|
|
|
15
15
|
exports.liftBlock = exports.isTable = exports.isInsideTaskOrDecisionItem = exports.isInsideTask = exports.isInsideDecision = exports.isInLastTextblockOfBlockTaskItem = exports.isInFirstTextblockOfBlockTaskItem = exports.isEmptyTaskDecision = exports.isActionOrDecisionList = exports.isActionOrDecisionItem = exports.getTaskItemIndex = void 0;
|
|
16
16
|
exports.openRequestEditPopupAt = openRequestEditPopupAt;
|
|
17
17
|
exports.removeCheckboxFocus = removeCheckboxFocus;
|
|
18
|
-
exports.walkOut =
|
|
18
|
+
exports.walkOut = void 0;
|
|
19
19
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
20
20
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
21
21
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
@@ -213,56 +213,6 @@ var walkOut = exports.walkOut = function walkOut($startPos) {
|
|
|
213
213
|
return $pos;
|
|
214
214
|
};
|
|
215
215
|
|
|
216
|
-
/**
|
|
217
|
-
* Finds the height of a tree-like structure, given any position inside it.
|
|
218
|
-
*
|
|
219
|
-
* Traverses from the top of the tree to all leaf nodes, and returns the length
|
|
220
|
-
* of the longest path.
|
|
221
|
-
*
|
|
222
|
-
* This means you can use it with things like taskList, which
|
|
223
|
-
* do not nest themselves inside taskItems but rather as adjacent children.
|
|
224
|
-
*
|
|
225
|
-
* @param $pos Any position inside the tree.
|
|
226
|
-
* @param types The node types to consider traversable
|
|
227
|
-
*/
|
|
228
|
-
var subtreeHeight = exports.subtreeHeight = function subtreeHeight($from, $to, types) {
|
|
229
|
-
var root = (0, _utils.findFarthestParentNode)(function (node) {
|
|
230
|
-
return types.indexOf(node.type) > -1;
|
|
231
|
-
})($from);
|
|
232
|
-
if (!root) {
|
|
233
|
-
return -1;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// get the height between the root and the current position
|
|
237
|
-
var distToParent = $from.depth - root.depth;
|
|
238
|
-
|
|
239
|
-
// include any following taskList since nested lists appear
|
|
240
|
-
// as siblings
|
|
241
|
-
//
|
|
242
|
-
// this is unlike regular bullet lists where the orderedList
|
|
243
|
-
// appears as descendent of listItem
|
|
244
|
-
var blockRange = getBlockRange({
|
|
245
|
-
$from: $from,
|
|
246
|
-
$to: $to
|
|
247
|
-
});
|
|
248
|
-
if (!blockRange) {
|
|
249
|
-
return -1;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// and get the max height from the current position to the
|
|
253
|
-
// deepest leaf node
|
|
254
|
-
var maxChildDepth = $from.depth;
|
|
255
|
-
$from.doc.nodesBetween(blockRange.start, blockRange.end, function (descendent, relPos, _parent) {
|
|
256
|
-
maxChildDepth = Math.max($from.doc.resolve(relPos).depth, maxChildDepth);
|
|
257
|
-
|
|
258
|
-
// keep descending down the tree if we can
|
|
259
|
-
if (types.indexOf(descendent.type) > -1) {
|
|
260
|
-
return true;
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
return distToParent + (maxChildDepth - $from.depth);
|
|
264
|
-
};
|
|
265
|
-
|
|
266
216
|
/**
|
|
267
217
|
* Determines if the current selection is inside an empty taskItem, decisionItem, or blockTaskItem.
|
|
268
218
|
*
|
|
@@ -20,7 +20,6 @@ var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
|
20
20
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
21
21
|
var _state2 = require("@atlaskit/editor-prosemirror/state");
|
|
22
22
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
23
|
-
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
24
23
|
var _moveSelectedTaskListItems = require("./actions/move-selected-task-list-items");
|
|
25
24
|
var _commands2 = require("./commands");
|
|
26
25
|
var _helpers = require("./helpers");
|
|
@@ -108,24 +107,18 @@ var getUnindentCommand = exports.getUnindentCommand = function getUnindentComman
|
|
|
108
107
|
return (0, _utils.filterCommand)(_helpers.isInsideTask, function (state, dispatch) {
|
|
109
108
|
var normalizedSelection = (0, _utils3.normalizeTaskItemsSelection)(state.selection);
|
|
110
109
|
var curIndentLevel = (0, _helpers.getCurrentIndentLevel)(normalizedSelection);
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
var outdentTr = (0, _moveSelectedTaskListItems.moveSelectedTaskListItems)(state.tr, -1);
|
|
116
|
-
if (outdentTr) {
|
|
117
|
-
(0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, indentationAnalytics(curIndentLevel, _analytics.INDENT_DIRECTION.OUTDENT, inputMethod))(function (_state, d) {
|
|
118
|
-
d === null || d === void 0 || d(outdentTr);
|
|
119
|
-
return true;
|
|
120
|
-
})(state, dispatch);
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
return false;
|
|
110
|
+
if (!curIndentLevel) {
|
|
111
|
+
return true;
|
|
124
112
|
}
|
|
125
|
-
|
|
126
|
-
|
|
113
|
+
var outdentTr = (0, _moveSelectedTaskListItems.moveSelectedTaskListItems)(state.tr, -1);
|
|
114
|
+
if (outdentTr) {
|
|
115
|
+
(0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, indentationAnalytics(curIndentLevel, _analytics.INDENT_DIRECTION.OUTDENT, inputMethod))(function (_state, d) {
|
|
116
|
+
d === null || d === void 0 || d(outdentTr);
|
|
117
|
+
return true;
|
|
118
|
+
})(state, dispatch);
|
|
119
|
+
return true;
|
|
127
120
|
}
|
|
128
|
-
return
|
|
121
|
+
return false;
|
|
129
122
|
});
|
|
130
123
|
};
|
|
131
124
|
};
|
|
@@ -152,24 +145,18 @@ var getIndentCommand = exports.getIndentCommand = function getIndentCommand(edit
|
|
|
152
145
|
return (0, _utils.filterCommand)(_helpers.isInsideTask, function (state, dispatch) {
|
|
153
146
|
var normalizedSelection = (0, _utils3.normalizeTaskItemsSelection)(state.selection);
|
|
154
147
|
var curIndentLevel = (0, _helpers.getCurrentIndentLevel)(normalizedSelection);
|
|
155
|
-
if (
|
|
156
|
-
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
var indentTr = (0, _moveSelectedTaskListItems.moveSelectedTaskListItems)(state.tr, 1);
|
|
160
|
-
if (indentTr) {
|
|
161
|
-
(0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, indentationAnalytics(curIndentLevel, _analytics.INDENT_DIRECTION.INDENT, inputMethod))(function (_state, d) {
|
|
162
|
-
d === null || d === void 0 || d(indentTr);
|
|
163
|
-
return true;
|
|
164
|
-
})(state, dispatch);
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
return false;
|
|
148
|
+
if (!curIndentLevel) {
|
|
149
|
+
return true;
|
|
168
150
|
}
|
|
169
|
-
|
|
151
|
+
var indentTr = (0, _moveSelectedTaskListItems.moveSelectedTaskListItems)(state.tr, 1);
|
|
152
|
+
if (indentTr) {
|
|
153
|
+
(0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, indentationAnalytics(curIndentLevel, _analytics.INDENT_DIRECTION.INDENT, inputMethod))(function (_state, d) {
|
|
154
|
+
d === null || d === void 0 || d(indentTr);
|
|
155
|
+
return true;
|
|
156
|
+
})(state, dispatch);
|
|
170
157
|
return true;
|
|
171
158
|
}
|
|
172
|
-
return
|
|
159
|
+
return false;
|
|
173
160
|
});
|
|
174
161
|
};
|
|
175
162
|
};
|
|
@@ -607,13 +594,12 @@ var enter = function enter(editorAnalyticsAPI, getContextIdentifier) {
|
|
|
607
594
|
tr.insert(insertPos, newTask);
|
|
608
595
|
// Place cursor on the newly inserted empty task item above
|
|
609
596
|
// when nested inside another taskList.
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
}
|
|
597
|
+
|
|
598
|
+
var taskListType = schema.nodes.taskList;
|
|
599
|
+
var parentTaskList = $from.node($from.depth - 1);
|
|
600
|
+
var grandparent = $from.depth >= 3 ? $from.node($from.depth - 2) : null;
|
|
601
|
+
if ((parentTaskList === null || parentTaskList === void 0 ? void 0 : parentTaskList.type) === taskListType && (grandparent === null || grandparent === void 0 ? void 0 : grandparent.type) === taskListType) {
|
|
602
|
+
tr.setSelection(_state2.TextSelection.create(tr.doc, insertPos + 1));
|
|
617
603
|
}
|
|
618
604
|
return tr;
|
|
619
605
|
}
|
|
@@ -15,14 +15,12 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
15
15
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
16
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
17
17
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
18
|
-
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
19
18
|
var _DecisionItemNodeView = require("../nodeviews/DecisionItemNodeView");
|
|
20
19
|
var _taskNodeView = require("../nodeviews/task-node-view");
|
|
21
20
|
var _actions = require("./actions");
|
|
22
21
|
var _helpers = require("./helpers");
|
|
23
22
|
var _pluginKey = require("./plugin-key");
|
|
24
23
|
var _taskItemOnChange = require("./taskItemOnChange");
|
|
25
|
-
var _transforms = require("./transforms");
|
|
26
24
|
var _types = require("./types");
|
|
27
25
|
var _paste = require("./utils/paste");
|
|
28
26
|
var _excluded = ["localId"];
|
|
@@ -270,24 +268,6 @@ function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api, getIntl
|
|
|
270
268
|
* Note: we currently do not handle the edge case where two nodes may have the same localId
|
|
271
269
|
*/
|
|
272
270
|
appendTransaction: function appendTransaction(transactions, _oldState, newState) {
|
|
273
|
-
// Normalise taskList structure first — runs on its own transaction (without addToHistory: false)
|
|
274
|
-
// so it is included in history and correctly undone with the triggering operation.
|
|
275
|
-
if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_flexible_list_schema', 'isEnabled', true) && transactions.some(function (t) {
|
|
276
|
-
return t.docChanged;
|
|
277
|
-
})) {
|
|
278
|
-
var normTr = (0, _transforms.applyTaskListNormalisationFixes)({
|
|
279
|
-
tr: newState.tr,
|
|
280
|
-
transactions: transactions,
|
|
281
|
-
doc: newState.doc,
|
|
282
|
-
schema: newState.schema
|
|
283
|
-
});
|
|
284
|
-
if (normTr.docChanged) {
|
|
285
|
-
// Return the normalisation transaction — the next appendTransaction call will
|
|
286
|
-
// assign any missing localIds to newly inserted nodes via the localId path below.
|
|
287
|
-
return normTr;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
271
|
// Assign unique localIds to any new nodes that don't have one.
|
|
292
272
|
// Runs with addToHistory: false so localId assignment is not part of the undo history.
|
|
293
273
|
var tr = newState.tr;
|
|
@@ -6,16 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.flattenTaskList = flattenTaskList;
|
|
7
7
|
exports.rebuildTaskList = rebuildTaskList;
|
|
8
8
|
var _uuid = require("@atlaskit/adf-schema/uuid");
|
|
9
|
-
var _lists = require("@atlaskit/editor-common/lists");
|
|
10
|
-
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
11
9
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
12
10
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
13
11
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
12
|
/**
|
|
15
|
-
* Flattens a taskList into
|
|
16
|
-
*
|
|
13
|
+
* Flattens a taskList tree into an array of task items with computed depths.
|
|
14
|
+
* Only selected items have their depth adjusted by indentDelta.
|
|
17
15
|
*/
|
|
18
|
-
function
|
|
16
|
+
function flattenTaskList(options) {
|
|
19
17
|
var doc = options.doc,
|
|
20
18
|
rootListStart = options.rootListStart,
|
|
21
19
|
rootListEnd = options.rootListEnd,
|
|
@@ -72,35 +70,6 @@ function flattenTaskListImpl(options) {
|
|
|
72
70
|
};
|
|
73
71
|
}
|
|
74
72
|
|
|
75
|
-
/**
|
|
76
|
-
* Flattens a taskList tree into an array of task items with computed depths.
|
|
77
|
-
* Only selected items have their depth adjusted by indentDelta.
|
|
78
|
-
*/
|
|
79
|
-
function flattenTaskList(options) {
|
|
80
|
-
if ((0, _fg.fg)('platform_editor_flexible_list_normalization_fix')) {
|
|
81
|
-
return flattenTaskListImpl(options);
|
|
82
|
-
}
|
|
83
|
-
var _options$doc$type$sch = options.doc.type.schema.nodes,
|
|
84
|
-
taskList = _options$doc$type$sch.taskList,
|
|
85
|
-
taskItem = _options$doc$type$sch.taskItem,
|
|
86
|
-
blockTaskItem = _options$doc$type$sch.blockTaskItem;
|
|
87
|
-
return (0, _lists.flattenList)(options, {
|
|
88
|
-
isContentNode: function isContentNode(node, parent) {
|
|
89
|
-
var isTaskItemType = node.type === taskItem || blockTaskItem != null && node.type === blockTaskItem;
|
|
90
|
-
return isTaskItemType && parent != null && parent.type === taskList;
|
|
91
|
-
},
|
|
92
|
-
getSelectionBounds: function getSelectionBounds(node, pos) {
|
|
93
|
-
return {
|
|
94
|
-
start: pos,
|
|
95
|
-
end: pos + node.nodeSize
|
|
96
|
-
};
|
|
97
|
-
},
|
|
98
|
-
getDepth: function getDepth(resolvedDepth, rootDepth) {
|
|
99
|
-
return resolvedDepth - rootDepth - 1;
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
73
|
// Each stack entry collects children for a taskList at a given depth.
|
|
105
74
|
// The root entry (depth -1) is special: its children become the content
|
|
106
75
|
// of the outermost taskList directly (not wrapped in another taskList).
|
|
@@ -27,7 +27,6 @@ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
|
27
27
|
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
28
28
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
29
29
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
30
|
-
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
31
30
|
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
32
31
|
var _helpers = require("./pm-plugins/helpers");
|
|
33
32
|
var _inputRules = _interopRequireDefault(require("./pm-plugins/input-rules"));
|
|
@@ -208,13 +207,11 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
|
|
|
208
207
|
}
|
|
209
208
|
var pluginState = _pluginKey.stateKey.getState(editorState);
|
|
210
209
|
var indentLevel = (0, _helpers.getCurrentIndentLevel)(editorState.selection) || 0;
|
|
211
|
-
var itemIndex = (0, _helpers.getTaskItemIndex)(editorState);
|
|
212
|
-
var isFlexibleListIndentationEnabled = (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_flexible_list_indentation', 'isEnabled', true);
|
|
213
210
|
return {
|
|
214
211
|
focusedTaskItemLocalId: (pluginState === null || pluginState === void 0 ? void 0 : pluginState.focusedTaskItemLocalId) || null,
|
|
215
212
|
isInsideTask: (0, _helpers.isInsideTask)(editorState),
|
|
216
|
-
indentDisabled:
|
|
217
|
-
outdentDisabled:
|
|
213
|
+
indentDisabled: indentLevel >= _indentation.MAX_INDENTATION_LEVEL,
|
|
214
|
+
outdentDisabled: indentLevel <= 0,
|
|
218
215
|
// hasEditPermission is assumed to be true if pluginState.hasEditPermission is undefined
|
|
219
216
|
// this allows the default plugin state to initialise as true if the extra configuration is not provided
|
|
220
217
|
hasEditPermission: (pluginState === null || pluginState === void 0 ? void 0 : pluginState.hasEditPermission) !== undefined ? pluginState === null || pluginState === void 0 ? void 0 : pluginState.hasEditPermission : true,
|
|
@@ -18,7 +18,8 @@ var _insertCommands = require("../../pm-plugins/insert-commands");
|
|
|
18
18
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
19
19
|
var TasksAndDecisionsQuickInsertMenuItem = exports.TasksAndDecisionsQuickInsertMenuItem = function TasksAndDecisionsQuickInsertMenuItem(_ref) {
|
|
20
20
|
var api = _ref.api,
|
|
21
|
-
item = _ref.item
|
|
21
|
+
item = _ref.item,
|
|
22
|
+
previewImageUrls = _ref.previewImageUrls;
|
|
22
23
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
23
24
|
formatMessage = _useIntl.formatMessage;
|
|
24
25
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['contextIdentifier'], function (states) {
|
|
@@ -58,6 +59,7 @@ var TasksAndDecisionsQuickInsertMenuItem = exports.TasksAndDecisionsQuickInsertM
|
|
|
58
59
|
label: ""
|
|
59
60
|
}),
|
|
60
61
|
onSelect: onSelect,
|
|
62
|
+
previewImageUrls: previewImageUrls,
|
|
61
63
|
shortcut: isAction ? '[]' : '<>',
|
|
62
64
|
title: formatMessage(isAction ? _messages.toolbarInsertBlockMessages.action : _messages.toolbarInsertBlockMessages.decision)
|
|
63
65
|
});
|
|
@@ -11,6 +11,14 @@ var _createQuickInsertMatcher = require("@atlaskit/editor-common/quick-insert/cr
|
|
|
11
11
|
var _keys = require("@atlaskit/editor-common/quick-insert/keys");
|
|
12
12
|
var _rank = require("@atlaskit/editor-common/quick-insert/rank");
|
|
13
13
|
var _TasksAndDecisionsQuickInsertMenuItem = require("./TasksAndDecisionsQuickInsertMenuItem");
|
|
14
|
+
var taskPreviewImageUrls = {
|
|
15
|
+
light: 'https://dam-cdn.atl.orangelogic.com/AssetLink/y5ly4nr488m2m4k4esk1bu415k1gn4gn.png',
|
|
16
|
+
dark: 'https://dam-cdn.atl.orangelogic.com/AssetLink/t7loyl783j0qo1h45i828310rv4au3h8.png'
|
|
17
|
+
};
|
|
18
|
+
var decisionPreviewImageUrls = {
|
|
19
|
+
light: 'https://dam-cdn.atl.orangelogic.com/AssetLink/h5duy8s83312r7263jauu10mapc53383.png',
|
|
20
|
+
dark: 'https://dam-cdn.atl.orangelogic.com/AssetLink/70q22b8a03dep35ynbv8xigg82osw0rk.png'
|
|
21
|
+
};
|
|
14
22
|
var getTasksAndDecisionsQuickInsertComponents = exports.getTasksAndDecisionsQuickInsertComponents = function getTasksAndDecisionsQuickInsertComponents(_ref) {
|
|
15
23
|
var api = _ref.api,
|
|
16
24
|
quickInsertActionDescription = _ref.quickInsertActionDescription;
|
|
@@ -34,7 +42,8 @@ var getTasksAndDecisionsQuickInsertComponents = exports.getTasksAndDecisionsQuic
|
|
|
34
42
|
component: function component() {
|
|
35
43
|
return /*#__PURE__*/_react.default.createElement(_TasksAndDecisionsQuickInsertMenuItem.TasksAndDecisionsQuickInsertMenuItem, {
|
|
36
44
|
api: api,
|
|
37
|
-
item: "taskList"
|
|
45
|
+
item: "taskList",
|
|
46
|
+
previewImageUrls: taskPreviewImageUrls
|
|
38
47
|
});
|
|
39
48
|
}
|
|
40
49
|
}, {
|
|
@@ -57,7 +66,8 @@ var getTasksAndDecisionsQuickInsertComponents = exports.getTasksAndDecisionsQuic
|
|
|
57
66
|
component: function component() {
|
|
58
67
|
return /*#__PURE__*/_react.default.createElement(_TasksAndDecisionsQuickInsertMenuItem.TasksAndDecisionsQuickInsertMenuItem, {
|
|
59
68
|
api: api,
|
|
60
|
-
item: "decisionList"
|
|
69
|
+
item: "decisionList",
|
|
70
|
+
previewImageUrls: decisionPreviewImageUrls
|
|
61
71
|
});
|
|
62
72
|
}
|
|
63
73
|
}];
|
|
@@ -1,87 +1,9 @@
|
|
|
1
1
|
import { findCutBefore } from '@atlaskit/editor-common/commands';
|
|
2
2
|
import { getFirstParagraphBlockMarkAttrs } from '@atlaskit/editor-common/lists';
|
|
3
3
|
import { isTaskList } from '@atlaskit/editor-common/transforms';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { findBlockTaskItem, normalizeTaskItemsSelection } from './utils';
|
|
4
|
+
import { ReplaceAroundStep } from '@atlaskit/editor-prosemirror/transform';
|
|
5
|
+
import { isActionOrDecisionItem, isActionOrDecisionList } from './helpers';
|
|
7
6
|
import { normalizeNodeForTaskTextSize } from './utils/paste';
|
|
8
|
-
export const liftSelection = (state, dispatch) => {
|
|
9
|
-
const normalizedSelection = normalizeTaskItemsSelection(state.selection);
|
|
10
|
-
const {
|
|
11
|
-
$from,
|
|
12
|
-
$to
|
|
13
|
-
} = normalizedSelection;
|
|
14
|
-
const tr = liftBlock(state.tr, $from, $to);
|
|
15
|
-
if (dispatch && tr) {
|
|
16
|
-
dispatch(tr);
|
|
17
|
-
}
|
|
18
|
-
return !!tr;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Wraps the current selection in a task list, respecting a maximum indentation depth of 6 levels.
|
|
23
|
-
*
|
|
24
|
-
* - Normalizes the selection to ensure it covers complete task items.
|
|
25
|
-
* - Determines the maximum depth of task list nesting within the selection.
|
|
26
|
-
* - If the selection is already nested at or beyond the maximum depth, the command does nothing.
|
|
27
|
-
* - Calculates the block range to wrap, handling both regular and block task items.
|
|
28
|
-
* - Wraps the block in a task list to increase indentation or create a new task list if necessary.
|
|
29
|
-
*
|
|
30
|
-
* @param state - The current editor state.
|
|
31
|
-
* @param dispatch - The dispatch function to apply the transaction.
|
|
32
|
-
* @returns `true` if the command was handled (even if no changes were made), otherwise `false`.
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* autoJoin(wrapSelectionInTaskList, ['taskList']))(state, dispatch);
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export const wrapSelectionInTaskList = (state, dispatch) => {
|
|
39
|
-
const {
|
|
40
|
-
$from,
|
|
41
|
-
$to
|
|
42
|
-
} = normalizeTaskItemsSelection(state.selection);
|
|
43
|
-
|
|
44
|
-
// limit ui indentation to 6 levels
|
|
45
|
-
const {
|
|
46
|
-
taskList,
|
|
47
|
-
taskItem,
|
|
48
|
-
blockTaskItem
|
|
49
|
-
} = state.schema.nodes;
|
|
50
|
-
let maxDepth = subtreeHeight($from, $to, [taskList, taskItem]);
|
|
51
|
-
if (blockTaskItem) {
|
|
52
|
-
const resultOfFindBlockTaskItem = findBlockTaskItem($from);
|
|
53
|
-
if (resultOfFindBlockTaskItem) {
|
|
54
|
-
const {
|
|
55
|
-
hasParagraph
|
|
56
|
-
} = resultOfFindBlockTaskItem;
|
|
57
|
-
// If the selection is inside a nested node inside the blockTaskItem
|
|
58
|
-
// Remove the difference in depth between the selection and the blockTaskItemNode
|
|
59
|
-
if (hasParagraph) {
|
|
60
|
-
maxDepth = subtreeHeight($from, $to, [taskList, blockTaskItem]) - 1;
|
|
61
|
-
} else {
|
|
62
|
-
maxDepth = subtreeHeight($from, $to, [taskList, blockTaskItem]);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (maxDepth >= 6) {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
const blockRange = getBlockRange({
|
|
70
|
-
$from,
|
|
71
|
-
$to
|
|
72
|
-
});
|
|
73
|
-
if (!blockRange) {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
const wrapping = findWrapping(blockRange, state.schema.nodes.taskList);
|
|
77
|
-
if (!wrapping) {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
if (dispatch) {
|
|
81
|
-
dispatch(state.tr.wrap(blockRange, wrapping).scrollIntoView());
|
|
82
|
-
}
|
|
83
|
-
return true;
|
|
84
|
-
};
|
|
85
7
|
|
|
86
8
|
/**
|
|
87
9
|
* Tries to move the paragraph content near the given position into the taskItem or decisionItem
|
|
@@ -203,54 +203,6 @@ export const walkOut = $startPos => {
|
|
|
203
203
|
return $pos;
|
|
204
204
|
};
|
|
205
205
|
|
|
206
|
-
/**
|
|
207
|
-
* Finds the height of a tree-like structure, given any position inside it.
|
|
208
|
-
*
|
|
209
|
-
* Traverses from the top of the tree to all leaf nodes, and returns the length
|
|
210
|
-
* of the longest path.
|
|
211
|
-
*
|
|
212
|
-
* This means you can use it with things like taskList, which
|
|
213
|
-
* do not nest themselves inside taskItems but rather as adjacent children.
|
|
214
|
-
*
|
|
215
|
-
* @param $pos Any position inside the tree.
|
|
216
|
-
* @param types The node types to consider traversable
|
|
217
|
-
*/
|
|
218
|
-
export const subtreeHeight = ($from, $to, types) => {
|
|
219
|
-
const root = findFarthestParentNode(node => types.indexOf(node.type) > -1)($from);
|
|
220
|
-
if (!root) {
|
|
221
|
-
return -1;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// get the height between the root and the current position
|
|
225
|
-
const distToParent = $from.depth - root.depth;
|
|
226
|
-
|
|
227
|
-
// include any following taskList since nested lists appear
|
|
228
|
-
// as siblings
|
|
229
|
-
//
|
|
230
|
-
// this is unlike regular bullet lists where the orderedList
|
|
231
|
-
// appears as descendent of listItem
|
|
232
|
-
const blockRange = getBlockRange({
|
|
233
|
-
$from,
|
|
234
|
-
$to
|
|
235
|
-
});
|
|
236
|
-
if (!blockRange) {
|
|
237
|
-
return -1;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// and get the max height from the current position to the
|
|
241
|
-
// deepest leaf node
|
|
242
|
-
let maxChildDepth = $from.depth;
|
|
243
|
-
$from.doc.nodesBetween(blockRange.start, blockRange.end, (descendent, relPos, _parent) => {
|
|
244
|
-
maxChildDepth = Math.max($from.doc.resolve(relPos).depth, maxChildDepth);
|
|
245
|
-
|
|
246
|
-
// keep descending down the tree if we can
|
|
247
|
-
if (types.indexOf(descendent.type) > -1) {
|
|
248
|
-
return true;
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
return distToParent + (maxChildDepth - $from.depth);
|
|
252
|
-
};
|
|
253
|
-
|
|
254
206
|
/**
|
|
255
207
|
* Determines if the current selection is inside an empty taskItem, decisionItem, or blockTaskItem.
|
|
256
208
|
*
|