@atlaskit/editor-plugin-block-menu 9.0.19 → 9.1.1

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 (107) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.js +5 -5
  3. package/dist/cjs/editor-commands/transform-node-utils/{unwrapExpandStep.js → steps/unwrapExpandStep.js} +1 -1
  4. package/dist/cjs/editor-commands/transform-node-utils/{wrapIntoListStep.js → steps/wrapIntoListStep.js} +2 -2
  5. package/dist/cjs/editor-commands/transform-node-utils/{wrapStep.js → steps/wrapStep.js} +2 -2
  6. package/dist/cjs/editor-commands/transform-node-utils/utils.js +4 -1
  7. package/dist/cjs/editor-commands/transformNode.js +1 -1
  8. package/dist/es2019/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.js +5 -6
  9. package/dist/es2019/editor-commands/transform-node-utils/{unwrapExpandStep.js → steps/unwrapExpandStep.js} +1 -1
  10. package/dist/es2019/editor-commands/transform-node-utils/{wrapIntoListStep.js → steps/wrapIntoListStep.js} +2 -2
  11. package/dist/es2019/editor-commands/transform-node-utils/{wrapStep.js → steps/wrapStep.js} +2 -2
  12. package/dist/es2019/editor-commands/transform-node-utils/utils.js +3 -0
  13. package/dist/es2019/editor-commands/transformNode.js +1 -1
  14. package/dist/esm/editor-commands/transform-node-utils/TRANSFORMATION_MATRIX.js +5 -6
  15. package/dist/esm/editor-commands/transform-node-utils/{unwrapExpandStep.js → steps/unwrapExpandStep.js} +1 -1
  16. package/dist/esm/editor-commands/transform-node-utils/{wrapIntoListStep.js → steps/wrapIntoListStep.js} +2 -2
  17. package/dist/esm/editor-commands/transform-node-utils/{wrapStep.js → steps/wrapStep.js} +2 -2
  18. package/dist/esm/editor-commands/transform-node-utils/utils.js +3 -0
  19. package/dist/esm/editor-commands/transformNode.js +1 -1
  20. package/dist/types/blockMenuPluginType.d.ts +1 -1
  21. package/dist/types/editor-commands/selection.d.ts +1 -1
  22. package/dist/types/editor-commands/transform-node-utils/{flattenStep.d.ts → steps/flattenStep.d.ts} +1 -1
  23. package/dist/types/editor-commands/transform-node-utils/{unwrapExpandStep.d.ts → steps/unwrapExpandStep.d.ts} +1 -1
  24. package/dist/types/editor-commands/transform-node-utils/{unwrapStep.d.ts → steps/unwrapStep.d.ts} +1 -1
  25. package/dist/{types-ts4.5/editor-commands/transform-node-utils → types/editor-commands/transform-node-utils/steps}/wrapIntoListStep.d.ts +1 -1
  26. package/dist/types/editor-commands/transform-node-utils/{wrapStep.d.ts → steps/wrapStep.d.ts} +1 -1
  27. package/dist/types/editor-commands/transform-node-utils/utils.d.ts +1 -0
  28. package/dist/types/editor-commands/transformNode.d.ts +1 -1
  29. package/dist/{types-ts4.5/editor-commands/transforms → types/editor-commands}/types.d.ts +0 -3
  30. package/dist/types/index.d.ts +1 -1
  31. package/dist/types-ts4.5/blockMenuPluginType.d.ts +1 -1
  32. package/dist/types-ts4.5/editor-commands/selection.d.ts +1 -1
  33. package/dist/types-ts4.5/editor-commands/transform-node-utils/{flattenStep.d.ts → steps/flattenStep.d.ts} +1 -1
  34. package/dist/types-ts4.5/editor-commands/transform-node-utils/{unwrapExpandStep.d.ts → steps/unwrapExpandStep.d.ts} +1 -1
  35. package/dist/types-ts4.5/editor-commands/transform-node-utils/{unwrapStep.d.ts → steps/unwrapStep.d.ts} +1 -1
  36. package/dist/{types/editor-commands/transform-node-utils → types-ts4.5/editor-commands/transform-node-utils/steps}/wrapIntoListStep.d.ts +1 -1
  37. package/dist/types-ts4.5/editor-commands/transform-node-utils/{wrapStep.d.ts → steps/wrapStep.d.ts} +1 -1
  38. package/dist/types-ts4.5/editor-commands/transform-node-utils/utils.d.ts +1 -0
  39. package/dist/types-ts4.5/editor-commands/transformNode.d.ts +1 -1
  40. package/dist/{types/editor-commands/transforms → types-ts4.5/editor-commands}/types.d.ts +0 -3
  41. package/dist/types-ts4.5/index.d.ts +1 -1
  42. package/docs/0-intro.tsx +5 -5
  43. package/package.json +4 -4
  44. package/dist/cjs/editor-commands/transforms/block-transforms.js +0 -55
  45. package/dist/cjs/editor-commands/transforms/container-transforms.js +0 -448
  46. package/dist/cjs/editor-commands/transforms/inline-node-transforms.js +0 -39
  47. package/dist/cjs/editor-commands/transforms/layout/utils.js +0 -355
  48. package/dist/cjs/editor-commands/transforms/layout-transforms.js +0 -79
  49. package/dist/cjs/editor-commands/transforms/list/transformOrderedUnorderedListToBlockNodes.js +0 -97
  50. package/dist/cjs/editor-commands/transforms/list/transformTaskListToBlockNodes.js +0 -59
  51. package/dist/cjs/editor-commands/transforms/list/transformToTaskList.js +0 -44
  52. package/dist/cjs/editor-commands/transforms/list-transforms.js +0 -161
  53. package/dist/cjs/editor-commands/transforms/transformNodeToTargetType.js +0 -77
  54. package/dist/cjs/editor-commands/transforms/utils.js +0 -260
  55. package/dist/es2019/editor-commands/transforms/block-transforms.js +0 -58
  56. package/dist/es2019/editor-commands/transforms/container-transforms.js +0 -449
  57. package/dist/es2019/editor-commands/transforms/inline-node-transforms.js +0 -33
  58. package/dist/es2019/editor-commands/transforms/layout/utils.js +0 -334
  59. package/dist/es2019/editor-commands/transforms/layout-transforms.js +0 -75
  60. package/dist/es2019/editor-commands/transforms/list/transformOrderedUnorderedListToBlockNodes.js +0 -93
  61. package/dist/es2019/editor-commands/transforms/list/transformTaskListToBlockNodes.js +0 -47
  62. package/dist/es2019/editor-commands/transforms/list/transformToTaskList.js +0 -38
  63. package/dist/es2019/editor-commands/transforms/list-transforms.js +0 -168
  64. package/dist/es2019/editor-commands/transforms/transformNodeToTargetType.js +0 -76
  65. package/dist/es2019/editor-commands/transforms/utils.js +0 -248
  66. package/dist/esm/editor-commands/transforms/block-transforms.js +0 -50
  67. package/dist/esm/editor-commands/transforms/container-transforms.js +0 -441
  68. package/dist/esm/editor-commands/transforms/inline-node-transforms.js +0 -33
  69. package/dist/esm/editor-commands/transforms/layout/utils.js +0 -348
  70. package/dist/esm/editor-commands/transforms/layout-transforms.js +0 -72
  71. package/dist/esm/editor-commands/transforms/list/transformOrderedUnorderedListToBlockNodes.js +0 -90
  72. package/dist/esm/editor-commands/transforms/list/transformTaskListToBlockNodes.js +0 -53
  73. package/dist/esm/editor-commands/transforms/list/transformToTaskList.js +0 -37
  74. package/dist/esm/editor-commands/transforms/list-transforms.js +0 -155
  75. package/dist/esm/editor-commands/transforms/transformNodeToTargetType.js +0 -72
  76. package/dist/esm/editor-commands/transforms/utils.js +0 -253
  77. package/dist/types/editor-commands/transforms/block-transforms.d.ts +0 -5
  78. package/dist/types/editor-commands/transforms/container-transforms.d.ts +0 -20
  79. package/dist/types/editor-commands/transforms/inline-node-transforms.d.ts +0 -6
  80. package/dist/types/editor-commands/transforms/layout/utils.d.ts +0 -5
  81. package/dist/types/editor-commands/transforms/layout-transforms.d.ts +0 -6
  82. package/dist/types/editor-commands/transforms/list/transformOrderedUnorderedListToBlockNodes.d.ts +0 -3
  83. package/dist/types/editor-commands/transforms/list/transformTaskListToBlockNodes.d.ts +0 -3
  84. package/dist/types/editor-commands/transforms/list/transformToTaskList.d.ts +0 -10
  85. package/dist/types/editor-commands/transforms/list-transforms.d.ts +0 -23
  86. package/dist/types/editor-commands/transforms/transformNodeToTargetType.d.ts +0 -14
  87. package/dist/types/editor-commands/transforms/utils.d.ts +0 -45
  88. package/dist/types-ts4.5/editor-commands/transforms/block-transforms.d.ts +0 -5
  89. package/dist/types-ts4.5/editor-commands/transforms/container-transforms.d.ts +0 -20
  90. package/dist/types-ts4.5/editor-commands/transforms/inline-node-transforms.d.ts +0 -6
  91. package/dist/types-ts4.5/editor-commands/transforms/layout/utils.d.ts +0 -5
  92. package/dist/types-ts4.5/editor-commands/transforms/layout-transforms.d.ts +0 -6
  93. package/dist/types-ts4.5/editor-commands/transforms/list/transformOrderedUnorderedListToBlockNodes.d.ts +0 -3
  94. package/dist/types-ts4.5/editor-commands/transforms/list/transformTaskListToBlockNodes.d.ts +0 -3
  95. package/dist/types-ts4.5/editor-commands/transforms/list/transformToTaskList.d.ts +0 -10
  96. package/dist/types-ts4.5/editor-commands/transforms/list-transforms.d.ts +0 -23
  97. package/dist/types-ts4.5/editor-commands/transforms/transformNodeToTargetType.d.ts +0 -14
  98. package/dist/types-ts4.5/editor-commands/transforms/utils.d.ts +0 -45
  99. /package/dist/cjs/editor-commands/transform-node-utils/{flattenStep.js → steps/flattenStep.js} +0 -0
  100. /package/dist/cjs/editor-commands/transform-node-utils/{unwrapStep.js → steps/unwrapStep.js} +0 -0
  101. /package/dist/cjs/editor-commands/{transforms/types.js → types.js} +0 -0
  102. /package/dist/es2019/editor-commands/transform-node-utils/{flattenStep.js → steps/flattenStep.js} +0 -0
  103. /package/dist/es2019/editor-commands/transform-node-utils/{unwrapStep.js → steps/unwrapStep.js} +0 -0
  104. /package/dist/es2019/editor-commands/{transforms/types.js → types.js} +0 -0
  105. /package/dist/esm/editor-commands/transform-node-utils/{flattenStep.js → steps/flattenStep.js} +0 -0
  106. /package/dist/esm/editor-commands/transform-node-utils/{unwrapStep.js → steps/unwrapStep.js} +0 -0
  107. /package/dist/esm/editor-commands/{transforms/types.js → types.js} +0 -0
