@atlaskit/editor-plugin-block-menu 11.0.5 → 11.1.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.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/editor-commands/transformNode.js +11 -3
- package/dist/cjs/ui/suggested-menu-items.js +2 -1
- package/dist/es2019/editor-commands/transformNode.js +4 -0
- package/dist/es2019/ui/suggested-menu-items.js +2 -1
- package/dist/esm/editor-commands/transformNode.js +10 -3
- package/dist/esm/ui/suggested-menu-items.js +2 -1
- package/dist/types/blockMenuPluginType.d.ts +7 -1
- package/dist/types/editor-commands/types.d.ts +1 -0
- package/dist/types/entry-points/blockMenuPluginType.d.ts +1 -1
- package/package.json +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 11.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`b483e293da76f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b483e293da76f) -
|
|
8
|
+
Add a gated `isSuggested` attribute to block menu element transformed analytics events so
|
|
9
|
+
suggested and non-suggested transform selections can be distinguished. The event attribute is
|
|
10
|
+
gated behind the `platform_editor_blocks_patch_2` feature gate.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 11.0.5
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -1,9 +1,11 @@
|
|
|
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.transformNode = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
10
|
var _expand = require("@atlaskit/editor-common/expand");
|
|
9
11
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
@@ -16,6 +18,8 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
16
18
|
var _isNestedNode = require("../ui/utils/isNestedNode");
|
|
17
19
|
var _transform2 = require("./transform-node-utils/transform");
|
|
18
20
|
var _utils = require("./transform-node-utils/utils");
|
|
21
|
+
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; }
|
|
22
|
+
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; }
|
|
19
23
|
var transformNode = exports.transformNode = function transformNode(api) {
|
|
20
24
|
return function (targetType, metadata) {
|
|
21
25
|
return function (_ref) {
|
|
@@ -44,6 +48,7 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
44
48
|
|
|
45
49
|
// Check if source node is empty paragraph or heading
|
|
46
50
|
var isEmptyLine = sourceNodes.length === 1 && (sourceNodes[0].type === nodes.paragraph || sourceNodes[0].type === nodes.heading) && (sourceNodes[0].content.size === 0 || sourceNodes[0].textContent.trim() === '');
|
|
51
|
+
var isSuggested = Boolean(metadata === null || metadata === void 0 ? void 0 : metadata.isSuggested);
|
|
47
52
|
try {
|
|
48
53
|
var resultNodes = (0, _transform2.convertNodesToTargetType)({
|
|
49
54
|
sourceNodes: sourceNodes,
|
|
@@ -113,10 +118,13 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
113
118
|
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({
|
|
114
119
|
action: _analytics.ACTION.TRANSFORMED,
|
|
115
120
|
actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
|
|
116
|
-
attributes: {
|
|
121
|
+
attributes: _objectSpread(_objectSpread({
|
|
117
122
|
duration: duration,
|
|
118
123
|
isEmptyLine: isEmptyLine,
|
|
119
|
-
isNested: isNested
|
|
124
|
+
isNested: isNested
|
|
125
|
+
}, (0, _platformFeatureFlags.fg)('platform_editor_blocks_patch_2') ? {
|
|
126
|
+
isSuggested: isSuggested
|
|
127
|
+
} : {}), {}, {
|
|
120
128
|
sourceNodesCount: sourceNodes.length,
|
|
121
129
|
sourceNodesCountByType: sourceNodeTypes,
|
|
122
130
|
sourceNodeType: sourceNodes.length === 1 ? sourceNodes[0].type.name : 'multiple',
|
|
@@ -124,7 +132,7 @@ var transformNode = exports.transformNode = function transformNode(api) {
|
|
|
124
132
|
targetNodeType: targetType.name,
|
|
125
133
|
outputNodesCount: content.length,
|
|
126
134
|
inputMethod: _analytics.INPUT_METHOD.BLOCK_MENU
|
|
127
|
-
},
|
|
135
|
+
}),
|
|
128
136
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
129
137
|
})(tr);
|
|
130
138
|
});
|
|
@@ -13,7 +13,8 @@ var SuggestedMenuItems = exports.SuggestedMenuItems = /*#__PURE__*/_react.defaul
|
|
|
13
13
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, suggestedItems.map(function (item) {
|
|
14
14
|
var ItemComponent = item.component;
|
|
15
15
|
return ItemComponent ? /*#__PURE__*/_react.default.createElement(ItemComponent, {
|
|
16
|
-
key: item.key
|
|
16
|
+
key: item.key,
|
|
17
|
+
isSuggested: true
|
|
17
18
|
}) : null;
|
|
18
19
|
}));
|
|
19
20
|
});
|
|
@@ -40,6 +40,7 @@ export const transformNode = api => (targetType, metadata) => ({
|
|
|
40
40
|
|
|
41
41
|
// Check if source node is empty paragraph or heading
|
|
42
42
|
const isEmptyLine = sourceNodes.length === 1 && (sourceNodes[0].type === nodes.paragraph || sourceNodes[0].type === nodes.heading) && (sourceNodes[0].content.size === 0 || sourceNodes[0].textContent.trim() === '');
|
|
43
|
+
const isSuggested = Boolean(metadata === null || metadata === void 0 ? void 0 : metadata.isSuggested);
|
|
43
44
|
try {
|
|
44
45
|
const resultNodes = convertNodesToTargetType({
|
|
45
46
|
sourceNodes,
|
|
@@ -111,6 +112,9 @@ export const transformNode = api => (targetType, metadata) => ({
|
|
|
111
112
|
duration,
|
|
112
113
|
isEmptyLine,
|
|
113
114
|
isNested,
|
|
115
|
+
...(fg('platform_editor_blocks_patch_2') ? {
|
|
116
|
+
isSuggested
|
|
117
|
+
} : {}),
|
|
114
118
|
sourceNodesCount: sourceNodes.length,
|
|
115
119
|
sourceNodesCountByType: sourceNodeTypes,
|
|
116
120
|
sourceNodeType: sourceNodes.length === 1 ? sourceNodes[0].type.name : 'multiple',
|
|
@@ -7,7 +7,8 @@ export const SuggestedMenuItems = /*#__PURE__*/React.memo(({
|
|
|
7
7
|
return /*#__PURE__*/React.createElement(React.Fragment, null, suggestedItems.map(item => {
|
|
8
8
|
const ItemComponent = item.component;
|
|
9
9
|
return ItemComponent ? /*#__PURE__*/React.createElement(ItemComponent, {
|
|
10
|
-
key: item.key
|
|
10
|
+
key: item.key,
|
|
11
|
+
isSuggested: true
|
|
11
12
|
}) : null;
|
|
12
13
|
}));
|
|
13
14
|
});
|
|
@@ -1,3 +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; }
|
|
1
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
5
|
import { expandedState } from '@atlaskit/editor-common/expand';
|
|
3
6
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
@@ -38,6 +41,7 @@ export var transformNode = function transformNode(api) {
|
|
|
38
41
|
|
|
39
42
|
// Check if source node is empty paragraph or heading
|
|
40
43
|
var isEmptyLine = sourceNodes.length === 1 && (sourceNodes[0].type === nodes.paragraph || sourceNodes[0].type === nodes.heading) && (sourceNodes[0].content.size === 0 || sourceNodes[0].textContent.trim() === '');
|
|
44
|
+
var isSuggested = Boolean(metadata === null || metadata === void 0 ? void 0 : metadata.isSuggested);
|
|
41
45
|
try {
|
|
42
46
|
var resultNodes = convertNodesToTargetType({
|
|
43
47
|
sourceNodes: sourceNodes,
|
|
@@ -107,10 +111,13 @@ export var transformNode = function transformNode(api) {
|
|
|
107
111
|
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({
|
|
108
112
|
action: ACTION.TRANSFORMED,
|
|
109
113
|
actionSubject: ACTION_SUBJECT.ELEMENT,
|
|
110
|
-
attributes: {
|
|
114
|
+
attributes: _objectSpread(_objectSpread({
|
|
111
115
|
duration: duration,
|
|
112
116
|
isEmptyLine: isEmptyLine,
|
|
113
|
-
isNested: isNested
|
|
117
|
+
isNested: isNested
|
|
118
|
+
}, fg('platform_editor_blocks_patch_2') ? {
|
|
119
|
+
isSuggested: isSuggested
|
|
120
|
+
} : {}), {}, {
|
|
114
121
|
sourceNodesCount: sourceNodes.length,
|
|
115
122
|
sourceNodesCountByType: sourceNodeTypes,
|
|
116
123
|
sourceNodeType: sourceNodes.length === 1 ? sourceNodes[0].type.name : 'multiple',
|
|
@@ -118,7 +125,7 @@ export var transformNode = function transformNode(api) {
|
|
|
118
125
|
targetNodeType: targetType.name,
|
|
119
126
|
outputNodesCount: content.length,
|
|
120
127
|
inputMethod: INPUT_METHOD.BLOCK_MENU
|
|
121
|
-
},
|
|
128
|
+
}),
|
|
122
129
|
eventType: EVENT_TYPE.TRACK
|
|
123
130
|
})(tr);
|
|
124
131
|
});
|
|
@@ -6,7 +6,8 @@ export var SuggestedMenuItems = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
6
6
|
return /*#__PURE__*/React.createElement(React.Fragment, null, suggestedItems.map(function (item) {
|
|
7
7
|
var ItemComponent = item.component;
|
|
8
8
|
return ItemComponent ? /*#__PURE__*/React.createElement(ItemComponent, {
|
|
9
|
-
key: item.key
|
|
9
|
+
key: item.key,
|
|
10
|
+
isSuggested: true
|
|
10
11
|
}) : null;
|
|
11
12
|
}));
|
|
12
13
|
});
|
|
@@ -104,7 +104,13 @@ export type BlockMenuSectionComponent = (props: {
|
|
|
104
104
|
export type BlockMenuNestedSectionComponent = (props: {
|
|
105
105
|
children: React.ReactNode;
|
|
106
106
|
}) => React.ReactNode;
|
|
107
|
-
export type
|
|
107
|
+
export type BlockMenuItemComponentProps = {
|
|
108
|
+
/**
|
|
109
|
+
* TODO: Make this required when cleaning up platform_editor_blocks_patch_2.
|
|
110
|
+
*/
|
|
111
|
+
isSuggested?: boolean;
|
|
112
|
+
};
|
|
113
|
+
export type BlockMenuItemComponent = (props?: BlockMenuItemComponentProps) => React.ReactNode;
|
|
108
114
|
export type RegisterBlockMenuNested = BlockMenuNested & {
|
|
109
115
|
component?: BlockMenuNestedComponent;
|
|
110
116
|
isHidden?: () => boolean;
|
|
@@ -2,6 +2,7 @@ import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
export type TransfromNodeTargetType = 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'blockquote' | 'expand' | 'layoutSection' | 'panel' | 'panel_c1' | 'codeBlock' | 'bulletList' | 'orderedList' | 'taskList' | 'decisionList';
|
|
3
3
|
export type TransformNodeMetadata = {
|
|
4
4
|
inputMethod: INPUT_METHOD.BLOCK_MENU;
|
|
5
|
+
isSuggested?: boolean;
|
|
5
6
|
targetAttrs?: Record<string, unknown>;
|
|
6
7
|
targetTypeName: TransfromNodeTargetType;
|
|
7
8
|
triggeredFrom: INPUT_METHOD.MOUSE | INPUT_METHOD.KEYBOARD;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { BlockMenuPlugin, RegisterBlockMenuComponent, Parent, BlockMenuPluginOptions, BlockMenuSharedState, } from '../blockMenuPluginType';
|
|
1
|
+
export type { BlockMenuPlugin, RegisterBlockMenuComponent, BlockMenuItemComponentProps, BlockMenuItemComponent, Parent, BlockMenuPluginOptions, BlockMenuSharedState, } from '../blockMenuPluginType';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-menu",
|
|
3
|
-
"version": "11.0
|
|
3
|
+
"version": "11.1.0",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
37
37
|
"@atlaskit/primitives": "^20.0.0",
|
|
38
38
|
"@atlaskit/prosemirror-history": "^1.0.0",
|
|
39
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
40
|
-
"@atlaskit/tokens": "^
|
|
39
|
+
"@atlaskit/tmp-editor-statsig": "^110.0.0",
|
|
40
|
+
"@atlaskit/tokens": "^15.0.0",
|
|
41
41
|
"@babel/runtime": "^7.0.0",
|
|
42
42
|
"bind-event-listener": "^3.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@atlaskit/editor-common": "^116.
|
|
45
|
+
"@atlaskit/editor-common": "^116.11.0",
|
|
46
46
|
"react": "^18.2.0",
|
|
47
47
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
48
48
|
},
|
|
@@ -101,6 +101,9 @@
|
|
|
101
101
|
"platform_editor_block_menu_v2_patch_2": {
|
|
102
102
|
"type": "boolean"
|
|
103
103
|
},
|
|
104
|
+
"platform_editor_blocks_patch_2": {
|
|
105
|
+
"type": "boolean"
|
|
106
|
+
},
|
|
104
107
|
"cc-maui-phase-3": {
|
|
105
108
|
"type": "boolean"
|
|
106
109
|
}
|
|
@@ -108,6 +111,6 @@
|
|
|
108
111
|
"devDependencies": {
|
|
109
112
|
"@atlassian/structured-docs-types": "workspace:^",
|
|
110
113
|
"react": "^18.2.0",
|
|
111
|
-
"react-intl": "^
|
|
114
|
+
"react-intl": "^7.0.0"
|
|
112
115
|
}
|
|
113
116
|
}
|