@atlaskit/editor-plugin-tasks-and-decisions 18.0.0 → 18.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-plugin-tasks-and-decisions
2
2
 
3
+ ## 18.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4273da2e1a648`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4273da2e1a648) -
8
+ Register native Quick Insert items behind `platform_editor_slash_command`.
9
+ - Updated dependencies
10
+
3
11
  ## 18.0.0
4
12
 
5
13
  ### Patch Changes
@@ -11,10 +11,12 @@ require("./tasksAndDecisionsPlugin.compiled.css");
11
11
  var React = _interopRequireWildcard(require("react"));
12
12
  var _runtime = require("@compiled/react/runtime");
13
13
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
15
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
16
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
16
17
  var _adfSchema = require("@atlaskit/adf-schema");
17
18
  var _analytics = require("@atlaskit/editor-common/analytics");
19
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
18
20
  var _blockMenu = require("@atlaskit/editor-common/block-menu");
19
21
  var _indentation = require("@atlaskit/editor-common/indentation");
20
22
  var _messages = require("@atlaskit/editor-common/messages");
@@ -37,10 +39,12 @@ var _DecisionListBlockMenuItem = require("./ui/DecisionListBlockMenuItem/Decisio
37
39
  var _RequestToEditPopup = require("./ui/Task/RequestToEditPopup");
38
40
  var _TaskListBlockMenuItem = require("./ui/TaskListBlockMenuItem/TaskListBlockMenuItem");
39
41
  var _toolbarComponents = require("./ui/toolbar-components");
42
+ var _getTasksAndDecisionsQuickInsertComponents = require("./ui/quick-insert/getTasksAndDecisionsQuickInsertComponents");
40
43
  var _ToolbarDecision = _interopRequireDefault(require("./ui/ToolbarDecision"));
41
44
  var _ToolbarTask = _interopRequireDefault(require("./ui/ToolbarTask"));
42
45
  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); }
43
- // Ignored via go/ees005
46
+ 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; }
47
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // Ignored via go/ees005
44
48
  // eslint-disable-next-line import/no-named-as-default
45
49
  var taskDecisionToolbarGroupStyles = null;
46
50
  var TASK_LIST_NODE_NAME = 'taskList';
@@ -111,6 +115,14 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
111
115
  };
112
116
  var previousTaskAndDecisionProvider;
113
117
  var isToolbarAIFCEnabled = Boolean(api === null || api === void 0 ? void 0 : api.toolbar);
118
+ var isRegisteredSlashCommandEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command');
119
+ if (isRegisteredSlashCommandEnabled) {
120
+ var _api$uiControlRegistr;
121
+ api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register((0, _getTasksAndDecisionsQuickInsertComponents.getTasksAndDecisionsQuickInsertComponents)({
122
+ api: api,
123
+ quickInsertActionDescription: quickInsertActionDescription
124
+ }));
125
+ }
114
126
  if (isToolbarAIFCEnabled) {
115
127
  var _api$toolbar;
116
128
  api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents((0, _toolbarComponents.getTasksAndDecisionsToolbarComponents)({
@@ -333,7 +345,7 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
333
345
  popupsScrollableElement: popupsScrollableElement
334
346
  });
335
347
  },
336
- pluginsOptions: {
348
+ pluginsOptions: _objectSpread({}, !isRegisteredSlashCommandEnabled && {
337
349
  quickInsert: function quickInsert(_ref13) {
338
350
  var formatMessage = _ref13.formatMessage;
339
351
  return [{
@@ -365,6 +377,6 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
365
377
  }
366
378
  }];
367
379
  }
368
- }
380
+ })
369
381
  };