@@ -1,155 +0,0 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import { transformBetweenListTypes, isTaskList } from '@atlaskit/editor-common/transforms';
3
- import { Fragment } from '@atlaskit/editor-prosemirror/model';
4
- import { findWrapping } from '@atlaskit/editor-prosemirror/transform';
5
- import { transformOrderedUnorderedListToBlockNodes } from './list/transformOrderedUnorderedListToBlockNodes';
6
- import { transformTaskListToBlockNodes } from './list/transformTaskListToBlockNodes';
7
- import { transformToTaskList } from './list/transformToTaskList';
8
- import { isBlockNodeType, isContainerNodeType, isListNodeType } from './utils';
9
-
10
- /**
11
- * Transform selection to list type
12
- */
13
- export var transformBlockToList = function transformBlockToList(context) {
14
- var tr = context.tr,
15
- sourceNode = context.sourceNode,
16
- targetNodeType = context.targetNodeType,
17
- targetAttrs = context.targetAttrs;
18
- var _tr$selection = tr.selection,
19
- $from = _tr$selection.$from,
20
- $to = _tr$selection.$to;
21
- var schema = tr.doc.type.schema;
22
- var range = $from.blockRange($to);
23
- if (!range) {
24
- return null;
25
- }
26
- var nodes = tr.doc.type.schema.nodes;
27
- var isTargetTask = isTaskList(targetNodeType);
28
-
29
- // Handle task lists differently due to their structure
30
- if (isTargetTask) {
31
- return transformToTaskList(tr, range, targetNodeType, targetAttrs, nodes);
32
- }
33
-
34
- // filter marks that are not allowed in the target node type
35
- if (sourceNode.type === schema.nodes.paragraph || sourceNode.type === schema.nodes.heading) {
36
- var allowedMarks = targetNodeType.allowedMarks(sourceNode.marks);
37
- tr.setNodeMarkup(range.start, null, null, allowedMarks);
38
- }
39
-
40
- // For headings, convert to paragraph first since headings cannot be direct children of list items
41
- if (sourceNode && sourceNode.type.name.startsWith('heading')) {
42
- tr.setBlockType(range.start, range.end, nodes.paragraph);
43
- }
44
-
45
- // Get the current range (updated if we converted from heading)
46
- var currentRange = tr.selection.$from.blockRange(tr.selection.$to) || range;
47
-
48
- // Wrap in the target list type
49
- var wrapping = findWrapping(currentRange, targetNodeType, targetAttrs);
50
- if (!wrapping) {
51
- return null;
52
- }
53
- tr.wrap(currentRange, wrapping);
54
- return tr;
55
- };
56
-
57
- /**
58
- * Transform list to block nodes
59
- */
60
- export var transformListToBlockNodes = function transformListToBlockNodes(context) {
61
- var sourceNode = context.sourceNode;
62
- if (sourceNode.type.name === 'taskList') {
63
- return transformTaskListToBlockNodes(context);
64
- } else {
65
- return transformOrderedUnorderedListToBlockNodes(context);
66
- }
67
- };
68
-
69
- /**
70
- * Wraps bulletList, orderedList or taskList in node of container type
71
- */
72
- export var transformListToContainer = function transformListToContainer(context) {
73
- var tr = context.tr,
74
- sourceNode = context.sourceNode,
75
- sourcePos = context.sourcePos,
76
- targetNodeType = context.targetNodeType,
77
- targetAttrs = context.targetAttrs;
78
- if (sourcePos === null) {
79
- return null;
80
- }
81
- var schema = tr.doc.type.schema;
82
- var _schema$nodes = schema.nodes,
83
- blockquote = _schema$nodes.blockquote,
84
- taskList = _schema$nodes.taskList,
85
- taskItem = _schema$nodes.taskItem,
86
- paragraph = _schema$nodes.paragraph;
87
-
88
- // Special case: Task list -> Blockquote
89
- // Flattens the task list before wrapping by blockquote
90
- if (sourceNode.type === taskList && targetNodeType === blockquote) {
91
- var _extractParagraphsFromTaskList = function extractParagraphsFromTaskList(node) {
92
- var paragraphs = [];
93
- node.forEach(function (child) {
94
- if (child.type === taskItem) {
95
- if (child.content.size > 0) {
96
- var paragraphNode = paragraph.createChecked({}, child.content.content);
97
- paragraphs.push(paragraphNode);
98
- }
99
- } else if (child.type === taskList) {
100
- paragraphs.push.apply(paragraphs, _toConsumableArray(_extractParagraphsFromTaskList(child)));
101
- }
102
- });
103
- return paragraphs;
104
- };
105
- var liftedParagraphs = _extractParagraphsFromTaskList(sourceNode);
106
- var _containerNode = targetNodeType.createAndFill(targetAttrs, Fragment.from(liftedParagraphs));
107
- if (!_containerNode) {
108
- return null;
109
- }
110
- tr.replaceWith(sourcePos, sourcePos + sourceNode.nodeSize, _containerNode);
111
- return tr;
112
- }
113
-
114
- // Default case
115
- var containerNode = targetNodeType.createAndFill(targetAttrs, [sourceNode]);
116
- if (!containerNode) {
117
- return null;
118
- }
119
- tr.replaceWith(sourcePos, sourcePos + sourceNode.nodeSize, containerNode);
120
- return tr;
121
- };
122
-
123
- /**
124
- * Transform list nodes
125
- */
126
- export var transformListNode = function transformListNode(context) {
127
- var targetNodeType = context.targetNodeType;
128
- // Transform list to block type
129
- if (isBlockNodeType(targetNodeType)) {
130
- // Lift list items out of the list and convert to target block type
131
- return transformListToBlockNodes(context);
132
- }
133
-
134
- // Transform list to container type
135
- if (isContainerNodeType(targetNodeType)) {
136
- // Wrap list items into container type, where possible
137
- return transformListToContainer(context);
138
- }
139
-
140
- // Transform between list types
141
- if (isListNodeType(targetNodeType)) {
142
- return transformBetweenListTypes(context);
143
- }
144
- return null;
145
- };
146
-
147
- /**
148
- * Lift list content and convert to block type
149
- */
150
- export var liftListToBlockType = function liftListToBlockType() {
151
- // Convert to target block type directly
152
- return null;
153
- };
154
-
155
- // transformBetweenListTypes is now imported from @atlaskit/editor-common/transforms
@@ -1,72 +0,0 @@
1
- import { transformBlockNode } from './block-transforms';
2
- import { transformContainerNode, unwrapAndConvertToList } from './container-transforms';
3
- import { convertToLayout, transformLayoutNode } from './layout-transforms';
4
- import { transformListNode } from './list-transforms';
5
- import { getTargetNodeInfo, isBlockNode, isListNode, isListNodeType, isContainerNode, isLayoutNodeType, isLayoutNode } from './utils';
6
-
7
- /**
8
- * Transforms a source node to the specified target type.
9
- * Throws errors on failure which should be caught at the command level.
10
- *
11
- * @param tr - The transaction to apply transformations to
12
- * @param sourceNode - The node to transform
13
- * @param sourcePos - The position of the source node in the document
14
- * @param targetType - The target node type to transform to
15
- * @returns The modified transaction if successful, null if transformation is not possible
16
- */
17
- export function transformNodeToTargetType(tr, sourceNode, sourcePos, targetType) {
18
- var nodes = tr.doc.type.schema.nodes;
19
- var targetNodeInfo = getTargetNodeInfo(targetType, nodes);
20
- if (!targetNodeInfo) {
21
- return null;
22
- }
23
- var targetNodeType = targetNodeInfo.nodeType,
24
- targetAttrs = targetNodeInfo.attrs;
25
-
26
- // Early return if trying to transform to the same type
27
- if (sourceNode.type.name === targetNodeType.name) {
28
- // For headings, also check if the level matches
29
- if (targetNodeType.name === 'heading') {
30
- var _sourceNode$attrs;
31
- var sourceLevel = (_sourceNode$attrs = sourceNode.attrs) === null || _sourceNode$attrs === void 0 ? void 0 : _sourceNode$attrs.level;
32
- var targetLevel = targetAttrs === null || targetAttrs === void 0 ? void 0 : targetAttrs.level;
33
- if (sourceLevel === targetLevel) {
34
- return tr;
35
- }
36
- } else {
37
- return tr;
38
- }
39
- }
40
-
41
- // Prepare transformation context
42
- var transformationContext = {
43
- tr: tr,
44
- sourceNode: sourceNode,
45
- sourcePos: sourcePos,
46
- targetNodeType: targetNodeType,
47
- targetAttrs: targetAttrs
48
- };
49
-
50
- // Route to appropriate transformation strategy based on source node type
51
- if (isLayoutNodeType(targetNodeType)) {
52
- return convertToLayout(transformationContext);
53
- }
54
-
55
- // special case codeblock to listType
56
- if (sourceNode.type.name === 'codeBlock' && isListNodeType(targetNodeType)) {
57
- return unwrapAndConvertToList(transformationContext);
58
- }
59
- if (isLayoutNode(sourceNode)) {
60
- return transformLayoutNode(transformationContext);
61
- }
62
- if (isBlockNode(sourceNode)) {
63
- return transformBlockNode(transformationContext);
64
- }
65
- if (isListNode(sourceNode)) {
66
- return transformListNode(transformationContext);
67
- }
68
- if (isContainerNode(sourceNode)) {
69
- return transformContainerNode(transformationContext);
70
- }
71
- return null;
72
- }
@@ -1,253 +0,0 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import { breakoutResizableNodes } from '@atlaskit/editor-common/utils';
3
- import { Fragment } from '@atlaskit/editor-prosemirror/model';
4
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
- export var getTargetNodeInfo = function getTargetNodeInfo(targetType, nodes) {
6
- switch (targetType) {
7
- case 'heading1':
8
- return {
9
- nodeType: nodes.heading,
10
- attrs: {
11
- level: 1
12
- }
13
- };
14
- case 'heading2':
15
- return {
16
- nodeType: nodes.heading,
17
- attrs: {
18
- level: 2
19
- }
20
- };
21
- case 'heading3':
22
- return {
23
- nodeType: nodes.heading,
24
- attrs: {
25
- level: 3
26
- }
27
- };
28
- case 'heading4':
29
- return {
30
- nodeType: nodes.heading,
31
- attrs: {
32
- level: 4
33
- }
34
- };
35
- case 'heading5':
36
- return {
37
- nodeType: nodes.heading,
38
- attrs: {
39
- level: 5
40
- }
41
- };
42
- case 'heading6':
43
- return {
44
- nodeType: nodes.heading,
45
- attrs: {
46
- level: 6
47
- }
48
- };
49
- case 'paragraph':
50
- return {
51
- nodeType: nodes.paragraph
52
- };
53
- case 'blockquote':
54
- return {
55
- nodeType: nodes.blockquote
56
- };
57
- case 'expand':
58
- return {
59
- nodeType: nodes.expand
60
- };
61
- case 'panel':
62
- return {
63
- nodeType: nodes.panel,
64
- attrs: {
65
- panelType: 'info'
66
- }
67
- };
68
- case 'codeBlock':
69
- return {
70
- nodeType: nodes.codeBlock
71
- };
72
- case 'bulletList':
73
- return {
74
- nodeType: nodes.bulletList
75
- };
76
- case 'orderedList':
77
- return {
78
- nodeType: nodes.orderedList
79
- };
80
- case 'taskList':
81
- return {
82
- nodeType: nodes.taskList
83
- };
84
- case 'layoutSection':
85
- return {
86
- nodeType: nodes.layoutSection
87
- };
88
- default:
89
- return null;
90
- }
91
- };
92
-
93
- // Helper functions to categorize node types
94
- export var isBlockNode = function isBlockNode(node) {
95
- return ['paragraph', 'heading', 'codeBlock'].includes(node.type.name);
96
- };
97
- export var isHeadingOrParagraphNode = function isHeadingOrParagraphNode(node) {
98
- return ['paragraph', 'heading'].includes(node.type.name);
99
- };
100
- export var isListNode = function isListNode(node) {
101
- return ['bulletList', 'orderedList', 'taskList'].includes(node.type.name);
102
- };
103
- export var isContainerNode = function isContainerNode(node) {
104
- return ['panel', 'expand', 'blockquote'].includes(node.type.name);
105
- };
106
- export var isBlockNodeType = function isBlockNodeType(nodeType) {
107
- return ['paragraph', 'heading', 'codeBlock'].includes(nodeType.name);
108
- };
109
- export var isListNodeType = function isListNodeType(nodeType) {
110
- return ['bulletList', 'orderedList', 'taskList'].includes(nodeType.name);
111
- };
112
- export var isContainerNodeType = function isContainerNodeType(nodeType) {
113
- return ['panel', 'expand', 'blockquote'].includes(nodeType.name);
114
- };
115
-
116
- // List type utilities moved to @atlaskit/editor-common/transforms
117
-
118
- export var isLayoutNodeType = function isLayoutNodeType(nodeType) {
119
- return nodeType.name === 'layoutSection';
120
- };
121
- export var isLayoutNode = function isLayoutNode(node) {
122
- return node.type.name === 'layoutSection';
123
- };
124
-
125
- /**
126
- * Check if a node should be extracted as a standalone block node
127
- * rather than converted to inline content
128
- */
129
- export var isBlockNodeForExtraction = function isBlockNodeForExtraction(node) {
130
- var blockNodesForExtraction = ['table', 'mediaSingle', 'extension', 'bodiedExtension', 'blockCard', 'embedCard'];
131
- return blockNodesForExtraction.includes(node.type.name);
132
- };
133
-
134
- /**
135
- * Get a function that checks if content is supported in the target container type
136
- */
137
- export var getContentSupportChecker = function getContentSupportChecker(targetNodeType) {
138
- return function (node) {
139
- // Check if the target container type can contain this node
140
- try {
141
- return targetNodeType.validContent(Fragment.from(node));
142
- } catch (_unused) {
143
- return false;
144
- }
145
- };
146
- };
147
-
148
- /**
149
- * Convert a node to inline content that can be placed in a paragraph
150
- */
151
- export var convertNodeToInlineContent = function convertNodeToInlineContent(node, schema) {
152
- // Extract text and inline nodes from any complex node
153
- var inlineNodes = [];
154
- node.descendants(function (childNode) {
155
- if (childNode.isText) {
156
- inlineNodes.push(childNode);
157
- } else if (childNode.isInline) {
158
- inlineNodes.push(childNode);
159
- }
160
- return true; // Continue traversing
161
- });
162
-
163
- // If no inline content was found but the node has text content,
164
- // create a text node with the full text content
165
- if (inlineNodes.length === 0 && node.textContent) {
166
- return [schema.text(node.textContent)];
167
- }
168
- return inlineNodes;
169
- };
170
-
171
- /**
172
- * Filter marks from content based on the target node type
173
- * @param content The content fragment to filter
174
- * @param targetNodeType The target node type to check against
175
- * @returns A new fragment with marks filtered for the target node type
176
- */
177
- export var filterMarksForTargetNodeType = function filterMarksForTargetNodeType(content, targetNodeType) {
178
- var withValidMarks = [];
179
- content.forEach(function (node) {
180
- if (node.marks.length > 0) {
181
- var allowedMarks = targetNodeType.allowedMarks(node.marks);
182
- var updatedNode = node.mark(allowedMarks);
183
- withValidMarks.push(updatedNode);
184
- } else {
185
- withValidMarks.push(node);
186
- }
187
- });
188
- return Fragment.from(withValidMarks);
189
- };
190
-
191
- /** * Convert content from a code block node into multiple paragraph nodes
192
- */
193
- export var convertCodeBlockContentToParagraphs = function convertCodeBlockContentToParagraphs(codeBlockNode, schema) {
194
- var paragraphNodes = [];
195
- var codeText = codeBlockNode.textContent;
196
- var lines = codeText.split('\n');
197
- lines.forEach(function (line) {
198
- var paragraphNode = schema.nodes.paragraph.create(null, line ? schema.text(line) : null);
199
- paragraphNodes.push(paragraphNode);
200
- });
201
- return paragraphNodes;
202
- };
203
- var isBreakoutMarkSupported = function isBreakoutMarkSupported(nodeType) {
204
- return editorExperiment('platform_synced_block', true) ? breakoutResizableNodes.includes(nodeType.name) : ['codeBlock', 'expand', 'layoutSection'].includes(nodeType.name);
205
- };
206
- export var getMarksWithBreakout = function getMarksWithBreakout(sourceNode, targetNodeType) {
207
- var allowedMarks = targetNodeType.allowedMarks(sourceNode.marks);
208
- var sourceBreakoutMark = sourceNode.marks.find(function (mark) {
209
- return mark.type.name === 'breakout';
210
- });
211
- if (sourceBreakoutMark && isBreakoutMarkSupported(targetNodeType)) {
212
- // Check if breakout mark is already in allowedMarks to avoid duplicates
213
- var hasBreakoutMark = allowedMarks.some(function (mark) {
214
- return mark.type.name === 'breakout';
215
- });
216
- return hasBreakoutMark ? allowedMarks : [].concat(_toConsumableArray(allowedMarks), [sourceBreakoutMark]);
217
- }
218
- return allowedMarks;
219
- };
220
-
221
- /**
222
- * Determines the conversion type based on source and target node types
223
- * This is for analytics use - these types match existing analytics events for consistency
224
- */
225
- export var getConversionType = function getConversionType(from, to) {
226
- // Block node insertion: block-like elements inserted from empty line or wrapping text/list
227
- var blockNodes = ['panel', 'expand', 'codeBlock', 'layoutSection', 'taskList'];
228
- var textNodes = ['paragraph', 'blockquote'];
229
- var headingNodes = ['heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6'];
230
- var listNodes = ['bulletList', 'orderedList'];
231
-
232
- // Check if converting to block nodes from text/heading/list nodes
233
- if (blockNodes.includes(to) && (textNodes.includes(from) || headingNodes.includes(from) || listNodes.includes(from))) {
234
- return 'blockNodeInserted';
235
- }
236
-
237
- // Check if converting from paragraph/blockquote to list
238
- if (listNodes.includes(to) && textNodes.includes(from)) {
239
- return 'listInserted';
240
- }
241
-
242
- // Check if converting from list to paragraph/heading/blockquote or between list types
243
- if (listNodes.includes(from) && (listNodes.includes(to) || textNodes.includes(to))) {
244
- return 'listConverted';
245
- }
246
-
247
- // Text formatting: conversions among paragraph/headings/blockquote
248
- if ((textNodes.includes(from) || headingNodes.includes(from)) && (textNodes.includes(to) || headingNodes.includes(to))) {
249
- return 'textFormatted';
250
- }
251
- // For other conversions, we do not have a matching event category
252
- return undefined;
253
- };
@@ -1,5 +0,0 @@
1
- import type { TransformFunction } from './types';
2
- /**
3
- * Transform block nodes (paragraph, heading, codeblock)
4
- */
5
- export declare const transformBlockNode: TransformFunction;
@@ -1,20 +0,0 @@
1
- import type { TransformContext } from '@atlaskit/editor-common/transforms';
2
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
- import type { TransformFunction } from './types';
4
- /**
5
- * Transform selection to container type
6
- */
7
- export declare const transformToContainer: ({ tr, sourceNode, targetNodeType, targetAttrs, }: TransformContext) => Transaction | null;
8
- /**
9
- * Transform container nodes (panel, expand, blockquote)
10
- */
11
- export declare const transformContainerNode: TransformFunction;
12
- /**
13
- * Unwrap container node and convert content to block type
14
- */
15
- export declare const unwrapAndConvertToBlockType: (context: TransformContext) => Transaction;
16
- /**
17
- * Unwrap container node and convert content to list
18
- */
19
- export declare const unwrapAndConvertToList: ({ tr, sourceNode, sourcePos, targetNodeType, targetAttrs, }: TransformContext) => Transaction | null;
20
- export declare const transformBetweenContainerTypes: (context: TransformContext) => Transaction;
@@ -1,6 +0,0 @@
1
- import type { Fragment, Schema, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- export declare const getInlineNodeTextContent: (sourceContent: Fragment) => {
3
- inlineTextContent: string;
4
- invalidContent: PMNode[];
5
- };
6
- export declare const getInlineNodeTextNode: (sourceContent: Fragment, schema: Schema) => PMNode;
@@ -1,5 +0,0 @@
1
- import type { TransformContext } from '@atlaskit/editor-common/transforms';
2
- import type { NodeType, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
3
- export declare const unwrapLayoutNodesToTextNodes: (context: TransformContext, finalTargetNodeType: NodeType) => PMNode[];
4
- export declare const transformToListNode: (nodes: PMNode[], targetNodeType: NodeType, schema: Schema) => PMNode[];
5
- export declare const convertUnwrappedLayoutContent: (nodes: PMNode[], targetNodeType: NodeType, schema: Schema, targetAttrs?: TransformContext["targetAttrs"]) => PMNode[];
@@ -1,6 +0,0 @@
1
- import type { TransformContext } from '@atlaskit/editor-common/transforms';
2
- import { type Mark, type Node as PMNode, type Schema } from '@atlaskit/editor-prosemirror/model';
3
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
- export declare const createDefaultLayoutSection: (schema: Schema, content: PMNode, marks?: readonly Mark[]) => PMNode;
5
- export declare const convertToLayout: (context: TransformContext) => Transaction;
6
- export declare const transformLayoutNode: (context: TransformContext) => Transaction;
@@ -1,3 +0,0 @@
1
- import type { TransformContext } from '@atlaskit/editor-common/transforms';
2
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
- export declare const transformOrderedUnorderedListToBlockNodes: (context: TransformContext) => Transaction | null;
@@ -1,3 +0,0 @@
1
- import type { TransformContext } from '@atlaskit/editor-common/transforms';
2
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
- export declare const transformTaskListToBlockNodes: (context: TransformContext) => Transaction | null;
@@ -1,10 +0,0 @@
1
- import type { NodeType } from '@atlaskit/editor-prosemirror/model';
2
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
- /**
4
- * Transform selection to task list
5
- * Handles the special structure where taskItem contains text directly (no paragraph wrapper)
6
- */
7
- export declare const transformToTaskList: (tr: Transaction, range: {
8
- end: number;
9
- start: number;
10
- }, targetNodeType: NodeType, targetAttrs: Record<string, unknown> | undefined, nodes: Record<string, NodeType>) => Transaction | null;
@@ -1,23 +0,0 @@
1
- import type { TransformContext } from '@atlaskit/editor-common/transforms';
2
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
- import type { TransformFunction } from './types';
4
- /**
5
- * Transform selection to list type
6
- */
7
- export declare const transformBlockToList: (context: TransformContext) => Transaction | null;
8
- /**
9
- * Transform list to block nodes
10
- */
11
- export declare const transformListToBlockNodes: (context: TransformContext) => Transaction | null;
12
- /**
13
- * Wraps bulletList, orderedList or taskList in node of container type
14
- */
15
- export declare const transformListToContainer: (context: TransformContext) => Transaction | null;
16
- /**
17
- * Transform list nodes
18
- */
19
- export declare const transformListNode: TransformFunction;
20
- /**
21
- * Lift list content and convert to block type
22
- */
23
- export declare const liftListToBlockType: () => null;
@@ -1,14 +0,0 @@
1
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
- import type { TransfromNodeTargetType } from './types';
4
- /**
5
- * Transforms a source node to the specified target type.
6
- * Throws errors on failure which should be caught at the command level.
7
- *
8
- * @param tr - The transaction to apply transformations to
9
- * @param sourceNode - The node to transform
10
- * @param sourcePos - The position of the source node in the document
11
- * @param targetType - The target node type to transform to
12
- * @returns The modified transaction if successful, null if transformation is not possible
13
- */
14
- export declare function transformNodeToTargetType(tr: Transaction, sourceNode: PMNode, sourcePos: number, targetType: TransfromNodeTargetType): Transaction | null;
@@ -1,45 +0,0 @@
1
- import type { Mark, Node as PMNode, NodeType, Schema } from '@atlaskit/editor-prosemirror/model';
2
- import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
- import type { TransfromNodeTargetType } from './types';
4
- export declare const getTargetNodeInfo: (targetType: TransfromNodeTargetType, nodes: Record<string, NodeType>) => {
5
- attrs?: Record<string, unknown>;
6
- nodeType: NodeType;
7
- } | null;
8
- export declare const isBlockNode: (node: PMNode) => boolean;
9
- export declare const isHeadingOrParagraphNode: (node: PMNode) => boolean;
10
- export declare const isListNode: (node: PMNode) => boolean;
11
- export declare const isContainerNode: (node: PMNode) => boolean;
12
- export declare const isBlockNodeType: (nodeType: NodeType) => boolean;
13
- export declare const isListNodeType: (nodeType: NodeType) => boolean;
14
- export declare const isContainerNodeType: (nodeType: NodeType) => boolean;
15
- export declare const isLayoutNodeType: (nodeType: NodeType) => boolean;
16
- export declare const isLayoutNode: (node: PMNode) => boolean;
17
- /**
18
- * Check if a node should be extracted as a standalone block node
19
- * rather than converted to inline content
20
- */
21
- export declare const isBlockNodeForExtraction: (node: PMNode) => boolean;
22
- /**
23
- * Get a function that checks if content is supported in the target container type
24
- */
25
- export declare const getContentSupportChecker: (targetNodeType: NodeType) => ((node: PMNode) => boolean);
26
- /**
27
- * Convert a node to inline content that can be placed in a paragraph
28
- */
29
- export declare const convertNodeToInlineContent: (node: PMNode, schema: Schema) => PMNode[];
30
- /**
31
- * Filter marks from content based on the target node type
32
- * @param content The content fragment to filter
33
- * @param targetNodeType The target node type to check against
34
- * @returns A new fragment with marks filtered for the target node type
35
- */
36
- export declare const filterMarksForTargetNodeType: (content: Fragment, targetNodeType: NodeType) => Fragment;
37
- /** * Convert content from a code block node into multiple paragraph nodes
38
- */
39
- export declare const convertCodeBlockContentToParagraphs: (codeBlockNode: PMNode, schema: Schema) => PMNode[];
40
- export declare const getMarksWithBreakout: (sourceNode: PMNode, targetNodeType: NodeType) => readonly Mark[];
41
- /**
42
- * Determines the conversion type based on source and target node types
43
- * This is for analytics use - these types match existing analytics events for consistency
44
- */
45
- export declare const getConversionType: (from: string, to: string) => "blockNodeInserted" | "listInserted" | "listConverted" | "textFormatted" | undefined;
@@ -1,5 +0,0 @@
1
- import type { TransformFunction } from './types';
2
- /**
3
- * Transform block nodes (paragraph, heading, codeblock)
4
- */
5
- export declare const transformBlockNode: TransformFunction;
@@ -1,20 +0,0 @@
1
- import type { TransformContext } from '@atlaskit/editor-common/transforms';
2
- import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
- import type { TransformFunction } from './types';
4
- /**
5
- * Transform selection to container type
6
- */
7
- export declare const transformToContainer: ({ tr, sourceNode, targetNodeType, targetAttrs, }: TransformContext) => Transaction | null;
8
- /**
9
- * Transform container nodes (panel, expand, blockquote)
10
- */
11
- export declare const transformContainerNode: TransformFunction;
12
- /**
13
- * Unwrap container node and convert content to block type
14
- */
15
- export declare const unwrapAndConvertToBlockType: (context: TransformContext) => Transaction;
16
- /**
17
- * Unwrap container node and convert content to list
18
- */
19
- export declare const unwrapAndConvertToList: ({ tr, sourceNode, sourcePos, targetNodeType, targetAttrs, }: TransformContext) => Transaction | null;
20
- export declare const transformBetweenContainerTypes: (context: TransformContext) => Transaction;
@@ -1,6 +0,0 @@
1
- import type { Fragment, Schema, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- export declare const getInlineNodeTextContent: (sourceContent: Fragment) => {
3
- inlineTextContent: string;
4
- invalidContent: PMNode[];
5
- };
6
- export declare const getInlineNodeTextNode: (sourceContent: Fragment, schema: Schema) => PMNode;