@atlaskit/editor-plugin-block-menu 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/cjs/editor-commands/transforms/block-transforms.js +1 -1
- package/dist/cjs/editor-commands/transforms/container-transforms.js +8 -25
- package/dist/cjs/editor-commands/transforms/inline-node-transforms.js +9 -7
- package/dist/cjs/editor-commands/transforms/layout/utils.js +289 -0
- package/dist/cjs/editor-commands/transforms/layout-transforms.js +40 -2
- package/dist/cjs/editor-commands/transforms/list/transformBetweenListTypes.js +92 -50
- package/dist/cjs/editor-commands/transforms/list-transforms.js +7 -0
- package/dist/cjs/editor-commands/transforms/transformNodeToTargetType.js +3 -0
- package/dist/cjs/editor-commands/transforms/utils.js +40 -1
- package/dist/es2019/editor-commands/transforms/block-transforms.js +2 -2
- package/dist/es2019/editor-commands/transforms/container-transforms.js +8 -23
- package/dist/es2019/editor-commands/transforms/inline-node-transforms.js +8 -6
- package/dist/es2019/editor-commands/transforms/layout/utils.js +272 -0
- package/dist/es2019/editor-commands/transforms/layout-transforms.js +40 -1
- package/dist/es2019/editor-commands/transforms/list/transformBetweenListTypes.js +94 -51
- package/dist/es2019/editor-commands/transforms/list-transforms.js +7 -0
- package/dist/es2019/editor-commands/transforms/transformNodeToTargetType.js +5 -2
- package/dist/es2019/editor-commands/transforms/utils.js +39 -0
- package/dist/esm/editor-commands/transforms/block-transforms.js +2 -2
- package/dist/esm/editor-commands/transforms/container-transforms.js +8 -25
- package/dist/esm/editor-commands/transforms/inline-node-transforms.js +8 -6
- package/dist/esm/editor-commands/transforms/layout/utils.js +282 -0
- package/dist/esm/editor-commands/transforms/layout-transforms.js +38 -1
- package/dist/esm/editor-commands/transforms/list/transformBetweenListTypes.js +92 -49
- package/dist/esm/editor-commands/transforms/list-transforms.js +7 -0
- package/dist/esm/editor-commands/transforms/transformNodeToTargetType.js +5 -2
- package/dist/esm/editor-commands/transforms/utils.js +39 -0
- package/dist/types/editor-commands/transforms/inline-node-transforms.d.ts +3 -3
- package/dist/types/editor-commands/transforms/layout/utils.d.ts +5 -0
- package/dist/types/editor-commands/transforms/layout-transforms.d.ts +1 -0
- package/dist/types/editor-commands/transforms/list/transformBetweenListTypes.d.ts +13 -0
- package/dist/types/editor-commands/transforms/utils.d.ts +13 -0
- package/dist/types-ts4.5/editor-commands/transforms/inline-node-transforms.d.ts +3 -3
- package/dist/types-ts4.5/editor-commands/transforms/layout/utils.d.ts +5 -0
- package/dist/types-ts4.5/editor-commands/transforms/layout-transforms.d.ts +1 -0
- package/dist/types-ts4.5/editor-commands/transforms/list/transformBetweenListTypes.d.ts +13 -0
- package/dist/types-ts4.5/editor-commands/transforms/utils.d.ts +13 -0
- package/package.json +2 -2
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2
5
|
import { getSupportedListTypesSet, isBulletOrOrderedList, isTaskList } from '../utils';
|
|
3
6
|
|
|
4
7
|
/**
|
|
@@ -15,10 +18,87 @@ var convertBlockToInlineContent = function convertBlockToInlineContent(node, sch
|
|
|
15
18
|
}
|
|
16
19
|
return [node];
|
|
17
20
|
};
|
|
21
|
+
var _transformListRecursively = function transformListRecursively(props) {
|
|
22
|
+
var transformedItems = [];
|
|
23
|
+
var listNode = props.listNode,
|
|
24
|
+
isSourceBulletOrOrdered = props.isSourceBulletOrOrdered,
|
|
25
|
+
isTargetBulletOrOrdered = props.isTargetBulletOrOrdered,
|
|
26
|
+
isSourceTask = props.isSourceTask,
|
|
27
|
+
isTargetTask = props.isTargetTask,
|
|
28
|
+
supportedListTypes = props.supportedListTypes,
|
|
29
|
+
schema = props.schema,
|
|
30
|
+
targetNodeType = props.targetNodeType;
|
|
31
|
+
var _schema$nodes = schema.nodes,
|
|
32
|
+
taskList = _schema$nodes.taskList,
|
|
33
|
+
listItem = _schema$nodes.listItem,
|
|
34
|
+
taskItem = _schema$nodes.taskItem,
|
|
35
|
+
paragraph = _schema$nodes.paragraph;
|
|
36
|
+
listNode.forEach(function (child) {
|
|
37
|
+
if (isSourceBulletOrOrdered && isTargetTask) {
|
|
38
|
+
// Convert bullet/ordered => task
|
|
39
|
+
if (child.type === listItem) {
|
|
40
|
+
var inlineContent = [];
|
|
41
|
+
var nestedTaskLists = [];
|
|
42
|
+
child.forEach(function (grandChild) {
|
|
43
|
+
if (supportedListTypes.has(grandChild.type) && grandChild.type !== taskList) {
|
|
44
|
+
nestedTaskLists.push(_transformListRecursively(_objectSpread(_objectSpread({}, props), {}, {
|
|
45
|
+
listNode: grandChild
|
|
46
|
+
})));
|
|
47
|
+
} else {
|
|
48
|
+
inlineContent.push.apply(inlineContent, _toConsumableArray(convertBlockToInlineContent(grandChild, schema)));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
if (inlineContent.length > 0) {
|
|
52
|
+
transformedItems.push(taskItem.create(null, inlineContent));
|
|
53
|
+
}
|
|
54
|
+
transformedItems.push.apply(transformedItems, nestedTaskLists);
|
|
55
|
+
}
|
|
56
|
+
} else if (isSourceTask && isTargetBulletOrOrdered) {
|
|
57
|
+
// Convert task => bullet/ordered
|
|
58
|
+
if (child.type === taskItem) {
|
|
59
|
+
var _inlineContent = _toConsumableArray(child.content.content);
|
|
60
|
+
if (_inlineContent.length > 0) {
|
|
61
|
+
var paragraphNode = paragraph.create(null, _inlineContent);
|
|
62
|
+
transformedItems.push(listItem.create(null, [paragraphNode]));
|
|
63
|
+
}
|
|
64
|
+
} else if (child.type === taskList) {
|
|
65
|
+
var transformedNestedList = _transformListRecursively(_objectSpread(_objectSpread({}, props), {}, {
|
|
66
|
+
listNode: child
|
|
67
|
+
}));
|
|
68
|
+
var lastItem = transformedItems[transformedItems.length - 1];
|
|
69
|
+
if ((lastItem === null || lastItem === void 0 ? void 0 : lastItem.type) === listItem) {
|
|
70
|
+
// Attach nested list to previous item
|
|
71
|
+
var updatedContent = [].concat(_toConsumableArray(lastItem.content.content), [transformedNestedList]);
|
|
72
|
+
transformedItems[transformedItems.length - 1] = listItem.create(lastItem.attrs, updatedContent);
|
|
73
|
+
} else {
|
|
74
|
+
// No previous item, flatten nested items
|
|
75
|
+
transformedItems.push.apply(transformedItems, _toConsumableArray(transformedNestedList.content.content));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
} else if (isSourceBulletOrOrdered && isTargetBulletOrOrdered) {
|
|
79
|
+
if (child.type === listItem) {
|
|
80
|
+
var convertedNestedLists = [];
|
|
81
|
+
child.forEach(function (grandChild) {
|
|
82
|
+
if (supportedListTypes.has(grandChild.type) && grandChild.type !== targetNodeType) {
|
|
83
|
+
var convertedNode = _transformListRecursively(_objectSpread(_objectSpread({}, props), {}, {
|
|
84
|
+
listNode: grandChild
|
|
85
|
+
}));
|
|
86
|
+
convertedNestedLists.push(convertedNode);
|
|
87
|
+
} else {
|
|
88
|
+
convertedNestedLists.push(grandChild);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
transformedItems.push(listItem.create(null, convertedNestedLists));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return targetNodeType.create(null, transformedItems);
|
|
96
|
+
};
|
|
18
97
|
|
|
19
98
|
/**
|
|
20
99
|
* Transform list structure between different list types
|
|
21
100
|
*/
|
|
101
|
+
export { _transformListRecursively as transformListRecursively };
|
|
22
102
|
export var transformListStructure = function transformListStructure(context) {
|
|
23
103
|
var tr = context.tr,
|
|
24
104
|
sourceNode = context.sourceNode,
|
|
@@ -32,60 +112,23 @@ export var transformListStructure = function transformListStructure(context) {
|
|
|
32
112
|
};
|
|
33
113
|
var sourceList = listNode.node,
|
|
34
114
|
listPos = listNode.pos;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
taskItem = nodes.taskItem,
|
|
38
|
-
paragraph = nodes.paragraph;
|
|
115
|
+
// const { taskList, listItem, taskItem, paragraph } = nodes;
|
|
116
|
+
|
|
39
117
|
var isSourceBulletOrOrdered = isBulletOrOrderedList(sourceList.type);
|
|
40
118
|
var isTargetTask = isTaskList(targetNodeType);
|
|
41
119
|
var isSourceTask = isTaskList(sourceList.type);
|
|
42
120
|
var isTargetBulletOrOrdered = isBulletOrOrderedList(targetNodeType);
|
|
43
121
|
var supportedListTypes = getSupportedListTypesSet(nodes);
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
nestedTaskLists.push(_transformListRecursively(grandChild));
|
|
55
|
-
} else {
|
|
56
|
-
inlineContent.push.apply(inlineContent, _toConsumableArray(convertBlockToInlineContent(grandChild, tr.doc.type.schema)));
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
if (inlineContent.length > 0) {
|
|
60
|
-
transformedItems.push(taskItem.create(null, inlineContent));
|
|
61
|
-
}
|
|
62
|
-
transformedItems.push.apply(transformedItems, nestedTaskLists);
|
|
63
|
-
}
|
|
64
|
-
} else if (isSourceTask && isTargetBulletOrOrdered) {
|
|
65
|
-
// Convert task => bullet/ordered
|
|
66
|
-
if (child.type === taskItem) {
|
|
67
|
-
var _inlineContent = _toConsumableArray(child.content.content);
|
|
68
|
-
if (_inlineContent.length > 0) {
|
|
69
|
-
var paragraphNode = paragraph.create(null, _inlineContent);
|
|
70
|
-
transformedItems.push(listItem.create(null, [paragraphNode]));
|
|
71
|
-
}
|
|
72
|
-
} else if (child.type === taskList) {
|
|
73
|
-
var transformedNestedList = _transformListRecursively(child);
|
|
74
|
-
var lastItem = transformedItems[transformedItems.length - 1];
|
|
75
|
-
if ((lastItem === null || lastItem === void 0 ? void 0 : lastItem.type) === listItem) {
|
|
76
|
-
// Attach nested list to previous item
|
|
77
|
-
var updatedContent = [].concat(_toConsumableArray(lastItem.content.content), [transformedNestedList]);
|
|
78
|
-
transformedItems[transformedItems.length - 1] = listItem.create(lastItem.attrs, updatedContent);
|
|
79
|
-
} else {
|
|
80
|
-
// No previous item, flatten nested items
|
|
81
|
-
transformedItems.push.apply(transformedItems, _toConsumableArray(transformedNestedList.content.content));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
return targetNodeType.create(null, transformedItems);
|
|
87
|
-
};
|
|
88
|
-
var newList = _transformListRecursively(sourceList);
|
|
122
|
+
var newList = _transformListRecursively({
|
|
123
|
+
isSourceBulletOrOrdered: isSourceBulletOrOrdered,
|
|
124
|
+
isSourceTask: isSourceTask,
|
|
125
|
+
isTargetBulletOrOrdered: isTargetBulletOrOrdered,
|
|
126
|
+
isTargetTask: isTargetTask,
|
|
127
|
+
listNode: sourceList,
|
|
128
|
+
schema: tr.doc.type.schema,
|
|
129
|
+
supportedListTypes: supportedListTypes,
|
|
130
|
+
targetNodeType: targetNodeType
|
|
131
|
+
});
|
|
89
132
|
tr.replaceWith(listPos, listPos + sourceList.nodeSize, newList);
|
|
90
133
|
return tr;
|
|
91
134
|
} catch (_unused) {
|
|
@@ -18,6 +18,7 @@ export var transformBlockToList = function transformBlockToList(context) {
|
|
|
18
18
|
var _tr$selection = tr.selection,
|
|
19
19
|
$from = _tr$selection.$from,
|
|
20
20
|
$to = _tr$selection.$to;
|
|
21
|
+
var schema = tr.doc.type.schema;
|
|
21
22
|
var range = $from.blockRange($to);
|
|
22
23
|
if (!range) {
|
|
23
24
|
return null;
|
|
@@ -30,6 +31,12 @@ export var transformBlockToList = function transformBlockToList(context) {
|
|
|
30
31
|
return transformToTaskList(tr, range, targetNodeType, targetAttrs, nodes);
|
|
31
32
|
}
|
|
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
|
+
|
|
33
40
|
// For headings, convert to paragraph first since headings cannot be direct children of list items
|
|
34
41
|
if (sourceNode && sourceNode.type.name.startsWith('heading')) {
|
|
35
42
|
tr.setBlockType(range.start, range.end, nodes.paragraph);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { transformBlockNode } from './block-transforms';
|
|
2
2
|
import { transformContainerNode, unwrapAndConvertToList } from './container-transforms';
|
|
3
|
-
import { convertToLayout } from './layout-transforms';
|
|
3
|
+
import { convertToLayout, transformLayoutNode } from './layout-transforms';
|
|
4
4
|
import { transformListNode } from './list-transforms';
|
|
5
|
-
import { getTargetNodeInfo, isBlockNode, isListNode, isListNodeType, isContainerNode, isLayoutNodeType } from './utils';
|
|
5
|
+
import { getTargetNodeInfo, isBlockNode, isListNode, isListNodeType, isContainerNode, isLayoutNodeType, isLayoutNode } from './utils';
|
|
6
6
|
export function transformNodeToTargetType(tr, sourceNode, sourcePos, targetType) {
|
|
7
7
|
var nodes = tr.doc.type.schema.nodes;
|
|
8
8
|
var targetNodeInfo = getTargetNodeInfo(targetType, nodes);
|
|
@@ -46,6 +46,9 @@ export function transformNodeToTargetType(tr, sourceNode, sourcePos, targetType)
|
|
|
46
46
|
if (sourceNode.type.name === 'codeBlock' && isListNodeType(targetNodeType)) {
|
|
47
47
|
return unwrapAndConvertToList(transformationContext);
|
|
48
48
|
}
|
|
49
|
+
if (isLayoutNode(sourceNode)) {
|
|
50
|
+
return transformLayoutNode(transformationContext);
|
|
51
|
+
}
|
|
49
52
|
if (isBlockNode(sourceNode)) {
|
|
50
53
|
return transformBlockNode(transformationContext);
|
|
51
54
|
}
|
|
@@ -91,6 +91,9 @@ export var getTargetNodeInfo = function getTargetNodeInfo(targetType, nodes) {
|
|
|
91
91
|
export var isBlockNode = function isBlockNode(node) {
|
|
92
92
|
return ['paragraph', 'heading', 'codeBlock'].includes(node.type.name);
|
|
93
93
|
};
|
|
94
|
+
export var isHeadingOrParagraphNode = function isHeadingOrParagraphNode(node) {
|
|
95
|
+
return ['paragraph', 'heading'].includes(node.type.name);
|
|
96
|
+
};
|
|
94
97
|
export var isListNode = function isListNode(node) {
|
|
95
98
|
return ['bulletList', 'orderedList', 'taskList'].includes(node.type.name);
|
|
96
99
|
};
|
|
@@ -123,6 +126,9 @@ export var getSupportedListTypesSet = function getSupportedListTypesSet(nodes) {
|
|
|
123
126
|
export var isLayoutNodeType = function isLayoutNodeType(nodeType) {
|
|
124
127
|
return nodeType.name === 'layoutSection';
|
|
125
128
|
};
|
|
129
|
+
export var isLayoutNode = function isLayoutNode(node) {
|
|
130
|
+
return node.type.name === 'layoutSection';
|
|
131
|
+
};
|
|
126
132
|
|
|
127
133
|
/**
|
|
128
134
|
* Check if a node should be extracted as a standalone block node
|
|
@@ -168,4 +174,37 @@ export var convertNodeToInlineContent = function convertNodeToInlineContent(node
|
|
|
168
174
|
return [schema.text(node.textContent)];
|
|
169
175
|
}
|
|
170
176
|
return inlineNodes;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Filter marks from content based on the target node type
|
|
181
|
+
* @param content The content fragment to filter
|
|
182
|
+
* @param targetNodeType The target node type to check against
|
|
183
|
+
* @returns A new fragment with marks filtered for the target node type
|
|
184
|
+
*/
|
|
185
|
+
export var filterMarksForTargetNodeType = function filterMarksForTargetNodeType(content, targetNodeType) {
|
|
186
|
+
var withValidMarks = [];
|
|
187
|
+
content.forEach(function (node) {
|
|
188
|
+
if (node.marks.length > 0) {
|
|
189
|
+
var allowedMarks = targetNodeType.allowedMarks(node.marks);
|
|
190
|
+
var updatedNode = node.mark(allowedMarks);
|
|
191
|
+
withValidMarks.push(updatedNode);
|
|
192
|
+
} else {
|
|
193
|
+
withValidMarks.push(node);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
return Fragment.from(withValidMarks);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/** * Convert content from a code block node into multiple paragraph nodes
|
|
200
|
+
*/
|
|
201
|
+
export var convertCodeBlockContentToParagraphs = function convertCodeBlockContentToParagraphs(codeBlockNode, schema) {
|
|
202
|
+
var paragraphNodes = [];
|
|
203
|
+
var codeText = codeBlockNode.textContent;
|
|
204
|
+
var lines = codeText.split('\n');
|
|
205
|
+
lines.forEach(function (line) {
|
|
206
|
+
var paragraphNode = schema.nodes.paragraph.create(null, line ? schema.text(line) : null);
|
|
207
|
+
paragraphNodes.push(paragraphNode);
|
|
208
|
+
});
|
|
209
|
+
return paragraphNodes;
|
|
171
210
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
1
|
+
import type { Fragment, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
export declare const getInlineNodeTextContent: (sourceContent: Fragment) => string;
|
|
3
|
+
export declare const getInlineNodeTextNode: (sourceContent: Fragment, schema: Schema) => import("prosemirror-model").Node;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { NodeType, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { TransformContext } from '../types';
|
|
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) => PMNode[];
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { TransformContext } from './types';
|
|
2
2
|
export declare const convertToLayout: (context: TransformContext) => import("prosemirror-state").Transaction;
|
|
3
|
+
export declare const transformLayoutNode: (context: TransformContext) => import("prosemirror-state").Transaction;
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
+
import type { NodeType, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
1
2
|
import type { TransformContext } from '../types';
|
|
3
|
+
type TransformListRecursivelyProps = {
|
|
4
|
+
isSourceBulletOrOrdered: boolean;
|
|
5
|
+
isSourceTask: boolean;
|
|
6
|
+
isTargetBulletOrOrdered: boolean;
|
|
7
|
+
isTargetTask: boolean;
|
|
8
|
+
listNode: PMNode;
|
|
9
|
+
schema: Schema;
|
|
10
|
+
supportedListTypes: Set<NodeType>;
|
|
11
|
+
targetNodeType: NodeType;
|
|
12
|
+
};
|
|
13
|
+
export declare const transformListRecursively: (props: TransformListRecursivelyProps) => PMNode;
|
|
2
14
|
/**
|
|
3
15
|
* Transform list structure between different list types
|
|
4
16
|
*/
|
|
5
17
|
export declare const transformListStructure: (context: TransformContext) => import("prosemirror-state").Transaction;
|
|
18
|
+
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Node as PMNode, NodeType, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import type { FormatNodeTargetType } from './types';
|
|
3
4
|
export declare const getTargetNodeInfo: (targetType: FormatNodeTargetType, nodes: Record<string, NodeType>) => {
|
|
4
5
|
attrs?: Record<string, unknown>;
|
|
5
6
|
nodeType: NodeType;
|
|
6
7
|
} | null;
|
|
7
8
|
export declare const isBlockNode: (node: PMNode) => boolean;
|
|
9
|
+
export declare const isHeadingOrParagraphNode: (node: PMNode) => boolean;
|
|
8
10
|
export declare const isListNode: (node: PMNode) => boolean;
|
|
9
11
|
export declare const isContainerNode: (node: PMNode) => boolean;
|
|
10
12
|
export declare const isBlockNodeType: (nodeType: NodeType) => boolean;
|
|
@@ -15,6 +17,7 @@ export declare const isTaskList: (nodeType: NodeType) => boolean;
|
|
|
15
17
|
export declare const getSupportedListTypes: (nodes: Record<string, NodeType>) => NodeType[];
|
|
16
18
|
export declare const getSupportedListTypesSet: (nodes: Record<string, NodeType>) => Set<NodeType>;
|
|
17
19
|
export declare const isLayoutNodeType: (nodeType: NodeType) => boolean;
|
|
20
|
+
export declare const isLayoutNode: (node: PMNode) => boolean;
|
|
18
21
|
/**
|
|
19
22
|
* Check if a node should be extracted as a standalone block node
|
|
20
23
|
* rather than converted to inline content
|
|
@@ -28,3 +31,13 @@ export declare const getContentSupportChecker: (targetNodeType: NodeType) => ((n
|
|
|
28
31
|
* Convert a node to inline content that can be placed in a paragraph
|
|
29
32
|
*/
|
|
30
33
|
export declare const convertNodeToInlineContent: (node: PMNode, schema: Schema) => PMNode[];
|
|
34
|
+
/**
|
|
35
|
+
* Filter marks from content based on the target node type
|
|
36
|
+
* @param content The content fragment to filter
|
|
37
|
+
* @param targetNodeType The target node type to check against
|
|
38
|
+
* @returns A new fragment with marks filtered for the target node type
|
|
39
|
+
*/
|
|
40
|
+
export declare const filterMarksForTargetNodeType: (content: Fragment, targetNodeType: NodeType) => Fragment;
|
|
41
|
+
/** * Convert content from a code block node into multiple paragraph nodes
|
|
42
|
+
*/
|
|
43
|
+
export declare const convertCodeBlockContentToParagraphs: (codeBlockNode: PMNode, schema: Schema) => PMNode[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
1
|
+
import type { Fragment, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
export declare const getInlineNodeTextContent: (sourceContent: Fragment) => string;
|
|
3
|
+
export declare const getInlineNodeTextNode: (sourceContent: Fragment, schema: Schema) => import("prosemirror-model").Node;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { NodeType, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { TransformContext } from '../types';
|
|
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) => PMNode[];
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { TransformContext } from './types';
|
|
2
2
|
export declare const convertToLayout: (context: TransformContext) => import("prosemirror-state").Transaction;
|
|
3
|
+
export declare const transformLayoutNode: (context: TransformContext) => import("prosemirror-state").Transaction;
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
+
import type { NodeType, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
1
2
|
import type { TransformContext } from '../types';
|
|
3
|
+
type TransformListRecursivelyProps = {
|
|
4
|
+
isSourceBulletOrOrdered: boolean;
|
|
5
|
+
isSourceTask: boolean;
|
|
6
|
+
isTargetBulletOrOrdered: boolean;
|
|
7
|
+
isTargetTask: boolean;
|
|
8
|
+
listNode: PMNode;
|
|
9
|
+
schema: Schema;
|
|
10
|
+
supportedListTypes: Set<NodeType>;
|
|
11
|
+
targetNodeType: NodeType;
|
|
12
|
+
};
|
|
13
|
+
export declare const transformListRecursively: (props: TransformListRecursivelyProps) => PMNode;
|
|
2
14
|
/**
|
|
3
15
|
* Transform list structure between different list types
|
|
4
16
|
*/
|
|
5
17
|
export declare const transformListStructure: (context: TransformContext) => import("prosemirror-state").Transaction;
|
|
18
|
+
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Node as PMNode, NodeType, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import type { FormatNodeTargetType } from './types';
|
|
3
4
|
export declare const getTargetNodeInfo: (targetType: FormatNodeTargetType, nodes: Record<string, NodeType>) => {
|
|
4
5
|
attrs?: Record<string, unknown>;
|
|
5
6
|
nodeType: NodeType;
|
|
6
7
|
} | null;
|
|
7
8
|
export declare const isBlockNode: (node: PMNode) => boolean;
|
|
9
|
+
export declare const isHeadingOrParagraphNode: (node: PMNode) => boolean;
|
|
8
10
|
export declare const isListNode: (node: PMNode) => boolean;
|
|
9
11
|
export declare const isContainerNode: (node: PMNode) => boolean;
|
|
10
12
|
export declare const isBlockNodeType: (nodeType: NodeType) => boolean;
|
|
@@ -15,6 +17,7 @@ export declare const isTaskList: (nodeType: NodeType) => boolean;
|
|
|
15
17
|
export declare const getSupportedListTypes: (nodes: Record<string, NodeType>) => NodeType[];
|
|
16
18
|
export declare const getSupportedListTypesSet: (nodes: Record<string, NodeType>) => Set<NodeType>;
|
|
17
19
|
export declare const isLayoutNodeType: (nodeType: NodeType) => boolean;
|
|
20
|
+
export declare const isLayoutNode: (node: PMNode) => boolean;
|
|
18
21
|
/**
|
|
19
22
|
* Check if a node should be extracted as a standalone block node
|
|
20
23
|
* rather than converted to inline content
|
|
@@ -28,3 +31,13 @@ export declare const getContentSupportChecker: (targetNodeType: NodeType) => ((n
|
|
|
28
31
|
* Convert a node to inline content that can be placed in a paragraph
|
|
29
32
|
*/
|
|
30
33
|
export declare const convertNodeToInlineContent: (node: PMNode, schema: Schema) => PMNode[];
|
|
34
|
+
/**
|
|
35
|
+
* Filter marks from content based on the target node type
|
|
36
|
+
* @param content The content fragment to filter
|
|
37
|
+
* @param targetNodeType The target node type to check against
|
|
38
|
+
* @returns A new fragment with marks filtered for the target node type
|
|
39
|
+
*/
|
|
40
|
+
export declare const filterMarksForTargetNodeType: (content: Fragment, targetNodeType: NodeType) => Fragment;
|
|
41
|
+
/** * Convert content from a code block node into multiple paragraph nodes
|
|
42
|
+
*/
|
|
43
|
+
export declare const convertCodeBlockContentToParagraphs: (codeBlockNode: PMNode, schema: Schema) => PMNode[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-menu",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
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.
|
|
49
|
+
"@atlaskit/editor-common": "^108.7.0",
|
|
50
50
|
"react": "^18.2.0",
|
|
51
51
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
52
52
|
},
|