@atlaskit/editor-plugin-block-menu 5.2.2 → 5.2.4

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 (45) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/editor-commands/transform-node-utils/{flattenListStep.js → steps/flattenListStep.js} +3 -5
  3. package/dist/cjs/editor-commands/transform-node-utils/steps/listToListStep.js +232 -0
  4. package/dist/cjs/editor-commands/transform-node-utils/{wrapMixedContentStep.js → steps/wrapMixedContentStep.js} +25 -25
  5. package/dist/cjs/editor-commands/transform-node-utils/transform.js +14 -17
  6. package/dist/es2019/editor-commands/transform-node-utils/{flattenListStep.js → steps/flattenListStep.js} +3 -5
  7. package/dist/es2019/editor-commands/transform-node-utils/steps/listToListStep.js +225 -0
  8. package/dist/es2019/editor-commands/transform-node-utils/{wrapMixedContentStep.js → steps/wrapMixedContentStep.js} +25 -22
  9. package/dist/es2019/editor-commands/transform-node-utils/transform.js +14 -17
  10. package/dist/esm/editor-commands/transform-node-utils/{flattenListStep.js → steps/flattenListStep.js} +3 -5
  11. package/dist/esm/editor-commands/transform-node-utils/steps/listToListStep.js +226 -0
  12. package/dist/esm/editor-commands/transform-node-utils/{wrapMixedContentStep.js → steps/wrapMixedContentStep.js} +25 -24
  13. package/dist/esm/editor-commands/transform-node-utils/transform.js +14 -17
  14. package/dist/{types-ts4.5/editor-commands/transform-node-utils → types/editor-commands/transform-node-utils/steps}/flattenListStep.d.ts +1 -1
  15. package/dist/types/editor-commands/transform-node-utils/steps/listToListStep.d.ts +65 -0
  16. package/dist/types/editor-commands/transform-node-utils/{unwrapListStep.d.ts → steps/unwrapListStep.d.ts} +1 -1
  17. package/dist/types/editor-commands/transform-node-utils/{wrapMixedContentStep.d.ts → steps/wrapMixedContentStep.d.ts} +1 -1
  18. package/dist/{types/editor-commands/transform-node-utils → types-ts4.5/editor-commands/transform-node-utils/steps}/flattenListStep.d.ts +1 -1
  19. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/listToListStep.d.ts +65 -0
  20. package/dist/types-ts4.5/editor-commands/transform-node-utils/{unwrapListStep.d.ts → steps/unwrapListStep.d.ts} +1 -1
  21. package/dist/types-ts4.5/editor-commands/transform-node-utils/{wrapMixedContentStep.d.ts → steps/wrapMixedContentStep.d.ts} +1 -1
  22. package/package.json +1 -1
  23. package/dist/cjs/editor-commands/transform-node-utils/steps/convertBulletListToTextStep.js +0 -34
  24. package/dist/cjs/editor-commands/transform-node-utils/steps/convertOrderedListToTextStep.js +0 -62
  25. package/dist/cjs/editor-commands/transform-node-utils/steps/convertTaskListToTextStep.js +0 -39
  26. package/dist/cjs/editor-commands/transform-node-utils/steps/createListToTextStep.js +0 -90
  27. package/dist/es2019/editor-commands/transform-node-utils/steps/convertBulletListToTextStep.js +0 -27
  28. package/dist/es2019/editor-commands/transform-node-utils/steps/convertOrderedListToTextStep.js +0 -55
  29. package/dist/es2019/editor-commands/transform-node-utils/steps/convertTaskListToTextStep.js +0 -34
  30. package/dist/es2019/editor-commands/transform-node-utils/steps/createListToTextStep.js +0 -86
  31. package/dist/esm/editor-commands/transform-node-utils/steps/convertBulletListToTextStep.js +0 -29
  32. package/dist/esm/editor-commands/transform-node-utils/steps/convertOrderedListToTextStep.js +0 -57
  33. package/dist/esm/editor-commands/transform-node-utils/steps/convertTaskListToTextStep.js +0 -34
  34. package/dist/esm/editor-commands/transform-node-utils/steps/createListToTextStep.js +0 -85
  35. package/dist/types/editor-commands/transform-node-utils/steps/convertBulletListToTextStep.d.ts +0 -18
  36. package/dist/types/editor-commands/transform-node-utils/steps/convertOrderedListToTextStep.d.ts +0 -19
  37. package/dist/types/editor-commands/transform-node-utils/steps/convertTaskListToTextStep.d.ts +0 -22
  38. package/dist/types/editor-commands/transform-node-utils/steps/createListToTextStep.d.ts +0 -38
  39. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/convertBulletListToTextStep.d.ts +0 -18
  40. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/convertOrderedListToTextStep.d.ts +0 -19
  41. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/convertTaskListToTextStep.d.ts +0 -22
  42. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/createListToTextStep.d.ts +0 -38
  43. /package/dist/cjs/editor-commands/transform-node-utils/{unwrapListStep.js → steps/unwrapListStep.js} +0 -0
  44. /package/dist/es2019/editor-commands/transform-node-utils/{unwrapListStep.js → steps/unwrapListStep.js} +0 -0
  45. /package/dist/esm/editor-commands/transform-node-utils/{unwrapListStep.js → steps/unwrapListStep.js} +0 -0