370
382
  };
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.TasksAndDecisionsQuickInsertMenuItem = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactIntl = require("react-intl");
10
+ var _analytics = require("@atlaskit/editor-common/analytics");
11
+ var _hooks = require("@atlaskit/editor-common/hooks");
12
+ var _messages = require("@atlaskit/editor-common/messages");
13
+ var _assets = require("@atlaskit/editor-common/assets");
14
+ var _menuItem = require("@atlaskit/editor-common/quick-insert/menu-item");
15
+ var _insertCommands = require("../../pm-plugins/insert-commands");
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 TasksAndDecisionsQuickInsertMenuItem = exports.TasksAndDecisionsQuickInsertMenuItem = function TasksAndDecisionsQuickInsertMenuItem(_ref) {
18
+ var api = _ref.api,
19
+ item = _ref.item;
20
+ var _useIntl = (0, _reactIntl.useIntl)(),
21
+ formatMessage = _useIntl.formatMessage;
22
+ var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['contextIdentifier'], function (states) {
23
+ var _states$contextIdenti;
24
+ return {
25
+ contextIdentifierProvider: (_states$contextIdenti = states.contextIdentifierState) === null || _states$contextIdenti === void 0 ? void 0 : _states$contextIdenti.contextIdentifierProvider
26
+ };
27
+ }),
28
+ contextIdentifierProvider = _useSharedPluginState.contextIdentifierProvider;
29
+ var isAction = item === 'taskList';
30
+ var onSelect = (0, _react.useCallback)(function (_ref2) {
31
+ var _api$analytics;
32
+ var editorView = _ref2.editorView,
33
+ insert = _ref2.insert,
34
+ source = _ref2.source;
35
+ var schema = editorView.state.schema;
36
+ var addAndCreateList = function addAndCreateList(_ref3) {
37
+ var listLocalId = _ref3.listLocalId,
38
+ itemLocalId = _ref3.itemLocalId;
39
+ var _getListTypes = (0, _insertCommands.getListTypes)(item, schema),
40
+ list = _getListTypes.list,
41
+ listItem = _getListTypes.item;
42
+ return insert(list.createChecked({
43
+ localId: listLocalId
44
+ }, listItem.createChecked({
45
+ localId: itemLocalId
46
+ })));
47
+ };
48
+ return (0, _insertCommands.insertTaskDecisionAction)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, function () {
49
+ return contextIdentifierProvider;
50
+ })(editorView.state, item, source !== null && source !== void 0 ? source : _analytics.INPUT_METHOD.QUICK_INSERT, addAndCreateList);
51
+ }, [api, contextIdentifierProvider, item]);
52
+ return /*#__PURE__*/_react.default.createElement(_menuItem.QuickInsertMenuItem, {
53
+ iconBefore: isAction ? /*#__PURE__*/_react.default.createElement(_assets.IconAction, null) : /*#__PURE__*/_react.default.createElement(_assets.IconDecision, null),
54
+ onSelect: onSelect,
55
+ shortcut: isAction ? '[]' : '<>',
56
+ title: formatMessage(isAction ? _messages.toolbarInsertBlockMessages.action : _messages.toolbarInsertBlockMessages.decision)
57
+ });
58
+ };
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getTasksAndDecisionsQuickInsertComponents = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _messages = require("@atlaskit/editor-common/messages");
10
+ var _createQuickInsertMatcher = require("@atlaskit/editor-common/quick-insert/create-quick-insert-matcher");
11
+ var _keys = require("@atlaskit/editor-common/quick-insert/keys");
12
+ var _rank = require("@atlaskit/editor-common/quick-insert/rank");
13
+ var _TasksAndDecisionsQuickInsertMenuItem = require("./TasksAndDecisionsQuickInsertMenuItem");
14
+ var getTasksAndDecisionsQuickInsertComponents = exports.getTasksAndDecisionsQuickInsertComponents = function getTasksAndDecisionsQuickInsertComponents(_ref) {
15
+ var api = _ref.api,
16
+ quickInsertActionDescription = _ref.quickInsertActionDescription;
17
+ return [{
18
+ key: _keys.ACTION_MENU_ITEM.key,
19
+ type: _keys.ACTION_MENU_ITEM.type,
20
+ parents: [{
21
+ key: _keys.STRUCTURE_SECTION.key,
22
+ type: _keys.STRUCTURE_SECTION.type,
23
+ rank: _rank.STRUCTURE_SECTION_RANK[_keys.ACTION_MENU_ITEM.key]
24
+ }],
25
+ match: (0, _createQuickInsertMatcher.createQuickInsertMatcher)(function (_ref2) {
26
+ var formatMessage = _ref2.formatMessage;
27
+ return {
28
+ description: quickInsertActionDescription !== null && quickInsertActionDescription !== void 0 ? quickInsertActionDescription : formatMessage(_messages.toolbarInsertBlockMessages.actionDescription),
29
+ keywords: ['checkbox', 'task', 'todo'],
30
+ shortcut: '[]',
31
+ title: formatMessage(_messages.toolbarInsertBlockMessages.action)
32
+ };
33
+ }),
34
+ component: function component() {
35
+ return /*#__PURE__*/_react.default.createElement(_TasksAndDecisionsQuickInsertMenuItem.TasksAndDecisionsQuickInsertMenuItem, {
36
+ api: api,
37
+ item: "taskList"
38
+ });
39
+ }
40
+ }, {
41
+ key: _keys.DECISION_MENU_ITEM.key,
42
+ type: _keys.DECISION_MENU_ITEM.type,
43
+ parents: [{
44
+ key: _keys.STRUCTURE_SECTION.key,
45
+ type: _keys.STRUCTURE_SECTION.type,
46
+ rank: _rank.STRUCTURE_SECTION_RANK[_keys.DECISION_MENU_ITEM.key]
47
+ }],
48
+ match: (0, _createQuickInsertMatcher.createQuickInsertMatcher)(function (_ref3) {
49
+ var formatMessage = _ref3.formatMessage;
50
+ return {
51
+ description: formatMessage(_messages.toolbarInsertBlockMessages.decisionDescription),
52
+ keywords: [],
53
+ shortcut: '<>',
54
+ title: formatMessage(_messages.toolbarInsertBlockMessages.decision)
55
+ };
56
+ }),
57
+ component: function component() {
58
+ return /*#__PURE__*/_react.default.createElement(_TasksAndDecisionsQuickInsertMenuItem.TasksAndDecisionsQuickInsertMenuItem, {
59
+ api: api,
60
+ item: "decisionList"
61
+ });
62
+ }
63
+ }];
64
+ };
@@ -4,6 +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 { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
7
8
  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
9
  import { MAX_INDENTATION_LEVEL } from '@atlaskit/editor-common/indentation';
9
10
  import { toolbarInsertBlockMessages as insertBlockMessages } from '@atlaskit/editor-common/messages';
@@ -28,6 +29,7 @@ import { DecisionListBlockMenuItem } from './ui/DecisionListBlockMenuItem/Decisi
28
29
  import { RequestToEditPopup } from './ui/Task/RequestToEditPopup';
29
30
  import { TaskListBlockMenuItem } from './ui/TaskListBlockMenuItem/TaskListBlockMenuItem';
30
31
  import { getTasksAndDecisionsToolbarComponents } from './ui/toolbar-components';
32
+ import { getTasksAndDecisionsQuickInsertComponents } from './ui/quick-insert/getTasksAndDecisionsQuickInsertComponents';
31
33
  import ToolbarDecision from './ui/ToolbarDecision';
32
34
  import ToolbarTask from './ui/ToolbarTask';
33
35
  const taskDecisionToolbarGroupStyles = null;
@@ -100,6 +102,14 @@ export const tasksAndDecisionsPlugin = ({
100
102
  };
101
103
  let previousTaskAndDecisionProvider;
102
104
  const isToolbarAIFCEnabled = Boolean(api === null || api === void 0 ? void 0 : api.toolbar);
105
+ const isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
106
+ if (isRegisteredSlashCommandEnabled) {
107
+ var _api$uiControlRegistr;
108
+ api === null || api === void 0 ? void 0 : (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 ? void 0 : _api$uiControlRegistr.actions.register(getTasksAndDecisionsQuickInsertComponents({
109
+ api,
110
+ quickInsertActionDescription
111
+ }));
112
+ }
103
113
  if (isToolbarAIFCEnabled) {
104
114
  var _api$toolbar;
105
115
  api === null || api === void 0 ? void 0 : (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.registerComponents(getTasksAndDecisionsToolbarComponents({
@@ -298,32 +308,34 @@ export const tasksAndDecisionsPlugin = ({
298
308
  });
299
309
  },
300
310
  pluginsOptions: {
301
- quickInsert: ({
302
- formatMessage
303
- }) => [{
304
- id: 'action',
305
- title: formatMessage(insertBlockMessages.action),
306
- description: quickInsertActionDescription !== null && quickInsertActionDescription !== void 0 ? quickInsertActionDescription : formatMessage(insertBlockMessages.actionDescription),
307
- priority: 100,
308
- keywords: ['checkbox', 'task', 'todo'],
309
- keyshortcut: '[]',
310
- icon: () => /*#__PURE__*/React.createElement(IconAction, null),
311
- action(insert, state, source) {
312
- var _api$analytics6;
313
- return insertTaskDecisionAction(api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions, getIdentifierProvider)(state, 'taskList', source !== null && source !== void 0 ? source : INPUT_METHOD.QUICK_INSERT, addItem(insert, 'taskList', state.schema));
314
- }
315
- }, {
316
- id: 'decision',
317
- title: formatMessage(insertBlockMessages.decision),
318
- description: formatMessage(insertBlockMessages.decisionDescription),
319
- priority: 900,
320
- keyshortcut: '<>',
321
- icon: () => /*#__PURE__*/React.createElement(IconDecision, null),
322
- action(insert, state, source) {
323
- var _api$analytics7;
324
- return insertTaskDecisionAction(api === null || api === void 0 ? void 0 : (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions, getIdentifierProvider)(state, 'decisionList', source !== null && source !== void 0 ? source : INPUT_METHOD.QUICK_INSERT, addItem(insert, 'decisionList', state.schema));
325
- }
326
- }]
311
+ ...(!isRegisteredSlashCommandEnabled && {
312
+ quickInsert: ({
313
+ formatMessage
314
+ }) => [{
315
+ id: 'action',
316
+ title: formatMessage(insertBlockMessages.action),
317
+ description: quickInsertActionDescription !== null && quickInsertActionDescription !== void 0 ? quickInsertActionDescription : formatMessage(insertBlockMessages.actionDescription),
318
+ priority: 100,
319
+ keywords: ['checkbox', 'task', 'todo'],
320
+ keyshortcut: '[]',
321
+ icon: () => /*#__PURE__*/React.createElement(IconAction, null),
322
+ action(insert, state, source) {
323
+ var _api$analytics6;
324
+ return insertTaskDecisionAction(api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions, getIdentifierProvider)(state, 'taskList', source !== null && source !== void 0 ? source : INPUT_METHOD.QUICK_INSERT, addItem(insert, 'taskList', state.schema));
325
+ }
326
+ }, {
327
+ id: 'decision',
328
+ title: formatMessage(insertBlockMessages.decision),
329
+ description: formatMessage(insertBlockMessages.decisionDescription),
330
+ priority: 900,
331
+ keyshortcut: '<>',
332
+ icon: () => /*#__PURE__*/React.createElement(IconDecision, null),
333
+ action(insert, state, source) {
334
+ var _api$analytics7;
335
+ return insertTaskDecisionAction(api === null || api === void 0 ? void 0 : (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions, getIdentifierProvider)(state, 'decisionList', source !== null && source !== void 0 ? source : INPUT_METHOD.QUICK_INSERT, addItem(insert, 'decisionList', state.schema));
336
+ }
337
+ }]
338
+ })
327
339
  }
328
340
  };
329
341
  };
@@ -0,0 +1,56 @@
1
+ import React, { useCallback } from 'react';
2
+ import { useIntl } from 'react-intl';
3
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
+ import { IconAction, IconDecision } from '@atlaskit/editor-common/assets';
7
+ import { QuickInsertMenuItem } from '@atlaskit/editor-common/quick-insert/menu-item';
8
+ import { getListTypes, insertTaskDecisionAction } from '../../pm-plugins/insert-commands';
9
+ export const TasksAndDecisionsQuickInsertMenuItem = ({
10
+ api,
11
+ item
12
+ }) => {
13
+ const {
14
+ formatMessage
15
+ } = useIntl();
16
+ const {
17
+ contextIdentifierProvider
18
+ } = useSharedPluginStateWithSelector(api, ['contextIdentifier'], states => {
19
+ var _states$contextIdenti;
20
+ return {
21
+ contextIdentifierProvider: (_states$contextIdenti = states.contextIdentifierState) === null || _states$contextIdenti === void 0 ? void 0 : _states$contextIdenti.contextIdentifierProvider
22
+ };
23
+ });
24
+ const isAction = item === 'taskList';
25
+ const onSelect = useCallback(({
26
+ editorView,
27
+ insert,
28
+ source
29
+ }) => {
30
+ var _api$analytics;
31
+ const {
32
+ schema
33
+ } = editorView.state;
34
+ const addAndCreateList = ({
35
+ listLocalId,
36
+ itemLocalId
37
+ }) => {
38
+ const {
39
+ list,
40
+ item: listItem
41
+ } = getListTypes(item, schema);
42
+ return insert(list.createChecked({
43
+ localId: listLocalId
44
+ }, listItem.createChecked({
45
+ localId: itemLocalId
46
+ })));
47
+ };
48
+ return insertTaskDecisionAction(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, () => contextIdentifierProvider)(editorView.state, item, source !== null && source !== void 0 ? source : INPUT_METHOD.QUICK_INSERT, addAndCreateList);
49
+ }, [api, contextIdentifierProvider, item]);
50
+ return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
51
+ iconBefore: isAction ? /*#__PURE__*/React.createElement(IconAction, null) : /*#__PURE__*/React.createElement(IconDecision, null),
52
+ onSelect: onSelect,
53
+ shortcut: isAction ? '[]' : '<>',
54
+ title: formatMessage(isAction ? messages.action : messages.decision)
55
+ });
56
+ };
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
3
+ import { createQuickInsertMatcher } from '@atlaskit/editor-common/quick-insert/create-quick-insert-matcher';
4
+ import { ACTION_MENU_ITEM, DECISION_MENU_ITEM, STRUCTURE_SECTION } from '@atlaskit/editor-common/quick-insert/keys';
5
+ import { STRUCTURE_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/rank';
6
+ import { TasksAndDecisionsQuickInsertMenuItem } from './TasksAndDecisionsQuickInsertMenuItem';
7
+ export const getTasksAndDecisionsQuickInsertComponents = ({
8
+ api,
9
+ quickInsertActionDescription
10
+ }) => [{
11
+ key: ACTION_MENU_ITEM.key,
12
+ type: ACTION_MENU_ITEM.type,
13
+ parents: [{
14
+ key: STRUCTURE_SECTION.key,
15
+ type: STRUCTURE_SECTION.type,
16
+ rank: STRUCTURE_SECTION_RANK[ACTION_MENU_ITEM.key]
17
+ }],
18
+ match: createQuickInsertMatcher(({
19
+ formatMessage
20
+ }) => ({
21
+ description: quickInsertActionDescription !== null && quickInsertActionDescription !== void 0 ? quickInsertActionDescription : formatMessage(messages.actionDescription),
22
+ keywords: ['checkbox', 'task', 'todo'],
23
+ shortcut: '[]',
24
+ title: formatMessage(messages.action)
25
+ })),
26
+ component: () => /*#__PURE__*/React.createElement(TasksAndDecisionsQuickInsertMenuItem, {
27
+ api: api,
28
+ item: "taskList"
29
+ })
30
+ }, {
31
+ key: DECISION_MENU_ITEM.key,
32
+ type: DECISION_MENU_ITEM.type,
33
+ parents: [{
34
+ key: STRUCTURE_SECTION.key,
35
+ type: STRUCTURE_SECTION.type,
36
+ rank: STRUCTURE_SECTION_RANK[DECISION_MENU_ITEM.key]
37
+ }],
38
+ match: createQuickInsertMatcher(({
39
+ formatMessage
40
+ }) => ({
41
+ description: formatMessage(messages.decisionDescription),
42
+ keywords: [],
43
+ shortcut: '<>',
44
+ title: formatMessage(messages.decision)
45
+ })),
46
+ component: () => /*#__PURE__*/React.createElement(TasksAndDecisionsQuickInsertMenuItem, {
47
+ api: api,
48
+ item: "decisionList"
49
+ })
50
+ }];
@@ -1,12 +1,16 @@
1
1
  /* tasksAndDecisionsPlugin.tsx generated by @compiled/babel-plugin v2.0.0 */
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
4
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
4
5
  import "./tasksAndDecisionsPlugin.compiled.css";
5
6
  import * as React from 'react';
6
7
  import { ax, ix } from "@compiled/react/runtime";
8
+ 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; }
9
+ 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; }
7
10
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
11
  import { decisionList, taskList } from '@atlaskit/adf-schema';
9
12
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
13
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
10
14
  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
15
  import { MAX_INDENTATION_LEVEL } from '@atlaskit/editor-common/indentation';
12
16
  import { toolbarInsertBlockMessages as insertBlockMessages } from '@atlaskit/editor-common/messages';
@@ -31,6 +35,7 @@ import { DecisionListBlockMenuItem } from './ui/DecisionListBlockMenuItem/Decisi
31
35
  import { RequestToEditPopup } from './ui/Task/RequestToEditPopup';
32
36
  import { TaskListBlockMenuItem } from './ui/TaskListBlockMenuItem/TaskListBlockMenuItem';
33
37
  import { getTasksAndDecisionsToolbarComponents } from './ui/toolbar-components';
38
+ import { getTasksAndDecisionsQuickInsertComponents } from './ui/quick-insert/getTasksAndDecisionsQuickInsertComponents';
34
39
  import ToolbarDecision from './ui/ToolbarDecision';
35
40
  import ToolbarTask from './ui/ToolbarTask';
36
41
  var taskDecisionToolbarGroupStyles = null;
@@ -102,6 +107,14 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref3) {
102
107
  };
103
108
  var previousTaskAndDecisionProvider;
104
109
  var isToolbarAIFCEnabled = Boolean(api === null || api === void 0 ? void 0 : api.toolbar);
110
+ var isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
111
+ if (isRegisteredSlashCommandEnabled) {
112
+ var _api$uiControlRegistr;
113
+ api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register(getTasksAndDecisionsQuickInsertComponents({
114
+ api: api,
115
+ quickInsertActionDescription: quickInsertActionDescription
116
+ }));
117
+ }
105
118
  if (isToolbarAIFCEnabled) {
106
119
  var _api$toolbar;
107
120
  api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents(getTasksAndDecisionsToolbarComponents({
@@ -324,7 +337,7 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref3) {
324
337
  popupsScrollableElement: popupsScrollableElement
325
338
  });
326
339
  },
327
- pluginsOptions: {
340
+ pluginsOptions: _objectSpread({}, !isRegisteredSlashCommandEnabled && {
328
341
  quickInsert: function quickInsert(_ref13) {
329
342
  var formatMessage = _ref13.formatMessage;
330
343
  return [{
@@ -356,6 +369,6 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref3) {
356
369
  }
357
370
  }];
358
371
  }
359
- }
372
+ })
360
373
  };
361
374
  };
@@ -0,0 +1,50 @@
1
+ import React, { useCallback } from 'react';
2
+ import { useIntl } from 'react-intl';
3
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
+ import { IconAction, IconDecision } from '@atlaskit/editor-common/assets';
7
+ import { QuickInsertMenuItem } from '@atlaskit/editor-common/quick-insert/menu-item';
8
+ import { getListTypes, insertTaskDecisionAction } from '../../pm-plugins/insert-commands';
9
+ export var TasksAndDecisionsQuickInsertMenuItem = function TasksAndDecisionsQuickInsertMenuItem(_ref) {
10
+ var api = _ref.api,
11
+ item = _ref.item;
12
+ var _useIntl = useIntl(),
13
+ formatMessage = _useIntl.formatMessage;
14
+ var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['contextIdentifier'], function (states) {
15
+ var _states$contextIdenti;
16
+ return {
17
+ contextIdentifierProvider: (_states$contextIdenti = states.contextIdentifierState) === null || _states$contextIdenti === void 0 ? void 0 : _states$contextIdenti.contextIdentifierProvider
18
+ };
19
+ }),
20
+ contextIdentifierProvider = _useSharedPluginState.contextIdentifierProvider;
21
+ var isAction = item === 'taskList';
22
+ var onSelect = useCallback(function (_ref2) {
23
+ var _api$analytics;
24
+ var editorView = _ref2.editorView,
25
+ insert = _ref2.insert,
26
+ source = _ref2.source;
27
+ var schema = editorView.state.schema;
28
+ var addAndCreateList = function addAndCreateList(_ref3) {
29
+ var listLocalId = _ref3.listLocalId,
30
+ itemLocalId = _ref3.itemLocalId;
31
+ var _getListTypes = getListTypes(item, schema),
32
+ list = _getListTypes.list,
33
+ listItem = _getListTypes.item;
34
+ return insert(list.createChecked({
35
+ localId: listLocalId
36
+ }, listItem.createChecked({
37
+ localId: itemLocalId
38
+ })));
39
+ };
40
+ return insertTaskDecisionAction(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, function () {
41
+ return contextIdentifierProvider;
42
+ })(editorView.state, item, source !== null && source !== void 0 ? source : INPUT_METHOD.QUICK_INSERT, addAndCreateList);
43
+ }, [api, contextIdentifierProvider, item]);
44
+ return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
45
+ iconBefore: isAction ? /*#__PURE__*/React.createElement(IconAction, null) : /*#__PURE__*/React.createElement(IconDecision, null),
46
+ onSelect: onSelect,
47
+ shortcut: isAction ? '[]' : '<>',
48
+ title: formatMessage(isAction ? messages.action : messages.decision)
49
+ });
50
+ };
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
3
+ import { createQuickInsertMatcher } from '@atlaskit/editor-common/quick-insert/create-quick-insert-matcher';
4
+ import { ACTION_MENU_ITEM, DECISION_MENU_ITEM, STRUCTURE_SECTION } from '@atlaskit/editor-common/quick-insert/keys';
5
+ import { STRUCTURE_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/rank';
6
+ import { TasksAndDecisionsQuickInsertMenuItem } from './TasksAndDecisionsQuickInsertMenuItem';
7
+ export var getTasksAndDecisionsQuickInsertComponents = function getTasksAndDecisionsQuickInsertComponents(_ref) {
8
+ var api = _ref.api,
9
+ quickInsertActionDescription = _ref.quickInsertActionDescription;
10
+ return [{
11
+ key: ACTION_MENU_ITEM.key,
12
+ type: ACTION_MENU_ITEM.type,
13
+ parents: [{
14
+ key: STRUCTURE_SECTION.key,
15
+ type: STRUCTURE_SECTION.type,
16
+ rank: STRUCTURE_SECTION_RANK[ACTION_MENU_ITEM.key]
17
+ }],
18
+ match: createQuickInsertMatcher(function (_ref2) {
19
+ var formatMessage = _ref2.formatMessage;
20
+ return {
21
+ description: quickInsertActionDescription !== null && quickInsertActionDescription !== void 0 ? quickInsertActionDescription : formatMessage(messages.actionDescription),
22
+ keywords: ['checkbox', 'task', 'todo'],
23
+ shortcut: '[]',
24
+ title: formatMessage(messages.action)
25
+ };
26
+ }),
27
+ component: function component() {
28
+ return /*#__PURE__*/React.createElement(TasksAndDecisionsQuickInsertMenuItem, {
29
+ api: api,
30
+ item: "taskList"
31
+ });
32
+ }
33
+ }, {
34
+ key: DECISION_MENU_ITEM.key,
35
+ type: DECISION_MENU_ITEM.type,
36
+ parents: [{
37
+ key: STRUCTURE_SECTION.key,
38
+ type: STRUCTURE_SECTION.type,
39
+ rank: STRUCTURE_SECTION_RANK[DECISION_MENU_ITEM.key]
40
+ }],
41
+ match: createQuickInsertMatcher(function (_ref3) {
42
+ var formatMessage = _ref3.formatMessage;
43
+ return {
44
+ description: formatMessage(messages.decisionDescription),
45
+ keywords: [],
46
+ shortcut: '<>',
47
+ title: formatMessage(messages.decision)
48
+ };
49
+ }),
50
+ component: function component() {
51
+ return /*#__PURE__*/React.createElement(TasksAndDecisionsQuickInsertMenuItem, {
52
+ api: api,
53
+ item: "decisionList"
54
+ });
55
+ }
56
+ }];
57
+ };
@@ -6,6 +6,7 @@ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmo
6
6
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
7
7
  import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
8
8
  import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
9
+ import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry';
9
10
  import type { TaskDecisionProvider } from '@atlaskit/task-decision/types';
10
11
  import type { insertTaskDecisionCommand } from './pm-plugins/insert-commands';
11
12
  import type { getIndentCommand, getUnindentCommand } from './pm-plugins/keymaps';
@@ -18,7 +19,8 @@ export type TasksAndDecisionsPluginDependencies = [
18
19
  OptionalPlugin<BlockMenuPlugin>,
19
20
  OptionalPlugin<SelectionPlugin>,
20
21
  OptionalPlugin<ToolbarPlugin>,
21
- OptionalPlugin<_MarkdownModePluginStub>
22
+ OptionalPlugin<_MarkdownModePluginStub>,
23
+ OptionalPlugin<UiControlRegistryPlugin>
22
24
  ];
23
25
  export type TasksAndDecisionsPlugin = NextEditorPlugin<'taskDecision', {
24
26
  actions: {
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { TasksAndDecisionsPlugin } from '../../tasksAndDecisionsPluginType';
4
+ import type { TaskDecisionListType } from '../../types';
5
+ type Props = {
6
+ api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined;
7
+ item: TaskDecisionListType;
8
+ };
9
+ export declare const TasksAndDecisionsQuickInsertMenuItem: ({ api, item }: Props) => React.JSX.Element;
10
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { RegisterMenuItem } from '@atlaskit/editor-ui-control-model/types';
3
+ import type { TasksAndDecisionsPlugin } from '../../tasksAndDecisionsPluginType';
4
+ export declare const getTasksAndDecisionsQuickInsertComponents: ({ api, quickInsertActionDescription, }: {
5
+ api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined;
6
+ quickInsertActionDescription?: string;
7
+ }) => RegisterMenuItem[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-tasks-and-decisions",
3
- "version": "18.0.0",
3
+ "version": "18.0.1",
4
4
  "description": "Tasks and decisions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -37,6 +37,7 @@
37
37
  "@atlaskit/editor-toolbar-model": "^1.2.0",
38
38
  "@atlaskit/heading": "^7.0.0",
39
39
  "@atlaskit/icon": "^37.3.0",
40
+ "@atlaskit/platform-feature-experiments": "^0.3.0",
40
41
  "@atlaskit/platform-feature-flags": "^2.1.0",
41
42
  "@atlaskit/primitives": "^22.2.0",
42
43
  "@atlaskit/prosemirror-input-rules": "^4.0.0",
@@ -48,7 +49,7 @@
48
49
  "bind-event-listener": "^3.0.0"
49
50
  },
50
51
  "peerDependencies": {
51
- "@atlaskit/editor-common": "^119.0.0",
52
+ "@atlaskit/editor-common": "^119.1.0",
52
53
  "react": "^18.2.0 || ^19.2.0",
53
54
  "react-dom": "^18.2.0 || ^19.2.0",
54
55
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"