@atlaskit/editor-plugin-tasks-and-decisions 0.2.16 → 0.3.1
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 +20 -0
- package/dist/cjs/commands.js +6 -7
- package/dist/cjs/plugin.js +8 -4
- package/dist/cjs/pm-plugins/helpers.js +22 -0
- package/dist/cjs/pm-plugins/input-rules.js +6 -6
- package/dist/cjs/pm-plugins/keymaps.js +67 -8
- package/dist/cjs/pm-plugins/main.js +0 -31
- package/dist/cjs/pm-plugins/types.js +1 -2
- package/dist/cjs/ui/ToolbarDecision/index.js +5 -1
- package/dist/cjs/ui/ToolbarTask/index.js +5 -1
- package/dist/es2019/commands.js +6 -7
- package/dist/es2019/plugin.js +8 -4
- package/dist/es2019/pm-plugins/helpers.js +22 -1
- package/dist/es2019/pm-plugins/input-rules.js +6 -6
- package/dist/es2019/pm-plugins/keymaps.js +71 -10
- package/dist/es2019/pm-plugins/main.js +0 -30
- package/dist/es2019/pm-plugins/types.js +1 -2
- package/dist/es2019/ui/ToolbarDecision/index.js +5 -1
- package/dist/es2019/ui/ToolbarTask/index.js +5 -1
- package/dist/esm/commands.js +6 -7
- package/dist/esm/plugin.js +8 -4
- package/dist/esm/pm-plugins/helpers.js +22 -1
- package/dist/esm/pm-plugins/input-rules.js +6 -6
- package/dist/esm/pm-plugins/keymaps.js +69 -10
- package/dist/esm/pm-plugins/main.js +0 -31
- package/dist/esm/pm-plugins/types.js +1 -2
- package/dist/esm/ui/ToolbarDecision/index.js +5 -1
- package/dist/esm/ui/ToolbarTask/index.js +5 -1
- package/dist/types/commands.d.ts +4 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/pm-plugins/helpers.d.ts +4 -0
- package/dist/types/pm-plugins/input-rules.d.ts +2 -1
- package/dist/types/pm-plugins/types.d.ts +1 -2
- package/dist/types/types.d.ts +5 -1
- package/dist/types-ts4.5/commands.d.ts +4 -4
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/helpers.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/input-rules.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/types.d.ts +1 -2
- package/dist/types-ts4.5/types.d.ts +5 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-tasks-and-decisions
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#68640](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68640) [`6a3ea210641a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6a3ea210641a) - Create new context identifier plugin which contains the provider.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 0.3.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [#68790](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68790) [`c6d8affc52d1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c6d8affc52d1) - Support maybeAdd plugins in usePreset. Add typing support for universal preset.
|
|
15
|
+
|
|
16
|
+
Now when using the editor API with the universal preset
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [#69144](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/69144) [`10e7328aea8c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/10e7328aea8c) - [ux] ED-21844 Add fix for enter keybind behaviour for nested actions inside list and relevant testcases
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 0.2.16
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/cjs/commands.js
CHANGED
|
@@ -14,7 +14,6 @@ var _model = require("@atlaskit/editor-prosemirror/model");
|
|
|
14
14
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
15
15
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
16
16
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
17
|
-
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
18
17
|
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; }
|
|
19
18
|
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; }
|
|
20
19
|
var getContextData = function getContextData() {
|
|
@@ -71,7 +70,7 @@ var getListTypes = exports.getListTypes = function getListTypes(listType, schema
|
|
|
71
70
|
item: decisionItem
|
|
72
71
|
};
|
|
73
72
|
};
|
|
74
|
-
var insertTaskDecisionAction = exports.insertTaskDecisionAction = function insertTaskDecisionAction(editorAnalyticsAPI) {
|
|
73
|
+
var insertTaskDecisionAction = exports.insertTaskDecisionAction = function insertTaskDecisionAction(editorAnalyticsAPI, getContextIdentifierProvider) {
|
|
75
74
|
return function (state, listType) {
|
|
76
75
|
var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _analytics.INPUT_METHOD.TOOLBAR;
|
|
77
76
|
var addItem = arguments.length > 3 ? arguments[3] : undefined;
|
|
@@ -103,7 +102,7 @@ var insertTaskDecisionAction = exports.insertTaskDecisionAction = function inser
|
|
|
103
102
|
}]).setSelection(new _state.TextSelection(tr.doc.resolve(newItemParagraphPos)));
|
|
104
103
|
};
|
|
105
104
|
var addAndCreateListFn = addItem !== null && addItem !== void 0 ? addItem : addAndCreateList;
|
|
106
|
-
var tr = insertTaskDecisionWithAnalytics(editorAnalyticsAPI)(state, listType, inputMethod, addAndCreateListFn, addToList, listLocalId, itemLocalId, itemAttrs);
|
|
105
|
+
var tr = insertTaskDecisionWithAnalytics(editorAnalyticsAPI, getContextIdentifierProvider)(state, listType, inputMethod, addAndCreateListFn, addToList, listLocalId, itemLocalId, itemAttrs);
|
|
107
106
|
if (!tr) {
|
|
108
107
|
return state.tr;
|
|
109
108
|
}
|
|
@@ -111,14 +110,14 @@ var insertTaskDecisionAction = exports.insertTaskDecisionAction = function inser
|
|
|
111
110
|
return tr;
|
|
112
111
|
};
|
|
113
112
|
};
|
|
114
|
-
var insertTaskDecisionCommand = exports.insertTaskDecisionCommand = function insertTaskDecisionCommand(editorAnalyticsAPI) {
|
|
113
|
+
var insertTaskDecisionCommand = exports.insertTaskDecisionCommand = function insertTaskDecisionCommand(editorAnalyticsAPI, getContextIdentifierProvider) {
|
|
115
114
|
return function (listType) {
|
|
116
115
|
var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analytics.INPUT_METHOD.TOOLBAR;
|
|
117
116
|
var addItem = arguments.length > 2 ? arguments[2] : undefined;
|
|
118
117
|
var listLocalId = arguments.length > 3 ? arguments[3] : undefined;
|
|
119
118
|
var itemLocalId = arguments.length > 4 ? arguments[4] : undefined;
|
|
120
119
|
return function (state, dispatch) {
|
|
121
|
-
var tr = insertTaskDecisionAction(editorAnalyticsAPI)(state, listType, inputMethod, addItem, listLocalId, itemLocalId);
|
|
120
|
+
var tr = insertTaskDecisionAction(editorAnalyticsAPI, getContextIdentifierProvider)(state, listType, inputMethod, addItem, listLocalId, itemLocalId);
|
|
122
121
|
if (dispatch) {
|
|
123
122
|
dispatch(tr);
|
|
124
123
|
}
|
|
@@ -126,7 +125,7 @@ var insertTaskDecisionCommand = exports.insertTaskDecisionCommand = function ins
|
|
|
126
125
|
};
|
|
127
126
|
};
|
|
128
127
|
};
|
|
129
|
-
var insertTaskDecisionWithAnalytics = exports.insertTaskDecisionWithAnalytics = function insertTaskDecisionWithAnalytics(editorAnalyticsAPI) {
|
|
128
|
+
var insertTaskDecisionWithAnalytics = exports.insertTaskDecisionWithAnalytics = function insertTaskDecisionWithAnalytics(editorAnalyticsAPI, getContextIdentifierProvider) {
|
|
130
129
|
return function (state, listType, inputMethod, addAndCreateList, addToList, listLocalId, itemLocalId, itemAttrs) {
|
|
131
130
|
var schema = state.schema;
|
|
132
131
|
var _getListTypes = getListTypes(listType, schema),
|
|
@@ -135,7 +134,7 @@ var insertTaskDecisionWithAnalytics = exports.insertTaskDecisionWithAnalytics =
|
|
|
135
134
|
var tr = state.tr;
|
|
136
135
|
var $to = state.selection.$to;
|
|
137
136
|
var listNode = (0, _utils2.findParentNodeOfType)(list)(state.selection);
|
|
138
|
-
var contextIdentifierProvider =
|
|
137
|
+
var contextIdentifierProvider = getContextIdentifierProvider();
|
|
139
138
|
var contextData = getContextData(contextIdentifierProvider);
|
|
140
139
|
var insertTrCreator;
|
|
141
140
|
var itemIdx;
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -49,6 +49,10 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
|
|
|
49
49
|
consumeTabs = _ref2$config2.consumeTabs,
|
|
50
50
|
useLongPressSelection = _ref2$config2.useLongPressSelection,
|
|
51
51
|
api = _ref2.api;
|
|
52
|
+
var getIdentifierProvider = function getIdentifierProvider() {
|
|
53
|
+
var _api$contextIdentifie;
|
|
54
|
+
return api === null || api === void 0 || (_api$contextIdentifie = api.contextIdentifier) === null || _api$contextIdentifie === void 0 || (_api$contextIdentifie = _api$contextIdentifie.sharedState.currentState()) === null || _api$contextIdentifie === void 0 ? void 0 : _api$contextIdentifie.contextIdentifierProvider;
|
|
55
|
+
};
|
|
52
56
|
return {
|
|
53
57
|
name: 'taskDecision',
|
|
54
58
|
nodes: function nodes() {
|
|
@@ -81,7 +85,7 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
|
|
|
81
85
|
};
|
|
82
86
|
},
|
|
83
87
|
actions: {
|
|
84
|
-
insertTaskDecision: (0, _commands.insertTaskDecisionCommand)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
|
|
88
|
+
insertTaskDecision: (0, _commands.insertTaskDecisionCommand)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, getIdentifierProvider),
|
|
85
89
|
indentTaskList: (0, _keymaps.getIndentCommand)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
|
|
86
90
|
outdentTaskList: (0, _keymaps.getUnindentCommand)(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)
|
|
87
91
|
},
|
|
@@ -101,7 +105,7 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
|
|
|
101
105
|
var _api$analytics4;
|
|
102
106
|
var schema = _ref4.schema,
|
|
103
107
|
featureFlags = _ref4.featureFlags;
|
|
104
|
-
return (0, _inputRules.default)(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)(schema, featureFlags);
|
|
108
|
+
return (0, _inputRules.default)(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, getIdentifierProvider)(schema, featureFlags);
|
|
105
109
|
}
|
|
106
110
|
}, {
|
|
107
111
|
name: 'tasksAndDecisionsKeyMap',
|
|
@@ -144,7 +148,7 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
|
|
|
144
148
|
},
|
|
145
149
|
action: function action(insert, state) {
|
|
146
150
|
var _api$analytics5;
|
|
147
|
-
return (0, _commands.insertTaskDecisionAction)(api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions)(state, 'taskList', _analytics.INPUT_METHOD.QUICK_INSERT, addItem(insert, 'taskList', state.schema));
|
|
151
|
+
return (0, _commands.insertTaskDecisionAction)(api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, getIdentifierProvider)(state, 'taskList', _analytics.INPUT_METHOD.QUICK_INSERT, addItem(insert, 'taskList', state.schema));
|
|
148
152
|
}
|
|
149
153
|
}, {
|
|
150
154
|
id: 'decision',
|
|
@@ -157,7 +161,7 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
|
|
|
157
161
|
},
|
|
158
162
|
action: function action(insert, state) {
|
|
159
163
|
var _api$analytics6;
|
|
160
|
-
return (0, _commands.insertTaskDecisionAction)(api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions)(state, 'decisionList', _analytics.INPUT_METHOD.QUICK_INSERT, addItem(insert, 'decisionList', state.schema));
|
|
164
|
+
return (0, _commands.insertTaskDecisionAction)(api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions, getIdentifierProvider)(state, 'decisionList', _analytics.INPUT_METHOD.QUICK_INSERT, addItem(insert, 'decisionList', state.schema));
|
|
161
165
|
}
|
|
162
166
|
}];
|
|
163
167
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.findFirstParentListNode = findFirstParentListNode;
|
|
6
7
|
exports.focusCheckboxAndUpdateSelection = focusCheckboxAndUpdateSelection;
|
|
7
8
|
exports.getAllTaskItemsDataInRootTaskList = getAllTaskItemsDataInRootTaskList;
|
|
8
9
|
exports.getCurrentIndentLevel = exports.getBlockRange = void 0;
|
|
@@ -296,4 +297,25 @@ function removeCheckboxFocus(view) {
|
|
|
296
297
|
dispatch(tr.setMeta(_pluginKey.stateKey, {
|
|
297
298
|
action: _types.ACTIONS.FOCUS_BY_LOCALID
|
|
298
299
|
}));
|
|
300
|
+
}
|
|
301
|
+
function findFirstParentListNode($pos) {
|
|
302
|
+
var currentNode = $pos.doc.nodeAt($pos.pos);
|
|
303
|
+
var listNodePosition = null;
|
|
304
|
+
if ((0, _utils.isListNode)(currentNode)) {
|
|
305
|
+
listNodePosition = $pos.pos;
|
|
306
|
+
} else {
|
|
307
|
+
var result = (0, _utils2.findParentNodeClosestToPos)($pos, _utils.isListNode);
|
|
308
|
+
listNodePosition = result && result.pos;
|
|
309
|
+
}
|
|
310
|
+
if (listNodePosition == null) {
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
var node = $pos.doc.nodeAt(listNodePosition);
|
|
314
|
+
if (!node) {
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
return {
|
|
318
|
+
node: node,
|
|
319
|
+
pos: listNodePosition
|
|
320
|
+
};
|
|
299
321
|
}
|
|
@@ -13,7 +13,7 @@ var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
|
|
|
13
13
|
var _commands = require("../commands");
|
|
14
14
|
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; }
|
|
15
15
|
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; }
|
|
16
|
-
var createListRule = function createListRule(editorAnalyticsAPI) {
|
|
16
|
+
var createListRule = function createListRule(editorAnalyticsAPI, getContextIdentifierProvider) {
|
|
17
17
|
return function (regex, listType, itemAttrs) {
|
|
18
18
|
return (0, _prosemirrorInputRules.createRule)(regex, function (state, _match, start, end) {
|
|
19
19
|
var paragraph = state.schema.nodes.paragraph;
|
|
@@ -26,7 +26,7 @@ var createListRule = function createListRule(editorAnalyticsAPI) {
|
|
|
26
26
|
if ($end.parent.type !== paragraph || !(0, _utils.canInsert)($endOfParent, list.createAndFill())) {
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
|
-
var insertTr = (0, _commands.insertTaskDecisionAction)(editorAnalyticsAPI)(state, listType, _analytics.INPUT_METHOD.FORMATTING, addItem(start, end), undefined, undefined, itemAttrs);
|
|
29
|
+
var insertTr = (0, _commands.insertTaskDecisionAction)(editorAnalyticsAPI, getContextIdentifierProvider)(state, listType, _analytics.INPUT_METHOD.FORMATTING, addItem(start, end), undefined, undefined, itemAttrs);
|
|
30
30
|
return insertTr;
|
|
31
31
|
});
|
|
32
32
|
};
|
|
@@ -86,7 +86,7 @@ var addItem = function addItem(start, end) {
|
|
|
86
86
|
return tr;
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
|
-
var inputRulePlugin = exports.inputRulePlugin = function inputRulePlugin(editorAnalyticsAPI) {
|
|
89
|
+
var inputRulePlugin = exports.inputRulePlugin = function inputRulePlugin(editorAnalyticsAPI, getContextIdentifierProvider) {
|
|
90
90
|
return function (schema, featureFlags) {
|
|
91
91
|
var rules = [];
|
|
92
92
|
var _schema$nodes = schema.nodes,
|
|
@@ -95,11 +95,11 @@ var inputRulePlugin = exports.inputRulePlugin = function inputRulePlugin(editorA
|
|
|
95
95
|
taskList = _schema$nodes.taskList,
|
|
96
96
|
taskItem = _schema$nodes.taskItem;
|
|
97
97
|
if (decisionList && decisionItem) {
|
|
98
|
-
rules.push(createListRule(editorAnalyticsAPI)(new RegExp("(^|".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, ")\\<\\>\\s$")), 'decisionList'));
|
|
98
|
+
rules.push(createListRule(editorAnalyticsAPI, getContextIdentifierProvider)(new RegExp("(^|".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, ")\\<\\>\\s$")), 'decisionList'));
|
|
99
99
|
}
|
|
100
100
|
if (taskList && taskItem) {
|
|
101
|
-
rules.push(createListRule(editorAnalyticsAPI)(new RegExp("(^|".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, ")\\[\\]\\s$")), 'taskList'));
|
|
102
|
-
rules.push(createListRule(editorAnalyticsAPI)(new RegExp("(^|".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, ")\\[x\\]\\s$")), 'taskList', {
|
|
101
|
+
rules.push(createListRule(editorAnalyticsAPI, getContextIdentifierProvider)(new RegExp("(^|".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, ")\\[\\]\\s$")), 'taskList'));
|
|
102
|
+
rules.push(createListRule(editorAnalyticsAPI, getContextIdentifierProvider)(new RegExp("(^|".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, ")\\[x\\]\\s$")), 'taskList', {
|
|
103
103
|
state: 'DONE'
|
|
104
104
|
}));
|
|
105
105
|
}
|
|
@@ -222,7 +222,38 @@ var unindentTaskOrUnwrapTaskDecisionFollowing = function unindentTaskOrUnwrapTas
|
|
|
222
222
|
return false;
|
|
223
223
|
};
|
|
224
224
|
var deleteForwards = (0, _commands.autoJoin)((0, _commands.chainCommands)((0, _utils.deleteEmptyParagraphAndMoveBlockUp)(_helpers.isActionOrDecisionList), joinTaskDecisionFollowing, unindentTaskOrUnwrapTaskDecisionFollowing), ['taskList', 'decisionList']);
|
|
225
|
+
var deleteExtraListItem = function deleteExtraListItem(tr, $from) {
|
|
226
|
+
/*
|
|
227
|
+
After we replace actionItem with empty list item if there's the anomaly of extra empty list item
|
|
228
|
+
the cursor moves inside the first taskItem of splitted taskList
|
|
229
|
+
so the extra list item present above the list item containing taskList & cursor
|
|
230
|
+
*/
|
|
231
|
+
|
|
232
|
+
var $currentFrom = tr.selection.$from;
|
|
233
|
+
var listItemContainingActionList = tr.doc.resolve($currentFrom.start($currentFrom.depth - 2));
|
|
234
|
+
var emptyListItem = tr.doc.resolve(listItemContainingActionList.before() - 1);
|
|
235
|
+
tr.delete(emptyListItem.start(), listItemContainingActionList.pos);
|
|
236
|
+
};
|
|
237
|
+
var processNestedActionItem = function processNestedActionItem(tr, $from, previousListItemPos) {
|
|
238
|
+
var parentListNode = (0, _helpers.findFirstParentListNode)($from);
|
|
239
|
+
var previousChildCountOfList = parentListNode === null || parentListNode === void 0 ? void 0 : parentListNode.node.childCount;
|
|
240
|
+
var currentParentListNode = (0, _helpers.findFirstParentListNode)(tr.doc.resolve(tr.mapping.map($from.pos)));
|
|
241
|
+
var currentChildCountOfList = currentParentListNode === null || currentParentListNode === void 0 ? void 0 : currentParentListNode.node.childCount;
|
|
242
|
+
|
|
243
|
+
/*
|
|
244
|
+
While replacing range with empty list item an extra list item gets created in some of the scenarios
|
|
245
|
+
After splitting only one extra listItem should be created else an extra listItem is created
|
|
246
|
+
*/
|
|
247
|
+
if (previousChildCountOfList && currentChildCountOfList && previousChildCountOfList + 1 !== currentChildCountOfList) {
|
|
248
|
+
deleteExtraListItem(tr, $from);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Set custom selection for nested action inside lists using previosuly calculated previousListItem position
|
|
252
|
+
var stableResolvedPos = tr.doc.resolve(previousListItemPos);
|
|
253
|
+
tr.setSelection(_state.TextSelection.create(tr.doc, stableResolvedPos.after() + 2));
|
|
254
|
+
};
|
|
225
255
|
var splitListItemWith = function splitListItemWith(tr, content, $from, setSelection) {
|
|
256
|
+
var _frag$firstChild;
|
|
226
257
|
var origDoc = tr.doc;
|
|
227
258
|
|
|
228
259
|
// split just before the current item
|
|
@@ -230,7 +261,13 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
|
|
|
230
261
|
var container = $from.node($from.depth - 2);
|
|
231
262
|
var posInList = $from.index($from.depth - 1);
|
|
232
263
|
var shouldSplit = !(!(0, _helpers.isActionOrDecisionList)(container) && posInList === 0);
|
|
233
|
-
|
|
264
|
+
var frag = _model.Fragment.from(content);
|
|
265
|
+
var isNestedActionInsideLists = frag.childCount === 1 && ((_frag$firstChild = frag.firstChild) === null || _frag$firstChild === void 0 ? void 0 : _frag$firstChild.type.name) === 'listItem';
|
|
266
|
+
|
|
267
|
+
/* We don't split the list item if it's nested inside lists
|
|
268
|
+
to have consistent behaviour and their resolution.
|
|
269
|
+
*/
|
|
270
|
+
if (shouldSplit && !isNestedActionInsideLists) {
|
|
234
271
|
// this only splits a node to delete it, so we probably don't need a random uuid
|
|
235
272
|
// but generate one anyway for correctness
|
|
236
273
|
tr = tr.split($from.pos, 1, [{
|
|
@@ -240,19 +277,25 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
|
|
|
240
277
|
}
|
|
241
278
|
}]);
|
|
242
279
|
}
|
|
280
|
+
/*
|
|
281
|
+
In case of nested action inside lists we explicitly set the cursor
|
|
282
|
+
We need to insert it relatively to previous doc structure
|
|
283
|
+
So we calculate the position of previous list item and save that position
|
|
284
|
+
(The cursor can be placed easily next to list item)
|
|
285
|
+
*/
|
|
286
|
+
var previousListItemPos = isNestedActionInsideLists ? $from.start($from.depth - 2) : 0;
|
|
287
|
+
|
|
243
288
|
// and delete the action at the current pos
|
|
244
289
|
// we can do this because we know either first new child will be taskItem or nothing at all
|
|
245
|
-
|
|
290
|
+
|
|
246
291
|
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
292
|
|
|
248
293
|
// put cursor inside paragraph
|
|
249
|
-
if (setSelection) {
|
|
294
|
+
if (setSelection && !isNestedActionInsideLists) {
|
|
250
295
|
tr = tr.setSelection(new _state.TextSelection(tr.doc.resolve($from.pos + 1 - (shouldSplit ? 0 : 2))));
|
|
251
296
|
}
|
|
252
|
-
|
|
253
297
|
// lift list up if the node after the initial one was a taskList
|
|
254
298
|
// which means it would have empty placeholder content if we just immediately delete it
|
|
255
|
-
//
|
|
256
299
|
// if it's a taskItem then it can stand alone, so it's fine
|
|
257
300
|
var $oldAfter = origDoc.resolve($from.after());
|
|
258
301
|
|
|
@@ -273,21 +316,33 @@ var splitListItemWith = function splitListItemWith(tr, content, $from, setSelect
|
|
|
273
316
|
tr = tr.deleteRange(pos - 3, pos - 1);
|
|
274
317
|
}
|
|
275
318
|
}
|
|
319
|
+
if (isNestedActionInsideLists) {
|
|
320
|
+
processNestedActionItem(tr, $from, previousListItemPos);
|
|
321
|
+
}
|
|
276
322
|
return tr;
|
|
277
323
|
};
|
|
324
|
+
var creatParentListItemFragement = function creatParentListItemFragement(state) {
|
|
325
|
+
return state.schema.nodes.listItem.create({}, state.schema.nodes.paragraph.create());
|
|
326
|
+
};
|
|
278
327
|
var splitListItem = function splitListItem(state, dispatch) {
|
|
279
328
|
var tr = state.tr,
|
|
280
329
|
$from = state.selection.$from;
|
|
281
330
|
var paragraph = state.schema.nodes.paragraph;
|
|
331
|
+
var listItem = state.schema.nodes.listItem;
|
|
282
332
|
if (actionDecisionFollowsOrNothing($from)) {
|
|
283
333
|
if (dispatch) {
|
|
334
|
+
if ((0, _utils2.hasParentNodeOfType)(listItem)(tr.selection)) {
|
|
335
|
+
// if we're inside a list item, then we pass in a fragment containing a new list item not a paragraph
|
|
336
|
+
dispatch(splitListItemWith(tr, creatParentListItemFragement(state), $from, true));
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
284
339
|
dispatch(splitListItemWith(tr, paragraph.createChecked(), $from, true));
|
|
285
340
|
}
|
|
286
341
|
return true;
|
|
287
342
|
}
|
|
288
343
|
return false;
|
|
289
344
|
};
|
|
290
|
-
var enter = function enter(editorAnalyticsAPI) {
|
|
345
|
+
var enter = function enter(editorAnalyticsAPI, getContextIdentifier) {
|
|
291
346
|
return (0, _utils.filterCommand)(_helpers.isInsideTaskOrDecisionItem, (0, _commands.chainCommands)((0, _utils.filterCommand)(_helpers.isEmptyTaskDecision, (0, _commands.chainCommands)(getUnindentCommand(editorAnalyticsAPI)(), splitListItem)), function (state, dispatch) {
|
|
292
347
|
var selection = state.selection,
|
|
293
348
|
schema = state.schema;
|
|
@@ -317,7 +372,7 @@ var enter = function enter(editorAnalyticsAPI) {
|
|
|
317
372
|
}
|
|
318
373
|
}]);
|
|
319
374
|
};
|
|
320
|
-
var insertTr = (0, _commands2.insertTaskDecisionWithAnalytics)(editorAnalyticsAPI)(state, listType, _analytics.INPUT_METHOD.KEYBOARD, addItem);
|
|
375
|
+
var insertTr = (0, _commands2.insertTaskDecisionWithAnalytics)(editorAnalyticsAPI, getContextIdentifier)(state, listType, _analytics.INPUT_METHOD.KEYBOARD, addItem);
|
|
321
376
|
if (insertTr && dispatch) {
|
|
322
377
|
insertTr.scrollIntoView();
|
|
323
378
|
dispatch(insertTr);
|
|
@@ -347,6 +402,10 @@ var cmdOptEnter = (0, _utils.filterCommand)(_helpers.isInsideTaskOrDecisionItem,
|
|
|
347
402
|
});
|
|
348
403
|
function keymapPlugin(schema, api, allowNestedTasks, consumeTabs) {
|
|
349
404
|
var _api$analytics3, _api$analytics4;
|
|
405
|
+
var getContextIdentifier = function getContextIdentifier() {
|
|
406
|
+
var _api$contextIdentifie;
|
|
407
|
+
return api === null || api === void 0 || (_api$contextIdentifie = api.contextIdentifier) === null || _api$contextIdentifie === void 0 || (_api$contextIdentifie = _api$contextIdentifie.sharedState.currentState()) === null || _api$contextIdentifie === void 0 ? void 0 : _api$contextIdentifie.contextIdentifierProvider;
|
|
408
|
+
};
|
|
350
409
|
var indentHandlers = {
|
|
351
410
|
'Shift-Tab': (0, _utils.filterCommand)([_helpers.isInsideTaskOrDecisionItem, function (state) {
|
|
352
411
|
return !shouldLetTabThroughInTable(state);
|
|
@@ -369,7 +428,7 @@ function keymapPlugin(schema, api, allowNestedTasks, consumeTabs) {
|
|
|
369
428
|
Backspace: backspace(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
|
|
370
429
|
Delete: deleteForwards,
|
|
371
430
|
'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)
|
|
431
|
+
Enter: enter(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, getContextIdentifier)
|
|
373
432
|
}, _keymaps.toggleTaskItemCheckbox.common, cmdOptEnter), allowNestedTasks ? indentHandlers : defaultHandlers);
|
|
374
433
|
return (0, _keymap.keymap)(keymaps);
|
|
375
434
|
}
|
|
@@ -28,17 +28,6 @@ function nodesBetweenChanged(tr, f, startPos) {
|
|
|
28
28
|
}
|
|
29
29
|
tr.doc.nodesBetween(stepRange.from, stepRange.to, f, startPos);
|
|
30
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
31
|
function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api) {
|
|
43
32
|
var useLongPressSelection = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
44
33
|
return new _safePlugin.SafePlugin({
|
|
@@ -187,11 +176,6 @@ function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispa
|
|
|
187
176
|
data = _ref.data;
|
|
188
177
|
var newPluginState = pluginState;
|
|
189
178
|
switch (action) {
|
|
190
|
-
case _types.ACTIONS.SET_CONTEXT_PROVIDER:
|
|
191
|
-
newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
192
|
-
contextIdentifierProvider: data
|
|
193
|
-
});
|
|
194
|
-
break;
|
|
195
179
|
case _types.ACTIONS.FOCUS_BY_LOCALID:
|
|
196
180
|
newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
197
181
|
focusedTaskItemLocalId: data
|
|
@@ -202,21 +186,6 @@ function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispa
|
|
|
202
186
|
return newPluginState;
|
|
203
187
|
}
|
|
204
188
|
},
|
|
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
189
|
key: _pluginKey.stateKey,
|
|
221
190
|
/*
|
|
222
191
|
* After each transaction, we search through the document for any decisionList/Item & taskList/Item nodes
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.ACTIONS = void 0;
|
|
7
7
|
var ACTIONS = exports.ACTIONS = /*#__PURE__*/function (ACTIONS) {
|
|
8
|
-
ACTIONS[ACTIONS["
|
|
9
|
-
ACTIONS[ACTIONS["FOCUS_BY_LOCALID"] = 1] = "FOCUS_BY_LOCALID";
|
|
8
|
+
ACTIONS[ACTIONS["FOCUS_BY_LOCALID"] = 0] = "FOCUS_BY_LOCALID";
|
|
10
9
|
return ACTIONS;
|
|
11
10
|
}({});
|
|
@@ -23,7 +23,11 @@ var ToolbarDecision = function ToolbarDecision(_ref) {
|
|
|
23
23
|
if (!editorView) {
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
var getContextIdentifier = function getContextIdentifier() {
|
|
27
|
+
var _editorAPI$contextIde;
|
|
28
|
+
return editorAPI === null || editorAPI === void 0 || (_editorAPI$contextIde = editorAPI.contextIdentifier) === null || _editorAPI$contextIde === void 0 || (_editorAPI$contextIde = _editorAPI$contextIde.sharedState.currentState()) === null || _editorAPI$contextIde === void 0 ? void 0 : _editorAPI$contextIde.contextIdentifierProvider;
|
|
29
|
+
};
|
|
30
|
+
(0, _commands.insertTaskDecisionCommand)(editorAPI === null || editorAPI === void 0 || (_editorAPI$analytics = editorAPI.analytics) === null || _editorAPI$analytics === void 0 ? void 0 : _editorAPI$analytics.actions, getContextIdentifier)('decisionList')(editorView.state, editorView.dispatch);
|
|
27
31
|
return true;
|
|
28
32
|
};
|
|
29
33
|
return /*#__PURE__*/_react.default.createElement(_uiMenu.ToolbarButton, {
|
|
@@ -23,7 +23,11 @@ var ToolbarTask = function ToolbarTask(_ref) {
|
|
|
23
23
|
if (!editorView) {
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
var getContextIdentifier = function getContextIdentifier() {
|
|
27
|
+
var _editorAPI$contextIde;
|
|
28
|
+
return editorAPI === null || editorAPI === void 0 || (_editorAPI$contextIde = editorAPI.contextIdentifier) === null || _editorAPI$contextIde === void 0 || (_editorAPI$contextIde = _editorAPI$contextIde.sharedState.currentState()) === null || _editorAPI$contextIde === void 0 ? void 0 : _editorAPI$contextIde.contextIdentifierProvider;
|
|
29
|
+
};
|
|
30
|
+
(0, _commands.insertTaskDecisionCommand)(editorAPI === null || editorAPI === void 0 || (_editorAPI$analytics = editorAPI.analytics) === null || _editorAPI$analytics === void 0 ? void 0 : _editorAPI$analytics.actions, getContextIdentifier)('taskList')(editorView.state, editorView.dispatch);
|
|
27
31
|
return true;
|
|
28
32
|
};
|
|
29
33
|
return /*#__PURE__*/_react.default.createElement(_uiMenu.ToolbarButton, {
|
package/dist/es2019/commands.js
CHANGED
|
@@ -6,7 +6,6 @@ import { NodeRange } from '@atlaskit/editor-prosemirror/model';
|
|
|
6
6
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
|
|
8
8
|
import { findParentNodeOfType, hasParentNodeOfType, replaceParentNodeOfType, safeInsert, setTextSelection } from '@atlaskit/editor-prosemirror/utils';
|
|
9
|
-
import { stateKey as taskDecisionStateKey } from './pm-plugins/plugin-key';
|
|
10
9
|
const getContextData = (contextProvider = {}) => {
|
|
11
10
|
const {
|
|
12
11
|
objectId,
|
|
@@ -65,7 +64,7 @@ export const getListTypes = (listType, schema) => {
|
|
|
65
64
|
item: decisionItem
|
|
66
65
|
};
|
|
67
66
|
};
|
|
68
|
-
export const insertTaskDecisionAction = editorAnalyticsAPI => (state, listType, inputMethod = INPUT_METHOD.TOOLBAR, addItem, listLocalId, itemLocalId, itemAttrs) => {
|
|
67
|
+
export const insertTaskDecisionAction = (editorAnalyticsAPI, getContextIdentifierProvider) => (state, listType, inputMethod = INPUT_METHOD.TOOLBAR, addItem, listLocalId, itemLocalId, itemAttrs) => {
|
|
69
68
|
const {
|
|
70
69
|
schema
|
|
71
70
|
} = state;
|
|
@@ -95,21 +94,21 @@ export const insertTaskDecisionAction = editorAnalyticsAPI => (state, listType,
|
|
|
95
94
|
}]).setSelection(new TextSelection(tr.doc.resolve(newItemParagraphPos)));
|
|
96
95
|
};
|
|
97
96
|
const addAndCreateListFn = addItem !== null && addItem !== void 0 ? addItem : addAndCreateList;
|
|
98
|
-
const tr = insertTaskDecisionWithAnalytics(editorAnalyticsAPI)(state, listType, inputMethod, addAndCreateListFn, addToList, listLocalId, itemLocalId, itemAttrs);
|
|
97
|
+
const tr = insertTaskDecisionWithAnalytics(editorAnalyticsAPI, getContextIdentifierProvider)(state, listType, inputMethod, addAndCreateListFn, addToList, listLocalId, itemLocalId, itemAttrs);
|
|
99
98
|
if (!tr) {
|
|
100
99
|
return state.tr;
|
|
101
100
|
}
|
|
102
101
|
autoJoinTr(tr, ['taskList', 'decisionList']);
|
|
103
102
|
return tr;
|
|
104
103
|
};
|
|
105
|
-
export const insertTaskDecisionCommand = editorAnalyticsAPI => (listType, inputMethod = INPUT_METHOD.TOOLBAR, addItem, listLocalId, itemLocalId) => (state, dispatch) => {
|
|
106
|
-
const tr = insertTaskDecisionAction(editorAnalyticsAPI)(state, listType, inputMethod, addItem, listLocalId, itemLocalId);
|
|
104
|
+
export const insertTaskDecisionCommand = (editorAnalyticsAPI, getContextIdentifierProvider) => (listType, inputMethod = INPUT_METHOD.TOOLBAR, addItem, listLocalId, itemLocalId) => (state, dispatch) => {
|
|
105
|
+
const tr = insertTaskDecisionAction(editorAnalyticsAPI, getContextIdentifierProvider)(state, listType, inputMethod, addItem, listLocalId, itemLocalId);
|
|
107
106
|
if (dispatch) {
|
|
108
107
|
dispatch(tr);
|
|
109
108
|
}
|
|
110
109
|
return true;
|
|
111
110
|
};
|
|
112
|
-
export const insertTaskDecisionWithAnalytics = editorAnalyticsAPI => (state, listType, inputMethod, addAndCreateList, addToList, listLocalId, itemLocalId, itemAttrs) => {
|
|
111
|
+
export const insertTaskDecisionWithAnalytics = (editorAnalyticsAPI, getContextIdentifierProvider) => (state, listType, inputMethod, addAndCreateList, addToList, listLocalId, itemLocalId, itemAttrs) => {
|
|
113
112
|
const {
|
|
114
113
|
schema
|
|
115
114
|
} = state;
|
|
@@ -124,7 +123,7 @@ export const insertTaskDecisionWithAnalytics = editorAnalyticsAPI => (state, lis
|
|
|
124
123
|
$to
|
|
125
124
|
} = state.selection;
|
|
126
125
|
const listNode = findParentNodeOfType(list)(state.selection);
|
|
127
|
-
const contextIdentifierProvider =
|
|
126
|
+
const contextIdentifierProvider = getContextIdentifierProvider();
|
|
128
127
|
const contextData = getContextData(contextIdentifierProvider);
|
|
129
128
|
let insertTrCreator;
|
|
130
129
|
let itemIdx;
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -39,6 +39,10 @@ export const tasksAndDecisionsPlugin = ({
|
|
|
39
39
|
api
|
|
40
40
|
}) => {
|
|
41
41
|
var _api$analytics, _api$analytics2, _api$analytics3;
|
|
42
|
+
const getIdentifierProvider = () => {
|
|
43
|
+
var _api$contextIdentifie, _api$contextIdentifie2;
|
|
44
|
+
return api === null || api === void 0 ? void 0 : (_api$contextIdentifie = api.contextIdentifier) === null || _api$contextIdentifie === void 0 ? void 0 : (_api$contextIdentifie2 = _api$contextIdentifie.sharedState.currentState()) === null || _api$contextIdentifie2 === void 0 ? void 0 : _api$contextIdentifie2.contextIdentifierProvider;
|
|
45
|
+
};
|
|
42
46
|
return {
|
|
43
47
|
name: 'taskDecision',
|
|
44
48
|
nodes() {
|
|
@@ -71,7 +75,7 @@ export const tasksAndDecisionsPlugin = ({
|
|
|
71
75
|
};
|
|
72
76
|
},
|
|
73
77
|
actions: {
|
|
74
|
-
insertTaskDecision: insertTaskDecisionCommand(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
|
|
78
|
+
insertTaskDecision: insertTaskDecisionCommand(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, getIdentifierProvider),
|
|
75
79
|
indentTaskList: getIndentCommand(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
|
|
76
80
|
outdentTaskList: getUnindentCommand(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)
|
|
77
81
|
},
|
|
@@ -93,7 +97,7 @@ export const tasksAndDecisionsPlugin = ({
|
|
|
93
97
|
featureFlags
|
|
94
98
|
}) => {
|
|
95
99
|
var _api$analytics4;
|
|
96
|
-
return inputRulePlugin(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)(schema, featureFlags);
|
|
100
|
+
return inputRulePlugin(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, getIdentifierProvider)(schema, featureFlags);
|
|
97
101
|
}
|
|
98
102
|
}, {
|
|
99
103
|
name: 'tasksAndDecisionsKeyMap',
|
|
@@ -135,7 +139,7 @@ export const tasksAndDecisionsPlugin = ({
|
|
|
135
139
|
icon: () => jsx(IconAction, null),
|
|
136
140
|
action(insert, state) {
|
|
137
141
|
var _api$analytics5;
|
|
138
|
-
return insertTaskDecisionAction(api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions)(state, 'taskList', INPUT_METHOD.QUICK_INSERT, addItem(insert, 'taskList', state.schema));
|
|
142
|
+
return insertTaskDecisionAction(api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, getIdentifierProvider)(state, 'taskList', INPUT_METHOD.QUICK_INSERT, addItem(insert, 'taskList', state.schema));
|
|
139
143
|
}
|
|
140
144
|
}, {
|
|
141
145
|
id: 'decision',
|
|
@@ -146,7 +150,7 @@ export const tasksAndDecisionsPlugin = ({
|
|
|
146
150
|
icon: () => jsx(IconDecision, null),
|
|
147
151
|
action(insert, state) {
|
|
148
152
|
var _api$analytics6;
|
|
149
|
-
return insertTaskDecisionAction(api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions)(state, 'decisionList', INPUT_METHOD.QUICK_INSERT, addItem(insert, 'decisionList', state.schema));
|
|
153
|
+
return insertTaskDecisionAction(api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions, getIdentifierProvider)(state, 'decisionList', INPUT_METHOD.QUICK_INSERT, addItem(insert, 'decisionList', state.schema));
|
|
150
154
|
}
|
|
151
155
|
}]
|
|
152
156
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { findFarthestParentNode } from '@atlaskit/editor-common/utils';
|
|
1
|
+
import { findFarthestParentNode, isListNode } from '@atlaskit/editor-common/utils';
|
|
2
2
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
|
|
4
4
|
import { findParentNodeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -313,4 +313,25 @@ export function removeCheckboxFocus(view) {
|
|
|
313
313
|
dispatch(tr.setMeta(stateKey, {
|
|
314
314
|
action: ACTIONS.FOCUS_BY_LOCALID
|
|
315
315
|
}));
|
|
316
|
+
}
|
|
317
|
+
export function findFirstParentListNode($pos) {
|
|
318
|
+
const currentNode = $pos.doc.nodeAt($pos.pos);
|
|
319
|
+
let listNodePosition = null;
|
|
320
|
+
if (isListNode(currentNode)) {
|
|
321
|
+
listNodePosition = $pos.pos;
|
|
322
|
+
} else {
|
|
323
|
+
const result = findParentNodeClosestToPos($pos, isListNode);
|
|
324
|
+
listNodePosition = result && result.pos;
|
|
325
|
+
}
|
|
326
|
+
if (listNodePosition == null) {
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
const node = $pos.doc.nodeAt(listNodePosition);
|
|
330
|
+
if (!node) {
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
node,
|
|
335
|
+
pos: listNodePosition
|
|
336
|
+
};
|
|
316
337
|
}
|
|
@@ -3,7 +3,7 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
|
|
|
3
3
|
import { canInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import { createPlugin, createRule, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
5
5
|
import { changeInDepth, getListTypes, insertTaskDecisionAction } from '../commands';
|
|
6
|
-
const createListRule = editorAnalyticsAPI => (regex, listType, itemAttrs) => {
|
|
6
|
+
const createListRule = (editorAnalyticsAPI, getContextIdentifierProvider) => (regex, listType, itemAttrs) => {
|
|
7
7
|
return createRule(regex, (state, _match, start, end) => {
|
|
8
8
|
const {
|
|
9
9
|
paragraph
|
|
@@ -18,7 +18,7 @@ const createListRule = editorAnalyticsAPI => (regex, listType, itemAttrs) => {
|
|
|
18
18
|
if ($end.parent.type !== paragraph || !canInsert($endOfParent, list.createAndFill())) {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
|
-
const insertTr = insertTaskDecisionAction(editorAnalyticsAPI)(state, listType, INPUT_METHOD.FORMATTING, addItem(start, end), undefined, undefined, itemAttrs);
|
|
21
|
+
const insertTr = insertTaskDecisionAction(editorAnalyticsAPI, getContextIdentifierProvider)(state, listType, INPUT_METHOD.FORMATTING, addItem(start, end), undefined, undefined, itemAttrs);
|
|
22
22
|
return insertTr;
|
|
23
23
|
});
|
|
24
24
|
};
|
|
@@ -85,7 +85,7 @@ const addItem = (start, end) => ({
|
|
|
85
85
|
tr.doc.nodeAt($from.pos + 1).content)])).setSelection(new TextSelection(tr.doc.resolve($from.pos + depthAdjustment))).delete(start, end + 1);
|
|
86
86
|
return tr;
|
|
87
87
|
};
|
|
88
|
-
export const inputRulePlugin = editorAnalyticsAPI => (schema, featureFlags) => {
|
|
88
|
+
export const inputRulePlugin = (editorAnalyticsAPI, getContextIdentifierProvider) => (schema, featureFlags) => {
|
|
89
89
|
const rules = [];
|
|
90
90
|
const {
|
|
91
91
|
decisionList,
|
|
@@ -94,11 +94,11 @@ export const inputRulePlugin = editorAnalyticsAPI => (schema, featureFlags) => {
|
|
|
94
94
|
taskItem
|
|
95
95
|
} = schema.nodes;
|
|
96
96
|
if (decisionList && decisionItem) {
|
|
97
|
-
rules.push(createListRule(editorAnalyticsAPI)(new RegExp(`(^|${leafNodeReplacementCharacter})\\<\\>\\s$`), 'decisionList'));
|
|
97
|
+
rules.push(createListRule(editorAnalyticsAPI, getContextIdentifierProvider)(new RegExp(`(^|${leafNodeReplacementCharacter})\\<\\>\\s$`), 'decisionList'));
|
|
98
98
|
}
|
|
99
99
|
if (taskList && taskItem) {
|
|
100
|
-
rules.push(createListRule(editorAnalyticsAPI)(new RegExp(`(^|${leafNodeReplacementCharacter})\\[\\]\\s$`), 'taskList'));
|
|
101
|
-
rules.push(createListRule(editorAnalyticsAPI)(new RegExp(`(^|${leafNodeReplacementCharacter})\\[x\\]\\s$`), 'taskList', {
|
|
100
|
+
rules.push(createListRule(editorAnalyticsAPI, getContextIdentifierProvider)(new RegExp(`(^|${leafNodeReplacementCharacter})\\[\\]\\s$`), 'taskList'));
|
|
101
|
+
rules.push(createListRule(editorAnalyticsAPI, getContextIdentifierProvider)(new RegExp(`(^|${leafNodeReplacementCharacter})\\[x\\]\\s$`), 'taskList', {
|
|
102
102
|
state: 'DONE'
|
|
103
103
|
}));
|
|
104
104
|
}
|