@atlaskit/editor-plugin-tasks-and-decisions 9.1.17 → 9.1.19

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,21 @@
1
1
  # @atlaskit/editor-plugin-tasks-and-decisions
2
2
 
3
+ ## 9.1.19
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e3779b75fdeca`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e3779b75fdeca) -
8
+ EDITOR-1643 Promote syncBlock and bodiedSyncBlock to full schema
9
+ - Updated dependencies
10
+
11
+ ## 9.1.18
12
+
13
+ ### Patch Changes
14
+
15
+ - [`55920a92e882a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/55920a92e882a) -
16
+ tsignores added for help-center local consumpton removed
17
+ - Updated dependencies
18
+
3
19
  ## 9.1.17
4
20
 
5
21
  ### Patch Changes
@@ -31,9 +31,6 @@ function nodesBetweenChanged(tr, f, startPos) {
31
31
  if (!stepRange) {
32
32
  return;
33
33
  }
34
-
35
- // @ts-ignore - Workaround for help-center local consumption
36
-
37
34
  tr.doc.nodesBetween(stepRange.from, stepRange.to, f, startPos);
38
35
  }
39
36
 
@@ -46,8 +43,6 @@ function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api, getIntl
46
43
  var taskPlaceholder = arguments.length > 9 ? arguments[9] : undefined;
47
44
  return new _safePlugin.SafePlugin({
48
45
  props: {
49
- // @ts-ignore - Workaround for help-center local consumption
50
-
51
46
  nodeViews: _objectSpread({
52
47
  taskItem: (0, _taskNodeView.taskView)(api, getIntl(), taskPlaceholder),
53
48
  decisionItem: function (node) {
@@ -56,7 +51,6 @@ function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api, getIntl
56
51
  }, (0, _expValEquals.expValEquals)('platform_editor_blocktaskitem_node_tenantid', 'isEnabled', true) ? {
57
52
  blockTaskItem: (0, _taskNodeView.taskView)(api, getIntl(), taskPlaceholder)
58
53
  } : {}),
59
- // @ts-ignore - Workaround for help-center local consumption
60
54
  decorations: function decorations(state) {
61
55
  var pluginState = _pluginKey.stateKey.getState(state);
62
56
  if (pluginState !== null && pluginState !== void 0 && pluginState.decorations) {
@@ -64,7 +58,6 @@ function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api, getIntl
64
58
  }
65
59
  return _view.DecorationSet.empty;
66
60
  },
67
- // @ts-ignore - Workaround for help-center local consumption
68
61
  handleTextInput: function handleTextInput(view, from, to, text) {
69
62
  // When a decision item is selected and the user starts typing, the entire node
70
63
  // should be replaced with what was just typed. This custom text input handler
@@ -88,15 +81,11 @@ function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api, getIntl
88
81
  }, {
89
82
  useLongPressSelection: useLongPressSelection
90
83
  }),
91
- // @ts-ignore - Workaround for help-center local consumption
92
-
93
84
  handleDOMEvents: {
94
85
  // When the page is lazy loaded and task item is not yet available this allows
95
86
  // our toDOM implementation to toggle the node state
96
87
  change: _taskItemOnChange.taskItemOnChange
97
88
  },
98
- // @ts-ignore - Workaround for help-center local consumption
99
-
100
89
  handleKeyDown: function handleKeyDown(view, event) {
101
90
  var state = view.state;
102
91
  var selection = state.selection,
@@ -189,8 +178,6 @@ function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api, getIntl
189
178
  }
190
179
  }
191
180
  },
192
- // @ts-ignore - Workaround for help-center local consumption
193
-
194
181
  transformPasted: function transformPasted(slice, view) {
195
182
  var _view$state;
196
183
  if (Boolean(view === null || view === void 0 || (_view$state = view.state) === null || _view$state === void 0 || (_view$state = _view$state.schema) === null || _view$state === void 0 || (_view$state = _view$state.nodes) === null || _view$state === void 0 ? void 0 : _view$state.blockTaskItem)) {
@@ -200,7 +187,6 @@ function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api, getIntl
200
187
  }
201
188
  },
202
189
  state: {
203
- // @ts-ignore - Workaround for help-center local consumption
204
190
  init: function init() {
205
191
  return {
206
192
  insideTaskDecisionItem: false,
@@ -212,7 +198,6 @@ function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api, getIntl
212
198
  decorations: _view.DecorationSet.empty
213
199
  };
214
200
  },
215
- // @ts-ignore - Workaround for help-center local consumption
216
201
  apply: function apply(tr, pluginState) {
217
202
  var metaData = tr.getMeta(_pluginKey.stateKey);
218
203
  var _ref = metaData !== null && metaData !== void 0 ? metaData : {
@@ -264,8 +249,6 @@ function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api, getIntl
264
249
  })]);
