@atlaskit/editor-plugin-tasks-and-decisions 5.1.0 → 5.1.2
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/nodeviews/TaskItemNodeView.js +189 -0
- package/dist/cjs/nodeviews/{task-lazy-node-view.js → task-node-view.js} +16 -4
- package/dist/cjs/nodeviews/taskItem.js +1 -1
- package/dist/cjs/nodeviews/taskItemNodeSpec.js +160 -0
- package/dist/cjs/pm-plugins/actions.js +6 -1
- package/dist/cjs/pm-plugins/helpers.js +35 -2
- package/dist/cjs/pm-plugins/main.js +33 -10
- package/dist/cjs/pm-plugins/types.js +1 -0
- package/dist/cjs/tasksAndDecisionsPlugin.js +98 -111
- package/dist/cjs/ui/Task/RequestToEditPopup.compiled.css +37 -0
- package/dist/cjs/ui/Task/RequestToEditPopup.js +178 -0
- package/dist/es2019/nodeviews/TaskItemNodeView.js +164 -0
- package/dist/es2019/nodeviews/{task-lazy-node-view.js → task-node-view.js} +15 -3
- package/dist/es2019/nodeviews/taskItem.js +1 -1
- package/dist/es2019/nodeviews/taskItemNodeSpec.js +150 -0
- package/dist/es2019/pm-plugins/actions.js +6 -0
- package/dist/es2019/pm-plugins/helpers.js +44 -2
- package/dist/es2019/pm-plugins/main.js +35 -12
- package/dist/es2019/pm-plugins/types.js +1 -0
- package/dist/es2019/tasksAndDecisionsPlugin.js +62 -73
- package/dist/es2019/ui/Task/RequestToEditPopup.compiled.css +37 -0
- package/dist/es2019/ui/Task/RequestToEditPopup.js +161 -0
- package/dist/esm/nodeviews/TaskItemNodeView.js +182 -0
- package/dist/esm/nodeviews/{task-lazy-node-view.js → task-node-view.js} +15 -3
- package/dist/esm/nodeviews/taskItem.js +1 -1
- package/dist/esm/nodeviews/taskItemNodeSpec.js +152 -0
- package/dist/esm/pm-plugins/actions.js +5 -0
- package/dist/esm/pm-plugins/helpers.js +32 -2
- package/dist/esm/pm-plugins/main.js +35 -12
- package/dist/esm/pm-plugins/types.js +1 -0
- package/dist/esm/tasksAndDecisionsPlugin.js +98 -112
- package/dist/esm/ui/Task/RequestToEditPopup.compiled.css +37 -0
- package/dist/esm/ui/Task/RequestToEditPopup.js +168 -0
- package/dist/types/nodeviews/TaskItemNodeView.d.ts +40 -0
- package/dist/types/nodeviews/task-node-view.d.ts +10 -0
- package/dist/types/nodeviews/taskItem.d.ts +2 -1
- package/dist/types/nodeviews/taskItemNodeSpec.d.ts +10 -0
- package/dist/types/pm-plugins/actions.d.ts +2 -1
- package/dist/types/pm-plugins/helpers.d.ts +3 -0
- package/dist/types/pm-plugins/types.d.ts +7 -2
- package/dist/types/tasksAndDecisionsPlugin.d.ts +0 -1
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/ui/Task/RequestToEditPopup.d.ts +22 -0
- package/dist/types/ui/Task/task-item-with-providers.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/TaskItemNodeView.d.ts +40 -0
- package/dist/types-ts4.5/nodeviews/task-node-view.d.ts +10 -0
- package/dist/types-ts4.5/nodeviews/taskItem.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/taskItemNodeSpec.d.ts +10 -0
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/helpers.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/types.d.ts +7 -2
- package/dist/types-ts4.5/tasksAndDecisionsPlugin.d.ts +0 -1
- package/dist/types-ts4.5/types/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/Task/RequestToEditPopup.d.ts +22 -0
- package/dist/types-ts4.5/ui/Task/task-item-with-providers.d.ts +1 -0
- package/package.json +18 -13
- package/dist/types/nodeviews/task-lazy-node-view.d.ts +0 -6
- package/dist/types-ts4.5/nodeviews/task-lazy-node-view.d.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-tasks-and-decisions
|
|
2
2
|
|
|
3
|
+
## 5.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#146751](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/146751)
|
|
8
|
+
[`ba4499469ce64`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ba4499469ce64) -
|
|
9
|
+
fix vanilla task with collab session
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 5.1.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#139777](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/139777)
|
|
17
|
+
[`cfdfe0077993d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cfdfe0077993d) -
|
|
18
|
+
Fix bug where a refs were passed incorrectly, preventing task item focus from being set
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 5.1.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.TaskItemNodeView = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _bindEventListener = require("bind-event-listener");
|
|
12
|
+
var _steps = require("@atlaskit/adf-schema/steps");
|
|
13
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
|
+
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
15
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
16
|
+
var _helpers = require("../pm-plugins/helpers");
|
|
17
|
+
var _taskItemNodeSpec = require("./taskItemNodeSpec");
|
|
18
|
+
var TaskItemNodeView = exports.TaskItemNodeView = /*#__PURE__*/function () {
|
|
19
|
+
function TaskItemNodeView(node, view, getPos, _ref) {
|
|
20
|
+
var _this = this;
|
|
21
|
+
var api = _ref.api,
|
|
22
|
+
placeholder = _ref.placeholder,
|
|
23
|
+
intl = _ref.intl;
|
|
24
|
+
(0, _classCallCheck2.default)(this, TaskItemNodeView);
|
|
25
|
+
(0, _defineProperty2.default)(this, "dom", document.createElement('span'));
|
|
26
|
+
(0, _defineProperty2.default)(this, "handleOnClick", function (event) {
|
|
27
|
+
var _this$api;
|
|
28
|
+
if (!((_this$api = _this.api) !== null && _this$api !== void 0 && (_this$api = _this$api.taskDecision) !== null && _this$api !== void 0 && (_this$api = _this$api.sharedState.currentState()) !== null && _this$api !== void 0 && _this$api.hasEditPermission)) {
|
|
29
|
+
event.stopImmediatePropagation();
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
var pos = _this.getPos();
|
|
32
|
+
if (typeof pos === 'number') {
|
|
33
|
+
(0, _helpers.openRequestEditPopupAt)(_this.view, pos);
|
|
34
|
+
}
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
(0, _defineProperty2.default)(this, "handleOnChange", function () {
|
|
39
|
+
var _this$api2;
|
|
40
|
+
var tr = _this.view.state.tr;
|
|
41
|
+
var nodePos = _this.getPos();
|
|
42
|
+
if (typeof nodePos !== 'number') {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
var _this$node$attrs = _this.node.attrs,
|
|
46
|
+
localId = _this$node$attrs.localId,
|
|
47
|
+
state = _this$node$attrs.state;
|
|
48
|
+
var isDone = state === 'DONE';
|
|
49
|
+
var nextState = isDone ? 'TODO' : 'DONE';
|
|
50
|
+
var currentTaskDecisionState = (_this$api2 = _this.api) === null || _this$api2 === void 0 ? void 0 : _this$api2.taskDecision.sharedState.currentState();
|
|
51
|
+
|
|
52
|
+
// logic is inspired from packages/elements/task-decision/src/components/ResourcedTaskItem.tsx
|
|
53
|
+
if (currentTaskDecisionState !== null && currentTaskDecisionState !== void 0 && currentTaskDecisionState.taskDecisionProvider && _this.objectId) {
|
|
54
|
+
currentTaskDecisionState === null || currentTaskDecisionState === void 0 || currentTaskDecisionState.taskDecisionProvider.toggleTask({
|
|
55
|
+
localId: localId,
|
|
56
|
+
objectAri: _this.objectId
|
|
57
|
+
}, isDone ? 'DONE' : 'TODO');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// SetAttrsStep should be used to prevent task updates from being dropped when mapping task ticks
|
|
61
|
+
// from a previous version of the document, such as a published page.
|
|
62
|
+
tr.step(new _steps.SetAttrsStep(nodePos, {
|
|
63
|
+
state: nextState,
|
|
64
|
+
localId: localId
|
|
65
|
+
}));
|
|
66
|
+
tr.setMeta('scrollIntoView', false);
|
|
67
|
+
_this.view.dispatch(tr);
|
|
68
|
+
});
|
|
69
|
+
this.node = node;
|
|
70
|
+
this.view = view;
|
|
71
|
+
this.getPos = getPos;
|
|
72
|
+
this.intl = intl;
|
|
73
|
+
this.api = api;
|
|
74
|
+
this.view = view;
|
|
75
|
+
try {
|
|
76
|
+
var domPlaceholder = placeholder !== null && placeholder !== void 0 ? placeholder : this.intl.formatMessage(_messages.tasksAndDecisionsMessages.taskPlaceholder);
|
|
77
|
+
var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, (0, _taskItemNodeSpec.taskItemToDom)(node, domPlaceholder)),
|
|
78
|
+
dom = _DOMSerializer$render.dom,
|
|
79
|
+
contentDOM = _DOMSerializer$render.contentDOM;
|
|
80
|
+
if (!(dom instanceof HTMLElement)) {
|
|
81
|
+
// It's safe to throw error here because, the code is wrapped in try-catch.
|
|
82
|
+
// However, it should never happen because `DOMSerializer.renderSpec()` should always return HTMLElement.
|
|
83
|
+
throw new Error('DOMSerializer.renderSpec() did not return HTMLElement');
|
|
84
|
+
}
|
|
85
|
+
this.dom = dom;
|
|
86
|
+
this.contentDOM = contentDOM;
|
|
87
|
+
this.input = this.dom.querySelector('input[type="checkbox"]');
|
|
88
|
+
this.unbindInputDom = (0, _bindEventListener.bindAll)(this.input, [{
|
|
89
|
+
type: 'click',
|
|
90
|
+
listener: this.handleOnClick
|
|
91
|
+
}, {
|
|
92
|
+
type: 'change',
|
|
93
|
+
listener: this.handleOnChange
|
|
94
|
+
}]);
|
|
95
|
+
this.objectId = this.getObjectAri();
|
|
96
|
+
this.updatePlaceholder(node);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
TaskItemNodeView.logError(error instanceof Error ? error : new Error('Unknown error on TaskItemNodeView constructor'));
|
|
99
|
+
this.renderFallback();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return (0, _createClass2.default)(TaskItemNodeView, [{
|
|
103
|
+
key: "getContextIdentifierProvider",
|
|
104
|
+
value: function getContextIdentifierProvider() {
|
|
105
|
+
var _this$api3;
|
|
106
|
+
return (_this$api3 = this.api) === null || _this$api3 === void 0 || (_this$api3 = _this$api3.contextIdentifier) === null || _this$api3 === void 0 || (_this$api3 = _this$api3.sharedState.currentState()) === null || _this$api3 === void 0 ? void 0 : _this$api3.contextIdentifierProvider;
|
|
107
|
+
}
|
|
108
|
+
}, {
|
|
109
|
+
key: "getObjectAri",
|
|
110
|
+
value: function getObjectAri() {
|
|
111
|
+
var provider = this.getContextIdentifierProvider();
|
|
112
|
+
if (provider) {
|
|
113
|
+
return provider.objectId;
|
|
114
|
+
}
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
key: "isContentEmpty",
|
|
119
|
+
value: function isContentEmpty(node) {
|
|
120
|
+
return node.content.childCount === 0;
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "renderFallback",
|
|
124
|
+
value: function renderFallback() {
|
|
125
|
+
var _this$node$firstChild;
|
|
126
|
+
var fallbackElementInput = document.createElement('input');
|
|
127
|
+
fallbackElementInput.setAttribute('type', 'checkbox');
|
|
128
|
+
var fallbackElementText = document.createElement('span');
|
|
129
|
+
fallbackElementText.innerText = ((_this$node$firstChild = this.node.firstChild) === null || _this$node$firstChild === void 0 ? void 0 : _this$node$firstChild.text) || '';
|
|
130
|
+
this.dom.appendChild(fallbackElementInput);
|
|
131
|
+
this.dom.appendChild(fallbackElementText);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Update the placeholder visibility based on content
|
|
135
|
+
}, {
|
|
136
|
+
key: "updatePlaceholder",
|
|
137
|
+
value: function updatePlaceholder(node) {
|
|
138
|
+
var currentIsContentEmpty = this.isContentEmpty(node);
|
|
139
|
+
if (currentIsContentEmpty !== this.emptyContent) {
|
|
140
|
+
var _this$contentDOM;
|
|
141
|
+
this.emptyContent = currentIsContentEmpty;
|
|
142
|
+
(_this$contentDOM = this.contentDOM) === null || _this$contentDOM === void 0 || _this$contentDOM.toggleAttribute('data-empty', currentIsContentEmpty);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}, {
|
|
146
|
+
key: "update",
|
|
147
|
+
value: function update(node) {
|
|
148
|
+
var isValidUpdate = node.type === this.node.type && !!(node.attrs.state === this.node.attrs.state);
|
|
149
|
+
if (!isValidUpdate) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
this.updatePlaceholder(node);
|
|
153
|
+
if (!node.sameMarkup(this.node)) {
|
|
154
|
+
this.dom.setAttribute('data-task-state', node.attrs.state);
|
|
155
|
+
this.dom.setAttribute('data-task-local-id', node.attrs.localId);
|
|
156
|
+
this.dom.setAttribute('state', node.attrs.state);
|
|
157
|
+
}
|
|
158
|
+
this.node = node;
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
key: "ignoreMutation",
|
|
163
|
+
value: function ignoreMutation(mutation) {
|
|
164
|
+
if (!this.contentDOM) {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
return !this.contentDOM.contains(mutation.target) && mutation.type !== 'selection';
|
|
168
|
+
}
|
|
169
|
+
}, {
|
|
170
|
+
key: "destroy",
|
|
171
|
+
value: function destroy() {
|
|
172
|
+
if (this.unbindInputDom) {
|
|
173
|
+
this.unbindInputDom();
|
|
174
|
+
}
|
|
175
|
+
this.contentDOM = undefined;
|
|
176
|
+
this.input = undefined;
|
|
177
|
+
this.objectId = undefined;
|
|
178
|
+
this.emptyContent = undefined;
|
|
179
|
+
this.api = undefined;
|
|
180
|
+
}
|
|
181
|
+
}], [{
|
|
182
|
+
key: "logError",
|
|
183
|
+
value: function logError(error) {
|
|
184
|
+
void (0, _monitoring.logException)(error, {
|
|
185
|
+
location: 'editor-plugin-date/DateNodeView'
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}]);
|
|
189
|
+
}();
|
|
@@ -4,16 +4,28 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.taskView = void 0;
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
10
10
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
11
11
|
var _taskItem = require("./taskItem");
|
|
12
|
+
var _TaskItemNodeView = require("./TaskItemNodeView");
|
|
12
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != (0, _typeof2.default)(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
-
var
|
|
15
|
+
var taskView = exports.taskView = function taskView(portalProviderAPI, eventDispatcher, providerFactory, api, intl, placeholder) {
|
|
16
|
+
if ((0, _experiments.editorExperiment)('platform_editor_vanilla_dom', true, {
|
|
17
|
+
exposure: true
|
|
18
|
+
})) {
|
|
19
|
+
return function (node, view, getPos) {
|
|
20
|
+
return new _TaskItemNodeView.TaskItemNodeView(node, view, getPos, {
|
|
21
|
+
placeholder: placeholder,
|
|
22
|
+
api: api,
|
|
23
|
+
intl: intl
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
15
27
|
if ((0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false)) {
|
|
16
|
-
return (0, _taskItem.taskItemNodeViewFactory)(portalProviderAPI, eventDispatcher, providerFactory, api, placeholder);
|
|
28
|
+
return (0, _taskItem.taskItemNodeViewFactory)(portalProviderAPI, eventDispatcher, providerFactory, api, intl, placeholder);
|
|
17
29
|
}
|
|
18
30
|
return (0, _lazyNodeView.withLazyLoading)({
|
|
19
31
|
nodeName: 'taskItem',
|
|
@@ -25,7 +37,7 @@ var lazyTaskView = exports.lazyTaskView = function lazyTaskView(portalProviderAP
|
|
|
25
37
|
}).then(function (_ref) {
|
|
26
38
|
var taskItemNodeViewFactory = _ref.taskItemNodeViewFactory;
|
|
27
39
|
return function (node, view, getPos) {
|
|
28
|
-
return taskItemNodeViewFactory(portalProviderAPI, eventDispatcher, providerFactory, api, placeholder)(node, view, getPos);
|
|
40
|
+
return taskItemNodeViewFactory(portalProviderAPI, eventDispatcher, providerFactory, api, intl, placeholder)(node, view, getPos);
|
|
29
41
|
};
|
|
30
42
|
});
|
|
31
43
|
return result;
|
|
@@ -389,7 +389,7 @@ var Task = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
389
389
|
}
|
|
390
390
|
}]);
|
|
391
391
|
}(_reactNodeView.default);
|
|
392
|
-
function taskItemNodeViewFactory(portalProviderAPI, eventDispatcher, providerFactory, api, placeholder) {
|
|
392
|
+
function taskItemNodeViewFactory(portalProviderAPI, eventDispatcher, providerFactory, api, intl, placeholder) {
|
|
393
393
|
return function (node, view, getPos) {
|
|
394
394
|
return new Task(node, view, getPos, portalProviderAPI, eventDispatcher, {
|
|
395
395
|
placeholder: placeholder,
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.taskItemNodeSpec = exports.lazyTaskItemToDom = void 0;
|
|
8
|
+
exports.taskItemToDom = taskItemToDom;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _adfSchema = require("@atlaskit/adf-schema");
|
|
11
|
+
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
12
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
13
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
14
|
+
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; }
|
|
15
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
|
+
/**
|
|
17
|
+
* Wrapper for ADF taskItem node spec to augment toDOM implementation
|
|
18
|
+
* with fallback UI for lazy node view rendering / window virtualization
|
|
19
|
+
* @nodeSpecException:toDOM patch
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
var taskItemNodeSpec = exports.taskItemNodeSpec = function taskItemNodeSpec() {
|
|
23
|
+
if ((0, _experiments.editorExperiment)('platform_editor_exp_lazy_node_views', false)) {
|
|
24
|
+
return _adfSchema.taskItem;
|
|
25
|
+
}
|
|
26
|
+
return _objectSpread(_objectSpread({}, _adfSchema.taskItem), {}, {
|
|
27
|
+
toDOM: function toDOM(node) {
|
|
28
|
+
return lazyTaskItemToDom(node);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
function taskItemToDom(node, placeholder) {
|
|
33
|
+
var checked = node.attrs.state === 'DONE';
|
|
34
|
+
var inputAttrs = {
|
|
35
|
+
name: node.attrs.localId,
|
|
36
|
+
id: node.attrs.localId,
|
|
37
|
+
type: 'checkbox'
|
|
38
|
+
};
|
|
39
|
+
if (checked) {
|
|
40
|
+
inputAttrs.checked = 'true';
|
|
41
|
+
}
|
|
42
|
+
var dataAttrs = {
|
|
43
|
+
'data-task-local-id': node.attrs.localId,
|
|
44
|
+
'data-task-state': node.attrs.state,
|
|
45
|
+
'data-prosemirror-node-view-type': 'vanilla'
|
|
46
|
+
};
|
|
47
|
+
return ['div', _objectSpread(_objectSpread({
|
|
48
|
+
class: "".concat(_styles.TaskDecisionSharedCssClassName.TASK_CONTAINER)
|
|
49
|
+
}, dataAttrs), {}, {
|
|
50
|
+
state: node.attrs.state
|
|
51
|
+
}), ['div', {
|
|
52
|
+
'data-component': 'task-item-main'
|
|
53
|
+
}, ['span', {
|
|
54
|
+
contenteditable: 'false',
|
|
55
|
+
class: "".concat(_styles.TaskDecisionSharedCssClassName.TASK_CHECKBOX_CONTAINER),
|
|
56
|
+
'data-component': 'task-item-input-wrap'
|
|
57
|
+
}, ['input', _objectSpread(_objectSpread({}, inputAttrs), {}, {
|
|
58
|
+
'data-input-type': 'task-item',
|
|
59
|
+
'data-task-input': true,
|
|
60
|
+
'data-testid': 'task-item-checkbox',
|
|
61
|
+
'data-component': 'task-item-input',
|
|
62
|
+
role: 'checkbox'
|
|
63
|
+
})], ['span', {
|
|
64
|
+
'aria-hidden': true,
|
|
65
|
+
'data-component': 'checkbox-icon-wrap'
|
|
66
|
+
}, ['http://www.w3.org/2000/svg svg', {
|
|
67
|
+
viewBox: "0 0 16 16",
|
|
68
|
+
width: '16',
|
|
69
|
+
height: '16',
|
|
70
|
+
role: 'presentation',
|
|
71
|
+
fill: 'none',
|
|
72
|
+
'data-component': 'checkbox-unchecked-icon'
|
|
73
|
+
}, ['http://www.w3.org/2000/svg rect', {
|
|
74
|
+
width: '12.5',
|
|
75
|
+
height: '12.5',
|
|
76
|
+
x: '1.75',
|
|
77
|
+
y: '1.75',
|
|
78
|
+
stroke: 'currentcolor',
|
|
79
|
+
'stroke-width': '1.5',
|
|
80
|
+
rx: '1.25'
|
|
81
|
+
}]], ['http://www.w3.org/2000/svg svg', {
|
|
82
|
+
viewBox: "0 0 16 16",
|
|
83
|
+
width: '16',
|
|
84
|
+
height: '16',
|
|
85
|
+
role: 'presentation',
|
|
86
|
+
fill: 'none',
|
|
87
|
+
'data-component': 'checkbox-checked-icon'
|
|
88
|
+
}, ['http://www.w3.org/2000/svg path', {
|
|
89
|
+
fill: 'currentcolor',
|
|
90
|
+
'fill-rule': 'evenodd',
|
|
91
|
+
'clip-rule': 'evenodd',
|
|
92
|
+
d: 'M3 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2zm9.326 4.48-1.152-.96L6.75 9.828 4.826 7.52l-1.152.96 2.5 3a.75.75 0 0 0 1.152 0z'
|
|
93
|
+
}]]]], ['span', {
|
|
94
|
+
class: 'placeholder-node-view',
|
|
95
|
+
'data-testid': 'task-decision-item-placeholder',
|
|
96
|
+
'data-component': 'placeholder',
|
|
97
|
+
contenteditable: 'false'
|
|
98
|
+
}, placeholder], ['div', {
|
|
99
|
+
'data-component': 'content'
|
|
100
|
+
}, ['div', {
|
|
101
|
+
class: _styles.TaskDecisionSharedCssClassName.TASK_ITEM
|
|
102
|
+
}, 0]]]];
|
|
103
|
+
}
|
|
104
|
+
var lazyTaskItemToDom = exports.lazyTaskItemToDom = function lazyTaskItemToDom(node) {
|
|
105
|
+
var checked = node.attrs.state === 'DONE';
|
|
106
|
+
var inputAttrs = {
|
|
107
|
+
name: node.attrs.localId,
|
|
108
|
+
id: node.attrs.localId,
|
|
109
|
+
type: 'checkbox'
|
|
110
|
+
};
|
|
111
|
+
if (checked) {
|
|
112
|
+
inputAttrs.checked = 'true';
|
|
113
|
+
}
|
|
114
|
+
var dataAttrs = {
|
|
115
|
+
'data-task-local-id': node.attrs.localId,
|
|
116
|
+
'data-task-state': node.attrs.state
|
|
117
|
+
};
|
|
118
|
+
return ['div', _objectSpread(_objectSpread({
|
|
119
|
+
class: _styles.TaskDecisionSharedCssClassName.TASK_CONTAINER
|
|
120
|
+
}, dataAttrs), {}, {
|
|
121
|
+
style: (0, _lazyNodeView.convertToInlineCss)({
|
|
122
|
+
listStyleType: 'none',
|
|
123
|
+
lineHeight: '24px',
|
|
124
|
+
minWidth: '48px',
|
|
125
|
+
position: 'relative'
|
|
126
|
+
})
|
|
127
|
+
}), ['div', {
|
|
128
|
+
style: (0, _lazyNodeView.convertToInlineCss)({
|
|
129
|
+
display: 'flex'
|
|
130
|
+
})
|
|
131
|
+
}, ['span', {
|
|
132
|
+
contenteditable: 'false',
|
|
133
|
+
style: (0, _lazyNodeView.convertToInlineCss)({
|
|
134
|
+
width: '24px',
|
|
135
|
+
height: '24px',
|
|
136
|
+
lineHeight: '24px',
|
|
137
|
+
display: 'grid',
|
|
138
|
+
placeContent: 'center center'
|
|
139
|
+
})
|
|
140
|
+
}, ['input', _objectSpread(_objectSpread({}, inputAttrs), {}, {
|
|
141
|
+
'data-input-type': 'lazy-task-item',
|
|
142
|
+
style: (0, _lazyNodeView.convertToInlineCss)({
|
|
143
|
+
width: '13px',
|
|
144
|
+
height: '13px',
|
|
145
|
+
margin: '1px 0 0 0',
|
|
146
|
+
padding: 0,
|
|
147
|
+
accentColor: "var(--ds-background-selected-bold, #0C66E4)"
|
|
148
|
+
})
|
|
149
|
+
})]], ['div', {
|
|
150
|
+
'data-component': 'content'
|
|
151
|
+
}, ['div', {
|
|
152
|
+
class: _styles.TaskDecisionSharedCssClassName.TASK_ITEM,
|
|
153
|
+
style: (0, _lazyNodeView.convertToInlineCss)({
|
|
154
|
+
display: 'block',
|
|
155
|
+
fontSize: '16px',
|
|
156
|
+
fontFamily: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
|
|
157
|
+
color: "var(--ds-text, #172B4D)"
|
|
158
|
+
})
|
|
159
|
+
}, 0]]]];
|
|
160
|
+
};
|
|
@@ -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.setProvider = exports.focusTaskDecision = void 0;
|
|
7
|
+
exports.setProvider = exports.openRequestEditPopup = exports.focusTaskDecision = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
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; }
|
|
10
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -17,4 +17,9 @@ var setProvider = exports.setProvider = function setProvider(state, action) {
|
|
|
17
17
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
18
18
|
taskDecisionProvider: action.data
|
|
19
19
|
});
|
|
20
|
+
};
|
|
21
|
+
var openRequestEditPopup = exports.openRequestEditPopup = function openRequestEditPopup(state, action) {
|
|
22
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
23
|
+
openRequestToEditPopupAt: action.data
|
|
24
|
+
});
|
|
20
25
|
};
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.closeRequestEditPopupAt = closeRequestEditPopupAt;
|
|
6
7
|
exports.findFirstParentListNode = findFirstParentListNode;
|
|
8
|
+
exports.focusCheckbox = focusCheckbox;
|
|
7
9
|
exports.focusCheckboxAndUpdateSelection = focusCheckboxAndUpdateSelection;
|
|
8
10
|
exports.getAllTaskItemsDataInRootTaskList = getAllTaskItemsDataInRootTaskList;
|
|
9
11
|
exports.getCurrentIndentLevel = exports.getBlockRange = void 0;
|
|
@@ -11,6 +13,7 @@ exports.getCurrentTaskItemIndex = getCurrentTaskItemIndex;
|
|
|
11
13
|
exports.getTaskItemDataAtPos = getTaskItemDataAtPos;
|
|
12
14
|
exports.getTaskItemDataToFocus = getTaskItemDataToFocus;
|
|
13
15
|
exports.liftBlock = exports.isTable = exports.isInsideTaskOrDecisionItem = exports.isInsideTask = exports.isInsideDecision = exports.isEmptyTaskDecision = exports.isActionOrDecisionList = exports.isActionOrDecisionItem = exports.getTaskItemIndex = void 0;
|
|
16
|
+
exports.openRequestEditPopupAt = openRequestEditPopupAt;
|
|
14
17
|
exports.removeCheckboxFocus = removeCheckboxFocus;
|
|
15
18
|
exports.walkOut = exports.subtreeHeight = void 0;
|
|
16
19
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
@@ -275,13 +278,25 @@ function getTaskItemDataToFocus(view, direction) {
|
|
|
275
278
|
localId: taskItemToFocus.node.attrs.localId
|
|
276
279
|
};
|
|
277
280
|
}
|
|
281
|
+
function focusCheckbox(view, taskItemData) {
|
|
282
|
+
var state = view.state,
|
|
283
|
+
dispatch = view.dispatch;
|
|
284
|
+
var tr = state.tr;
|
|
285
|
+
if (taskItemData) {
|
|
286
|
+
tr.setMeta(_pluginKey.stateKey, {
|
|
287
|
+
action: _types.ACTIONS.FOCUS_BY_LOCALID,
|
|
288
|
+
data: taskItemData.localId
|
|
289
|
+
});
|
|
290
|
+
dispatch(tr);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
278
293
|
function focusCheckboxAndUpdateSelection(view, taskItemData) {
|
|
279
294
|
var pos = taskItemData.pos,
|
|
280
295
|
localId = taskItemData.localId;
|
|
281
296
|
var state = view.state,
|
|
282
297
|
dispatch = view.dispatch;
|
|
283
|
-
var doc = state.doc
|
|
284
|
-
|
|
298
|
+
var doc = state.doc;
|
|
299
|
+
var tr = state.tr;
|
|
285
300
|
tr.setSelection(new _state.TextSelection(doc.resolve(pos + 1)));
|
|
286
301
|
tr.setMeta(_pluginKey.stateKey, {
|
|
287
302
|
action: _types.ACTIONS.FOCUS_BY_LOCALID,
|
|
@@ -298,6 +313,24 @@ function removeCheckboxFocus(view) {
|
|
|
298
313
|
action: _types.ACTIONS.FOCUS_BY_LOCALID
|
|
299
314
|
}));
|
|
300
315
|
}
|
|
316
|
+
function openRequestEditPopupAt(view, pos) {
|
|
317
|
+
var state = view.state,
|
|
318
|
+
dispatch = view.dispatch;
|
|
319
|
+
var tr = state.tr;
|
|
320
|
+
dispatch(tr.setMeta(_pluginKey.stateKey, {
|
|
321
|
+
action: _types.ACTIONS.OPEN_REQUEST_TO_EDIT_POPUP,
|
|
322
|
+
data: pos
|
|
323
|
+
}));
|
|
324
|
+
}
|
|
325
|
+
function closeRequestEditPopupAt(view) {
|
|
326
|
+
var state = view.state,
|
|
327
|
+
dispatch = view.dispatch;
|
|
328
|
+
var tr = state.tr;
|
|
329
|
+
dispatch(tr.setMeta(_pluginKey.stateKey, {
|
|
330
|
+
action: _types.ACTIONS.OPEN_REQUEST_TO_EDIT_POPUP,
|
|
331
|
+
data: null
|
|
332
|
+
}));
|
|
333
|
+
}
|
|
301
334
|
function findFirstParentListNode($pos) {
|
|
302
335
|
var currentNode = $pos.doc.nodeAt($pos.pos);
|
|
303
336
|
var listNodePosition = null;
|
|
@@ -17,7 +17,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
17
17
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
18
18
|
var _decisionLazyNodeView = require("../nodeviews/decision-lazy-node-view");
|
|
19
19
|
var _DecisionItemVanilla = require("../nodeviews/DecisionItemVanilla");
|
|
20
|
-
var
|
|
20
|
+
var _taskNodeView = require("../nodeviews/task-node-view");
|
|
21
21
|
var _actions = require("./actions");
|
|
22
22
|
var _helpers = require("./helpers");
|
|
23
23
|
var _pluginKey = require("./plugin-key");
|
|
@@ -42,7 +42,7 @@ function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispa
|
|
|
42
42
|
return new _safePlugin.SafePlugin({
|
|
43
43
|
props: {
|
|
44
44
|
nodeViews: {
|
|
45
|
-
taskItem: (0,
|
|
45
|
+
taskItem: (0, _taskNodeView.taskView)(portalProviderAPI, eventDispatcher, providerFactory, api, getIntl(), taskPlaceholder),
|
|
46
46
|
decisionItem: function (node, view, getPos, decorations, innerDecorations) {
|
|
47
47
|
if ((0, _experiments.editorExperiment)('platform_editor_vanilla_dom', true, {
|
|
48
48
|
exposure: true
|
|
@@ -70,7 +70,7 @@ function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispa
|
|
|
70
70
|
}
|
|
71
71
|
return false;
|
|
72
72
|
},
|
|
73
|
-
handleClickOn: (0, _selection.createSelectionClickHandler)(['decisionItem'], function (target) {
|
|
73
|
+
handleClickOn: (0, _selection.createSelectionClickHandler)(['decisionItem', 'taskItem'], function (target) {
|
|
74
74
|
return target.hasAttribute('data-decision-wrapper') || target.getAttribute('aria-label') === 'Decision';
|
|
75
75
|
}, {
|
|
76
76
|
useLongPressSelection: useLongPressSelection
|
|
@@ -81,8 +81,7 @@ function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispa
|
|
|
81
81
|
change: _taskItemOnChange.taskItemOnChange
|
|
82
82
|
},
|
|
83
83
|
handleKeyDown: function handleKeyDown(view, event) {
|
|
84
|
-
var state = view.state
|
|
85
|
-
dispatch = view.dispatch;
|
|
84
|
+
var state = view.state;
|
|
86
85
|
var selection = state.selection,
|
|
87
86
|
schema = state.schema;
|
|
88
87
|
var $from = selection.$from,
|
|
@@ -140,16 +139,12 @@ function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispa
|
|
|
140
139
|
}
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
|
-
|
|
144
142
|
// If left arrow key is pressed and cursor is at first position in task-item
|
|
145
143
|
// then focus checkbox and DON'T proceed with default keyboard handler
|
|
146
144
|
if (event.key === 'ArrowLeft' && parentOffset === 0) {
|
|
147
145
|
// here we are not using focusCheckboxAndUpdateSelection() method
|
|
148
146
|
// because it is working incorretly when we are placing is inside the nested items
|
|
149
|
-
|
|
150
|
-
action: _types.ACTIONS.FOCUS_BY_LOCALID,
|
|
151
|
-
data: currentTaskItemData === null || currentTaskItemData === void 0 ? void 0 : currentTaskItemData.localId
|
|
152
|
-
}));
|
|
147
|
+
(0, _helpers.focusCheckbox)(view, currentTaskItemData);
|
|
153
148
|
return true;
|
|
154
149
|
}
|
|
155
150
|
if (event.key === 'ArrowRight') {
|
|
@@ -213,6 +208,12 @@ function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispa
|
|
|
213
208
|
data: data
|
|
214
209
|
});
|
|
215
210
|
break;
|
|
211
|
+
case _types.ACTIONS.OPEN_REQUEST_TO_EDIT_POPUP:
|
|
212
|
+
newPluginState = (0, _actions.openRequestEditPopup)(newPluginState, {
|
|
213
|
+
action: _types.ACTIONS.OPEN_REQUEST_TO_EDIT_POPUP,
|
|
214
|
+
data: data
|
|
215
|
+
});
|
|
216
|
+
break;
|
|
216
217
|
}
|
|
217
218
|
|
|
218
219
|
// Commands
|
|
@@ -273,6 +274,28 @@ function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispa
|
|
|
273
274
|
return tr.setMeta('addToHistory', false);
|
|
274
275
|
}
|
|
275
276
|
return;
|
|
277
|
+
},
|
|
278
|
+
view: function view() {
|
|
279
|
+
return {
|
|
280
|
+
update: function update(view, prevState) {
|
|
281
|
+
var pluginState = _pluginKey.stateKey.getState(view.state);
|
|
282
|
+
var prevPluginState = _pluginKey.stateKey.getState(prevState);
|
|
283
|
+
if (pluginState.focusedTaskItemLocalId === prevPluginState.focusedTaskItemLocalId) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
var taskItem = (0, _helpers.getTaskItemDataAtPos)(view);
|
|
287
|
+
if (!taskItem) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (pluginState.focusedTaskItemLocalId === taskItem.localId) {
|
|
291
|
+
var taskElement = view.nodeDOM(taskItem.pos);
|
|
292
|
+
if (taskElement instanceof HTMLElement) {
|
|
293
|
+
var _taskElement$querySel;
|
|
294
|
+
taskElement === null || taskElement === void 0 || (_taskElement$querySel = taskElement.querySelector('input')) === null || _taskElement$querySel === void 0 || _taskElement$querySel.focus();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
276
299
|
}
|
|
277
300
|
});
|
|
278
301
|
}
|
|
@@ -7,6 +7,7 @@ exports.ACTIONS = void 0;
|
|
|
7
7
|
var ACTIONS = exports.ACTIONS = /*#__PURE__*/function (ACTIONS) {
|
|
8
8
|
ACTIONS[ACTIONS["SET_PROVIDER"] = 0] = "SET_PROVIDER";
|
|
9
9
|
ACTIONS[ACTIONS["FOCUS_BY_LOCALID"] = 1] = "FOCUS_BY_LOCALID";
|
|
10
|
+
ACTIONS[ACTIONS["OPEN_REQUEST_TO_EDIT_POPUP"] = 2] = "OPEN_REQUEST_TO_EDIT_POPUP";
|
|
10
11
|
return ACTIONS;
|
|
11
12
|
}({}); // actions
|
|
12
13
|
// commands
|