@atlaskit/editor-plugin-block-menu 5.2.19 → 5.2.20

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
+ ## 5.2.20
4
+
5
+ ### Patch Changes
6
+
7
+ - [`65f1df43f39d7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/65f1df43f39d7) -
8
+ Add heading transform
9
+ - Updated dependencies
10
+
3
11
  ## 5.2.19
4
12
 
5
13
  ### Patch Changes
@@ -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) {
48
+ } else if (child.isText || child.isInline) {
49
49
  itemContent.push(child);
50
50
  } else if (!(0, _nodeChecks.isListWithIndentation)(child.type.name, schema)) {
51
51
  unsupportedContent.push(child);
@@ -8,6 +8,7 @@ exports.wrapMixedContentStep = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _model = require("@atlaskit/editor-prosemirror/model");
10
10
  var _types = require("../types");
11
+ var _utils = require("../utils");
11
12
  /**
12
13
  * Determines if a node is a text node (heading or paragraph).
13
14
  * Text nodes can have their content converted to paragraphs when they can't be wrapped directly.
@@ -17,21 +18,6 @@ var isTextNode = function isTextNode(node) {
17
18
  return category === 'text';
18
19
  };
19
20
 
20
- /**
21
- * Converts a text node (heading, paragraph) to a paragraph preserving its inline content.
22
- * This is used when a text node can't be wrapped directly in the target container
23
- * (e.g., heading can't go in blockquote, so it becomes a paragraph).
24
- */
25
- var convertTextNodeToParagraph = function convertTextNodeToParagraph(node, schema) {
26
- var _schema$nodes$paragra;
27
- // If it's already a paragraph, return as-is
28
- if (node.type.name === 'paragraph') {
29
- return node;
30
- }
31
- // Convert heading (or other text node) to paragraph with same inline content
32
- return (_schema$nodes$paragra = schema.nodes.paragraph.createAndFill({}, node.content)) !== null && _schema$nodes$paragra !== void 0 ? _schema$nodes$paragra : null;
33
- };
34
-
35
21
  /**
36
22
  * Determines if a node can be wrapped in the target container type.
37
23
  * Uses the schema's validContent to check if the target container can hold this node.
@@ -134,7 +120,7 @@ var wrapMixedContentStep = exports.wrapMixedContentStep = function wrapMixedCont
134
120
  } else if (isTextNode(node)) {
135
121
  // Text node (heading, paragraph) that can't be wrapped - convert to paragraph
136
122
  // Example: heading can't go in blockquote, so convert to paragraph with same content
137
- var paragraph = convertTextNodeToParagraph(node, schema);
123
+ var paragraph = (0, _utils.convertTextNodeToParagraph)(node, schema);
138
124
  if (paragraph) {
139
125
  currentContainerContent.push(paragraph);
140
126
  }
@@ -45,7 +45,7 @@ var TRANSFORM_STEPS = {
45
45
  },
46
46
  text: {
47
47
  atomic: undefined,
48
- container: [_wrapStep.wrapStep],
48
+ container: [_wrapMixedContentStep.wrapMixedContentStep],
49
49
  list: [_wrapIntoListStep.wrapIntoListStep],
50
50
  text: [_flattenStep.flattenStep, _applyTargetTextTypeStep.applyTargetTextTypeStep]
51
51
  }
@@ -58,6 +58,10 @@ var TRANSFORM_STEPS_OVERRIDE = {
58
58
  codeBlock: [_wrapTextToCodeblock.wrapTextToCodeblockStep],
59
59
  layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
60
60
  },
61
+ heading: {
62
+ codeBlock: [_wrapTextToCodeblock.wrapTextToCodeblockStep],
63
+ layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
64
+ },
61
65
  panel: {
62
66
  layoutSection: [_unwrapStep.unwrapStep, _wrapIntoLayoutStep.wrapIntoLayoutStep],
63
67
  codeBlock: [_unwrapStep.unwrapStep, _flattenStep.flattenStep, _wrapStep.wrapStep],
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.getBlockNodesInRange = exports.createTextContent = exports.convertNestedExpandToExpand = exports.convertExpandToNestedExpand = void 0;
6
+ exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.getBlockNodesInRange = exports.createTextContent = exports.convertTextNodeToParagraph = exports.convertNestedExpandToExpand = exports.convertExpandToNestedExpand = void 0;
7
7
  var _state = require("@atlaskit/editor-prosemirror/state");
8
8
  var _utils = require("@atlaskit/editor-prosemirror/utils");
9
9
  var _editorTables = require("@atlaskit/editor-tables");
@@ -87,6 +87,21 @@ var convertExpandToNestedExpand = exports.convertExpandToNestedExpand = function
87
87
  title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || ''
88
88
  }, node.content);
89
89
  };
90
+
91
+ /**
92
+ * Converts a text node (heading, paragraph) to a paragraph preserving its inline content.
93
+ * This is used when a text node can't be wrapped directly in the target container
94
+ * (e.g., heading can't go in blockquote, so it becomes a paragraph).
95
+ */
96
+ var convertTextNodeToParagraph = exports.convertTextNodeToParagraph = function convertTextNodeToParagraph(node, schema) {
97
+ var _schema$nodes$paragra;
98
+ // If it's already a paragraph, return as-is
99
+ if (node.type.name === 'paragraph') {
100
+ return node;
101
+ }
102
+ // Convert heading (or other text node) to paragraph with same inline content
103
+ return (_schema$nodes$paragra = schema.nodes.paragraph.createAndFill({}, node.content)) !== null && _schema$nodes$paragra !== void 0 ? _schema$nodes$paragra : null;
104
+ };
90
105
  var getBlockNodesInRange = exports.getBlockNodesInRange = function getBlockNodesInRange(range) {
91
106
  if (range.startIndex === range.endIndex) {
92
107
  return [];
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.wrapIntoListStep = void 0;
7
7
  var _nodeChecks = require("./nodeChecks");
8
+ var _utils = require("./utils");
8
9
  var wrapIntoTaskOrDecisionList = function wrapIntoTaskOrDecisionList(nodes, targetNodeTypeName, schema) {
9
10
  var itemNodeType = targetNodeTypeName === 'taskList' ? schema.nodes.taskItem : schema.nodes.decisionItem;
10
11
  var inlineContent = nodes.flatMap(function (node) {
@@ -20,8 +21,15 @@ var wrapIntoTaskOrDecisionList = function wrapIntoTaskOrDecisionList(nodes, targ
20
21
  return outputNode ? [outputNode] : nodes;
21
22
  };
22
23
  var wrapIntoBulletOrOrderedList = function wrapIntoBulletOrOrderedList(nodes, targetNodeTypeName, schema) {
23
- var listItemNode = schema.nodes.listItem.createAndFill({}, nodes);
24
- var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, listItemNode);
24
+ var listItemNodes = nodes.map(function (node) {
25
+ return schema.nodes.listItem.createAndFill({}, node.isTextblock ? (0, _utils.convertTextNodeToParagraph)(node, schema) : node);
26
+ }).filter(function (node) {
27
+ return node !== null;
28
+ });
29
+ if (listItemNodes.length === 0) {
30
+ return nodes;
31
+ }
32
+ var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, listItemNodes);
25
33
  return outputNode ? [outputNode] : nodes;
26
34
  };
27
35
 
@@ -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) {
42
+ } else if (child.isText || child.isInline) {
43
43
  itemContent.push(child);
44
44
  } else if (!isListWithIndentation(child.type.name, schema)) {
45
45
  unsupportedContent.push(child);
@@ -1,5 +1,6 @@
1
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
2
  import { NODE_CATEGORY_BY_TYPE } from '../types';
3
+ import { convertTextNodeToParagraph } from '../utils';
3
4
 
4
5
  /**
5
6
  * Determines if a node is a text node (heading or paragraph).
@@ -10,21 +11,6 @@ const isTextNode = node => {
10
11
  return category === 'text';
11
12
  };
12
13
 
13
- /**
14
- * Converts a text node (heading, paragraph) to a paragraph preserving its inline content.
15
- * This is used when a text node can't be wrapped directly in the target container
16
- * (e.g., heading can't go in blockquote, so it becomes a paragraph).
17
- */
18
- const convertTextNodeToParagraph = (node, schema) => {
19
- var _schema$nodes$paragra;
20
- // If it's already a paragraph, return as-is
21
- if (node.type.name === 'paragraph') {
22
- return node;
23
- }
24
- // Convert heading (or other text node) to paragraph with same inline content
25
- return (_schema$nodes$paragra = schema.nodes.paragraph.createAndFill({}, node.content)) !== null && _schema$nodes$paragra !== void 0 ? _schema$nodes$paragra : null;
26
- };
27
-
28
14
  /**
29
15
  * Determines if a node can be wrapped in the target container type.
30
16
  * Uses the schema's validContent to check if the target container can hold this node.
@@ -40,7 +40,7 @@ const TRANSFORM_STEPS = {
40
40
  },
41
41
  text: {
42
42
  atomic: undefined,
43
- container: [wrapStep],
43
+ container: [wrapMixedContentStep],
44
44
  list: [wrapIntoListStep],
45
45
  text: [flattenStep, applyTargetTextTypeStep]
46
46
  }
@@ -53,6 +53,10 @@ const TRANSFORM_STEPS_OVERRIDE = {
53
53
  codeBlock: [wrapTextToCodeblockStep],
54
54
  layoutSection: [wrapIntoLayoutStep]
55
55
  },
56
+ heading: {
57
+ codeBlock: [wrapTextToCodeblockStep],
58
+ layoutSection: [wrapIntoLayoutStep]
59
+ },
56
60
  panel: {
57
61
  layoutSection: [unwrapStep, wrapIntoLayoutStep],
58
62
  codeBlock: [unwrapStep, flattenStep, wrapStep],
@@ -82,6 +82,21 @@ export const convertExpandToNestedExpand = (node, schema) => {
82
82
  title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || ''
83
83
  }, node.content);
84
84
  };
85
+
86
+ /**
87
+ * Converts a text node (heading, paragraph) to a paragraph preserving its inline content.
88
+ * This is used when a text node can't be wrapped directly in the target container
89
+ * (e.g., heading can't go in blockquote, so it becomes a paragraph).
90
+ */
91
+ export const convertTextNodeToParagraph = (node, schema) => {
92
+ var _schema$nodes$paragra;
93
+ // If it's already a paragraph, return as-is
94
+ if (node.type.name === 'paragraph') {
95
+ return node;
96
+ }
97
+ // Convert heading (or other text node) to paragraph with same inline content
98
+ return (_schema$nodes$paragra = schema.nodes.paragraph.createAndFill({}, node.content)) !== null && _schema$nodes$paragra !== void 0 ? _schema$nodes$paragra : null;
99
+ };
85
100
  export const getBlockNodesInRange = range => {
86
101
  if (range.startIndex === range.endIndex) {
87
102
  return [];
@@ -1,4 +1,5 @@
1
1
  import { isListWithTextContentOnly } from './nodeChecks';
2
+ import { convertTextNodeToParagraph } from './utils';
2
3
  const wrapIntoTaskOrDecisionList = (nodes, targetNodeTypeName, schema) => {
3
4
  const itemNodeType = targetNodeTypeName === 'taskList' ? schema.nodes.taskItem : schema.nodes.decisionItem;
4
5
  const inlineContent = nodes.flatMap(node => {
@@ -14,8 +15,11 @@ const wrapIntoTaskOrDecisionList = (nodes, targetNodeTypeName, schema) => {
14
15
  return outputNode ? [outputNode] : nodes;
15
16
  };
16
17
  const wrapIntoBulletOrOrderedList = (nodes, targetNodeTypeName, schema) => {
17
- const listItemNode = schema.nodes.listItem.createAndFill({}, nodes);
18
- const outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, listItemNode);
18
+ const listItemNodes = nodes.map(node => schema.nodes.listItem.createAndFill({}, node.isTextblock ? convertTextNodeToParagraph(node, schema) : node)).filter(node => node !== null);
19
+ if (listItemNodes.length === 0) {
20
+ return nodes;
21
+ }
22
+ const outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, listItemNodes);
19
23
  return outputNode ? [outputNode] : nodes;
20
24
  };
21
25
 
@@ -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) {
41
+ } else if (child.isText || child.isInline) {
42
42
  itemContent.push(child);
43
43
  } else if (!isListWithIndentation(child.type.name, schema)) {
44
44
  unsupportedContent.push(child);
@@ -1,6 +1,7 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
3
  import { NODE_CATEGORY_BY_TYPE } from '../types';
4
+ import { convertTextNodeToParagraph } from '../utils';
4
5
 
5
6
  /**
6
7
  * Determines if a node is a text node (heading or paragraph).
@@ -11,21 +12,6 @@ var isTextNode = function isTextNode(node) {
11
12
  return category === 'text';
12
13
  };
13
14
 
14
- /**
15
- * Converts a text node (heading, paragraph) to a paragraph preserving its inline content.
16
- * This is used when a text node can't be wrapped directly in the target container
17
- * (e.g., heading can't go in blockquote, so it becomes a paragraph).
18
- */
19
- var convertTextNodeToParagraph = function convertTextNodeToParagraph(node, schema) {
20
- var _schema$nodes$paragra;
21
- // If it's already a paragraph, return as-is
22
- if (node.type.name === 'paragraph') {
23
- return node;
24
- }
25
- // Convert heading (or other text node) to paragraph with same inline content
26
- return (_schema$nodes$paragra = schema.nodes.paragraph.createAndFill({}, node.content)) !== null && _schema$nodes$paragra !== void 0 ? _schema$nodes$paragra : null;
27
- };
28
-
29
15
  /**
30
16
  * Determines if a node can be wrapped in the target container type.
31
17
  * Uses the schema's validContent to check if the target container can hold this node.
@@ -40,7 +40,7 @@ var TRANSFORM_STEPS = {
40
40
  },
41
41
  text: {
42
42
  atomic: undefined,
43
- container: [wrapStep],
43
+ container: [wrapMixedContentStep],
44
44
  list: [wrapIntoListStep],
45
45
  text: [flattenStep, applyTargetTextTypeStep]
46
46
  }
@@ -53,6 +53,10 @@ var TRANSFORM_STEPS_OVERRIDE = {
53
53
  codeBlock: [wrapTextToCodeblockStep],
54
54
  layoutSection: [wrapIntoLayoutStep]
55
55
  },
56
+ heading: {
57
+ codeBlock: [wrapTextToCodeblockStep],
58
+ layoutSection: [wrapIntoLayoutStep]
59
+ },
56
60
  panel: {
57
61
  layoutSection: [unwrapStep, wrapIntoLayoutStep],
58
62
  codeBlock: [unwrapStep, flattenStep, wrapStep],
@@ -81,6 +81,21 @@ export var convertExpandToNestedExpand = function convertExpandToNestedExpand(no
81
81
  title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || ''
82
82
  }, node.content);
83
83
  };
84
+
85
+ /**
86
+ * Converts a text node (heading, paragraph) to a paragraph preserving its inline content.
87
+ * This is used when a text node can't be wrapped directly in the target container
88
+ * (e.g., heading can't go in blockquote, so it becomes a paragraph).
89
+ */
90
+ export var convertTextNodeToParagraph = function convertTextNodeToParagraph(node, schema) {
91
+ var _schema$nodes$paragra;
92
+ // If it's already a paragraph, return as-is
93
+ if (node.type.name === 'paragraph') {
94
+ return node;
95
+ }
96
+ // Convert heading (or other text node) to paragraph with same inline content
97
+ return (_schema$nodes$paragra = schema.nodes.paragraph.createAndFill({}, node.content)) !== null && _schema$nodes$paragra !== void 0 ? _schema$nodes$paragra : null;
98
+ };
84
99
  export var getBlockNodesInRange = function getBlockNodesInRange(range) {
85
100
  if (range.startIndex === range.endIndex) {
86
101
  return [];
@@ -1,4 +1,5 @@
1
1
  import { isListWithTextContentOnly } from './nodeChecks';
2
+ import { convertTextNodeToParagraph } from './utils';
2
3
  var wrapIntoTaskOrDecisionList = function wrapIntoTaskOrDecisionList(nodes, targetNodeTypeName, schema) {
3
4
  var itemNodeType = targetNodeTypeName === 'taskList' ? schema.nodes.taskItem : schema.nodes.decisionItem;
4
5
  var inlineContent = nodes.flatMap(function (node) {
@@ -14,8 +15,15 @@ var wrapIntoTaskOrDecisionList = function wrapIntoTaskOrDecisionList(nodes, targ
14
15
  return outputNode ? [outputNode] : nodes;
15
16
  };
16
17
  var wrapIntoBulletOrOrderedList = function wrapIntoBulletOrOrderedList(nodes, targetNodeTypeName, schema) {
17
- var listItemNode = schema.nodes.listItem.createAndFill({}, nodes);
18
- var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, listItemNode);
18
+ var listItemNodes = nodes.map(function (node) {
19
+ return schema.nodes.listItem.createAndFill({}, node.isTextblock ? convertTextNodeToParagraph(node, schema) : node);
20
+ }).filter(function (node) {
21
+ return node !== null;
22
+ });
23
+ if (listItemNodes.length === 0) {
24
+ return nodes;
25
+ }
26
+ var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, listItemNodes);
19
27
  return outputNode ? [outputNode] : nodes;
20
28
  };
21
29
 
@@ -16,6 +16,12 @@ export declare const convertNestedExpandToExpand: (node: PMNode, schema: Schema)
16
16
  * since expand cannot be a direct child of expand.
17
17
  */
18
18
  export declare const convertExpandToNestedExpand: (node: PMNode, schema: Schema) => PMNode | null;
19
+ /**
20
+ * Converts a text node (heading, paragraph) to a paragraph preserving its inline content.
21
+ * This is used when a text node can't be wrapped directly in the target container
22
+ * (e.g., heading can't go in blockquote, so it becomes a paragraph).
23
+ */
24
+ export declare const convertTextNodeToParagraph: (node: PMNode, schema: Schema) => PMNode | null;
19
25
  export declare const getBlockNodesInRange: (range: NodeRange) => PMNode[];
20
26
  /**
21
27
  * Iterates over a nodes children and extracting text content, removing all other inline content and converting
@@ -16,6 +16,12 @@ export declare const convertNestedExpandToExpand: (node: PMNode, schema: Schema)
16
16
  * since expand cannot be a direct child of expand.
17
17
  */
18
18
  export declare const convertExpandToNestedExpand: (node: PMNode, schema: Schema) => PMNode | null;
19
+ /**
20
+ * Converts a text node (heading, paragraph) to a paragraph preserving its inline content.
21
+ * This is used when a text node can't be wrapped directly in the target container
22
+ * (e.g., heading can't go in blockquote, so it becomes a paragraph).
23
+ */
24
+ export declare const convertTextNodeToParagraph: (node: PMNode, schema: Schema) => PMNode | null;
19
25
  export declare const getBlockNodesInRange: (range: NodeRange) => PMNode[];
20
26
  /**
21
27
  * Iterates over a nodes children and extracting text content, removing all other inline content and converting
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "5.2.19",
3
+ "version": "5.2.20",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  "@atlaskit/css": "^0.19.0",
32
32
  "@atlaskit/dropdown-menu": "^16.3.0",
33
33
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
34
- "@atlaskit/editor-plugin-block-controls": "^7.15.0",
34
+ "@atlaskit/editor-plugin-block-controls": "^7.17.0",
35
35
  "@atlaskit/editor-plugin-decorations": "^6.1.0",
36
36
  "@atlaskit/editor-plugin-selection": "^6.1.0",
37
37
  "@atlaskit/editor-plugin-user-intent": "^4.0.0",
@@ -49,7 +49,7 @@
49
49
  "@babel/runtime": "^7.0.0"
50
50
  },
51
51
  "peerDependencies": {
52
- "@atlaskit/editor-common": "^110.46.0",
52
+ "@atlaskit/editor-common": "^110.47.0",
53
53
  "react": "^18.2.0",
54
54
  "react-intl-next": "npm:react-intl@^5.18.1"
55
55
  },