@atlaskit/editor-plugin-tasks-and-decisions 2.6.9 → 2.7.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,19 @@
1
1
  # @atlaskit/editor-plugin-tasks-and-decisions
2
2
 
3
+ ## 2.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#146446](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/146446)
8
+ [`725ff855c13b6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/725ff855c13b6) -
9
+ ED-24965 Adds new command to update hasEditPermission from outside plugin
10
+
11
+ ## 2.6.10
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 2.6.9
4
18
 
5
19
  ### Patch Changes
@@ -160,6 +160,16 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
160
160
  requestToEditContent: pluginState === null || pluginState === void 0 ? void 0 : pluginState.requestToEditContent
161
161
  };
162
162
  },
163
+ commands: {
164
+ updateEditPermission: function updateEditPermission(hasEditPermission) {
165
+ return function (_ref3) {
166
+ var tr = _ref3.tr;
167
+ return tr.setMeta(_pluginKey.stateKey, {
168
+ hasEditPermission: hasEditPermission
169
+ });
170
+ };
171
+ }
172
+ },
163
173
  actions: {
164
174
  insertTaskDecision: (0, _commands.insertTaskDecisionCommand)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, getIdentifierProvider),
165
175
  indentTaskList: (0, _keymaps.getIndentCommand)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
@@ -168,33 +178,33 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
168
178
  pmPlugins: function pmPlugins() {
169
179
  return [{
170
180
  name: 'tasksAndDecisions',
171
- plugin: function plugin(_ref3) {
172
- var portalProviderAPI = _ref3.portalProviderAPI,
173
- providerFactory = _ref3.providerFactory,
174
- eventDispatcher = _ref3.eventDispatcher,
175
- dispatch = _ref3.dispatch;
181
+ plugin: function plugin(_ref4) {
182
+ var portalProviderAPI = _ref4.portalProviderAPI,
183
+ providerFactory = _ref4.providerFactory,
184
+ eventDispatcher = _ref4.eventDispatcher,
185
+ dispatch = _ref4.dispatch;
176
186
  return (0, _main.createPlugin)(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection, hasEditPermission, requestToEditContent);
177
187
  }
178
188
  }, {
179
189
  name: 'tasksAndDecisionsInputRule',
180
- plugin: function plugin(_ref4) {
190
+ plugin: function plugin(_ref5) {
181
191
  var _api$analytics4;
182
- var schema = _ref4.schema,
183
- featureFlags = _ref4.featureFlags;
192
+ var schema = _ref5.schema,
193
+ featureFlags = _ref5.featureFlags;
184
194
  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);
185
195
  }
186
196
  }, {
187
197
  name: 'tasksAndDecisionsKeyMap',
188
- plugin: function plugin(_ref5) {
189
- var schema = _ref5.schema;
198
+ plugin: function plugin(_ref6) {
199
+ var schema = _ref6.schema;
190
200
  return (0, _keymaps.default)(schema, api, allowNestedTasks, consumeTabs);
191
201
  }
192
202
  } // Needs to be after "save-on-enter"
193
203
  ];
194
204
  },
195
- secondaryToolbarComponent: function secondaryToolbarComponent(_ref6) {
196
- var editorView = _ref6.editorView,
197
- disabled = _ref6.disabled;
205
+ secondaryToolbarComponent: function secondaryToolbarComponent(_ref7) {
206
+ var editorView = _ref7.editorView,
207
+ disabled = _ref7.disabled;
198
208
  return (0, _react.jsx)("div", {
199
209
  css: taskDecisionToolbarGroupStyles
200
210
  }, (0, _react.jsx)(_ToolbarDecision.default, {
@@ -210,8 +220,8 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
210
220
  }));
211
221
  },
212
222
  pluginsOptions: {
213
- quickInsert: function quickInsert(_ref7) {
214
- var formatMessage = _ref7.formatMessage;
223
+ quickInsert: function quickInsert(_ref8) {
224
+ var formatMessage = _ref8.formatMessage;
215
225
  return [{
216
226
  id: 'action',
217
227
  title: formatMessage(_messages.toolbarInsertBlockMessages.action),
@@ -13,6 +13,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
13
13
  var _selection = require("@atlaskit/editor-common/selection");
14
14
  var _utils = require("@atlaskit/editor-common/utils");
15
15
  var _state = require("@atlaskit/editor-prosemirror/state");
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
17
  var _decisionLazyNodeView = require("../nodeviews/decision-lazy-node-view");
17
18
  var _taskLazyNodeView = require("../nodeviews/task-lazy-node-view");
18
19
  var _helpers = require("./helpers");
@@ -172,13 +173,16 @@ function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispa
172
173
  };
173
174
  },
174
175
  apply: function apply(tr, pluginState) {
175
- var _ref = tr.getMeta(_pluginKey.stateKey) || {
176
+ var metaData = tr.getMeta(_pluginKey.stateKey);
177
+ var _ref = metaData || {
176
178
  action: null,
177
179
  data: null
178
180
  },
179
181
  action = _ref.action,
180
182
  data = _ref.data;
181
183
  var newPluginState = pluginState;
184
+
185
+ // Actions
182
186
  switch (action) {
183
187
  case _types.ACTIONS.FOCUS_BY_LOCALID:
184
188
  newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
@@ -186,6 +190,15 @@ function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispa
186
190
  });
187
191
  break;
188
192
  }
193
+
194
+ // Commands
195
+ if (metaData && 'hasEditPermission' in metaData && (0, _platformFeatureFlags.fg)('editor_request_to_edit_task')) {
196
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
197
+ hasEditPermission: metaData.hasEditPermission
198
+ });
199
+ }
200
+
201
+ // Dispatch
189
202
  dispatch(_pluginKey.stateKey, newPluginState);
190
203
  return newPluginState;
191
204
  }
@@ -152,6 +152,13 @@ export const tasksAndDecisionsPlugin = ({
152
152
  requestToEditContent: pluginState === null || pluginState === void 0 ? void 0 : pluginState.requestToEditContent
153
153
  };
154
154
  },
155
+ commands: {
156
+ updateEditPermission: hasEditPermission => ({
157
+ tr
158
+ }) => tr.setMeta(taskPluginKey, {
159
+ hasEditPermission
160
+ })
161
+ },
155
162
  actions: {
156
163
  insertTaskDecision: insertTaskDecisionCommand(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, getIdentifierProvider),
157
164
  indentTaskList: getIndentCommand(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
@@ -4,6 +4,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { createSelectionClickHandler, GapCursorSelection } from '@atlaskit/editor-common/selection';
5
5
  import { getStepRange } from '@atlaskit/editor-common/utils';
6
6
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { lazyDecisionView } from '../nodeviews/decision-lazy-node-view';
8
9
  import { lazyTaskView } from '../nodeviews/task-lazy-node-view';
9
10
  import { focusCheckboxAndUpdateSelection, getTaskItemDataAtPos, getTaskItemDataToFocus, removeCheckboxFocus } from './helpers';
@@ -165,14 +166,17 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
165
166
  };
166
167
  },
167
168
  apply(tr, pluginState) {
169
+ const metaData = tr.getMeta(stateKey);
168
170
  const {
169
171
  action,
170
172
  data
171
- } = tr.getMeta(stateKey) || {
173
+ } = metaData || {
172
174
  action: null,
173
175
  data: null
174
176
  };
175
177
  let newPluginState = pluginState;
178
+
179
+ // Actions
176
180
  switch (action) {
177
181
  case ACTIONS.FOCUS_BY_LOCALID:
178
182
  newPluginState = {
@@ -181,6 +185,16 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
181
185
  };
182
186
  break;
183
187
  }
188
+
189
+ // Commands
190
+ if (metaData && 'hasEditPermission' in metaData && fg('editor_request_to_edit_task')) {
191
+ newPluginState = {
192
+ ...newPluginState,
193
+ hasEditPermission: metaData.hasEditPermission
194
+ };
195
+ }
196
+
197
+ // Dispatch
184
198
  dispatch(stateKey, newPluginState);
185
199
  return newPluginState;
186
200
  }
@@ -152,6 +152,16 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
152
152
  requestToEditContent: pluginState === null || pluginState === void 0 ? void 0 : pluginState.requestToEditContent
153
153
  };
154
154
  },
155
+ commands: {
156
+ updateEditPermission: function updateEditPermission(hasEditPermission) {
157
+ return function (_ref3) {
158
+ var tr = _ref3.tr;
159
+ return tr.setMeta(taskPluginKey, {
160
+ hasEditPermission: hasEditPermission
161
+ });
162
+ };
163
+ }
164
+ },
155
165
  actions: {
156
166
  insertTaskDecision: insertTaskDecisionCommand(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, getIdentifierProvider),
157
167
  indentTaskList: getIndentCommand(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
@@ -160,33 +170,33 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
160
170
  pmPlugins: function pmPlugins() {
161
171
  return [{
162
172
  name: 'tasksAndDecisions',
163
- plugin: function plugin(_ref3) {
164
- var portalProviderAPI = _ref3.portalProviderAPI,
165
- providerFactory = _ref3.providerFactory,
166
- eventDispatcher = _ref3.eventDispatcher,
167
- dispatch = _ref3.dispatch;
173
+ plugin: function plugin(_ref4) {
174
+ var portalProviderAPI = _ref4.portalProviderAPI,
175
+ providerFactory = _ref4.providerFactory,
176
+ eventDispatcher = _ref4.eventDispatcher,
177
+ dispatch = _ref4.dispatch;
168
178
  return createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection, hasEditPermission, requestToEditContent);
169
179
  }
170
180
  }, {
171
181
  name: 'tasksAndDecisionsInputRule',
172
- plugin: function plugin(_ref4) {
182
+ plugin: function plugin(_ref5) {
173
183
  var _api$analytics4;
174
- var schema = _ref4.schema,
175
- featureFlags = _ref4.featureFlags;
184
+ var schema = _ref5.schema,
185
+ featureFlags = _ref5.featureFlags;
176
186
  return inputRulePlugin(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, getIdentifierProvider)(schema, featureFlags);
177
187
  }
178
188
  }, {
179
189
  name: 'tasksAndDecisionsKeyMap',
180
- plugin: function plugin(_ref5) {
181
- var schema = _ref5.schema;
190
+ plugin: function plugin(_ref6) {
191
+ var schema = _ref6.schema;
182
192
  return keymap(schema, api, allowNestedTasks, consumeTabs);
183
193
  }
184
194
  } // Needs to be after "save-on-enter"
185
195
  ];
186
196
  },
187
- secondaryToolbarComponent: function secondaryToolbarComponent(_ref6) {
188
- var editorView = _ref6.editorView,
189
- disabled = _ref6.disabled;
197
+ secondaryToolbarComponent: function secondaryToolbarComponent(_ref7) {
198
+ var editorView = _ref7.editorView,
199
+ disabled = _ref7.disabled;
190
200
  return jsx("div", {
191
201
  css: taskDecisionToolbarGroupStyles
192
202
  }, jsx(ToolbarDecision, {
@@ -202,8 +212,8 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
202
212
  }));
203
213
  },
204
214
  pluginsOptions: {
205
- quickInsert: function quickInsert(_ref7) {
206
- var formatMessage = _ref7.formatMessage;
215
+ quickInsert: function quickInsert(_ref8) {
216
+ var formatMessage = _ref8.formatMessage;
207
217
  return [{
208
218
  id: 'action',
209
219
  title: formatMessage(insertBlockMessages.action),
@@ -9,6 +9,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
9
9
  import { createSelectionClickHandler, GapCursorSelection } from '@atlaskit/editor-common/selection';
10
10
  import { getStepRange } from '@atlaskit/editor-common/utils';
11
11
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
12
+ import { fg } from '@atlaskit/platform-feature-flags';
12
13
  import { lazyDecisionView } from '../nodeviews/decision-lazy-node-view';
13
14
  import { lazyTaskView } from '../nodeviews/task-lazy-node-view';
14
15
  import { focusCheckboxAndUpdateSelection, getTaskItemDataAtPos, getTaskItemDataToFocus, removeCheckboxFocus } from './helpers';
@@ -165,13 +166,16 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
165
166
  };
166
167
  },
167
168
  apply: function apply(tr, pluginState) {
168
- var _ref = tr.getMeta(stateKey) || {
169
+ var metaData = tr.getMeta(stateKey);
170
+ var _ref = metaData || {
169
171
  action: null,
170
172
  data: null
171
173
  },
172
174
  action = _ref.action,
173
175
  data = _ref.data;
174
176
  var newPluginState = pluginState;
177
+
178
+ // Actions
175
179
  switch (action) {
176
180
  case ACTIONS.FOCUS_BY_LOCALID:
177
181
  newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
@@ -179,6 +183,15 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
179
183
  });
180
184
  break;
181
185
  }
186
+
187
+ // Commands
188
+ if (metaData && 'hasEditPermission' in metaData && fg('editor_request_to_edit_task')) {
189
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
190
+ hasEditPermission: metaData.hasEditPermission
191
+ });
192
+ }
193
+
194
+ // Dispatch
182
195
  dispatch(stateKey, newPluginState);
183
196
  return newPluginState;
184
197
  }
@@ -1,7 +1,7 @@
1
1
  import type { DecisionItemDefinition, TaskItemDefinition } from '@atlaskit/adf-schema';
2
2
  import type { INPUT_METHOD, USER_CONTEXT } from '@atlaskit/editor-common/analytics';
3
3
  import type { ContextIdentifierProvider } from '@atlaskit/editor-common/provider-factory';
4
- import type { LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
4
+ import type { EditorCommand, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
5
5
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
6
  import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
7
7
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
@@ -74,5 +74,8 @@ export type TasksAndDecisionsPlugin = NextEditorPlugin<'taskDecision', {
74
74
  indentTaskList: ReturnType<typeof getIndentCommand>;
75
75
  outdentTaskList: ReturnType<typeof getUnindentCommand>;
76
76
  };
77
+ commands: {
78
+ updateEditPermission: (hasEditPermission: boolean | undefined) => EditorCommand;
79
+ };
77
80
  }>;
78
81
  export type GetContextIdentifier = () => ContextIdentifierProvider | undefined;
@@ -1,7 +1,7 @@
1
1
  import type { DecisionItemDefinition, TaskItemDefinition } from '@atlaskit/adf-schema';
2
2
  import type { INPUT_METHOD, USER_CONTEXT } from '@atlaskit/editor-common/analytics';
3
3
  import type { ContextIdentifierProvider } from '@atlaskit/editor-common/provider-factory';
4
- import type { LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
4
+ import type { EditorCommand, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
5
5
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
6
  import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
7
7
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
@@ -74,5 +74,8 @@ export type TasksAndDecisionsPlugin = NextEditorPlugin<'taskDecision', {
74
74
  indentTaskList: ReturnType<typeof getIndentCommand>;
75
75
  outdentTaskList: ReturnType<typeof getUnindentCommand>;
76
76
  };
77
+ commands: {
78
+ updateEditPermission: (hasEditPermission: boolean | undefined) => EditorCommand;
79
+ };
77
80
  }>;
78
81
  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": "2.6.9",
3
+ "version": "2.7.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,14 +34,14 @@
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": "^91.1.0",
37
+ "@atlaskit/editor-common": "^91.2.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-editor-viewmode": "2.1.7",
41
41
  "@atlaskit/editor-plugin-type-ahead": "^1.8.0",
42
42
  "@atlaskit/editor-prosemirror": "6.0.0",
43
43
  "@atlaskit/heading": "2.4.6",
44
- "@atlaskit/icon": "22.18.1",
44
+ "@atlaskit/icon": "22.19.0",
45
45
  "@atlaskit/platform-feature-flags": "^0.3.0",
46
46
  "@atlaskit/popup": "1.27.2",
47
47
  "@atlaskit/primitives": "12.2.2",