265
250
  } else {
266
251
  var _newPluginState$decor;
267
- // @ts-ignore - Workaround for help-center local consumption
268
-
269
252
  decorations = (_newPluginState$decor = newPluginState.decorations) === null || _newPluginState$decor === void 0 ? void 0 : _newPluginState$decor.map(tr.mapping, tr.doc);
270
253
  }
271
254
  var newState = _objectSpread(_objectSpread({}, newPluginState), {}, {
@@ -284,13 +267,9 @@ function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api, getIntl
284
267
  *
285
268
  * Note: we currently do not handle the edge case where two nodes may have the same localId
286
269
  */
287
- // @ts-ignore - Workaround for help-center local consumption
288
-
289
270
  appendTransaction: function appendTransaction(transactions, _oldState, newState) {
290
271
  var tr = newState.tr;
291
272
  var modified = false;
292
- // @ts-ignore - Workaround for help-center local consumption
293
-
294
273
  transactions.forEach(function (transaction) {
295
274
  if (!transaction.docChanged) {
296
275
  return;
@@ -32,6 +32,7 @@ var _keymaps = _interopRequireWildcard(require("./pm-plugins/keymaps"));
32
32
  var _main = require("./pm-plugins/main");
33
33
  var _pluginKey = require("./pm-plugins/plugin-key");
34
34
  var _toggleTasklistCommands = require("./pm-plugins/toggle-tasklist-commands");
35
+ var _DecisionListBlockMenuItem = require("./ui/DecisionListBlockMenuItem/DecisionListBlockMenuItem");
35
36
  var _RequestToEditPopup = require("./ui/Task/RequestToEditPopup");
36
37
  var _TaskListBlockMenuItem = require("./ui/TaskListBlockMenuItem/TaskListBlockMenuItem");
37
38
  var _toolbarComponents = require("./ui/toolbar-components");
@@ -139,6 +140,19 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
139
140
  api: api
140
141
  });
141
142
  }
143
+ }, {
144
+ type: 'block-menu-item',
145
+ key: _blockMenu.TRANSFORM_STRUCTURE_DECISION_MENU_ITEM.key,
146
+ parent: {
147
+ type: 'block-menu-section',
148
+ key: _blockMenu.TRANSFORM_STRUCTURE_MENU_SECTION.key,
149
+ rank: _blockMenu.TRANSFORM_STRUCTURE_MENU_SECTION_RANK[_blockMenu.TRANSFORM_STRUCTURE_DECISION_MENU_ITEM.key]
150
+ },
151
+ component: function component() {
152
+ return /*#__PURE__*/React.createElement(_DecisionListBlockMenuItem.DecisionListBlockMenuItem, {
153
+ api: api
154
+ });
155
+ }
142
156
  }]);
143
157
  }
