@atlaskit/editor-plugin-tasks-and-decisions 0.3.0 → 0.3.2
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 +13 -0
- package/dist/cjs/commands.js +6 -7
- package/dist/cjs/plugin.js +8 -4
- package/dist/cjs/pm-plugins/input-rules.js +6 -6
- package/dist/cjs/pm-plugins/keymaps.js +7 -3
- 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/input-rules.js +6 -6
- package/dist/es2019/pm-plugins/keymaps.js +7 -3
- 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/input-rules.js +6 -6
- package/dist/esm/pm-plugins/keymaps.js +7 -3
- 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/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/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 +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-tasks-and-decisions
|
|
2
2
|
|
|
3
|
+
## 0.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#70152](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70152) [`53ed3673df28`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/53ed3673df28) - Updating adf-schema version to 35.5.1
|
|
8
|
+
|
|
9
|
+
## 0.3.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#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.
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 0.3.0
|
|
4
17
|
|
|
5
18
|
### Minor 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
|
}
|
|
@@ -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
|
}
|
|
@@ -342,7 +342,7 @@ var splitListItem = function splitListItem(state, dispatch) {
|
|
|
342
342
|
}
|
|
343
343
|
return false;
|
|
344
344
|
};
|
|
345
|
-
var enter = function enter(editorAnalyticsAPI) {
|
|
345
|
+
var enter = function enter(editorAnalyticsAPI, getContextIdentifier) {
|
|
346
346
|
return (0, _utils.filterCommand)(_helpers.isInsideTaskOrDecisionItem, (0, _commands.chainCommands)((0, _utils.filterCommand)(_helpers.isEmptyTaskDecision, (0, _commands.chainCommands)(getUnindentCommand(editorAnalyticsAPI)(), splitListItem)), function (state, dispatch) {
|
|
347
347
|
var selection = state.selection,
|
|
348
348
|
schema = state.schema;
|
|
@@ -372,7 +372,7 @@ var enter = function enter(editorAnalyticsAPI) {
|
|
|
372
372
|
}
|
|
373
373
|
}]);
|
|
374
374
|
};
|
|
375
|
-
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);
|
|
376
376
|
if (insertTr && dispatch) {
|
|
377
377
|
insertTr.scrollIntoView();
|
|
378
378
|
dispatch(insertTr);
|
|
@@ -402,6 +402,10 @@ var cmdOptEnter = (0, _utils.filterCommand)(_helpers.isInsideTaskOrDecisionItem,
|
|
|
402
402
|
});
|
|
403
403
|
function keymapPlugin(schema, api, allowNestedTasks, consumeTabs) {
|
|
404
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
|
+
};
|
|
405
409
|
var indentHandlers = {
|
|
406
410
|
'Shift-Tab': (0, _utils.filterCommand)([_helpers.isInsideTaskOrDecisionItem, function (state) {
|
|
407
411
|
return !shouldLetTabThroughInTable(state);
|
|
@@ -424,7 +428,7 @@ function keymapPlugin(schema, api, allowNestedTasks, consumeTabs) {
|
|
|
424
428
|
Backspace: backspace(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
|
|
425
429
|
Delete: deleteForwards,
|
|
426
430
|
'Ctrl-d': deleteForwards,
|
|
427
|
-
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)
|
|
428
432
|
}, _keymaps.toggleTaskItemCheckbox.common, cmdOptEnter), allowNestedTasks ? indentHandlers : defaultHandlers);
|
|
429
433
|
return (0, _keymap.keymap)(keymaps);
|
|
430
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
|
}
|
|
@@ -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
|
}
|
|
@@ -329,7 +329,7 @@ const splitListItem = (state, dispatch) => {
|
|
|
329
329
|
}
|
|
330
330
|
return false;
|
|
331
331
|
};
|
|
332
|
-
const enter = editorAnalyticsAPI => filter(isInsideTaskOrDecisionItem, chainCommands(filter(isEmptyTaskDecision, chainCommands(getUnindentCommand(editorAnalyticsAPI)(), splitListItem)), (state, dispatch) => {
|
|
332
|
+
const enter = (editorAnalyticsAPI, getContextIdentifier) => filter(isInsideTaskOrDecisionItem, chainCommands(filter(isEmptyTaskDecision, chainCommands(getUnindentCommand(editorAnalyticsAPI)(), splitListItem)), (state, dispatch) => {
|
|
333
333
|
const {
|
|
334
334
|
selection,
|
|
335
335
|
schema
|
|
@@ -365,7 +365,7 @@ const enter = editorAnalyticsAPI => filter(isInsideTaskOrDecisionItem, chainComm
|
|
|
365
365
|
}
|
|
366
366
|
}]);
|
|
367
367
|
};
|
|
368
|
-
const insertTr = insertTaskDecisionWithAnalytics(editorAnalyticsAPI)(state, listType, INPUT_METHOD.KEYBOARD, addItem);
|
|
368
|
+
const insertTr = insertTaskDecisionWithAnalytics(editorAnalyticsAPI, getContextIdentifier)(state, listType, INPUT_METHOD.KEYBOARD, addItem);
|
|
369
369
|
if (insertTr && dispatch) {
|
|
370
370
|
insertTr.scrollIntoView();
|
|
371
371
|
dispatch(insertTr);
|
|
@@ -400,6 +400,10 @@ const cmdOptEnter = filter(isInsideTaskOrDecisionItem, (state, dispatch) => {
|
|
|
400
400
|
});
|
|
401
401
|
export function keymapPlugin(schema, api, allowNestedTasks, consumeTabs) {
|
|
402
402
|
var _api$analytics3, _api$analytics4;
|
|
403
|
+
const getContextIdentifier = () => {
|
|
404
|
+
var _api$contextIdentifie, _api$contextIdentifie2;
|
|
405
|
+
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;
|
|
406
|
+
};
|
|
403
407
|
const indentHandlers = {
|
|
404
408
|
'Shift-Tab': filter([isInsideTaskOrDecisionItem, state => !shouldLetTabThroughInTable(state)], (state, dispatch) => {
|
|
405
409
|
var _api$analytics;
|
|
@@ -418,7 +422,7 @@ export function keymapPlugin(schema, api, allowNestedTasks, consumeTabs) {
|
|
|
418
422
|
Backspace: backspace(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
|
|
419
423
|
Delete: deleteForwards,
|
|
420
424
|
'Ctrl-d': deleteForwards,
|
|
421
|
-
Enter: enter(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions),
|
|
425
|
+
Enter: enter(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, getContextIdentifier),
|
|
422
426
|
[toggleTaskItemCheckbox.common]: cmdOptEnter,
|
|
423
427
|
...(allowNestedTasks ? indentHandlers : defaultHandlers)
|
|
424
428
|
};
|
|
@@ -16,15 +16,6 @@ function nodesBetweenChanged(tr, f, startPos) {
|
|
|
16
16
|
}
|
|
17
17
|
tr.doc.nodesBetween(stepRange.from, stepRange.to, f, startPos);
|
|
18
18
|
}
|
|
19
|
-
const setContextIdentifierProvider = provider => (state, dispatch) => {
|
|
20
|
-
if (dispatch) {
|
|
21
|
-
dispatch(state.tr.setMeta(stateKey, {
|
|
22
|
-
action: ACTIONS.SET_CONTEXT_PROVIDER,
|
|
23
|
-
data: provider
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
return true;
|
|
27
|
-
};
|
|
28
19
|
export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection = false) {
|
|
29
20
|
return new SafePlugin({
|
|
30
21
|
props: {
|
|
@@ -181,12 +172,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
|
|
|
181
172
|
};
|
|
182
173
|
let newPluginState = pluginState;
|
|
183
174
|
switch (action) {
|
|
184
|
-
case ACTIONS.SET_CONTEXT_PROVIDER:
|
|
185
|
-
newPluginState = {
|
|
186
|
-
...pluginState,
|
|
187
|
-
contextIdentifierProvider: data
|
|
188
|
-
};
|
|
189
|
-
break;
|
|
190
175
|
case ACTIONS.FOCUS_BY_LOCALID:
|
|
191
176
|
newPluginState = {
|
|
192
177
|
...pluginState,
|
|
@@ -198,21 +183,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
|
|
|
198
183
|
return newPluginState;
|
|
199
184
|
}
|
|
200
185
|
},
|
|
201
|
-
view(editorView) {
|
|
202
|
-
const providerHandler = (name, providerPromise) => {
|
|
203
|
-
if (name === 'contextIdentifierProvider') {
|
|
204
|
-
if (!providerPromise) {
|
|
205
|
-
setContextIdentifierProvider(undefined)(editorView.state, editorView.dispatch);
|
|
206
|
-
} else {
|
|
207
|
-
providerPromise.then(provider => {
|
|
208
|
-
setContextIdentifierProvider(provider)(editorView.state, editorView.dispatch);
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
providerFactory.subscribe('contextIdentifierProvider', providerHandler);
|
|
214
|
-
return {};
|
|
215
|
-
},
|
|
216
186
|
key: stateKey,
|
|
217
187
|
/*
|
|
218
188
|
* After each transaction, we search through the document for any decisionList/Item & taskList/Item nodes
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export let ACTIONS = /*#__PURE__*/function (ACTIONS) {
|
|
2
|
-
ACTIONS[ACTIONS["
|
|
3
|
-
ACTIONS[ACTIONS["FOCUS_BY_LOCALID"] = 1] = "FOCUS_BY_LOCALID";
|
|
2
|
+
ACTIONS[ACTIONS["FOCUS_BY_LOCALID"] = 0] = "FOCUS_BY_LOCALID";
|
|
4
3
|
return ACTIONS;
|
|
5
4
|
}({});
|
|
@@ -19,7 +19,11 @@ const ToolbarDecision = ({
|
|
|
19
19
|
if (!editorView) {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
const getContextIdentifier = () => {
|
|
23
|
+
var _editorAPI$contextIde, _editorAPI$contextIde2;
|
|
24
|
+
return editorAPI === null || editorAPI === void 0 ? void 0 : (_editorAPI$contextIde = editorAPI.contextIdentifier) === null || _editorAPI$contextIde === void 0 ? void 0 : (_editorAPI$contextIde2 = _editorAPI$contextIde.sharedState.currentState()) === null || _editorAPI$contextIde2 === void 0 ? void 0 : _editorAPI$contextIde2.contextIdentifierProvider;
|
|
25
|
+
};
|
|
26
|
+
insertTaskDecisionCommand(editorAPI === null || editorAPI === void 0 ? void 0 : (_editorAPI$analytics = editorAPI.analytics) === null || _editorAPI$analytics === void 0 ? void 0 : _editorAPI$analytics.actions, getContextIdentifier)('decisionList')(editorView.state, editorView.dispatch);
|
|
23
27
|
return true;
|
|
24
28
|
};
|
|
25
29
|
return /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
@@ -19,7 +19,11 @@ const ToolbarTask = ({
|
|
|
19
19
|
if (!editorView) {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
const getContextIdentifier = () => {
|
|
23
|
+
var _editorAPI$contextIde, _editorAPI$contextIde2;
|
|
24
|
+
return editorAPI === null || editorAPI === void 0 ? void 0 : (_editorAPI$contextIde = editorAPI.contextIdentifier) === null || _editorAPI$contextIde === void 0 ? void 0 : (_editorAPI$contextIde2 = _editorAPI$contextIde.sharedState.currentState()) === null || _editorAPI$contextIde2 === void 0 ? void 0 : _editorAPI$contextIde2.contextIdentifierProvider;
|
|
25
|
+
};
|
|
26
|
+
insertTaskDecisionCommand(editorAPI === null || editorAPI === void 0 ? void 0 : (_editorAPI$analytics = editorAPI.analytics) === null || _editorAPI$analytics === void 0 ? void 0 : _editorAPI$analytics.actions, getContextIdentifier)('taskList')(editorView.state, editorView.dispatch);
|
|
23
27
|
return true;
|
|
24
28
|
};
|
|
25
29
|
return /*#__PURE__*/React.createElement(ToolbarButton, {
|
package/dist/esm/commands.js
CHANGED
|
@@ -9,7 +9,6 @@ import { NodeRange } from '@atlaskit/editor-prosemirror/model';
|
|
|
9
9
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
10
|
import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
|
|
11
11
|
import { findParentNodeOfType, hasParentNodeOfType, replaceParentNodeOfType, safeInsert, setTextSelection } from '@atlaskit/editor-prosemirror/utils';
|
|
12
|
-
import { stateKey as taskDecisionStateKey } from './pm-plugins/plugin-key';
|
|
13
12
|
var getContextData = function getContextData() {
|
|
14
13
|
var contextProvider = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
15
14
|
var objectId = contextProvider.objectId,
|
|
@@ -64,7 +63,7 @@ export var getListTypes = function getListTypes(listType, schema) {
|
|
|
64
63
|
item: decisionItem
|
|
65
64
|
};
|
|
66
65
|
};
|
|
67
|
-
export var insertTaskDecisionAction = function insertTaskDecisionAction(editorAnalyticsAPI) {
|
|
66
|
+
export var insertTaskDecisionAction = function insertTaskDecisionAction(editorAnalyticsAPI, getContextIdentifierProvider) {
|
|
68
67
|
return function (state, listType) {
|
|
69
68
|
var inputMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : INPUT_METHOD.TOOLBAR;
|
|
70
69
|
var addItem = arguments.length > 3 ? arguments[3] : undefined;
|
|
@@ -96,7 +95,7 @@ export var insertTaskDecisionAction = function insertTaskDecisionAction(editorAn
|
|
|
96
95
|
}]).setSelection(new TextSelection(tr.doc.resolve(newItemParagraphPos)));
|
|
97
96
|
};
|
|
98
97
|
var addAndCreateListFn = addItem !== null && addItem !== void 0 ? addItem : addAndCreateList;
|
|
99
|
-
var tr = insertTaskDecisionWithAnalytics(editorAnalyticsAPI)(state, listType, inputMethod, addAndCreateListFn, addToList, listLocalId, itemLocalId, itemAttrs);
|
|
98
|
+
var tr = insertTaskDecisionWithAnalytics(editorAnalyticsAPI, getContextIdentifierProvider)(state, listType, inputMethod, addAndCreateListFn, addToList, listLocalId, itemLocalId, itemAttrs);
|
|
100
99
|
if (!tr) {
|
|
101
100
|
return state.tr;
|
|
102
101
|
}
|
|
@@ -104,14 +103,14 @@ export var insertTaskDecisionAction = function insertTaskDecisionAction(editorAn
|
|
|
104
103
|
return tr;
|
|
105
104
|
};
|
|
106
105
|
};
|
|
107
|
-
export var insertTaskDecisionCommand = function insertTaskDecisionCommand(editorAnalyticsAPI) {
|
|
106
|
+
export var insertTaskDecisionCommand = function insertTaskDecisionCommand(editorAnalyticsAPI, getContextIdentifierProvider) {
|
|
108
107
|
return function (listType) {
|
|
109
108
|
var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INPUT_METHOD.TOOLBAR;
|
|
110
109
|
var addItem = arguments.length > 2 ? arguments[2] : undefined;
|
|
111
110
|
var listLocalId = arguments.length > 3 ? arguments[3] : undefined;
|
|
112
111
|
var itemLocalId = arguments.length > 4 ? arguments[4] : undefined;
|
|
113
112
|
return function (state, dispatch) {
|
|
114
|
-
var tr = insertTaskDecisionAction(editorAnalyticsAPI)(state, listType, inputMethod, addItem, listLocalId, itemLocalId);
|
|
113
|
+
var tr = insertTaskDecisionAction(editorAnalyticsAPI, getContextIdentifierProvider)(state, listType, inputMethod, addItem, listLocalId, itemLocalId);
|
|
115
114
|
if (dispatch) {
|
|
116
115
|
dispatch(tr);
|
|
117
116
|
}
|
|
@@ -119,7 +118,7 @@ export var insertTaskDecisionCommand = function insertTaskDecisionCommand(editor
|
|
|
119
118
|
};
|
|
120
119
|
};
|
|
121
120
|
};
|
|
122
|
-
export var insertTaskDecisionWithAnalytics = function insertTaskDecisionWithAnalytics(editorAnalyticsAPI) {
|
|
121
|
+
export var insertTaskDecisionWithAnalytics = function insertTaskDecisionWithAnalytics(editorAnalyticsAPI, getContextIdentifierProvider) {
|
|
123
122
|
return function (state, listType, inputMethod, addAndCreateList, addToList, listLocalId, itemLocalId, itemAttrs) {
|
|
124
123
|
var schema = state.schema;
|
|
125
124
|
var _getListTypes = getListTypes(listType, schema),
|
|
@@ -128,7 +127,7 @@ export var insertTaskDecisionWithAnalytics = function insertTaskDecisionWithAnal
|
|
|
128
127
|
var tr = state.tr;
|
|
129
128
|
var $to = state.selection.$to;
|
|
130
129
|
var listNode = findParentNodeOfType(list)(state.selection);
|
|
131
|
-
var contextIdentifierProvider =
|
|
130
|
+
var contextIdentifierProvider = getContextIdentifierProvider();
|
|
132
131
|
var contextData = getContextData(contextIdentifierProvider);
|
|
133
132
|
var insertTrCreator;
|
|
134
133
|
var itemIdx;
|
package/dist/esm/plugin.js
CHANGED
|
@@ -38,6 +38,10 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
|
|
|
38
38
|
consumeTabs = _ref2$config2.consumeTabs,
|
|
39
39
|
useLongPressSelection = _ref2$config2.useLongPressSelection,
|
|
40
40
|
api = _ref2.api;
|
|
41
|
+
var getIdentifierProvider = function getIdentifierProvider() {
|
|
42
|
+
var _api$contextIdentifie;
|
|
43
|
+
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;
|
|
44
|
+
};
|
|
41
45
|
return {
|
|
42
46
|
name: 'taskDecision',
|
|
43
47
|
nodes: function nodes() {
|
|
@@ -70,7 +74,7 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
|
|
|
70
74
|
};
|
|
71
75
|
},
|
|
72
76
|
actions: {
|
|
73
|
-
insertTaskDecision: insertTaskDecisionCommand(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
|
|
77
|
+
insertTaskDecision: insertTaskDecisionCommand(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, getIdentifierProvider),
|
|
74
78
|
indentTaskList: getIndentCommand(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
|
|
75
79
|
outdentTaskList: getUnindentCommand(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)
|
|
76
80
|
},
|
|
@@ -90,7 +94,7 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
|
|
|
90
94
|
var _api$analytics4;
|
|
91
95
|
var schema = _ref4.schema,
|
|
92
96
|
featureFlags = _ref4.featureFlags;
|
|
93
|
-
return inputRulePlugin(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)(schema, featureFlags);
|
|
97
|
+
return inputRulePlugin(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, getIdentifierProvider)(schema, featureFlags);
|
|
94
98
|
}
|
|
95
99
|
}, {
|
|
96
100
|
name: 'tasksAndDecisionsKeyMap',
|
|
@@ -133,7 +137,7 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
|
|
|
133
137
|
},
|
|
134
138
|
action: function action(insert, state) {
|
|
135
139
|
var _api$analytics5;
|
|
136
|
-
return insertTaskDecisionAction(api === null || api === 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));
|
|
140
|
+
return insertTaskDecisionAction(api === null || api === 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));
|
|
137
141
|
}
|
|
138
142
|
}, {
|
|
139
143
|
id: 'decision',
|
|
@@ -146,7 +150,7 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
|
|
|
146
150
|
},
|
|
147
151
|
action: function action(insert, state) {
|
|
148
152
|
var _api$analytics6;
|
|
149
|
-
return insertTaskDecisionAction(api === null || api === 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 || (_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
|
}
|
|
@@ -6,7 +6,7 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
|
|
|
6
6
|
import { canInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
7
|
import { createPlugin, createRule, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
8
8
|
import { changeInDepth, getListTypes, insertTaskDecisionAction } from '../commands';
|
|
9
|
-
var createListRule = function createListRule(editorAnalyticsAPI) {
|
|
9
|
+
var createListRule = function createListRule(editorAnalyticsAPI, getContextIdentifierProvider) {
|
|
10
10
|
return function (regex, listType, itemAttrs) {
|
|
11
11
|
return createRule(regex, function (state, _match, start, end) {
|
|
12
12
|
var paragraph = state.schema.nodes.paragraph;
|
|
@@ -19,7 +19,7 @@ var createListRule = function createListRule(editorAnalyticsAPI) {
|
|
|
19
19
|
if ($end.parent.type !== paragraph || !canInsert($endOfParent, list.createAndFill())) {
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
|
-
var insertTr = insertTaskDecisionAction(editorAnalyticsAPI)(state, listType, INPUT_METHOD.FORMATTING, addItem(start, end), undefined, undefined, itemAttrs);
|
|
22
|
+
var insertTr = insertTaskDecisionAction(editorAnalyticsAPI, getContextIdentifierProvider)(state, listType, INPUT_METHOD.FORMATTING, addItem(start, end), undefined, undefined, itemAttrs);
|
|
23
23
|
return insertTr;
|
|
24
24
|
});
|
|
25
25
|
};
|
|
@@ -79,7 +79,7 @@ var addItem = function addItem(start, end) {
|
|
|
79
79
|
return tr;
|
|
80
80
|
};
|
|
81
81
|
};
|
|
82
|
-
export var inputRulePlugin = function inputRulePlugin(editorAnalyticsAPI) {
|
|
82
|
+
export var inputRulePlugin = function inputRulePlugin(editorAnalyticsAPI, getContextIdentifierProvider) {
|
|
83
83
|
return function (schema, featureFlags) {
|
|
84
84
|
var rules = [];
|
|
85
85
|
var _schema$nodes = schema.nodes,
|
|
@@ -88,11 +88,11 @@ export var inputRulePlugin = function inputRulePlugin(editorAnalyticsAPI) {
|
|
|
88
88
|
taskList = _schema$nodes.taskList,
|
|
89
89
|
taskItem = _schema$nodes.taskItem;
|
|
90
90
|
if (decisionList && decisionItem) {
|
|
91
|
-
rules.push(createListRule(editorAnalyticsAPI)(new RegExp("(^|".concat(leafNodeReplacementCharacter, ")\\<\\>\\s$")), 'decisionList'));
|
|
91
|
+
rules.push(createListRule(editorAnalyticsAPI, getContextIdentifierProvider)(new RegExp("(^|".concat(leafNodeReplacementCharacter, ")\\<\\>\\s$")), 'decisionList'));
|
|
92
92
|
}
|
|
93
93
|
if (taskList && taskItem) {
|
|
94
|
-
rules.push(createListRule(editorAnalyticsAPI)(new RegExp("(^|".concat(leafNodeReplacementCharacter, ")\\[\\]\\s$")), 'taskList'));
|
|
95
|
-
rules.push(createListRule(editorAnalyticsAPI)(new RegExp("(^|".concat(leafNodeReplacementCharacter, ")\\[x\\]\\s$")), 'taskList', {
|
|
94
|
+
rules.push(createListRule(editorAnalyticsAPI, getContextIdentifierProvider)(new RegExp("(^|".concat(leafNodeReplacementCharacter, ")\\[\\]\\s$")), 'taskList'));
|
|
95
|
+
rules.push(createListRule(editorAnalyticsAPI, getContextIdentifierProvider)(new RegExp("(^|".concat(leafNodeReplacementCharacter, ")\\[x\\]\\s$")), 'taskList', {
|
|
96
96
|
state: 'DONE'
|
|
97
97
|
}));
|
|
98
98
|
}
|
|
@@ -334,7 +334,7 @@ var splitListItem = function splitListItem(state, dispatch) {
|
|
|
334
334
|
}
|
|
335
335
|
return false;
|
|
336
336
|
};
|
|
337
|
-
var enter = function enter(editorAnalyticsAPI) {
|
|
337
|
+
var enter = function enter(editorAnalyticsAPI, getContextIdentifier) {
|
|
338
338
|
return filter(isInsideTaskOrDecisionItem, chainCommands(filter(isEmptyTaskDecision, chainCommands(getUnindentCommand(editorAnalyticsAPI)(), splitListItem)), function (state, dispatch) {
|
|
339
339
|
var selection = state.selection,
|
|
340
340
|
schema = state.schema;
|
|
@@ -364,7 +364,7 @@ var enter = function enter(editorAnalyticsAPI) {
|
|
|
364
364
|
}
|
|
365
365
|
}]);
|
|
366
366
|
};
|
|
367
|
-
var insertTr = insertTaskDecisionWithAnalytics(editorAnalyticsAPI)(state, listType, INPUT_METHOD.KEYBOARD, addItem);
|
|
367
|
+
var insertTr = insertTaskDecisionWithAnalytics(editorAnalyticsAPI, getContextIdentifier)(state, listType, INPUT_METHOD.KEYBOARD, addItem);
|
|
368
368
|
if (insertTr && dispatch) {
|
|
369
369
|
insertTr.scrollIntoView();
|
|
370
370
|
dispatch(insertTr);
|
|
@@ -394,6 +394,10 @@ var cmdOptEnter = filter(isInsideTaskOrDecisionItem, function (state, dispatch)
|
|
|
394
394
|
});
|
|
395
395
|
export function keymapPlugin(schema, api, allowNestedTasks, consumeTabs) {
|
|
396
396
|
var _api$analytics3, _api$analytics4;
|
|
397
|
+
var getContextIdentifier = function getContextIdentifier() {
|
|
398
|
+
var _api$contextIdentifie;
|
|
399
|
+
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;
|
|
400
|
+
};
|
|
397
401
|
var indentHandlers = {
|
|
398
402
|
'Shift-Tab': filter([isInsideTaskOrDecisionItem, function (state) {
|
|
399
403
|
return !shouldLetTabThroughInTable(state);
|
|
@@ -416,7 +420,7 @@ export function keymapPlugin(schema, api, allowNestedTasks, consumeTabs) {
|
|
|
416
420
|
Backspace: backspace(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
|
|
417
421
|
Delete: deleteForwards,
|
|
418
422
|
'Ctrl-d': deleteForwards,
|
|
419
|
-
Enter: enter(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)
|
|
423
|
+
Enter: enter(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, getContextIdentifier)
|
|
420
424
|
}, toggleTaskItemCheckbox.common, cmdOptEnter), allowNestedTasks ? indentHandlers : defaultHandlers);
|
|
421
425
|
return keymap(keymaps);
|
|
422
426
|
}
|
|
@@ -21,17 +21,6 @@ function nodesBetweenChanged(tr, f, startPos) {
|
|
|
21
21
|
}
|
|
22
22
|
tr.doc.nodesBetween(stepRange.from, stepRange.to, f, startPos);
|
|
23
23
|
}
|
|
24
|
-
var setContextIdentifierProvider = function setContextIdentifierProvider(provider) {
|
|
25
|
-
return function (state, dispatch) {
|
|
26
|
-
if (dispatch) {
|
|
27
|
-
dispatch(state.tr.setMeta(stateKey, {
|
|
28
|
-
action: ACTIONS.SET_CONTEXT_PROVIDER,
|
|
29
|
-
data: provider
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
return true;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
24
|
export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api) {
|
|
36
25
|
var useLongPressSelection = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
37
26
|
return new SafePlugin({
|
|
@@ -180,11 +169,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
|
|
|
180
169
|
data = _ref.data;
|
|
181
170
|
var newPluginState = pluginState;
|
|
182
171
|
switch (action) {
|
|
183
|
-
case ACTIONS.SET_CONTEXT_PROVIDER:
|
|
184
|
-
newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
185
|
-
contextIdentifierProvider: data
|
|
186
|
-
});
|
|
187
|
-
break;
|
|
188
172
|
case ACTIONS.FOCUS_BY_LOCALID:
|
|
189
173
|
newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
190
174
|
focusedTaskItemLocalId: data
|
|
@@ -195,21 +179,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
|
|
|
195
179
|
return newPluginState;
|
|
196
180
|
}
|
|
197
181
|
},
|
|
198
|
-
view: function view(editorView) {
|
|
199
|
-
var providerHandler = function providerHandler(name, providerPromise) {
|
|
200
|
-
if (name === 'contextIdentifierProvider') {
|
|
201
|
-
if (!providerPromise) {
|
|
202
|
-
setContextIdentifierProvider(undefined)(editorView.state, editorView.dispatch);
|
|
203
|
-
} else {
|
|
204
|
-
providerPromise.then(function (provider) {
|
|
205
|
-
setContextIdentifierProvider(provider)(editorView.state, editorView.dispatch);
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
providerFactory.subscribe('contextIdentifierProvider', providerHandler);
|
|
211
|
-
return {};
|
|
212
|
-
},
|
|
213
182
|
key: stateKey,
|
|
214
183
|
/*
|
|
215
184
|
* After each transaction, we search through the document for any decisionList/Item & taskList/Item nodes
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export var ACTIONS = /*#__PURE__*/function (ACTIONS) {
|
|
2
|
-
ACTIONS[ACTIONS["
|
|
3
|
-
ACTIONS[ACTIONS["FOCUS_BY_LOCALID"] = 1] = "FOCUS_BY_LOCALID";
|
|
2
|
+
ACTIONS[ACTIONS["FOCUS_BY_LOCALID"] = 0] = "FOCUS_BY_LOCALID";
|
|
4
3
|
return ACTIONS;
|
|
5
4
|
}({});
|
|
@@ -16,7 +16,11 @@ var ToolbarDecision = function ToolbarDecision(_ref) {
|
|
|
16
16
|
if (!editorView) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
var getContextIdentifier = function getContextIdentifier() {
|
|
20
|
+
var _editorAPI$contextIde;
|
|
21
|
+
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;
|
|
22
|
+
};
|
|
23
|
+
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);
|
|
20
24
|
return true;
|
|
21
25
|
};
|
|
22
26
|
return /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
@@ -16,7 +16,11 @@ var ToolbarTask = function ToolbarTask(_ref) {
|
|
|
16
16
|
if (!editorView) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
var getContextIdentifier = function getContextIdentifier() {
|
|
20
|
+
var _editorAPI$contextIde;
|
|
21
|
+
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;
|
|
22
|
+
};
|
|
23
|
+
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);
|
|
20
24
|
return true;
|
|
21
25
|
};
|
|
22
26
|
return /*#__PURE__*/React.createElement(ToolbarButton, {
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
3
3
|
import type { Command, TOOLBAR_MENU_TYPE } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { NodeType, ResolvedPos, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
-
import type { AddItemAttrs, AddItemTransactionCreator, TaskDecisionInputMethod, TaskDecisionListType } from './types';
|
|
6
|
+
import type { AddItemAttrs, AddItemTransactionCreator, GetContextIdentifier, TaskDecisionInputMethod, TaskDecisionListType } from './types';
|
|
7
7
|
export declare const getListTypes: (listType: TaskDecisionListType, schema: Schema) => {
|
|
8
8
|
list: NodeType;
|
|
9
9
|
item: NodeType;
|
|
10
10
|
};
|
|
11
|
-
export declare const insertTaskDecisionAction: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (state: EditorState, listType: TaskDecisionListType, inputMethod?: INPUT_METHOD.FORMATTING | INPUT_METHOD.QUICK_INSERT | TOOLBAR_MENU_TYPE, addItem?: AddItemTransactionCreator, listLocalId?: string, itemLocalId?: string, itemAttrs?: AddItemAttrs) => Transaction;
|
|
12
|
-
export declare const insertTaskDecisionCommand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (listType: TaskDecisionListType, inputMethod?: INPUT_METHOD.FORMATTING | INPUT_METHOD.QUICK_INSERT | TOOLBAR_MENU_TYPE, addItem?: AddItemTransactionCreator, listLocalId?: string, itemLocalId?: string) => Command;
|
|
13
|
-
export declare const insertTaskDecisionWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (state: EditorState, listType: TaskDecisionListType, inputMethod: TaskDecisionInputMethod, addAndCreateList: AddItemTransactionCreator, addToList?: AddItemTransactionCreator, listLocalId?: string, itemLocalId?: string, itemAttrs?: AddItemAttrs) => Transaction | null;
|
|
11
|
+
export declare const insertTaskDecisionAction: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, getContextIdentifierProvider: GetContextIdentifier) => (state: EditorState, listType: TaskDecisionListType, inputMethod?: INPUT_METHOD.FORMATTING | INPUT_METHOD.QUICK_INSERT | TOOLBAR_MENU_TYPE, addItem?: AddItemTransactionCreator, listLocalId?: string, itemLocalId?: string, itemAttrs?: AddItemAttrs) => Transaction;
|
|
12
|
+
export declare const insertTaskDecisionCommand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, getContextIdentifierProvider: GetContextIdentifier) => (listType: TaskDecisionListType, inputMethod?: INPUT_METHOD.FORMATTING | INPUT_METHOD.QUICK_INSERT | TOOLBAR_MENU_TYPE, addItem?: AddItemTransactionCreator, listLocalId?: string, itemLocalId?: string) => Command;
|
|
13
|
+
export declare const insertTaskDecisionWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, getContextIdentifierProvider: GetContextIdentifier) => (state: EditorState, listType: TaskDecisionListType, inputMethod: TaskDecisionInputMethod, addAndCreateList: AddItemTransactionCreator, addToList?: AddItemTransactionCreator, listLocalId?: string, itemLocalId?: string, itemAttrs?: AddItemAttrs) => Transaction | null;
|
|
14
14
|
export declare const isSupportedSourceNode: (schema: Schema, selection: Selection) => boolean;
|
|
15
15
|
export declare const changeInDepth: (before: ResolvedPos, after: ResolvedPos) => number;
|
|
16
16
|
export declare const createListAtSelection: (tr: Transaction, list: NodeType, item: NodeType, schema: Schema, state: EditorState, listLocalId?: string, itemLocalId?: string, itemAttrs?: AddItemAttrs) => Transaction | null;
|
|
@@ -2,5 +2,6 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
|
|
5
|
+
import type { GetContextIdentifier } from '../types';
|
|
6
|
+
export declare const inputRulePlugin: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, getContextIdentifierProvider: GetContextIdentifier) => (schema: Schema, featureFlags: FeatureFlags) => SafePlugin;
|
|
6
7
|
export default inputRulePlugin;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { DecisionItemDefinition, TaskItemDefinition } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { INPUT_METHOD, USER_CONTEXT } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { ContextIdentifierProvider } from '@atlaskit/editor-common/provider-factory';
|
|
3
4
|
import type { LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
4
5
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
6
|
+
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
5
7
|
import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
6
8
|
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
7
9
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -39,7 +41,8 @@ export type TasksAndDecisionsPlugin = NextEditorPlugin<'taskDecision', {
|
|
|
39
41
|
sharedState: TaskAndDecisionsSharedState | undefined;
|
|
40
42
|
dependencies: [
|
|
41
43
|
OptionalPlugin<TypeAheadPlugin>,
|
|
42
|
-
OptionalPlugin<AnalyticsPlugin
|
|
44
|
+
OptionalPlugin<AnalyticsPlugin>,
|
|
45
|
+
OptionalPlugin<ContextIdentifierPlugin>
|
|
43
46
|
];
|
|
44
47
|
actions: {
|
|
45
48
|
insertTaskDecision: ReturnType<typeof insertTaskDecisionCommand>;
|
|
@@ -47,3 +50,4 @@ export type TasksAndDecisionsPlugin = NextEditorPlugin<'taskDecision', {
|
|
|
47
50
|
outdentTaskList: ReturnType<typeof getUnindentCommand>;
|
|
48
51
|
};
|
|
49
52
|
}>;
|
|
53
|
+
export type GetContextIdentifier = () => ContextIdentifierProvider | undefined;
|
|
@@ -3,14 +3,14 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
3
3
|
import type { Command, TOOLBAR_MENU_TYPE } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { NodeType, ResolvedPos, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
-
import type { AddItemAttrs, AddItemTransactionCreator, TaskDecisionInputMethod, TaskDecisionListType } from './types';
|
|
6
|
+
import type { AddItemAttrs, AddItemTransactionCreator, GetContextIdentifier, TaskDecisionInputMethod, TaskDecisionListType } from './types';
|
|
7
7
|
export declare const getListTypes: (listType: TaskDecisionListType, schema: Schema) => {
|
|
8
8
|
list: NodeType;
|
|
9
9
|
item: NodeType;
|
|
10
10
|
};
|
|
11
|
-
export declare const insertTaskDecisionAction: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (state: EditorState, listType: TaskDecisionListType, inputMethod?: INPUT_METHOD.FORMATTING | INPUT_METHOD.QUICK_INSERT | TOOLBAR_MENU_TYPE, addItem?: AddItemTransactionCreator, listLocalId?: string, itemLocalId?: string, itemAttrs?: AddItemAttrs) => Transaction;
|
|
12
|
-
export declare const insertTaskDecisionCommand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (listType: TaskDecisionListType, inputMethod?: INPUT_METHOD.FORMATTING | INPUT_METHOD.QUICK_INSERT | TOOLBAR_MENU_TYPE, addItem?: AddItemTransactionCreator, listLocalId?: string, itemLocalId?: string) => Command;
|
|
13
|
-
export declare const insertTaskDecisionWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (state: EditorState, listType: TaskDecisionListType, inputMethod: TaskDecisionInputMethod, addAndCreateList: AddItemTransactionCreator, addToList?: AddItemTransactionCreator, listLocalId?: string, itemLocalId?: string, itemAttrs?: AddItemAttrs) => Transaction | null;
|
|
11
|
+
export declare const insertTaskDecisionAction: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, getContextIdentifierProvider: GetContextIdentifier) => (state: EditorState, listType: TaskDecisionListType, inputMethod?: INPUT_METHOD.FORMATTING | INPUT_METHOD.QUICK_INSERT | TOOLBAR_MENU_TYPE, addItem?: AddItemTransactionCreator, listLocalId?: string, itemLocalId?: string, itemAttrs?: AddItemAttrs) => Transaction;
|
|
12
|
+
export declare const insertTaskDecisionCommand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, getContextIdentifierProvider: GetContextIdentifier) => (listType: TaskDecisionListType, inputMethod?: INPUT_METHOD.FORMATTING | INPUT_METHOD.QUICK_INSERT | TOOLBAR_MENU_TYPE, addItem?: AddItemTransactionCreator, listLocalId?: string, itemLocalId?: string) => Command;
|
|
13
|
+
export declare const insertTaskDecisionWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, getContextIdentifierProvider: GetContextIdentifier) => (state: EditorState, listType: TaskDecisionListType, inputMethod: TaskDecisionInputMethod, addAndCreateList: AddItemTransactionCreator, addToList?: AddItemTransactionCreator, listLocalId?: string, itemLocalId?: string, itemAttrs?: AddItemAttrs) => Transaction | null;
|
|
14
14
|
export declare const isSupportedSourceNode: (schema: Schema, selection: Selection) => boolean;
|
|
15
15
|
export declare const changeInDepth: (before: ResolvedPos, after: ResolvedPos) => number;
|
|
16
16
|
export declare const createListAtSelection: (tr: Transaction, list: NodeType, item: NodeType, schema: Schema, state: EditorState, listLocalId?: string, itemLocalId?: string, itemAttrs?: AddItemAttrs) => Transaction | null;
|
|
@@ -2,5 +2,6 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
|
|
5
|
+
import type { GetContextIdentifier } from '../types';
|
|
6
|
+
export declare const inputRulePlugin: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, getContextIdentifierProvider: GetContextIdentifier) => (schema: Schema, featureFlags: FeatureFlags) => SafePlugin;
|
|
6
7
|
export default inputRulePlugin;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { DecisionItemDefinition, TaskItemDefinition } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { INPUT_METHOD, USER_CONTEXT } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { ContextIdentifierProvider } from '@atlaskit/editor-common/provider-factory';
|
|
3
4
|
import type { LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
4
5
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
6
|
+
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
5
7
|
import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
6
8
|
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
7
9
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -39,7 +41,8 @@ export type TasksAndDecisionsPlugin = NextEditorPlugin<'taskDecision', {
|
|
|
39
41
|
sharedState: TaskAndDecisionsSharedState | undefined;
|
|
40
42
|
dependencies: [
|
|
41
43
|
OptionalPlugin<TypeAheadPlugin>,
|
|
42
|
-
OptionalPlugin<AnalyticsPlugin
|
|
44
|
+
OptionalPlugin<AnalyticsPlugin>,
|
|
45
|
+
OptionalPlugin<ContextIdentifierPlugin>
|
|
43
46
|
];
|
|
44
47
|
actions: {
|
|
45
48
|
insertTaskDecision: ReturnType<typeof insertTaskDecisionCommand>;
|
|
@@ -47,3 +50,4 @@ export type TasksAndDecisionsPlugin = NextEditorPlugin<'taskDecision', {
|
|
|
47
50
|
outdentTaskList: ReturnType<typeof getUnindentCommand>;
|
|
48
51
|
};
|
|
49
52
|
}>;
|
|
53
|
+
export type GetContextIdentifier = () => ContextIdentifierProvider | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-tasks-and-decisions",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Tasks and decisions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,11 +33,12 @@
|
|
|
33
33
|
".": "./src/index.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/adf-schema": "^35.
|
|
36
|
+
"@atlaskit/adf-schema": "^35.5.1",
|
|
37
37
|
"@atlaskit/analytics-namespaced-context": "^6.9.0",
|
|
38
38
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
39
|
-
"@atlaskit/editor-common": "^77.
|
|
39
|
+
"@atlaskit/editor-common": "^77.2.0",
|
|
40
40
|
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
41
|
+
"@atlaskit/editor-plugin-context-identifier": "^0.1.0",
|
|
41
42
|
"@atlaskit/editor-plugin-type-ahead": "^0.9.0",
|
|
42
43
|
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
43
44
|
"@atlaskit/icon": "^22.0.0",
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
"@atlaskit/util-data-test": "^17.8.0",
|
|
59
60
|
"@atlaskit/visual-regression": "*",
|
|
60
61
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
61
|
-
"@atlassian/feature-flags-test-utils": "^0.
|
|
62
|
+
"@atlassian/feature-flags-test-utils": "^0.2.0",
|
|
62
63
|
"@testing-library/react": "^12.1.5",
|
|
63
64
|
"react-dom": "^16.8.0",
|
|
64
65
|
"typescript": "~4.9.5",
|