@atlaskit/editor-plugin-block-menu 6.0.8 → 6.0.10

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.
Files changed (24) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.js +224 -0
  3. package/dist/cjs/editor-commands/transform-node-utils/steps/applyTargetTextTypeStep.js +4 -0
  4. package/dist/cjs/editor-commands/transform-node-utils/steps/convertEachNodeStep.js +58 -1
  5. package/dist/cjs/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +12 -1
  6. package/dist/cjs/editor-commands/transform-node-utils/transform.js +4 -236
  7. package/dist/cjs/editor-commands/transform-node-utils/utils.js +33 -11
  8. package/dist/es2019/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.js +219 -0
  9. package/dist/es2019/editor-commands/transform-node-utils/steps/applyTargetTextTypeStep.js +4 -0
  10. package/dist/es2019/editor-commands/transform-node-utils/steps/convertEachNodeStep.js +56 -1
  11. package/dist/es2019/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +13 -2
  12. package/dist/es2019/editor-commands/transform-node-utils/transform.js +5 -238
  13. package/dist/es2019/editor-commands/transform-node-utils/utils.js +32 -10
  14. package/dist/esm/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.js +219 -0
  15. package/dist/esm/editor-commands/transform-node-utils/steps/applyTargetTextTypeStep.js +4 -0
  16. package/dist/esm/editor-commands/transform-node-utils/steps/convertEachNodeStep.js +58 -1
  17. package/dist/esm/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +13 -2
  18. package/dist/esm/editor-commands/transform-node-utils/transform.js +5 -238
  19. package/dist/esm/editor-commands/transform-node-utils/utils.js +32 -10
  20. package/dist/types/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.d.ts +2 -0
  21. package/dist/types/editor-commands/transform-node-utils/utils.d.ts +10 -5
  22. package/dist/types-ts4.5/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.d.ts +2 -0
  23. package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +10 -5
  24. package/package.json +4 -4
@@ -126,20 +126,42 @@ export var getBlockNodesInRange = function getBlockNodesInRange(range) {
126
126
  };
127
127
 
128
128
  /**
129
- * Iterates over a nodes children and extracting text content, removing all other inline content and converting
130
- * hardbreaks to newlines.
129
+ * Splits a text node (paragraph/heading) into parts for codeBlock conversion.
130
+ * Returns an array of:
131
+ * - strings (text content that can go into codeBlock)
132
+ * - PMNodes (incompatible inline nodes wrapped in paragraphs that need to break out)
131
133
  *
132
- * @param node - The node to create text content from (should be paragraph)
133
- * @returns The text content string.
134
+ * This preserves inline nodes (like status, inlineExtension) that cannot be represented as plain text.
135
+ *
136
+ * @param node - The text node (paragraph or heading) to split
137
+ * @param schema - The schema to use for creating paragraph nodes
138
+ * @returns Array of strings (for codeBlock) and PMNodes (to break out)
134
139
  */
