@atlaskit/editor-plugin-tasks-and-decisions 2.8.0 → 2.9.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/commands.js +11 -1
  3. package/dist/cjs/nodeviews/taskItem.js +4 -2
  4. package/dist/cjs/plugin.js +70 -21
  5. package/dist/cjs/pm-plugins/actions.js +20 -0
  6. package/dist/cjs/pm-plugins/main.js +14 -4
  7. package/dist/cjs/pm-plugins/types.js +4 -2
  8. package/dist/cjs/ui/Task/index.js +26 -6
  9. package/dist/es2019/commands.js +8 -0
  10. package/dist/es2019/nodeviews/taskItem.js +4 -2
  11. package/dist/es2019/plugin.js +29 -4
  12. package/dist/es2019/pm-plugins/actions.js +12 -0
  13. package/dist/es2019/pm-plugins/main.js +15 -6
  14. package/dist/es2019/pm-plugins/types.js +7 -2
  15. package/dist/es2019/ui/Task/index.js +25 -4
  16. package/dist/esm/commands.js +10 -0
  17. package/dist/esm/nodeviews/taskItem.js +4 -2
  18. package/dist/esm/plugin.js +71 -22
  19. package/dist/esm/pm-plugins/actions.js +13 -0
  20. package/dist/esm/pm-plugins/main.js +14 -4
  21. package/dist/esm/pm-plugins/types.js +7 -2
  22. package/dist/esm/ui/Task/index.js +26 -6
  23. package/dist/types/commands.d.ts +2 -0
  24. package/dist/types/pm-plugins/actions.d.ts +4 -0
  25. package/dist/types/pm-plugins/main.d.ts +2 -2
  26. package/dist/types/pm-plugins/types.d.ts +17 -1
  27. package/dist/types/types.d.ts +14 -4
  28. package/dist/types/ui/Task/index.d.ts +8 -2
  29. package/dist/types-ts4.5/commands.d.ts +2 -0
  30. package/dist/types-ts4.5/pm-plugins/actions.d.ts +4 -0
  31. package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -2
  32. package/dist/types-ts4.5/pm-plugins/types.d.ts +17 -1
  33. package/dist/types-ts4.5/types.d.ts +14 -4
  34. package/dist/types-ts4.5/ui/Task/index.d.ts +8 -2
  35. package/package.json +8 -5
@@ -9,6 +9,8 @@ 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 } from './pm-plugins/plugin-key';
13
+ import { ACTIONS } from './pm-plugins/types';
12
14
  var getContextData = function getContextData() {
13
15
  var contextProvider = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
14
16
  var objectId = contextProvider.objectId,
@@ -278,4 +280,12 @@ export var createListAtSelection = function createListAtSelection(tr, list, item
278
280
  }
279
281
  }
280
282
  return safeInsert(emptyList)(tr);
283
+ };
284
+ export var setProvider = function setProvider(provider) {
285
+ return function (tr) {
286
+ return tr.setMeta(stateKey, {
287
+ action: ACTIONS.SET_PROVIDER,
288
+ data: provider
289
+ });
290
+ };
281
291
  };
@@ -176,7 +176,8 @@ var TaskItemWrapper = function TaskItemWrapper(_ref2) {
176
176
  onChange: onChange,
177
177
  isFocused: isFocused,
178
178
  showPlaceholder: showPlaceholder,
179
- providers: providerFactory
179
+ providers: providerFactory,
180
+ api: api
180
181
  });
181
182
  }
182
183
  return /*#__PURE__*/React.createElement(Popup, {
@@ -222,7 +223,8 @@ var TaskItemWrapper = function TaskItemWrapper(_ref2) {
222
223
  isFocused: isFocused,
223
224
  showPlaceholder: showPlaceholder,
224
225
  providers: providerFactory,
225
- disableOnChange: !(api !== null && api !== void 0 && (_api$taskDecision3 = api.taskDecision) !== null && _api$taskDecision3 !== void 0 && (_api$taskDecision3 = _api$taskDecision3.sharedState.currentState()) !== null && _api$taskDecision3 !== void 0 && _api$taskDecision3.hasEditPermission)
226
+ disableOnChange: !(api !== null && api !== void 0 && (_api$taskDecision3 = api.taskDecision) !== null && _api$taskDecision3 !== void 0 && (_api$taskDecision3 = _api$taskDecision3.sharedState.currentState()) !== null && _api$taskDecision3 !== void 0 && _api$taskDecision3.hasEditPermission),
227
+ api: api
226
228
  });
227
229
  },
