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