@atlaskit/editor-plugin-block-menu 6.0.5 → 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.
Files changed (37) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/editor-commands/transform-node-utils/steps/decisionListToListStep.js +1 -5
  3. package/dist/cjs/editor-commands/transform-node-utils/steps/flattenListStep.js +1 -3
  4. package/dist/cjs/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +1 -1
  5. package/dist/cjs/editor-commands/transform-node-utils/steps/listToListStep.js +1 -1
  6. package/dist/cjs/editor-commands/transform-node-utils/steps/wrapBlockquoteToDecisionListStep.js +2 -12
  7. package/dist/cjs/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +69 -52
  8. package/dist/cjs/editor-commands/transform-node-utils/transform.js +18 -21
  9. package/dist/cjs/editor-commands/transform-node-utils/utils.js +10 -1
  10. package/dist/es2019/editor-commands/transform-node-utils/steps/decisionListToListStep.js +1 -5
  11. package/dist/es2019/editor-commands/transform-node-utils/steps/flattenListStep.js +1 -3
  12. package/dist/es2019/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +1 -1
  13. package/dist/es2019/editor-commands/transform-node-utils/steps/listToListStep.js +1 -1
  14. package/dist/es2019/editor-commands/transform-node-utils/steps/wrapBlockquoteToDecisionListStep.js +1 -11
  15. package/dist/es2019/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +71 -53
  16. package/dist/es2019/editor-commands/transform-node-utils/transform.js +18 -21
  17. package/dist/es2019/editor-commands/transform-node-utils/utils.js +10 -0
  18. package/dist/esm/editor-commands/transform-node-utils/steps/decisionListToListStep.js +1 -5
  19. package/dist/esm/editor-commands/transform-node-utils/steps/flattenListStep.js +1 -3
  20. package/dist/esm/editor-commands/transform-node-utils/steps/listToDecisionListStep.js +1 -1
  21. package/dist/esm/editor-commands/transform-node-utils/steps/listToListStep.js +1 -1
  22. package/dist/esm/editor-commands/transform-node-utils/steps/wrapBlockquoteToDecisionListStep.js +1 -11
  23. package/dist/esm/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +70 -53
  24. package/dist/esm/editor-commands/transform-node-utils/transform.js +18 -21
  25. package/dist/esm/editor-commands/transform-node-utils/utils.js +10 -0
  26. package/dist/types/editor-commands/transform-node-utils/steps/flattenListStep.d.ts +0 -2
  27. package/dist/types/editor-commands/transform-node-utils/steps/wrapMixedContentStep.d.ts +17 -2
  28. package/dist/types/editor-commands/transform-node-utils/utils.d.ts +5 -0
  29. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/flattenListStep.d.ts +0 -2
  30. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/wrapMixedContentStep.d.ts +17 -2
  31. package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +5 -0
  32. package/package.json +3 -3
  33. package/dist/cjs/editor-commands/transform-node-utils/wrapIntoLayoutStep.js +0 -20
  34. package/dist/es2019/editor-commands/transform-node-utils/wrapIntoLayoutStep.js +0 -17
  35. package/dist/esm/editor-commands/transform-node-utils/wrapIntoLayoutStep.js +0 -14
  36. package/dist/types/editor-commands/transform-node-utils/wrapIntoLayoutStep.d.ts +0 -2
  37. package/dist/types-ts4.5/editor-commands/transform-node-utils/wrapIntoLayoutStep.d.ts +0 -2
@@ -15,7 +15,6 @@ import { wrapTextToCodeblockStep } from './steps/wrapTextToCodeblock';
15
15
  import { getNodeName, NODE_CATEGORY_BY_TYPE, toNodeTypeValue } from './types';
16
16
  import { unwrapExpandStep } from './unwrapExpandStep';
17
17
  import { unwrapStep } from './unwrapStep';
18
- import { wrapIntoLayoutStep } from './wrapIntoLayoutStep';
19
18
  import { wrapIntoListStep } from './wrapIntoListStep';
20
19
  import { wrapStep } from './wrapStep';
21
20
 