144
158
  return {
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.DecisionListBlockMenuItem = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _reactIntlNext = require("react-intl-next");
11
+ var _analytics = require("@atlaskit/editor-common/analytics");
12
+ var _hooks = require("@atlaskit/editor-common/hooks");
13
+ var _messages = require("@atlaskit/editor-common/messages");
14
+ var _editorToolbar = require("@atlaskit/editor-toolbar");
15
+ var _decision = _interopRequireDefault(require("@atlaskit/icon/core/decision"));
16
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
17
+ var DecisionListBlockMenuItem = exports.DecisionListBlockMenuItem = function DecisionListBlockMenuItem(_ref) {
18
+ var api = _ref.api;
19
+ var _useIntl = (0, _reactIntlNext.useIntl)(),
20
+ formatMessage = _useIntl.formatMessage;
21
+ var selection = (0, _hooks.useSharedPluginStateWithSelector)(api, ['selection'], function (states) {
22
+ var _states$selectionStat;
23
+ return (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection;
24
+ });
25
+ var isSelected = (0, _react.useMemo)(function () {
26
+ return selection && selection.$from.parent.type.name === 'decisionItem';
27
+ }, [selection]);
28
+ var onClick = function onClick(event) {
29
+ var triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? _analytics.INPUT_METHOD.KEYBOARD : _analytics.INPUT_METHOD.MOUSE;
30
+ var inputMethod = _analytics.INPUT_METHOD.BLOCK_MENU;
31
+ api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
32
+ var _api$blockMenu;
33
+ var tr = _ref2.tr;
34
+ var command = api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.transformNode(tr.doc.type.schema.nodes.decisionList, {
35
+ inputMethod: inputMethod,
36
+ triggeredFrom: triggeredFrom,
37
+ targetTypeName: 'decisionList'
38
+ });
39
+ return command ? command({
40
+ tr: tr
41
+ }) : null;
42
+ });
43
+ };
44
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
45
+ isSelected: isSelected,
46
+ onClick: onClick,
47
+ elemBefore: /*#__PURE__*/_react.default.createElement(_decision.default, {
48
+ label: ""
49
+ })
50
+ }, formatMessage(_messages.blockMenuMessages.decisionList));
51
+ };
@@ -9,8 +9,8 @@ exports.TaskListBlockMenuItem = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _reactIntlNext = require("react-intl-next");
11
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
+ var _hooks = require("@atlaskit/editor-common/hooks");
12
13
  var _messages = require("@atlaskit/editor-common/messages");
13
- var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
14
14
  var _editorToolbar = require("@atlaskit/editor-toolbar");
15
15
  var _task = _interopRequireDefault(require("@atlaskit/icon/core/task"));
16
16
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -18,7 +18,10 @@ var TaskListBlockMenuItem = exports.TaskListBlockMenuItem = function TaskListBlo
18
18
  var api = _ref.api;
19
19
  var _useIntl = (0, _reactIntlNext.useIntl)(),
20
20
  formatMessage = _useIntl.formatMessage;
