@atlaskit/editor-plugin-status 2.5.10 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/index.js +2 -2
  3. package/dist/cjs/{actions.js → pm-plugins/actions.js} +1 -1
  4. package/dist/cjs/pm-plugins/keymap.js +2 -2
  5. package/dist/cjs/pm-plugins/plugin.js +1 -1
  6. package/dist/cjs/statusPlugin.js +145 -0
  7. package/dist/cjs/types/index.js +5 -0
  8. package/dist/cjs/ui/ContentComponent.js +1 -1
  9. package/dist/cjs/ui/statusPicker.js +2 -2
  10. package/dist/es2019/index.js +1 -1
  11. package/dist/es2019/{actions.js → pm-plugins/actions.js} +1 -1
  12. package/dist/es2019/pm-plugins/keymap.js +2 -2
  13. package/dist/es2019/pm-plugins/plugin.js +1 -1
  14. package/dist/es2019/statusPlugin.js +135 -0
  15. package/dist/es2019/ui/ContentComponent.js +1 -1
  16. package/dist/es2019/ui/statusPicker.js +2 -2
  17. package/dist/esm/index.js +1 -1
  18. package/dist/esm/{actions.js → pm-plugins/actions.js} +1 -1
  19. package/dist/esm/pm-plugins/keymap.js +2 -2
  20. package/dist/esm/pm-plugins/plugin.js +1 -1
  21. package/dist/esm/statusPlugin.js +138 -0
  22. package/dist/esm/statusPluginType.js +1 -0
  23. package/dist/esm/types/index.js +1 -0
  24. package/dist/esm/ui/ContentComponent.js +1 -1
  25. package/dist/esm/ui/statusPicker.js +2 -2
  26. package/dist/types/index.d.ts +3 -3
  27. package/dist/types/{actions.d.ts → pm-plugins/actions.d.ts} +1 -1
  28. package/dist/types/{utils.d.ts → pm-plugins/utils.d.ts} +1 -1
  29. package/dist/types/statusPlugin.d.ts +2 -0
  30. package/dist/types/statusPluginType.d.ts +41 -0
  31. package/dist/{types-ts4.5/types.d.ts → types/types/index.d.ts} +1 -1
  32. package/dist/types/ui/ContentComponent.d.ts +1 -1
  33. package/dist/types-ts4.5/index.d.ts +3 -3
  34. package/dist/types-ts4.5/{actions.d.ts → pm-plugins/actions.d.ts} +1 -1
  35. package/dist/types-ts4.5/{utils.d.ts → pm-plugins/utils.d.ts} +1 -1
  36. package/dist/types-ts4.5/statusPlugin.d.ts +2 -0
  37. package/dist/types-ts4.5/statusPluginType.d.ts +41 -0
  38. package/dist/{types/types.d.ts → types-ts4.5/types/index.d.ts} +1 -1
  39. package/dist/types-ts4.5/ui/ContentComponent.d.ts +1 -1
  40. package/package.json +10 -3
  41. package/dist/cjs/plugin.js +0 -111
  42. package/dist/es2019/plugin.js +0 -100
  43. package/dist/esm/plugin.js +0 -104
  44. package/dist/types/plugin.d.ts +0 -19
  45. package/dist/types-ts4.5/plugin.d.ts +0 -21
  46. /package/dist/cjs/{utils.js → pm-plugins/utils.js} +0 -0
  47. /package/dist/cjs/{types.js → statusPluginType.js} +0 -0
  48. /package/dist/cjs/{analytics.js → ui/analytics.js} +0 -0
  49. /package/dist/es2019/{utils.js → pm-plugins/utils.js} +0 -0
  50. /package/dist/es2019/{types.js → statusPluginType.js} +0 -0
  51. /package/dist/{esm/types.js → es2019/types/index.js} +0 -0
  52. /package/dist/es2019/{analytics.js → ui/analytics.js} +0 -0
  53. /package/dist/esm/{utils.js → pm-plugins/utils.js} +0 -0
  54. /package/dist/esm/{analytics.js → ui/analytics.js} +0 -0
  55. /package/dist/types/{analytics.d.ts → ui/analytics.d.ts} +0 -0
  56. /package/dist/types-ts4.5/{analytics.d.ts → ui/analytics.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/editor-plugin-status
2
2
 
3
+ ## 2.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#171440](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/171440)
8
+ [`835f7bbff3122`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/835f7bbff3122) -
9
+ ED-25816: refactors plugins to meet folder standards
10
+
11
+ ## 2.6.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#174097](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/174097)
16
+ [`b691b87e73dc2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b691b87e73dc2) -
17
+ [ux] ED-25902-add-floating-toolbar-in-view-mode
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies
22
+
3
23
  ## 2.5.10
4
24
 
5
25
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "statusPlugin", {
7
7
  enumerable: true,
8
8
  get: function get() {
9
- return _plugin.statusPlugin;
9
+ return _statusPlugin.statusPlugin;
10
10
  }
11
11
  });
12
- var _plugin = require("./plugin");
12
+ var _statusPlugin = require("./statusPlugin");
@@ -14,7 +14,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
14
14
  var _state = require("@atlaskit/editor-prosemirror/state");
15
15
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
16
16
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
- var _pluginKey = require("./pm-plugins/plugin-key");
17
+ var _pluginKey = require("./plugin-key");
18
18
  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; }
19
19
  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; }
20
20
  var DEFAULT_STATUS = exports.DEFAULT_STATUS = {
@@ -8,9 +8,9 @@ exports.keymapPlugin = keymapPlugin;
8
8
  var _keymaps = require("@atlaskit/editor-common/keymaps");
9
9
  var _keymap = require("@atlaskit/editor-prosemirror/keymap");
10
10
  var _state = require("@atlaskit/editor-prosemirror/state");
11
- var _actions = require("../actions");
12
- var _utils = require("../utils");
11
+ var _actions = require("./actions");
13
12
  var _pluginKey = require("./plugin-key");
13
+ var _utils = require("./utils");
14
14
  function keymapPlugin() {
15
15
  var list = {};
16
16
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.enter.common, consumeKeyEvent, list);
@@ -23,8 +23,8 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
23
23
  var _utils = require("@atlaskit/editor-common/utils");
24
24
  var _state = require("@atlaskit/editor-prosemirror/state");
25
25
  var _status = require("../nodeviews/status");
26
- var _utils2 = require("../utils");
27
26
  var _pluginKey = require("./plugin-key");
27
+ var _utils2 = require("./utils");
28
28
  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; }
29
29
  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; }
30
30
  var createPlugin = function createPlugin(pmPluginFactoryParams, options) {
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.statusPlugin = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _adfSchema = require("@atlaskit/adf-schema");
10
+ var _analytics = require("@atlaskit/editor-common/analytics");
11
+ var _keymaps = require("@atlaskit/editor-common/keymaps");
12
+ var _messages = require("@atlaskit/editor-common/messages");
13
+ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
14
+ var _utils = require("@atlaskit/editor-common/utils");
15
+ var _comment = _interopRequireDefault(require("@atlaskit/icon/core/comment"));
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
+ var _actions = require("./pm-plugins/actions");
18
+ var _keymap = require("./pm-plugins/keymap");
19
+ var _plugin = _interopRequireDefault(require("./pm-plugins/plugin"));
20
+ var _pluginKey = require("./pm-plugins/plugin-key");
21
+ var _ContentComponent = require("./ui/ContentComponent");
22
+ var statusPlugin = exports.statusPlugin = function statusPlugin(_ref) {
23
+ var _api$analytics, _api$analytics2;
24
+ var options = _ref.config,
25
+ api = _ref.api;
26
+ return {
27
+ name: 'status',
28
+ nodes: function nodes() {
29
+ return [{
30
+ name: 'status',
31
+ node: _adfSchema.status
32
+ }];
33
+ },
34
+ pmPlugins: function pmPlugins() {
35
+ return [{
36
+ name: 'status',
37
+ plugin: function plugin(pmPluginFactoryParams) {
38
+ return (0, _plugin.default)(pmPluginFactoryParams, options);
39
+ }
40
+ }, {
41
+ name: 'statusKeymap',
42
+ plugin: _keymap.keymapPlugin
43
+ }];
44
+ },
45
+ actions: {
46
+ commitStatusPicker: _actions.commitStatusPicker,
47
+ updateStatus: (0, _actions.updateStatusWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
48
+ },
49
+ commands: {
50
+ removeStatus: _actions.removeStatus,
51
+ insertStatus: (0, _actions.insertStatus)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
52
+ },
53
+ getSharedState: function getSharedState(state) {
54
+ if (!state) {
55
+ return undefined;
56
+ }
57
+ var pluginState = _pluginKey.pluginKey.getState(state);
58
+ return pluginState ? {
59
+ isNew: pluginState.isNew,
60
+ showStatusPickerAt: pluginState.showStatusPickerAt,
61
+ focusStatusInput: pluginState.focusStatusInput
62
+ } : undefined;
63
+ },
64
+ pluginsOptions: {
65
+ quickInsert: function quickInsert(_ref2) {
66
+ var formatMessage = _ref2.formatMessage;
67
+ if ((options === null || options === void 0 ? void 0 : options.menuDisabled) === true) {
68
+ return [];
69
+ }
70
+ return [{
71
+ id: 'status',
72
+ title: formatMessage(_messages.toolbarInsertBlockMessages.status),
73
+ description: formatMessage(_messages.toolbarInsertBlockMessages.statusDescription),
74
+ priority: 700,
75
+ keywords: ['lozenge'],
76
+ icon: function icon() {
77
+ return /*#__PURE__*/_react.default.createElement(_quickInsert.IconStatus, null);
78
+ },
79
+ action: function action(_insert, state) {
80
+ var _insertStatus, _api$analytics3;
81
+ return (_insertStatus = (0, _actions.insertStatus)(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)(_analytics.INPUT_METHOD.QUICK_INSERT)({
82
+ tr: state.tr
83
+ })) !== null && _insertStatus !== void 0 ? _insertStatus : state.tr;
84
+ }
85
+ }];
86
+ },
87
+ floatingToolbar: function floatingToolbar(state, intl) {
88
+ var _api$editorViewMode;
89
+ var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
90
+ if (!(0, _platformFeatureFlags.fg)('platform_inline_node_as_valid_annotation_selection') || !isViewMode) {
91
+ return undefined;
92
+ }
93
+ return {
94
+ title: 'Status floating toolbar',
95
+ nodeType: state.schema.nodes.status,
96
+ onPositionCalculated: (0, _utils.calculateToolbarPositionAboveSelection)('Status floating toolbar'),
97
+ items: function items(node) {
98
+ var _api$annotation;
99
+ var annotationState = api === null || api === void 0 || (_api$annotation = api.annotation) === null || _api$annotation === void 0 ? void 0 : _api$annotation.sharedState.currentState();
100
+ var hasActiveMark = node.marks.some(function (mark) {
101
+ return mark.type.name === 'annotation' && (annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations[mark.attrs.id]) === false;
102
+ });
103
+ var showAnnotation = annotationState && isViewMode && annotationState.isVisible && !annotationState.bookmark && !annotationState.mouseData.isSelecting && !hasActiveMark;
104
+ var onCommentClick = function onCommentClick(stateFromClickEvent, dispatch) {
105
+ if (!(api !== null && api !== void 0 && api.annotation)) {
106
+ return true;
107
+ }
108
+ var command = api.annotation.actions.setInlineCommentDraftState(true, _analytics.INPUT_METHOD.TOOLBAR);
109
+ return command(stateFromClickEvent, dispatch);
110
+ };
111
+ var createCommentMessage = intl.formatMessage(_messages.annotationMessages.createComment);
112
+ var commentItems = showAnnotation ? [{
113
+ type: 'button',
114
+ title: createCommentMessage,
115
+ onClick: onCommentClick,
116
+ showTitle: true,
117
+ tooltipContent: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
118
+ description: createCommentMessage,
119
+ keymap: _keymaps.addInlineComment
120
+ }),
121
+ icon: _comment.default,
122
+ supportsViewMode: true
123
+ }] : [];
124
+ return [].concat(commentItems);
125
+ }
126
+ };
127
+ }
128
+ },
129
+ contentComponent: function contentComponent(_ref3) {
130
+ var editorView = _ref3.editorView,
131
+ popupsMountPoint = _ref3.popupsMountPoint,
132
+ popupsBoundariesElement = _ref3.popupsBoundariesElement,
133
+ popupsScrollableElement = _ref3.popupsScrollableElement;
134
+ var domAtPos = editorView.domAtPos.bind(editorView);
135
+ return /*#__PURE__*/_react.default.createElement(_ContentComponent.ContentComponent, {
136
+ domAtPos: domAtPos,
137
+ api: api,
138
+ editorView: editorView,
139
+ popupsMountPoint: popupsMountPoint,
140
+ popupsBoundariesElement: popupsBoundariesElement,
141
+ popupsScrollableElement: popupsScrollableElement
142
+ });
143
+ }
144
+ };
145
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -9,7 +9,7 @@ exports.ContentComponent = ContentComponent;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _hooks = require("@atlaskit/editor-common/hooks");
11
11
  var _utils = require("@atlaskit/editor-prosemirror/utils");
12
- var _actions = require("../actions");
12
+ var _actions = require("../pm-plugins/actions");
13
13
  var _statusPicker = _interopRequireDefault(require("./statusPicker"));
14
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
15
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -22,8 +22,8 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
22
  var _picker = require("@atlaskit/status/picker");
23
23
  var _colors = require("@atlaskit/theme/colors");
24
24
  var _constants = require("@atlaskit/theme/constants");
25
- var _actions = require("../actions");
26
- var _analytics = require("../analytics");
25
+ var _actions = require("../pm-plugins/actions");
26
+ var _analytics = require("./analytics");
27
27
  function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
28
28
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /**
29
29
  * @jsxRuntime classic
@@ -1 +1 @@
1
- export { statusPlugin } from './plugin';
1
+ export { statusPlugin } from './statusPlugin';
@@ -6,7 +6,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
6
6
  import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { canInsert } from '@atlaskit/editor-prosemirror/utils';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
- import { pluginKey } from './pm-plugins/plugin-key';
9
+ import { pluginKey } from './plugin-key';
10
10
  export const DEFAULT_STATUS = {
11
11
  text: '',
12
12
  color: 'neutral'
@@ -1,9 +1,9 @@
1
1
  import { bindKeymapWithCommand, enter, tab } from '@atlaskit/editor-common/keymaps';
2
2
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
3
3
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
- import { setFocusOnStatusInput } from '../actions';
5
- import { mayGetStatusAtSelection } from '../utils';
4
+ import { setFocusOnStatusInput } from './actions';
6
5
  import { pluginKey } from './plugin-key';
6
+ import { mayGetStatusAtSelection } from './utils';
7
7
  export function keymapPlugin() {
8
8
  const list = {};
9
9
  bindKeymapWithCommand(enter.common, consumeKeyEvent, list);
@@ -3,8 +3,8 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import { pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
4
4
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { StatusNodeView } from '../nodeviews/status';
6
- import { isEmptyStatus, mayGetStatusAtSelection } from '../utils';
7
6
  import { pluginKey } from './plugin-key';
7
+ import { isEmptyStatus, mayGetStatusAtSelection } from './utils';
8
8
  export { pluginKey, pluginKeyName } from './plugin-key';
9
9
  const createPlugin = (pmPluginFactoryParams, options) => new SafePlugin({
10
10
  state: {
@@ -0,0 +1,135 @@
1
+ import React from 'react';
2
+ import { status } from '@atlaskit/adf-schema';
3
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { addInlineComment, ToolTipContent } from '@atlaskit/editor-common/keymaps';
5
+ import { annotationMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
+ import { IconStatus } from '@atlaskit/editor-common/quick-insert';
7
+ import { calculateToolbarPositionAboveSelection } from '@atlaskit/editor-common/utils';
8
+ import CommentIcon from '@atlaskit/icon/core/comment';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { commitStatusPicker, insertStatus, removeStatus, updateStatusWithAnalytics } from './pm-plugins/actions';
11
+ import { keymapPlugin } from './pm-plugins/keymap';
12
+ import createStatusPlugin from './pm-plugins/plugin';
13
+ import { pluginKey } from './pm-plugins/plugin-key';
14
+ import { ContentComponent } from './ui/ContentComponent';
15
+ export const statusPlugin = ({
16
+ config: options,
17
+ api
18
+ }) => {
19
+ var _api$analytics, _api$analytics2;
20
+ return {
21
+ name: 'status',
22
+ nodes() {
23
+ return [{
24
+ name: 'status',
25
+ node: status
26
+ }];
27
+ },
28
+ pmPlugins() {
29
+ return [{
30
+ name: 'status',
31
+ plugin: pmPluginFactoryParams => createStatusPlugin(pmPluginFactoryParams, options)
32
+ }, {
33
+ name: 'statusKeymap',
34
+ plugin: keymapPlugin
35
+ }];
36
+ },
37
+ actions: {
38
+ commitStatusPicker,
39
+ updateStatus: updateStatusWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
40
+ },
41
+ commands: {
42
+ removeStatus,
43
+ insertStatus: insertStatus(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
44
+ },
45
+ getSharedState(state) {
46
+ if (!state) {
47
+ return undefined;
48
+ }
49
+ const pluginState = pluginKey.getState(state);
50
+ return pluginState ? {
51
+ isNew: pluginState.isNew,
52
+ showStatusPickerAt: pluginState.showStatusPickerAt,
53
+ focusStatusInput: pluginState.focusStatusInput
54
+ } : undefined;
55
+ },
56
+ pluginsOptions: {
57
+ quickInsert: ({
58
+ formatMessage
59
+ }) => {
60
+ if ((options === null || options === void 0 ? void 0 : options.menuDisabled) === true) {
61
+ return [];
62
+ }
63
+ return [{
64
+ id: 'status',
65
+ title: formatMessage(messages.status),
66
+ description: formatMessage(messages.statusDescription),
67
+ priority: 700,
68
+ keywords: ['lozenge'],
69
+ icon: () => /*#__PURE__*/React.createElement(IconStatus, null),
70
+ action(_insert, state) {
71
+ var _insertStatus, _api$analytics3;
72
+ return (_insertStatus = insertStatus(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)(INPUT_METHOD.QUICK_INSERT)({
73
+ tr: state.tr
74
+ })) !== null && _insertStatus !== void 0 ? _insertStatus : state.tr;
75
+ }
76
+ }];
77
+ },
78
+ floatingToolbar(state, intl) {
79
+ var _api$editorViewMode, _api$editorViewMode$s;
80
+ const isViewMode = (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'view';
81
+ if (!fg('platform_inline_node_as_valid_annotation_selection') || !isViewMode) {
82
+ return undefined;
83
+ }
84
+ return {
85
+ title: 'Status floating toolbar',
86
+ nodeType: state.schema.nodes.status,
87
+ onPositionCalculated: calculateToolbarPositionAboveSelection('Status floating toolbar'),
88
+ items: node => {
89
+ var _api$annotation;
90
+ const annotationState = api === null || api === void 0 ? void 0 : (_api$annotation = api.annotation) === null || _api$annotation === void 0 ? void 0 : _api$annotation.sharedState.currentState();
91
+ const hasActiveMark = node.marks.some(mark => mark.type.name === 'annotation' && (annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations[mark.attrs.id]) === false);
92
+ const showAnnotation = annotationState && isViewMode && annotationState.isVisible && !annotationState.bookmark && !annotationState.mouseData.isSelecting && !hasActiveMark;
93
+ const onCommentClick = (stateFromClickEvent, dispatch) => {
94
+ if (!(api !== null && api !== void 0 && api.annotation)) {
95
+ return true;
96
+ }
97
+ const command = api.annotation.actions.setInlineCommentDraftState(true, INPUT_METHOD.TOOLBAR);
98
+ return command(stateFromClickEvent, dispatch);
99
+ };
100
+ const createCommentMessage = intl.formatMessage(annotationMessages.createComment);
101
+ const commentItems = showAnnotation ? [{
102
+ type: 'button',
103
+ title: createCommentMessage,
104
+ onClick: onCommentClick,
105
+ showTitle: true,
106
+ tooltipContent: /*#__PURE__*/React.createElement(ToolTipContent, {
107
+ description: createCommentMessage,
108
+ keymap: addInlineComment
109
+ }),
110
+ icon: CommentIcon,
111
+ supportsViewMode: true
112
+ }] : [];
113
+ return [...commentItems];
114
+ }
115
+ };
116
+ }
117
+ },
118
+ contentComponent({
119
+ editorView,
120
+ popupsMountPoint,
121
+ popupsBoundariesElement,
122
+ popupsScrollableElement
123
+ }) {
124
+ const domAtPos = editorView.domAtPos.bind(editorView);
125
+ return /*#__PURE__*/React.createElement(ContentComponent, {
126
+ domAtPos: domAtPos,
127
+ api: api,
128
+ editorView: editorView,
129
+ popupsMountPoint: popupsMountPoint,
130
+ popupsBoundariesElement: popupsBoundariesElement,
131
+ popupsScrollableElement: popupsScrollableElement
132
+ });
133
+ }
134
+ };
135
+ };
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useMemo } from 'react';
2
2
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
3
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
4
- import { commitStatusPicker, updateStatus } from '../actions';
4
+ import { commitStatusPicker, updateStatus } from '../pm-plugins/actions';
5
5
  import StatusPicker from './statusPicker';
6
6
  export function ContentComponent({
7
7
  api,
@@ -16,8 +16,8 @@ import { fg } from '@atlaskit/platform-feature-flags';
16
16
  import { StatusPicker as AkStatusPicker } from '@atlaskit/status/picker';
17
17
  import { N0 } from '@atlaskit/theme/colors';
18
18
  import { borderRadius } from '@atlaskit/theme/constants';
19
- import { DEFAULT_STATUS } from '../actions';
20
- import { analyticsState, createStatusAnalyticsAndFire } from '../analytics';
19
+ import { DEFAULT_STATUS } from '../pm-plugins/actions';
20
+ import { analyticsState, createStatusAnalyticsAndFire } from './analytics';
21
21
  const PopupWithListeners = withOuterListeners(Popup);
22
22
  export let InputMethod = /*#__PURE__*/function (InputMethod) {
23
23
  InputMethod["blur"] = "blur";
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export { statusPlugin } from './plugin';
1
+ export { statusPlugin } from './statusPlugin';
@@ -9,7 +9,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
9
9
  import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
10
10
  import { canInsert } from '@atlaskit/editor-prosemirror/utils';
11
11
  import { fg } from '@atlaskit/platform-feature-flags';
12
- import { pluginKey } from './pm-plugins/plugin-key';
12
+ import { pluginKey } from './plugin-key';
13
13
  export var DEFAULT_STATUS = {
14
14
  text: '',
15
15
  color: 'neutral'
@@ -1,9 +1,9 @@
1
1
  import { bindKeymapWithCommand, enter, tab } from '@atlaskit/editor-common/keymaps';
2
2
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
3
3
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
- import { setFocusOnStatusInput } from '../actions';
5
- import { mayGetStatusAtSelection } from '../utils';
4
+ import { setFocusOnStatusInput } from './actions';
6
5
  import { pluginKey } from './plugin-key';
6
+ import { mayGetStatusAtSelection } from './utils';
7
7
  export function keymapPlugin() {
8
8
  var list = {};
9
9
  bindKeymapWithCommand(enter.common, consumeKeyEvent, list);
@@ -6,8 +6,8 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
6
  import { pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
7
7
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
8
8
  import { StatusNodeView } from '../nodeviews/status';
9
- import { isEmptyStatus, mayGetStatusAtSelection } from '../utils';
10
9
  import { pluginKey } from './plugin-key';
10
+ import { isEmptyStatus, mayGetStatusAtSelection } from './utils';
11
11
  export { pluginKey, pluginKeyName } from './plugin-key';
12
12
  var createPlugin = function createPlugin(pmPluginFactoryParams, options) {
13
13
  return new SafePlugin({
@@ -0,0 +1,138 @@
1
+ import React from 'react';
2
+ import { status } from '@atlaskit/adf-schema';
3
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { addInlineComment, ToolTipContent } from '@atlaskit/editor-common/keymaps';
5
+ import { annotationMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
+ import { IconStatus } from '@atlaskit/editor-common/quick-insert';
7
+ import { calculateToolbarPositionAboveSelection } from '@atlaskit/editor-common/utils';
8
+ import CommentIcon from '@atlaskit/icon/core/comment';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { commitStatusPicker, insertStatus, removeStatus, updateStatusWithAnalytics } from './pm-plugins/actions';
11
+ import { keymapPlugin } from './pm-plugins/keymap';
12
+ import createStatusPlugin from './pm-plugins/plugin';
13
+ import { pluginKey } from './pm-plugins/plugin-key';
14
+ import { ContentComponent } from './ui/ContentComponent';
15
+ export var statusPlugin = function statusPlugin(_ref) {
16
+ var _api$analytics, _api$analytics2;
17
+ var options = _ref.config,
18
+ api = _ref.api;
19
+ return {
20
+ name: 'status',
21
+ nodes: function nodes() {
22
+ return [{
23
+ name: 'status',
24
+ node: status
25
+ }];
26
+ },
27
+ pmPlugins: function pmPlugins() {
28
+ return [{
29
+ name: 'status',
30
+ plugin: function plugin(pmPluginFactoryParams) {
31
+ return createStatusPlugin(pmPluginFactoryParams, options);
32
+ }
33
+ }, {
34
+ name: 'statusKeymap',
35
+ plugin: keymapPlugin
36
+ }];
37
+ },
38
+ actions: {
39
+ commitStatusPicker: commitStatusPicker,
40
+ updateStatus: updateStatusWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
41
+ },
42
+ commands: {
43
+ removeStatus: removeStatus,
44
+ insertStatus: insertStatus(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
45
+ },
46
+ getSharedState: function getSharedState(state) {
47
+ if (!state) {
48
+ return undefined;
49
+ }
50
+ var pluginState = pluginKey.getState(state);
51
+ return pluginState ? {
52
+ isNew: pluginState.isNew,
53
+ showStatusPickerAt: pluginState.showStatusPickerAt,
54
+ focusStatusInput: pluginState.focusStatusInput
55
+ } : undefined;
56
+ },
57
+ pluginsOptions: {
58
+ quickInsert: function quickInsert(_ref2) {
59
+ var formatMessage = _ref2.formatMessage;
60
+ if ((options === null || options === void 0 ? void 0 : options.menuDisabled) === true) {
61
+ return [];
62
+ }
63
+ return [{
64
+ id: 'status',
65
+ title: formatMessage(messages.status),
66
+ description: formatMessage(messages.statusDescription),
67
+ priority: 700,
68
+ keywords: ['lozenge'],
69
+ icon: function icon() {
70
+ return /*#__PURE__*/React.createElement(IconStatus, null);
71
+ },
72
+ action: function action(_insert, state) {
73
+ var _insertStatus, _api$analytics3;
74
+ return (_insertStatus = insertStatus(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)(INPUT_METHOD.QUICK_INSERT)({
75
+ tr: state.tr
76
+ })) !== null && _insertStatus !== void 0 ? _insertStatus : state.tr;
77
+ }
78
+ }];
79
+ },
80
+ floatingToolbar: function floatingToolbar(state, intl) {
81
+ var _api$editorViewMode;
82
+ var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
83
+ if (!fg('platform_inline_node_as_valid_annotation_selection') || !isViewMode) {
84
+ return undefined;
85
+ }
86
+ return {
87
+ title: 'Status floating toolbar',
88
+ nodeType: state.schema.nodes.status,
89
+ onPositionCalculated: calculateToolbarPositionAboveSelection('Status floating toolbar'),
90
+ items: function items(node) {
91
+ var _api$annotation;
92
+ var annotationState = api === null || api === void 0 || (_api$annotation = api.annotation) === null || _api$annotation === void 0 ? void 0 : _api$annotation.sharedState.currentState();
93
+ var hasActiveMark = node.marks.some(function (mark) {
94
+ return mark.type.name === 'annotation' && (annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations[mark.attrs.id]) === false;
95
+ });
96
+ var showAnnotation = annotationState && isViewMode && annotationState.isVisible && !annotationState.bookmark && !annotationState.mouseData.isSelecting && !hasActiveMark;
97
+ var onCommentClick = function onCommentClick(stateFromClickEvent, dispatch) {
98
+ if (!(api !== null && api !== void 0 && api.annotation)) {
99
+ return true;
100
+ }
101
+ var command = api.annotation.actions.setInlineCommentDraftState(true, INPUT_METHOD.TOOLBAR);
102
+ return command(stateFromClickEvent, dispatch);
103
+ };
104
+ var createCommentMessage = intl.formatMessage(annotationMessages.createComment);
105
+ var commentItems = showAnnotation ? [{
106
+ type: 'button',
107
+ title: createCommentMessage,
108
+ onClick: onCommentClick,
109
+ showTitle: true,
110
+ tooltipContent: /*#__PURE__*/React.createElement(ToolTipContent, {
111
+ description: createCommentMessage,
112
+ keymap: addInlineComment
113
+ }),
114
+ icon: CommentIcon,
115
+ supportsViewMode: true
116
+ }] : [];
117
+ return [].concat(commentItems);
118
+ }
119
+ };
120
+ }
121
+ },
122
+ contentComponent: function contentComponent(_ref3) {
123
+ var editorView = _ref3.editorView,
124
+ popupsMountPoint = _ref3.popupsMountPoint,
125
+ popupsBoundariesElement = _ref3.popupsBoundariesElement,
126
+ popupsScrollableElement = _ref3.popupsScrollableElement;
127
+ var domAtPos = editorView.domAtPos.bind(editorView);
128
+ return /*#__PURE__*/React.createElement(ContentComponent, {
129
+ domAtPos: domAtPos,
130
+ api: api,
131
+ editorView: editorView,
132
+ popupsMountPoint: popupsMountPoint,
133
+ popupsBoundariesElement: popupsBoundariesElement,
134
+ popupsScrollableElement: popupsScrollableElement
135
+ });
136
+ }
137
+ };
138
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useMemo } from 'react';
2
2
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
3
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
4
- import { commitStatusPicker, updateStatus } from '../actions';
4
+ import { commitStatusPicker, updateStatus } from '../pm-plugins/actions';
5
5
  import StatusPicker from './statusPicker';
6
6
  export function ContentComponent(_ref) {
7
7
  var api = _ref.api,