@atlaskit/editor-plugin-block-menu 1.0.4 → 1.0.6

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 (30) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/editor-commands/transforms/block-transforms.js +7 -1
  3. package/dist/cjs/editor-commands/transforms/container-transforms.js +83 -11
  4. package/dist/cjs/editor-commands/transforms/layout-transforms.js +30 -0
  5. package/dist/cjs/editor-commands/transforms/list-transforms.js +60 -3
  6. package/dist/cjs/editor-commands/transforms/transformNodeToTargetType.js +4 -0
  7. package/dist/cjs/editor-commands/transforms/utils.js +8 -1
  8. package/dist/es2019/editor-commands/transforms/block-transforms.js +8 -2
  9. package/dist/es2019/editor-commands/transforms/container-transforms.js +78 -7
  10. package/dist/es2019/editor-commands/transforms/layout-transforms.js +25 -0
  11. package/dist/es2019/editor-commands/transforms/list-transforms.js +62 -2
  12. package/dist/es2019/editor-commands/transforms/transformNodeToTargetType.js +5 -1
  13. package/dist/es2019/editor-commands/transforms/utils.js +7 -0
  14. package/dist/esm/editor-commands/transforms/block-transforms.js +8 -2
  15. package/dist/esm/editor-commands/transforms/container-transforms.js +83 -12
  16. package/dist/esm/editor-commands/transforms/layout-transforms.js +24 -0
  17. package/dist/esm/editor-commands/transforms/list-transforms.js +58 -2
  18. package/dist/esm/editor-commands/transforms/transformNodeToTargetType.js +5 -1
  19. package/dist/esm/editor-commands/transforms/utils.js +7 -0
  20. package/dist/types/editor-commands/transforms/container-transforms.d.ts +1 -1
  21. package/dist/types/editor-commands/transforms/layout-transforms.d.ts +2 -0
  22. package/dist/types/editor-commands/transforms/list-transforms.d.ts +4 -0
  23. package/dist/types/editor-commands/transforms/types.d.ts +1 -1
  24. package/dist/types/editor-commands/transforms/utils.d.ts +1 -0
  25. package/dist/types-ts4.5/editor-commands/transforms/container-transforms.d.ts +1 -1
  26. package/dist/types-ts4.5/editor-commands/transforms/layout-transforms.d.ts +2 -0
  27. package/dist/types-ts4.5/editor-commands/transforms/list-transforms.d.ts +4 -0
  28. package/dist/types-ts4.5/editor-commands/transforms/types.d.ts +1 -1
  29. package/dist/types-ts4.5/editor-commands/transforms/utils.d.ts +1 -0
  30. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 1.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`40e6bcca6edd4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/40e6bcca6edd4) -
8
+ [ux] ED-29146: unwrap container to block nodes
9
+ - Updated dependencies
10
+
11
+ ## 1.0.5
12
+
13
+ ### Patch Changes
14
+
15
+ - [`b76a419d23d3d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b76a419d23d3d) -
16
+ [ux] ED-29143 Transform nodes into layout
17
+ - [`0d741324d534a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0d741324d534a) -
18
+ [ux] Adds wrapping of list node types in container node types.
19
+ - Updated dependencies
20
+
3
21
  ## 1.0.4
4
22
 
5
23
  ### Patch Changes
@@ -33,7 +33,8 @@ var transformBlockNode = exports.transformBlockNode = function transformBlockNod
33
33
  var transformToBlockNode = function transformToBlockNode(context) {
34
34
  var tr = context.tr,
35
35
  targetNodeType = context.targetNodeType,
36
- targetAttrs = context.targetAttrs;
36
+ targetAttrs = context.targetAttrs,
37
+ sourceNode = context.sourceNode;
37
38
  var selection = tr.selection,
38
39
  doc = tr.doc;
39
40
  var $from = selection.$from,
@@ -44,6 +45,11 @@ var transformToBlockNode = function transformToBlockNode(context) {
44
45
  var node = schema.nodes.codeBlock.createChecked(undefined, textContent);
45
46
  return tr.replaceRangeWith(selection.from, selection.to, node);
46
47
  }
48
+
49
+ // code block acts like a container, we need to unwrap it
50
+ if (sourceNode.type === schema.nodes.codeBlock) {
51
+ return (0, _containerTransforms.unwrapAndConvertToBlockType)(context);
52
+ }
47
53
  tr.setBlockType($from.pos, $to.pos, targetNodeType, targetAttrs);
48
54
  return tr;
49
55
  };
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.unwrapAndConvertToList = exports.unwrapAndConvertToBlockType = exports.transformToContainer = exports.transformContainerNode = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
7
9
  var _model = require("@atlaskit/editor-prosemirror/model");
8
10
  var _utils = require("./utils");
9
11
  var convertInvalidNodeToValidNodeType = function convertInvalidNodeToValidNodeType(sourceContent, sourceNodeType, validNodeType, withMarks) {
@@ -60,7 +62,13 @@ var transformContainerNode = exports.transformContainerNode = function transform
60
62
 
61
63
  // Transform container to block type - unwrap and convert content
62
64
  if ((0, _utils.isBlockNodeType)(targetNodeType)) {
63
- return unwrapAndConvertToBlockType();
65
+ return unwrapAndConvertToBlockType({
66
+ tr: tr,
67
+ sourceNode: sourceNode,
68
+ sourcePos: sourcePos,
69
+ targetNodeType: targetNodeType,
70
+ targetAttrs: targetAttrs
71
+ });
64
72
  }
65
73
 
66
74
  // Transform container to list type
@@ -85,9 +93,73 @@ var transformContainerNode = exports.transformContainerNode = function transform
85
93
  /**
86
94
  * Unwrap container node and convert content to block type
87
95
  */
88
- var unwrapAndConvertToBlockType = exports.unwrapAndConvertToBlockType = function unwrapAndConvertToBlockType() {
89
- // Convert to block type directly
90
- return null;
96
+ var unwrapAndConvertToBlockType = exports.unwrapAndConvertToBlockType = function unwrapAndConvertToBlockType(context) {
97
+ var tr = context.tr,
98
+ targetNodeType = context.targetNodeType,
99
+ targetAttrs = context.targetAttrs,
100
+ sourceNode = context.sourceNode,
101
+ sourcePos = context.sourcePos;
102
+ var selection = tr.selection;
103
+ var schema = selection.$from.doc.type.schema;
104
+ var _schema$nodes = schema.nodes,
105
+ paragraph = _schema$nodes.paragraph,
106
+ heading = _schema$nodes.heading,
107
+ codeBlock = _schema$nodes.codeBlock,
108
+ expand = _schema$nodes.expand;
109
+ var rangeStart = sourcePos !== null ? sourcePos : selection.from;
110
+ var sourceChildren = (0, _toConsumableArray2.default)(sourceNode.children);
111
+ var transformedContent = [];
112
+
113
+ // If the container is expand, we need to extract the title and convert it to a paragraph
114
+ // and add it to the beginning of the content
115
+ if (sourceNode.type === expand) {
116
+ var _sourceNode$attrs;
117
+ var title = (_sourceNode$attrs = sourceNode.attrs) === null || _sourceNode$attrs === void 0 ? void 0 : _sourceNode$attrs.title;
118
+ if (title) {
119
+ var titleContent = schema.text(title);
120
+ sourceChildren.unshift(paragraph.createChecked({}, titleContent));
121
+ }
122
+ }
123
+
124
+ // if the container is a code block, convert text content to multiple paragraphs
125
+ if (sourceNode.type === codeBlock) {
126
+ var codeText = sourceNode.textContent;
127
+ var lines = codeText.split('\n');
128
+ var paragraphNodes = lines.map(function (line) {
129
+ return paragraph.create(null, line ? schema.text(line) : null);
130
+ });
131
+ sourceChildren = paragraphNodes;
132
+ }
133
+
134
+ // if target node is a paragraph, just do unwrap
135
+ if (targetNodeType === paragraph) {
136
+ transformedContent = sourceChildren;
137
+ }
138
+
139
+ // if target node is a headings, do unwrap and convert to heading
140
+ if (targetNodeType === heading && targetAttrs) {
141
+ var targetHeadingLevel = targetAttrs.level;
142
+ sourceChildren.forEach(function (node, index) {
143
+ if (node.isTextblock) {
144
+ var headingNode = heading.create({
145
+ level: targetHeadingLevel
146
+ }, node.content);
147
+ sourceChildren[index] = headingNode;
148
+ }
149
+ });
150
+ transformedContent = sourceChildren;
151
+ }
152
+
153
+ // if target node is code block, do unwrap and convert to code block
154
+ if (targetNodeType === codeBlock) {
155
+ var codeBlockContent = sourceChildren.map(function (node) {
156
+ return node.content.textBetween(0, node.content.size, '\n');
157
+ }).join('\n');
158
+ transformedContent = [codeBlock.createChecked({}, schema.text(codeBlockContent))];
159
+ }
160
+ var slice = new _model.Slice(_model.Fragment.fromArray(transformedContent), 0, 0);
161
+ tr.replaceRange(rangeStart, rangeStart + sourceNode.nodeSize, slice);
162
+ return tr;
91
163
  };
92
164
 
93
165
  /**
@@ -103,11 +175,11 @@ var unwrapAndConvertToList = exports.unwrapAndConvertToList = function unwrapAnd
103
175
  return tr;
104
176
  }
105
177
  var schema = tr.doc.type.schema;
106
- var _schema$nodes = schema.nodes,
107
- listItem = _schema$nodes.listItem,
108
- paragraph = _schema$nodes.paragraph,
109
- taskList = _schema$nodes.taskList,
110
- taskItem = _schema$nodes.taskItem;
178
+ var _schema$nodes2 = schema.nodes,
179
+ listItem = _schema$nodes2.listItem,
180
+ paragraph = _schema$nodes2.paragraph,
181
+ taskList = _schema$nodes2.taskList,
182
+ taskItem = _schema$nodes2.taskItem;
111
183
  var isTargetTaskList = targetNodeType === taskList;
112
184
  var createListItemFromInline = function createListItemFromInline(inlineFrag) {
113
185
  return isTargetTaskList ? taskItem.create(null, inlineFrag) : listItem.create(null, paragraph.create(null, inlineFrag));
@@ -123,8 +195,8 @@ var unwrapAndConvertToList = exports.unwrapAndConvertToList = function unwrapAnd
123
195
 
124
196
  // Expand's title should become the first item of the list
125
197
  if (sourceNode.type.name === 'expand') {
126
- var _sourceNode$attrs;
127
- var title = (_sourceNode$attrs = sourceNode.attrs) === null || _sourceNode$attrs === void 0 ? void 0 : _sourceNode$attrs.title;
198
+ var _sourceNode$attrs2;
199
+ var title = (_sourceNode$attrs2 = sourceNode.attrs) === null || _sourceNode$attrs2 === void 0 ? void 0 : _sourceNode$attrs2.title;
128
200
  if (title) {
129
201
  var titleContent = schema.text(title);
130
202
  items.push(isTargetTaskList ? taskItem.create(null, titleContent) : listItem.create(null, paragraph.create(null, titleContent)));
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.convertToLayout = void 0;
7
+ var _styles = require("@atlaskit/editor-common/styles");
8
+ var _model = require("@atlaskit/editor-prosemirror/model");
9
+ var convertToLayout = exports.convertToLayout = function convertToLayout(context) {
10
+ var tr = context.tr,
11
+ sourceNode = context.sourceNode,
12
+ sourcePos = context.sourcePos;
13
+ var _ref = tr.doc.type.schema.nodes || {},
14
+ layoutSection = _ref.layoutSection,
15
+ layoutColumn = _ref.layoutColumn,
16
+ paragraph = _ref.paragraph;
17
+ var content = sourceNode.mark(sourceNode.marks.filter(function (mark) {
18
+ return mark.type.name !== 'breakout';
19
+ }));
20
+ var layoutContent = _model.Fragment.fromArray([layoutColumn.createChecked({
21
+ width: _styles.DEFAULT_TWO_COLUMN_LAYOUT_COLUMN_WIDTH
22
+ }, content), layoutColumn.create({
23
+ width: _styles.DEFAULT_TWO_COLUMN_LAYOUT_COLUMN_WIDTH
24
+ }, paragraph.createAndFill())]);
25
+ var layoutSectionNode = layoutSection.createChecked(undefined, layoutContent);
26
+
27
+ // Replace the original node with the new layout node
28
+ tr.replaceRangeWith(sourcePos || 0, (sourcePos || 0) + sourceNode.nodeSize, layoutSectionNode);
29
+ return tr;
30
+ };
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
- exports.transformListToBlockNodes = exports.transformListNode = exports.transformBlockToList = exports.transformBetweenListTypes = exports.liftListToBlockType = void 0;
7
+ exports.transformListToContainer = exports.transformListToBlockNodes = exports.transformListNode = exports.transformBlockToList = exports.transformBetweenListTypes = exports.liftListToBlockType = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _model = require("@atlaskit/editor-prosemirror/model");
7
10
  var _transform = require("@atlaskit/editor-prosemirror/transform");
8
11
  var _transformBetweenListTypes = require("./list/transformBetweenListTypes");
9
12
  var _transformOrderedUnorderedListToBlockNodes = require("./list/transformOrderedUnorderedListToBlockNodes");
@@ -62,6 +65,60 @@ var transformListToBlockNodes = exports.transformListToBlockNodes = function tra
62
65
  }
63
66
  };
64
67
 
68
+ /**
69
+ * Wraps bulletList, orderedList or taskList in node of container type
70
+ */
71
+ var transformListToContainer = exports.transformListToContainer = function transformListToContainer(context) {
72
+ var tr = context.tr,
73
+ sourceNode = context.sourceNode,
74
+ sourcePos = context.sourcePos,
75
+ targetNodeType = context.targetNodeType,
76
+ targetAttrs = context.targetAttrs;
77
+ if (sourcePos === null) {
78
+ return null;
79
+ }
80
+ var schema = tr.doc.type.schema;
81
+ var _schema$nodes = schema.nodes,
82
+ blockquote = _schema$nodes.blockquote,
83
+ taskList = _schema$nodes.taskList,
84
+ taskItem = _schema$nodes.taskItem,
85
+ paragraph = _schema$nodes.paragraph;
86
+
87
+ // Special case: Task list -> Blockquote
88
+ // Flattens the task list before wrapping by blockquote
89
+ if (sourceNode.type === taskList && targetNodeType === blockquote) {
90
+ var _extractParagraphsFromTaskList = function extractParagraphsFromTaskList(node) {
91
+ var paragraphs = [];
92
+ node.forEach(function (child) {
93
+ if (child.type === taskItem) {
94
+ if (child.content.size > 0) {
95
+ var paragraphNode = paragraph.createChecked({}, child.content.content);
96
+ paragraphs.push(paragraphNode);
97
+ }
98
+ } else if (child.type === taskList) {
99
+ paragraphs.push.apply(paragraphs, (0, _toConsumableArray2.default)(_extractParagraphsFromTaskList(child)));
100
+ }
101
+ });
102
+ return paragraphs;
103
+ };
104
+ var liftedParagraphs = _extractParagraphsFromTaskList(sourceNode);
105
+ var _containerNode = targetNodeType.createAndFill(targetAttrs, _model.Fragment.from(liftedParagraphs));
106
+ if (!_containerNode) {
107
+ return null;
108
+ }
109
+ tr.replaceWith(sourcePos, sourcePos + sourceNode.nodeSize, _containerNode);
110
+ return tr;
111
+ }
112
+
113
+ // Default case
114
+ var containerNode = targetNodeType.createAndFill(targetAttrs, [sourceNode]);
115
+ if (!containerNode) {
116
+ return null;
117
+ }
118
+ tr.replaceWith(sourcePos, sourcePos + sourceNode.nodeSize, containerNode);
119
+ return tr;
120
+ };
121
+
65
122
  /**
66
123
  * Transform list nodes
67
124
  */
@@ -75,8 +132,8 @@ var transformListNode = exports.transformListNode = function transformListNode(c
75
132
 
76
133
  // Transform list to container type
77
134
  if ((0, _utils.isContainerNodeType)(targetNodeType)) {
78
- // Lift list items out of the list and convert to container type
79
- return null;
135
+ // Wrap list items into container type, where possible
136
+ return transformListToContainer(context);
80
137
  }
81
138
 
82
139
  // Transform between list types
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.transformNodeToTargetType = transformNodeToTargetType;
7
7
  var _blockTransforms = require("./block-transforms");
8
8
  var _containerTransforms = require("./container-transforms");
9
+ var _layoutTransforms = require("./layout-transforms");
9
10
  var _listTransforms = require("./list-transforms");
10
11
  var _utils = require("./utils");
11
12
  function transformNodeToTargetType(tr, sourceNode, sourcePos, targetType) {
@@ -43,6 +44,9 @@ function transformNodeToTargetType(tr, sourceNode, sourcePos, targetType) {
43
44
 
44
45
  // Route to appropriate transformation strategy based on source node type
45
46
  try {
47
+ if ((0, _utils.isLayoutNodeType)(targetNodeType)) {
48
+ return (0, _layoutTransforms.convertToLayout)(transformationContext);
49
+ }
46
50
  if ((0, _utils.isBlockNode)(sourceNode)) {
47
51
  return (0, _blockTransforms.transformBlockNode)(transformationContext);
48
52
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isTaskList = exports.isListNodeType = exports.isListNode = exports.isContainerNodeType = exports.isContainerNode = exports.isBulletOrOrderedList = exports.isBlockNodeType = exports.isBlockNode = exports.getTargetNodeInfo = exports.getSupportedListTypesSet = exports.getSupportedListTypes = void 0;
6
+ exports.isTaskList = exports.isListNodeType = exports.isListNode = exports.isLayoutNodeType = exports.isContainerNodeType = exports.isContainerNode = exports.isBulletOrOrderedList = exports.isBlockNodeType = exports.isBlockNode = exports.getTargetNodeInfo = exports.getSupportedListTypesSet = exports.getSupportedListTypes = void 0;
7
7
  var getTargetNodeInfo = exports.getTargetNodeInfo = function getTargetNodeInfo(targetType, nodes) {
8
8
  switch (targetType) {
9
9
  case 'heading1':
@@ -83,6 +83,10 @@ var getTargetNodeInfo = exports.getTargetNodeInfo = function getTargetNodeInfo(t
83
83
  return {
84
84
  nodeType: nodes.taskList
85
85
  };
86
+ case 'layoutSection':
87
+ return {
88
+ nodeType: nodes.layoutSection
89
+ };
86
90
  default:
87
91
  return null;
88
92
  }
@@ -120,4 +124,7 @@ var getSupportedListTypes = exports.getSupportedListTypes = function getSupporte
120
124
  };
121
125
  var getSupportedListTypesSet = exports.getSupportedListTypesSet = function getSupportedListTypesSet(nodes) {
122
126
  return new Set(getSupportedListTypes(nodes));
127
+ };
128
+ var isLayoutNodeType = exports.isLayoutNodeType = function isLayoutNodeType(nodeType) {
129
+ return nodeType.name === 'layoutSection';
123
130
  };
@@ -1,4 +1,4 @@
1
- import { transformToContainer } from './container-transforms';
1
+ import { transformToContainer, unwrapAndConvertToBlockType } from './container-transforms';
2
2
  import { getInlineNodeTextContent } from './inline-node-transforms';
3
3
  import { transformBlockToList } from './list-transforms';
4
4
  import { isListNodeType, isContainerNodeType, isBlockNodeType } from './utils';
@@ -31,7 +31,8 @@ const transformToBlockNode = context => {
31
31
  const {
32
32
  tr,
33
33
  targetNodeType,
34
- targetAttrs
34
+ targetAttrs,
35
+ sourceNode
35
36
  } = context;
36
37
  const {
37
38
  selection,
@@ -47,6 +48,11 @@ const transformToBlockNode = context => {
47
48
  const node = schema.nodes.codeBlock.createChecked(undefined, textContent);
48
49
  return tr.replaceRangeWith(selection.from, selection.to, node);
49
50
  }
51
+
52
+ // code block acts like a container, we need to unwrap it
53
+ if (sourceNode.type === schema.nodes.codeBlock) {
54
+ return unwrapAndConvertToBlockType(context);
55
+ }
50
56
  tr.setBlockType($from.pos, $to.pos, targetNodeType, targetAttrs);
51
57
  return tr;
52
58
  };
@@ -1,4 +1,4 @@
1
- import { Fragment } from '@atlaskit/editor-prosemirror/model';
1
+ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
2
2
  import { isBlockNodeType, isListNodeType, isContainerNodeType } from './utils';
3
3
  const convertInvalidNodeToValidNodeType = (sourceContent, sourceNodeType, validNodeType, withMarks) => {
4
4
  const validTransformedContent = [];
@@ -56,7 +56,13 @@ export const transformContainerNode = ({
56
56
 
57
57
  // Transform container to block type - unwrap and convert content
58
58
  if (isBlockNodeType(targetNodeType)) {
59
- return unwrapAndConvertToBlockType();
59
+ return unwrapAndConvertToBlockType({
60
+ tr,
61
+ sourceNode,
62
+ sourcePos,
63
+ targetNodeType,
64
+ targetAttrs
65
+ });
60
66
  }
61
67
 
62
68
  // Transform container to list type
@@ -81,9 +87,74 @@ export const transformContainerNode = ({
81
87
  /**
82
88
  * Unwrap container node and convert content to block type
83
89
  */
84
- export const unwrapAndConvertToBlockType = () => {
85
- // Convert to block type directly
86
- return null;
90
+ export const unwrapAndConvertToBlockType = context => {
91
+ const {
92
+ tr,
93
+ targetNodeType,
94
+ targetAttrs,
95
+ sourceNode,
96
+ sourcePos
97
+ } = context;
98
+ const {
99
+ selection
100
+ } = tr;
101
+ const schema = selection.$from.doc.type.schema;
102
+ const {
103
+ paragraph,
104
+ heading,
105
+ codeBlock,
106
+ expand
107
+ } = schema.nodes;
108
+ const rangeStart = sourcePos !== null ? sourcePos : selection.from;
109
+ let sourceChildren = [...sourceNode.children];
110
+ let transformedContent = [];
111
+
112
+ // If the container is expand, we need to extract the title and convert it to a paragraph
113
+ // and add it to the beginning of the content
114
+ if (sourceNode.type === expand) {
115
+ var _sourceNode$attrs;
116
+ const title = (_sourceNode$attrs = sourceNode.attrs) === null || _sourceNode$attrs === void 0 ? void 0 : _sourceNode$attrs.title;
117
+ if (title) {
118
+ const titleContent = schema.text(title);
119
+ sourceChildren.unshift(paragraph.createChecked({}, titleContent));
120
+ }
121
+ }
122
+
123
+ // if the container is a code block, convert text content to multiple paragraphs
124
+ if (sourceNode.type === codeBlock) {
125
+ const codeText = sourceNode.textContent;
126
+ const lines = codeText.split('\n');
127
+ const paragraphNodes = lines.map(line => paragraph.create(null, line ? schema.text(line) : null));
128
+ sourceChildren = paragraphNodes;
129
+ }
130
+
131
+ // if target node is a paragraph, just do unwrap
132
+ if (targetNodeType === paragraph) {
133
+ transformedContent = sourceChildren;
134
+ }
135
+
136
+ // if target node is a headings, do unwrap and convert to heading
137
+ if (targetNodeType === heading && targetAttrs) {
138
+ const targetHeadingLevel = targetAttrs.level;
139
+ sourceChildren.forEach((node, index) => {
140
+ if (node.isTextblock) {
141
+ const headingNode = heading.create({
142
+ level: targetHeadingLevel
143
+ }, node.content);
144
+ sourceChildren[index] = headingNode;
145
+ }
146
+ });
147
+ transformedContent = sourceChildren;
148
+ }
149
+
150
+ // if target node is code block, do unwrap and convert to code block
151
+ if (targetNodeType === codeBlock) {
152
+ const codeBlockContent = sourceChildren.map(node => node.content.textBetween(0, node.content.size, '\n')).join('\n');
153
+ transformedContent = [codeBlock.createChecked({}, schema.text(codeBlockContent))];
154
+ }
155
+ const slice = new Slice(Fragment.fromArray(transformedContent), 0, 0);
156
+ tr.replaceRange(rangeStart, rangeStart + sourceNode.nodeSize, slice);
157
+ return tr;
87
158
  };
88
159
 
89
160
  /**
@@ -123,8 +194,8 @@ export const unwrapAndConvertToList = ({
123
194
 
124
195
  // Expand's title should become the first item of the list
125
196
  if (sourceNode.type.name === 'expand') {
126
- var _sourceNode$attrs;
127
- const title = (_sourceNode$attrs = sourceNode.attrs) === null || _sourceNode$attrs === void 0 ? void 0 : _sourceNode$attrs.title;
197
+ var _sourceNode$attrs2;
198
+ const title = (_sourceNode$attrs2 = sourceNode.attrs) === null || _sourceNode$attrs2 === void 0 ? void 0 : _sourceNode$attrs2.title;
128
199
  if (title) {
129
200
  const titleContent = schema.text(title);
130
201
  items.push(isTargetTaskList ? taskItem.create(null, titleContent) : listItem.create(null, paragraph.create(null, titleContent)));
@@ -0,0 +1,25 @@
1
+ import { DEFAULT_TWO_COLUMN_LAYOUT_COLUMN_WIDTH } from '@atlaskit/editor-common/styles';
2
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
+ export const convertToLayout = context => {
4
+ const {
5
+ tr,
6
+ sourceNode,
7
+ sourcePos
8
+ } = context;
9
+ const {
10
+ layoutSection,
11
+ layoutColumn,
12
+ paragraph
13
+ } = tr.doc.type.schema.nodes || {};
14
+ const content = sourceNode.mark(sourceNode.marks.filter(mark => mark.type.name !== 'breakout'));
15
+ const layoutContent = Fragment.fromArray([layoutColumn.createChecked({
16
+ width: DEFAULT_TWO_COLUMN_LAYOUT_COLUMN_WIDTH
17
+ }, content), layoutColumn.create({
18
+ width: DEFAULT_TWO_COLUMN_LAYOUT_COLUMN_WIDTH
19
+ }, paragraph.createAndFill())]);
20
+ const layoutSectionNode = layoutSection.createChecked(undefined, layoutContent);
21
+
22
+ // Replace the original node with the new layout node
23
+ tr.replaceRangeWith(sourcePos || 0, (sourcePos || 0) + sourceNode.nodeSize, layoutSectionNode);
24
+ return tr;
25
+ };
@@ -1,3 +1,4 @@
1
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
1
2
  import { findWrapping } from '@atlaskit/editor-prosemirror/transform';
2
3
  import { transformListStructure } from './list/transformBetweenListTypes';
3
4
  import { transformOrderedUnorderedListToBlockNodes } from './list/transformOrderedUnorderedListToBlockNodes';
@@ -64,6 +65,65 @@ export const transformListToBlockNodes = context => {
64
65
  }
65
66
  };
66
67
 
68
+ /**
69
+ * Wraps bulletList, orderedList or taskList in node of container type
70
+ */
71
+ export const transformListToContainer = context => {
72
+ const {
73
+ tr,
74
+ sourceNode,
75
+ sourcePos,
76
+ targetNodeType,
77
+ targetAttrs
78
+ } = context;
79
+ if (sourcePos === null) {
80
+ return null;
81
+ }
82
+ const {
83
+ schema
84
+ } = tr.doc.type;
85
+ const {
86
+ blockquote,
87
+ taskList,
88
+ taskItem,
89
+ paragraph
90
+ } = schema.nodes;
91
+
92
+ // Special case: Task list -> Blockquote
93
+ // Flattens the task list before wrapping by blockquote
94
+ if (sourceNode.type === taskList && targetNodeType === blockquote) {
95
+ const extractParagraphsFromTaskList = node => {
96
+ const paragraphs = [];
97
+ node.forEach(child => {
98
+ if (child.type === taskItem) {
99
+ if (child.content.size > 0) {
100
+ const paragraphNode = paragraph.createChecked({}, child.content.content);
101
+ paragraphs.push(paragraphNode);
102
+ }
103
+ } else if (child.type === taskList) {
104
+ paragraphs.push(...extractParagraphsFromTaskList(child));
105
+ }
106
+ });
107
+ return paragraphs;
108
+ };
109
+ const liftedParagraphs = extractParagraphsFromTaskList(sourceNode);
110
+ const containerNode = targetNodeType.createAndFill(targetAttrs, Fragment.from(liftedParagraphs));
111
+ if (!containerNode) {
112
+ return null;
113
+ }
114
+ tr.replaceWith(sourcePos, sourcePos + sourceNode.nodeSize, containerNode);
115
+ return tr;
116
+ }
117
+
118
+ // Default case
119
+ const containerNode = targetNodeType.createAndFill(targetAttrs, [sourceNode]);
120
+ if (!containerNode) {
121
+ return null;
122
+ }
123
+ tr.replaceWith(sourcePos, sourcePos + sourceNode.nodeSize, containerNode);
124
+ return tr;
125
+ };
126
+
67
127
  /**
68
128
  * Transform list nodes
69
129
  */
@@ -79,8 +139,8 @@ export const transformListNode = context => {
79
139
 
80
140
  // Transform list to container type
81
141
  if (isContainerNodeType(targetNodeType)) {
82
- // Lift list items out of the list and convert to container type
83
- return null;
142
+ // Wrap list items into container type, where possible
143
+ return transformListToContainer(context);
84
144
  }
85
145
 
86
146
  // Transform between list types
@@ -1,7 +1,8 @@
1
1
  import { transformBlockNode } from './block-transforms';
2
2
  import { transformContainerNode } from './container-transforms';
3
+ import { convertToLayout } from './layout-transforms';
3
4
  import { transformListNode } from './list-transforms';
4
- import { getTargetNodeInfo, isBlockNode, isListNode, isContainerNode } from './utils';
5
+ import { getTargetNodeInfo, isBlockNode, isListNode, isContainerNode, isLayoutNodeType } from './utils';
5
6
  export function transformNodeToTargetType(tr, sourceNode, sourcePos, targetType) {
6
7
  const {
7
8
  nodes
@@ -41,6 +42,9 @@ export function transformNodeToTargetType(tr, sourceNode, sourcePos, targetType)
41
42
 
42
43
  // Route to appropriate transformation strategy based on source node type
43
44
  try {
45
+ if (isLayoutNodeType(targetNodeType)) {
46
+ return convertToLayout(transformationContext);
47
+ }
44
48
  if (isBlockNode(sourceNode)) {
45
49
  return transformBlockNode(transformationContext);
46
50
  }
@@ -77,6 +77,10 @@ export const getTargetNodeInfo = (targetType, nodes) => {
77
77
  return {
78
78
  nodeType: nodes.taskList
79
79
  };
80
+ case 'layoutSection':
81
+ return {
82
+ nodeType: nodes.layoutSection
83
+ };
80
84
  default:
81
85
  return null;
82
86
  }
@@ -114,4 +118,7 @@ export const getSupportedListTypes = nodes => {
114
118
  };
115
119
  export const getSupportedListTypesSet = nodes => {
116
120
  return new Set(getSupportedListTypes(nodes));
121
+ };
122
+ export const isLayoutNodeType = nodeType => {
123
+ return nodeType.name === 'layoutSection';
117
124
  };
@@ -1,4 +1,4 @@
1
- import { transformToContainer } from './container-transforms';
1
+ import { transformToContainer, unwrapAndConvertToBlockType } from './container-transforms';
2
2
  import { getInlineNodeTextContent } from './inline-node-transforms';
3
3
  import { transformBlockToList } from './list-transforms';
4
4
  import { isListNodeType, isContainerNodeType, isBlockNodeType } from './utils';
@@ -28,7 +28,8 @@ export var transformBlockNode = function transformBlockNode(context) {
28
28
  var transformToBlockNode = function transformToBlockNode(context) {
29
29
  var tr = context.tr,
30
30
  targetNodeType = context.targetNodeType,
31
- targetAttrs = context.targetAttrs;
31
+ targetAttrs = context.targetAttrs,
32
+ sourceNode = context.sourceNode;
32
33
  var selection = tr.selection,
33
34
  doc = tr.doc;
34
35
  var $from = selection.$from,
@@ -39,6 +40,11 @@ var transformToBlockNode = function transformToBlockNode(context) {
39
40
  var node = schema.nodes.codeBlock.createChecked(undefined, textContent);
40
41
  return tr.replaceRangeWith(selection.from, selection.to, node);
41
42
  }
43
+
44
+ // code block acts like a container, we need to unwrap it
45
+ if (sourceNode.type === schema.nodes.codeBlock) {
46
+ return unwrapAndConvertToBlockType(context);
47
+ }
42
48
  tr.setBlockType($from.pos, $to.pos, targetNodeType, targetAttrs);
43
49
  return tr;
44
50
  };
@@ -1,4 +1,5 @@
1
- import { Fragment } from '@atlaskit/editor-prosemirror/model';
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
2
3
  import { isBlockNodeType, isListNodeType, isContainerNodeType } from './utils';
3
4
  var convertInvalidNodeToValidNodeType = function convertInvalidNodeToValidNodeType(sourceContent, sourceNodeType, validNodeType, withMarks) {
4
5
  var validTransformedContent = [];
@@ -54,7 +55,13 @@ export var transformContainerNode = function transformContainerNode(_ref2) {
54
55
 
55
56
  // Transform container to block type - unwrap and convert content
56
57
  if (isBlockNodeType(targetNodeType)) {
57
- return unwrapAndConvertToBlockType();
58
+ return unwrapAndConvertToBlockType({
59
+ tr: tr,
60
+ sourceNode: sourceNode,
61
+ sourcePos: sourcePos,
62
+ targetNodeType: targetNodeType,
63
+ targetAttrs: targetAttrs
64
+ });
58
65
  }
59
66
 
60
67
  // Transform container to list type
@@ -79,9 +86,73 @@ export var transformContainerNode = function transformContainerNode(_ref2) {
79
86
  /**
80
87
  * Unwrap container node and convert content to block type
81
88
  */
82
- export var unwrapAndConvertToBlockType = function unwrapAndConvertToBlockType() {
83
- // Convert to block type directly
84
- return null;
89
+ export var unwrapAndConvertToBlockType = function unwrapAndConvertToBlockType(context) {
90
+ var tr = context.tr,
91
+ targetNodeType = context.targetNodeType,
92
+ targetAttrs = context.targetAttrs,
93
+ sourceNode = context.sourceNode,
94
+ sourcePos = context.sourcePos;
95
+ var selection = tr.selection;
96
+ var schema = selection.$from.doc.type.schema;
97
+ var _schema$nodes = schema.nodes,
98
+ paragraph = _schema$nodes.paragraph,
99
+ heading = _schema$nodes.heading,
100
+ codeBlock = _schema$nodes.codeBlock,
101
+ expand = _schema$nodes.expand;
102
+ var rangeStart = sourcePos !== null ? sourcePos : selection.from;
103
+ var sourceChildren = _toConsumableArray(sourceNode.children);
104
+ var transformedContent = [];
105
+
106
+ // If the container is expand, we need to extract the title and convert it to a paragraph
107
+ // and add it to the beginning of the content
108
+ if (sourceNode.type === expand) {
109
+ var _sourceNode$attrs;
110
+ var title = (_sourceNode$attrs = sourceNode.attrs) === null || _sourceNode$attrs === void 0 ? void 0 : _sourceNode$attrs.title;
111
+ if (title) {
112
+ var titleContent = schema.text(title);
113
+ sourceChildren.unshift(paragraph.createChecked({}, titleContent));
114
+ }
115
+ }
116
+
117
+ // if the container is a code block, convert text content to multiple paragraphs
118
+ if (sourceNode.type === codeBlock) {
119
+ var codeText = sourceNode.textContent;
120
+ var lines = codeText.split('\n');
121
+ var paragraphNodes = lines.map(function (line) {
122
+ return paragraph.create(null, line ? schema.text(line) : null);
123
+ });
124
+ sourceChildren = paragraphNodes;
125
+ }
126
+
127
+ // if target node is a paragraph, just do unwrap
128
+ if (targetNodeType === paragraph) {
129
+ transformedContent = sourceChildren;
130
+ }
131
+
132
+ // if target node is a headings, do unwrap and convert to heading
133
+ if (targetNodeType === heading && targetAttrs) {
134
+ var targetHeadingLevel = targetAttrs.level;
135
+ sourceChildren.forEach(function (node, index) {
136
+ if (node.isTextblock) {
137
+ var headingNode = heading.create({
138
+ level: targetHeadingLevel
139
+ }, node.content);
140
+ sourceChildren[index] = headingNode;
141
+ }
142
+ });
143
+ transformedContent = sourceChildren;
144
+ }
145
+
146
+ // if target node is code block, do unwrap and convert to code block
147
+ if (targetNodeType === codeBlock) {
148
+ var codeBlockContent = sourceChildren.map(function (node) {
149
+ return node.content.textBetween(0, node.content.size, '\n');
150
+ }).join('\n');
151
+ transformedContent = [codeBlock.createChecked({}, schema.text(codeBlockContent))];
152
+ }
153
+ var slice = new Slice(Fragment.fromArray(transformedContent), 0, 0);
154
+ tr.replaceRange(rangeStart, rangeStart + sourceNode.nodeSize, slice);
155
+ return tr;
85
156
  };
86
157
 
87
158
  /**
@@ -97,11 +168,11 @@ export var unwrapAndConvertToList = function unwrapAndConvertToList(_ref3) {
97
168
  return tr;
98
169
  }
99
170
  var schema = tr.doc.type.schema;
100
- var _schema$nodes = schema.nodes,
101
- listItem = _schema$nodes.listItem,
102
- paragraph = _schema$nodes.paragraph,
103
- taskList = _schema$nodes.taskList,
104
- taskItem = _schema$nodes.taskItem;
171
+ var _schema$nodes2 = schema.nodes,
172
+ listItem = _schema$nodes2.listItem,
173
+ paragraph = _schema$nodes2.paragraph,
174
+ taskList = _schema$nodes2.taskList,
175
+ taskItem = _schema$nodes2.taskItem;
105
176
  var isTargetTaskList = targetNodeType === taskList;
106
177
  var createListItemFromInline = function createListItemFromInline(inlineFrag) {
107
178
  return isTargetTaskList ? taskItem.create(null, inlineFrag) : listItem.create(null, paragraph.create(null, inlineFrag));
@@ -117,8 +188,8 @@ export var unwrapAndConvertToList = function unwrapAndConvertToList(_ref3) {
117
188
 
118
189
  // Expand's title should become the first item of the list
119
190
  if (sourceNode.type.name === 'expand') {
120
- var _sourceNode$attrs;
121
- var title = (_sourceNode$attrs = sourceNode.attrs) === null || _sourceNode$attrs === void 0 ? void 0 : _sourceNode$attrs.title;
191
+ var _sourceNode$attrs2;
192
+ var title = (_sourceNode$attrs2 = sourceNode.attrs) === null || _sourceNode$attrs2 === void 0 ? void 0 : _sourceNode$attrs2.title;
122
193
  if (title) {
123
194
  var titleContent = schema.text(title);
124
195
  items.push(isTargetTaskList ? taskItem.create(null, titleContent) : listItem.create(null, paragraph.create(null, titleContent)));
@@ -0,0 +1,24 @@
1
+ import { DEFAULT_TWO_COLUMN_LAYOUT_COLUMN_WIDTH } from '@atlaskit/editor-common/styles';
2
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
+ export var convertToLayout = function convertToLayout(context) {
4
+ var tr = context.tr,
5
+ sourceNode = context.sourceNode,
6
+ sourcePos = context.sourcePos;
7
+ var _ref = tr.doc.type.schema.nodes || {},
8
+ layoutSection = _ref.layoutSection,
9
+ layoutColumn = _ref.layoutColumn,
10
+ paragraph = _ref.paragraph;
11
+ var content = sourceNode.mark(sourceNode.marks.filter(function (mark) {
12
+ return mark.type.name !== 'breakout';
13
+ }));
14
+ var layoutContent = Fragment.fromArray([layoutColumn.createChecked({
15
+ width: DEFAULT_TWO_COLUMN_LAYOUT_COLUMN_WIDTH
16
+ }, content), layoutColumn.create({
17
+ width: DEFAULT_TWO_COLUMN_LAYOUT_COLUMN_WIDTH
18
+ }, paragraph.createAndFill())]);
19
+ var layoutSectionNode = layoutSection.createChecked(undefined, layoutContent);
20
+
21
+ // Replace the original node with the new layout node
22
+ tr.replaceRangeWith(sourcePos || 0, (sourcePos || 0) + sourceNode.nodeSize, layoutSectionNode);
23
+ return tr;
24
+ };
@@ -1,3 +1,5 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
1
3
  import { findWrapping } from '@atlaskit/editor-prosemirror/transform';
2
4
  import { transformListStructure } from './list/transformBetweenListTypes';
3
5
  import { transformOrderedUnorderedListToBlockNodes } from './list/transformOrderedUnorderedListToBlockNodes';
@@ -57,6 +59,60 @@ export var transformListToBlockNodes = function transformListToBlockNodes(contex
57
59
  }
58
60
  };
59
61
 
62
+ /**
63
+ * Wraps bulletList, orderedList or taskList in node of container type
64
+ */
65
+ export var transformListToContainer = function transformListToContainer(context) {
66
+ var tr = context.tr,
67
+ sourceNode = context.sourceNode,
68
+ sourcePos = context.sourcePos,
69
+ targetNodeType = context.targetNodeType,
70
+ targetAttrs = context.targetAttrs;
71
+ if (sourcePos === null) {
72
+ return null;
73
+ }
74
+ var schema = tr.doc.type.schema;
75
+ var _schema$nodes = schema.nodes,
76
+ blockquote = _schema$nodes.blockquote,
77
+ taskList = _schema$nodes.taskList,
78
+ taskItem = _schema$nodes.taskItem,
79
+ paragraph = _schema$nodes.paragraph;
80
+
81
+ // Special case: Task list -> Blockquote
82
+ // Flattens the task list before wrapping by blockquote
83
+ if (sourceNode.type === taskList && targetNodeType === blockquote) {
84
+ var _extractParagraphsFromTaskList = function extractParagraphsFromTaskList(node) {
85
+ var paragraphs = [];
86
+ node.forEach(function (child) {
87
+ if (child.type === taskItem) {
88
+ if (child.content.size > 0) {
89
+ var paragraphNode = paragraph.createChecked({}, child.content.content);
90
+ paragraphs.push(paragraphNode);
91
+ }
92
+ } else if (child.type === taskList) {
93
+ paragraphs.push.apply(paragraphs, _toConsumableArray(_extractParagraphsFromTaskList(child)));
94
+ }
95
+ });
96
+ return paragraphs;
97
+ };
98
+ var liftedParagraphs = _extractParagraphsFromTaskList(sourceNode);
99
+ var _containerNode = targetNodeType.createAndFill(targetAttrs, Fragment.from(liftedParagraphs));
100
+ if (!_containerNode) {
101
+ return null;
102
+ }
103
+ tr.replaceWith(sourcePos, sourcePos + sourceNode.nodeSize, _containerNode);
104
+ return tr;
105
+ }
106
+
107
+ // Default case
108
+ var containerNode = targetNodeType.createAndFill(targetAttrs, [sourceNode]);
109
+ if (!containerNode) {
110
+ return null;
111
+ }
112
+ tr.replaceWith(sourcePos, sourcePos + sourceNode.nodeSize, containerNode);
113
+ return tr;
114
+ };
115
+
60
116
  /**
61
117
  * Transform list nodes
62
118
  */
@@ -70,8 +126,8 @@ export var transformListNode = function transformListNode(context) {
70
126
 
71
127
  // Transform list to container type
72
128
  if (isContainerNodeType(targetNodeType)) {
73
- // Lift list items out of the list and convert to container type
74
- return null;
129
+ // Wrap list items into container type, where possible
130
+ return transformListToContainer(context);
75
131
  }
76
132
 
77
133
  // Transform between list types
@@ -1,7 +1,8 @@
1
1
  import { transformBlockNode } from './block-transforms';
2
2
  import { transformContainerNode } from './container-transforms';
3
+ import { convertToLayout } from './layout-transforms';
3
4
  import { transformListNode } from './list-transforms';
4
- import { getTargetNodeInfo, isBlockNode, isListNode, isContainerNode } from './utils';
5
+ import { getTargetNodeInfo, isBlockNode, isListNode, isContainerNode, isLayoutNodeType } from './utils';
5
6
  export function transformNodeToTargetType(tr, sourceNode, sourcePos, targetType) {
6
7
  var nodes = tr.doc.type.schema.nodes;
7
8
  var targetNodeInfo = getTargetNodeInfo(targetType, nodes);
@@ -37,6 +38,9 @@ export function transformNodeToTargetType(tr, sourceNode, sourcePos, targetType)
37
38
 
38
39
  // Route to appropriate transformation strategy based on source node type
39
40
  try {
41
+ if (isLayoutNodeType(targetNodeType)) {
42
+ return convertToLayout(transformationContext);
43
+ }
40
44
  if (isBlockNode(sourceNode)) {
41
45
  return transformBlockNode(transformationContext);
42
46
  }
@@ -77,6 +77,10 @@ export var getTargetNodeInfo = function getTargetNodeInfo(targetType, nodes) {
77
77
  return {
78
78
  nodeType: nodes.taskList
79
79
  };
80
+ case 'layoutSection':
81
+ return {
82
+ nodeType: nodes.layoutSection
83
+ };
80
84
  default:
81
85
  return null;
82
86
  }
@@ -114,4 +118,7 @@ export var getSupportedListTypes = function getSupportedListTypes(nodes) {
114
118
  };
115
119
  export var getSupportedListTypesSet = function getSupportedListTypesSet(nodes) {
116
120
  return new Set(getSupportedListTypes(nodes));
121
+ };
122
+ export var isLayoutNodeType = function isLayoutNodeType(nodeType) {
123
+ return nodeType.name === 'layoutSection';
117
124
  };
@@ -10,7 +10,7 @@ export declare const transformContainerNode: TransformFunction;
10
10
  /**
11
11
  * Unwrap container node and convert content to block type
12
12
  */
13
- export declare const unwrapAndConvertToBlockType: () => null;
13
+ export declare const unwrapAndConvertToBlockType: (context: TransformContext) => import("prosemirror-state").Transaction;
14
14
  /**
15
15
  * Unwrap container node and convert content to list
16
16
  */
@@ -0,0 +1,2 @@
1
+ import type { TransformContext } from './types';
2
+ export declare const convertToLayout: (context: TransformContext) => import("prosemirror-state").Transaction;
@@ -8,6 +8,10 @@ export declare const transformBlockToList: (context: TransformContext) => Transa
8
8
  * Transform list to block nodes
9
9
  */
10
10
  export declare const transformListToBlockNodes: (context: TransformContext) => Transaction | null;
11
+ /**
12
+ * Wraps bulletList, orderedList or taskList in node of container type
13
+ */
14
+ export declare const transformListToContainer: (context: TransformContext) => Transaction | null;
11
15
  /**
12
16
  * Transform list nodes
13
17
  */
@@ -1,6 +1,6 @@
1
1
  import type { Node as PMNode, NodeType } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
- export type FormatNodeTargetType = 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'blockquote' | 'expand' | 'layout' | 'panel' | 'codeBlock' | 'bulletList' | 'orderedList' | 'taskList';
3
+ export type FormatNodeTargetType = 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'blockquote' | 'expand' | 'layoutSection' | 'panel' | 'codeBlock' | 'bulletList' | 'orderedList' | 'taskList';
4
4
  export interface TransformContext {
5
5
  sourceNode: PMNode;
6
6
  sourcePos: number;
@@ -14,3 +14,4 @@ export declare const isBulletOrOrderedList: (nodeType: NodeType) => boolean;
14
14
  export declare const isTaskList: (nodeType: NodeType) => boolean;
15
15
  export declare const getSupportedListTypes: (nodes: Record<string, NodeType>) => NodeType[];
16
16
  export declare const getSupportedListTypesSet: (nodes: Record<string, NodeType>) => Set<NodeType>;
17
+ export declare const isLayoutNodeType: (nodeType: NodeType) => boolean;
@@ -10,7 +10,7 @@ export declare const transformContainerNode: TransformFunction;
10
10
  /**
11
11
  * Unwrap container node and convert content to block type
12
12
  */
13
- export declare const unwrapAndConvertToBlockType: () => null;
13
+ export declare const unwrapAndConvertToBlockType: (context: TransformContext) => import("prosemirror-state").Transaction;
14
14
  /**
15
15
  * Unwrap container node and convert content to list
16
16
  */
@@ -0,0 +1,2 @@
1
+ import type { TransformContext } from './types';
2
+ export declare const convertToLayout: (context: TransformContext) => import("prosemirror-state").Transaction;
@@ -8,6 +8,10 @@ export declare const transformBlockToList: (context: TransformContext) => Transa
8
8
  * Transform list to block nodes
9
9
  */
10
10
  export declare const transformListToBlockNodes: (context: TransformContext) => Transaction | null;
11
+ /**
12
+ * Wraps bulletList, orderedList or taskList in node of container type
13
+ */
14
+ export declare const transformListToContainer: (context: TransformContext) => Transaction | null;
11
15
  /**
12
16
  * Transform list nodes
13
17
  */
@@ -1,6 +1,6 @@
1
1
  import type { Node as PMNode, NodeType } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
- export type FormatNodeTargetType = 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'blockquote' | 'expand' | 'layout' | 'panel' | 'codeBlock' | 'bulletList' | 'orderedList' | 'taskList';
3
+ export type FormatNodeTargetType = 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'blockquote' | 'expand' | 'layoutSection' | 'panel' | 'codeBlock' | 'bulletList' | 'orderedList' | 'taskList';
4
4
  export interface TransformContext {
5
5
  sourceNode: PMNode;
6
6
  sourcePos: number;
@@ -14,3 +14,4 @@ export declare const isBulletOrOrderedList: (nodeType: NodeType) => boolean;
14
14
  export declare const isTaskList: (nodeType: NodeType) => boolean;
15
15
  export declare const getSupportedListTypes: (nodes: Record<string, NodeType>) => NodeType[];
16
16
  export declare const getSupportedListTypesSet: (nodes: Record<string, NodeType>) => Set<NodeType>;
17
+ export declare const isLayoutNodeType: (nodeType: NodeType) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -46,7 +46,7 @@
46
46
  "@babel/runtime": "^7.0.0"
47
47
  },
48
48
  "peerDependencies": {
49
- "@atlaskit/editor-common": "^108.2.0",
49
+ "@atlaskit/editor-common": "^108.5.0",
50
50
  "react": "^18.2.0",
51
51
  "react-intl-next": "npm:react-intl@^5.18.1"
52
52
  },