135
- export var createTextContent = function createTextContent(node) {
136
- var textContent = node.children.map(function (child) {
140
+ export var splitTextNodeForCodeBlock = function splitTextNodeForCodeBlock(node, schema) {
141
+ var result = [];
142
+ var currentText = '';
143
+ node.content.forEach(function (child) {
137
144
  if (child.isText) {
138
- return child.text;
145
+ currentText += child.text || '';
139
146
  } else if (child.type.name === 'hardBreak') {
140
- return '\n';
147
+ currentText += '\n';
148
+ } else {
149
+ // Incompatible inline node (status, inlineExtension, etc.)
150
+ // Flush accumulated text if any
151
+ if (currentText) {
152
+ result.push(currentText);
153
+ currentText = '';
154
+ }
155
+ // Wrap the inline node in a paragraph and add it to break out
156
+ var paragraph = schema.nodes.paragraph.create({}, child);
157
+ result.push(paragraph);
141
158
  }
142
- return '';
143
159
  });
144
- return textContent.join('');
160
+
161
+ // Don't forget remaining text (or empty string for empty nodes)
162
+ // Always push at least an empty string so empty paragraphs create empty codeBlocks
163
+ if (currentText || result.length === 0) {
164
+ result.push(currentText);
165
+ }
166
+ return result;
145
167
  };
@@ -0,0 +1,2 @@
1
+ import type { NodeTypeName, TransformStep } from './types';
2
+ export declare const TRANSFORMATION_MATRIX: Record<NodeTypeName, Partial<Record<NodeTypeName, TransformStep[]>>>;
@@ -29,10 +29,15 @@ export declare const convertExpandToNestedExpand: (node: PMNode, schema: Schema)
29
29
  export declare const convertTextNodeToParagraph: (node: PMNode, schema: Schema) => PMNode | null;
30
30
  export declare const getBlockNodesInRange: (range: NodeRange) => PMNode[];
31
31
  /**
32
- * Iterates over a nodes children and extracting text content, removing all other inline content and converting
33
- * hardbreaks to newlines.
32
+ * Splits a text node (paragraph/heading) into parts for codeBlock conversion.
33
+ * Returns an array of:
34
+ * - strings (text content that can go into codeBlock)
35
+ * - PMNodes (incompatible inline nodes wrapped in paragraphs that need to break out)
34
36
  *
35
- * @param node - The node to create text content from (should be paragraph)
36
- * @returns The text content string.
37
+ * This preserves inline nodes (like status, inlineExtension) that cannot be represented as plain text.
38
+ *
39
+ * @param node - The text node (paragraph or heading) to split
40
+ * @param schema - The schema to use for creating paragraph nodes
41
+ * @returns Array of strings (for codeBlock) and PMNodes (to break out)
37
42
  */
38
- export declare const createTextContent: (node: PMNode) => string;
43
+ export declare const splitTextNodeForCodeBlock: (node: PMNode, schema: Schema) => Array<string | PMNode>;
@@ -0,0 +1,2 @@
1
+ import type { NodeTypeName, TransformStep } from './types';
2
+ export declare const TRANSFORMATION_MATRIX: Record<NodeTypeName, Partial<Record<NodeTypeName, TransformStep[]>>>;
@@ -29,10 +29,15 @@ export declare const convertExpandToNestedExpand: (node: PMNode, schema: Schema)
29
29
  export declare const convertTextNodeToParagraph: (node: PMNode, schema: Schema) => PMNode | null;
30
30
  export declare const getBlockNodesInRange: (range: NodeRange) => PMNode[];
31
31
  /**
32
- * Iterates over a nodes children and extracting text content, removing all other inline content and converting
33
- * hardbreaks to newlines.
32
+ * Splits a text node (paragraph/heading) into parts for codeBlock conversion.
33
+ * Returns an array of:
34
+ * - strings (text content that can go into codeBlock)
35
+ * - PMNodes (incompatible inline nodes wrapped in paragraphs that need to break out)
34
36
  *
35
- * @param node - The node to create text content from (should be paragraph)
36
- * @returns The text content string.
37
+ * This preserves inline nodes (like status, inlineExtension) that cannot be represented as plain text.
38
+ *
39
+ * @param node - The text node (paragraph or heading) to split
40
+ * @param schema - The schema to use for creating paragraph nodes
41
+ * @returns Array of strings (for codeBlock) and PMNodes (to break out)
37
42
  */
38
- export declare const createTextContent: (node: PMNode) => string;
43
+ export declare const splitTextNodeForCodeBlock: (node: PMNode, schema: Schema) => Array<string | PMNode>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "6.0.8",
3
+ "version": "6.0.10",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -40,16 +40,16 @@
40
40
  "@atlaskit/editor-tables": "^2.9.0",
41
41
  "@atlaskit/editor-toolbar": "^0.18.0",
42
42
  "@atlaskit/flag": "^17.7.0",
43
- "@atlaskit/icon": "^29.3.0",
43
+ "@atlaskit/icon": "^29.4.0",
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
46
46
  "@atlaskit/primitives": "^17.0.0",
47
- "@atlaskit/tmp-editor-statsig": "^16.4.0",
47
+ "@atlaskit/tmp-editor-statsig": "^16.8.0",
48
48
  "@atlaskit/tokens": "^9.1.0",
49
49
  "@babel/runtime": "^7.0.0"
50
50
  },
51
51
  "peerDependencies": {
52
- "@atlaskit/editor-common": "^111.2.0",
52
+ "@atlaskit/editor-common": "^111.6.0",
53
53
  "react": "^18.2.0",
54
54
  "react-intl-next": "npm:react-intl@^5.18.1"
55
55
  },