21
- var selection = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
21
+ var selection = (0, _hooks.useSharedPluginStateWithSelector)(api, ['selection'], function (states) {
22
+ var _states$selectionStat;
23
+ return (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection;
24
+ });
22
25
  var isSelected = (0, _react.useMemo)(function () {
23
26
  return selection && selection.$from.parent.type.name === 'taskItem';
24
27
  }, [selection]);
@@ -19,9 +19,6 @@ function nodesBetweenChanged(tr, f, startPos) {
19
19
  if (!stepRange) {
20
20
  return;
21
21
  }
22
-
23
- // @ts-ignore - Workaround for help-center local consumption
24
-
25
22
  tr.doc.nodesBetween(stepRange.from, stepRange.to, f, startPos);
26
23
  }
27
24
 
@@ -29,8 +26,6 @@ function nodesBetweenChanged(tr, f, startPos) {
29
26
  export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api, getIntl, useLongPressSelection = false, hasEditPermission, hasRequestedEditPermission, requestToEditContent, taskPlaceholder) {
30
27
  return new SafePlugin({
31
28
  props: {
32
- // @ts-ignore - Workaround for help-center local consumption
33
-
34
29
  nodeViews: {
35
30
  taskItem: taskView(api, getIntl(), taskPlaceholder),
36
31
  decisionItem: node => {
@@ -40,8 +35,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
40
35
  blockTaskItem: taskView(api, getIntl(), taskPlaceholder)
41
36
  } : {})
42
37
  },
43
- // @ts-ignore - Workaround for help-center local consumption
44
-
45
38
  decorations(state) {
46
39
  const pluginState = stateKey.getState(state);
47
40
  if (pluginState !== null && pluginState !== void 0 && pluginState.decorations) {
@@ -49,8 +42,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
49
42
  }
50
43
  return DecorationSet.empty;
51
44
  },
52
- // @ts-ignore - Workaround for help-center local consumption
53
-
54
45
  handleTextInput(view, from, to, text) {
55
46
  // When a decision item is selected and the user starts typing, the entire node
56
47
  // should be replaced with what was just typed. This custom text input handler
@@ -76,15 +67,11 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
76
67
  handleClickOn: createSelectionClickHandler(['decisionItem', 'taskItem'], target => target.hasAttribute('data-decision-wrapper') || target.getAttribute('aria-label') === 'Decision', {
77
68
  useLongPressSelection
78
69
  }),
79
- // @ts-ignore - Workaround for help-center local consumption
80
-
81
70
  handleDOMEvents: {
82
71
  // When the page is lazy loaded and task item is not yet available this allows
83
72
  // our toDOM implementation to toggle the node state
84
73
  change: taskItemOnChange
85
74
  },
86
- // @ts-ignore - Workaround for help-center local consumption
87
-
88
75
  handleKeyDown: (view, event) => {
89
76
  const {
90
77
  state
@@ -183,8 +170,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
183
170
  }
184
171
  }
185
172
  },
186
- // @ts-ignore - Workaround for help-center local consumption
187
-
188
173
  transformPasted: (slice, view) => {
189
174
  var _view$state, _view$state$schema, _view$state$schema$no;
190
175
  if (Boolean(view === null || view === void 0 ? void 0 : (_view$state = view.state) === null || _view$state === void 0 ? void 0 : (_view$state$schema = _view$state.schema) === null || _view$state$schema === void 0 ? void 0 : (_view$state$schema$no = _view$state$schema.nodes) === null || _view$state$schema$no === void 0 ? void 0 : _view$state$schema$no.blockTaskItem)) {
@@ -194,8 +179,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
194
179
  }
195
180
  },
196
181
  state: {
197
- // @ts-ignore - Workaround for help-center local consumption
198
-
199
182
  init() {
200
183
  return {
201
184
  insideTaskDecisionItem: false,
@@ -207,8 +190,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
207
190
  decorations: DecorationSet.empty
208
191
  };
209
192
  },
210
- // @ts-ignore - Workaround for help-center local consumption
211
-
212
193
  apply(tr, pluginState) {
213
194
  const metaData = tr.getMeta(stateKey);
214
195
  const {
@@ -263,8 +244,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
263
244
  })]);
264
245
  } else {
265
246
  var _newPluginState$decor;
266
- // @ts-ignore - Workaround for help-center local consumption
267
-
268
247
  decorations = (_newPluginState$decor = newPluginState.decorations) === null || _newPluginState$decor === void 0 ? void 0 : _newPluginState$decor.map(tr.mapping, tr.doc);
269
248
  }
270
249
  const newState = {
@@ -284,13 +263,9 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
284
263
  *
285
264
  * Note: we currently do not handle the edge case where two nodes may have the same localId
286
265
  */
287
- // @ts-ignore - Workaround for help-center local consumption
288
-
289
266
  appendTransaction: (transactions, _oldState, newState) => {
290
267
  const tr = newState.tr;
291
268
  let modified = false;
292
- // @ts-ignore - Workaround for help-center local consumption
293
-
294
269
  transactions.forEach(transaction => {
295
270
  if (!transaction.docChanged) {
296
271
  return;
@@ -4,7 +4,7 @@ import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
5
5
  import { decisionList, taskList } from '@atlaskit/adf-schema';
6
6
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
7
- import { TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM, TRANSFORM_STRUCTURE_MENU_SECTION_RANK } from '@atlaskit/editor-common/block-menu';
7
+ import { TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM, TRANSFORM_STRUCTURE_MENU_SECTION_RANK, TRANSFORM_STRUCTURE_DECISION_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
8
8
  import { MAX_INDENTATION_LEVEL } from '@atlaskit/editor-common/indentation';
9
9
  import { toolbarInsertBlockMessages as insertBlockMessages } from '@atlaskit/editor-common/messages';
10
10
  import { IconAction, IconDecision } from '@atlaskit/editor-common/quick-insert';
@@ -23,6 +23,7 @@ import keymap, { getIndentCommand, getUnindentCommand } from './pm-plugins/keyma
23
23
  import { createPlugin } from './pm-plugins/main';
24
24
  import { stateKey as taskPluginKey } from './pm-plugins/plugin-key';
25
25
  import { toggleTaskList } from './pm-plugins/toggle-tasklist-commands';
26
+ import { DecisionListBlockMenuItem } from './ui/DecisionListBlockMenuItem/DecisionListBlockMenuItem';
26
27
  import { RequestToEditPopup } from './ui/Task/RequestToEditPopup';
27
28
  import { TaskListBlockMenuItem } from './ui/TaskListBlockMenuItem/TaskListBlockMenuItem';
28
29
  import { getTasksAndDecisionsToolbarComponents } from './ui/toolbar-components';
@@ -125,6 +126,17 @@ export const tasksAndDecisionsPlugin = ({
125
126
  component: () => /*#__PURE__*/React.createElement(TaskListBlockMenuItem, {
126
127
  api: api
127
128
  })
129
+ }, {
130
+ type: 'block-menu-item',
131
+ key: TRANSFORM_STRUCTURE_DECISION_MENU_ITEM.key,
132
+ parent: {
133
+ type: 'block-menu-section',
134
+ key: TRANSFORM_STRUCTURE_MENU_SECTION.key,
135
+ rank: TRANSFORM_STRUCTURE_MENU_SECTION_RANK[TRANSFORM_STRUCTURE_DECISION_MENU_ITEM.key]
136
+ },
137
+ component: () => /*#__PURE__*/React.createElement(DecisionListBlockMenuItem, {
138
+ api: api
139
+ })
128
140
  }]);
129
141
  }
130
142
  return {
@@ -0,0 +1,45 @@
1
+ import React, { useMemo } from 'react';
2
+ import { useIntl } from 'react-intl-next';
3
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
+ import { blockMenuMessages } from '@atlaskit/editor-common/messages';
6
+ import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
7
+ import DecisionIcon from '@atlaskit/icon/core/decision';
8
+ export const DecisionListBlockMenuItem = ({
9
+ api
10
+ }) => {
11
+ const {
12
+ formatMessage
13
+ } = useIntl();
14
+ const selection = useSharedPluginStateWithSelector(api, ['selection'], states => {
15
+ var _states$selectionStat;
16
+ return (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection;
17
+ });
18
+ const isSelected = useMemo(() => {
19
+ return selection && selection.$from.parent.type.name === 'decisionItem';
20
+ }, [selection]);
21
+ const onClick = event => {
22
+ const triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE;
23
+ const inputMethod = INPUT_METHOD.BLOCK_MENU;
24
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(({
25
+ tr
26
+ }) => {
27
+ var _api$blockMenu;
28
+ const command = api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.transformNode(tr.doc.type.schema.nodes.decisionList, {
29
+ inputMethod,
30
+ triggeredFrom,
31
+ targetTypeName: 'decisionList'
32
+ });
33
+ return command ? command({
34
+ tr
35
+ }) : null;
36
+ });
37
+ };
38
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
39
+ isSelected: isSelected,
40
+ onClick: onClick,
41
+ elemBefore: /*#__PURE__*/React.createElement(DecisionIcon, {
42
+ label: ""
43
+ })
44
+ }, formatMessage(blockMenuMessages.decisionList));
45
+ };
@@ -1,8 +1,8 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
5
  import { tasksAndDecisionsMessages } from '@atlaskit/editor-common/messages';
5
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
6
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
7
7
  import TaskIcon from '@atlaskit/icon/core/task';
8
8
  export const TaskListBlockMenuItem = ({
@@ -11,7 +11,10 @@ export const TaskListBlockMenuItem = ({
11
11
  const {
12
12
  formatMessage
13
13
  } = useIntl();
14
- const selection = useSharedPluginStateSelector(api, 'selection.selection');
14
+ const selection = useSharedPluginStateWithSelector(api, ['selection'], states => {
15
+ var _states$selectionStat;
16
+ return (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection;
17
+ });
15
18
  const isSelected = useMemo(() => {
16
19
  return selection && selection.$from.parent.type.name === 'taskItem';
17
20
  }, [selection]);
@@ -24,9 +24,6 @@ function nodesBetweenChanged(tr, f, startPos) {
24
24
  if (!stepRange) {
25
25
  return;
26
26
  }
27
-
28
- // @ts-ignore - Workaround for help-center local consumption
29
-
30
27
  tr.doc.nodesBetween(stepRange.from, stepRange.to, f, startPos);
31
28
  }
32
29
 
@@ -39,8 +36,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
39
36
  var taskPlaceholder = arguments.length > 9 ? arguments[9] : undefined;
40
37
  return new SafePlugin({
41
38
  props: {
42
- // @ts-ignore - Workaround for help-center local consumption
43
-
44
39
  nodeViews: _objectSpread({
45
40
  taskItem: taskView(api, getIntl(), taskPlaceholder),
46
41
  decisionItem: function (node) {
@@ -49,7 +44,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
49
44
  }, expValEquals('platform_editor_blocktaskitem_node_tenantid', 'isEnabled', true) ? {
50
45
  blockTaskItem: taskView(api, getIntl(), taskPlaceholder)
51
46
  } : {}),
52
- // @ts-ignore - Workaround for help-center local consumption
53
47
  decorations: function decorations(state) {
54
48
  var pluginState = stateKey.getState(state);
55
49
  if (pluginState !== null && pluginState !== void 0 && pluginState.decorations) {
@@ -57,7 +51,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
57
51
  }
58
52
  return DecorationSet.empty;
59
53
  },
60
- // @ts-ignore - Workaround for help-center local consumption
61
54
  handleTextInput: function handleTextInput(view, from, to, text) {
62
55
  // When a decision item is selected and the user starts typing, the entire node
63
56
  // should be replaced with what was just typed. This custom text input handler
@@ -81,15 +74,11 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
81
74
  }, {
82
75
  useLongPressSelection: useLongPressSelection
83
76
  }),
84
- // @ts-ignore - Workaround for help-center local consumption
85
-
86
77
  handleDOMEvents: {
87
78
  // When the page is lazy loaded and task item is not yet available this allows
88
79
  // our toDOM implementation to toggle the node state
89
80
  change: taskItemOnChange
90
81
  },
91
- // @ts-ignore - Workaround for help-center local consumption
92
-
93
82
  handleKeyDown: function handleKeyDown(view, event) {
94
83
  var state = view.state;
95
84
  var selection = state.selection,
@@ -182,8 +171,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
182
171
  }
183
172
  }
184
173
  },
185
- // @ts-ignore - Workaround for help-center local consumption
186
-
187
174
  transformPasted: function transformPasted(slice, view) {
188
175
  var _view$state;
189
176
  if (Boolean(view === null || view === void 0 || (_view$state = view.state) === null || _view$state === void 0 || (_view$state = _view$state.schema) === null || _view$state === void 0 || (_view$state = _view$state.nodes) === null || _view$state === void 0 ? void 0 : _view$state.blockTaskItem)) {
@@ -193,7 +180,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
193
180
  }
194
181
  },
195
182
  state: {
196
- // @ts-ignore - Workaround for help-center local consumption
197
183
  init: function init() {
198
184
  return {
199
185
  insideTaskDecisionItem: false,
@@ -205,7 +191,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
205
191
  decorations: DecorationSet.empty
206
192
  };
207
193
  },
208
- // @ts-ignore - Workaround for help-center local consumption
209
194
  apply: function apply(tr, pluginState) {
210
195
  var metaData = tr.getMeta(stateKey);
211
196
  var _ref = metaData !== null && metaData !== void 0 ? metaData : {
@@ -257,8 +242,6 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
257
242
  })]);
258
243
  } else {
259
244
  var _newPluginState$decor;
260
- // @ts-ignore - Workaround for help-center local consumption
261
-
262
245
  decorations = (_newPluginState$decor = newPluginState.decorations) === null || _newPluginState$decor === void 0 ? void 0 : _newPluginState$decor.map(tr.mapping, tr.doc);
263
246
  }
264
247
  var newState = _objectSpread(_objectSpread({}, newPluginState), {}, {
@@ -277,13 +260,9 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
277
260
  *
278
261
  * Note: we currently do not handle the edge case where two nodes may have the same localId
279
262
  */
280
- // @ts-ignore - Workaround for help-center local consumption
281
-
282
263
  appendTransaction: function appendTransaction(transactions, _oldState, newState) {
283
264
  var tr = newState.tr;
284
265
  var modified = false;
285
- // @ts-ignore - Workaround for help-center local consumption
286
-
287
266
  transactions.forEach(function (transaction) {
288
267
  if (!transaction.docChanged) {
289
268
  return;
@@ -7,7 +7,7 @@ import { ax, ix } from "@compiled/react/runtime";
7
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
  import { decisionList, taskList } from '@atlaskit/adf-schema';
9
9
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
10
- import { TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM, TRANSFORM_STRUCTURE_MENU_SECTION_RANK } from '@atlaskit/editor-common/block-menu';
10
+ import { TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_STRUCTURE_TASK_LIST_MENU_ITEM, TRANSFORM_STRUCTURE_MENU_SECTION_RANK, TRANSFORM_STRUCTURE_DECISION_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
11
11
  import { MAX_INDENTATION_LEVEL } from '@atlaskit/editor-common/indentation';
12
12
  import { toolbarInsertBlockMessages as insertBlockMessages } from '@atlaskit/editor-common/messages';
13
13
  import { IconAction, IconDecision } from '@atlaskit/editor-common/quick-insert';
@@ -26,6 +26,7 @@ import keymap, { getIndentCommand, getUnindentCommand } from './pm-plugins/keyma
26
26
  import { createPlugin } from './pm-plugins/main';
27
27
  import { stateKey as taskPluginKey } from './pm-plugins/plugin-key';
28
28
  import { toggleTaskList } from './pm-plugins/toggle-tasklist-commands';
29
+ import { DecisionListBlockMenuItem } from './ui/DecisionListBlockMenuItem/DecisionListBlockMenuItem';
29
30
  import { RequestToEditPopup } from './ui/Task/RequestToEditPopup';
30
31
  import { TaskListBlockMenuItem } from './ui/TaskListBlockMenuItem/TaskListBlockMenuItem';
31
32
  import { getTasksAndDecisionsToolbarComponents } from './ui/toolbar-components';
@@ -130,6 +131,19 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref3) {
130
131
  api: api
131
132
  });
132
133
  }
134
+ }, {
135
+ type: 'block-menu-item',
136
+ key: TRANSFORM_STRUCTURE_DECISION_MENU_ITEM.key,
137
+ parent: {
138
+ type: 'block-menu-section',
139
+ key: TRANSFORM_STRUCTURE_MENU_SECTION.key,
140
+ rank: TRANSFORM_STRUCTURE_MENU_SECTION_RANK[TRANSFORM_STRUCTURE_DECISION_MENU_ITEM.key]
141
+ },
142
+ component: function component() {
143
+ return /*#__PURE__*/React.createElement(DecisionListBlockMenuItem, {
144
+ api: api
145
+ });
146
+ }
133
147
  }]);
134
148
  }
135
149
  return {
@@ -0,0 +1,42 @@
1
+ import React, { useMemo } from 'react';
2
+ import { useIntl } from 'react-intl-next';
3
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
+ import { blockMenuMessages } from '@atlaskit/editor-common/messages';
6
+ import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
7
+ import DecisionIcon from '@atlaskit/icon/core/decision';
8
+ export var DecisionListBlockMenuItem = function DecisionListBlockMenuItem(_ref) {
9
+ var api = _ref.api;
10
+ var _useIntl = useIntl(),
11
+ formatMessage = _useIntl.formatMessage;
12
+ var selection = useSharedPluginStateWithSelector(api, ['selection'], function (states) {
13
+ var _states$selectionStat;
14
+ return (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection;
15
+ });
16
+ var isSelected = useMemo(function () {
17
+ return selection && selection.$from.parent.type.name === 'decisionItem';
18
+ }, [selection]);
19
+ var onClick = function onClick(event) {
20
+ var triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE;
21
+ var inputMethod = INPUT_METHOD.BLOCK_MENU;
22
+ api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
23
+ var _api$blockMenu;
24
+ var tr = _ref2.tr;
25
+ var command = api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.transformNode(tr.doc.type.schema.nodes.decisionList, {
26
+ inputMethod: inputMethod,
27
+ triggeredFrom: triggeredFrom,
28
+ targetTypeName: 'decisionList'
29
+ });
30
+ return command ? command({
31
+ tr: tr
32
+ }) : null;
33
+ });
34
+ };
35
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
36
+ isSelected: isSelected,
37
+ onClick: onClick,
38
+ elemBefore: /*#__PURE__*/React.createElement(DecisionIcon, {
39
+ label: ""
40
+ })
41
+ }, formatMessage(blockMenuMessages.decisionList));
42
+ };
@@ -1,15 +1,18 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
5
  import { tasksAndDecisionsMessages } from '@atlaskit/editor-common/messages';
5
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
6
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
7
7
  import TaskIcon from '@atlaskit/icon/core/task';
8
8
  export var TaskListBlockMenuItem = function TaskListBlockMenuItem(_ref) {
9
9
  var api = _ref.api;
10
10
  var _useIntl = useIntl(),
11
11
  formatMessage = _useIntl.formatMessage;
12
- var selection = useSharedPluginStateSelector(api, 'selection.selection');
12
+ var selection = useSharedPluginStateWithSelector(api, ['selection'], function (states) {
13
+ var _states$selectionStat;
14
+ return (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection;
15
+ });
13
16
  var isSelected = useMemo(function () {
14
17
  return selection && selection.$from.parent.type.name === 'taskItem';
15
18
  }, [selection]);
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { TasksAndDecisionsPlugin } from '../../tasksAndDecisionsPluginType';
4
+ export declare const DecisionListBlockMenuItem: ({ api, }: {
5
+ api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined;
6
+ }) => React.JSX.Element;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { TasksAndDecisionsPlugin } from '../../tasksAndDecisionsPluginType';
4
+ export declare const DecisionListBlockMenuItem: ({ api, }: {
5
+ api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined;
6
+ }) => React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-tasks-and-decisions",
3
- "version": "9.1.17",
3
+ "version": "9.1.19",
4
4
  "description": "Tasks and decisions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,7 +29,7 @@
29
29
  ],
30
30
  "atlaskit:src": "src/index.ts",
31
31
  "dependencies": {
32
- "@atlaskit/adf-schema": "^51.4.0",
32
+ "@atlaskit/adf-schema": "^51.5.1",
33
33
  "@atlaskit/analytics-namespaced-context": "^7.2.0",
34
34
  "@atlaskit/css": "^0.17.0",
35
35
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
@@ -49,14 +49,14 @@
49
49
  "@atlaskit/primitives": "^16.4.0",
50
50
  "@atlaskit/prosemirror-input-rules": "^3.6.0",
51
51
  "@atlaskit/task-decision": "^19.2.0",
52
- "@atlaskit/tmp-editor-statsig": "^14.2.0",
52
+ "@atlaskit/tmp-editor-statsig": "^14.5.0",
53
53
  "@atlaskit/tokens": "^8.4.0",
54
54
  "@babel/runtime": "^7.0.0",
55
55
  "@compiled/react": "^0.18.6",
56
56
  "bind-event-listener": "^3.0.0"
57
57
  },
58
58
  "peerDependencies": {
59
- "@atlaskit/editor-common": "^110.36.0",
59
+ "@atlaskit/editor-common": "^110.38.0",
60
60
  "react": "^18.2.0",
61
61
  "react-dom": "^18.2.0",
62
62
  "react-intl-next": "npm:react-intl@^5.18.1"