@atlaskit/editor-plugin-status 2.0.0 → 2.1.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 +19 -0
- package/dist/cjs/actions.js +34 -16
- package/dist/cjs/plugin.js +7 -14
- package/dist/es2019/actions.js +22 -8
- package/dist/es2019/plugin.js +9 -16
- package/dist/esm/actions.js +34 -16
- package/dist/esm/plugin.js +9 -16
- package/dist/types/actions.d.ts +4 -2
- package/dist/types/plugin.d.ts +2 -1
- package/dist/types-ts4.5/actions.d.ts +4 -2
- package/dist/types-ts4.5/plugin.d.ts +2 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-status
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#117356](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117356)
|
|
8
|
+
[`9d772a51e5663`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9d772a51e5663) -
|
|
9
|
+
[ux] Fix inserting status from insert block dropdown.
|
|
10
|
+
|
|
11
|
+
Introduces new command on status plugin "insertStatus" which can be used by toolbars to insert a
|
|
12
|
+
status node.
|
|
13
|
+
|
|
14
|
+
Example:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
return pluginInjectionApi?.core?.actions.execute(
|
|
18
|
+
pluginInjectionApi?.status?.commands?.insertStatus(inputMethod),
|
|
19
|
+
);
|
|
20
|
+
```
|
|
21
|
+
|
|
3
22
|
## 2.0.0
|
|
4
23
|
|
|
5
24
|
### Major Changes
|
package/dist/cjs/actions.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.verifyAndInsertStatus = exports.updateStatusWithAnalytics = exports.updateStatus = exports.setStatusPickerAt = exports.setFocusOnStatusInput = exports.removeStatus = exports.createStatus = exports.commitStatusPicker = exports.DEFAULT_STATUS = void 0;
|
|
7
|
+
exports.verifyAndInsertStatus = exports.updateStatusWithAnalytics = exports.updateStatus = exports.setStatusPickerAt = exports.setFocusOnStatusInput = exports.removeStatus = exports.insertStatus = exports.createStatus = exports.commitStatusPicker = exports.DEFAULT_STATUS = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
@@ -19,9 +19,8 @@ var DEFAULT_STATUS = exports.DEFAULT_STATUS = {
|
|
|
19
19
|
text: '',
|
|
20
20
|
color: 'neutral'
|
|
21
21
|
};
|
|
22
|
-
var verifyAndInsertStatus = exports.verifyAndInsertStatus = function verifyAndInsertStatus(statusNode,
|
|
23
|
-
var fragment = _model.Fragment.fromArray([statusNode,
|
|
24
|
-
var tr = state.tr;
|
|
22
|
+
var verifyAndInsertStatus = exports.verifyAndInsertStatus = function verifyAndInsertStatus(statusNode, tr) {
|
|
23
|
+
var fragment = _model.Fragment.fromArray([statusNode, tr.doc.type.schema.text(' ')]);
|
|
25
24
|
var insertable = (0, _utils.canInsert)(tr.selection.$from, fragment);
|
|
26
25
|
if (!insertable) {
|
|
27
26
|
var parentSelection = _state.NodeSelection.create(tr.doc, tr.selection.from - tr.selection.$anchor.parentOffset - 1);
|
|
@@ -34,11 +33,30 @@ var verifyAndInsertStatus = exports.verifyAndInsertStatus = function verifyAndIn
|
|
|
34
33
|
isNew: true
|
|
35
34
|
}).scrollIntoView();
|
|
36
35
|
};
|
|
37
|
-
var createStatus = exports.createStatus = function createStatus(
|
|
38
|
-
var statusNode =
|
|
36
|
+
var createStatus = exports.createStatus = function createStatus(tr) {
|
|
37
|
+
var statusNode = tr.doc.type.schema.nodes.status.createChecked(_objectSpread(_objectSpread({}, DEFAULT_STATUS), {}, {
|
|
39
38
|
localId: _adfSchema.uuid.generate()
|
|
40
39
|
}));
|
|
41
|
-
return verifyAndInsertStatus(statusNode,
|
|
40
|
+
return verifyAndInsertStatus(statusNode, tr);
|
|
41
|
+
};
|
|
42
|
+
var insertStatus = exports.insertStatus = function insertStatus(editorAnalyticsAPI) {
|
|
43
|
+
return function () {
|
|
44
|
+
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _analytics.INPUT_METHOD.TOOLBAR;
|
|
45
|
+
return function (_ref) {
|
|
46
|
+
var tr = _ref.tr;
|
|
47
|
+
var statusTr = createStatus(tr);
|
|
48
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
49
|
+
action: _analytics.ACTION.INSERTED,
|
|
50
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
51
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.STATUS,
|
|
52
|
+
attributes: {
|
|
53
|
+
inputMethod: inputMethod
|
|
54
|
+
},
|
|
55
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
56
|
+
})(statusTr);
|
|
57
|
+
return statusTr;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
42
60
|
};
|
|
43
61
|
var updateStatus = exports.updateStatus = function updateStatus(status) {
|
|
44
62
|
return function (state, dispatch) {
|
|
@@ -49,12 +67,12 @@ var updateStatus = exports.updateStatus = function updateStatus(status) {
|
|
|
49
67
|
}) : status;
|
|
50
68
|
var statusProps = _objectSpread(_objectSpread({}, DEFAULT_STATUS), selectedStatus);
|
|
51
69
|
var tr = state.tr;
|
|
52
|
-
var
|
|
53
|
-
showStatusPickerAt =
|
|
70
|
+
var _ref2 = _pluginKey.pluginKey.getState(state) || {},
|
|
71
|
+
showStatusPickerAt = _ref2.showStatusPickerAt;
|
|
54
72
|
if (!showStatusPickerAt) {
|
|
55
73
|
// Same behaviour as quick insert (used in createStatus)
|
|
56
74
|
var statusNode = schema.nodes.status.createChecked(statusProps);
|
|
57
|
-
tr = verifyAndInsertStatus(statusNode, state);
|
|
75
|
+
tr = verifyAndInsertStatus(statusNode, state.tr);
|
|
58
76
|
if (dispatch) {
|
|
59
77
|
dispatch(tr);
|
|
60
78
|
}
|
|
@@ -95,8 +113,8 @@ var setStatusPickerAt = exports.setStatusPickerAt = function setStatusPickerAt(s
|
|
|
95
113
|
};
|
|
96
114
|
};
|
|
97
115
|
var removeStatus = exports.removeStatus = function removeStatus(showStatusPickerAt) {
|
|
98
|
-
return function (
|
|
99
|
-
var tr =
|
|
116
|
+
return function (_ref3) {
|
|
117
|
+
var tr = _ref3.tr;
|
|
100
118
|
tr.replace(showStatusPickerAt, showStatusPickerAt + 1);
|
|
101
119
|
return tr;
|
|
102
120
|
};
|
|
@@ -126,10 +144,10 @@ var commitStatusPicker = exports.commitStatusPicker = function commitStatusPicke
|
|
|
126
144
|
return function (editorView) {
|
|
127
145
|
var state = editorView.state,
|
|
128
146
|
dispatch = editorView.dispatch;
|
|
129
|
-
var
|
|
130
|
-
showStatusPickerAt =
|
|
131
|
-
var
|
|
132
|
-
closingMethod =
|
|
147
|
+
var _ref4 = _pluginKey.pluginKey.getState(state) || {},
|
|
148
|
+
showStatusPickerAt = _ref4.showStatusPickerAt;
|
|
149
|
+
var _ref5 = closingPayload || {},
|
|
150
|
+
closingMethod = _ref5.closingMethod;
|
|
133
151
|
if (!showStatusPickerAt) {
|
|
134
152
|
return;
|
|
135
153
|
}
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -16,7 +16,7 @@ var _plugin = _interopRequireDefault(require("./pm-plugins/plugin"));
|
|
|
16
16
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
17
17
|
var _ContentComponent = require("./ui/ContentComponent");
|
|
18
18
|
var baseStatusPlugin = function baseStatusPlugin(_ref) {
|
|
19
|
-
var _api$analytics;
|
|
19
|
+
var _api$analytics, _api$analytics2;
|
|
20
20
|
var options = _ref.config,
|
|
21
21
|
api = _ref.api;
|
|
22
22
|
return {
|
|
@@ -43,7 +43,8 @@ var baseStatusPlugin = function baseStatusPlugin(_ref) {
|
|
|
43
43
|
updateStatus: (0, _actions.updateStatusWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
44
44
|
},
|
|
45
45
|
commands: {
|
|
46
|
-
removeStatus: _actions.removeStatus
|
|
46
|
+
removeStatus: _actions.removeStatus,
|
|
47
|
+
insertStatus: (0, _actions.insertStatus)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
47
48
|
},
|
|
48
49
|
getSharedState: function getSharedState(state) {
|
|
49
50
|
if (!state) {
|
|
@@ -90,18 +91,10 @@ var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, optio
|
|
|
90
91
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconStatus, null);
|
|
91
92
|
},
|
|
92
93
|
action: function action(insert, state) {
|
|
93
|
-
var _api$
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
98
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.STATUS,
|
|
99
|
-
attributes: {
|
|
100
|
-
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
|
|
101
|
-
},
|
|
102
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
103
|
-
})(tr);
|
|
104
|
-
return tr;
|
|
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;
|
|
105
98
|
}
|
|
106
99
|
}];
|
|
107
100
|
}
|
package/dist/es2019/actions.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { uuid } from '@atlaskit/adf-schema';
|
|
2
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
4
4
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -9,9 +9,8 @@ export const DEFAULT_STATUS = {
|
|
|
9
9
|
text: '',
|
|
10
10
|
color: 'neutral'
|
|
11
11
|
};
|
|
12
|
-
export const verifyAndInsertStatus = (statusNode,
|
|
13
|
-
const fragment = Fragment.fromArray([statusNode,
|
|
14
|
-
const tr = state.tr;
|
|
12
|
+
export const verifyAndInsertStatus = (statusNode, tr) => {
|
|
13
|
+
const fragment = Fragment.fromArray([statusNode, tr.doc.type.schema.text(' ')]);
|
|
15
14
|
const insertable = canInsert(tr.selection.$from, fragment);
|
|
16
15
|
if (!insertable) {
|
|
17
16
|
const parentSelection = NodeSelection.create(tr.doc, tr.selection.from - tr.selection.$anchor.parentOffset - 1);
|
|
@@ -24,12 +23,27 @@ export const verifyAndInsertStatus = (statusNode, state) => {
|
|
|
24
23
|
isNew: true
|
|
25
24
|
}).scrollIntoView();
|
|
26
25
|
};
|
|
27
|
-
export const createStatus =
|
|
28
|
-
const statusNode =
|
|
26
|
+
export const createStatus = tr => {
|
|
27
|
+
const statusNode = tr.doc.type.schema.nodes.status.createChecked({
|
|
29
28
|
...DEFAULT_STATUS,
|
|
30
29
|
localId: uuid.generate()
|
|
31
30
|
});
|
|
32
|
-
return verifyAndInsertStatus(statusNode,
|
|
31
|
+
return verifyAndInsertStatus(statusNode, tr);
|
|
32
|
+
};
|
|
33
|
+
export const insertStatus = editorAnalyticsAPI => (inputMethod = INPUT_METHOD.TOOLBAR) => ({
|
|
34
|
+
tr
|
|
35
|
+
}) => {
|
|
36
|
+
const statusTr = createStatus(tr);
|
|
37
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
38
|
+
action: ACTION.INSERTED,
|
|
39
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
40
|
+
actionSubjectId: ACTION_SUBJECT_ID.STATUS,
|
|
41
|
+
attributes: {
|
|
42
|
+
inputMethod
|
|
43
|
+
},
|
|
44
|
+
eventType: EVENT_TYPE.TRACK
|
|
45
|
+
})(statusTr);
|
|
46
|
+
return statusTr;
|
|
33
47
|
};
|
|
34
48
|
export const updateStatus = status => (state, dispatch) => {
|
|
35
49
|
const {
|
|
@@ -50,7 +64,7 @@ export const updateStatus = status => (state, dispatch) => {
|
|
|
50
64
|
if (!showStatusPickerAt) {
|
|
51
65
|
// Same behaviour as quick insert (used in createStatus)
|
|
52
66
|
const statusNode = schema.nodes.status.createChecked(statusProps);
|
|
53
|
-
tr = verifyAndInsertStatus(statusNode, state);
|
|
67
|
+
tr = verifyAndInsertStatus(statusNode, state.tr);
|
|
54
68
|
if (dispatch) {
|
|
55
69
|
dispatch(tr);
|
|
56
70
|
}
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { status } from '@atlaskit/adf-schema';
|
|
3
|
-
import {
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { IconStatus } from '@atlaskit/editor-common/quick-insert';
|
|
6
|
-
import { commitStatusPicker,
|
|
6
|
+
import { commitStatusPicker, insertStatus, removeStatus, updateStatusWithAnalytics } from './actions';
|
|
7
7
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
8
8
|
import createStatusPlugin from './pm-plugins/plugin';
|
|
9
9
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
@@ -12,7 +12,7 @@ const baseStatusPlugin = ({
|
|
|
12
12
|
config: options,
|
|
13
13
|
api
|
|
14
14
|
}) => {
|
|
15
|
-
var _api$analytics;
|
|
15
|
+
var _api$analytics, _api$analytics2;
|
|
16
16
|
return {
|
|
17
17
|
name: 'status',
|
|
18
18
|
nodes() {
|
|
@@ -35,7 +35,8 @@ const baseStatusPlugin = ({
|
|
|
35
35
|
updateStatus: updateStatusWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
36
36
|
},
|
|
37
37
|
commands: {
|
|
38
|
-
removeStatus
|
|
38
|
+
removeStatus,
|
|
39
|
+
insertStatus: insertStatus(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
39
40
|
},
|
|
40
41
|
getSharedState(state) {
|
|
41
42
|
if (!state) {
|
|
@@ -81,18 +82,10 @@ const decorateWithPluginOptions = (plugin, options, api) => {
|
|
|
81
82
|
keywords: ['lozenge'],
|
|
82
83
|
icon: () => /*#__PURE__*/React.createElement(IconStatus, null),
|
|
83
84
|
action(insert, state) {
|
|
84
|
-
var _api$
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
89
|
-
actionSubjectId: ACTION_SUBJECT_ID.STATUS,
|
|
90
|
-
attributes: {
|
|
91
|
-
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
92
|
-
},
|
|
93
|
-
eventType: EVENT_TYPE.TRACK
|
|
94
|
-
})(tr);
|
|
95
|
-
return tr;
|
|
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;
|
|
96
89
|
}
|
|
97
90
|
}]
|
|
98
91
|
};
|
package/dist/esm/actions.js
CHANGED
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
4
|
import { uuid } from '@atlaskit/adf-schema';
|
|
5
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
7
7
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
8
8
|
import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -12,9 +12,8 @@ export var DEFAULT_STATUS = {
|
|
|
12
12
|
text: '',
|
|
13
13
|
color: 'neutral'
|
|
14
14
|
};
|
|
15
|
-
export var verifyAndInsertStatus = function verifyAndInsertStatus(statusNode,
|
|
16
|
-
var fragment = Fragment.fromArray([statusNode,
|
|
17
|
-
var tr = state.tr;
|
|
15
|
+
export var verifyAndInsertStatus = function verifyAndInsertStatus(statusNode, tr) {
|
|
16
|
+
var fragment = Fragment.fromArray([statusNode, tr.doc.type.schema.text(' ')]);
|
|
18
17
|
var insertable = canInsert(tr.selection.$from, fragment);
|
|
19
18
|
if (!insertable) {
|
|
20
19
|
var parentSelection = NodeSelection.create(tr.doc, tr.selection.from - tr.selection.$anchor.parentOffset - 1);
|
|
@@ -27,11 +26,30 @@ export var verifyAndInsertStatus = function verifyAndInsertStatus(statusNode, st
|
|
|
27
26
|
isNew: true
|
|
28
27
|
}).scrollIntoView();
|
|
29
28
|
};
|
|
30
|
-
export var createStatus = function createStatus(
|
|
31
|
-
var statusNode =
|
|
29
|
+
export var createStatus = function createStatus(tr) {
|
|
30
|
+
var statusNode = tr.doc.type.schema.nodes.status.createChecked(_objectSpread(_objectSpread({}, DEFAULT_STATUS), {}, {
|
|
32
31
|
localId: uuid.generate()
|
|
33
32
|
}));
|
|
34
|
-
return verifyAndInsertStatus(statusNode,
|
|
33
|
+
return verifyAndInsertStatus(statusNode, tr);
|
|
34
|
+
};
|
|
35
|
+
export var insertStatus = function insertStatus(editorAnalyticsAPI) {
|
|
36
|
+
return function () {
|
|
37
|
+
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INPUT_METHOD.TOOLBAR;
|
|
38
|
+
return function (_ref) {
|
|
39
|
+
var tr = _ref.tr;
|
|
40
|
+
var statusTr = createStatus(tr);
|
|
41
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
42
|
+
action: ACTION.INSERTED,
|
|
43
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
44
|
+
actionSubjectId: ACTION_SUBJECT_ID.STATUS,
|
|
45
|
+
attributes: {
|
|
46
|
+
inputMethod: inputMethod
|
|
47
|
+
},
|
|
48
|
+
eventType: EVENT_TYPE.TRACK
|
|
49
|
+
})(statusTr);
|
|
50
|
+
return statusTr;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
35
53
|
};
|
|
36
54
|
export var updateStatus = function updateStatus(status) {
|
|
37
55
|
return function (state, dispatch) {
|
|
@@ -42,12 +60,12 @@ export var updateStatus = function updateStatus(status) {
|
|
|
42
60
|
}) : status;
|
|
43
61
|
var statusProps = _objectSpread(_objectSpread({}, DEFAULT_STATUS), selectedStatus);
|
|
44
62
|
var tr = state.tr;
|
|
45
|
-
var
|
|
46
|
-
showStatusPickerAt =
|
|
63
|
+
var _ref2 = pluginKey.getState(state) || {},
|
|
64
|
+
showStatusPickerAt = _ref2.showStatusPickerAt;
|
|
47
65
|
if (!showStatusPickerAt) {
|
|
48
66
|
// Same behaviour as quick insert (used in createStatus)
|
|
49
67
|
var statusNode = schema.nodes.status.createChecked(statusProps);
|
|
50
|
-
tr = verifyAndInsertStatus(statusNode, state);
|
|
68
|
+
tr = verifyAndInsertStatus(statusNode, state.tr);
|
|
51
69
|
if (dispatch) {
|
|
52
70
|
dispatch(tr);
|
|
53
71
|
}
|
|
@@ -88,8 +106,8 @@ export var setStatusPickerAt = function setStatusPickerAt(showStatusPickerAt) {
|
|
|
88
106
|
};
|
|
89
107
|
};
|
|
90
108
|
export var removeStatus = function removeStatus(showStatusPickerAt) {
|
|
91
|
-
return function (
|
|
92
|
-
var tr =
|
|
109
|
+
return function (_ref3) {
|
|
110
|
+
var tr = _ref3.tr;
|
|
93
111
|
tr.replace(showStatusPickerAt, showStatusPickerAt + 1);
|
|
94
112
|
return tr;
|
|
95
113
|
};
|
|
@@ -119,10 +137,10 @@ export var commitStatusPicker = function commitStatusPicker(closingPayload) {
|
|
|
119
137
|
return function (editorView) {
|
|
120
138
|
var state = editorView.state,
|
|
121
139
|
dispatch = editorView.dispatch;
|
|
122
|
-
var
|
|
123
|
-
showStatusPickerAt =
|
|
124
|
-
var
|
|
125
|
-
closingMethod =
|
|
140
|
+
var _ref4 = pluginKey.getState(state) || {},
|
|
141
|
+
showStatusPickerAt = _ref4.showStatusPickerAt;
|
|
142
|
+
var _ref5 = closingPayload || {},
|
|
143
|
+
closingMethod = _ref5.closingMethod;
|
|
126
144
|
if (!showStatusPickerAt) {
|
|
127
145
|
return;
|
|
128
146
|
}
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { status } from '@atlaskit/adf-schema';
|
|
3
|
-
import {
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { IconStatus } from '@atlaskit/editor-common/quick-insert';
|
|
6
|
-
import { commitStatusPicker,
|
|
6
|
+
import { commitStatusPicker, insertStatus, removeStatus, updateStatusWithAnalytics } from './actions';
|
|
7
7
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
8
8
|
import createStatusPlugin from './pm-plugins/plugin';
|
|
9
9
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
10
10
|
import { ContentComponent } from './ui/ContentComponent';
|
|
11
11
|
var baseStatusPlugin = function baseStatusPlugin(_ref) {
|
|
12
|
-
var _api$analytics;
|
|
12
|
+
var _api$analytics, _api$analytics2;
|
|
13
13
|
var options = _ref.config,
|
|
14
14
|
api = _ref.api;
|
|
15
15
|
return {
|
|
@@ -36,7 +36,8 @@ var baseStatusPlugin = function baseStatusPlugin(_ref) {
|
|
|
36
36
|
updateStatus: updateStatusWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
37
37
|
},
|
|
38
38
|
commands: {
|
|
39
|
-
removeStatus: removeStatus
|
|
39
|
+
removeStatus: removeStatus,
|
|
40
|
+
insertStatus: insertStatus(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
40
41
|
},
|
|
41
42
|
getSharedState: function getSharedState(state) {
|
|
42
43
|
if (!state) {
|
|
@@ -83,18 +84,10 @@ var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, optio
|
|
|
83
84
|
return /*#__PURE__*/React.createElement(IconStatus, null);
|
|
84
85
|
},
|
|
85
86
|
action: function action(insert, state) {
|
|
86
|
-
var _api$
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
91
|
-
actionSubjectId: ACTION_SUBJECT_ID.STATUS,
|
|
92
|
-
attributes: {
|
|
93
|
-
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
94
|
-
},
|
|
95
|
-
eventType: EVENT_TYPE.TRACK
|
|
96
|
-
})(tr);
|
|
97
|
-
return tr;
|
|
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;
|
|
98
91
|
}
|
|
99
92
|
}];
|
|
100
93
|
}
|
package/dist/types/actions.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import type { Command, CommandDispatch, EditorCommand, TOOLBAR_MENU_TYPE } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
5
6
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
7
|
import type { ClosingPayload, StatusType } from './types';
|
|
7
8
|
export declare const DEFAULT_STATUS: StatusType;
|
|
8
|
-
export declare const verifyAndInsertStatus: (statusNode: Node,
|
|
9
|
-
export declare const createStatus: (
|
|
9
|
+
export declare const verifyAndInsertStatus: (statusNode: Node, tr: Transaction) => Transaction;
|
|
10
|
+
export declare const createStatus: (tr: Transaction) => Transaction;
|
|
11
|
+
export declare const insertStatus: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod?: INPUT_METHOD.INSERT_MENU | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR) => EditorCommand;
|
|
10
12
|
export declare const updateStatus: (status?: StatusType) => Command;
|
|
11
13
|
export type UpdateStatus = (inputMethod: TOOLBAR_MENU_TYPE, status?: StatusType) => Command;
|
|
12
14
|
export declare const updateStatusWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: TOOLBAR_MENU_TYPE, status?: StatusType) => Command;
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
3
|
import type { UpdateStatus } from './actions';
|
|
4
|
-
import { commitStatusPicker, removeStatus } from './actions';
|
|
4
|
+
import { commitStatusPicker, insertStatus, removeStatus } from './actions';
|
|
5
5
|
import type { StatusPluginOptions, StatusState } from './types';
|
|
6
6
|
export type StatusPlugin = NextEditorPlugin<'status', {
|
|
7
7
|
dependencies: [OptionalPlugin<AnalyticsPlugin>];
|
|
@@ -12,6 +12,7 @@ export type StatusPlugin = NextEditorPlugin<'status', {
|
|
|
12
12
|
};
|
|
13
13
|
commands: {
|
|
14
14
|
removeStatus: typeof removeStatus;
|
|
15
|
+
insertStatus: ReturnType<typeof insertStatus>;
|
|
15
16
|
};
|
|
16
17
|
sharedState: StatusState | undefined;
|
|
17
18
|
}>;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import type { Command, CommandDispatch, EditorCommand, TOOLBAR_MENU_TYPE } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
5
6
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
7
|
import type { ClosingPayload, StatusType } from './types';
|
|
7
8
|
export declare const DEFAULT_STATUS: StatusType;
|
|
8
|
-
export declare const verifyAndInsertStatus: (statusNode: Node,
|
|
9
|
-
export declare const createStatus: (
|
|
9
|
+
export declare const verifyAndInsertStatus: (statusNode: Node, tr: Transaction) => Transaction;
|
|
10
|
+
export declare const createStatus: (tr: Transaction) => Transaction;
|
|
11
|
+
export declare const insertStatus: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod?: INPUT_METHOD.INSERT_MENU | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR) => EditorCommand;
|
|
10
12
|
export declare const updateStatus: (status?: StatusType) => Command;
|
|
11
13
|
export type UpdateStatus = (inputMethod: TOOLBAR_MENU_TYPE, status?: StatusType) => Command;
|
|
12
14
|
export declare const updateStatusWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: TOOLBAR_MENU_TYPE, status?: StatusType) => Command;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
3
|
import type { UpdateStatus } from './actions';
|
|
4
|
-
import { commitStatusPicker, removeStatus } from './actions';
|
|
4
|
+
import { commitStatusPicker, insertStatus, removeStatus } from './actions';
|
|
5
5
|
import type { StatusPluginOptions, StatusState } from './types';
|
|
6
6
|
export type StatusPlugin = NextEditorPlugin<'status', {
|
|
7
7
|
dependencies: [
|
|
@@ -14,6 +14,7 @@ export type StatusPlugin = NextEditorPlugin<'status', {
|
|
|
14
14
|
};
|
|
15
15
|
commands: {
|
|
16
16
|
removeStatus: typeof removeStatus;
|
|
17
|
+
insertStatus: ReturnType<typeof insertStatus>;
|
|
17
18
|
};
|
|
18
19
|
sharedState: StatusState | undefined;
|
|
19
20
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-status",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Status plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"registry": "https://registry.npmjs.org/"
|
|
9
9
|
},
|
|
10
10
|
"atlassian": {
|
|
11
|
-
"team": "Editor:
|
|
11
|
+
"team": "Editor: Core Experiences",
|
|
12
12
|
"singleton": true,
|
|
13
13
|
"inPublicMirror": false,
|
|
14
14
|
"releaseModel": "continuous",
|