@atlaskit/editor-plugin-tasks-and-decisions 2.4.7 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-tasks-and-decisions
2
2
 
3
+ ## 2.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#140548](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/140548)
8
+ [`36d26892db64c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/36d26892db64c) -
9
+ ED-24762 Add support for hasEditPermission in tasks and decision plugin
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 2.4.7
4
16
 
5
17
  ### Patch Changes
@@ -18,6 +18,7 @@ var _steps = require("@atlaskit/adf-schema/steps");
18
18
  var _analyticsNext = require("@atlaskit/analytics-next");
19
19
  var _hooks = require("@atlaskit/editor-common/hooks");
20
20
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
21
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
22
  var _Task = _interopRequireDefault(require("../ui/Task"));
22
23
  var _useShowPlaceholder = require("./hooks/use-show-placeholder");
23
24
  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; }
@@ -99,6 +100,7 @@ var Task = /*#__PURE__*/function (_ReactNodeView) {
99
100
  var listSize = resolvedPos.parent.childCount;
100
101
  var listLocalId = resolvedPos.parent.attrs.localId;
101
102
  event.update(function (payload) {
103
+ var _this$api;
102
104
  var _payload$attributes = payload.attributes,
103
105
  attributes = _payload$attributes === void 0 ? {} : _payload$attributes,
104
106
  actionSubject = payload.actionSubject;
@@ -111,6 +113,8 @@ var Task = /*#__PURE__*/function (_ReactNodeView) {
111
113
  position: position,
112
114
  listSize: listSize,
113
115
  listLocalId: listLocalId
116
+ }, (0, _platformFeatureFlags.fg)('editor_request_to_edit_task') && {
117
+ hasEditPermission: (_this$api = _this.api) === null || _this$api === void 0 || (_this$api = _this$api.taskDecision) === null || _this$api === void 0 || (_this$api = _this$api.sharedState.currentState()) === null || _this$api === void 0 ? void 0 : _this$api.hasEditPermission
114
118
  })
115
119
  });
116
120
  });
@@ -115,6 +115,7 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
115
115
  allowNestedTasks = _ref2$config2.allowNestedTasks,
116
116
  consumeTabs = _ref2$config2.consumeTabs,
117
117
  useLongPressSelection = _ref2$config2.useLongPressSelection,
118
+ hasEditPermission = _ref2$config2.hasEditPermission,
118
119
  api = _ref2.api;
119
120
  var getIdentifierProvider = function getIdentifierProvider() {
120
121
  var _api$contextIdentifie;
@@ -148,7 +149,8 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
148
149
  focusedTaskItemLocalId: (pluginState === null || pluginState === void 0 ? void 0 : pluginState.focusedTaskItemLocalId) || null,
149
150
  isInsideTask: (0, _helpers.isInsideTask)(editorState),
150
151
  indentDisabled: itemIndex === 0 || indentLevel >= _indentation.MAX_INDENTATION_LEVEL,
151
- outdentDisabled: indentLevel <= 1
152
+ outdentDisabled: indentLevel <= 1,
153
+ hasEditPermission: pluginState === null || pluginState === void 0 ? void 0 : pluginState.hasEditPermission
152
154
  };
153
155
  },
154
156
  actions: {
@@ -164,7 +166,7 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
164
166
  providerFactory = _ref3.providerFactory,
165
167
  eventDispatcher = _ref3.eventDispatcher,
166
168
  dispatch = _ref3.dispatch;
167
- return (0, _main.createPlugin)(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection);
169
+ return (0, _main.createPlugin)(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection, hasEditPermission);
168
170
  }
169
171
  }, {
170
172
  name: 'tasksAndDecisionsInputRule',
@@ -30,6 +30,7 @@ function nodesBetweenChanged(tr, f, startPos) {
30
30
  }
31
31
  function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api) {
32
32
  var useLongPressSelection = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
33
+ var hasEditPermission = arguments.length > 6 ? arguments[6] : undefined;
33
34
  return new _safePlugin.SafePlugin({
34
35
  props: {
35
36
  nodeViews: {
@@ -164,7 +165,8 @@ function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispa
164
165
  state: {
165
166
  init: function init() {
166
167
  return {
167
- insideTaskDecisionItem: false
168
+ insideTaskDecisionItem: false,
169
+ hasEditPermission: hasEditPermission
168
170
  };
169
171
  },
170
172
  apply: function apply(tr, pluginState) {
@@ -4,6 +4,7 @@ import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
4
4
  import { AnalyticsListener } from '@atlaskit/analytics-next';
5
5
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
6
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import TaskItem from '../ui/Task';
8
9
  import { useShowPlaceholder } from './hooks/use-show-placeholder';
9
10
  const TaskItemWrapper = ({
@@ -78,6 +79,7 @@ class Task extends ReactNodeView {
78
79
  const listSize = resolvedPos.parent.childCount;
79
80
  const listLocalId = resolvedPos.parent.attrs.localId;
80
81
  event.update(payload => {
82
+ var _this$api, _this$api$taskDecisio, _this$api$taskDecisio2;
81
83
  const {
82
84
  attributes = {},
83
85
  actionSubject
@@ -92,7 +94,10 @@ class Task extends ReactNodeView {
92
94
  ...attributes,
93
95
  position,
94
96
  listSize,
95
- listLocalId
97
+ listLocalId,
98
+ ...(fg('editor_request_to_edit_task') && {
99
+ hasEditPermission: (_this$api = this.api) === null || _this$api === void 0 ? void 0 : (_this$api$taskDecisio = _this$api.taskDecision) === null || _this$api$taskDecisio === void 0 ? void 0 : (_this$api$taskDecisio2 = _this$api$taskDecisio.sharedState.currentState()) === null || _this$api$taskDecisio2 === void 0 ? void 0 : _this$api$taskDecisio2.hasEditPermission
100
+ })
96
101
  }
97
102
  };
98
103
  });
@@ -103,7 +103,8 @@ export const tasksAndDecisionsPlugin = ({
103
103
  config: {
104
104
  allowNestedTasks,
105
105
  consumeTabs,
106
- useLongPressSelection
106
+ useLongPressSelection,
107
+ hasEditPermission
107
108
  } = {},
108
109
  api
109
110
  }) => {
@@ -140,7 +141,8 @@ export const tasksAndDecisionsPlugin = ({
140
141
  focusedTaskItemLocalId: (pluginState === null || pluginState === void 0 ? void 0 : pluginState.focusedTaskItemLocalId) || null,
141
142
  isInsideTask: isInsideTask(editorState),
142
143
  indentDisabled: itemIndex === 0 || indentLevel >= MAX_INDENTATION_LEVEL,
143
- outdentDisabled: indentLevel <= 1
144
+ outdentDisabled: indentLevel <= 1,
145
+ hasEditPermission: pluginState === null || pluginState === void 0 ? void 0 : pluginState.hasEditPermission
144
146
  };
145
147
  },
146
148
  actions: {
@@ -157,7 +159,7 @@ export const tasksAndDecisionsPlugin = ({
157
159
  eventDispatcher,
158
160
  dispatch
159
161
  }) => {
160
- return createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection);
162
+ return createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection, hasEditPermission);
161
163
  }
162
164
  }, {
163
165
  name: 'tasksAndDecisionsInputRule',
@@ -16,7 +16,7 @@ function nodesBetweenChanged(tr, f, startPos) {
16
16
  }
17
17
  tr.doc.nodesBetween(stepRange.from, stepRange.to, f, startPos);
18
18
  }
19
- export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection = false) {
19
+ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection = false, hasEditPermission) {
20
20
  return new SafePlugin({
21
21
  props: {
22
22
  nodeViews: {
@@ -159,7 +159,8 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
159
159
  state: {
160
160
  init() {
161
161
  return {
162
- insideTaskDecisionItem: false
162
+ insideTaskDecisionItem: false,
163
+ hasEditPermission
163
164
  };
164
165
  },
165
166
  apply(tr, pluginState) {
@@ -15,6 +15,7 @@ import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
15
15
  import { AnalyticsListener } from '@atlaskit/analytics-next';
16
16
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
17
17
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
18
+ import { fg } from '@atlaskit/platform-feature-flags';
18
19
  import TaskItem from '../ui/Task';
19
20
  import { useShowPlaceholder } from './hooks/use-show-placeholder';
20
21
  var TaskItemWrapper = function TaskItemWrapper(_ref) {
@@ -92,6 +93,7 @@ var Task = /*#__PURE__*/function (_ReactNodeView) {
92
93
  var listSize = resolvedPos.parent.childCount;
93
94
  var listLocalId = resolvedPos.parent.attrs.localId;
94
95
  event.update(function (payload) {
96
+ var _this$api;
95
97
  var _payload$attributes = payload.attributes,
96
98
  attributes = _payload$attributes === void 0 ? {} : _payload$attributes,
97
99
  actionSubject = payload.actionSubject;
@@ -104,6 +106,8 @@ var Task = /*#__PURE__*/function (_ReactNodeView) {
104
106
  position: position,
105
107
  listSize: listSize,
106
108
  listLocalId: listLocalId
109
+ }, fg('editor_request_to_edit_task') && {
110
+ hasEditPermission: (_this$api = _this.api) === null || _this$api === void 0 || (_this$api = _this$api.taskDecision) === null || _this$api === void 0 || (_this$api = _this$api.sharedState.currentState()) === null || _this$api === void 0 ? void 0 : _this$api.hasEditPermission
107
111
  })
108
112
  });
109
113
  });
@@ -107,6 +107,7 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
107
107
  allowNestedTasks = _ref2$config2.allowNestedTasks,
108
108
  consumeTabs = _ref2$config2.consumeTabs,
109
109
  useLongPressSelection = _ref2$config2.useLongPressSelection,
110
+ hasEditPermission = _ref2$config2.hasEditPermission,
110
111
  api = _ref2.api;
111
112
  var getIdentifierProvider = function getIdentifierProvider() {
112
113
  var _api$contextIdentifie;
@@ -140,7 +141,8 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
140
141
  focusedTaskItemLocalId: (pluginState === null || pluginState === void 0 ? void 0 : pluginState.focusedTaskItemLocalId) || null,
141
142
  isInsideTask: isInsideTask(editorState),
142
143
  indentDisabled: itemIndex === 0 || indentLevel >= MAX_INDENTATION_LEVEL,
143
- outdentDisabled: indentLevel <= 1
144
+ outdentDisabled: indentLevel <= 1,
145
+ hasEditPermission: pluginState === null || pluginState === void 0 ? void 0 : pluginState.hasEditPermission
144
146
  };
145
147
  },
146
148
  actions: {
@@ -156,7 +158,7 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
156
158
  providerFactory = _ref3.providerFactory,
157
159
  eventDispatcher = _ref3.eventDispatcher,
158
160
  dispatch = _ref3.dispatch;
159
- return createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection);
161
+ return createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection, hasEditPermission);
160
162
  }
161
163
  }, {
162
164
  name: 'tasksAndDecisionsInputRule',
@@ -23,6 +23,7 @@ function nodesBetweenChanged(tr, f, startPos) {
23
23
  }
24
24
  export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api) {
25
25
  var useLongPressSelection = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
26
+ var hasEditPermission = arguments.length > 6 ? arguments[6] : undefined;
26
27
  return new SafePlugin({
27
28
  props: {
28
29
  nodeViews: {
@@ -157,7 +158,8 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
157
158
  state: {
158
159
  init: function init() {
159
160
  return {
160
- insideTaskDecisionItem: false
161
+ insideTaskDecisionItem: false,
162
+ hasEditPermission: hasEditPermission
161
163
  };
162
164
  },
163
165
  apply: function apply(tr, pluginState) {
@@ -4,4 +4,4 @@ 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
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): SafePlugin<any>;
7
+ export declare function createPlugin(portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, dispatch: Dispatch, api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined, useLongPressSelection?: boolean, hasEditPermission?: boolean): SafePlugin<any>;
@@ -26,15 +26,40 @@ export type AddItemTransactionCreator = (opts: {
26
26
  itemLocalId: string;
27
27
  itemAttrs?: AddItemAttrs;
28
28
  }) => Transaction | null;
29
+ /**
30
+ * Interface representing the options for the TaskDecisionPlugin.
31
+ * Extends the LongPressSelectionPluginOptions interface.
32
+ */
33
+ /**
34
+ * Represents the options for the TaskDecisionPlugin.
35
+ */
29
36
  export interface TaskDecisionPluginOptions extends LongPressSelectionPluginOptions {
37
+ /**
38
+ * Indicates whether nested tasks are allowed.
39
+ * @default false
40
+ */
30
41
  allowNestedTasks?: boolean;
42
+ /**
43
+ * Indicates whether tab key presses should be consumed.
44
+ * @default false
45
+ */
31
46
  consumeTabs?: boolean;
47
+ /**
48
+ * Indicates whether the user has permission to edit.
49
+ * @default false
50
+ */
51
+ hasEditPermission?: boolean;
52
+ /**
53
+ * Function to request edit permission.
54
+ */
55
+ requestEditPermission?: () => void;
32
56
  }
33
57
  export type TaskAndDecisionsSharedState = {
34
58
  focusedTaskItemLocalId: string | null;
35
59
  indentDisabled: boolean;
36
60
  outdentDisabled: boolean;
37
61
  isInsideTask: boolean;
62
+ hasEditPermission?: boolean;
38
63
  };
39
64
  export type TasksAndDecisionsPlugin = NextEditorPlugin<'taskDecision', {
40
65
  pluginConfiguration: TaskDecisionPluginOptions | undefined;
@@ -4,4 +4,4 @@ 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
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): SafePlugin<any>;
7
+ export declare function createPlugin(portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, dispatch: Dispatch, api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined, useLongPressSelection?: boolean, hasEditPermission?: boolean): SafePlugin<any>;
@@ -26,15 +26,40 @@ export type AddItemTransactionCreator = (opts: {
26
26
  itemLocalId: string;
27
27
  itemAttrs?: AddItemAttrs;
28
28
  }) => Transaction | null;
29
+ /**
30
+ * Interface representing the options for the TaskDecisionPlugin.
31
+ * Extends the LongPressSelectionPluginOptions interface.
32
+ */
33
+ /**
34
+ * Represents the options for the TaskDecisionPlugin.
35
+ */
29
36
  export interface TaskDecisionPluginOptions extends LongPressSelectionPluginOptions {
37
+ /**
38
+ * Indicates whether nested tasks are allowed.
39
+ * @default false
40
+ */
30
41
  allowNestedTasks?: boolean;
42
+ /**
43
+ * Indicates whether tab key presses should be consumed.
44
+ * @default false
45
+ */
31
46
  consumeTabs?: boolean;
47
+ /**
48
+ * Indicates whether the user has permission to edit.
49
+ * @default false
50
+ */
51
+ hasEditPermission?: boolean;
52
+ /**
53
+ * Function to request edit permission.
54
+ */
55
+ requestEditPermission?: () => void;
32
56
  }
33
57
  export type TaskAndDecisionsSharedState = {
34
58
  focusedTaskItemLocalId: string | null;
35
59
  indentDisabled: boolean;
36
60
  outdentDisabled: boolean;
37
61
  isInsideTask: boolean;
62
+ hasEditPermission?: boolean;
38
63
  };
39
64
  export type TasksAndDecisionsPlugin = NextEditorPlugin<'taskDecision', {
40
65
  pluginConfiguration: TaskDecisionPluginOptions | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-tasks-and-decisions",
3
- "version": "2.4.7",
3
+ "version": "2.5.0",
4
4
  "description": "Tasks and decisions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,12 +34,13 @@
34
34
  "@atlaskit/adf-schema": "^40.9.0",
35
35
  "@atlaskit/analytics-namespaced-context": "^6.12.0",
36
36
  "@atlaskit/analytics-next": "^10.1.0",
37
- "@atlaskit/editor-common": "^89.0.0",
37
+ "@atlaskit/editor-common": "^89.1.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^1.8.0",
39
39
  "@atlaskit/editor-plugin-context-identifier": "^1.3.0",
40
40
  "@atlaskit/editor-plugin-type-ahead": "^1.8.0",
41
41
  "@atlaskit/editor-prosemirror": "6.0.0",
42
- "@atlaskit/icon": "^22.16.0",
42
+ "@atlaskit/icon": "^22.18.0",
43
+ "@atlaskit/platform-feature-flags": "0.3.0",
43
44
  "@atlaskit/prosemirror-input-rules": "^3.2.0",
44
45
  "@atlaskit/task-decision": "^17.10.0",
45
46
  "@atlaskit/tmp-editor-statsig": "^2.1.8",
@@ -94,5 +95,10 @@
94
95
  "import-no-extraneous-disable-for-examples-and-docs"
95
96
  ]
96
97
  }
98
+ },
99
+ "platform-feature-flags": {
100
+ "editor_request_to_edit_task": {
101
+ "type": "boolean"
102
+ }
97
103
  }
98
104
  }