@@ -65,15 +64,15 @@ var TRANSFORM_STEPS_OVERRIDE = {
65
64
  paragraph: {
66
65
  paragraph: null,
67
66
  codeBlock: [wrapTextToCodeblockStep],
68
- layoutSection: [wrapIntoLayoutStep]
67
+ layoutSection: [wrapMixedContentStep]
69
68
  },
70
69
  heading: {
71
70
  codeBlock: [wrapTextToCodeblockStep],
72
- layoutSection: [wrapIntoLayoutStep]
71
+ layoutSection: [wrapMixedContentStep]
73
72
  },
74
73
  panel: {
75
74
  panel: null,
76
- layoutSection: [unwrapStep, wrapIntoLayoutStep],
75
+ layoutSection: [unwrapStep, wrapMixedContentStep],
77
76
  codeBlock: [unwrapStep, flattenStep, wrapStep],
78
77
  blockquote: [unwrapStep, wrapMixedContentStep],
79
78
  taskList: null,
@@ -85,7 +84,7 @@ var TRANSFORM_STEPS_OVERRIDE = {
85
84
  expand: null,
86
85
  panel: [unwrapExpandStep, wrapMixedContentStep],
87
86
  blockquote: [unwrapExpandStep, wrapMixedContentStep],
88
- layoutSection: [unwrapExpandStep, wrapIntoLayoutStep],
87
+ layoutSection: [unwrapExpandStep, wrapMixedContentStep],
89
88
  paragraph: [unwrapExpandStep],
90
89
  codeBlock: null,
91
90
  heading: null
@@ -103,7 +102,7 @@ var TRANSFORM_STEPS_OVERRIDE = {
103
102
  blockquote: null,
104
103
  expand: [wrapStep],
105
104
  nestedExpand: [wrapStep],
106
- layoutSection: [wrapIntoLayoutStep],
105
+ layoutSection: [wrapMixedContentStep],
107
106
  codeBlock: null,
108
107
  decisionList: [unwrapStep, wrapBlockquoteToDecisionListStep]
109
108
  },
@@ -121,34 +120,34 @@ var TRANSFORM_STEPS_OVERRIDE = {
121
120
  blockquote: [wrapStep],
122
121
  expand: [wrapStep],
123
122
  nestedExpand: [wrapStep],
124
- layoutSection: [wrapIntoLayoutStep],
123
+ layoutSection: [wrapMixedContentStep],
125
124
  panel: [wrapStep],
126
125
  heading: null
127
126
  },
128
127
  bulletList: {
129
128
  bulletList: null,
130
129
  codeBlock: null,
131
- layoutSection: [wrapIntoLayoutStep],
130
+ layoutSection: [wrapMixedContentStep],
132
131
  decisionList: [flattenListStep, listToDecisionListStep],
133
132
  heading: null
134
133
  },
135
134
  orderedList: {
136
135
  orderedList: null,
137
136
  codeBlock: null,
138
- layoutSection: [wrapIntoLayoutStep],
137
+ layoutSection: [wrapMixedContentStep],
139
138
  decisionList: [flattenListStep, listToDecisionListStep],
140
139
  heading: null
141
140
  },
142
141
  taskList: {
143
142
  blockquote: null,
144
143
  codeBlock: null,
145
- layoutSection: [wrapIntoLayoutStep],
144
+ layoutSection: [wrapMixedContentStep],
146
145
  decisionList: [flattenListStep, listToDecisionListStep],
147
146
  heading: null,
148
147
  taskList: null
149
148
  },
150
149
  table: {
151
- layoutSection: [wrapIntoLayoutStep],
150
+ layoutSection: [wrapMixedContentStep],
152
151
  blockquote: null,
153
152
  panel: null,
154
153
  codeBlock: null,
@@ -158,13 +157,13 @@ var TRANSFORM_STEPS_OVERRIDE = {
158
157
  decisionList: null
159
158
  },
160
159
  mediaSingle: {
161
- layoutSection: [wrapIntoLayoutStep],
160
+ layoutSection: [wrapMixedContentStep],
162
161
  codeBlock: null,
163
162
  decisionList: null,
164
163
  taskList: null
165
164
  },
166
165
  mediaGroup: {
167
- layoutSection: [wrapIntoLayoutStep],
166
+ layoutSection: [wrapMixedContentStep],
168
167
  codeBlock: null,
169
168
  decisionList: null,
170
169
  bulletList: null,
@@ -176,10 +175,10 @@ var TRANSFORM_STEPS_OVERRIDE = {
176
175
  bulletList: [decisionListToListStep],
177
176
  orderedList: [decisionListToListStep],
178
177
  taskList: [decisionListToListStep],
179
- layoutSection: [wrapIntoLayoutStep]
178
+ layoutSection: [wrapMixedContentStep]
180
179
  },
181
180
  blockCard: {
182
- layoutSection: [wrapIntoLayoutStep],
181
+ layoutSection: [wrapMixedContentStep],
183
182
  blockquote: null,
184
183
  codeBlock: null,
185
184
  orderedList: null,
@@ -188,7 +187,7 @@ var TRANSFORM_STEPS_OVERRIDE = {
188
187
  decisionList: null
189
188
  },
190
189
  embedCard: {
191
- layoutSection: [wrapIntoLayoutStep],
190
+ layoutSection: [wrapMixedContentStep],
192
191
  blockquote: null,
193
192
  panel: null,
194
193
  codeBlock: null,
@@ -198,7 +197,7 @@ var TRANSFORM_STEPS_OVERRIDE = {
198
197
  decisionList: null
199
198
  },
200
199
  extension: {
201
- layoutSection: [wrapIntoLayoutStep],
200
+ layoutSection: [wrapMixedContentStep],
202
201
  codeBlock: null,
203
202
  decisionList: null,
204
203
  taskList: null,
@@ -206,7 +205,7 @@ var TRANSFORM_STEPS_OVERRIDE = {
206
205
  bulletList: null
207
206
  },
208
207
  bodiedExtension: {
209
- layoutSection: [wrapIntoLayoutStep],
208
+ layoutSection: [wrapMixedContentStep],
210
209
  blockquote: null,
211
210
  expand: null,
212
211
  panel: null,
@@ -220,9 +219,7 @@ var TRANSFORM_STEPS_OVERRIDE = {
220
219
  // TODO: EDITOR-4140 - Implement multiple paragraphs/headings/codeblocks to heading transform
221
220
  heading: null,
222
221
  // TODO: EDITOR-4141 - Implement multiple codeblocks/headings to paragraph transform
223
- paragraph: null,
224
- // TODO: EDITOR-4138 - Implement multi content to layout transform
225
- layoutSection: undefined
222
+ paragraph: null
226
223
  }
227
224
  };
228
225
  var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
@@ -1,6 +1,16 @@
1
1
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
3
  import { CellSelection } from '@atlaskit/editor-tables';
4
+ import { NODE_CATEGORY_BY_TYPE } from './types';
5
+
6
+ /**
7
+ * Determines if a node is a text node (heading or paragraph).
8
+ * Text nodes can have their content converted to paragraphs when they can't be wrapped directly.
9
+ */
10
+ export var isTextNode = function isTextNode(node) {
11
+ var category = NODE_CATEGORY_BY_TYPE[node.type.name];
12
+ return category === 'text';
13
+ };
4
14
  export var getSelectedNode = function getSelectedNode(selection) {
5
15
  if (selection instanceof NodeSelection) {
6
16
  return {
@@ -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;
@@ -5,17 +5,32 @@ import type { TransformStep } from '../types';
5
5
  * - Same-type containers break out as separate containers (preserved as-is)
6
6
  * - NestedExpands break out as regular expands (converted since nestedExpand can't exist outside expand)
7
7
  * - Container structures that can't be nested in target break out (not flattened)
8
- * - Text/list nodes that can't be wrapped are flattened and merged into the container
8
+ * - Text/list nodes that can't be wrapped are converted to paragraphs and merged into the container
9
9
  * - Atomic nodes (tables, media, macros) break out
10
10
  *
11
+ * Special handling for layouts:
12
+ * - Layout sections break out as separate layouts (preserved as-is, not wrapped)
13
+ * - Other nodes (including headings, paragraphs, lists) are wrapped into layout columns within a layout section
14
+ * - Layouts always require layoutColumns as children (never paragraphs directly)
15
+ * - Layout columns can contain most block content including headings, paragraphs, lists, etc.
16
+ *
17
+ * Edge case handling:
18
+ * - For regular containers: If all content breaks out (container → container transform with no
19
+ * valid children), an empty container with a paragraph is created to ensure the target type exists
20
+ * - For layouts: Edge case handling is skipped because layouts require columns, not direct paragraphs.
21
+ * If all content breaks out, only the broken-out nodes are returned (no empty layout created)
22
+ *
11
23
  * What can be wrapped depends on the target container's schema:
12
24
  * - expand → panel: tables break out, nestedExpands convert to expands and break out
13
- * - expand → blockquote: tables/media break out, nestedExpands convert to expands and break out
25
+ * - expand → blockquote: tables/media break out, nestedExpands convert to expands and break out, headings converted to paragraphs
14
26
  * - expand → expand: tables/media stay inside (expands can contain them)
27
+ * - multi → layoutSection: layout sections break out, headings/paragraphs/lists wrapped into layout columns
15
28
  *
16
29
  * Example: expand(p('a'), table(), p('b')) → panel: [panel(p('a')), table(), panel(p('b'))]
17
30
  * Example: expand(p('a'), panel(p('x')), p('b')) → panel: [panel(p('a')), panel(p('x')), panel(p('b'))]
18
31
  * Example: expand(p('a'), nestedExpand({title: 'inner'})(p('x')), p('b')) → panel: [panel(p('a')), expand({title: 'inner'})(p('x')), panel(p('b'))]
19
32
  * Example: expand(nestedExpand()(p())) → panel: [panel(), expand()(p())] (empty panel when all content breaks out)
33
+ * Example: [p('a'), layoutSection(...), p('b')] → layoutSection: [layoutSection(layoutColumn(p('a'))), layoutSection(...), layoutSection(layoutColumn(p('b')))]
34
+ * Example: [h1('heading'), p('para')] → layoutSection: [layoutSection(layoutColumn(h1('heading'), p('para')))] (headings stay as headings in layouts)
20
35
  */
21
36
  export declare const wrapMixedContentStep: TransformStep;
@@ -2,6 +2,11 @@ import type { NodeRange, Node as PMNode, Schema } from '@atlaskit/editor-prosemi
2
2
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
4
4
  import type { NodeTypeName } from './types';
5
+ /**
6
+ * Determines if a node is a text node (heading or paragraph).
7
+ * Text nodes can have their content converted to paragraphs when they can't be wrapped directly.
8
+ */
9
+ export declare const isTextNode: (node: PMNode) => boolean;
5
10
  export declare const getSelectedNode: (selection: Selection) => ContentNodeWithPos | undefined;
6
11
  export declare const getTargetNodeTypeNameInContext: (nodeTypeName: NodeTypeName | null, isNested?: boolean, parentNode?: PMNode) => NodeTypeName | null;
7
12
  /**
@@ -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;
@@ -5,17 +5,32 @@ import type { TransformStep } from '../types';
5
5
  * - Same-type containers break out as separate containers (preserved as-is)
6
6
  * - NestedExpands break out as regular expands (converted since nestedExpand can't exist outside expand)
7
7
  * - Container structures that can't be nested in target break out (not flattened)
8
- * - Text/list nodes that can't be wrapped are flattened and merged into the container
8
+ * - Text/list nodes that can't be wrapped are converted to paragraphs and merged into the container
9
9
  * - Atomic nodes (tables, media, macros) break out
10
10
  *
11
+ * Special handling for layouts:
12
+ * - Layout sections break out as separate layouts (preserved as-is, not wrapped)
13
+ * - Other nodes (including headings, paragraphs, lists) are wrapped into layout columns within a layout section
14
+ * - Layouts always require layoutColumns as children (never paragraphs directly)
15
+ * - Layout columns can contain most block content including headings, paragraphs, lists, etc.
16
+ *
17
+ * Edge case handling:
18
+ * - For regular containers: If all content breaks out (container → container transform with no
19
+ * valid children), an empty container with a paragraph is created to ensure the target type exists
20
+ * - For layouts: Edge case handling is skipped because layouts require columns, not direct paragraphs.
21
+ * If all content breaks out, only the broken-out nodes are returned (no empty layout created)
22
+ *
11
23
  * What can be wrapped depends on the target container's schema:
12
24
  * - expand → panel: tables break out, nestedExpands convert to expands and break out
13
- * - expand → blockquote: tables/media break out, nestedExpands convert to expands and break out
25
+ * - expand → blockquote: tables/media break out, nestedExpands convert to expands and break out, headings converted to paragraphs
14
26
  * - expand → expand: tables/media stay inside (expands can contain them)
27
+ * - multi → layoutSection: layout sections break out, headings/paragraphs/lists wrapped into layout columns
15
28
  *
16
29
  * Example: expand(p('a'), table(), p('b')) → panel: [panel(p('a')), table(), panel(p('b'))]
17
30
  * Example: expand(p('a'), panel(p('x')), p('b')) → panel: [panel(p('a')), panel(p('x')), panel(p('b'))]
18
31
  * Example: expand(p('a'), nestedExpand({title: 'inner'})(p('x')), p('b')) → panel: [panel(p('a')), expand({title: 'inner'})(p('x')), panel(p('b'))]
19
32
  * Example: expand(nestedExpand()(p())) → panel: [panel(), expand()(p())] (empty panel when all content breaks out)
33
+ * Example: [p('a'), layoutSection(...), p('b')] → layoutSection: [layoutSection(layoutColumn(p('a'))), layoutSection(...), layoutSection(layoutColumn(p('b')))]
34
+ * Example: [h1('heading'), p('para')] → layoutSection: [layoutSection(layoutColumn(h1('heading'), p('para')))] (headings stay as headings in layouts)
20
35
  */
21
36
  export declare const wrapMixedContentStep: TransformStep;
@@ -2,6 +2,11 @@ import type { NodeRange, Node as PMNode, Schema } from '@atlaskit/editor-prosemi
2
2
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
4
4
  import type { NodeTypeName } from './types';
5
+ /**
6
+ * Determines if a node is a text node (heading or paragraph).
7
+ * Text nodes can have their content converted to paragraphs when they can't be wrapped directly.
8
+ */
9
+ export declare const isTextNode: (node: PMNode) => boolean;
5
10
  export declare const getSelectedNode: (selection: Selection) => ContentNodeWithPos | undefined;
6
11
  export declare const getTargetNodeTypeNameInContext: (nodeTypeName: NodeTypeName | null, isNested?: boolean, parentNode?: PMNode) => NodeTypeName | null;
7
12
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "6.0.5",
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",
@@ -44,12 +44,12 @@
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.3.0",
47
+ "@atlaskit/tmp-editor-statsig": "^16.4.0",
48
48
  "@atlaskit/tokens": "^9.0.0",
49
49
  "@babel/runtime": "^7.0.0"
50
50
  },
51
51
  "peerDependencies": {
52
- "@atlaskit/editor-common": "^111.1.0",
52
+ "@atlaskit/editor-common": "^111.2.0",
53
53
  "react": "^18.2.0",
54
54
  "react-intl-next": "npm:react-intl@^5.18.1"
55
55
  },
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.wrapIntoLayoutStep = void 0;
7
- var _marks = require("./marks");
8
- var wrapIntoLayoutStep = exports.wrapIntoLayoutStep = function wrapIntoLayoutStep(nodes, context) {
9
- var schema = context.schema;
10
- var _ref = schema.nodes || {},
11
- layoutSection = _ref.layoutSection,
12
- layoutColumn = _ref.layoutColumn;
13
- var columnOne = layoutColumn.createAndFill({}, (0, _marks.removeDisallowedMarks)(nodes, layoutColumn));
14
- var columnTwo = layoutColumn.createAndFill();
15
- if (!columnOne || !columnTwo) {
16
- return nodes;
17
- }
18
- var layout = layoutSection.createAndFill({}, [columnOne, columnTwo]);
19
- return layout ? [layout] : nodes;
20
- };
@@ -1,17 +0,0 @@
1
- import { removeDisallowedMarks } from './marks';
2
- export const wrapIntoLayoutStep = (nodes, context) => {
3
- const {
4
- schema
5
- } = context;
6
- const {
7
- layoutSection,
8
- layoutColumn
9
- } = schema.nodes || {};
10
- const columnOne = layoutColumn.createAndFill({}, removeDisallowedMarks(nodes, layoutColumn));
11
- const columnTwo = layoutColumn.createAndFill();
12
- if (!columnOne || !columnTwo) {
13
- return nodes;
14
- }
15
- const layout = layoutSection.createAndFill({}, [columnOne, columnTwo]);
16
- return layout ? [layout] : nodes;
17
- };
@@ -1,14 +0,0 @@
1
- import { removeDisallowedMarks } from './marks';
2
- export var wrapIntoLayoutStep = function wrapIntoLayoutStep(nodes, context) {
3
- var schema = context.schema;
4
- var _ref = schema.nodes || {},
5
- layoutSection = _ref.layoutSection,
6
- layoutColumn = _ref.layoutColumn;
7
- var columnOne = layoutColumn.createAndFill({}, removeDisallowedMarks(nodes, layoutColumn));
8
- var columnTwo = layoutColumn.createAndFill();
9
- if (!columnOne || !columnTwo) {
10
- return nodes;
11
- }
12
- var layout = layoutSection.createAndFill({}, [columnOne, columnTwo]);
13
- return layout ? [layout] : nodes;
14
- };
@@ -1,2 +0,0 @@
1
- import type { TransformStep } from './types';
2
- export declare const wrapIntoLayoutStep: TransformStep;
@@ -1,2 +0,0 @@
1
- import type { TransformStep } from './types';
2
- export declare const wrapIntoLayoutStep: TransformStep;