@@ -1,85 +0,0 @@
1
- import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
-
3
- /**
4
- * Configuration for creating a list-to-text transformation step.
5
- */
6
-
7
- /**
8
- * Recursively extracts list items from a list (including nested lists)
9
- * and converts them to paragraphs with configurable prefixes and indentation.
10
- */
11
- var extractListItemsAsParagraphs = function extractListItemsAsParagraphs(node, schema, config) {
12
- var paragraphs = [];
13
- var paragraphType = schema.nodes.paragraph;
14
- var listType = schema.nodes[config.listTypeName];
15
- var itemType = schema.nodes[config.itemTypeName];
16
- var _extract = function extract(currentNode) {
17
- var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
18
- var itemIndex = 0;
19
- currentNode.forEach(function (child) {
20
- if (child.type === itemType) {
21
- itemIndex++;
22
- var indent = config.indent.repeat(depth);
23
- var prefix = config.getPrefix(depth, itemIndex, child);
24
- var listPrefix = schema.text("".concat(indent).concat(prefix));
25
-
26
- // Collect inline content and nested lists separately
27
- var inlineContent = [];
28
- var nestedLists = [];
29
- child.forEach(function (grandChild) {
30
- if (grandChild.type === listType) {
31
- nestedLists.push(grandChild);
32
- } else if (config.unwrapParagraphContent && grandChild.type === paragraphType) {
33
- // Extract content from paragraph nodes
34
- grandChild.forEach(function (content) {
35
- inlineContent.push(content);
36
- });
37
- } else {
38
- inlineContent.push(grandChild);
39
- }
40
- });
41
-
42
- // Create paragraph with prefix + inline content
43
- if (inlineContent.length > 0) {
44
- var newContent = Fragment.from(listPrefix).append(Fragment.fromArray(inlineContent));
45
- var newParagraph = paragraphType.create({}, newContent);
46
- paragraphs.push(newParagraph);
47
- }
48
-
49
- // Recursively process nested lists with increased depth
50
- nestedLists.forEach(function (nestedList) {
51
- _extract(nestedList, depth + 1);
52
- });
53
- } else if (child.type === listType) {
54
- // Handle list that appears directly as a sibling
55
- _extract(child, depth + 1);
56
- }
57
- });
58
- };
59
- _extract(node, 0);
60
- return paragraphs;
61
- };
62
-
63
- /**
64
- * Creates a TransformStep that converts a list to paragraphs with text prefixes.
65
- *
66
- * Given an array of nodes, processes each list by converting its items
67
- * to paragraphs with configurable prefixes.
68
- *
69
- * Handles nested lists recursively with configurable indentation per level.
70
- *
71
- * @param config - Configuration for the list-to-text transformation
72
- * @returns A TransformStep function
73
- */
74
- export var createListToTextStep = function createListToTextStep(config) {
75
- return function (nodes, context) {
76
- var schema = context.schema;
77
- var listType = schema.nodes[config.listTypeName];
78
- return nodes.flatMap(function (node) {
79
- if (node.type === listType) {
80
- return extractListItemsAsParagraphs(node, schema, config);
81
- }
82
- return node;
83
- });
84
- };
85
- };
@@ -1,18 +0,0 @@
1
- /**
2
- * Given an array of nodes, processes each bullet list by converting its items
3
- * to paragraphs with "- " prefix.
4
- *
5
- * Handles nested bullet lists recursively with 3-space indentation per level.
6
- *
7
- * @example
8
- * Input:
9
- * - bulletList()(
10
- * listItem()(p()('Item 1')),
11
- * bulletList()(listItem()(p()('Sub item 1')))
12
- * )
13
- *
14
- * Output:
15
- * - p()('- Item 1')
16
- * - p()(' - Sub item 1')
17
- */
18
- export declare const convertBulletListToTextStep: import("../types").TransformStep;
@@ -1,19 +0,0 @@
1
- /**
2
- * Given an array of nodes, processes each ordered list by converting its items
3
- * to paragraphs with numbered prefixes (1., 2., 3.) at the top level and
4
- * lettered prefixes (a., b., c.) for nested levels.
5
- *
6
- * Handles nested ordered lists recursively with 3-space indentation per level.
7
- *
8
- * @example
9
- * Input:
10
- * - orderedList({ order: 1 })(
11
- * listItem()(p()('Item 1')),
12
- * orderedList({ order: 1 })(listItem()(p()('Sub item 1')))
13
- * )
14
- *
15
- * Output:
16
- * - p()('1. Item 1')
17
- * - p()(' a. Sub item 1')
18
- */
19
- export declare const convertOrderedListToTextStep: import("../types").TransformStep;
@@ -1,22 +0,0 @@
1
- /**
2
- * Given an array of nodes, processes each task list by converting its items
3
- * to paragraphs with a checkbox prefix. Uses "[] " for unchecked (TODO) tasks
4
- * and "[x] " for checked (DONE) tasks.
5
- *
6
- * Handles nested task lists recursively with 4-space indentation per level.
7
- *
8
- * This is used when converting a task list to a container that doesn't support
9
- * task items (like blockquote).
10
- *
11
- * @example
12
- * Input:
13
- * - taskList()(
14
- * taskItem({ state: 'TODO' })('Task list item'),
15
- * taskList()(taskItem({ state: 'DONE' })('Nested done task'))
16
- * )
17
- *
18
- * Output:
19
- * - p()('[] Task list item')
20
- * - p()(' [x] Nested done task')
21
- */
22
- export declare const convertTaskListToTextStep: import("../types").TransformStep;
@@ -1,38 +0,0 @@
1
- import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import type { TransformStep } from '../types';
3
- /**
4
- * Configuration for creating a list-to-text transformation step.
5
- */
6
- export interface ListToTextConfig {
7
- /**
8
- * Generate prefix text for a list item.
9
- * @param depth - Nesting depth (0 = top level)
10
- * @param index - 1-based index within current list
11
- * @param itemNode - The item node (for reading attrs like task state)
12
- */
13
- getPrefix: (depth: number, index: number, itemNode: PMNode) => string;
14
- /** Indentation string per nesting level (e.g., ' ' for 3 spaces) */
15
- indent: string;
16
- /** Name of the item node type (e.g., 'listItem', 'taskItem') */
17
- itemTypeName: string;
18
- /** Name of the list node type (e.g., 'bulletList', 'orderedList', 'taskList') */
19
- listTypeName: string;
20
- /**
21
- * Whether to unwrap content from paragraph children.
22
- * - bullet/ordered lists = true (content is wrapped in paragraphs)
23
- * - task lists = false (inline content is a direct child)
24
- */
25
- unwrapParagraphContent: boolean;
26
- }
27
- /**
28
- * Creates a TransformStep that converts a list to paragraphs with text prefixes.
29
- *
30
- * Given an array of nodes, processes each list by converting its items
31
- * to paragraphs with configurable prefixes.
32
- *
33
- * Handles nested lists recursively with configurable indentation per level.
34
- *
35
- * @param config - Configuration for the list-to-text transformation
36
- * @returns A TransformStep function
37
- */
38
- export declare const createListToTextStep: (config: ListToTextConfig) => TransformStep;
@@ -1,18 +0,0 @@
1
- /**
2
- * Given an array of nodes, processes each bullet list by converting its items
3
- * to paragraphs with "- " prefix.
4
- *
5
- * Handles nested bullet lists recursively with 3-space indentation per level.
6
- *
7
- * @example
8
- * Input:
9
- * - bulletList()(
10
- * listItem()(p()('Item 1')),
11
- * bulletList()(listItem()(p()('Sub item 1')))
12
- * )
13
- *
14
- * Output:
15
- * - p()('- Item 1')
16
- * - p()(' - Sub item 1')
17
- */
18
- export declare const convertBulletListToTextStep: import("../types").TransformStep;
@@ -1,19 +0,0 @@
1
- /**
2
- * Given an array of nodes, processes each ordered list by converting its items
3
- * to paragraphs with numbered prefixes (1., 2., 3.) at the top level and
4
- * lettered prefixes (a., b., c.) for nested levels.
5
- *
6
- * Handles nested ordered lists recursively with 3-space indentation per level.
7
- *
8
- * @example
9
- * Input:
10
- * - orderedList({ order: 1 })(
11
- * listItem()(p()('Item 1')),
12
- * orderedList({ order: 1 })(listItem()(p()('Sub item 1')))
13
- * )
14
- *
15
- * Output:
16
- * - p()('1. Item 1')
17
- * - p()(' a. Sub item 1')
18
- */
19
- export declare const convertOrderedListToTextStep: import("../types").TransformStep;
@@ -1,22 +0,0 @@
1
- /**
2
- * Given an array of nodes, processes each task list by converting its items
3
- * to paragraphs with a checkbox prefix. Uses "[] " for unchecked (TODO) tasks
4
- * and "[x] " for checked (DONE) tasks.
5
- *
6
- * Handles nested task lists recursively with 4-space indentation per level.
7
- *
8
- * This is used when converting a task list to a container that doesn't support
9
- * task items (like blockquote).
10
- *
11
- * @example
12
- * Input:
13
- * - taskList()(
14
- * taskItem({ state: 'TODO' })('Task list item'),
15
- * taskList()(taskItem({ state: 'DONE' })('Nested done task'))
16
- * )
17
- *
18
- * Output:
19
- * - p()('[] Task list item')
20
- * - p()(' [x] Nested done task')
21
- */
22
- export declare const convertTaskListToTextStep: import("../types").TransformStep;
@@ -1,38 +0,0 @@
1
- import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import type { TransformStep } from '../types';
3
- /**
4
- * Configuration for creating a list-to-text transformation step.
5
- */
6
- export interface ListToTextConfig {
7
- /**
8
- * Generate prefix text for a list item.
9
- * @param depth - Nesting depth (0 = top level)
10
- * @param index - 1-based index within current list
11
- * @param itemNode - The item node (for reading attrs like task state)
12
- */
13
- getPrefix: (depth: number, index: number, itemNode: PMNode) => string;
14
- /** Indentation string per nesting level (e.g., ' ' for 3 spaces) */
15
- indent: string;
16
- /** Name of the item node type (e.g., 'listItem', 'taskItem') */
17
- itemTypeName: string;
18
- /** Name of the list node type (e.g., 'bulletList', 'orderedList', 'taskList') */
19
- listTypeName: string;
20
- /**
21
- * Whether to unwrap content from paragraph children.
22
- * - bullet/ordered lists = true (content is wrapped in paragraphs)
23
- * - task lists = false (inline content is a direct child)
24
- */
25
- unwrapParagraphContent: boolean;
26
- }
27
- /**
28
- * Creates a TransformStep that converts a list to paragraphs with text prefixes.
29
- *
30
- * Given an array of nodes, processes each list by converting its items
31
- * to paragraphs with configurable prefixes.
32
- *
33
- * Handles nested lists recursively with configurable indentation per level.
34
- *
35
- * @param config - Configuration for the list-to-text transformation
36
- * @returns A TransformStep function
37
- */
38
- export declare const createListToTextStep: (config: ListToTextConfig) => TransformStep;