228
230
  placement: 'bottom-start'
@@ -1,4 +1,6 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
4
  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; }
3
5
  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) { _defineProperty(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; }
4
6
  /**
@@ -14,8 +16,9 @@ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
14
16
  import { toolbarInsertBlockMessages as insertBlockMessages } from '@atlaskit/editor-common/messages';
15
17
  import { IconAction, IconDecision } from '@atlaskit/editor-common/quick-insert';
16
18
  import { TaskDecisionSharedCssClassName } from '@atlaskit/editor-common/styles';
19
+ import { fg } from '@atlaskit/platform-feature-flags';
17
20
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
18
- import { getListTypes, insertTaskDecisionAction, insertTaskDecisionCommand } from './commands';
21
+ import { getListTypes, insertTaskDecisionAction, insertTaskDecisionCommand, setProvider as _setProvider } from './commands';
19
22
  import { getCurrentIndentLevel, getTaskItemIndex, isInsideTask } from './pm-plugins/helpers';
20
23
  import inputRulePlugin from './pm-plugins/input-rules';
21
24
  import keymap, { getIndentCommand, getUnindentCommand } from './pm-plugins/keymaps';
@@ -115,11 +118,23 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
115
118
  hasEditPermission = _ref2$config2.hasEditPermission,
116
119
  hasRequestedEditPermission = _ref2$config2.hasRequestedEditPermission,
117
120
  requestToEditContent = _ref2$config2.requestToEditContent,
121
+ taskDecisionProvider = _ref2$config2.taskDecisionProvider,
118
122
  api = _ref2.api;
119
123
  var getIdentifierProvider = function getIdentifierProvider() {
120
124
  var _api$contextIdentifie;
121
125
  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;
122
126
  };
127
+ var previousTaskAndDecisionProvider;
128
+ if (fg('platform_editor_td_provider_from_plugin_config')) {
129
+ if (taskDecisionProvider) {
130
+ taskDecisionProvider.then(function (provider) {
131
+ api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
132
+ var tr = _ref3.tr;
133
+ return _setProvider(provider)(tr);
134
+ });
135
+ });
136
+ }
137
+ }
123
138
  return {
124
139
  name: 'taskDecision',
125
140
  nodes: function nodes() {
@@ -151,21 +166,22 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
151
166
  outdentDisabled: indentLevel <= 1,
152
167
  hasEditPermission: pluginState === null || pluginState === void 0 ? void 0 : pluginState.hasEditPermission,
153
168
  requestToEditContent: pluginState === null || pluginState === void 0 ? void 0 : pluginState.requestToEditContent,
154
- hasRequestedEditPermission: pluginState === null || pluginState === void 0 ? void 0 : pluginState.hasRequestedEditPermission
169
+ hasRequestedEditPermission: pluginState === null || pluginState === void 0 ? void 0 : pluginState.hasRequestedEditPermission,
170
+ taskDecisionProvider: pluginState === null || pluginState === void 0 ? void 0 : pluginState.taskDecisionProvider
155
171
  };
156
172
  },
157
173
  commands: {
158
174
  updateEditPermission: function updateEditPermission(hasEditPermission) {
159
- return function (_ref3) {
160
- var tr = _ref3.tr;
175
+ return function (_ref4) {
176
+ var tr = _ref4.tr;
161
177
  return tr.setMeta(taskPluginKey, {
162
178
  hasEditPermission: hasEditPermission
163
179
  });
164
180
  };
165
181
  },
166
182
  updateHasRequestedEditPermission: function updateHasRequestedEditPermission(hasRequestedEditPermission) {
167
- return function (_ref4) {
168
- var tr = _ref4.tr;
183
+ return function (_ref5) {
184
+ var tr = _ref5.tr;
169
185
  return tr.setMeta(taskPluginKey, {
170
186
  hasRequestedEditPermission: hasRequestedEditPermission
171
187
  });
@@ -175,38 +191,71 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
175
191
  actions: {
176
192
  insertTaskDecision: insertTaskDecisionCommand(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, getIdentifierProvider),
177
193
  indentTaskList: getIndentCommand(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
178
- outdentTaskList: getUnindentCommand(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)
194
+ outdentTaskList: getUnindentCommand(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
195
+ setProvider: function () {
196
+ var _setProvider2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(providerPromise) {
197
+ var _api$core$actions$exe;
198
+ var provider;
199
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
200
+ while (1) switch (_context.prev = _context.next) {
201
+ case 0:
202
+ _context.next = 2;
203
+ return providerPromise;
204
+ case 2:
205
+ provider = _context.sent;
206
+ if (!(previousTaskAndDecisionProvider === provider || taskDecisionProvider === providerPromise)) {
207
+ _context.next = 5;
208
+ break;
209
+ }
210
+ return _context.abrupt("return", false);
211
+ case 5:
212
+ previousTaskAndDecisionProvider = provider;
213
+ return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref6) {
214
+ var tr = _ref6.tr;
215
+ return _setProvider(provider)(tr);
216
+ })) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false);
217
+ case 7:
218
+ case "end":
219
+ return _context.stop();
220
+ }
221
+ }, _callee);
222
+ }));
223
+ function setProvider(_x) {
224
+ return _setProvider2.apply(this, arguments);
225
+ }
226
+ return setProvider;
227
+ }()
179
228
  },
180
229
  pmPlugins: function pmPlugins() {
181
230
  return [{
182
231
  name: 'tasksAndDecisions',
183
- plugin: function plugin(_ref5) {
184
- var portalProviderAPI = _ref5.portalProviderAPI,
185
- providerFactory = _ref5.providerFactory,
186
- eventDispatcher = _ref5.eventDispatcher,
187
- dispatch = _ref5.dispatch;
232
+ plugin: function plugin(_ref7) {
233
+ var portalProviderAPI = _ref7.portalProviderAPI,
234
+ providerFactory = _ref7.providerFactory,
235
+ eventDispatcher = _ref7.eventDispatcher,
236
+ dispatch = _ref7.dispatch;
188
237
  return createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection, hasEditPermission, hasRequestedEditPermission, requestToEditContent);
189
238
  }
190
239
  }, {
191
240
  name: 'tasksAndDecisionsInputRule',
192
- plugin: function plugin(_ref6) {
241
+ plugin: function plugin(_ref8) {
193
242
  var _api$analytics4;
194
- var schema = _ref6.schema,
195
- featureFlags = _ref6.featureFlags;
243
+ var schema = _ref8.schema,
244
+ featureFlags = _ref8.featureFlags;
196
245
  return inputRulePlugin(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, getIdentifierProvider)(schema, featureFlags);
197
246
  }
198
247
  }, {
199
248
  name: 'tasksAndDecisionsKeyMap',
200
- plugin: function plugin(_ref7) {
201
- var schema = _ref7.schema;
249
+ plugin: function plugin(_ref9) {
250
+ var schema = _ref9.schema;
202
251
  return keymap(schema, api, allowNestedTasks, consumeTabs);
203
252
  }
204
253
  } // Needs to be after "save-on-enter"
205
254
  ];
206
255
  },
207
- secondaryToolbarComponent: function secondaryToolbarComponent(_ref8) {
208
- var editorView = _ref8.editorView,
209
- disabled = _ref8.disabled;
256
+ secondaryToolbarComponent: function secondaryToolbarComponent(_ref10) {
257
+ var editorView = _ref10.editorView,
258
+ disabled = _ref10.disabled;
210
259
  return jsx("div", {
211
260
  css: taskDecisionToolbarGroupStyles
212
261
  }, jsx(ToolbarDecision, {
@@ -222,8 +271,8 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
222
271
  }));
223
272
  },
224
273
  pluginsOptions: {
225
- quickInsert: function quickInsert(_ref9) {
226
- var formatMessage = _ref9.formatMessage;
274
+ quickInsert: function quickInsert(_ref11) {
275
+ var formatMessage = _ref11.formatMessage;
227
276
  return [{
228
277
  id: 'action',
229
278
  title: formatMessage(insertBlockMessages.action),
@@ -0,0 +1,13 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ 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; }
3
+ 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) { _defineProperty(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; }
4
+ export var focusTaskDecision = function focusTaskDecision(state, action) {
5
+ return _objectSpread(_objectSpread({}, state), {}, {
6
+ focusedTaskItemLocalId: action.data
7
+ });
8
+ };
9
+ export var setProvider = function setProvider(state, action) {
10
+ return _objectSpread(_objectSpread({}, state), {}, {
11
+ taskDecisionProvider: action.data
12
+ });
13
+ };
@@ -12,6 +12,7 @@ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
12
12
  import { fg } from '@atlaskit/platform-feature-flags';
13
13
  import { lazyDecisionView } from '../nodeviews/decision-lazy-node-view';
14
14
  import { lazyTaskView } from '../nodeviews/task-lazy-node-view';
15
+ import { focusTaskDecision, setProvider } from './actions';
15
16
  import { focusCheckboxAndUpdateSelection, getTaskItemDataAtPos, getTaskItemDataToFocus, removeCheckboxFocus } from './helpers';
16
17
  import { stateKey } from './plugin-key';
17
18
  import { ACTIONS } from './types';
@@ -164,12 +165,14 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
164
165
  insideTaskDecisionItem: false,
165
166
  hasEditPermission: hasEditPermission,
166
167
  hasRequestedEditPermission: hasRequestedEditPermission,
167
- requestToEditContent: requestToEditContent
168
+ requestToEditContent: requestToEditContent,
169
+ focusedTaskItemLocalId: null,
170
+ taskDecisionProvider: undefined
168
171
  };
169
172
  },
170
173
  apply: function apply(tr, pluginState) {
171
174
  var metaData = tr.getMeta(stateKey);
172
- var _ref = metaData || {
175
+ var _ref = metaData !== null && metaData !== void 0 ? metaData : {
173
176
  action: null,
174
177
  data: null
175
178
  },
@@ -180,8 +183,15 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
180
183
  // Actions
181
184
  switch (action) {
182
185
  case ACTIONS.FOCUS_BY_LOCALID:
183
- newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
184
- focusedTaskItemLocalId: data
186
+ newPluginState = focusTaskDecision(newPluginState, {
187
+ action: ACTIONS.FOCUS_BY_LOCALID,
188
+ data: data
189
+ });
190
+ break;
191
+ case ACTIONS.SET_PROVIDER:
192
+ newPluginState = setProvider(newPluginState, {
193
+ action: ACTIONS.SET_PROVIDER,
194
+ data: data
185
195
  });
186
196
  break;
187
197
  }
@@ -1,4 +1,9 @@
1
1
  export var ACTIONS = /*#__PURE__*/function (ACTIONS) {
2
- ACTIONS[ACTIONS["FOCUS_BY_LOCALID"] = 0] = "FOCUS_BY_LOCALID";
2
+ ACTIONS[ACTIONS["SET_PROVIDER"] = 0] = "SET_PROVIDER";
3
+ ACTIONS[ACTIONS["FOCUS_BY_LOCALID"] = 1] = "FOCUS_BY_LOCALID";
3
4
  return ACTIONS;
4
- }({});
5
+ }({});
6
+
7
+ // actions
8
+
9
+ // commands
@@ -7,13 +7,15 @@ import _inherits from "@babel/runtime/helpers/inherits";
7
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
8
8
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
9
9
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
- var _excluded = ["providers", "intl"];
10
+ var _excluded = ["providers", "intl", "api"];
11
11
  function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
