@atlaskit/editor-plugin-tasks-and-decisions 6.2.0 → 6.2.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/pm-plugins/main.js +11 -3
- package/dist/cjs/pm-plugins/utils/paste.js +78 -0
- package/dist/es2019/pm-plugins/main.js +11 -3
- package/dist/es2019/pm-plugins/utils/paste.js +75 -0
- package/dist/esm/pm-plugins/main.js +11 -3
- package/dist/esm/pm-plugins/utils/paste.js +72 -0
- package/dist/types/pm-plugins/utils/paste.d.ts +22 -0
- package/dist/types/ui/Task/RequestToEditPopup.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/utils/paste.d.ts +22 -0
- package/dist/types-ts4.5/ui/Task/RequestToEditPopup.d.ts +0 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-tasks-and-decisions
|
|
2
2
|
|
|
3
|
+
## 6.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#200845](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/200845)
|
|
8
|
+
[`4e3985a5a347d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4e3985a5a347d) -
|
|
9
|
+
EDITOR-1320 Ensure localID creation for blockTaskItem
|
|
10
|
+
|
|
11
|
+
## 6.2.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#200663](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/200663)
|
|
16
|
+
[`0899e8f2578b2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0899e8f2578b2) -
|
|
17
|
+
[ux] EDITOR-1271 Modifies paste behaviour of editor-plugin-tasks-and-decisions to prevent
|
|
18
|
+
blockTaskItems being created when pasting block content into taskItems
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 6.2.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -22,6 +22,7 @@ var _helpers = require("./helpers");
|
|
|
22
22
|
var _pluginKey = require("./plugin-key");
|
|
23
23
|
var _taskItemOnChange = require("./taskItemOnChange");
|
|
24
24
|
var _types = require("./types");
|
|
25
|
+
var _paste = require("./utils/paste");
|
|
25
26
|
var _excluded = ["localId"];
|
|
26
27
|
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; }
|
|
27
28
|
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; }
|
|
@@ -176,6 +177,12 @@ function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api, getIntl
|
|
|
176
177
|
return false;
|
|
177
178
|
}
|
|
178
179
|
}
|
|
180
|
+
},
|
|
181
|
+
transformPasted: function transformPasted(slice, view) {
|
|
182
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_blocktaskitem_node', 'isEnabled', true)) {
|
|
183
|
+
slice = (0, _paste.tempTransformSliceToRemoveBlockTaskItem)(slice, view);
|
|
184
|
+
}
|
|
185
|
+
return slice;
|
|
179
186
|
}
|
|
180
187
|
},
|
|
181
188
|
state: {
|
|
@@ -254,7 +261,7 @@ function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api, getIntl
|
|
|
254
261
|
/*
|
|
255
262
|
* After each transaction, we search through the document for any decisionList/Item & taskList/Item nodes
|
|
256
263
|
* that do not have the localId attribute set and generate a random UUID to use. This is to replace a previous
|
|
257
|
-
* Prosemirror
|
|
264
|
+
* Prosemirror capability where node attributes could be generated dynamically.
|
|
258
265
|
* See https://discuss.prosemirror.net/t/release-0-23-0-possibly-to-be-1-0-0/959/17 for a discussion of this approach.
|
|
259
266
|
*
|
|
260
267
|
* Note: we currently do not handle the edge case where two nodes may have the same localId
|
|
@@ -273,8 +280,9 @@ function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api, getIntl
|
|
|
273
280
|
decisionList = _newState$schema$node.decisionList,
|
|
274
281
|
decisionItem = _newState$schema$node.decisionItem,
|
|
275
282
|
taskList = _newState$schema$node.taskList,
|
|
276
|
-
taskItem = _newState$schema$node.taskItem
|
|
277
|
-
|
|
283
|
+
taskItem = _newState$schema$node.taskItem,
|
|
284
|
+
blockTaskItem = _newState$schema$node.blockTaskItem;
|
|
285
|
+
if (!!node.type && (node.type === decisionList || node.type === decisionItem || node.type === taskList || node.type === taskItem || blockTaskItem && node.type === blockTaskItem)) {
|
|
278
286
|
var _node$attrs = node.attrs,
|
|
279
287
|
localId = _node$attrs.localId,
|
|
280
288
|
rest = (0, _objectWithoutProperties2.default)(_node$attrs, _excluded);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.tempTransformSliceToRemoveBlockTaskItem = void 0;
|
|
7
|
+
var _adfSchema = require("@atlaskit/adf-schema");
|
|
8
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
9
|
+
/**
|
|
10
|
+
* Transforms a paste slice to handle blockTaskItem nodes when pasting into task items.
|
|
11
|
+
*
|
|
12
|
+
* Initially we do not support user creation of blockTaskItem - it is intended primarily
|
|
13
|
+
* for TinyMCE migration purposes however that may change in the future.
|
|
14
|
+
* This function handles the behavior to work around Prosemirror behaviour which decides
|
|
15
|
+
* that blockTaskItem is the appropriate node to use here.
|
|
16
|
+
*
|
|
17
|
+
* @param slice - The slice being pasted
|
|
18
|
+
* @param view - The editor view where the paste is occurring
|
|
19
|
+
* @returns The transformed slice with blockTaskItems converted to taskItems when appropriate
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const transformedSlice = tempTransformSliceToRemoveBlockTaskItem(pasteSlice, editorView);
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @see {@link https://hello.atlassian.net/wiki/spaces/EDITOR/pages/5626622054/Block+elements+in+task+-+Decision+log#Can-users-create-block-task-items%3F} for reasoning
|
|
27
|
+
*/
|
|
28
|
+
var tempTransformSliceToRemoveBlockTaskItem = exports.tempTransformSliceToRemoveBlockTaskItem = function tempTransformSliceToRemoveBlockTaskItem(slice, view) {
|
|
29
|
+
var schema = view.state.schema;
|
|
30
|
+
var _schema$nodes = schema.nodes,
|
|
31
|
+
taskItem = _schema$nodes.taskItem,
|
|
32
|
+
blockTaskItem = _schema$nodes.blockTaskItem,
|
|
33
|
+
paragraph = _schema$nodes.paragraph;
|
|
34
|
+
|
|
35
|
+
// Check if we're pasting into a taskItem
|
|
36
|
+
var $from = view.state.selection.$from;
|
|
37
|
+
var isInTaskItem = $from.node().type === taskItem;
|
|
38
|
+
if (isInTaskItem && blockTaskItem) {
|
|
39
|
+
// Transform the slice to replace blockTaskItems with taskItems
|
|
40
|
+
var transformedContent = [];
|
|
41
|
+
slice.content.forEach(function (node) {
|
|
42
|
+
if (node.type === blockTaskItem) {
|
|
43
|
+
// Check if blockTaskItem only contains paragraphs
|
|
44
|
+
var allChildrenAreParagraphs = true;
|
|
45
|
+
node.content.forEach(function (child) {
|
|
46
|
+
if (child.type !== paragraph) {
|
|
47
|
+
allChildrenAreParagraphs = false;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (allChildrenAreParagraphs && node.childCount > 0) {
|
|
51
|
+
// Convert each paragraph to a taskItem
|
|
52
|
+
node.content.forEach(function (paragraphNode) {
|
|
53
|
+
var newTaskItem = taskItem.create({
|
|
54
|
+
localId: _adfSchema.uuid.generate(),
|
|
55
|
+
state: node.attrs.state || 'TODO'
|
|
56
|
+
}, paragraphNode.content);
|
|
57
|
+
transformedContent.push(newTaskItem);
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
// Keep the blockTaskItem as is if it doesn't only contain paragraphs
|
|
61
|
+
transformedContent.push(node);
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
// Keep other nodes as is
|
|
65
|
+
transformedContent.push(node);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Create new slice with transformed content
|
|
70
|
+
if (transformedContent.length !== slice.content.childCount || transformedContent.some(function (node, idx) {
|
|
71
|
+
return node !== slice.content.child(idx);
|
|
72
|
+
})) {
|
|
73
|
+
var newFragment = _model.Fragment.from(transformedContent);
|
|
74
|
+
return new _model.Slice(newFragment, slice.openStart, slice.openEnd);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return slice;
|
|
78
|
+
};
|
|
@@ -13,6 +13,7 @@ import { focusCheckbox, focusCheckboxAndUpdateSelection, getTaskItemDataAtPos, g
|
|
|
13
13
|
import { stateKey } from './plugin-key';
|
|
14
14
|
import { taskItemOnChange } from './taskItemOnChange';
|
|
15
15
|
import { ACTIONS } from './types';
|
|
16
|
+
import { tempTransformSliceToRemoveBlockTaskItem } from './utils/paste';
|
|
16
17
|
function nodesBetweenChanged(tr, f, startPos) {
|
|
17
18
|
const stepRange = getStepRange(tr);
|
|
18
19
|
if (!stepRange) {
|
|
@@ -168,6 +169,12 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
|
|
|
168
169
|
return false;
|
|
169
170
|
}
|
|
170
171
|
}
|
|
172
|
+
},
|
|
173
|
+
transformPasted: (slice, view) => {
|
|
174
|
+
if (expValEquals('platform_editor_blocktaskitem_node', 'isEnabled', true)) {
|
|
175
|
+
slice = tempTransformSliceToRemoveBlockTaskItem(slice, view);
|
|
176
|
+
}
|
|
177
|
+
return slice;
|
|
171
178
|
}
|
|
172
179
|
},
|
|
173
180
|
state: {
|
|
@@ -250,7 +257,7 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
|
|
|
250
257
|
/*
|
|
251
258
|
* After each transaction, we search through the document for any decisionList/Item & taskList/Item nodes
|
|
252
259
|
* that do not have the localId attribute set and generate a random UUID to use. This is to replace a previous
|
|
253
|
-
* Prosemirror
|
|
260
|
+
* Prosemirror capability where node attributes could be generated dynamically.
|
|
254
261
|
* See https://discuss.prosemirror.net/t/release-0-23-0-possibly-to-be-1-0-0/959/17 for a discussion of this approach.
|
|
255
262
|
*
|
|
256
263
|
* Note: we currently do not handle the edge case where two nodes may have the same localId
|
|
@@ -269,9 +276,10 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
|
|
|
269
276
|
decisionList,
|
|
270
277
|
decisionItem,
|
|
271
278
|
taskList,
|
|
272
|
-
taskItem
|
|
279
|
+
taskItem,
|
|
280
|
+
blockTaskItem
|
|
273
281
|
} = newState.schema.nodes;
|
|
274
|
-
if (!!node.type && (node.type === decisionList || node.type === decisionItem || node.type === taskList || node.type === taskItem)) {
|
|
282
|
+
if (!!node.type && (node.type === decisionList || node.type === decisionItem || node.type === taskList || node.type === taskItem || blockTaskItem && node.type === blockTaskItem)) {
|
|
275
283
|
const {
|
|
276
284
|
localId,
|
|
277
285
|
...rest
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { uuid } from '@atlaskit/adf-schema';
|
|
2
|
+
import { Slice, Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
/**
|
|
4
|
+
* Transforms a paste slice to handle blockTaskItem nodes when pasting into task items.
|
|
5
|
+
*
|
|
6
|
+
* Initially we do not support user creation of blockTaskItem - it is intended primarily
|
|
7
|
+
* for TinyMCE migration purposes however that may change in the future.
|
|
8
|
+
* This function handles the behavior to work around Prosemirror behaviour which decides
|
|
9
|
+
* that blockTaskItem is the appropriate node to use here.
|
|
10
|
+
*
|
|
11
|
+
* @param slice - The slice being pasted
|
|
12
|
+
* @param view - The editor view where the paste is occurring
|
|
13
|
+
* @returns The transformed slice with blockTaskItems converted to taskItems when appropriate
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const transformedSlice = tempTransformSliceToRemoveBlockTaskItem(pasteSlice, editorView);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @see {@link https://hello.atlassian.net/wiki/spaces/EDITOR/pages/5626622054/Block+elements+in+task+-+Decision+log#Can-users-create-block-task-items%3F} for reasoning
|
|
21
|
+
*/
|
|
22
|
+
export const tempTransformSliceToRemoveBlockTaskItem = (slice, view) => {
|
|
23
|
+
const {
|
|
24
|
+
schema
|
|
25
|
+
} = view.state;
|
|
26
|
+
const {
|
|
27
|
+
taskItem,
|
|
28
|
+
blockTaskItem,
|
|
29
|
+
paragraph
|
|
30
|
+
} = schema.nodes;
|
|
31
|
+
|
|
32
|
+
// Check if we're pasting into a taskItem
|
|
33
|
+
const {
|
|
34
|
+
$from
|
|
35
|
+
} = view.state.selection;
|
|
36
|
+
const isInTaskItem = $from.node().type === taskItem;
|
|
37
|
+
if (isInTaskItem && blockTaskItem) {
|
|
38
|
+
// Transform the slice to replace blockTaskItems with taskItems
|
|
39
|
+
const transformedContent = [];
|
|
40
|
+
slice.content.forEach(node => {
|
|
41
|
+
if (node.type === blockTaskItem) {
|
|
42
|
+
// Check if blockTaskItem only contains paragraphs
|
|
43
|
+
let allChildrenAreParagraphs = true;
|
|
44
|
+
node.content.forEach(child => {
|
|
45
|
+
if (child.type !== paragraph) {
|
|
46
|
+
allChildrenAreParagraphs = false;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
if (allChildrenAreParagraphs && node.childCount > 0) {
|
|
50
|
+
// Convert each paragraph to a taskItem
|
|
51
|
+
node.content.forEach(paragraphNode => {
|
|
52
|
+
const newTaskItem = taskItem.create({
|
|
53
|
+
localId: uuid.generate(),
|
|
54
|
+
state: node.attrs.state || 'TODO'
|
|
55
|
+
}, paragraphNode.content);
|
|
56
|
+
transformedContent.push(newTaskItem);
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
// Keep the blockTaskItem as is if it doesn't only contain paragraphs
|
|
60
|
+
transformedContent.push(node);
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
// Keep other nodes as is
|
|
64
|
+
transformedContent.push(node);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Create new slice with transformed content
|
|
69
|
+
if (transformedContent.length !== slice.content.childCount || transformedContent.some((node, idx) => node !== slice.content.child(idx))) {
|
|
70
|
+
const newFragment = Fragment.from(transformedContent);
|
|
71
|
+
return new Slice(newFragment, slice.openStart, slice.openEnd);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return slice;
|
|
75
|
+
};
|
|
@@ -18,6 +18,7 @@ import { focusCheckbox, focusCheckboxAndUpdateSelection, getTaskItemDataAtPos, g
|
|
|
18
18
|
import { stateKey } from './plugin-key';
|
|
19
19
|
import { taskItemOnChange } from './taskItemOnChange';
|
|
20
20
|
import { ACTIONS } from './types';
|
|
21
|
+
import { tempTransformSliceToRemoveBlockTaskItem } from './utils/paste';
|
|
21
22
|
function nodesBetweenChanged(tr, f, startPos) {
|
|
22
23
|
var stepRange = getStepRange(tr);
|
|
23
24
|
if (!stepRange) {
|
|
@@ -169,6 +170,12 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
|
|
|
169
170
|
return false;
|
|
170
171
|
}
|
|
171
172
|
}
|
|
173
|
+
},
|
|
174
|
+
transformPasted: function transformPasted(slice, view) {
|
|
175
|
+
if (expValEquals('platform_editor_blocktaskitem_node', 'isEnabled', true)) {
|
|
176
|
+
slice = tempTransformSliceToRemoveBlockTaskItem(slice, view);
|
|
177
|
+
}
|
|
178
|
+
return slice;
|
|
172
179
|
}
|
|
173
180
|
},
|
|
174
181
|
state: {
|
|
@@ -247,7 +254,7 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
|
|
|
247
254
|
/*
|
|
248
255
|
* After each transaction, we search through the document for any decisionList/Item & taskList/Item nodes
|
|
249
256
|
* that do not have the localId attribute set and generate a random UUID to use. This is to replace a previous
|
|
250
|
-
* Prosemirror
|
|
257
|
+
* Prosemirror capability where node attributes could be generated dynamically.
|
|
251
258
|
* See https://discuss.prosemirror.net/t/release-0-23-0-possibly-to-be-1-0-0/959/17 for a discussion of this approach.
|
|
252
259
|
*
|
|
253
260
|
* Note: we currently do not handle the edge case where two nodes may have the same localId
|
|
@@ -266,8 +273,9 @@ export function createPlugin(portalProviderAPI, eventDispatcher, dispatch, api,
|
|
|
266
273
|
decisionList = _newState$schema$node.decisionList,
|
|
267
274
|
decisionItem = _newState$schema$node.decisionItem,
|
|
268
275
|
taskList = _newState$schema$node.taskList,
|
|
269
|
-
taskItem = _newState$schema$node.taskItem
|
|
270
|
-
|
|
276
|
+
taskItem = _newState$schema$node.taskItem,
|
|
277
|
+
blockTaskItem = _newState$schema$node.blockTaskItem;
|
|
278
|
+
if (!!node.type && (node.type === decisionList || node.type === decisionItem || node.type === taskList || node.type === taskItem || blockTaskItem && node.type === blockTaskItem)) {
|
|
271
279
|
var _node$attrs = node.attrs,
|
|
272
280
|
localId = _node$attrs.localId,
|
|
273
281
|
rest = _objectWithoutProperties(_node$attrs, _excluded);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { uuid } from '@atlaskit/adf-schema';
|
|
2
|
+
import { Slice, Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
/**
|
|
4
|
+
* Transforms a paste slice to handle blockTaskItem nodes when pasting into task items.
|
|
5
|
+
*
|
|
6
|
+
* Initially we do not support user creation of blockTaskItem - it is intended primarily
|
|
7
|
+
* for TinyMCE migration purposes however that may change in the future.
|
|
8
|
+
* This function handles the behavior to work around Prosemirror behaviour which decides
|
|
9
|
+
* that blockTaskItem is the appropriate node to use here.
|
|
10
|
+
*
|
|
11
|
+
* @param slice - The slice being pasted
|
|
12
|
+
* @param view - The editor view where the paste is occurring
|
|
13
|
+
* @returns The transformed slice with blockTaskItems converted to taskItems when appropriate
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const transformedSlice = tempTransformSliceToRemoveBlockTaskItem(pasteSlice, editorView);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @see {@link https://hello.atlassian.net/wiki/spaces/EDITOR/pages/5626622054/Block+elements+in+task+-+Decision+log#Can-users-create-block-task-items%3F} for reasoning
|
|
21
|
+
*/
|
|
22
|
+
export var tempTransformSliceToRemoveBlockTaskItem = function tempTransformSliceToRemoveBlockTaskItem(slice, view) {
|
|
23
|
+
var schema = view.state.schema;
|
|
24
|
+
var _schema$nodes = schema.nodes,
|
|
25
|
+
taskItem = _schema$nodes.taskItem,
|
|
26
|
+
blockTaskItem = _schema$nodes.blockTaskItem,
|
|
27
|
+
paragraph = _schema$nodes.paragraph;
|
|
28
|
+
|
|
29
|
+
// Check if we're pasting into a taskItem
|
|
30
|
+
var $from = view.state.selection.$from;
|
|
31
|
+
var isInTaskItem = $from.node().type === taskItem;
|
|
32
|
+
if (isInTaskItem && blockTaskItem) {
|
|
33
|
+
// Transform the slice to replace blockTaskItems with taskItems
|
|
34
|
+
var transformedContent = [];
|
|
35
|
+
slice.content.forEach(function (node) {
|
|
36
|
+
if (node.type === blockTaskItem) {
|
|
37
|
+
// Check if blockTaskItem only contains paragraphs
|
|
38
|
+
var allChildrenAreParagraphs = true;
|
|
39
|
+
node.content.forEach(function (child) {
|
|
40
|
+
if (child.type !== paragraph) {
|
|
41
|
+
allChildrenAreParagraphs = false;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (allChildrenAreParagraphs && node.childCount > 0) {
|
|
45
|
+
// Convert each paragraph to a taskItem
|
|
46
|
+
node.content.forEach(function (paragraphNode) {
|
|
47
|
+
var newTaskItem = taskItem.create({
|
|
48
|
+
localId: uuid.generate(),
|
|
49
|
+
state: node.attrs.state || 'TODO'
|
|
50
|
+
}, paragraphNode.content);
|
|
51
|
+
transformedContent.push(newTaskItem);
|
|
52
|
+
});
|
|
53
|
+
} else {
|
|
54
|
+
// Keep the blockTaskItem as is if it doesn't only contain paragraphs
|
|
55
|
+
transformedContent.push(node);
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
// Keep other nodes as is
|
|
59
|
+
transformedContent.push(node);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Create new slice with transformed content
|
|
64
|
+
if (transformedContent.length !== slice.content.childCount || transformedContent.some(function (node, idx) {
|
|
65
|
+
return node !== slice.content.child(idx);
|
|
66
|
+
})) {
|
|
67
|
+
var newFragment = Fragment.from(transformedContent);
|
|
68
|
+
return new Slice(newFragment, slice.openStart, slice.openEnd);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return slice;
|
|
72
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
/**
|
|
4
|
+
* Transforms a paste slice to handle blockTaskItem nodes when pasting into task items.
|
|
5
|
+
*
|
|
6
|
+
* Initially we do not support user creation of blockTaskItem - it is intended primarily
|
|
7
|
+
* for TinyMCE migration purposes however that may change in the future.
|
|
8
|
+
* This function handles the behavior to work around Prosemirror behaviour which decides
|
|
9
|
+
* that blockTaskItem is the appropriate node to use here.
|
|
10
|
+
*
|
|
11
|
+
* @param slice - The slice being pasted
|
|
12
|
+
* @param view - The editor view where the paste is occurring
|
|
13
|
+
* @returns The transformed slice with blockTaskItems converted to taskItems when appropriate
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const transformedSlice = tempTransformSliceToRemoveBlockTaskItem(pasteSlice, editorView);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @see {@link https://hello.atlassian.net/wiki/spaces/EDITOR/pages/5626622054/Block+elements+in+task+-+Decision+log#Can-users-create-block-task-items%3F} for reasoning
|
|
21
|
+
*/
|
|
22
|
+
export declare const tempTransformSliceToRemoveBlockTaskItem: (slice: Slice, view: EditorView) => Slice;
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* @jsxFrag jsx
|
|
4
4
|
* @jsx jsx
|
|
5
5
|
*/
|
|
6
|
-
/// <reference types="react" />
|
|
7
6
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
8
7
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
9
8
|
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
/**
|
|
4
|
+
* Transforms a paste slice to handle blockTaskItem nodes when pasting into task items.
|
|
5
|
+
*
|
|
6
|
+
* Initially we do not support user creation of blockTaskItem - it is intended primarily
|
|
7
|
+
* for TinyMCE migration purposes however that may change in the future.
|
|
8
|
+
* This function handles the behavior to work around Prosemirror behaviour which decides
|
|
9
|
+
* that blockTaskItem is the appropriate node to use here.
|
|
10
|
+
*
|
|
11
|
+
* @param slice - The slice being pasted
|
|
12
|
+
* @param view - The editor view where the paste is occurring
|
|
13
|
+
* @returns The transformed slice with blockTaskItems converted to taskItems when appropriate
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const transformedSlice = tempTransformSliceToRemoveBlockTaskItem(pasteSlice, editorView);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @see {@link https://hello.atlassian.net/wiki/spaces/EDITOR/pages/5626622054/Block+elements+in+task+-+Decision+log#Can-users-create-block-task-items%3F} for reasoning
|
|
21
|
+
*/
|
|
22
|
+
export declare const tempTransformSliceToRemoveBlockTaskItem: (slice: Slice, view: EditorView) => Slice;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-tasks-and-decisions",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.2",
|
|
4
4
|
"description": "Tasks and decisions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -43,20 +43,20 @@
|
|
|
43
43
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
44
44
|
"@atlaskit/editor-shared-styles": "^3.6.0",
|
|
45
45
|
"@atlaskit/heading": "^5.2.0",
|
|
46
|
-
"@atlaskit/icon": "^27.
|
|
46
|
+
"@atlaskit/icon": "^27.12.0",
|
|
47
47
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
48
48
|
"@atlaskit/popup": "^4.3.0",
|
|
49
49
|
"@atlaskit/primitives": "^14.11.0",
|
|
50
50
|
"@atlaskit/prosemirror-input-rules": "^3.4.0",
|
|
51
51
|
"@atlaskit/task-decision": "^19.2.0",
|
|
52
|
-
"@atlaskit/tmp-editor-statsig": "^9.
|
|
52
|
+
"@atlaskit/tmp-editor-statsig": "^9.27.0",
|
|
53
53
|
"@atlaskit/tokens": "^6.0.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
55
55
|
"@compiled/react": "^0.18.3",
|
|
56
56
|
"bind-event-listener": "^3.0.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@atlaskit/editor-common": "^107.
|
|
59
|
+
"@atlaskit/editor-common": "^107.23.0",
|
|
60
60
|
"react": "^18.2.0",
|
|
61
61
|
"react-dom": "^18.2.0",
|
|
62
62
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@af/integration-testing": "workspace:^",
|
|
66
66
|
"@af/visual-regression": "workspace:^",
|
|
67
67
|
"@atlaskit/ssr": "workspace:^",
|
|
68
|
-
"@atlaskit/util-data-test": "^18.
|
|
68
|
+
"@atlaskit/util-data-test": "^18.1.0",
|
|
69
69
|
"@atlaskit/visual-regression": "workspace:^",
|
|
70
70
|
"@testing-library/react": "^13.4.0",
|
|
71
71
|
"wait-for-expect": "^1.2.0"
|