@atlaskit/editor-plugin-status 0.2.12 → 0.2.13
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/.eslintrc.js +18 -0
- package/CHANGELOG.md +6 -0
- package/dist/cjs/plugin.js +24 -52
- package/dist/cjs/ui/ContentComponent.js +70 -0
- package/dist/cjs/ui/statusPicker.js +1 -1
- package/dist/es2019/plugin.js +20 -51
- package/dist/es2019/ui/ContentComponent.js +60 -0
- package/dist/es2019/ui/statusPicker.js +1 -1
- package/dist/esm/plugin.js +25 -53
- package/dist/esm/ui/ContentComponent.js +60 -0
- package/dist/esm/ui/statusPicker.js +1 -1
- package/dist/types/plugin.d.ts +2 -1
- package/dist/types/ui/ContentComponent.d.ts +15 -0
- package/dist/types/ui/statusPicker.d.ts +1 -1
- package/dist/types-ts4.5/plugin.d.ts +2 -1
- package/dist/types-ts4.5/ui/ContentComponent.d.ts +15 -0
- package/dist/types-ts4.5/ui/statusPicker.d.ts +1 -1
- package/package.json +4 -4
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
rules: {
|
|
3
|
+
'@typescript-eslint/no-duplicate-imports': 'error',
|
|
4
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
5
|
+
'@typescript-eslint/ban-types': [
|
|
6
|
+
'error',
|
|
7
|
+
{
|
|
8
|
+
types: {
|
|
9
|
+
'React.FC':
|
|
10
|
+
'Please use types directly on props instead, and explicitly define children if required',
|
|
11
|
+
'React.FunctionalComponent':
|
|
12
|
+
'Please use types directly on props instead, and explicitly define children if required',
|
|
13
|
+
},
|
|
14
|
+
extendDefaults: false,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
};
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-status
|
|
2
2
|
|
|
3
|
+
## 0.2.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#67814](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67814) [`b9ae9606c2e0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b9ae9606c2e0) - Migrate status and alignment plugins to use useSharedPluginState rather than WithPluginState
|
|
8
|
+
|
|
3
9
|
## 0.2.12
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -10,13 +10,11 @@ var _adfSchema = require("@atlaskit/adf-schema");
|
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
11
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
12
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
13
|
-
var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
|
|
14
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
15
13
|
var _actions = require("./actions");
|
|
16
14
|
var _keymap = require("./pm-plugins/keymap");
|
|
17
15
|
var _plugin = _interopRequireDefault(require("./pm-plugins/plugin"));
|
|
18
16
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
19
|
-
var
|
|
17
|
+
var _ContentComponent = require("./ui/ContentComponent");
|
|
20
18
|
var baseStatusPlugin = function baseStatusPlugin(_ref) {
|
|
21
19
|
var _api$analytics;
|
|
22
20
|
var options = _ref.config,
|
|
@@ -47,56 +45,30 @@ var baseStatusPlugin = function baseStatusPlugin(_ref) {
|
|
|
47
45
|
commands: {
|
|
48
46
|
removeStatus: _actions.removeStatus
|
|
49
47
|
},
|
|
48
|
+
getSharedState: function getSharedState(state) {
|
|
49
|
+
if (!state) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
var pluginState = _pluginKey.pluginKey.getState(state);
|
|
53
|
+
return pluginState ? {
|
|
54
|
+
isNew: pluginState.isNew,
|
|
55
|
+
showStatusPickerAt: pluginState.showStatusPickerAt,
|
|
56
|
+
focusStatusInput: pluginState.focusStatusInput
|
|
57
|
+
} : undefined;
|
|
58
|
+
},
|
|
50
59
|
contentComponent: function contentComponent(_ref2) {
|
|
51
60
|
var editorView = _ref2.editorView,
|
|
52
61
|
popupsMountPoint = _ref2.popupsMountPoint,
|
|
53
62
|
popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
54
63
|
popupsScrollableElement = _ref2.popupsScrollableElement;
|
|
55
64
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
56
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var showStatusPickerAt = statusState.showStatusPickerAt;
|
|
64
|
-
if (typeof showStatusPickerAt !== 'number') {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
var target = (0, _utils.findDomRefAtPos)(showStatusPickerAt, domAtPos);
|
|
68
|
-
var statusNode = editorView.state.doc.nodeAt(showStatusPickerAt);
|
|
69
|
-
if (!statusNode || statusNode.type.name !== 'status') {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
var _statusNode$attrs = statusNode.attrs,
|
|
73
|
-
text = _statusNode$attrs.text,
|
|
74
|
-
color = _statusNode$attrs.color,
|
|
75
|
-
localId = _statusNode$attrs.localId;
|
|
76
|
-
return /*#__PURE__*/_react.default.createElement(_statusPicker.default, {
|
|
77
|
-
isNew: statusState.isNew,
|
|
78
|
-
focusStatusInput: statusState.focusStatusInput,
|
|
79
|
-
target: target,
|
|
80
|
-
defaultText: text,
|
|
81
|
-
defaultColor: color,
|
|
82
|
-
defaultLocalId: localId,
|
|
83
|
-
mountTo: popupsMountPoint,
|
|
84
|
-
boundariesElement: popupsBoundariesElement,
|
|
85
|
-
scrollableElement: popupsScrollableElement,
|
|
86
|
-
onSelect: function onSelect(status) {
|
|
87
|
-
(0, _actions.updateStatus)(status)(editorView.state, editorView.dispatch);
|
|
88
|
-
},
|
|
89
|
-
onTextChanged: function onTextChanged(status) {
|
|
90
|
-
(0, _actions.updateStatus)(status)(editorView.state, editorView.dispatch);
|
|
91
|
-
},
|
|
92
|
-
closeStatusPicker: function closeStatusPicker(closingPayload) {
|
|
93
|
-
(0, _actions.commitStatusPicker)(closingPayload)(editorView);
|
|
94
|
-
},
|
|
95
|
-
onEnter: function onEnter() {
|
|
96
|
-
(0, _actions.commitStatusPicker)()(editorView);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement(_ContentComponent.ContentComponent, {
|
|
66
|
+
domAtPos: domAtPos,
|
|
67
|
+
api: api,
|
|
68
|
+
editorView: editorView,
|
|
69
|
+
popupsMountPoint: popupsMountPoint,
|
|
70
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
71
|
+
popupsScrollableElement: popupsScrollableElement
|
|
100
72
|
});
|
|
101
73
|
}
|
|
102
74
|
};
|
|
@@ -106,8 +78,8 @@ var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, optio
|
|
|
106
78
|
return plugin;
|
|
107
79
|
}
|
|
108
80
|
plugin.pluginsOptions = {
|
|
109
|
-
quickInsert: function quickInsert(
|
|
110
|
-
var formatMessage =
|
|
81
|
+
quickInsert: function quickInsert(_ref3) {
|
|
82
|
+
var formatMessage = _ref3.formatMessage;
|
|
111
83
|
return [{
|
|
112
84
|
id: 'status',
|
|
113
85
|
title: formatMessage(_messages.toolbarInsertBlockMessages.status),
|
|
@@ -136,9 +108,9 @@ var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, optio
|
|
|
136
108
|
};
|
|
137
109
|
return plugin;
|
|
138
110
|
};
|
|
139
|
-
var statusPlugin = exports.statusPlugin = function statusPlugin(
|
|
140
|
-
var options =
|
|
141
|
-
api =
|
|
111
|
+
var statusPlugin = exports.statusPlugin = function statusPlugin(_ref4) {
|
|
112
|
+
var options = _ref4.config,
|
|
113
|
+
api = _ref4.api;
|
|
142
114
|
return decorateWithPluginOptions(baseStatusPlugin({
|
|
143
115
|
config: options,
|
|
144
116
|
api: api
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ContentComponent = ContentComponent;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
|
+
var _actions = require("../actions");
|
|
13
|
+
var _statusPicker = _interopRequireDefault(require("./statusPicker"));
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
+
function ContentComponent(_ref) {
|
|
17
|
+
var api = _ref.api,
|
|
18
|
+
popupsMountPoint = _ref.popupsMountPoint,
|
|
19
|
+
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
20
|
+
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
21
|
+
editorView = _ref.editorView,
|
|
22
|
+
domAtPos = _ref.domAtPos;
|
|
23
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['status']),
|
|
24
|
+
statusState = _useSharedPluginState.statusState;
|
|
25
|
+
var _ref2 = statusState !== null && statusState !== void 0 ? statusState : {},
|
|
26
|
+
showStatusPickerAt = _ref2.showStatusPickerAt;
|
|
27
|
+
var target = (0, _react.useMemo)(function () {
|
|
28
|
+
return showStatusPickerAt ? (0, _utils.findDomRefAtPos)(showStatusPickerAt, domAtPos) : null;
|
|
29
|
+
}, [showStatusPickerAt, domAtPos]);
|
|
30
|
+
var statusNode = (0, _react.useMemo)(function () {
|
|
31
|
+
return showStatusPickerAt ? editorView.state.doc.nodeAt(showStatusPickerAt) : undefined;
|
|
32
|
+
}, [showStatusPickerAt, editorView]);
|
|
33
|
+
var onSelect = (0, _react.useCallback)(function (status) {
|
|
34
|
+
(0, _actions.updateStatus)(status)(editorView.state, editorView.dispatch);
|
|
35
|
+
}, [editorView]);
|
|
36
|
+
var onTextChanged = (0, _react.useCallback)(function (status) {
|
|
37
|
+
(0, _actions.updateStatus)(status)(editorView.state, editorView.dispatch);
|
|
38
|
+
}, [editorView]);
|
|
39
|
+
var closeStatusPicker = (0, _react.useCallback)(function (closingPayload) {
|
|
40
|
+
(0, _actions.commitStatusPicker)(closingPayload)(editorView);
|
|
41
|
+
}, [editorView]);
|
|
42
|
+
var onEnter = (0, _react.useCallback)(function () {
|
|
43
|
+
(0, _actions.commitStatusPicker)()(editorView);
|
|
44
|
+
}, [editorView]);
|
|
45
|
+
if (typeof showStatusPickerAt !== 'number') {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
if (!statusNode || statusNode.type.name !== 'status') {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
var _statusNode$attrs = statusNode.attrs,
|
|
52
|
+
text = _statusNode$attrs.text,
|
|
53
|
+
color = _statusNode$attrs.color,
|
|
54
|
+
localId = _statusNode$attrs.localId;
|
|
55
|
+
return /*#__PURE__*/_react.default.createElement(_statusPicker.default, {
|
|
56
|
+
isNew: statusState === null || statusState === void 0 ? void 0 : statusState.isNew,
|
|
57
|
+
focusStatusInput: statusState === null || statusState === void 0 ? void 0 : statusState.focusStatusInput,
|
|
58
|
+
target: target,
|
|
59
|
+
defaultText: text,
|
|
60
|
+
defaultColor: color,
|
|
61
|
+
defaultLocalId: localId,
|
|
62
|
+
mountTo: popupsMountPoint,
|
|
63
|
+
boundariesElement: popupsBoundariesElement,
|
|
64
|
+
scrollableElement: popupsScrollableElement,
|
|
65
|
+
onSelect: onSelect,
|
|
66
|
+
onTextChanged: onTextChanged,
|
|
67
|
+
closeStatusPicker: closeStatusPicker,
|
|
68
|
+
onEnter: onEnter
|
|
69
|
+
});
|
|
70
|
+
}
|
|
@@ -247,7 +247,7 @@ var StatusPickerWithoutAnalytcs = exports.StatusPickerWithoutAnalytcs = /*#__PUR
|
|
|
247
247
|
}
|
|
248
248
|
}, {
|
|
249
249
|
key: "componentDidUpdate",
|
|
250
|
-
value: function componentDidUpdate(prevProps, prevState
|
|
250
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
|
251
251
|
var element = this.props.target;
|
|
252
252
|
if (prevProps.target !== element) {
|
|
253
253
|
var newState = this.extractStateFromProps(this.props);
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -3,13 +3,11 @@ import { status } from '@atlaskit/adf-schema';
|
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, 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 {
|
|
7
|
-
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
8
|
-
import { commitStatusPicker, createStatus, removeStatus, updateStatus, updateStatusWithAnalytics } from './actions';
|
|
6
|
+
import { commitStatusPicker, createStatus, removeStatus, updateStatusWithAnalytics } from './actions';
|
|
9
7
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
10
8
|
import createStatusPlugin from './pm-plugins/plugin';
|
|
11
9
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
12
|
-
import
|
|
10
|
+
import { ContentComponent } from './ui/ContentComponent';
|
|
13
11
|
const baseStatusPlugin = ({
|
|
14
12
|
config: options,
|
|
15
13
|
api
|
|
@@ -39,6 +37,17 @@ const baseStatusPlugin = ({
|
|
|
39
37
|
commands: {
|
|
40
38
|
removeStatus
|
|
41
39
|
},
|
|
40
|
+
getSharedState(state) {
|
|
41
|
+
if (!state) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const pluginState = pluginKey.getState(state);
|
|
45
|
+
return pluginState ? {
|
|
46
|
+
isNew: pluginState.isNew,
|
|
47
|
+
showStatusPickerAt: pluginState.showStatusPickerAt,
|
|
48
|
+
focusStatusInput: pluginState.focusStatusInput
|
|
49
|
+
} : undefined;
|
|
50
|
+
},
|
|
42
51
|
contentComponent({
|
|
43
52
|
editorView,
|
|
44
53
|
popupsMountPoint,
|
|
@@ -46,53 +55,13 @@ const baseStatusPlugin = ({
|
|
|
46
55
|
popupsScrollableElement
|
|
47
56
|
}) {
|
|
48
57
|
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
49
|
-
return /*#__PURE__*/React.createElement(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const {
|
|
57
|
-
showStatusPickerAt
|
|
58
|
-
} = statusState;
|
|
59
|
-
if (typeof showStatusPickerAt !== 'number') {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
const target = findDomRefAtPos(showStatusPickerAt, domAtPos);
|
|
63
|
-
const statusNode = editorView.state.doc.nodeAt(showStatusPickerAt);
|
|
64
|
-
if (!statusNode || statusNode.type.name !== 'status') {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
const {
|
|
68
|
-
text,
|
|
69
|
-
color,
|
|
70
|
-
localId
|
|
71
|
-
} = statusNode.attrs;
|
|
72
|
-
return /*#__PURE__*/React.createElement(StatusPicker, {
|
|
73
|
-
isNew: statusState.isNew,
|
|
74
|
-
focusStatusInput: statusState.focusStatusInput,
|
|
75
|
-
target: target,
|
|
76
|
-
defaultText: text,
|
|
77
|
-
defaultColor: color,
|
|
78
|
-
defaultLocalId: localId,
|
|
79
|
-
mountTo: popupsMountPoint,
|
|
80
|
-
boundariesElement: popupsBoundariesElement,
|
|
81
|
-
scrollableElement: popupsScrollableElement,
|
|
82
|
-
onSelect: status => {
|
|
83
|
-
updateStatus(status)(editorView.state, editorView.dispatch);
|
|
84
|
-
},
|
|
85
|
-
onTextChanged: status => {
|
|
86
|
-
updateStatus(status)(editorView.state, editorView.dispatch);
|
|
87
|
-
},
|
|
88
|
-
closeStatusPicker: closingPayload => {
|
|
89
|
-
commitStatusPicker(closingPayload)(editorView);
|
|
90
|
-
},
|
|
91
|
-
onEnter: () => {
|
|
92
|
-
commitStatusPicker()(editorView);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
58
|
+
return /*#__PURE__*/React.createElement(ContentComponent, {
|
|
59
|
+
domAtPos: domAtPos,
|
|
60
|
+
api: api,
|
|
61
|
+
editorView: editorView,
|
|
62
|
+
popupsMountPoint: popupsMountPoint,
|
|
63
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
64
|
+
popupsScrollableElement: popupsScrollableElement
|
|
96
65
|
});
|
|
97
66
|
}
|
|
98
67
|
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
+
import { commitStatusPicker, updateStatus } from '../actions';
|
|
5
|
+
import StatusPicker from './statusPicker';
|
|
6
|
+
export function ContentComponent({
|
|
7
|
+
api,
|
|
8
|
+
popupsMountPoint,
|
|
9
|
+
popupsBoundariesElement,
|
|
10
|
+
popupsScrollableElement,
|
|
11
|
+
editorView,
|
|
12
|
+
domAtPos
|
|
13
|
+
}) {
|
|
14
|
+
const {
|
|
15
|
+
statusState
|
|
16
|
+
} = useSharedPluginState(api, ['status']);
|
|
17
|
+
const {
|
|
18
|
+
showStatusPickerAt
|
|
19
|
+
} = statusState !== null && statusState !== void 0 ? statusState : {};
|
|
20
|
+
const target = useMemo(() => showStatusPickerAt ? findDomRefAtPos(showStatusPickerAt, domAtPos) : null, [showStatusPickerAt, domAtPos]);
|
|
21
|
+
const statusNode = useMemo(() => showStatusPickerAt ? editorView.state.doc.nodeAt(showStatusPickerAt) : undefined, [showStatusPickerAt, editorView]);
|
|
22
|
+
const onSelect = useCallback(status => {
|
|
23
|
+
updateStatus(status)(editorView.state, editorView.dispatch);
|
|
24
|
+
}, [editorView]);
|
|
25
|
+
const onTextChanged = useCallback(status => {
|
|
26
|
+
updateStatus(status)(editorView.state, editorView.dispatch);
|
|
27
|
+
}, [editorView]);
|
|
28
|
+
const closeStatusPicker = useCallback(closingPayload => {
|
|
29
|
+
commitStatusPicker(closingPayload)(editorView);
|
|
30
|
+
}, [editorView]);
|
|
31
|
+
const onEnter = useCallback(() => {
|
|
32
|
+
commitStatusPicker()(editorView);
|
|
33
|
+
}, [editorView]);
|
|
34
|
+
if (typeof showStatusPickerAt !== 'number') {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
if (!statusNode || statusNode.type.name !== 'status') {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const {
|
|
41
|
+
text,
|
|
42
|
+
color,
|
|
43
|
+
localId
|
|
44
|
+
} = statusNode.attrs;
|
|
45
|
+
return /*#__PURE__*/React.createElement(StatusPicker, {
|
|
46
|
+
isNew: statusState === null || statusState === void 0 ? void 0 : statusState.isNew,
|
|
47
|
+
focusStatusInput: statusState === null || statusState === void 0 ? void 0 : statusState.focusStatusInput,
|
|
48
|
+
target: target,
|
|
49
|
+
defaultText: text,
|
|
50
|
+
defaultColor: color,
|
|
51
|
+
defaultLocalId: localId,
|
|
52
|
+
mountTo: popupsMountPoint,
|
|
53
|
+
boundariesElement: popupsBoundariesElement,
|
|
54
|
+
scrollableElement: popupsScrollableElement,
|
|
55
|
+
onSelect: onSelect,
|
|
56
|
+
onTextChanged: onTextChanged,
|
|
57
|
+
closeStatusPicker: closeStatusPicker,
|
|
58
|
+
onEnter: onEnter
|
|
59
|
+
});
|
|
60
|
+
}
|
|
@@ -221,7 +221,7 @@ export class StatusPickerWithoutAnalytcs extends React.Component {
|
|
|
221
221
|
this.fireStatusPopupClosedAnalytics(this.state);
|
|
222
222
|
this.startTime = 0;
|
|
223
223
|
}
|
|
224
|
-
componentDidUpdate(prevProps, prevState
|
|
224
|
+
componentDidUpdate(prevProps, prevState) {
|
|
225
225
|
const element = this.props.target;
|
|
226
226
|
if (prevProps.target !== element) {
|
|
227
227
|
const newState = this.extractStateFromProps(this.props);
|
package/dist/esm/plugin.js
CHANGED
|
@@ -3,13 +3,11 @@ import { status } from '@atlaskit/adf-schema';
|
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, 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 {
|
|
7
|
-
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
8
|
-
import { commitStatusPicker, createStatus, removeStatus, updateStatus, updateStatusWithAnalytics } from './actions';
|
|
6
|
+
import { commitStatusPicker, createStatus, removeStatus, updateStatusWithAnalytics } from './actions';
|
|
9
7
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
10
8
|
import createStatusPlugin from './pm-plugins/plugin';
|
|
11
9
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
12
|
-
import
|
|
10
|
+
import { ContentComponent } from './ui/ContentComponent';
|
|
13
11
|
var baseStatusPlugin = function baseStatusPlugin(_ref) {
|
|
14
12
|
var _api$analytics;
|
|
15
13
|
var options = _ref.config,
|
|
@@ -40,56 +38,30 @@ var baseStatusPlugin = function baseStatusPlugin(_ref) {
|
|
|
40
38
|
commands: {
|
|
41
39
|
removeStatus: removeStatus
|
|
42
40
|
},
|
|
41
|
+
getSharedState: function getSharedState(state) {
|
|
42
|
+
if (!state) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
var pluginState = pluginKey.getState(state);
|
|
46
|
+
return pluginState ? {
|
|
47
|
+
isNew: pluginState.isNew,
|
|
48
|
+
showStatusPickerAt: pluginState.showStatusPickerAt,
|
|
49
|
+
focusStatusInput: pluginState.focusStatusInput
|
|
50
|
+
} : undefined;
|
|
51
|
+
},
|
|
43
52
|
contentComponent: function contentComponent(_ref2) {
|
|
44
53
|
var editorView = _ref2.editorView,
|
|
45
54
|
popupsMountPoint = _ref2.popupsMountPoint,
|
|
46
55
|
popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
47
56
|
popupsScrollableElement = _ref2.popupsScrollableElement;
|
|
48
57
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
49
|
-
return /*#__PURE__*/React.createElement(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var showStatusPickerAt = statusState.showStatusPickerAt;
|
|
57
|
-
if (typeof showStatusPickerAt !== 'number') {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
var target = findDomRefAtPos(showStatusPickerAt, domAtPos);
|
|
61
|
-
var statusNode = editorView.state.doc.nodeAt(showStatusPickerAt);
|
|
62
|
-
if (!statusNode || statusNode.type.name !== 'status') {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
var _statusNode$attrs = statusNode.attrs,
|
|
66
|
-
text = _statusNode$attrs.text,
|
|
67
|
-
color = _statusNode$attrs.color,
|
|
68
|
-
localId = _statusNode$attrs.localId;
|
|
69
|
-
return /*#__PURE__*/React.createElement(StatusPicker, {
|
|
70
|
-
isNew: statusState.isNew,
|
|
71
|
-
focusStatusInput: statusState.focusStatusInput,
|
|
72
|
-
target: target,
|
|
73
|
-
defaultText: text,
|
|
74
|
-
defaultColor: color,
|
|
75
|
-
defaultLocalId: localId,
|
|
76
|
-
mountTo: popupsMountPoint,
|
|
77
|
-
boundariesElement: popupsBoundariesElement,
|
|
78
|
-
scrollableElement: popupsScrollableElement,
|
|
79
|
-
onSelect: function onSelect(status) {
|
|
80
|
-
updateStatus(status)(editorView.state, editorView.dispatch);
|
|
81
|
-
},
|
|
82
|
-
onTextChanged: function onTextChanged(status) {
|
|
83
|
-
updateStatus(status)(editorView.state, editorView.dispatch);
|
|
84
|
-
},
|
|
85
|
-
closeStatusPicker: function closeStatusPicker(closingPayload) {
|
|
86
|
-
commitStatusPicker(closingPayload)(editorView);
|
|
87
|
-
},
|
|
88
|
-
onEnter: function onEnter() {
|
|
89
|
-
commitStatusPicker()(editorView);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
58
|
+
return /*#__PURE__*/React.createElement(ContentComponent, {
|
|
59
|
+
domAtPos: domAtPos,
|
|
60
|
+
api: api,
|
|
61
|
+
editorView: editorView,
|
|
62
|
+
popupsMountPoint: popupsMountPoint,
|
|
63
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
64
|
+
popupsScrollableElement: popupsScrollableElement
|
|
93
65
|
});
|
|
94
66
|
}
|
|
95
67
|
};
|
|
@@ -99,8 +71,8 @@ var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, optio
|
|
|
99
71
|
return plugin;
|
|
100
72
|
}
|
|
101
73
|
plugin.pluginsOptions = {
|
|
102
|
-
quickInsert: function quickInsert(
|
|
103
|
-
var formatMessage =
|
|
74
|
+
quickInsert: function quickInsert(_ref3) {
|
|
75
|
+
var formatMessage = _ref3.formatMessage;
|
|
104
76
|
return [{
|
|
105
77
|
id: 'status',
|
|
106
78
|
title: formatMessage(messages.status),
|
|
@@ -129,9 +101,9 @@ var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, optio
|
|
|
129
101
|
};
|
|
130
102
|
return plugin;
|
|
131
103
|
};
|
|
132
|
-
export var statusPlugin = function statusPlugin(
|
|
133
|
-
var options =
|
|
134
|
-
api =
|
|
104
|
+
export var statusPlugin = function statusPlugin(_ref4) {
|
|
105
|
+
var options = _ref4.config,
|
|
106
|
+
api = _ref4.api;
|
|
135
107
|
return decorateWithPluginOptions(baseStatusPlugin({
|
|
136
108
|
config: options,
|
|
137
109
|
api: api
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
+
import { commitStatusPicker, updateStatus } from '../actions';
|
|
5
|
+
import StatusPicker from './statusPicker';
|
|
6
|
+
export function ContentComponent(_ref) {
|
|
7
|
+
var api = _ref.api,
|
|
8
|
+
popupsMountPoint = _ref.popupsMountPoint,
|
|
9
|
+
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
10
|
+
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
11
|
+
editorView = _ref.editorView,
|
|
12
|
+
domAtPos = _ref.domAtPos;
|
|
13
|
+
var _useSharedPluginState = useSharedPluginState(api, ['status']),
|
|
14
|
+
statusState = _useSharedPluginState.statusState;
|
|
15
|
+
var _ref2 = statusState !== null && statusState !== void 0 ? statusState : {},
|
|
16
|
+
showStatusPickerAt = _ref2.showStatusPickerAt;
|
|
17
|
+
var target = useMemo(function () {
|
|
18
|
+
return showStatusPickerAt ? findDomRefAtPos(showStatusPickerAt, domAtPos) : null;
|
|
19
|
+
}, [showStatusPickerAt, domAtPos]);
|
|
20
|
+
var statusNode = useMemo(function () {
|
|
21
|
+
return showStatusPickerAt ? editorView.state.doc.nodeAt(showStatusPickerAt) : undefined;
|
|
22
|
+
}, [showStatusPickerAt, editorView]);
|
|
23
|
+
var onSelect = useCallback(function (status) {
|
|
24
|
+
updateStatus(status)(editorView.state, editorView.dispatch);
|
|
25
|
+
}, [editorView]);
|
|
26
|
+
var onTextChanged = useCallback(function (status) {
|
|
27
|
+
updateStatus(status)(editorView.state, editorView.dispatch);
|
|
28
|
+
}, [editorView]);
|
|
29
|
+
var closeStatusPicker = useCallback(function (closingPayload) {
|
|
30
|
+
commitStatusPicker(closingPayload)(editorView);
|
|
31
|
+
}, [editorView]);
|
|
32
|
+
var onEnter = useCallback(function () {
|
|
33
|
+
commitStatusPicker()(editorView);
|
|
34
|
+
}, [editorView]);
|
|
35
|
+
if (typeof showStatusPickerAt !== 'number') {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
if (!statusNode || statusNode.type.name !== 'status') {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
var _statusNode$attrs = statusNode.attrs,
|
|
42
|
+
text = _statusNode$attrs.text,
|
|
43
|
+
color = _statusNode$attrs.color,
|
|
44
|
+
localId = _statusNode$attrs.localId;
|
|
45
|
+
return /*#__PURE__*/React.createElement(StatusPicker, {
|
|
46
|
+
isNew: statusState === null || statusState === void 0 ? void 0 : statusState.isNew,
|
|
47
|
+
focusStatusInput: statusState === null || statusState === void 0 ? void 0 : statusState.focusStatusInput,
|
|
48
|
+
target: target,
|
|
49
|
+
defaultText: text,
|
|
50
|
+
defaultColor: color,
|
|
51
|
+
defaultLocalId: localId,
|
|
52
|
+
mountTo: popupsMountPoint,
|
|
53
|
+
boundariesElement: popupsBoundariesElement,
|
|
54
|
+
scrollableElement: popupsScrollableElement,
|
|
55
|
+
onSelect: onSelect,
|
|
56
|
+
onTextChanged: onTextChanged,
|
|
57
|
+
closeStatusPicker: closeStatusPicker,
|
|
58
|
+
onEnter: onEnter
|
|
59
|
+
});
|
|
60
|
+
}
|
|
@@ -242,7 +242,7 @@ export var StatusPickerWithoutAnalytcs = /*#__PURE__*/function (_React$Component
|
|
|
242
242
|
}
|
|
243
243
|
}, {
|
|
244
244
|
key: "componentDidUpdate",
|
|
245
|
-
value: function componentDidUpdate(prevProps, prevState
|
|
245
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
|
246
246
|
var element = this.props.target;
|
|
247
247
|
if (prevProps.target !== element) {
|
|
248
248
|
var newState = this.extractStateFromProps(this.props);
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/t
|
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
3
|
import type { UpdateStatus } from './actions';
|
|
4
4
|
import { commitStatusPicker, removeStatus } from './actions';
|
|
5
|
-
import type { StatusPluginOptions } from './types';
|
|
5
|
+
import type { StatusPluginOptions, StatusState } from './types';
|
|
6
6
|
export type StatusPlugin = NextEditorPlugin<'status', {
|
|
7
7
|
dependencies: [OptionalPlugin<AnalyticsPlugin>];
|
|
8
8
|
pluginConfiguration: StatusPluginOptions | undefined;
|
|
@@ -13,5 +13,6 @@ export type StatusPlugin = NextEditorPlugin<'status', {
|
|
|
13
13
|
commands: {
|
|
14
14
|
removeStatus: typeof removeStatus;
|
|
15
15
|
};
|
|
16
|
+
sharedState: StatusState | undefined;
|
|
16
17
|
}>;
|
|
17
18
|
export declare const statusPlugin: StatusPlugin;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { DomAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import type { StatusPlugin } from '../plugin';
|
|
6
|
+
interface ContentComponentProps {
|
|
7
|
+
api: ExtractInjectionAPI<StatusPlugin> | undefined;
|
|
8
|
+
popupsMountPoint?: HTMLElement;
|
|
9
|
+
popupsBoundariesElement?: HTMLElement;
|
|
10
|
+
popupsScrollableElement?: HTMLElement;
|
|
11
|
+
editorView: EditorView;
|
|
12
|
+
domAtPos: DomAtPos;
|
|
13
|
+
}
|
|
14
|
+
export declare function ContentComponent({ api, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, editorView, domAtPos, }: ContentComponentProps): JSX.Element | null;
|
|
15
|
+
export {};
|
|
@@ -46,7 +46,7 @@ export declare class StatusPickerWithoutAnalytcs extends React.Component<Props,
|
|
|
46
46
|
private reset;
|
|
47
47
|
componentDidMount(): void;
|
|
48
48
|
componentWillUnmount(): void;
|
|
49
|
-
componentDidUpdate(prevProps: Readonly<Props>, prevState: Readonly<State
|
|
49
|
+
componentDidUpdate(prevProps: Readonly<Props>, prevState: Readonly<State>): void;
|
|
50
50
|
private extractStateFromProps;
|
|
51
51
|
handleClickOutside: (event: Event) => void;
|
|
52
52
|
private handleEscapeKeydown;
|
|
@@ -2,7 +2,7 @@ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/t
|
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
3
|
import type { UpdateStatus } from './actions';
|
|
4
4
|
import { commitStatusPicker, removeStatus } from './actions';
|
|
5
|
-
import type { StatusPluginOptions } from './types';
|
|
5
|
+
import type { StatusPluginOptions, StatusState } from './types';
|
|
6
6
|
export type StatusPlugin = NextEditorPlugin<'status', {
|
|
7
7
|
dependencies: [
|
|
8
8
|
OptionalPlugin<AnalyticsPlugin>
|
|
@@ -15,5 +15,6 @@ export type StatusPlugin = NextEditorPlugin<'status', {
|
|
|
15
15
|
commands: {
|
|
16
16
|
removeStatus: typeof removeStatus;
|
|
17
17
|
};
|
|
18
|
+
sharedState: StatusState | undefined;
|
|
18
19
|
}>;
|
|
19
20
|
export declare const statusPlugin: StatusPlugin;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { DomAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import type { StatusPlugin } from '../plugin';
|
|
6
|
+
interface ContentComponentProps {
|
|
7
|
+
api: ExtractInjectionAPI<StatusPlugin> | undefined;
|
|
8
|
+
popupsMountPoint?: HTMLElement;
|
|
9
|
+
popupsBoundariesElement?: HTMLElement;
|
|
10
|
+
popupsScrollableElement?: HTMLElement;
|
|
11
|
+
editorView: EditorView;
|
|
12
|
+
domAtPos: DomAtPos;
|
|
13
|
+
}
|
|
14
|
+
export declare function ContentComponent({ api, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, editorView, domAtPos, }: ContentComponentProps): JSX.Element | null;
|
|
15
|
+
export {};
|
|
@@ -46,7 +46,7 @@ export declare class StatusPickerWithoutAnalytcs extends React.Component<Props,
|
|
|
46
46
|
private reset;
|
|
47
47
|
componentDidMount(): void;
|
|
48
48
|
componentWillUnmount(): void;
|
|
49
|
-
componentDidUpdate(prevProps: Readonly<Props>, prevState: Readonly<State
|
|
49
|
+
componentDidUpdate(prevProps: Readonly<Props>, prevState: Readonly<State>): void;
|
|
50
50
|
private extractStateFromProps;
|
|
51
51
|
handleClickOutside: (event: Event) => void;
|
|
52
52
|
private handleEscapeKeydown;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-status",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"description": "Status plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"releaseModel": "continuous",
|
|
15
15
|
"runReact18": false
|
|
16
16
|
},
|
|
17
|
-
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
17
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
18
18
|
"main": "dist/cjs/index.js",
|
|
19
19
|
"module": "dist/esm/index.js",
|
|
20
20
|
"module:es2019": "dist/es2019/index.js",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^35.3.0",
|
|
37
37
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
38
|
-
"@atlaskit/editor-common": "^76.
|
|
38
|
+
"@atlaskit/editor-common": "^76.41.0",
|
|
39
39
|
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
41
41
|
"@atlaskit/editor-shared-styles": "^2.9.0",
|
|
42
42
|
"@atlaskit/status": "^1.4.0",
|
|
43
43
|
"@atlaskit/theme": "^12.6.0",
|
|
44
|
-
"@atlaskit/tokens": "^1.
|
|
44
|
+
"@atlaskit/tokens": "^1.34.0",
|
|
45
45
|
"@babel/runtime": "^7.0.0",
|
|
46
46
|
"@emotion/react": "^11.7.1"
|
|
47
47
|
},
|