12
12
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
13
  import React, { PureComponent } from 'react';
14
14
  import { injectIntl } from 'react-intl-next';
15
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
15
16
  import { tasksAndDecisionsMessages } from '@atlaskit/editor-common/messages';
16
17
  import { ProviderFactory, WithProviders } from '@atlaskit/editor-common/provider-factory';
18
+ import { fg } from '@atlaskit/platform-feature-flags';
17
19
  import TaskItemWithProviders from './task-item-with-providers';
18
20
  // eslint-disable-next-line @repo/internal/react/no-class-components
19
21
  export var TaskItem = /*#__PURE__*/function (_PureComponent) {
@@ -27,13 +29,20 @@ export var TaskItem = /*#__PURE__*/function (_PureComponent) {
27
29
  var _this$props = _this.props,
28
30
  _providerFactory = _this$props.providers,
29
31
  formatMessage = _this$props.intl.formatMessage,
32
+ api = _this$props.api,
30
33
  otherProps = _objectWithoutProperties(_this$props, _excluded);
31
- var taskDecisionProvider = providers.taskDecisionProvider,
32
- contextIdentifierProvider = providers.contextIdentifierProvider;
34
+ var contextIdentifierProvider = providers.contextIdentifierProvider;
33
35
  var placeholder = formatMessage(tasksAndDecisionsMessages.taskPlaceholder);
36
+ var getTaskDecisionProvider = function getTaskDecisionProvider() {
37
+ if (fg('platform_editor_td_provider_from_plugin_config')) {
38
+ var _this$props$taskDecis;
39
+ return (_this$props$taskDecis = _this.props.taskDecisionState) !== null && _this$props$taskDecis !== void 0 && _this$props$taskDecis.taskDecisionProvider ? Promise.resolve(_this.props.taskDecisionState.taskDecisionProvider) : undefined;
40
+ }
41
+ return providers.taskDecisionProvider;
42
+ };
34
43
  return /*#__PURE__*/React.createElement(TaskItemWithProviders, _extends({}, otherProps, {
35
44
  placeholder: placeholder,
36
- taskDecisionProvider: taskDecisionProvider,
45
+ taskDecisionProvider: getTaskDecisionProvider(),
37
46
  contextIdentifierProvider: contextIdentifierProvider
38
47
  }));
39
48
  });
