@atlaskit/editor-plugin-status 2.5.9 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cjs/plugin.js +81 -41
- package/dist/cjs/ui/statusPicker.js +2 -6
- package/dist/es2019/plugin.js +76 -34
- package/dist/es2019/ui/statusPicker.js +2 -6
- package/dist/esm/plugin.js +83 -42
- package/dist/esm/ui/statusPicker.js +2 -6
- package/dist/types/plugin.d.ts +26 -2
- package/dist/types-ts4.5/plugin.d.ts +24 -2
- package/package.json +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-status
|
|
2
2
|
|
|
3
|
+
## 2.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#174097](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/174097)
|
|
8
|
+
[`b691b87e73dc2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b691b87e73dc2) -
|
|
9
|
+
[ux] ED-25902-add-floating-toolbar-in-view-mode
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 2.5.10
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 2.5.9
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -8,14 +8,24 @@ exports.statusPlugin = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
+
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
11
12
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
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");
|
|
13
17
|
var _actions = require("./actions");
|
|
14
18
|
var _keymap = require("./pm-plugins/keymap");
|
|
15
19
|
var _plugin = _interopRequireDefault(require("./pm-plugins/plugin"));
|
|
16
20
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
17
21
|
var _ContentComponent = require("./ui/ContentComponent");
|
|
18
|
-
|
|
22
|
+
// This dummy type is to bypass the typescript compiler maximum length limit error
|
|
23
|
+
// TODO: Fix the type definition of editor-core's createUniversalPreset
|
|
24
|
+
|
|
25
|
+
// This dummy type is to bypass the typescript compiler maximum length limit error
|
|
26
|
+
// TODO: Fix the type definition of editor-core's createUniversalPreset
|
|
27
|
+
|
|
28
|
+
var statusPlugin = exports.statusPlugin = function statusPlugin(_ref) {
|
|
19
29
|
var _api$analytics, _api$analytics2;
|
|
20
30
|
var options = _ref.config,
|
|
21
31
|
api = _ref.api;
|
|
@@ -57,11 +67,76 @@ var baseStatusPlugin = function baseStatusPlugin(_ref) {
|
|
|
57
67
|
focusStatusInput: pluginState.focusStatusInput
|
|
58
68
|
} : undefined;
|
|
59
69
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
70
|
+
pluginsOptions: {
|
|
71
|
+
quickInsert: function quickInsert(_ref2) {
|
|
72
|
+
var formatMessage = _ref2.formatMessage;
|
|
73
|
+
if ((options === null || options === void 0 ? void 0 : options.menuDisabled) === true) {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
return [{
|
|
77
|
+
id: 'status',
|
|
78
|
+
title: formatMessage(_messages.toolbarInsertBlockMessages.status),
|
|
79
|
+
description: formatMessage(_messages.toolbarInsertBlockMessages.statusDescription),
|
|
80
|
+
priority: 700,
|
|
81
|
+
keywords: ['lozenge'],
|
|
82
|
+
icon: function icon() {
|
|
83
|
+
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconStatus, null);
|
|
84
|
+
},
|
|
85
|
+
action: function action(_insert, state) {
|
|
86
|
+
var _insertStatus, _api$analytics3;
|
|
87
|
+
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)({
|
|
88
|
+
tr: state.tr
|
|
89
|
+
})) !== null && _insertStatus !== void 0 ? _insertStatus : state.tr;
|
|
90
|
+
}
|
|
91
|
+
}];
|
|
92
|
+
},
|
|
93
|
+
floatingToolbar: function floatingToolbar(state, intl) {
|
|
94
|
+
var _api$editorViewMode;
|
|
95
|
+
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';
|
|
96
|
+
if (!(0, _platformFeatureFlags.fg)('platform_inline_node_as_valid_annotation_selection') || !isViewMode) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
title: 'Status floating toolbar',
|
|
101
|
+
nodeType: state.schema.nodes.status,
|
|
102
|
+
onPositionCalculated: (0, _utils.calculateToolbarPositionAboveSelection)('Status floating toolbar'),
|
|
103
|
+
items: function items(node) {
|
|
104
|
+
var _api$annotation;
|
|
105
|
+
var annotationState = api === null || api === void 0 || (_api$annotation = api.annotation) === null || _api$annotation === void 0 ? void 0 : _api$annotation.sharedState.currentState();
|
|
106
|
+
var hasActiveMark = node.marks.some(function (mark) {
|
|
107
|
+
return mark.type.name === 'annotation' && (annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations[mark.attrs.id]) === false;
|
|
108
|
+
});
|
|
109
|
+
var showAnnotation = annotationState && isViewMode && annotationState.isVisible && !annotationState.bookmark && !annotationState.mouseData.isSelecting && !hasActiveMark;
|
|
110
|
+
var onCommentClick = function onCommentClick(stateFromClickEvent, dispatch) {
|
|
111
|
+
if (!(api !== null && api !== void 0 && api.annotation)) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
var command = api.annotation.actions.setInlineCommentDraftState(true, _analytics.INPUT_METHOD.TOOLBAR);
|
|
115
|
+
return command(stateFromClickEvent, dispatch);
|
|
116
|
+
};
|
|
117
|
+
var createCommentMessage = intl.formatMessage(_messages.annotationMessages.createComment);
|
|
118
|
+
var commentItems = showAnnotation ? [{
|
|
119
|
+
type: 'button',
|
|
120
|
+
title: createCommentMessage,
|
|
121
|
+
onClick: onCommentClick,
|
|
122
|
+
showTitle: true,
|
|
123
|
+
tooltipContent: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
|
|
124
|
+
description: createCommentMessage,
|
|
125
|
+
keymap: _keymaps.addInlineComment
|
|
126
|
+
}),
|
|
127
|
+
icon: _comment.default,
|
|
128
|
+
supportsViewMode: true
|
|
129
|
+
}] : [];
|
|
130
|
+
return [].concat(commentItems);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
contentComponent: function contentComponent(_ref3) {
|
|
136
|
+
var editorView = _ref3.editorView,
|
|
137
|
+
popupsMountPoint = _ref3.popupsMountPoint,
|
|
138
|
+
popupsBoundariesElement = _ref3.popupsBoundariesElement,
|
|
139
|
+
popupsScrollableElement = _ref3.popupsScrollableElement;
|
|
65
140
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
66
141
|
return /*#__PURE__*/_react.default.createElement(_ContentComponent.ContentComponent, {
|
|
67
142
|
domAtPos: domAtPos,
|
|
@@ -73,39 +148,4 @@ var baseStatusPlugin = function baseStatusPlugin(_ref) {
|
|
|
73
148
|
});
|
|
74
149
|
}
|
|
75
150
|
};
|
|
76
|
-
};
|
|
77
|
-
var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, options, api) {
|
|
78
|
-
if ((options === null || options === void 0 ? void 0 : options.menuDisabled) === true) {
|
|
79
|
-
return plugin;
|
|
80
|
-
}
|
|
81
|
-
plugin.pluginsOptions = {
|
|
82
|
-
quickInsert: function quickInsert(_ref3) {
|
|
83
|
-
var formatMessage = _ref3.formatMessage;
|
|
84
|
-
return [{
|
|
85
|
-
id: 'status',
|
|
86
|
-
title: formatMessage(_messages.toolbarInsertBlockMessages.status),
|
|
87
|
-
description: formatMessage(_messages.toolbarInsertBlockMessages.statusDescription),
|
|
88
|
-
priority: 700,
|
|
89
|
-
keywords: ['lozenge'],
|
|
90
|
-
icon: function icon() {
|
|
91
|
-
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconStatus, null);
|
|
92
|
-
},
|
|
93
|
-
action: function action(insert, state) {
|
|
94
|
-
var _insertStatus, _api$analytics3;
|
|
95
|
-
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)({
|
|
96
|
-
tr: state.tr
|
|
97
|
-
})) !== null && _insertStatus !== void 0 ? _insertStatus : state.tr;
|
|
98
|
-
}
|
|
99
|
-
}];
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
return plugin;
|
|
103
|
-
};
|
|
104
|
-
var statusPlugin = exports.statusPlugin = function statusPlugin(_ref4) {
|
|
105
|
-
var options = _ref4.config,
|
|
106
|
-
api = _ref4.api;
|
|
107
|
-
return decorateWithPluginOptions(baseStatusPlugin({
|
|
108
|
-
config: options,
|
|
109
|
-
api: api
|
|
110
|
-
}), options, api);
|
|
111
151
|
};
|
|
@@ -303,9 +303,7 @@ var StatusPickerWithoutAnalytcs = exports.StatusPickerWithoutAnalytcs = /*#__PUR
|
|
|
303
303
|
ref: this.setRef(setOutsideClickTargetRef),
|
|
304
304
|
onClick: this.handlePopupClick,
|
|
305
305
|
onKeyDown: this.onKeyDown
|
|
306
|
-
}, (0, _react2.jsx)(_picker.StatusPicker
|
|
307
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
308
|
-
, {
|
|
306
|
+
}, (0, _react2.jsx)(_picker.StatusPicker, {
|
|
309
307
|
autoFocus: isNew || focusStatusInput,
|
|
310
308
|
selectedColor: color,
|
|
311
309
|
text: text,
|
|
@@ -351,9 +349,7 @@ var StatusPickerWithoutAnalytcs = exports.StatusPickerWithoutAnalytcs = /*#__PUR
|
|
|
351
349
|
tabIndex: -1,
|
|
352
350
|
onClick: this.handlePopupClick,
|
|
353
351
|
onKeyDown: this.onKeyDown
|
|
354
|
-
}, (0, _react2.jsx)(_picker.StatusPicker
|
|
355
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
356
|
-
, {
|
|
352
|
+
}, (0, _react2.jsx)(_picker.StatusPicker, {
|
|
357
353
|
autoFocus: isNew || focusStatusInput,
|
|
358
354
|
selectedColor: color,
|
|
359
355
|
text: text,
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { status } from '@atlaskit/adf-schema';
|
|
3
3
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import {
|
|
4
|
+
import { addInlineComment, ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
5
|
+
import { annotationMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
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';
|
|
6
10
|
import { commitStatusPicker, insertStatus, removeStatus, updateStatusWithAnalytics } from './actions';
|
|
7
11
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
8
12
|
import createStatusPlugin from './pm-plugins/plugin';
|
|
9
13
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
10
14
|
import { ContentComponent } from './ui/ContentComponent';
|
|
11
|
-
|
|
15
|
+
|
|
16
|
+
// This dummy type is to bypass the typescript compiler maximum length limit error
|
|
17
|
+
// TODO: Fix the type definition of editor-core's createUniversalPreset
|
|
18
|
+
|
|
19
|
+
// This dummy type is to bypass the typescript compiler maximum length limit error
|
|
20
|
+
// TODO: Fix the type definition of editor-core's createUniversalPreset
|
|
21
|
+
|
|
22
|
+
export const statusPlugin = ({
|
|
12
23
|
config: options,
|
|
13
24
|
api
|
|
14
25
|
}) => {
|
|
@@ -49,6 +60,68 @@ const baseStatusPlugin = ({
|
|
|
49
60
|
focusStatusInput: pluginState.focusStatusInput
|
|
50
61
|
} : undefined;
|
|
51
62
|
},
|
|
63
|
+
pluginsOptions: {
|
|
64
|
+
quickInsert: ({
|
|
65
|
+
formatMessage
|
|
66
|
+
}) => {
|
|
67
|
+
if ((options === null || options === void 0 ? void 0 : options.menuDisabled) === true) {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
return [{
|
|
71
|
+
id: 'status',
|
|
72
|
+
title: formatMessage(messages.status),
|
|
73
|
+
description: formatMessage(messages.statusDescription),
|
|
74
|
+
priority: 700,
|
|
75
|
+
keywords: ['lozenge'],
|
|
76
|
+
icon: () => /*#__PURE__*/React.createElement(IconStatus, null),
|
|
77
|
+
action(_insert, state) {
|
|
78
|
+
var _insertStatus, _api$analytics3;
|
|
79
|
+
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)({
|
|
80
|
+
tr: state.tr
|
|
81
|
+
})) !== null && _insertStatus !== void 0 ? _insertStatus : state.tr;
|
|
82
|
+
}
|
|
83
|
+
}];
|
|
84
|
+
},
|
|
85
|
+
floatingToolbar(state, intl) {
|
|
86
|
+
var _api$editorViewMode, _api$editorViewMode$s;
|
|
87
|
+
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';
|
|
88
|
+
if (!fg('platform_inline_node_as_valid_annotation_selection') || !isViewMode) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
title: 'Status floating toolbar',
|
|
93
|
+
nodeType: state.schema.nodes.status,
|
|
94
|
+
onPositionCalculated: calculateToolbarPositionAboveSelection('Status floating toolbar'),
|
|
95
|
+
items: node => {
|
|
96
|
+
var _api$annotation;
|
|
97
|
+
const annotationState = api === null || api === void 0 ? void 0 : (_api$annotation = api.annotation) === null || _api$annotation === void 0 ? void 0 : _api$annotation.sharedState.currentState();
|
|
98
|
+
const hasActiveMark = node.marks.some(mark => mark.type.name === 'annotation' && (annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations[mark.attrs.id]) === false);
|
|
99
|
+
const showAnnotation = annotationState && isViewMode && annotationState.isVisible && !annotationState.bookmark && !annotationState.mouseData.isSelecting && !hasActiveMark;
|
|
100
|
+
const onCommentClick = (stateFromClickEvent, dispatch) => {
|
|
101
|
+
if (!(api !== null && api !== void 0 && api.annotation)) {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
const command = api.annotation.actions.setInlineCommentDraftState(true, INPUT_METHOD.TOOLBAR);
|
|
105
|
+
return command(stateFromClickEvent, dispatch);
|
|
106
|
+
};
|
|
107
|
+
const createCommentMessage = intl.formatMessage(annotationMessages.createComment);
|
|
108
|
+
const commentItems = showAnnotation ? [{
|
|
109
|
+
type: 'button',
|
|
110
|
+
title: createCommentMessage,
|
|
111
|
+
onClick: onCommentClick,
|
|
112
|
+
showTitle: true,
|
|
113
|
+
tooltipContent: /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
114
|
+
description: createCommentMessage,
|
|
115
|
+
keymap: addInlineComment
|
|
116
|
+
}),
|
|
117
|
+
icon: CommentIcon,
|
|
118
|
+
supportsViewMode: true
|
|
119
|
+
}] : [];
|
|
120
|
+
return [...commentItems];
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
},
|
|
52
125
|
contentComponent({
|
|
53
126
|
editorView,
|
|
54
127
|
popupsMountPoint,
|
|
@@ -66,35 +139,4 @@ const baseStatusPlugin = ({
|
|
|
66
139
|
});
|
|
67
140
|
}
|
|
68
141
|
};
|
|
69
|
-
};
|
|
70
|
-
const decorateWithPluginOptions = (plugin, options, api) => {
|
|
71
|
-
if ((options === null || options === void 0 ? void 0 : options.menuDisabled) === true) {
|
|
72
|
-
return plugin;
|
|
73
|
-
}
|
|
74
|
-
plugin.pluginsOptions = {
|
|
75
|
-
quickInsert: ({
|
|
76
|
-
formatMessage
|
|
77
|
-
}) => [{
|
|
78
|
-
id: 'status',
|
|
79
|
-
title: formatMessage(messages.status),
|
|
80
|
-
description: formatMessage(messages.statusDescription),
|
|
81
|
-
priority: 700,
|
|
82
|
-
keywords: ['lozenge'],
|
|
83
|
-
icon: () => /*#__PURE__*/React.createElement(IconStatus, null),
|
|
84
|
-
action(insert, state) {
|
|
85
|
-
var _insertStatus, _api$analytics3;
|
|
86
|
-
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)({
|
|
87
|
-
tr: state.tr
|
|
88
|
-
})) !== null && _insertStatus !== void 0 ? _insertStatus : state.tr;
|
|
89
|
-
}
|
|
90
|
-
}]
|
|
91
|
-
};
|
|
92
|
-
return plugin;
|
|
93
|
-
};
|
|
94
|
-
export const statusPlugin = ({
|
|
95
|
-
config: options,
|
|
96
|
-
api
|
|
97
|
-
}) => decorateWithPluginOptions(baseStatusPlugin({
|
|
98
|
-
config: options,
|
|
99
|
-
api
|
|
100
|
-
}), options, api);
|
|
142
|
+
};
|
|
@@ -276,9 +276,7 @@ export class StatusPickerWithoutAnalytcs extends React.Component {
|
|
|
276
276
|
ref: this.setRef(setOutsideClickTargetRef),
|
|
277
277
|
onClick: this.handlePopupClick,
|
|
278
278
|
onKeyDown: this.onKeyDown
|
|
279
|
-
}, jsx(AkStatusPicker
|
|
280
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
281
|
-
, {
|
|
279
|
+
}, jsx(AkStatusPicker, {
|
|
282
280
|
autoFocus: isNew || focusStatusInput,
|
|
283
281
|
selectedColor: color,
|
|
284
282
|
text: text,
|
|
@@ -324,9 +322,7 @@ export class StatusPickerWithoutAnalytcs extends React.Component {
|
|
|
324
322
|
tabIndex: -1,
|
|
325
323
|
onClick: this.handlePopupClick,
|
|
326
324
|
onKeyDown: this.onKeyDown
|
|
327
|
-
}, jsx(AkStatusPicker
|
|
328
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
329
|
-
, {
|
|
325
|
+
}, jsx(AkStatusPicker, {
|
|
330
326
|
autoFocus: isNew || focusStatusInput,
|
|
331
327
|
selectedColor: color,
|
|
332
328
|
text: text,
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { status } from '@atlaskit/adf-schema';
|
|
3
3
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import {
|
|
4
|
+
import { addInlineComment, ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
5
|
+
import { annotationMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
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';
|
|
6
10
|
import { commitStatusPicker, insertStatus, removeStatus, updateStatusWithAnalytics } from './actions';
|
|
7
11
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
8
12
|
import createStatusPlugin from './pm-plugins/plugin';
|
|
9
13
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
10
14
|
import { ContentComponent } from './ui/ContentComponent';
|
|
11
|
-
|
|
15
|
+
|
|
16
|
+
// This dummy type is to bypass the typescript compiler maximum length limit error
|
|
17
|
+
// TODO: Fix the type definition of editor-core's createUniversalPreset
|
|
18
|
+
|
|
19
|
+
// This dummy type is to bypass the typescript compiler maximum length limit error
|
|
20
|
+
// TODO: Fix the type definition of editor-core's createUniversalPreset
|
|
21
|
+
|
|
22
|
+
export var statusPlugin = function statusPlugin(_ref) {
|
|
12
23
|
var _api$analytics, _api$analytics2;
|
|
13
24
|
var options = _ref.config,
|
|
14
25
|
api = _ref.api;
|
|
@@ -50,11 +61,76 @@ var baseStatusPlugin = function baseStatusPlugin(_ref) {
|
|
|
50
61
|
focusStatusInput: pluginState.focusStatusInput
|
|
51
62
|
} : undefined;
|
|
52
63
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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.status),
|
|
73
|
+
description: formatMessage(messages.statusDescription),
|
|
74
|
+
priority: 700,
|
|
75
|
+
keywords: ['lozenge'],
|
|
76
|
+
icon: function icon() {
|
|
77
|
+
return /*#__PURE__*/React.createElement(IconStatus, null);
|
|
78
|
+
},
|
|
79
|
+
action: function action(_insert, state) {
|
|
80
|
+
var _insertStatus, _api$analytics3;
|
|
81
|
+
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)({
|
|
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 (!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: 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, INPUT_METHOD.TOOLBAR);
|
|
109
|
+
return command(stateFromClickEvent, dispatch);
|
|
110
|
+
};
|
|
111
|
+
var createCommentMessage = intl.formatMessage(annotationMessages.createComment);
|
|
112
|
+
var commentItems = showAnnotation ? [{
|
|
113
|
+
type: 'button',
|
|
114
|
+
title: createCommentMessage,
|
|
115
|
+
onClick: onCommentClick,
|
|
116
|
+
showTitle: true,
|
|
117
|
+
tooltipContent: /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
118
|
+
description: createCommentMessage,
|
|
119
|
+
keymap: addInlineComment
|
|
120
|
+
}),
|
|
121
|
+
icon: CommentIcon,
|
|
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;
|
|
58
134
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
59
135
|
return /*#__PURE__*/React.createElement(ContentComponent, {
|
|
60
136
|
domAtPos: domAtPos,
|
|
@@ -66,39 +142,4 @@ var baseStatusPlugin = function baseStatusPlugin(_ref) {
|
|
|
66
142
|
});
|
|
67
143
|
}
|
|
68
144
|
};
|
|
69
|
-
};
|
|
70
|
-
var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, options, api) {
|
|
71
|
-
if ((options === null || options === void 0 ? void 0 : options.menuDisabled) === true) {
|
|
72
|
-
return plugin;
|
|
73
|
-
}
|
|
74
|
-
plugin.pluginsOptions = {
|
|
75
|
-
quickInsert: function quickInsert(_ref3) {
|
|
76
|
-
var formatMessage = _ref3.formatMessage;
|
|
77
|
-
return [{
|
|
78
|
-
id: 'status',
|
|
79
|
-
title: formatMessage(messages.status),
|
|
80
|
-
description: formatMessage(messages.statusDescription),
|
|
81
|
-
priority: 700,
|
|
82
|
-
keywords: ['lozenge'],
|
|
83
|
-
icon: function icon() {
|
|
84
|
-
return /*#__PURE__*/React.createElement(IconStatus, null);
|
|
85
|
-
},
|
|
86
|
-
action: function action(insert, state) {
|
|
87
|
-
var _insertStatus, _api$analytics3;
|
|
88
|
-
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)({
|
|
89
|
-
tr: state.tr
|
|
90
|
-
})) !== null && _insertStatus !== void 0 ? _insertStatus : state.tr;
|
|
91
|
-
}
|
|
92
|
-
}];
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
return plugin;
|
|
96
|
-
};
|
|
97
|
-
export var statusPlugin = function statusPlugin(_ref4) {
|
|
98
|
-
var options = _ref4.config,
|
|
99
|
-
api = _ref4.api;
|
|
100
|
-
return decorateWithPluginOptions(baseStatusPlugin({
|
|
101
|
-
config: options,
|
|
102
|
-
api: api
|
|
103
|
-
}), options, api);
|
|
104
145
|
};
|
|
@@ -300,9 +300,7 @@ export var StatusPickerWithoutAnalytcs = /*#__PURE__*/function (_React$Component
|
|
|
300
300
|
ref: this.setRef(setOutsideClickTargetRef),
|
|
301
301
|
onClick: this.handlePopupClick,
|
|
302
302
|
onKeyDown: this.onKeyDown
|
|
303
|
-
}, jsx(AkStatusPicker
|
|
304
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
305
|
-
, {
|
|
303
|
+
}, jsx(AkStatusPicker, {
|
|
306
304
|
autoFocus: isNew || focusStatusInput,
|
|
307
305
|
selectedColor: color,
|
|
308
306
|
text: text,
|
|
@@ -348,9 +346,7 @@ export var StatusPickerWithoutAnalytcs = /*#__PURE__*/function (_React$Component
|
|
|
348
346
|
tabIndex: -1,
|
|
349
347
|
onClick: this.handlePopupClick,
|
|
350
348
|
onKeyDown: this.onKeyDown
|
|
351
|
-
}, jsx(AkStatusPicker
|
|
352
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
353
|
-
, {
|
|
349
|
+
}, jsx(AkStatusPicker, {
|
|
354
350
|
autoFocus: isNew || focusStatusInput,
|
|
355
351
|
selectedColor: color,
|
|
356
352
|
text: text,
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { NextEditorPlugin, OptionalPlugin, Command } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
4
|
import type { UpdateStatus } from './actions';
|
|
4
5
|
import { commitStatusPicker, insertStatus, removeStatus } from './actions';
|
|
5
6
|
import type { StatusPluginOptions, StatusState } from './types';
|
|
7
|
+
type DummyAnnotationPlugin = NextEditorPlugin<'annotation', {
|
|
8
|
+
actions: {
|
|
9
|
+
setInlineCommentDraftState: (isDraft: boolean, inputMethod: INPUT_METHOD) => Command;
|
|
10
|
+
};
|
|
11
|
+
sharedState: {
|
|
12
|
+
annotations: Record<string, boolean>;
|
|
13
|
+
isVisible: boolean;
|
|
14
|
+
bookmark: boolean;
|
|
15
|
+
mouseData: {
|
|
16
|
+
isSelecting: boolean;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
20
|
+
type DummyEditorViewModePlugin = NextEditorPlugin<'editorViewMode', {
|
|
21
|
+
sharedState: {
|
|
22
|
+
mode: 'view' | 'edit';
|
|
23
|
+
};
|
|
24
|
+
}>;
|
|
6
25
|
export type StatusPlugin = NextEditorPlugin<'status', {
|
|
7
|
-
dependencies: [
|
|
26
|
+
dependencies: [
|
|
27
|
+
OptionalPlugin<AnalyticsPlugin>,
|
|
28
|
+
OptionalPlugin<DummyAnnotationPlugin>,
|
|
29
|
+
OptionalPlugin<DummyEditorViewModePlugin>
|
|
30
|
+
];
|
|
8
31
|
pluginConfiguration: StatusPluginOptions | undefined;
|
|
9
32
|
actions: {
|
|
10
33
|
commitStatusPicker: typeof commitStatusPicker;
|
|
@@ -17,3 +40,4 @@ export type StatusPlugin = NextEditorPlugin<'status', {
|
|
|
17
40
|
sharedState: StatusState | undefined;
|
|
18
41
|
}>;
|
|
19
42
|
export declare const statusPlugin: StatusPlugin;
|
|
43
|
+
export {};
|
|
@@ -1,11 +1,32 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { NextEditorPlugin, OptionalPlugin, Command } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
4
|
import type { UpdateStatus } from './actions';
|
|
4
5
|
import { commitStatusPicker, insertStatus, removeStatus } from './actions';
|
|
5
6
|
import type { StatusPluginOptions, StatusState } from './types';
|
|
7
|
+
type DummyAnnotationPlugin = NextEditorPlugin<'annotation', {
|
|
8
|
+
actions: {
|
|
9
|
+
setInlineCommentDraftState: (isDraft: boolean, inputMethod: INPUT_METHOD) => Command;
|
|
10
|
+
};
|
|
11
|
+
sharedState: {
|
|
12
|
+
annotations: Record<string, boolean>;
|
|
13
|
+
isVisible: boolean;
|
|
14
|
+
bookmark: boolean;
|
|
15
|
+
mouseData: {
|
|
16
|
+
isSelecting: boolean;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
20
|
+
type DummyEditorViewModePlugin = NextEditorPlugin<'editorViewMode', {
|
|
21
|
+
sharedState: {
|
|
22
|
+
mode: 'view' | 'edit';
|
|
23
|
+
};
|
|
24
|
+
}>;
|
|
6
25
|
export type StatusPlugin = NextEditorPlugin<'status', {
|
|
7
26
|
dependencies: [
|
|
8
|
-
OptionalPlugin<AnalyticsPlugin
|
|
27
|
+
OptionalPlugin<AnalyticsPlugin>,
|
|
28
|
+
OptionalPlugin<DummyAnnotationPlugin>,
|
|
29
|
+
OptionalPlugin<DummyEditorViewModePlugin>
|
|
9
30
|
];
|
|
10
31
|
pluginConfiguration: StatusPluginOptions | undefined;
|
|
11
32
|
actions: {
|
|
@@ -19,3 +40,4 @@ export type StatusPlugin = NextEditorPlugin<'status', {
|
|
|
19
40
|
sharedState: StatusState | undefined;
|
|
20
41
|
}>;
|
|
21
42
|
export declare const statusPlugin: StatusPlugin;
|
|
43
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-status",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Status plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,14 +33,15 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
35
35
|
"@atlaskit/analytics-next": "^10.1.0",
|
|
36
|
-
"@atlaskit/editor-common": "^
|
|
36
|
+
"@atlaskit/editor-common": "^96.3.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
38
|
-
"@atlaskit/editor-prosemirror": "6.
|
|
38
|
+
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
39
39
|
"@atlaskit/editor-shared-styles": "^3.2.0",
|
|
40
|
+
"@atlaskit/icon": "^23.1.0",
|
|
40
41
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
41
42
|
"@atlaskit/status": "^1.8.0",
|
|
42
43
|
"@atlaskit/theme": "^14.0.0",
|
|
43
|
-
"@atlaskit/tokens": "^2.
|
|
44
|
+
"@atlaskit/tokens": "^2.4.0",
|
|
44
45
|
"@babel/runtime": "^7.0.0",
|
|
45
46
|
"@emotion/react": "^11.7.1"
|
|
46
47
|
},
|
|
@@ -99,6 +100,9 @@
|
|
|
99
100
|
},
|
|
100
101
|
"platform_editor_replace_finddomnode_in_common": {
|
|
101
102
|
"type": "boolean"
|
|
103
|
+
},
|
|
104
|
+
"platform_inline_node_as_valid_annotation_selection": {
|
|
105
|
+
"type": "boolean"
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
}
|