@atlaskit/editor-plugin-block-menu 6.0.42 → 6.0.44

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 6.0.44
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 6.0.43
10
+
11
+ ### Patch Changes
12
+
13
+ - [`61ffb7d51ff40`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/61ffb7d51ff40) -
14
+ [ux] Ensure that when a transform to an expand happens, its localId is present so that it remains
15
+ 'expanded'
16
+ - Updated dependencies
17
+
3
18
  ## 6.0.42
4
19
 
5
20
  ### Patch Changes
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.wrapMixedContentStep = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _model = require("@atlaskit/editor-prosemirror/model");
10
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
11
  var _marks = require("../marks");
11
12
  var _types = require("../types");
12
13
  var _utils = require("../utils");
@@ -35,7 +36,15 @@ var createTextContentContainer = function createTextContentContainer(textContent
35
36
  * Creates a regular container with node content.
36
37
  */
37
38
  var createNodeContentContainer = function createNodeContentContainer(nodeContent, targetNodeType) {
38
- return targetNodeType.createAndFill({}, nodeContent);
39
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
40
+ // Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
41
+ // object, preserving the expandedState WeakMap entry set in transformNode.ts.
42
+ // To clean up: remove the if-else, always use the flag-on branch.
43
+ var isExpandType = targetNodeType.name === 'expand' || targetNodeType.name === 'nestedExpand';
44
+ var nodeAttrs = isExpandType && (0, _platformFeatureFlags.fg)('platform_editor_block_menu_expand_localid_fix') ? {
45
+ localId: crypto.randomUUID()
46
+ } : {};
47
+ return targetNodeType.createAndFill(nodeAttrs, nodeContent);
39
48
  };
40
49
 
41
50
  /**
@@ -70,7 +79,14 @@ var handleEmptyContainerEdgeCase = function handleEmptyContainerEdgeCase(result,
70
79
  return emptyCodeBlock ? [emptyCodeBlock].concat((0, _toConsumableArray2.default)(result)) : result;
71
80
  }
72
81
  var emptyParagraph = schema.nodes.paragraph.create();
73
- var emptyContainer = targetNodeType.create({}, emptyParagraph);
82
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
83
+ // Same localId pre-assignment rationale as createNodeContentContainer above.
84
+ // To clean up: remove the if-else, always use the flag-on branch.
85
+ var isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
86
+ var emptyContainerAttrs = isExpandType && (0, _platformFeatureFlags.fg)('platform_editor_block_menu_expand_localid_fix') ? {
87
+ localId: crypto.randomUUID()
88
+ } : {};
89
+ var emptyContainer = targetNodeType.create(emptyContainerAttrs, emptyParagraph);
74
90
  return [emptyContainer].concat((0, _toConsumableArray2.default)(result));
75
91
  };
76
92
 
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.isTextNode = exports.getTargetNodeTypeNameInContext = exports.getSelectedNode = exports.getBlockNodesInRange = exports.createTextContent = exports.convertTextNodeToParagraph = exports.convertNestedExpandToExpand = exports.convertExpandToNestedExpand = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
7
9
  var _state = require("@atlaskit/editor-prosemirror/state");
8
10
  var _utils = require("@atlaskit/editor-prosemirror/utils");
9
11
  var _editorTables = require("@atlaskit/editor-tables");
12
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
13
  var _types = require("./types");
14
+ 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; }
15
+ 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) { (0, _defineProperty2.default)(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; }
11
16
  /**
12
17
  * Determines if a node is a text node (heading or paragraph).
13
18
  * Text nodes can have their content converted to paragraphs when they can't be wrapped directly.
@@ -79,9 +84,17 @@ var convertNestedExpandToExpand = exports.convertNestedExpandToExpand = function
79
84
  if (!expandType) {
80
85
  return null;
81
86
  }
82
- return expandType.createAndFill({
87
+
88
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
89
+ // Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
90
+ // object, preserving the expandedState WeakMap entry set in transformNode.ts.
91
+ // To clean up: remove the if-else, always include localId in attrs.
92
+ var localIdAttr = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_expand_localid_fix') ? {
93
+ localId: crypto.randomUUID()
94
+ } : {};
95
+ return expandType.createAndFill(_objectSpread({
83
96
  title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || ''
84
- }, node.content);
97
+ }, localIdAttr), node.content);
85
98
  };
86
99
 
87
100
  /**
@@ -95,9 +108,16 @@ var convertExpandToNestedExpand = exports.convertExpandToNestedExpand = function
95
108
  if (!nestedExpandType) {
96
109
  return null;
97
110
  }
98
- return nestedExpandType.createAndFill({
111
+
112
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
113
+ // Same localId pre-assignment rationale as convertNestedExpandToExpand above.
114
+ // To clean up: remove the if-else, always include localId in attrs.
115
+ var localIdAttr = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_expand_localid_fix') ? {
116
+ localId: crypto.randomUUID()
117
+ } : {};
118
+ return nestedExpandType.createAndFill(_objectSpread({
99
119
  title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || ''
100
- }, node.content);
120
+ }, localIdAttr), node.content);
101
121
  };
102
122
 
103
123
  /**
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.wrapStep = void 0;
7
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
7
8
  var _marks = require("./marks");
8
9
  var _utils = require("./utils");
9
10
  /**
@@ -27,6 +28,17 @@ var wrapStep = exports.wrapStep = function wrapStep(nodes, context) {
27
28
  return node;
28
29
  });
29
30
  }
30
- var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, (0, _marks.removeDisallowedMarks)(processedNodes, schema.nodes[targetNodeTypeName]));
31
+ var targetNodeType = schema.nodes[targetNodeTypeName];
32
+
33
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
34
+ // Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
35
+ // object (via setNodeAttribute), which would invalidate the expandedState WeakMap entry set
36
+ // in transformNode.ts and cause the expand to render as collapsed.
37
+ // To clean up: remove the if-else, always use the flag-on branch (isExpandType with uuid).
38
+ var isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
39
+ var nodeAttrs = isExpandType && (0, _platformFeatureFlags.fg)('platform_editor_block_menu_expand_localid_fix') ? {
40
+ localId: crypto.randomUUID()
41
+ } : {};
42
+ var outputNode = targetNodeType.createAndFill(nodeAttrs, (0, _marks.removeDisallowedMarks)(processedNodes, schema.nodes[targetNodeTypeName]));
31
43
  return outputNode ? [outputNode] : nodes;
32
44
  };
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.transformNode = void 0;
7
7
  var _analytics = require("@atlaskit/editor-common/analytics");
8
+ var _expand = require("@atlaskit/editor-common/expand");
8
9
  var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
9
10
  var _selection = require("@atlaskit/editor-common/selection");
10
11
  var _state = require("@atlaskit/editor-prosemirror/state");
@@ -52,6 +53,23 @@ var transformNode = exports.transformNode = function transformNode(api) {
52
53
  });
53
54
  var content = resultNodes.length > 0 ? resultNodes : sourceNodes;
54
55
  var sliceStart = isList ? $from.pos - 1 : $from.pos;
56
+
57
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
58
+ // Pre-populates the expandedState WeakMap so ExpandNodeView initializes newly created
59
+ // expand/nestedExpand nodes as expanded rather than collapsed. Works in conjunction with
60
+ // the localId pre-assignment in the transform steps — without a pre-assigned localId the
61
+ // localId plugin's appendTransaction replaces the node object (via setNodeAttribute),
62
+ // invalidating this WeakMap entry. The else branch preserves the previous behaviour.
63
+ // To clean up: remove the if-else block and keep only the flag-on body.
64
+ if ((0, _platformFeatureFlags.fg)('platform_editor_block_menu_expand_localid_fix')) {
65
+ var expand = nodes.expand,
66
+ nestedExpand = nodes.nestedExpand;
67
+ content.forEach(function (node) {
68
+ if (node.type === expand || node.type === nestedExpand) {
69
+ _expand.expandedState.set(node, true);
70
+ }
71
+ });
72
+ }
55
73
  if (preservedSelection instanceof _state.NodeSelection && preservedSelection.node.type === nodes.mediaSingle) {
56
74
  var _api$blockControls2;
57
75
  // when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
@@ -1,4 +1,5 @@
1
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { removeDisallowedMarks } from '../marks';
3
4
  import { NODE_CATEGORY_BY_TYPE } from '../types';
4
5
  import { convertTextNodeToParagraph, createTextContent, isTextNode } from '../utils';
@@ -28,7 +29,15 @@ const createTextContentContainer = (textContentArray, targetNodeType, schema) =>
28
29
  * Creates a regular container with node content.
29
30
  */
30
31
  const createNodeContentContainer = (nodeContent, targetNodeType) => {
31
- return targetNodeType.createAndFill({}, nodeContent);
32
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
33
+ // Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
34
+ // object, preserving the expandedState WeakMap entry set in transformNode.ts.
35
+ // To clean up: remove the if-else, always use the flag-on branch.
36
+ const isExpandType = targetNodeType.name === 'expand' || targetNodeType.name === 'nestedExpand';
37
+ const nodeAttrs = isExpandType && fg('platform_editor_block_menu_expand_localid_fix') ? {
38
+ localId: crypto.randomUUID()
39
+ } : {};
40
+ return targetNodeType.createAndFill(nodeAttrs, nodeContent);
32
41
  };
33
42
 
34
43
  /**
@@ -63,7 +72,14 @@ const handleEmptyContainerEdgeCase = (result, hasCreatedContainer, fromNode, tar
63
72
  return emptyCodeBlock ? [emptyCodeBlock, ...result] : result;
64
73
  }
65
74
  const emptyParagraph = schema.nodes.paragraph.create();
66
- const emptyContainer = targetNodeType.create({}, emptyParagraph);
75
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
76
+ // Same localId pre-assignment rationale as createNodeContentContainer above.
77
+ // To clean up: remove the if-else, always use the flag-on branch.
78
+ const isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
79
+ const emptyContainerAttrs = isExpandType && fg('platform_editor_block_menu_expand_localid_fix') ? {
80
+ localId: crypto.randomUUID()
81
+ } : {};
82
+ const emptyContainer = targetNodeType.create(emptyContainerAttrs, emptyParagraph);
67
83
  return [emptyContainer, ...result];
68
84
  };
69
85
 
@@ -1,6 +1,7 @@
1
1
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
3
  import { CellSelection } from '@atlaskit/editor-tables';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  import { NODE_CATEGORY_BY_TYPE } from './types';
5
6
 
6
7
  /**
@@ -75,8 +76,17 @@ export const convertNestedExpandToExpand = (node, schema) => {
75
76
  if (!expandType) {
76
77
  return null;
77
78
  }
79
+
80
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
81
+ // Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
82
+ // object, preserving the expandedState WeakMap entry set in transformNode.ts.
83
+ // To clean up: remove the if-else, always include localId in attrs.
84
+ const localIdAttr = fg('platform_editor_block_menu_expand_localid_fix') ? {
85
+ localId: crypto.randomUUID()
86
+ } : {};
78
87
  return expandType.createAndFill({
79
- title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || ''
88
+ title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || '',
89
+ ...localIdAttr
80
90
  }, node.content);
81
91
  };
82
92
 
@@ -91,8 +101,16 @@ export const convertExpandToNestedExpand = (node, schema) => {
91
101
  if (!nestedExpandType) {
92
102
  return null;
93
103
  }
104
+
105
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
106
+ // Same localId pre-assignment rationale as convertNestedExpandToExpand above.
107
+ // To clean up: remove the if-else, always include localId in attrs.
108
+ const localIdAttr = fg('platform_editor_block_menu_expand_localid_fix') ? {
109
+ localId: crypto.randomUUID()
110
+ } : {};
94
111
  return nestedExpandType.createAndFill({
95
- title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || ''
112
+ title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || '',
113
+ ...localIdAttr
96
114
  }, node.content);
97
115
  };
98
116
 
@@ -1,3 +1,4 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
1
2
  import { removeDisallowedMarks } from './marks';
2
3
  import { convertExpandToNestedExpand } from './utils';
3
4
 
@@ -24,6 +25,17 @@ export const wrapStep = (nodes, context) => {
24
25
  return node;
25
26
  });
26
27
  }
27
- const outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, removeDisallowedMarks(processedNodes, schema.nodes[targetNodeTypeName]));
28
+ const targetNodeType = schema.nodes[targetNodeTypeName];
29
+
30
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
31
+ // Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
32
+ // object (via setNodeAttribute), which would invalidate the expandedState WeakMap entry set
33
+ // in transformNode.ts and cause the expand to render as collapsed.
34
+ // To clean up: remove the if-else, always use the flag-on branch (isExpandType with uuid).
35
+ const isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
36
+ const nodeAttrs = isExpandType && fg('platform_editor_block_menu_expand_localid_fix') ? {
37
+ localId: crypto.randomUUID()
38
+ } : {};
39
+ const outputNode = targetNodeType.createAndFill(nodeAttrs, removeDisallowedMarks(processedNodes, schema.nodes[targetNodeTypeName]));
28
40
  return outputNode ? [outputNode] : nodes;
29
41
  };
@@ -1,4 +1,5 @@
1
1
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ import { expandedState } from '@atlaskit/editor-common/expand';
2
3
  import { startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
3
4
  import { expandSelectionToBlockRange, getSourceNodesFromSelectionRange } from '@atlaskit/editor-common/selection';
4
5
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
@@ -48,6 +49,25 @@ export const transformNode = api => (targetType, metadata) => ({
48
49
  });
49
50
  const content = resultNodes.length > 0 ? resultNodes : sourceNodes;
50
51
  const sliceStart = isList ? $from.pos - 1 : $from.pos;
52
+
53
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
54
+ // Pre-populates the expandedState WeakMap so ExpandNodeView initializes newly created
55
+ // expand/nestedExpand nodes as expanded rather than collapsed. Works in conjunction with
56
+ // the localId pre-assignment in the transform steps — without a pre-assigned localId the
57
+ // localId plugin's appendTransaction replaces the node object (via setNodeAttribute),
58
+ // invalidating this WeakMap entry. The else branch preserves the previous behaviour.
59
+ // To clean up: remove the if-else block and keep only the flag-on body.
60
+ if (fg('platform_editor_block_menu_expand_localid_fix')) {
61
+ const {
62
+ expand,
63
+ nestedExpand
64
+ } = nodes;
65
+ content.forEach(node => {
66
+ if (node.type === expand || node.type === nestedExpand) {
67
+ expandedState.set(node, true);
68
+ }
69
+ });
70
+ }
51
71
  if (preservedSelection instanceof NodeSelection && preservedSelection.node.type === nodes.mediaSingle) {
52
72
  var _api$blockControls2;
53
73
  // when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
@@ -1,5 +1,6 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { removeDisallowedMarks } from '../marks';
4
5
  import { NODE_CATEGORY_BY_TYPE } from '../types';
5
6
  import { convertTextNodeToParagraph, createTextContent, isTextNode } from '../utils';
@@ -29,7 +30,15 @@ var createTextContentContainer = function createTextContentContainer(textContent
29
30
  * Creates a regular container with node content.
30
31
  */
31
32
  var createNodeContentContainer = function createNodeContentContainer(nodeContent, targetNodeType) {
32
- return targetNodeType.createAndFill({}, nodeContent);
33
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
34
+ // Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
35
+ // object, preserving the expandedState WeakMap entry set in transformNode.ts.
36
+ // To clean up: remove the if-else, always use the flag-on branch.
37
+ var isExpandType = targetNodeType.name === 'expand' || targetNodeType.name === 'nestedExpand';
38
+ var nodeAttrs = isExpandType && fg('platform_editor_block_menu_expand_localid_fix') ? {
39
+ localId: crypto.randomUUID()
40
+ } : {};
41
+ return targetNodeType.createAndFill(nodeAttrs, nodeContent);
33
42
  };
34
43
 
35
44
  /**
@@ -64,7 +73,14 @@ var handleEmptyContainerEdgeCase = function handleEmptyContainerEdgeCase(result,
64
73
  return emptyCodeBlock ? [emptyCodeBlock].concat(_toConsumableArray(result)) : result;
65
74
  }
66
75
  var emptyParagraph = schema.nodes.paragraph.create();
67
- var emptyContainer = targetNodeType.create({}, emptyParagraph);
76
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
77
+ // Same localId pre-assignment rationale as createNodeContentContainer above.
78
+ // To clean up: remove the if-else, always use the flag-on branch.
79
+ var isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
80
+ var emptyContainerAttrs = isExpandType && fg('platform_editor_block_menu_expand_localid_fix') ? {
81
+ localId: crypto.randomUUID()
82
+ } : {};
83
+ var emptyContainer = targetNodeType.create(emptyContainerAttrs, emptyParagraph);
68
84
  return [emptyContainer].concat(_toConsumableArray(result));
69
85
  };
70
86
 
@@ -1,6 +1,10 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ 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; }
3
+ 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; }
1
4
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
2
5
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
6
  import { CellSelection } from '@atlaskit/editor-tables';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
4
8
  import { NODE_CATEGORY_BY_TYPE } from './types';
5
9
 
6
10
  /**
@@ -74,9 +78,17 @@ export var convertNestedExpandToExpand = function convertNestedExpandToExpand(no
74
78
  if (!expandType) {
75
79
  return null;
76
80
  }
77
- return expandType.createAndFill({
81
+
82
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
83
+ // Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
84
+ // object, preserving the expandedState WeakMap entry set in transformNode.ts.
85
+ // To clean up: remove the if-else, always include localId in attrs.
86
+ var localIdAttr = fg('platform_editor_block_menu_expand_localid_fix') ? {
87
+ localId: crypto.randomUUID()
88
+ } : {};
89
+ return expandType.createAndFill(_objectSpread({
78
90
  title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || ''
79
- }, node.content);
91
+ }, localIdAttr), node.content);
80
92
  };
81
93
 
82
94
  /**
@@ -90,9 +102,16 @@ export var convertExpandToNestedExpand = function convertExpandToNestedExpand(no
90
102
  if (!nestedExpandType) {
91
103
  return null;
92
104
  }
93
- return nestedExpandType.createAndFill({
105
+
106
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
107
+ // Same localId pre-assignment rationale as convertNestedExpandToExpand above.
108
+ // To clean up: remove the if-else, always include localId in attrs.
109
+ var localIdAttr = fg('platform_editor_block_menu_expand_localid_fix') ? {
110
+ localId: crypto.randomUUID()
111
+ } : {};
112
+ return nestedExpandType.createAndFill(_objectSpread({
94
113
  title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || ''
95
- }, node.content);
114
+ }, localIdAttr), node.content);
96
115
  };
97
116
 
98
117
  /**
@@ -1,3 +1,4 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
1
2
  import { removeDisallowedMarks } from './marks';
2
3
  import { convertExpandToNestedExpand } from './utils';
3
4
 
@@ -22,6 +23,17 @@ export var wrapStep = function wrapStep(nodes, context) {
22
23
  return node;
23
24
  });
24
25
  }
25
- var outputNode = schema.nodes[targetNodeTypeName].createAndFill({}, removeDisallowedMarks(processedNodes, schema.nodes[targetNodeTypeName]));
26
+ var targetNodeType = schema.nodes[targetNodeTypeName];
27
+
28
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
29
+ // Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
30
+ // object (via setNodeAttribute), which would invalidate the expandedState WeakMap entry set
31
+ // in transformNode.ts and cause the expand to render as collapsed.
32
+ // To clean up: remove the if-else, always use the flag-on branch (isExpandType with uuid).
33
+ var isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
34
+ var nodeAttrs = isExpandType && fg('platform_editor_block_menu_expand_localid_fix') ? {
35
+ localId: crypto.randomUUID()
36
+ } : {};
37
+ var outputNode = targetNodeType.createAndFill(nodeAttrs, removeDisallowedMarks(processedNodes, schema.nodes[targetNodeTypeName]));
26
38
  return outputNode ? [outputNode] : nodes;
27
39
  };
@@ -1,4 +1,5 @@
1
1
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ import { expandedState } from '@atlaskit/editor-common/expand';
2
3
  import { startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
3
4
  import { expandSelectionToBlockRange, getSourceNodesFromSelectionRange } from '@atlaskit/editor-common/selection';
4
5
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
@@ -46,6 +47,23 @@ export var transformNode = function transformNode(api) {
46
47
  });
47
48
  var content = resultNodes.length > 0 ? resultNodes : sourceNodes;
48
49
  var sliceStart = isList ? $from.pos - 1 : $from.pos;
50
+
51
+ // [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
52
+ // Pre-populates the expandedState WeakMap so ExpandNodeView initializes newly created
53
+ // expand/nestedExpand nodes as expanded rather than collapsed. Works in conjunction with
54
+ // the localId pre-assignment in the transform steps — without a pre-assigned localId the
55
+ // localId plugin's appendTransaction replaces the node object (via setNodeAttribute),
56
+ // invalidating this WeakMap entry. The else branch preserves the previous behaviour.
57
+ // To clean up: remove the if-else block and keep only the flag-on body.
58
+ if (fg('platform_editor_block_menu_expand_localid_fix')) {
59
+ var expand = nodes.expand,
60
+ nestedExpand = nodes.nestedExpand;
61
+ content.forEach(function (node) {
62
+ if (node.type === expand || node.type === nestedExpand) {
63
+ expandedState.set(node, true);
64
+ }
65
+ });
66
+ }
49
67
  if (preservedSelection instanceof NodeSelection && preservedSelection.node.type === nodes.mediaSingle) {
50
68
  var _api$blockControls2;
51
69
  // when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "6.0.42",
3
+ "version": "6.0.44",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,7 @@
32
32
  "@atlaskit/css": "^0.19.0",
33
33
  "@atlaskit/dropdown-menu": "^16.4.0",
34
34
  "@atlaskit/editor-plugin-analytics": "^7.0.0",
35
- "@atlaskit/editor-plugin-block-controls": "^8.3.0",
35
+ "@atlaskit/editor-plugin-block-controls": "^8.4.0",
36
36
  "@atlaskit/editor-plugin-decorations": "^7.0.0",
37
37
  "@atlaskit/editor-plugin-selection": "^7.0.0",
38
38
  "@atlaskit/editor-plugin-user-intent": "^5.0.0",
@@ -46,13 +46,13 @@
46
46
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
47
47
  "@atlaskit/primitives": "^18.0.0",
48
48
  "@atlaskit/prosemirror-history": "^0.2.0",
49
- "@atlaskit/tmp-editor-statsig": "^25.2.0",
49
+ "@atlaskit/tmp-editor-statsig": "^26.0.0",
50
50
  "@atlaskit/tokens": "^11.0.0",
51
51
  "@babel/runtime": "^7.0.0",
52
52
  "bind-event-listener": "^3.0.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@atlaskit/editor-common": "^111.13.0",
55
+ "@atlaskit/editor-common": "^111.16.0",
56
56
  "react": "^18.2.0",
57
57
  "react-intl-next": "npm:react-intl@^5.18.1"
58
58
  },
@@ -96,6 +96,9 @@
96
96
  "platform_editor_adf_with_localid": {
97
97
  "type": "boolean"
98
98
  },
99
+ "platform_editor_block_menu_expand_localid_fix": {
100
+ "type": "boolean"
101
+ },
99
102
  "platform_editor_block_menu_v2_patch_2": {
100
103
  "type": "boolean"
101
104
  },
package/tsconfig.json CHANGED
@@ -1,5 +1,4 @@
1
1
  {
2
2
  "extends": "../../../tsconfig.json",
3
- "include": ["src/**/*.ts", "src/**/*.tsx", "../editor-common/src/block-menu/messages.ts"],
4
- "compilerOptions": {}
3
+ "include": ["src/**/*.ts", "src/**/*.tsx", "../editor-common/src/block-menu/messages.ts"]
5
4
  }