@@ -52,8 +61,12 @@ export var TaskItem = /*#__PURE__*/function (_PureComponent) {
52
61
  }, {
53
62
  key: "render",
54
63
  value: function render() {
64
+ var providers = ['contextIdentifierProvider'];
65
+ if (!fg('platform_editor_td_provider_from_plugin_config')) {
66
+ providers.push('taskDecisionProvider');
67
+ }
55
68
  return /*#__PURE__*/React.createElement(WithProviders, {
56
- providers: ['taskDecisionProvider', 'contextIdentifierProvider'],
69
+ providers: providers,
57
70
  providerFactory: this.providerFactory,
58
71
  renderNode: this.renderWithProvider
59
72
  });
@@ -62,4 +75,11 @@ export var TaskItem = /*#__PURE__*/function (_PureComponent) {
62
75
  return TaskItem;
63
76
  }(PureComponent);
64
77
  _defineProperty(TaskItem, "displayName", 'TaskItem');
65
- export default injectIntl(TaskItem);
78
+ var TaskItemWrapper = function TaskItemWrapper(props) {
79
+ var _useSharedPluginState = useSharedPluginState(props.api, ['taskDecision']),
80
+ taskDecisionState = _useSharedPluginState.taskDecisionState;
81
+ return /*#__PURE__*/React.createElement(TaskItem, _extends({
82
+ taskDecisionState: taskDecisionState
83
+ }, props));
84
+ };
85
+ export default injectIntl(TaskItemWrapper);
@@ -3,6 +3,7 @@ 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 { TaskDecisionProvider } from '@atlaskit/task-decision/types';
6
7
  import type { AddItemAttrs, AddItemTransactionCreator, GetContextIdentifier, TaskDecisionInputMethod, TaskDecisionListType } from './types';
7
8
  export declare const getListTypes: (listType: TaskDecisionListType, schema: Schema) => {
8
9
  list: NodeType;
@@ -14,3 +15,4 @@ export declare const insertTaskDecisionWithAnalytics: (editorAnalyticsAPI: Edito
14
15
  export declare const isSupportedSourceNode: (schema: Schema, selection: Selection) => boolean;
15
16
  export declare const changeInDepth: (before: ResolvedPos, after: ResolvedPos) => number;
16
17
  export declare const createListAtSelection: (tr: Transaction, list: NodeType, item: NodeType, schema: Schema, state: EditorState, listLocalId?: string, itemLocalId?: string, itemAttrs?: AddItemAttrs) => Transaction | null;
18
+ export declare const setProvider: (provider?: TaskDecisionProvider) => (tr: Transaction) => Transaction;
@@ -0,0 +1,4 @@
1
+ import type { TaskDecisionPluginState } from '../types';
2
+ import type { TaskDecisionFocusByLocalIdAction, TaskDecisionSetProviderAction } from './types';
3
+ export declare const focusTaskDecision: (state: TaskDecisionPluginState, action: TaskDecisionFocusByLocalIdAction) => TaskDecisionPluginState;
4
+ export declare const setProvider: (state: TaskDecisionPluginState, action: TaskDecisionSetProviderAction) => TaskDecisionPluginState;
@@ -3,5 +3,5 @@ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { type PortalProviderAPI } from '@atlaskit/editor-common/src/portal';
5
5
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
- import type { TasksAndDecisionsPlugin } from '../types';
7
- export declare function createPlugin(portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, dispatch: Dispatch, api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined, useLongPressSelection?: boolean, hasEditPermission?: boolean, hasRequestedEditPermission?: boolean, requestToEditContent?: () => void): SafePlugin<any>;
6
+ import type { TaskDecisionPluginState, TasksAndDecisionsPlugin } from '../types';
7
+ export declare function createPlugin(portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, dispatch: Dispatch, api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined, useLongPressSelection?: boolean, hasEditPermission?: boolean, hasRequestedEditPermission?: boolean, requestToEditContent?: () => void): SafePlugin<TaskDecisionPluginState>;
@@ -1,7 +1,23 @@
1
+ import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
1
2
  export declare enum ACTIONS {
2
- FOCUS_BY_LOCALID = 0
3
+ SET_PROVIDER = 0,
4
+ FOCUS_BY_LOCALID = 1
3
5
  }
4
6
  export type TaskItemData = {
5
7
  pos: number;
6
8
  localId: string | null;
7
9
  };
10
+ export type TaskDecisionSetProviderAction = {
11
+ action: ACTIONS.SET_PROVIDER;
12
+ data: TaskDecisionProvider;
13
+ };
14
+ export type TaskDecisionFocusByLocalIdAction = {
15
+ action: ACTIONS.FOCUS_BY_LOCALID;
16
+ data: string;
17
+ };
18
+ export type TaskDecisionPluginAction = TaskDecisionSetProviderAction | TaskDecisionFocusByLocalIdAction;
19
+ export type TaskDecisionEditPermissionCommand = {
20
+ hasEditPermission?: boolean;
21
+ hasRequestedEditPermission?: boolean;
22
+ };
23
+ export type TaskDecisionPluginCommand = TaskDecisionEditPermissionCommand;
@@ -8,6 +8,7 @@ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmo
8
8
  import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
9
9
  import type { NodeType } from '@atlaskit/editor-prosemirror/model';
10
10
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
11
+ import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
11
12
  import type { insertTaskDecisionCommand } from './commands';
12
13
  import type { getIndentCommand, getUnindentCommand } from './pm-plugins/keymaps';
13
14
  export type TaskDecisionListType = 'taskList' | 'decisionList';
@@ -56,15 +57,23 @@ export interface TaskDecisionPluginOptions extends LongPressSelectionPluginOptio
56
57
  * Function to request edit permission.
57
58
  */
58
59
  requestToEditContent?: () => void;
60
+ /**
61
+ * The provider for tasks and decisions.
62
+ */
63
+ taskDecisionProvider?: Promise<TaskDecisionProvider>;
59
64
  }
60
- export type TaskAndDecisionsSharedState = {
65
+ export type TaskDecisionPluginState = {
66
+ insideTaskDecisionItem: boolean;
61
67
  focusedTaskItemLocalId: string | null;
62
- indentDisabled: boolean;
63
- outdentDisabled: boolean;
64
- isInsideTask: boolean;
65
68
  hasEditPermission?: boolean;
66
69
  hasRequestedEditPermission?: boolean;
67
70
  requestToEditContent?: () => void;
71
+ taskDecisionProvider: TaskDecisionProvider | undefined;
72
+ };
73
+ export type TaskAndDecisionsSharedState = Pick<TaskDecisionPluginState, 'focusedTaskItemLocalId' | 'hasEditPermission' | 'requestToEditContent' | 'taskDecisionProvider' | 'hasRequestedEditPermission'> & {
74
+ isInsideTask: boolean;
75
+ indentDisabled: boolean;
76
+ outdentDisabled: boolean;
68
77
  };
69
78
  export type TasksAndDecisionsPlugin = NextEditorPlugin<'taskDecision', {
70
79
  pluginConfiguration: TaskDecisionPluginOptions | undefined;
@@ -79,6 +88,7 @@ export type TasksAndDecisionsPlugin = NextEditorPlugin<'taskDecision', {
79
88
  insertTaskDecision: ReturnType<typeof insertTaskDecisionCommand>;
80
89
  indentTaskList: ReturnType<typeof getIndentCommand>;
81
90
  outdentTaskList: ReturnType<typeof getUnindentCommand>;
91
+ setProvider: (provider: Promise<TaskDecisionProvider>) => Promise<boolean>;
82
92
  };
83
93
  commands: {
84
94
  updateEditPermission: (hasEditPermission: boolean | undefined) => EditorCommand;
@@ -2,7 +2,9 @@ import type { ReactElement, Ref } from 'react';
2
2
  import React, { PureComponent } from 'react';
3
3
  import type { WrappedComponentProps } from 'react-intl-next';
4
4
  import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
5
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
6
  import type { ContentRef } from '@atlaskit/task-decision';
7
+ import { type TaskAndDecisionsSharedState, type TasksAndDecisionsPlugin } from '../../types';
6
8
  export interface TaskProps {
7
9
  taskId: string;
8
10
  isDone: boolean;
@@ -16,11 +18,15 @@ export interface TaskProps {
16
18
  disabled?: boolean;
17
19
  disableOnChange?: boolean;
18
20
  inputRef?: Ref<HTMLInputElement>;
21
+ api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined;
19
22
  }
20
- export declare class TaskItem extends PureComponent<TaskProps & WrappedComponentProps, {}> {
23
+ type TaskItemProps = TaskProps & WrappedComponentProps & {
24
+ taskDecisionState: TaskAndDecisionsSharedState | undefined;
25
+ };
26
+ export declare class TaskItem extends PureComponent<TaskItemProps, {}> {
21
27
  static displayName: string;
22
28
  private providerFactory;
23
- constructor(props: TaskProps & WrappedComponentProps);
29
+ constructor(props: TaskItemProps);
24
30
  componentWillUnmount(): void;
25
31
  private renderWithProvider;
26
32
  render(): JSX.Element;
@@ -3,6 +3,7 @@ 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 { TaskDecisionProvider } from '@atlaskit/task-decision/types';
6
7
  import type { AddItemAttrs, AddItemTransactionCreator, GetContextIdentifier, TaskDecisionInputMethod, TaskDecisionListType } from './types';
7
8
  export declare const getListTypes: (listType: TaskDecisionListType, schema: Schema) => {
8
9
  list: NodeType;
@@ -14,3 +15,4 @@ export declare const insertTaskDecisionWithAnalytics: (editorAnalyticsAPI: Edito
14
15
  export declare const isSupportedSourceNode: (schema: Schema, selection: Selection) => boolean;
15
16
  export declare const changeInDepth: (before: ResolvedPos, after: ResolvedPos) => number;
16
17
  export declare const createListAtSelection: (tr: Transaction, list: NodeType, item: NodeType, schema: Schema, state: EditorState, listLocalId?: string, itemLocalId?: string, itemAttrs?: AddItemAttrs) => Transaction | null;
18
+ export declare const setProvider: (provider?: TaskDecisionProvider) => (tr: Transaction) => Transaction;
@@ -0,0 +1,4 @@
1
+ import type { TaskDecisionPluginState } from '../types';
2
+ import type { TaskDecisionFocusByLocalIdAction, TaskDecisionSetProviderAction } from './types';
3
+ export declare const focusTaskDecision: (state: TaskDecisionPluginState, action: TaskDecisionFocusByLocalIdAction) => TaskDecisionPluginState;
4
+ export declare const setProvider: (state: TaskDecisionPluginState, action: TaskDecisionSetProviderAction) => TaskDecisionPluginState;
@@ -3,5 +3,5 @@ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { type PortalProviderAPI } from '@atlaskit/editor-common/src/portal';
5
5
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
- import type { TasksAndDecisionsPlugin } from '../types';
7
- export declare function createPlugin(portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, dispatch: Dispatch, api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined, useLongPressSelection?: boolean, hasEditPermission?: boolean, hasRequestedEditPermission?: boolean, requestToEditContent?: () => void): SafePlugin<any>;
6
+ import type { TaskDecisionPluginState, TasksAndDecisionsPlugin } from '../types';
7
+ export declare function createPlugin(portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, dispatch: Dispatch, api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined, useLongPressSelection?: boolean, hasEditPermission?: boolean, hasRequestedEditPermission?: boolean, requestToEditContent?: () => void): SafePlugin<TaskDecisionPluginState>;
@@ -1,7 +1,23 @@
1
+ import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
1
2
  export declare enum ACTIONS {
2
- FOCUS_BY_LOCALID = 0
3
+ SET_PROVIDER = 0,
4
+ FOCUS_BY_LOCALID = 1
3
5
  }
4
6
  export type TaskItemData = {
5
7
  pos: number;
6
8
  localId: string | null;
7
9
  };
10
+ export type TaskDecisionSetProviderAction = {
11
+ action: ACTIONS.SET_PROVIDER;
12
+ data: TaskDecisionProvider;
13
+ };
14
+ export type TaskDecisionFocusByLocalIdAction = {
15
+ action: ACTIONS.FOCUS_BY_LOCALID;
16
+ data: string;
17
+ };
18
+ export type TaskDecisionPluginAction = TaskDecisionSetProviderAction | TaskDecisionFocusByLocalIdAction;
19
+ export type TaskDecisionEditPermissionCommand = {
20
+ hasEditPermission?: boolean;
21
+ hasRequestedEditPermission?: boolean;
22
+ };
23
+ export type TaskDecisionPluginCommand = TaskDecisionEditPermissionCommand;
@@ -8,6 +8,7 @@ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmo
8
8
  import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
9
9
  import type { NodeType } from '@atlaskit/editor-prosemirror/model';
10
10
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
11
+ import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
11
12
  import type { insertTaskDecisionCommand } from './commands';
12
13
  import type { getIndentCommand, getUnindentCommand } from './pm-plugins/keymaps';
13
14
  export type TaskDecisionListType = 'taskList' | 'decisionList';
@@ -56,15 +57,23 @@ export interface TaskDecisionPluginOptions extends LongPressSelectionPluginOptio
56
57
  * Function to request edit permission.
57
58
  */
58
59
  requestToEditContent?: () => void;
60
+ /**
61
+ * The provider for tasks and decisions.
62
+ */
63
+ taskDecisionProvider?: Promise<TaskDecisionProvider>;
59
64
  }
60
- export type TaskAndDecisionsSharedState = {
65
+ export type TaskDecisionPluginState = {
66
+ insideTaskDecisionItem: boolean;
61
67
  focusedTaskItemLocalId: string | null;
62
- indentDisabled: boolean;
63
- outdentDisabled: boolean;
64
- isInsideTask: boolean;
65
68
  hasEditPermission?: boolean;
66
69
  hasRequestedEditPermission?: boolean;
67
70
  requestToEditContent?: () => void;
71
+ taskDecisionProvider: TaskDecisionProvider | undefined;
72
+ };
73
+ export type TaskAndDecisionsSharedState = Pick<TaskDecisionPluginState, 'focusedTaskItemLocalId' | 'hasEditPermission' | 'requestToEditContent' | 'taskDecisionProvider' | 'hasRequestedEditPermission'> & {
74
+ isInsideTask: boolean;
75
+ indentDisabled: boolean;
76
+ outdentDisabled: boolean;
68
77
  };
69
78
  export type TasksAndDecisionsPlugin = NextEditorPlugin<'taskDecision', {
70
79
  pluginConfiguration: TaskDecisionPluginOptions | undefined;
@@ -79,6 +88,7 @@ export type TasksAndDecisionsPlugin = NextEditorPlugin<'taskDecision', {
79
88
  insertTaskDecision: ReturnType<typeof insertTaskDecisionCommand>;
80
89
  indentTaskList: ReturnType<typeof getIndentCommand>;
81
90
  outdentTaskList: ReturnType<typeof getUnindentCommand>;
91
+ setProvider: (provider: Promise<TaskDecisionProvider>) => Promise<boolean>;
82
92
  };
83
93
  commands: {
84
94
  updateEditPermission: (hasEditPermission: boolean | undefined) => EditorCommand;
@@ -2,7 +2,9 @@ import type { ReactElement, Ref } from 'react';
2
2
  import React, { PureComponent } from 'react';
3
3
  import type { WrappedComponentProps } from 'react-intl-next';
4
4
  import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
5
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
6
  import type { ContentRef } from '@atlaskit/task-decision';
7
+ import { type TaskAndDecisionsSharedState, type TasksAndDecisionsPlugin } from '../../types';
6
8
  export interface TaskProps {
7
9
  taskId: string;
8
10
  isDone: boolean;
@@ -16,11 +18,15 @@ export interface TaskProps {
16
18
  disabled?: boolean;
17
19
  disableOnChange?: boolean;
18
20
  inputRef?: Ref<HTMLInputElement>;
21
+ api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined;
19
22
  }
20
- export declare class TaskItem extends PureComponent<TaskProps & WrappedComponentProps, {}> {
23
+ type TaskItemProps = TaskProps & WrappedComponentProps & {
24
+ taskDecisionState: TaskAndDecisionsSharedState | undefined;
25
+ };
26
+ export declare class TaskItem extends PureComponent<TaskItemProps, {}> {
21
27
  static displayName: string;
22
28
  private providerFactory;
23
- constructor(props: TaskProps & WrappedComponentProps);
29
+ constructor(props: TaskItemProps);
24
30
  componentWillUnmount(): void;
25
31
  private renderWithProvider;
26
32
  render(): JSX.Element;