@atlaskit/editor-plugin-block-menu 5.1.10 → 5.2.0

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 (34) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/afm-cc/tsconfig.json +2 -1
  3. package/afm-jira/tsconfig.json +2 -1
  4. package/afm-products/tsconfig.json +2 -1
  5. package/dist/cjs/editor-commands/transform-node-utils/steps/convertBulletListToTextStep.js +34 -0
  6. package/dist/cjs/editor-commands/transform-node-utils/steps/convertOrderedListToTextStep.js +62 -0
  7. package/dist/cjs/editor-commands/transform-node-utils/steps/convertTaskListToTextStep.js +39 -0
  8. package/dist/cjs/editor-commands/transform-node-utils/steps/createListToTextStep.js +90 -0
  9. package/dist/cjs/editor-commands/transform-node-utils/transform.js +22 -1
  10. package/dist/cjs/ui/block-menu.js +13 -6
  11. package/dist/cjs/ui/delete-button.js +3 -3
  12. package/dist/es2019/editor-commands/transform-node-utils/steps/convertBulletListToTextStep.js +27 -0
  13. package/dist/es2019/editor-commands/transform-node-utils/steps/convertOrderedListToTextStep.js +55 -0
  14. package/dist/es2019/editor-commands/transform-node-utils/steps/convertTaskListToTextStep.js +34 -0
  15. package/dist/es2019/editor-commands/transform-node-utils/steps/createListToTextStep.js +86 -0
  16. package/dist/es2019/editor-commands/transform-node-utils/transform.js +22 -1
  17. package/dist/es2019/ui/block-menu.js +13 -6
  18. package/dist/es2019/ui/delete-button.js +4 -4
  19. package/dist/esm/editor-commands/transform-node-utils/steps/convertBulletListToTextStep.js +29 -0
  20. package/dist/esm/editor-commands/transform-node-utils/steps/convertOrderedListToTextStep.js +57 -0
  21. package/dist/esm/editor-commands/transform-node-utils/steps/convertTaskListToTextStep.js +34 -0
  22. package/dist/esm/editor-commands/transform-node-utils/steps/createListToTextStep.js +85 -0
  23. package/dist/esm/editor-commands/transform-node-utils/transform.js +22 -1
  24. package/dist/esm/ui/block-menu.js +13 -6
  25. package/dist/esm/ui/delete-button.js +4 -4
  26. package/dist/types/editor-commands/transform-node-utils/steps/convertBulletListToTextStep.d.ts +18 -0
  27. package/dist/types/editor-commands/transform-node-utils/steps/convertOrderedListToTextStep.d.ts +19 -0
  28. package/dist/types/editor-commands/transform-node-utils/steps/convertTaskListToTextStep.d.ts +22 -0
  29. package/dist/types/editor-commands/transform-node-utils/steps/createListToTextStep.d.ts +38 -0
  30. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/convertBulletListToTextStep.d.ts +18 -0
  31. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/convertOrderedListToTextStep.d.ts +19 -0
  32. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/convertTaskListToTextStep.d.ts +22 -0
  33. package/dist/types-ts4.5/editor-commands/transform-node-utils/steps/createListToTextStep.d.ts +38 -0
  34. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 5.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`0bff72d37394d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0bff72d37394d) -
8
+ [ux] Implement steps for bullet, task, and numbered lists transformations to container nodes
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 5.1.11
15
+
16
+ ### Patch Changes
17
+
18
+ - [`7c295bfea1292`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7c295bfea1292) -
19
+ EDITOR-3380 Use preserved selection when deleting selected range
20
+ - Updated dependencies
21
+
3
22
  ## 5.1.10
4
23
 
5
24
  ### Patch Changes
@@ -4,7 +4,8 @@
4
4
  "target": "es5",
5
5
  "outDir": "../../../../../confluence/tsDist/@atlaskit__editor-plugin-block-menu",
6
6
  "rootDir": "../",
7
- "composite": true
7
+ "composite": true,
8
+ "noCheck": true
8
9
  },
9
10
  "include": [
10
11
  "../src/**/*.ts",
@@ -4,7 +4,8 @@
4
4
  "target": "es5",
5
5
  "outDir": "../../../../../jira/tsDist/@atlaskit__editor-plugin-block-menu/app",
6
6
  "rootDir": "../",
7
- "composite": true
7
+ "composite": true,
8
+ "noCheck": true
8
9
  },
9
10
  "include": [
10
11
  "../src/**/*.ts",
@@ -4,7 +4,8 @@
4
4
  "target": "es5",
5
5
  "outDir": "../../../../../tsDist/@atlaskit__editor-plugin-block-menu/app",
6
6
  "rootDir": "../",
7
- "composite": true
7
+ "composite": true,
8
+ "noCheck": true
8
9
  },
9
10
  "include": [
10
11
  "../src/**/*.ts",
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.convertBulletListToTextStep = void 0;
7
+ var _createListToTextStep = require("./createListToTextStep");
8
+ /**
9
+ * Given an array of nodes, processes each bullet list by converting its items
10
+ * to paragraphs with "- " prefix.
11
+ *
12
+ * Handles nested bullet lists recursively with 3-space indentation per level.
13
+ *
14
+ * @example
15
+ * Input:
16
+ * - bulletList()(
17
+ * listItem()(p()('Item 1')),
18
+ * bulletList()(listItem()(p()('Sub item 1')))
19
+ * )
20
+ *
21
+ * Output:
22
+ * - p()('- Item 1')
23
+ * - p()(' - Sub item 1')
24
+ */
25
+ var convertBulletListToTextStep = exports.convertBulletListToTextStep = (0, _createListToTextStep.createListToTextStep)({
26
+ listTypeName: 'bulletList',
27
+ itemTypeName: 'listItem',
28
+ indent: ' ',
29
+ // 3 spaces per nesting level
30
+ getPrefix: function getPrefix() {
31
+ return '- ';
32
+ },
33
+ unwrapParagraphContent: true
34
+ });
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.convertOrderedListToTextStep = void 0;
7
+ var _createListToTextStep = require("./createListToTextStep");
8
+ /**
9
+ * Converts a number to a letter (1=a, 2=b, etc.)
10
+ * For numbers > 26, continues with aa, ab, etc.
11
+ */
12
+ var numberToLetter = function numberToLetter(num) {
13
+ var result = '';
14
+ var n = num;
15
+ while (n > 0) {
16
+ n--;
17
+ result = String.fromCharCode(97 + n % 26) + result;
18
+ n = Math.floor(n / 26);
19
+ }
20
+ return result;
21
+ };
22
+
23
+ /**
24
+ * Gets the appropriate prefix for an ordered list item based on depth and index.
25
+ * - Level 0: "1. ", "2. ", "3. ", etc.
26
+ * - Level 1+: "a. ", "b. ", "c. ", etc.
27
+ */
28
+ var getOrderedListPrefix = function getOrderedListPrefix(depth, index) {
29
+ if (depth === 0) {
30
+ return "".concat(index, ". ");
31
+ }
32
+ return "".concat(numberToLetter(index), ". ");
33
+ };
34
+
35
+ /**
36
+ * Given an array of nodes, processes each ordered list by converting its items
37
+ * to paragraphs with numbered prefixes (1., 2., 3.) at the top level and
38
+ * lettered prefixes (a., b., c.) for nested levels.
39
+ *
40
+ * Handles nested ordered lists recursively with 3-space indentation per level.
41
+ *
42
+ * @example
43
+ * Input:
44
+ * - orderedList({ order: 1 })(
45
+ * listItem()(p()('Item 1')),
46
+ * orderedList({ order: 1 })(listItem()(p()('Sub item 1')))
47
+ * )
48
+ *
49
+ * Output:
50
+ * - p()('1. Item 1')
51
+ * - p()(' a. Sub item 1')
52
+ */
53
+ var convertOrderedListToTextStep = exports.convertOrderedListToTextStep = (0, _createListToTextStep.createListToTextStep)({
54
+ listTypeName: 'orderedList',
55
+ itemTypeName: 'listItem',
56
+ indent: ' ',
57
+ // 3 spaces per nesting level
58
+ getPrefix: function getPrefix(depth, index) {
59
+ return getOrderedListPrefix(depth, index);
60
+ },
61
+ unwrapParagraphContent: true
62
+ });
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.convertTaskListToTextStep = void 0;
7
+ var _createListToTextStep = require("./createListToTextStep");
8
+ /**
9
+ * Given an array of nodes, processes each task list by converting its items
10
+ * to paragraphs with a checkbox prefix. Uses "[] " for unchecked (TODO) tasks
11
+ * and "[x] " for checked (DONE) tasks.
12
+ *
13
+ * Handles nested task lists recursively with 4-space indentation per level.
14
+ *
15
+ * This is used when converting a task list to a container that doesn't support
16
+ * task items (like blockquote).
17
+ *
18
+ * @example
19
+ * Input:
20
+ * - taskList()(
21
+ * taskItem({ state: 'TODO' })('Task list item'),
22
+ * taskList()(taskItem({ state: 'DONE' })('Nested done task'))
23
+ * )
24
+ *
25
+ * Output:
26
+ * - p()('[] Task list item')
27
+ * - p()(' [x] Nested done task')
28
+ */
29
+ var convertTaskListToTextStep = exports.convertTaskListToTextStep = (0, _createListToTextStep.createListToTextStep)({
30
+ listTypeName: 'taskList',
31
+ itemTypeName: 'taskItem',
32
+ indent: ' ',
33
+ // 4 spaces per nesting level
34
+ getPrefix: function getPrefix(_, __, itemNode) {
35
+ var _itemNode$attrs;
36
+ return ((_itemNode$attrs = itemNode.attrs) === null || _itemNode$attrs === void 0 ? void 0 : _itemNode$attrs.state) === 'DONE' ? '[x] ' : '[] ';
37
+ },
38
+ unwrapParagraphContent: false
39
+ });
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createListToTextStep = void 0;
7
+ var _model = require("@atlaskit/editor-prosemirror/model");
8
+ /**
9
+ * Configuration for creating a list-to-text transformation step.
10
+ */
11
+
12
+ /**
13
+ * Recursively extracts list items from a list (including nested lists)
14
+ * and converts them to paragraphs with configurable prefixes and indentation.
15
+ */
16
+ var extractListItemsAsParagraphs = function extractListItemsAsParagraphs(node, schema, config) {
17
+ var paragraphs = [];
18
+ var paragraphType = schema.nodes.paragraph;
19
+ var listType = schema.nodes[config.listTypeName];
20
+ var itemType = schema.nodes[config.itemTypeName];
21
+ var _extract = function extract(currentNode) {
22
+ var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
23
+ var itemIndex = 0;
24
+ currentNode.forEach(function (child) {
25
+ if (child.type === itemType) {
26
+ itemIndex++;
27
+ var indent = config.indent.repeat(depth);
28
+ var prefix = config.getPrefix(depth, itemIndex, child);
29
+ var listPrefix = schema.text("".concat(indent).concat(prefix));
30
+
31
+ // Collect inline content and nested lists separately
32
+ var inlineContent = [];
33
+ var nestedLists = [];
34
+ child.forEach(function (grandChild) {
35
+ if (grandChild.type === listType) {
36
+ nestedLists.push(grandChild);
37
+ } else if (config.unwrapParagraphContent && grandChild.type === paragraphType) {
38
+ // Extract content from paragraph nodes
39
+ grandChild.forEach(function (content) {
40
+ inlineContent.push(content);
41
+ });
42
+ } else {
43
+ inlineContent.push(grandChild);
44
+ }
45
+ });
46
+
47
+ // Create paragraph with prefix + inline content
48
+ if (inlineContent.length > 0) {
49
+ var newContent = _model.Fragment.from(listPrefix).append(_model.Fragment.fromArray(inlineContent));
50
+ var newParagraph = paragraphType.create({}, newContent);
51
+ paragraphs.push(newParagraph);
52
+ }
53
+
54
+ // Recursively process nested lists with increased depth
55
+ nestedLists.forEach(function (nestedList) {
56
+ _extract(nestedList, depth + 1);
57
+ });
58
+ } else if (child.type === listType) {
59
+ // Handle list that appears directly as a sibling
60
+ _extract(child, depth + 1);
61
+ }
62
+ });
63
+ };
64
+ _extract(node, 0);
65
+ return paragraphs;
66
+ };
67
+
68
+ /**
69
+ * Creates a TransformStep that converts a list to paragraphs with text prefixes.
70
+ *
71
+ * Given an array of nodes, processes each list by converting its items
72
+ * to paragraphs with configurable prefixes.
73
+ *
74
+ * Handles nested lists recursively with configurable indentation per level.
75
+ *
76
+ * @param config - Configuration for the list-to-text transformation
77
+ * @returns A TransformStep function
78
+ */
79
+ var createListToTextStep = exports.createListToTextStep = function createListToTextStep(config) {
80
+ return function (nodes, context) {
81
+ var schema = context.schema;
82
+ var listType = schema.nodes[config.listTypeName];
83
+ return nodes.flatMap(function (node) {
84
+ if (node.type === listType) {
85
+ return extractListItemsAsParagraphs(node, schema, config);
86
+ }
87
+ return node;
88
+ });
89
+ };
90
+ };
@@ -7,6 +7,9 @@ exports.getOutputNodes = void 0;
7
7
  var _utils = require("../transform-node-utils/utils");
8
8
  var _flattenListStep = require("./flattenListStep");
9
9
  var _flattenStep = require("./flattenStep");
10
+ var _convertBulletListToTextStep = require("./steps/convertBulletListToTextStep");
11
+ var _convertOrderedListToTextStep = require("./steps/convertOrderedListToTextStep");
12
+ var _convertTaskListToTextStep = require("./steps/convertTaskListToTextStep");
10
13
  var _unwrapLayoutStep = require("./steps/unwrapLayoutStep");
11
14
  var _stubStep = require("./stubStep");
12
15
  var _types = require("./types");
@@ -40,7 +43,7 @@ var TRANSFORM_STEPS = {
40
43
  },
41
44
  list: {
42
45
  atomic: undefined,
43
- container: [_stubStep.stubStep],
46
+ container: [_wrapStep.wrapStep],
44
47
  list: [_stubStep.stubStep],
45
48
  text: [_flattenListStep.flattenListStep, _unwrapListStep.unwrapListStep]
46
49
  },
@@ -94,6 +97,24 @@ var TRANSFORM_STEPS_OVERRIDE = {
94
97
  nestedExpand: [_wrapStep.wrapStep],
95
98
  layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep],
96
99
  panel: [_wrapStep.wrapStep]
100
+ },
101
+ bulletList: {
102
+ // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
103
+ codeBlock: [_convertBulletListToTextStep.convertBulletListToTextStep, _flattenStep.flattenStep, _wrapStep.wrapStep],
104
+ layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
105
+ },
106
+ orderedList: {
107
+ // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
108
+ codeBlock: [_convertOrderedListToTextStep.convertOrderedListToTextStep, _flattenStep.flattenStep, _wrapStep.wrapStep],
109
+ // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
110
+ layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
111
+ },
112
+ taskList: {
113
+ // Warning: Actuall transformation logic not complete (Skeptical that prosemirror-markdown can be used)
114
+ blockquote: [_convertTaskListToTextStep.convertTaskListToTextStep, _wrapStep.wrapStep],
115
+ // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
116
+ codeBlock: [_convertTaskListToTextStep.convertTaskListToTextStep, _flattenStep.flattenStep, _wrapStep.wrapStep],
117
+ layoutSection: [_wrapIntoLayoutStep.wrapIntoLayoutStep]
97
118
  }
98
119
  };
99
120
  var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
@@ -195,24 +195,31 @@ var BlockMenu = function BlockMenu(_ref4) {
195
195
  if (!isMenuOpen) {
196
196
  return null;
197
197
  }
198
- var handleBackspaceDeleteKeydown = function handleBackspaceDeleteKeydown() {
198
+ var handleBackspaceDeleteKeydown = function handleBackspaceDeleteKeydown(event) {
199
+ // Pevents delete/backspace keypress being handled by editor, avoids double deletions
200
+ event === null || event === void 0 || event.preventDefault();
201
+ event === null || event === void 0 || event.stopPropagation();
199
202
  api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
200
- var _api$blockControls;
203
+ var _api$blockControls, _api$blockControls2;
201
204
  var tr = _ref6.tr;
202
- (0, _selection.deleteSelectedRange)(tr);
203
- api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.toggleBlockMenu({
205
+ (0, _selection.deleteSelectedRange)(tr, api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection);
206
+ api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.toggleBlockMenu({
204
207
  closeMenu: true
205
208
  })({
206
209
  tr: tr
207
210
  });
211
+ if (editorView && !editorView.hasFocus()) {
212
+ // if focus is outside editor, e.g. in block menu popup, then refocus editor after delete
213
+ editorView.focus();
214
+ }
208
215
  return tr;
209
216
  });
210
217
  };
211
218
  var closeMenu = function closeMenu() {
212
219
  api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
213
- var _api$blockControls2, _api$userIntent3;
220
+ var _api$blockControls3, _api$userIntent3;
214
221
  var tr = _ref7.tr;
215
- api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.toggleBlockMenu({
222
+ api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.toggleBlockMenu({
216
223
  closeMenu: true
217
224
  })({
218
225
  tr: tr
@@ -25,7 +25,7 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
25
25
  var nodeTypes = Object.values((api === null || api === void 0 || (_api$core$sharedState = api.core.sharedState.currentState()) === null || _api$core$sharedState === void 0 || (_api$core$sharedState = _api$core$sharedState.schema) === null || _api$core$sharedState === void 0 ? void 0 : _api$core$sharedState.nodes) || {});
26
26
  var onClick = function onClick() {
27
27
  api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
28
- var _api$analytics, _api$blockControls;
28
+ var _api$analytics, _api$blockControls, _api$blockControls2;
29
29
  var tr = _ref2.tr;
30
30
  var payload = {
31
31
  action: _analytics.ACTION.CLICKED,
@@ -36,8 +36,8 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
36
36
  eventType: _analytics.EVENT_TYPE.UI
37
37
  };
38
38
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent(payload)(tr);
39
- (0, _selection.deleteSelectedRange)(tr);
40
- api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.toggleBlockMenu({
39
+ (0, _selection.deleteSelectedRange)(tr, api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection);
40
+ api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.toggleBlockMenu({
41
41
  closeMenu: true
42
42
  })({
43
43
  tr: tr
@@ -0,0 +1,27 @@
1
+ import { createListToTextStep } from './createListToTextStep';
2
+
3
+ /**
4
+ * Given an array of nodes, processes each bullet list by converting its items
5
+ * to paragraphs with "- " prefix.
6
+ *
7
+ * Handles nested bullet lists recursively with 3-space indentation per level.
8
+ *
9
+ * @example
10
+ * Input:
11
+ * - bulletList()(
12
+ * listItem()(p()('Item 1')),
13
+ * bulletList()(listItem()(p()('Sub item 1')))
14
+ * )
15
+ *
16
+ * Output:
17
+ * - p()('- Item 1')
18
+ * - p()(' - Sub item 1')
19
+ */
20
+ export const convertBulletListToTextStep = createListToTextStep({
21
+ listTypeName: 'bulletList',
22
+ itemTypeName: 'listItem',
23
+ indent: ' ',
24
+ // 3 spaces per nesting level
25
+ getPrefix: () => '- ',
26
+ unwrapParagraphContent: true
27
+ });
@@ -0,0 +1,55 @@
1
+ import { createListToTextStep } from './createListToTextStep';
2
+
3
+ /**
4
+ * Converts a number to a letter (1=a, 2=b, etc.)
5
+ * For numbers > 26, continues with aa, ab, etc.
6
+ */
7
+ const numberToLetter = num => {
8
+ let result = '';
9
+ let n = num;
10
+ while (n > 0) {
11
+ n--;
12
+ result = String.fromCharCode(97 + n % 26) + result;
13
+ n = Math.floor(n / 26);
14
+ }
15
+ return result;
16
+ };
17
+
18
+ /**
19
+ * Gets the appropriate prefix for an ordered list item based on depth and index.
20
+ * - Level 0: "1. ", "2. ", "3. ", etc.
21
+ * - Level 1+: "a. ", "b. ", "c. ", etc.
22
+ */
23
+ const getOrderedListPrefix = (depth, index) => {
24
+ if (depth === 0) {
25
+ return `${index}. `;
26
+ }
27
+ return `${numberToLetter(index)}. `;
28
+ };
29
+
30
+ /**
31
+ * Given an array of nodes, processes each ordered list by converting its items
32
+ * to paragraphs with numbered prefixes (1., 2., 3.) at the top level and
33
+ * lettered prefixes (a., b., c.) for nested levels.
34
+ *
35
+ * Handles nested ordered lists recursively with 3-space indentation per level.
36
+ *
37
+ * @example
38
+ * Input:
39
+ * - orderedList({ order: 1 })(
40
+ * listItem()(p()('Item 1')),
41
+ * orderedList({ order: 1 })(listItem()(p()('Sub item 1')))
42
+ * )
43
+ *
44
+ * Output:
45
+ * - p()('1. Item 1')
46
+ * - p()(' a. Sub item 1')
47
+ */
48
+ export const convertOrderedListToTextStep = createListToTextStep({
49
+ listTypeName: 'orderedList',
50
+ itemTypeName: 'listItem',
51
+ indent: ' ',
52
+ // 3 spaces per nesting level
53
+ getPrefix: (depth, index) => getOrderedListPrefix(depth, index),
54
+ unwrapParagraphContent: true
55
+ });
@@ -0,0 +1,34 @@
1
+ import { createListToTextStep } from './createListToTextStep';
2
+
3
+ /**
4
+ * Given an array of nodes, processes each task list by converting its items
5
+ * to paragraphs with a checkbox prefix. Uses "[] " for unchecked (TODO) tasks
6
+ * and "[x] " for checked (DONE) tasks.
7
+ *
8
+ * Handles nested task lists recursively with 4-space indentation per level.
9
+ *
10
+ * This is used when converting a task list to a container that doesn't support
11
+ * task items (like blockquote).
12
+ *
13
+ * @example
14
+ * Input:
15
+ * - taskList()(
16
+ * taskItem({ state: 'TODO' })('Task list item'),
17
+ * taskList()(taskItem({ state: 'DONE' })('Nested done task'))
18
+ * )
19
+ *
20
+ * Output:
21
+ * - p()('[] Task list item')
22
+ * - p()(' [x] Nested done task')
23
+ */
24
+ export const convertTaskListToTextStep = createListToTextStep({
25
+ listTypeName: 'taskList',
26
+ itemTypeName: 'taskItem',
27
+ indent: ' ',
28
+ // 4 spaces per nesting level
29
+ getPrefix: (_, __, itemNode) => {
30
+ var _itemNode$attrs;
31
+ return ((_itemNode$attrs = itemNode.attrs) === null || _itemNode$attrs === void 0 ? void 0 : _itemNode$attrs.state) === 'DONE' ? '[x] ' : '[] ';
32
+ },
33
+ unwrapParagraphContent: false
34
+ });
@@ -0,0 +1,86 @@
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
+ const extractListItemsAsParagraphs = (node, schema, config) => {
12
+ const paragraphs = [];
13
+ const paragraphType = schema.nodes.paragraph;
14
+ const listType = schema.nodes[config.listTypeName];
15
+ const itemType = schema.nodes[config.itemTypeName];
16
+ const extract = (currentNode, depth = 0) => {
17
+ let itemIndex = 0;
18
+ currentNode.forEach(child => {
19
+ if (child.type === itemType) {
20
+ itemIndex++;
21
+ const indent = config.indent.repeat(depth);
22
+ const prefix = config.getPrefix(depth, itemIndex, child);
23
+ const listPrefix = schema.text(`${indent}${prefix}`);
24
+
25
+ // Collect inline content and nested lists separately
26
+ const inlineContent = [];
27
+ const nestedLists = [];
28
+ child.forEach(grandChild => {
29
+ if (grandChild.type === listType) {
30
+ nestedLists.push(grandChild);
31
+ } else if (config.unwrapParagraphContent && grandChild.type === paragraphType) {
32
+ // Extract content from paragraph nodes
33
+ grandChild.forEach(content => {
34
+ inlineContent.push(content);
35
+ });
36
+ } else {
37
+ inlineContent.push(grandChild);
38
+ }
39
+ });
40
+
41
+ // Create paragraph with prefix + inline content
42
+ if (inlineContent.length > 0) {
43
+ const newContent = Fragment.from(listPrefix).append(Fragment.fromArray(inlineContent));
44
+ const newParagraph = paragraphType.create({}, newContent);
45
+ paragraphs.push(newParagraph);
46
+ }
47
+
48
+ // Recursively process nested lists with increased depth
49
+ nestedLists.forEach(nestedList => {
50
+ extract(nestedList, depth + 1);
51
+ });
52
+ } else if (child.type === listType) {
53
+ // Handle list that appears directly as a sibling
54
+ extract(child, depth + 1);
55
+ }
56
+ });
57
+ };
58
+ extract(node, 0);
59
+ return paragraphs;
60
+ };
61
+
62
+ /**
63
+ * Creates a TransformStep that converts a list to paragraphs with text prefixes.
64
+ *
65
+ * Given an array of nodes, processes each list by converting its items
66
+ * to paragraphs with configurable prefixes.
67
+ *
68
+ * Handles nested lists recursively with configurable indentation per level.
69
+ *
70
+ * @param config - Configuration for the list-to-text transformation
71
+ * @returns A TransformStep function
72
+ */
73
+ export const createListToTextStep = config => {
74
+ return (nodes, context) => {
75
+ const {
76
+ schema
77
+ } = context;
78
+ const listType = schema.nodes[config.listTypeName];
79
+ return nodes.flatMap(node => {
80
+ if (node.type === listType) {
81
+ return extractListItemsAsParagraphs(node, schema, config);
82
+ }
83
+ return node;
84
+ });
85
+ };
86
+ };
@@ -1,6 +1,9 @@
1
1
  import { getTargetNodeTypeNameInContext } from '../transform-node-utils/utils';
2
2
  import { flattenListStep } from './flattenListStep';
3
3
  import { flattenStep } from './flattenStep';
4
+ import { convertBulletListToTextStep } from './steps/convertBulletListToTextStep';
5
+ import { convertOrderedListToTextStep } from './steps/convertOrderedListToTextStep';
6
+ import { convertTaskListToTextStep } from './steps/convertTaskListToTextStep';
4
7
  import { unwrapLayoutStep } from './steps/unwrapLayoutStep';
5
8
  import { stubStep } from './stubStep';
6
9
  import { NODE_CATEGORY_BY_TYPE, toNodeTypeValue } from './types';
@@ -35,7 +38,7 @@ const TRANSFORM_STEPS = {
35
38
  },
36
39
  list: {
37
40
  atomic: undefined,
38
- container: [stubStep],
41
+ container: [wrapStep],
39
42
  list: [stubStep],
40
43
  text: [flattenListStep, unwrapListStep]
41
44
  },
@@ -89,6 +92,24 @@ const TRANSFORM_STEPS_OVERRIDE = {
89
92
  nestedExpand: [wrapStep],
90
93
  layoutSection: [wrapIntoLayoutStep],
91
94
  panel: [wrapStep]
95
+ },
96
+ bulletList: {
97
+ // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
98
+ codeBlock: [convertBulletListToTextStep, flattenStep, wrapStep],
99
+ layoutSection: [wrapIntoLayoutStep]
100
+ },
101
+ orderedList: {
102
+ // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
103
+ codeBlock: [convertOrderedListToTextStep, flattenStep, wrapStep],
104
+ // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
105
+ layoutSection: [wrapIntoLayoutStep]
106
+ },
107
+ taskList: {
108
+ // Warning: Actuall transformation logic not complete (Skeptical that prosemirror-markdown can be used)
109
+ blockquote: [convertTaskListToTextStep, wrapStep],
110
+ // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
111
+ codeBlock: [convertTaskListToTextStep, flattenStep, wrapStep],
112
+ layoutSection: [wrapIntoLayoutStep]
92
113
  }
93
114
  };
94
115
  const getTransformStepsForNodeTypes = (selectedNodeTypeName, targetNodeTypeName) => {
@@ -180,17 +180,24 @@ const BlockMenu = ({
180
180
  if (!isMenuOpen) {
181
181
  return null;
182
182
  }
183
- const handleBackspaceDeleteKeydown = () => {
183
+ const handleBackspaceDeleteKeydown = event => {
184
+ // Pevents delete/backspace keypress being handled by editor, avoids double deletions
185
+ event === null || event === void 0 ? void 0 : event.preventDefault();
186
+ event === null || event === void 0 ? void 0 : event.stopPropagation();
184
187
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
185
188
  tr
186
189
  }) => {
187
- var _api$blockControls;
188
- deleteSelectedRange(tr);
189
- api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.commands.toggleBlockMenu({
190
+ var _api$blockControls, _api$blockControls$sh, _api$blockControls2;
191
+ deleteSelectedRange(tr, api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : (_api$blockControls$sh = _api$blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.preservedSelection);
192
+ api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.toggleBlockMenu({
190
193
  closeMenu: true
191
194
  })({
192
195
  tr
193
196
  });
197
+ if (editorView && !editorView.hasFocus()) {
198
+ // if focus is outside editor, e.g. in block menu popup, then refocus editor after delete
199
+ editorView.focus();
200
+ }
194
201
  return tr;
195
202
  });
196
203
  };
@@ -198,8 +205,8 @@ const BlockMenu = ({
198
205
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
199
206
  tr
200
207
  }) => {
201
- var _api$blockControls2, _api$userIntent3;
202
- api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.toggleBlockMenu({
208
+ var _api$blockControls3, _api$userIntent3;
209
+ api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.toggleBlockMenu({
203
210
  closeMenu: true
204
211
  })({
205
212
  tr
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useEffect } from 'react';
2
- import { useIntl, injectIntl } from 'react-intl-next';
2
+ import { injectIntl, useIntl } from 'react-intl-next';
3
3
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
4
4
  import { blockMenuMessages } from '@atlaskit/editor-common/messages';
5
5
  import { deleteSelectedRange } from '@atlaskit/editor-common/selection';
@@ -20,7 +20,7 @@ const DeleteDropdownItemContent = ({
20
20
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
21
21
  tr
22
22
  }) => {
23
- var _api$analytics, _api$analytics$action, _api$blockControls, _api$blockControls$co;
23
+ var _api$analytics, _api$analytics$action, _api$blockControls, _api$blockControls$sh, _api$blockControls2, _api$blockControls2$c;
24
24
  const payload = {
25
25
  action: ACTION.CLICKED,
26
26
  actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
@@ -30,8 +30,8 @@ const DeleteDropdownItemContent = ({
30
30
  eventType: EVENT_TYPE.UI
31
31
  };
32
32
  api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.attachAnalyticsEvent(payload)(tr);
33
- deleteSelectedRange(tr);
34
- api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : (_api$blockControls$co = _api$blockControls.commands) === null || _api$blockControls$co === void 0 ? void 0 : _api$blockControls$co.toggleBlockMenu({
33
+ deleteSelectedRange(tr, api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : (_api$blockControls$sh = _api$blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.preservedSelection);
34
+ api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$c = _api$blockControls2.commands) === null || _api$blockControls2$c === void 0 ? void 0 : _api$blockControls2$c.toggleBlockMenu({
35
35
  closeMenu: true
36
36
  })({
37
37
  tr
@@ -0,0 +1,29 @@
1
+ import { createListToTextStep } from './createListToTextStep';
2
+
3
+ /**
4
+ * Given an array of nodes, processes each bullet list by converting its items
5
+ * to paragraphs with "- " prefix.
6
+ *
7
+ * Handles nested bullet lists recursively with 3-space indentation per level.
8
+ *
9
+ * @example
10
+ * Input:
11
+ * - bulletList()(
12
+ * listItem()(p()('Item 1')),
13
+ * bulletList()(listItem()(p()('Sub item 1')))
14
+ * )
15
+ *
16
+ * Output:
17
+ * - p()('- Item 1')
18
+ * - p()(' - Sub item 1')
19
+ */
20
+ export var convertBulletListToTextStep = createListToTextStep({
21
+ listTypeName: 'bulletList',
22
+ itemTypeName: 'listItem',
23
+ indent: ' ',
24
+ // 3 spaces per nesting level
25
+ getPrefix: function getPrefix() {
26
+ return '- ';
27
+ },
28
+ unwrapParagraphContent: true
29
+ });
@@ -0,0 +1,57 @@
1
+ import { createListToTextStep } from './createListToTextStep';
2
+
3
+ /**
4
+ * Converts a number to a letter (1=a, 2=b, etc.)
5
+ * For numbers > 26, continues with aa, ab, etc.
6
+ */
7
+ var numberToLetter = function numberToLetter(num) {
8
+ var result = '';
9
+ var n = num;
10
+ while (n > 0) {
11
+ n--;
12
+ result = String.fromCharCode(97 + n % 26) + result;
13
+ n = Math.floor(n / 26);
14
+ }
15
+ return result;
16
+ };
17
+
18
+ /**
19
+ * Gets the appropriate prefix for an ordered list item based on depth and index.
20
+ * - Level 0: "1. ", "2. ", "3. ", etc.
21
+ * - Level 1+: "a. ", "b. ", "c. ", etc.
22
+ */
23
+ var getOrderedListPrefix = function getOrderedListPrefix(depth, index) {
24
+ if (depth === 0) {
25
+ return "".concat(index, ". ");
26
+ }
27
+ return "".concat(numberToLetter(index), ". ");
28
+ };
29
+
30
+ /**
31
+ * Given an array of nodes, processes each ordered list by converting its items
32
+ * to paragraphs with numbered prefixes (1., 2., 3.) at the top level and
33
+ * lettered prefixes (a., b., c.) for nested levels.
34
+ *
35
+ * Handles nested ordered lists recursively with 3-space indentation per level.
36
+ *
37
+ * @example
38
+ * Input:
39
+ * - orderedList({ order: 1 })(
40
+ * listItem()(p()('Item 1')),
41
+ * orderedList({ order: 1 })(listItem()(p()('Sub item 1')))
42
+ * )
43
+ *
44
+ * Output:
45
+ * - p()('1. Item 1')
46
+ * - p()(' a. Sub item 1')
47
+ */
48
+ export var convertOrderedListToTextStep = createListToTextStep({
49
+ listTypeName: 'orderedList',
50
+ itemTypeName: 'listItem',
51
+ indent: ' ',
52
+ // 3 spaces per nesting level
53
+ getPrefix: function getPrefix(depth, index) {
54
+ return getOrderedListPrefix(depth, index);
55
+ },
56
+ unwrapParagraphContent: true
57
+ });
@@ -0,0 +1,34 @@
1
+ import { createListToTextStep } from './createListToTextStep';
2
+
3
+ /**
4
+ * Given an array of nodes, processes each task list by converting its items
5
+ * to paragraphs with a checkbox prefix. Uses "[] " for unchecked (TODO) tasks
6
+ * and "[x] " for checked (DONE) tasks.
7
+ *
8
+ * Handles nested task lists recursively with 4-space indentation per level.
9
+ *
10
+ * This is used when converting a task list to a container that doesn't support
11
+ * task items (like blockquote).
12
+ *
13
+ * @example
14
+ * Input:
15
+ * - taskList()(
16
+ * taskItem({ state: 'TODO' })('Task list item'),
17
+ * taskList()(taskItem({ state: 'DONE' })('Nested done task'))
18
+ * )
19
+ *
20
+ * Output:
21
+ * - p()('[] Task list item')
22
+ * - p()(' [x] Nested done task')
23
+ */
24
+ export var convertTaskListToTextStep = createListToTextStep({
25
+ listTypeName: 'taskList',
26
+ itemTypeName: 'taskItem',
27
+ indent: ' ',
28
+ // 4 spaces per nesting level
29
+ getPrefix: function getPrefix(_, __, itemNode) {
30
+ var _itemNode$attrs;
31
+ return ((_itemNode$attrs = itemNode.attrs) === null || _itemNode$attrs === void 0 ? void 0 : _itemNode$attrs.state) === 'DONE' ? '[x] ' : '[] ';
32
+ },
33
+ unwrapParagraphContent: false
34
+ });
@@ -0,0 +1,85 @@
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,6 +1,9 @@
1
1
  import { getTargetNodeTypeNameInContext } from '../transform-node-utils/utils';
2
2
  import { flattenListStep } from './flattenListStep';
3
3
  import { flattenStep } from './flattenStep';
4
+ import { convertBulletListToTextStep } from './steps/convertBulletListToTextStep';
5
+ import { convertOrderedListToTextStep } from './steps/convertOrderedListToTextStep';
6
+ import { convertTaskListToTextStep } from './steps/convertTaskListToTextStep';
4
7
  import { unwrapLayoutStep } from './steps/unwrapLayoutStep';
5
8
  import { stubStep } from './stubStep';
6
9
  import { NODE_CATEGORY_BY_TYPE, toNodeTypeValue } from './types';
@@ -35,7 +38,7 @@ var TRANSFORM_STEPS = {
35
38
  },
36
39
  list: {
37
40
  atomic: undefined,
38
- container: [stubStep],
41
+ container: [wrapStep],
39
42
  list: [stubStep],
40
43
  text: [flattenListStep, unwrapListStep]
41
44
  },
@@ -89,6 +92,24 @@ var TRANSFORM_STEPS_OVERRIDE = {
89
92
  nestedExpand: [wrapStep],
90
93
  layoutSection: [wrapIntoLayoutStep],
91
94
  panel: [wrapStep]
95
+ },
96
+ bulletList: {
97
+ // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
98
+ codeBlock: [convertBulletListToTextStep, flattenStep, wrapStep],
99
+ layoutSection: [wrapIntoLayoutStep]
100
+ },
101
+ orderedList: {
102
+ // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
103
+ codeBlock: [convertOrderedListToTextStep, flattenStep, wrapStep],
104
+ // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
105
+ layoutSection: [wrapIntoLayoutStep]
106
+ },
107
+ taskList: {
108
+ // Warning: Actuall transformation logic not complete (Skeptical that prosemirror-markdown can be used)
109
+ blockquote: [convertTaskListToTextStep, wrapStep],
110
+ // Warning: Actuall transformation logic not complete (Likelly prosemirror-markdown to be used)
111
+ codeBlock: [convertTaskListToTextStep, flattenStep, wrapStep],
112
+ layoutSection: [wrapIntoLayoutStep]
92
113
  }
93
114
  };
94
115
  var getTransformStepsForNodeTypes = function getTransformStepsForNodeTypes(selectedNodeTypeName, targetNodeTypeName) {
@@ -186,24 +186,31 @@ var BlockMenu = function BlockMenu(_ref4) {
186
186
  if (!isMenuOpen) {
187
187
  return null;
188
188
  }
189
- var handleBackspaceDeleteKeydown = function handleBackspaceDeleteKeydown() {
189
+ var handleBackspaceDeleteKeydown = function handleBackspaceDeleteKeydown(event) {
190
+ // Pevents delete/backspace keypress being handled by editor, avoids double deletions
191
+ event === null || event === void 0 || event.preventDefault();
192
+ event === null || event === void 0 || event.stopPropagation();
190
193
  api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
191
- var _api$blockControls;
194
+ var _api$blockControls, _api$blockControls2;
192
195
  var tr = _ref6.tr;
193
- deleteSelectedRange(tr);
194
- api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.toggleBlockMenu({
196
+ deleteSelectedRange(tr, api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection);
197
+ api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.toggleBlockMenu({
195
198
  closeMenu: true
196
199
  })({
197
200
  tr: tr
198
201
  });
202
+ if (editorView && !editorView.hasFocus()) {
203
+ // if focus is outside editor, e.g. in block menu popup, then refocus editor after delete
204
+ editorView.focus();
205
+ }
199
206
  return tr;
200
207
  });
201
208
  };
202
209
  var closeMenu = function closeMenu() {
203
210
  api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
204
- var _api$blockControls2, _api$userIntent3;
211
+ var _api$blockControls3, _api$userIntent3;
205
212
  var tr = _ref7.tr;
206
- api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.toggleBlockMenu({
213
+ api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.toggleBlockMenu({
207
214
  closeMenu: true
208
215
  })({
209
216
  tr: tr
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useEffect } from 'react';
2
- import { useIntl, injectIntl } from 'react-intl-next';
2
+ import { injectIntl, useIntl } from 'react-intl-next';
3
3
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
4
4
  import { blockMenuMessages } from '@atlaskit/editor-common/messages';
5
5
  import { deleteSelectedRange } from '@atlaskit/editor-common/selection';
@@ -16,7 +16,7 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
16
16
  var nodeTypes = Object.values((api === null || api === void 0 || (_api$core$sharedState = api.core.sharedState.currentState()) === null || _api$core$sharedState === void 0 || (_api$core$sharedState = _api$core$sharedState.schema) === null || _api$core$sharedState === void 0 ? void 0 : _api$core$sharedState.nodes) || {});
17
17
  var onClick = function onClick() {
18
18
  api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
19
- var _api$analytics, _api$blockControls;
19
+ var _api$analytics, _api$blockControls, _api$blockControls2;
20
20
  var tr = _ref2.tr;
21
21
  var payload = {
22
22
  action: ACTION.CLICKED,
@@ -27,8 +27,8 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
27
27
  eventType: EVENT_TYPE.UI
28
28
  };
29
29
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent(payload)(tr);
30
- deleteSelectedRange(tr);
31
- api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.toggleBlockMenu({
30
+ deleteSelectedRange(tr, api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection);
31
+ api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.toggleBlockMenu({
32
32
  closeMenu: true
33
33
  })({
34
34
  tr: tr
@@ -0,0 +1,18 @@
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;
@@ -0,0 +1,19 @@
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;
@@ -0,0 +1,22 @@
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;
@@ -0,0 +1,38 @@
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;
@@ -0,0 +1,18 @@
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;
@@ -0,0 +1,19 @@
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;
@@ -0,0 +1,22 @@
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;
@@ -0,0 +1,38 @@
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "5.1.10",
3
+ "version": "5.2.0",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -44,12 +44,12 @@
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
46
46
  "@atlaskit/primitives": "^16.4.0",
47
- "@atlaskit/tmp-editor-statsig": "^15.0.0",
47
+ "@atlaskit/tmp-editor-statsig": "^15.7.0",
48
48
  "@atlaskit/tokens": "^8.4.0",
49
49
  "@babel/runtime": "^7.0.0"
50
50
  },
51
51
  "peerDependencies": {
52
- "@atlaskit/editor-common": "^110.40.0",
52
+ "@atlaskit/editor-common": "^110.41.0",
53
53
  "react": "^18.2.0",
54
54
  "react-intl-next": "npm:react-intl@^5.18.1"
55
55
  },