@atlaskit/editor-plugin-tasks-and-decisions 6.2.0 → 6.2.1

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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlaskit/editor-plugin-tasks-and-decisions
2
2
 
3
+ ## 6.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#200663](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/200663)
8
+ [`0899e8f2578b2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0899e8f2578b2) -
9
+ [ux] EDITOR-1271 Modifies paste behaviour of editor-plugin-tasks-and-decisions to prevent
10
+ blockTaskItems being created when pasting block content into taskItems
11
+ - Updated dependencies
12
+
3
13
  ## 6.2.0
4
14
 
5
15
  ### 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: {
@@ -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: {
@@ -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: {
@@ -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;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  /**
3
2
  * @jsxRuntime classic
4
3
  * @jsxFrag jsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-tasks-and-decisions",
3
- "version": "6.2.0",
3
+ "version": "6.2.1",
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.10.0",
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.26.0",
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.20.0",
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.0.0",
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"