@atlaskit/editor-plugin-block-menu 6.0.6 → 6.0.7

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,13 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 6.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`65223704a60e0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/65223704a60e0) -
8
+ Fix hard breaks being lost in nested task lists during transformation
9
+ - Updated dependencies
10
+
3
11
  ## 6.0.6
4
12
 
5
13
  ### Patch Changes
@@ -73,11 +73,7 @@ var decisionListToListStep = exports.decisionListToListStep = function decisionL
73
73
  }
74
74
  var newItems = [];
75
75
  node.forEach(function (decisionItem) {
76
- var itemContent = [];
77
- decisionItem.forEach(function (child) {
78
- itemContent.push(child);
79
- });
80
- var newItem = targetItemType === schema.nodes.listItem ? targetItemType.create({}, paragraphType.create({}, itemContent)) : targetItemType.create({}, itemContent);
76
+ var newItem = targetItemType.inlineContent ? targetItemType.create({}, decisionItem.children) : targetItemType.create({}, paragraphType.create({}, decisionItem.children));
81
77
  if (newItem) {
82
78
  newItems.push(newItem);
83
79
  }
@@ -24,7 +24,7 @@ var extractNestedLists = function extractNestedLists(node, schema) {
24
24
  child.forEach(function (grandChild) {
25
25
  if ((0, _nodeChecks.isListWithIndentation)(grandChild.type.name, schema)) {
26
26
  nestedLists.push(grandChild);
27
- } else if (grandChild.isText) {
27
+ } else if (grandChild.isInline) {
28
28
  // For taskItem/decisionItem, keep text as-is (they support inline content)
29
29
  // For listItem, wrap text in paragraph (they require block content)
30
30
  if (isInlineItem) {
@@ -75,8 +75,6 @@ var extractNestedLists = function extractNestedLists(node, schema) {
75
75
  * @param nodes
76
76
  * @param context
77
77
  * @returns
78
- *
79
- * TODO: Lists with mixed types (e.g. bulletList with a taskItem) doesn't full flatten
80
78
  */
81
79
  var flattenListStep = exports.flattenListStep = function flattenListStep(nodes, context) {
82
80
  return nodes.map(function (node) {
@@ -45,7 +45,7 @@ var listToDecisionListStep = exports.listToDecisionListStep = function listToDec
45
45
  if (child.type === paragraphType) {
46
46
  // paragraph may contain hard breaks etc.
47
47
  itemContent.push.apply(itemContent, (0, _toConsumableArray2.default)(child.children));
48
- } else if (child.isText || child.isInline) {
48
+ } else if (child.isInline) {
49
49
  itemContent.push(child);
50
50
  } else if (!(0, _nodeChecks.isListWithIndentation)(child.type.name, schema)) {
51
51
  unsupportedContent.push(child);
@@ -76,7 +76,7 @@ var _transformList = function transformList(node, targetListType, targetItemType
76
76
  itemNode.forEach(function (child) {
77
77
  if (child.type === paragraphType) {
78
78
  inlineContent.push.apply(inlineContent, (0, _toConsumableArray2.default)(child.children));
79
- } else if (child.isText) {
79
+ } else if (child.isInline) {
80
80
  inlineContent.push(child);
81
81
  // Nested lists will be extracted and placed as siblings in the taskList
82
82
  } else if (!(0, _nodeChecks.isListWithIndentation)(child.type.name, schema)) {
@@ -70,11 +70,7 @@ export const decisionListToListStep = (nodes, context) => {
70
70
  }
71
71
  const newItems = [];
72
72
  node.forEach(decisionItem => {
73
- const itemContent = [];
74
- decisionItem.forEach(child => {
75
- itemContent.push(child);
76
- });
77
- const newItem = targetItemType === schema.nodes.listItem ? targetItemType.create({}, paragraphType.create({}, itemContent)) : targetItemType.create({}, itemContent);
73
+ const newItem = targetItemType.inlineContent ? targetItemType.create({}, decisionItem.children) : targetItemType.create({}, paragraphType.create({}, decisionItem.children));
78
74
  if (newItem) {
79
75
  newItems.push(newItem);
80
76
  }
@@ -16,7 +16,7 @@ const extractNestedLists = (node, schema) => {
16
16
  child.forEach(grandChild => {
17
17
  if (isListWithIndentation(grandChild.type.name, schema)) {
18
18
  nestedLists.push(grandChild);
19
- } else if (grandChild.isText) {
19
+ } else if (grandChild.isInline) {
20
20
  // For taskItem/decisionItem, keep text as-is (they support inline content)
21
21
  // For listItem, wrap text in paragraph (they require block content)
22
22
  if (isInlineItem) {
@@ -67,8 +67,6 @@ const extractNestedLists = (node, schema) => {
67
67
  * @param nodes
68
68
  * @param context
69
69
  * @returns
70
- *
71
- * TODO: Lists with mixed types (e.g. bulletList with a taskItem) doesn't full flatten
72
70
  */
73
71
  export const flattenListStep = (nodes, context) => {
74
72
  return nodes.map(node => {
@@ -39,7 +39,7 @@ export const listToDecisionListStep = (nodes, context) => {
39
39
  if (child.type === paragraphType) {
40
40
  // paragraph may contain hard breaks etc.
41
41
  itemContent.push(...child.children);
42
- } else if (child.isText || child.isInline) {
42
+ } else if (child.isInline) {
43
43
  itemContent.push(child);
44
44
  } else if (!isListWithIndentation(child.type.name, schema)) {
45
45
  unsupportedContent.push(child);
@@ -67,7 +67,7 @@ const transformList = (node, targetListType, targetItemType, unsupportedContent)
67
67
  itemNode.forEach(child => {
68
68
  if (child.type === paragraphType) {
69
69
  inlineContent.push(...child.children);
70
- } else if (child.isText) {
70
+ } else if (child.isInline) {
71
71
  inlineContent.push(child);
72
72
  // Nested lists will be extracted and placed as siblings in the taskList
73
73
  } else if (!isListWithIndentation(child.type.name, schema)) {
@@ -67,11 +67,7 @@ export var decisionListToListStep = function decisionListToListStep(nodes, conte
67
67
  }
68
68
  var newItems = [];
69
69
  node.forEach(function (decisionItem) {
70
- var itemContent = [];
71
- decisionItem.forEach(function (child) {
72
- itemContent.push(child);
73
- });
74
- var newItem = targetItemType === schema.nodes.listItem ? targetItemType.create({}, paragraphType.create({}, itemContent)) : targetItemType.create({}, itemContent);
70
+ var newItem = targetItemType.inlineContent ? targetItemType.create({}, decisionItem.children) : targetItemType.create({}, paragraphType.create({}, decisionItem.children));
75
71
  if (newItem) {
76
72
  newItems.push(newItem);
77
73
  }
@@ -18,7 +18,7 @@ var extractNestedLists = function extractNestedLists(node, schema) {
18
18
  child.forEach(function (grandChild) {
19
19
  if (isListWithIndentation(grandChild.type.name, schema)) {
20
20
  nestedLists.push(grandChild);
21
- } else if (grandChild.isText) {
21
+ } else if (grandChild.isInline) {
22
22
  // For taskItem/decisionItem, keep text as-is (they support inline content)
23
23
  // For listItem, wrap text in paragraph (they require block content)
24
24
  if (isInlineItem) {
@@ -69,8 +69,6 @@ var extractNestedLists = function extractNestedLists(node, schema) {
69
69
  * @param nodes
70
70
  * @param context
71
71
  * @returns
72
- *
73
- * TODO: Lists with mixed types (e.g. bulletList with a taskItem) doesn't full flatten
74
72
  */
75
73
  export var flattenListStep = function flattenListStep(nodes, context) {
76
74
  return nodes.map(function (node) {
@@ -38,7 +38,7 @@ export var listToDecisionListStep = function listToDecisionListStep(nodes, conte
38
38
  if (child.type === paragraphType) {
39
39
  // paragraph may contain hard breaks etc.
40
40
  itemContent.push.apply(itemContent, _toConsumableArray(child.children));
41
- } else if (child.isText || child.isInline) {
41
+ } else if (child.isInline) {
42
42
  itemContent.push(child);
43
43
  } else if (!isListWithIndentation(child.type.name, schema)) {
44
44
  unsupportedContent.push(child);
@@ -69,7 +69,7 @@ var _transformList = function transformList(node, targetListType, targetItemType
69
69
  itemNode.forEach(function (child) {
70
70
  if (child.type === paragraphType) {
71
71
  inlineContent.push.apply(inlineContent, _toConsumableArray(child.children));
72
- } else if (child.isText) {
72
+ } else if (child.isInline) {
73
73
  inlineContent.push(child);
74
74
  // Nested lists will be extracted and placed as siblings in the taskList
75
75
  } else if (!isListWithIndentation(child.type.name, schema)) {
@@ -25,7 +25,5 @@ import type { TransformStep } from '../types';
25
25
  * @param nodes
26
26
  * @param context
27
27
  * @returns
28
- *
29
- * TODO: Lists with mixed types (e.g. bulletList with a taskItem) doesn't full flatten
30
28
  */
31
29
  export declare const flattenListStep: TransformStep;
@@ -25,7 +25,5 @@ import type { TransformStep } from '../types';
25
25
  * @param nodes
26
26
  * @param context
27
27
  * @returns
28
- *
29
- * TODO: Lists with mixed types (e.g. bulletList with a taskItem) doesn't full flatten
30
28
  */
31
29
  export declare const flattenListStep: TransformStep;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "6.0.6",
3
+ "version": "6.0.7",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",