@atlaskit/editor-plugin-block-menu 7.0.1 → 7.0.3
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 +16 -0
- package/README.md +45 -1
- package/dist/cjs/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +2 -10
- package/dist/cjs/editor-commands/transform-node-utils/utils.js +6 -24
- package/dist/cjs/editor-commands/transform-node-utils/wrapStep.js +1 -8
- package/dist/cjs/editor-commands/transformNode.js +7 -18
- package/dist/es2019/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +2 -10
- package/dist/es2019/editor-commands/transform-node-utils/utils.js +2 -18
- package/dist/es2019/editor-commands/transform-node-utils/wrapStep.js +1 -8
- package/dist/es2019/editor-commands/transformNode.js +9 -20
- package/dist/esm/editor-commands/transform-node-utils/steps/wrapMixedContentStep.js +2 -10
- package/dist/esm/editor-commands/transform-node-utils/utils.js +6 -23
- package/dist/esm/editor-commands/transform-node-utils/wrapStep.js +1 -8
- package/dist/esm/editor-commands/transformNode.js +7 -18
- package/docs/0-intro.tsx +79 -1
- package/package.json +3 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 7.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`d84e100ff2136`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d84e100ff2136) -
|
|
8
|
+
Update README.md and 0-intro.tsx
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 7.0.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`1b1c6f7936019`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1b1c6f7936019) -
|
|
16
|
+
Cleanup fg: platform_editor_block_menu_expand_localid_fix
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 7.0.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1 +1,45 @@
|
|
|
1
|
-
# Editor
|
|
1
|
+
# Editor Plugin Block Menu
|
|
2
|
+
|
|
3
|
+
Block Menu plugin for @atlaskit/editor-core
|
|
4
|
+
|
|
5
|
+
**Note:** This component is designed for internal Atlassian development.
|
|
6
|
+
External contributors will be able to use this component but will not be able to submit issues.
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
The Block Menu plugin provides a context menu for block-level transformations and operations in the Atlassian Editor. It enables users to quickly transform content blocks (paragraphs, lists, headings, etc.) into different node types and perform block-level actions like moving, copying, and deleting content through an interactive menu interface.
|
|
11
|
+
|
|
12
|
+
## Key features
|
|
13
|
+
|
|
14
|
+
- **Block transformation** - Transform content blocks between different node types (paragraphs, lists, headings, blockquotes, code blocks, etc.)
|
|
15
|
+
- **Customizable menu** - Register custom menu items, sections, and nested menus through a flexible component registry
|
|
16
|
+
- **Block actions** - Move blocks up/down, delete, copy links to specific blocks with deep linking support
|
|
17
|
+
- **Intelligent transformations** - Handle complex transformations with proper handling of nested content, lists, and mixed content types
|
|
18
|
+
- **Analytics integration** - Built-in event tracking for menu interactions and block transformations
|
|
19
|
+
- **Performance monitoring** - Measure and track transformation performance metrics
|
|
20
|
+
- **Keyboard and mouse support** - Open menu via drag handle, keyboard shortcut, or custom triggers
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
- **Install** - *yarn add @atlaskit/editor-plugin-block-menu*
|
|
25
|
+
- **npm** - [@atlaskit/editor-plugin-block-menu](https://www.npmjs.com/package/@atlaskit/editor-plugin-block-menu)
|
|
26
|
+
- **Source** - [Bitbucket](https://bitbucket.org/atlassian/atlassian-frontend/src/master/packages/editor/editor-plugin-block-menu)
|
|
27
|
+
- **Bundle** - [unpkg.com](https://unpkg.com/@atlaskit/editor-plugin-block-menu/dist/)
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
**Internal use only**
|
|
32
|
+
|
|
33
|
+
@atlaskit/editor-plugin-block-menu is intended for internal use by @atlaskit/editor-core and as a plugin dependency of the Editor within your product.
|
|
34
|
+
|
|
35
|
+
Direct use of this component is not supported.
|
|
36
|
+
|
|
37
|
+
Please see [Atlaskit - Editor plugin block menu](https://atlaskit.atlassian.com/packages/editor/editor-plugin-block-menu) for documentation and examples for this package.
|
|
38
|
+
|
|
39
|
+
## Support
|
|
40
|
+
|
|
41
|
+
For internal Atlassian, visit the slack channel [#help-editor](https://atlassian.slack.com/archives/CFG3PSQ9E) for support or visit [go/editor-help](https://go/editor-help) to submit a bug.
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
Please see [Atlassian Frontend - License](https://hello.atlassian.net/wiki/spaces/AF/pages/2589099144/Documentation#License) for more licensing information.
|
|
@@ -8,7 +8,6 @@ exports.wrapMixedContentStep = void 0;
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
10
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
11
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
11
|
var _marks = require("../marks");
|
|
13
12
|
var _types = require("../types");
|
|
14
13
|
var _utils2 = require("../utils");
|
|
@@ -38,12 +37,8 @@ var createTextContentContainer = function createTextContentContainer(textContent
|
|
|
38
37
|
* Creates a regular container with node content.
|
|
39
38
|
*/
|
|
40
39
|
var createNodeContentContainer = function createNodeContentContainer(nodeContent, targetNodeType) {
|
|
41
|
-
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
42
|
-
// Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
|
|
43
|
-
// object, preserving the expandedState WeakMap entry set in transformNode.ts.
|
|
44
|
-
// To clean up: remove the if-else, always use the flag-on branch.
|
|
45
40
|
var isExpandType = targetNodeType.name === 'expand' || targetNodeType.name === 'nestedExpand';
|
|
46
|
-
var nodeAttrs = isExpandType
|
|
41
|
+
var nodeAttrs = isExpandType ? {
|
|
47
42
|
localId: crypto.randomUUID()
|
|
48
43
|
} : {};
|
|
49
44
|
return targetNodeType.createAndFill(nodeAttrs, nodeContent);
|
|
@@ -81,11 +76,8 @@ var handleEmptyContainerEdgeCase = function handleEmptyContainerEdgeCase(result,
|
|
|
81
76
|
return emptyCodeBlock ? [emptyCodeBlock].concat((0, _toConsumableArray2.default)(result)) : result;
|
|
82
77
|
}
|
|
83
78
|
var emptyParagraph = schema.nodes.paragraph.create();
|
|
84
|
-
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
85
|
-
// Same localId pre-assignment rationale as createNodeContentContainer above.
|
|
86
|
-
// To clean up: remove the if-else, always use the flag-on branch.
|
|
87
79
|
var isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
|
|
88
|
-
var emptyContainerAttrs = isExpandType
|
|
80
|
+
var emptyContainerAttrs = isExpandType ? {
|
|
89
81
|
localId: crypto.randomUUID()
|
|
90
82
|
} : {};
|
|
91
83
|
var emptyContainer = targetNodeType.create(emptyContainerAttrs, emptyParagraph);
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
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"));
|
|
9
7
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
8
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
9
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
10
|
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; }
|
|
16
11
|
/**
|
|
17
12
|
* Determines if a node is a text node (heading or paragraph).
|
|
18
13
|
* Text nodes can have their content converted to paragraphs when they can't be wrapped directly.
|
|
@@ -84,17 +79,10 @@ var convertNestedExpandToExpand = exports.convertNestedExpandToExpand = function
|
|
|
84
79
|
if (!expandType) {
|
|
85
80
|
return null;
|
|
86
81
|
}
|
|
87
|
-
|
|
88
|
-
|
|
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') ? {
|
|
82
|
+
return expandType.createAndFill({
|
|
83
|
+
title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || '',
|
|
93
84
|
localId: crypto.randomUUID()
|
|
94
|
-
}
|
|
95
|
-
return expandType.createAndFill(_objectSpread({
|
|
96
|
-
title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || ''
|
|
97
|
-
}, localIdAttr), node.content);
|
|
85
|
+
}, node.content);
|
|
98
86
|
};
|
|
99
87
|
|
|
100
88
|
/**
|
|
@@ -108,16 +96,10 @@ var convertExpandToNestedExpand = exports.convertExpandToNestedExpand = function
|
|
|
108
96
|
if (!nestedExpandType) {
|
|
109
97
|
return null;
|
|
110
98
|
}
|
|
111
|
-
|
|
112
|
-
|
|
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') ? {
|
|
99
|
+
return nestedExpandType.createAndFill({
|
|
100
|
+
title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || '',
|
|
116
101
|
localId: crypto.randomUUID()
|
|
117
|
-
}
|
|
118
|
-
return nestedExpandType.createAndFill(_objectSpread({
|
|
119
|
-
title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || ''
|
|
120
|
-
}, localIdAttr), node.content);
|
|
102
|
+
}, node.content);
|
|
121
103
|
};
|
|
122
104
|
|
|
123
105
|
/**
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.wrapStep = void 0;
|
|
7
7
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
8
|
var _marks = require("./marks");
|
|
10
9
|
var _utils2 = require("./utils");
|
|
11
10
|
/**
|
|
@@ -34,14 +33,8 @@ var wrapStep = exports.wrapStep = function wrapStep(nodes, context) {
|
|
|
34
33
|
});
|
|
35
34
|
}
|
|
36
35
|
var targetNodeType = schema.nodes[targetNodeTypeName];
|
|
37
|
-
|
|
38
|
-
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
39
|
-
// Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
|
|
40
|
-
// object (via setNodeAttribute), which would invalidate the expandedState WeakMap entry set
|
|
41
|
-
// in transformNode.ts and cause the expand to render as collapsed.
|
|
42
|
-
// To clean up: remove the if-else, always use the flag-on branch (isExpandType with uuid).
|
|
43
36
|
var isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
|
|
44
|
-
var nodeAttrs = isExpandType
|
|
37
|
+
var nodeAttrs = isExpandType ? {
|
|
45
38
|
localId: crypto.randomUUID()
|
|
46
39
|
} : {};
|
|
47
40
|
var sourceSupportsBreakout = _utils.breakoutResizableNodes.includes(fromNode.type.name);
|
|
@@ -12,7 +12,6 @@ var _selection = require("@atlaskit/editor-common/selection");
|
|
|
12
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
13
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
14
14
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
15
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
15
|
var _isNestedNode = require("../ui/utils/isNestedNode");
|
|
17
16
|
var _transform2 = require("./transform-node-utils/transform");
|
|
18
17
|
var _utils = require("./transforms/utils");
|
|
@@ -55,23 +54,13 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
55
54
|
});
|
|
56
55
|
var content = resultNodes.length > 0 ? resultNodes : sourceNodes;
|
|
57
56
|
var sliceStart = isList ? $from.pos - 1 : $from.pos;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
// To clean up: remove the if-else block and keep only the flag-on body.
|
|
66
|
-
if ((0, _platformFeatureFlags.fg)('platform_editor_block_menu_expand_localid_fix')) {
|
|
67
|
-
var expand = nodes.expand,
|
|
68
|
-
nestedExpand = nodes.nestedExpand;
|
|
69
|
-
content.forEach(function (node) {
|
|
70
|
-
if (node.type === expand || node.type === nestedExpand) {
|
|
71
|
-
_expand.expandedState.set(node, true);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
57
|
+
var expand = nodes.expand,
|
|
58
|
+
nestedExpand = nodes.nestedExpand;
|
|
59
|
+
content.forEach(function (node) {
|
|
60
|
+
if (node.type === expand || node.type === nestedExpand) {
|
|
61
|
+
_expand.expandedState.set(node, true);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
75
64
|
if (preservedSelection instanceof _state.NodeSelection && preservedSelection.node.type === nodes.mediaSingle) {
|
|
76
65
|
var _api$blockControls2;
|
|
77
66
|
// when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { breakoutResizableNodes } from '@atlaskit/editor-common/utils';
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { removeDisallowedMarks } from '../marks';
|
|
5
4
|
import { NODE_CATEGORY_BY_TYPE } from '../types';
|
|
6
5
|
import { convertTextNodeToParagraph, createTextContent, isTextNode } from '../utils';
|
|
@@ -31,12 +30,8 @@ const createTextContentContainer = (textContentArray, targetNodeType, schema) =>
|
|
|
31
30
|
* Creates a regular container with node content.
|
|
32
31
|
*/
|
|
33
32
|
const createNodeContentContainer = (nodeContent, targetNodeType) => {
|
|
34
|
-
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
35
|
-
// Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
|
|
36
|
-
// object, preserving the expandedState WeakMap entry set in transformNode.ts.
|
|
37
|
-
// To clean up: remove the if-else, always use the flag-on branch.
|
|
38
33
|
const isExpandType = targetNodeType.name === 'expand' || targetNodeType.name === 'nestedExpand';
|
|
39
|
-
const nodeAttrs = isExpandType
|
|
34
|
+
const nodeAttrs = isExpandType ? {
|
|
40
35
|
localId: crypto.randomUUID()
|
|
41
36
|
} : {};
|
|
42
37
|
return targetNodeType.createAndFill(nodeAttrs, nodeContent);
|
|
@@ -74,11 +69,8 @@ const handleEmptyContainerEdgeCase = (result, hasCreatedContainer, fromNode, tar
|
|
|
74
69
|
return emptyCodeBlock ? [emptyCodeBlock, ...result] : result;
|
|
75
70
|
}
|
|
76
71
|
const emptyParagraph = schema.nodes.paragraph.create();
|
|
77
|
-
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
78
|
-
// Same localId pre-assignment rationale as createNodeContentContainer above.
|
|
79
|
-
// To clean up: remove the if-else, always use the flag-on branch.
|
|
80
72
|
const isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
|
|
81
|
-
const emptyContainerAttrs = isExpandType
|
|
73
|
+
const emptyContainerAttrs = isExpandType ? {
|
|
82
74
|
localId: crypto.randomUUID()
|
|
83
75
|
} : {};
|
|
84
76
|
const emptyContainer = targetNodeType.create(emptyContainerAttrs, emptyParagraph);
|
|
@@ -1,7 +1,6 @@
|
|
|
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';
|
|
5
4
|
import { NODE_CATEGORY_BY_TYPE } from './types';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -76,17 +75,9 @@ export const convertNestedExpandToExpand = (node, schema) => {
|
|
|
76
75
|
if (!expandType) {
|
|
77
76
|
return null;
|
|
78
77
|
}
|
|
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
|
-
} : {};
|
|
87
78
|
return expandType.createAndFill({
|
|
88
79
|
title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || '',
|
|
89
|
-
|
|
80
|
+
localId: crypto.randomUUID()
|
|
90
81
|
}, node.content);
|
|
91
82
|
};
|
|
92
83
|
|
|
@@ -101,16 +92,9 @@ export const convertExpandToNestedExpand = (node, schema) => {
|
|
|
101
92
|
if (!nestedExpandType) {
|
|
102
93
|
return null;
|
|
103
94
|
}
|
|
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
|
-
} : {};
|
|
111
95
|
return nestedExpandType.createAndFill({
|
|
112
96
|
title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || '',
|
|
113
|
-
|
|
97
|
+
localId: crypto.randomUUID()
|
|
114
98
|
}, node.content);
|
|
115
99
|
};
|
|
116
100
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { breakoutResizableNodes } from '@atlaskit/editor-common/utils';
|
|
2
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
2
|
import { removeDisallowedMarks } from './marks';
|
|
4
3
|
import { convertExpandToNestedExpand } from './utils';
|
|
5
4
|
|
|
@@ -31,14 +30,8 @@ export const wrapStep = (nodes, context) => {
|
|
|
31
30
|
});
|
|
32
31
|
}
|
|
33
32
|
const targetNodeType = schema.nodes[targetNodeTypeName];
|
|
34
|
-
|
|
35
|
-
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
36
|
-
// Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
|
|
37
|
-
// object (via setNodeAttribute), which would invalidate the expandedState WeakMap entry set
|
|
38
|
-
// in transformNode.ts and cause the expand to render as collapsed.
|
|
39
|
-
// To clean up: remove the if-else, always use the flag-on branch (isExpandType with uuid).
|
|
40
33
|
const isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
|
|
41
|
-
const nodeAttrs = isExpandType
|
|
34
|
+
const nodeAttrs = isExpandType ? {
|
|
42
35
|
localId: crypto.randomUUID()
|
|
43
36
|
} : {};
|
|
44
37
|
const sourceSupportsBreakout = breakoutResizableNodes.includes(fromNode.type.name);
|
|
@@ -6,7 +6,6 @@ import { expandSelectionToBlockRange, getSourceNodesFromSelectionRange } from '@
|
|
|
6
6
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { Mapping, StepMap } from '@atlaskit/editor-prosemirror/transform';
|
|
8
8
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
9
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
9
|
import { isNestedNode } from '../ui/utils/isNestedNode';
|
|
11
10
|
import { convertNodesToTargetType } from './transform-node-utils/transform';
|
|
12
11
|
import { isListNode } from './transforms/utils';
|
|
@@ -51,25 +50,15 @@ export const transformNode = api => (targetType, metadata) => ({
|
|
|
51
50
|
});
|
|
52
51
|
const content = resultNodes.length > 0 ? resultNodes : sourceNodes;
|
|
53
52
|
const sliceStart = isList ? $from.pos - 1 : $from.pos;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const {
|
|
64
|
-
expand,
|
|
65
|
-
nestedExpand
|
|
66
|
-
} = nodes;
|
|
67
|
-
content.forEach(node => {
|
|
68
|
-
if (node.type === expand || node.type === nestedExpand) {
|
|
69
|
-
expandedState.set(node, true);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
53
|
+
const {
|
|
54
|
+
expand,
|
|
55
|
+
nestedExpand
|
|
56
|
+
} = nodes;
|
|
57
|
+
content.forEach(node => {
|
|
58
|
+
if (node.type === expand || node.type === nestedExpand) {
|
|
59
|
+
expandedState.set(node, true);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
73
62
|
if (preservedSelection instanceof NodeSelection && preservedSelection.node.type === nodes.mediaSingle) {
|
|
74
63
|
var _api$blockControls2;
|
|
75
64
|
// when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import { breakoutResizableNodes } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { removeDisallowedMarks } from '../marks';
|
|
6
5
|
import { NODE_CATEGORY_BY_TYPE } from '../types';
|
|
7
6
|
import { convertTextNodeToParagraph, createTextContent, isTextNode } from '../utils';
|
|
@@ -32,12 +31,8 @@ var createTextContentContainer = function createTextContentContainer(textContent
|
|
|
32
31
|
* Creates a regular container with node content.
|
|
33
32
|
*/
|
|
34
33
|
var createNodeContentContainer = function createNodeContentContainer(nodeContent, targetNodeType) {
|
|
35
|
-
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
36
|
-
// Pre-assigns a localId so the localId plugin's appendTransaction does not replace the node
|
|
37
|
-
// object, preserving the expandedState WeakMap entry set in transformNode.ts.
|
|
38
|
-
// To clean up: remove the if-else, always use the flag-on branch.
|
|
39
34
|
var isExpandType = targetNodeType.name === 'expand' || targetNodeType.name === 'nestedExpand';
|
|
40
|
-
var nodeAttrs = isExpandType
|
|
35
|
+
var nodeAttrs = isExpandType ? {
|
|
41
36
|
localId: crypto.randomUUID()
|
|
42
37
|
} : {};
|
|
43
38
|
return targetNodeType.createAndFill(nodeAttrs, nodeContent);
|
|
@@ -75,11 +70,8 @@ var handleEmptyContainerEdgeCase = function handleEmptyContainerEdgeCase(result,
|
|
|
75
70
|
return emptyCodeBlock ? [emptyCodeBlock].concat(_toConsumableArray(result)) : result;
|
|
76
71
|
}
|
|
77
72
|
var emptyParagraph = schema.nodes.paragraph.create();
|
|
78
|
-
// [FEATURE FLAG: platform_editor_block_menu_expand_localid_fix]
|
|
79
|
-
// Same localId pre-assignment rationale as createNodeContentContainer above.
|
|
80
|
-
// To clean up: remove the if-else, always use the flag-on branch.
|
|
81
73
|
var isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
|
|
82
|
-
var emptyContainerAttrs = isExpandType
|
|
74
|
+
var emptyContainerAttrs = isExpandType ? {
|
|
83
75
|
localId: crypto.randomUUID()
|
|
84
76
|
} : {};
|
|
85
77
|
var emptyContainer = targetNodeType.create(emptyContainerAttrs, emptyParagraph);
|
|
@@ -1,10 +1,6 @@
|
|
|
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; }
|
|
4
1
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
2
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
3
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
4
|
import { NODE_CATEGORY_BY_TYPE } from './types';
|
|
9
5
|
|
|
10
6
|
/**
|
|
@@ -78,17 +74,10 @@ export var convertNestedExpandToExpand = function convertNestedExpandToExpand(no
|
|
|
78
74
|
if (!expandType) {
|
|
79
75
|
return null;
|
|
80
76
|
}
|
|
81
|
-
|
|
82
|
-
|
|
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') ? {
|
|
77
|
+
return expandType.createAndFill({
|
|
78
|
+
title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || '',
|
|
87
79
|
localId: crypto.randomUUID()
|
|
88
|
-
}
|
|
89
|
-
return expandType.createAndFill(_objectSpread({
|
|
90
|
-
title: ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.title) || ''
|
|
91
|
-
}, localIdAttr), node.content);
|
|
80
|
+
}, node.content);
|
|
92
81
|
};
|
|
93
82
|
|
|
94
83
|
/**
|
|
@@ -102,16 +91,10 @@ export var convertExpandToNestedExpand = function convertExpandToNestedExpand(no
|
|
|
102
91
|
if (!nestedExpandType) {
|
|
103
92
|
return null;
|
|
104
93
|
}
|
|
105
|
-
|
|
106
|
-
|
|
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') ? {
|
|
94
|
+
return nestedExpandType.createAndFill({
|
|
95
|
+
title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || '',
|
|
110
96
|
localId: crypto.randomUUID()
|
|
111
|
-
}
|
|
112
|
-
return nestedExpandType.createAndFill(_objectSpread({
|
|
113
|
-
title: ((_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) || ''
|
|
114
|
-
}, localIdAttr), node.content);
|
|
97
|
+
}, node.content);
|
|
115
98
|
};
|
|
116
99
|
|
|
117
100
|
/**
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { breakoutResizableNodes } from '@atlaskit/editor-common/utils';
|
|
2
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
2
|
import { removeDisallowedMarks } from './marks';
|
|
4
3
|
import { convertExpandToNestedExpand } from './utils';
|
|
5
4
|
|
|
@@ -29,14 +28,8 @@ export var wrapStep = function wrapStep(nodes, context) {
|
|
|
29
28
|
});
|
|
30
29
|
}
|
|
31
30
|
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
31
|
var isExpandType = targetNodeTypeName === 'expand' || targetNodeTypeName === 'nestedExpand';
|
|
39
|
-
var nodeAttrs = isExpandType
|
|
32
|
+
var nodeAttrs = isExpandType ? {
|
|
40
33
|
localId: crypto.randomUUID()
|
|
41
34
|
} : {};
|
|
42
35
|
var sourceSupportsBreakout = breakoutResizableNodes.includes(fromNode.type.name);
|
|
@@ -6,7 +6,6 @@ import { expandSelectionToBlockRange, getSourceNodesFromSelectionRange } from '@
|
|
|
6
6
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { Mapping, StepMap } from '@atlaskit/editor-prosemirror/transform';
|
|
8
8
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
9
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
9
|
import { isNestedNode } from '../ui/utils/isNestedNode';
|
|
11
10
|
import { convertNodesToTargetType } from './transform-node-utils/transform';
|
|
12
11
|
import { isListNode } from './transforms/utils';
|
|
@@ -49,23 +48,13 @@ export var transformNode = function transformNode(api) {
|
|
|
49
48
|
});
|
|
50
49
|
var content = resultNodes.length > 0 ? resultNodes : sourceNodes;
|
|
51
50
|
var sliceStart = isList ? $from.pos - 1 : $from.pos;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
var expand = nodes.expand,
|
|
62
|
-
nestedExpand = nodes.nestedExpand;
|
|
63
|
-
content.forEach(function (node) {
|
|
64
|
-
if (node.type === expand || node.type === nestedExpand) {
|
|
65
|
-
expandedState.set(node, true);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
51
|
+
var expand = nodes.expand,
|
|
52
|
+
nestedExpand = nodes.nestedExpand;
|
|
53
|
+
content.forEach(function (node) {
|
|
54
|
+
if (node.type === expand || node.type === nestedExpand) {
|
|
55
|
+
expandedState.set(node, true);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
69
58
|
if (preservedSelection instanceof NodeSelection && preservedSelection.node.type === nodes.mediaSingle) {
|
|
70
59
|
var _api$blockControls2;
|
|
71
60
|
// when node is media single, use tr.replaceWith freeze editor, if modify position, tr.replaceWith creates duplicats
|
package/docs/0-intro.tsx
CHANGED
|
@@ -30,7 +30,85 @@ The \`dependencies\`, \`configuration\`, \`state\`, \`actions\`, and \`commands\
|
|
|
30
30
|
below:
|
|
31
31
|
|
|
32
32
|
${code`
|
|
33
|
-
|
|
33
|
+
enum FLAG_ID {
|
|
34
|
+
LINK_COPIED_TO_CLIPBOARD = 'link-copied-to-clipboard',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type BlockMenuPlugin = NextEditorPlugin<
|
|
38
|
+
'blockMenu',
|
|
39
|
+
{
|
|
40
|
+
actions: {
|
|
41
|
+
getBlockMenuComponents: () => Array<RegisterBlockMenuComponent>;
|
|
42
|
+
isTransformOptionDisabled: (
|
|
43
|
+
optionNodeTypeName: string,
|
|
44
|
+
optionNodeTypeAttrs?: Record<string, unknown>,
|
|
45
|
+
) => boolean;
|
|
46
|
+
registerBlockMenuComponents: (blockMenuComponents: Array<RegisterBlockMenuComponent>) => void;
|
|
47
|
+
};
|
|
48
|
+
commands: {
|
|
49
|
+
transformNode: TransformNodeCommand;
|
|
50
|
+
};
|
|
51
|
+
dependencies: [
|
|
52
|
+
OptionalPlugin<BlockControlsPlugin>,
|
|
53
|
+
OptionalPlugin<UserIntentPlugin>,
|
|
54
|
+
OptionalPlugin<SelectionPlugin>,
|
|
55
|
+
OptionalPlugin<DecorationsPlugin>,
|
|
56
|
+
OptionalPlugin<AnalyticsPlugin>,
|
|
57
|
+
];
|
|
58
|
+
pluginConfiguration?: BlockMenuPluginOptions;
|
|
59
|
+
sharedState: BlockMenuSharedState;
|
|
60
|
+
}
|
|
61
|
+
>;
|
|
62
|
+
|
|
63
|
+
type BlockMenuPluginOptions = {
|
|
64
|
+
blockLinkHashPrefix?: string;
|
|
65
|
+
getLinkPath?: () => string | null;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
type BlockMenuSharedState =
|
|
69
|
+
| {
|
|
70
|
+
currentSelectedNodeName: string | undefined;
|
|
71
|
+
showFlag: FLAG_ID | false;
|
|
72
|
+
}
|
|
73
|
+
| undefined;
|
|
74
|
+
|
|
75
|
+
type Parent<T> = T & { rank: number };
|
|
76
|
+
|
|
77
|
+
type ComponentTypes = Array<BlockMenuSection | BlockMenuItem | BlockMenuNested>;
|
|
78
|
+
|
|
79
|
+
type BlockMenuNestedComponent = (props: { children: React.ReactNode }) => React.ReactNode;
|
|
80
|
+
|
|
81
|
+
type BlockMenuSectionComponent = (props: { children: React.ReactNode }) => React.ReactNode;
|
|
82
|
+
|
|
83
|
+
type BlockMenuNestedSectionComponent = (props: {
|
|
84
|
+
children: React.ReactNode;
|
|
85
|
+
}) => React.ReactNode;
|
|
86
|
+
|
|
87
|
+
type BlockMenuItemComponent = () => React.ReactNode;
|
|
88
|
+
|
|
89
|
+
type RegisterBlockMenuNested = BlockMenuNested & {
|
|
90
|
+
component?: BlockMenuNestedComponent;
|
|
91
|
+
parent: Parent<BlockMenuSection>;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
type RegisterBlockMenuSection = BlockMenuSection & {
|
|
95
|
+
component?: BlockMenuSectionComponent;
|
|
96
|
+
parent?: Parent<BlockMenuNested>;
|
|
97
|
+
rank?: number;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
type RegisterBlockMenuItem = BlockMenuItem & {
|
|
101
|
+
component?: BlockMenuItemComponent;
|
|
102
|
+
isHidden?: () => boolean;
|
|
103
|
+
parent: Parent<BlockMenuSection>;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
type RegisterBlockMenuComponent =
|
|
107
|
+
| RegisterBlockMenuNested
|
|
108
|
+
| RegisterBlockMenuSection
|
|
109
|
+
| RegisterBlockMenuItem;
|
|
110
|
+
|
|
111
|
+
type RegisterBlockMenuComponentType = RegisterBlockMenuComponent['type'];
|
|
34
112
|
`}
|
|
35
113
|
|
|
36
114
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-menu",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.3",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
45
45
|
"@atlaskit/primitives": "^18.0.0",
|
|
46
46
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
47
|
-
"@atlaskit/tmp-editor-statsig": "^36.
|
|
47
|
+
"@atlaskit/tmp-editor-statsig": "^36.3.0",
|
|
48
48
|
"@atlaskit/tokens": "^11.1.0",
|
|
49
49
|
"@babel/runtime": "^7.0.0",
|
|
50
50
|
"bind-event-listener": "^3.0.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@atlaskit/editor-common": "^112.
|
|
53
|
+
"@atlaskit/editor-common": "^112.2.0",
|
|
54
54
|
"react": "^18.2.0",
|
|
55
55
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
56
56
|
},
|
|
@@ -97,9 +97,6 @@
|
|
|
97
97
|
"platform_editor_block_menu_copy_section": {
|
|
98
98
|
"type": "boolean"
|
|
99
99
|
},
|
|
100
|
-
"platform_editor_block_menu_expand_localid_fix": {
|
|
101
|
-
"type": "boolean"
|
|
102
|
-
},
|
|
103
100
|
"platform_editor_block_menu_v2_patch_2": {
|
|
104
101
|
"type": "boolean"
|
|
105
102
|
},
|