@atlaskit/editor-plugin-insert-block 8.4.5 → 8.5.1
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 +17 -0
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +18 -5
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +15 -4
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +17 -4
- package/dist/types/ui/ElementBrowser/InsertMenu.d.ts +5 -2
- package/dist/types-ts4.5/ui/ElementBrowser/InsertMenu.d.ts +5 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-insert-block
|
|
2
2
|
|
|
3
|
+
## 8.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 8.5.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`fcc51e510981b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fcc51e510981b) -
|
|
14
|
+
[ux] Add logic to filter and pin create database menu item to editor toolbar for experiment.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 8.4.5
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.sortPrioritizedElements = exports.default = exports.DEFAULT_HEIGHT = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
@@ -21,6 +21,7 @@ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
|
21
21
|
var _uiReact = require("@atlaskit/editor-common/ui-react");
|
|
22
22
|
var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
|
|
23
23
|
var _colors = require("@atlaskit/theme/colors");
|
|
24
|
+
var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
24
25
|
var _excluded = ["children"];
|
|
25
26
|
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; }
|
|
26
27
|
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; } /**
|
|
@@ -30,12 +31,24 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
30
31
|
var DEFAULT_HEIGHT = exports.DEFAULT_HEIGHT = 560;
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
|
-
* Exported helper to allow testing of InsertMenu
|
|
34
|
+
* Exported helper to allow testing of InsertMenu pinning logic. NOTE: this is
|
|
34
35
|
*not* the ideal way to approach this, quickinsert plugin provides a `getSuggestions`
|
|
35
36
|
method that can be used to get suggestions -> once all experiments are cleaned up,
|
|
36
37
|
they should be unified through `pluginInjectionApi?.quickInsert?.actions.getSuggestions`
|
|
38
|
+
|
|
39
|
+
`cc_fd_db_top_editor_toolbar` experiment adds new logic to sort elements by `priority`
|
|
40
|
+
this newer implementation matches how the "quick insert menu" sorts elements
|
|
37
41
|
*/
|
|
38
|
-
var
|
|
42
|
+
var sortPrioritizedElements = exports.sortPrioritizedElements = function sortPrioritizedElements(featuredItems, formatMessage) {
|
|
43
|
+
if (['new-description', 'orig-description'].includes((0, _expVal.expVal)('cc_fd_db_top_editor_toolbar', 'cohort', 'control'))) {
|
|
44
|
+
// Sort by priority (lower first) on the concatenated list so items
|
|
45
|
+
// with "priority" are at the top (e.g. Whiteboard before Database)
|
|
46
|
+
return featuredItems.slice(0).sort(function (a, b) {
|
|
47
|
+
return (a.priority || Number.POSITIVE_INFINITY) - (b.priority || Number.POSITIVE_INFINITY);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// old logic sort whiteboards to top
|
|
39
52
|
var DIAGRAM_KEY = 'whiteboard-extension:create-diagram';
|
|
40
53
|
var isDiagram = function isDiagram(item) {
|
|
41
54
|
return item.key === DIAGRAM_KEY;
|
|
@@ -170,8 +183,8 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
170
183
|
}) : item;
|
|
171
184
|
})) !== null && _pluginInjectionApi$q4 !== void 0 ? _pluginInjectionApi$q4 : [];
|
|
172
185
|
var unfilteredResult = quickInsertDropdownItems.concat(featuredQuickInsertSuggestions);
|
|
173
|
-
// need to
|
|
174
|
-
result =
|
|
186
|
+
// need to sort on the concatenated list so desired elements are at the top
|
|
187
|
+
result = sortPrioritizedElements(unfilteredResult, formatMessage);
|
|
175
188
|
}
|
|
176
189
|
setItemCount(result.length);
|
|
177
190
|
return result;
|
|
@@ -17,15 +17,26 @@ import { messages, IconCode, IconDate, IconDecision, IconDivider, IconExpand, Ic
|
|
|
17
17
|
import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
18
18
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
19
19
|
import { N0, N30A, N60A } from '@atlaskit/theme/colors';
|
|
20
|
+
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
20
21
|
export const DEFAULT_HEIGHT = 560;
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
|
-
* Exported helper to allow testing of InsertMenu
|
|
24
|
+
* Exported helper to allow testing of InsertMenu pinning logic. NOTE: this is
|
|
24
25
|
*not* the ideal way to approach this, quickinsert plugin provides a `getSuggestions`
|
|
25
26
|
method that can be used to get suggestions -> once all experiments are cleaned up,
|
|
26
27
|
they should be unified through `pluginInjectionApi?.quickInsert?.actions.getSuggestions`
|
|
28
|
+
|
|
29
|
+
`cc_fd_db_top_editor_toolbar` experiment adds new logic to sort elements by `priority`
|
|
30
|
+
this newer implementation matches how the "quick insert menu" sorts elements
|
|
27
31
|
*/
|
|
28
|
-
export const
|
|
32
|
+
export const sortPrioritizedElements = (featuredItems, formatMessage) => {
|
|
33
|
+
if (['new-description', 'orig-description'].includes(expVal('cc_fd_db_top_editor_toolbar', 'cohort', 'control'))) {
|
|
34
|
+
// Sort by priority (lower first) on the concatenated list so items
|
|
35
|
+
// with "priority" are at the top (e.g. Whiteboard before Database)
|
|
36
|
+
return featuredItems.slice(0).sort((a, b) => (a.priority || Number.POSITIVE_INFINITY) - (b.priority || Number.POSITIVE_INFINITY));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// old logic sort whiteboards to top
|
|
29
40
|
const DIAGRAM_KEY = 'whiteboard-extension:create-diagram';
|
|
30
41
|
const isDiagram = item => item.key === DIAGRAM_KEY;
|
|
31
42
|
const featuredWhiteboardsPresent = featuredItems.some(isDiagram);
|
|
@@ -142,8 +153,8 @@ const InsertMenu = ({
|
|
|
142
153
|
isDisabled: true
|
|
143
154
|
} : item)) !== null && _pluginInjectionApi$q5 !== void 0 ? _pluginInjectionApi$q5 : [];
|
|
144
155
|
const unfilteredResult = quickInsertDropdownItems.concat(featuredQuickInsertSuggestions);
|
|
145
|
-
// need to
|
|
146
|
-
result =
|
|
156
|
+
// need to sort on the concatenated list so desired elements are at the top
|
|
157
|
+
result = sortPrioritizedElements(unfilteredResult, formatMessage);
|
|
147
158
|
}
|
|
148
159
|
setItemCount(result.length);
|
|
149
160
|
return result;
|
|
@@ -24,15 +24,28 @@ import { messages, IconCode, IconDate, IconDecision, IconDivider, IconExpand, Ic
|
|
|
24
24
|
import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
25
25
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
26
26
|
import { N0, N30A, N60A } from '@atlaskit/theme/colors';
|
|
27
|
+
import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
27
28
|
export var DEFAULT_HEIGHT = 560;
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
|
-
* Exported helper to allow testing of InsertMenu
|
|
31
|
+
* Exported helper to allow testing of InsertMenu pinning logic. NOTE: this is
|
|
31
32
|
*not* the ideal way to approach this, quickinsert plugin provides a `getSuggestions`
|
|
32
33
|
method that can be used to get suggestions -> once all experiments are cleaned up,
|
|
33
34
|
they should be unified through `pluginInjectionApi?.quickInsert?.actions.getSuggestions`
|
|
35
|
+
|
|
36
|
+
`cc_fd_db_top_editor_toolbar` experiment adds new logic to sort elements by `priority`
|
|
37
|
+
this newer implementation matches how the "quick insert menu" sorts elements
|
|
34
38
|
*/
|
|
35
|
-
export var
|
|
39
|
+
export var sortPrioritizedElements = function sortPrioritizedElements(featuredItems, formatMessage) {
|
|
40
|
+
if (['new-description', 'orig-description'].includes(expVal('cc_fd_db_top_editor_toolbar', 'cohort', 'control'))) {
|
|
41
|
+
// Sort by priority (lower first) on the concatenated list so items
|
|
42
|
+
// with "priority" are at the top (e.g. Whiteboard before Database)
|
|
43
|
+
return featuredItems.slice(0).sort(function (a, b) {
|
|
44
|
+
return (a.priority || Number.POSITIVE_INFINITY) - (b.priority || Number.POSITIVE_INFINITY);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// old logic sort whiteboards to top
|
|
36
49
|
var DIAGRAM_KEY = 'whiteboard-extension:create-diagram';
|
|
37
50
|
var isDiagram = function isDiagram(item) {
|
|
38
51
|
return item.key === DIAGRAM_KEY;
|
|
@@ -167,8 +180,8 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
167
180
|
}) : item;
|
|
168
181
|
})) !== null && _pluginInjectionApi$q4 !== void 0 ? _pluginInjectionApi$q4 : [];
|
|
169
182
|
var unfilteredResult = quickInsertDropdownItems.concat(featuredQuickInsertSuggestions);
|
|
170
|
-
// need to
|
|
171
|
-
result =
|
|
183
|
+
// need to sort on the concatenated list so desired elements are at the top
|
|
184
|
+
result = sortPrioritizedElements(unfilteredResult, formatMessage);
|
|
172
185
|
}
|
|
173
186
|
setItemCount(result.length);
|
|
174
187
|
return result;
|
|
@@ -4,11 +4,14 @@ import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
|
4
4
|
import type { InsertMenuProps } from './types';
|
|
5
5
|
export declare const DEFAULT_HEIGHT = 560;
|
|
6
6
|
/**
|
|
7
|
-
* Exported helper to allow testing of InsertMenu
|
|
7
|
+
* Exported helper to allow testing of InsertMenu pinning logic. NOTE: this is
|
|
8
8
|
*not* the ideal way to approach this, quickinsert plugin provides a `getSuggestions`
|
|
9
9
|
method that can be used to get suggestions -> once all experiments are cleaned up,
|
|
10
10
|
they should be unified through `pluginInjectionApi?.quickInsert?.actions.getSuggestions`
|
|
11
|
+
|
|
12
|
+
`cc_fd_db_top_editor_toolbar` experiment adds new logic to sort elements by `priority`
|
|
13
|
+
this newer implementation matches how the "quick insert menu" sorts elements
|
|
11
14
|
*/
|
|
12
|
-
export declare const
|
|
15
|
+
export declare const sortPrioritizedElements: (featuredItems: QuickInsertItem[], formatMessage: (msg: MessageDescriptor) => string) => QuickInsertItem[];
|
|
13
16
|
declare const InsertMenu: ({ editorView, dropdownItems, showElementBrowserLink, onInsert, toggleVisiblity, pluginInjectionApi, }: InsertMenuProps) => jsx.JSX.Element;
|
|
14
17
|
export default InsertMenu;
|
|
@@ -4,11 +4,14 @@ import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
|
4
4
|
import type { InsertMenuProps } from './types';
|
|
5
5
|
export declare const DEFAULT_HEIGHT = 560;
|
|
6
6
|
/**
|
|
7
|
-
* Exported helper to allow testing of InsertMenu
|
|
7
|
+
* Exported helper to allow testing of InsertMenu pinning logic. NOTE: this is
|
|
8
8
|
*not* the ideal way to approach this, quickinsert plugin provides a `getSuggestions`
|
|
9
9
|
method that can be used to get suggestions -> once all experiments are cleaned up,
|
|
10
10
|
they should be unified through `pluginInjectionApi?.quickInsert?.actions.getSuggestions`
|
|
11
|
+
|
|
12
|
+
`cc_fd_db_top_editor_toolbar` experiment adds new logic to sort elements by `priority`
|
|
13
|
+
this newer implementation matches how the "quick insert menu" sorts elements
|
|
11
14
|
*/
|
|
12
|
-
export declare const
|
|
15
|
+
export declare const sortPrioritizedElements: (featuredItems: QuickInsertItem[], formatMessage: (msg: MessageDescriptor) => string) => QuickInsertItem[];
|
|
13
16
|
declare const InsertMenu: ({ editorView, dropdownItems, showElementBrowserLink, onInsert, toggleVisiblity, pluginInjectionApi, }: InsertMenuProps) => jsx.JSX.Element;
|
|
14
17
|
export default InsertMenu;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-insert-block",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.5.1",
|
|
4
4
|
"description": "Insert block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@atlaskit/icon-lab": "^5.15.0",
|
|
66
66
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
67
67
|
"@atlaskit/theme": "^21.0.0",
|
|
68
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
68
|
+
"@atlaskit/tmp-editor-statsig": "^24.0.0",
|
|
69
69
|
"@atlaskit/tokens": "^11.0.0",
|
|
70
70
|
"@babel/runtime": "^7.0.0",
|
|
71
71
|
"@emotion/react": "^11.7.1",
|