@atlaskit/editor-plugin-insert-block 2.1.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/plugin.js +27 -21
- package/dist/cjs/ui/ToolbarInsertBlock/create-items.js +5 -1
- package/dist/es2019/plugin.js +27 -21
- package/dist/es2019/ui/ToolbarInsertBlock/create-items.js +5 -1
- package/dist/esm/plugin.js +27 -21
- package/dist/esm/ui/ToolbarInsertBlock/create-items.js +5 -1
- package/dist/types/plugin.d.ts +2 -1
- package/dist/types-ts4.5/plugin.d.ts +2 -1
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-insert-block
|
|
2
2
|
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#144047](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/144047)
|
|
8
|
+
[`0e77caf52a59d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0e77caf52a59d) -
|
|
9
|
+
add new full page toolbar breakpoints
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 2.1.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -26,7 +26,18 @@ var _ToolbarInsertBlock = _interopRequireDefault(require("./ui/ToolbarInsertBloc
|
|
|
26
26
|
var _transformOptions = require("./ui/transformOptions");
|
|
27
27
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
28
28
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
29
|
-
var toolbarSizeToButtons = function toolbarSizeToButtons(toolbarSize) {
|
|
29
|
+
var toolbarSizeToButtons = function toolbarSizeToButtons(toolbarSize, appearance) {
|
|
30
|
+
if (appearance === 'full-page' && (0, _platformFeatureFlags.fg)('platform_editor_toolbar_responsive_fixes')) {
|
|
31
|
+
switch (toolbarSize) {
|
|
32
|
+
case _types.ToolbarSize.XXL:
|
|
33
|
+
case _types.ToolbarSize.XL:
|
|
34
|
+
return 7;
|
|
35
|
+
case _types.ToolbarSize.L:
|
|
36
|
+
return 5;
|
|
37
|
+
default:
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
30
41
|
switch (toolbarSize) {
|
|
31
42
|
case _types.ToolbarSize.XXL:
|
|
32
43
|
case _types.ToolbarSize.XL:
|
|
@@ -60,7 +71,7 @@ function handleInsertBlockType(insertCodeBlock, insertPanel, insertBlockQuote) {
|
|
|
60
71
|
};
|
|
61
72
|
}
|
|
62
73
|
var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
63
|
-
var _api$primaryToolbar, _options$
|
|
74
|
+
var _api$primaryToolbar, _options$appearance4;
|
|
64
75
|
var _ref$config = _ref.config,
|
|
65
76
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
66
77
|
api = _ref.api;
|
|
@@ -104,7 +115,8 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
|
|
|
104
115
|
isLastItem: isLastItem,
|
|
105
116
|
providers: providers,
|
|
106
117
|
options: options,
|
|
107
|
-
registerToggleDropdownMenuOptions: registerToggleDropdownMenuOptions
|
|
118
|
+
registerToggleDropdownMenuOptions: registerToggleDropdownMenuOptions,
|
|
119
|
+
appearance: options.appearance
|
|
108
120
|
});
|
|
109
121
|
};
|
|
110
122
|
return /*#__PURE__*/_react.default.createElement(_providerFactory.WithProviders, {
|
|
@@ -134,10 +146,10 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
|
|
|
134
146
|
*/
|
|
135
147
|
// @ts-expect-error
|
|
136
148
|
getSharedState: function getSharedState(editorState) {
|
|
137
|
-
var _options$
|
|
149
|
+
var _options$appearance;
|
|
138
150
|
if (!editorState ||
|
|
139
151
|
// @ts-ignore
|
|
140
|
-
!['full-page', 'full-width'].includes((_options$
|
|
152
|
+
!['full-page', 'full-width'].includes((_options$appearance = options.appearance) !== null && _options$appearance !== void 0 ? _options$appearance : '') || !(0, _experiments.editorExperiment)('insert-menu-in-right-rail', true)) {
|
|
141
153
|
return;
|
|
142
154
|
}
|
|
143
155
|
var pluginState = _elementBrowser.elementBrowserPmKey.getState(editorState);
|
|
@@ -146,10 +158,10 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
|
|
|
146
158
|
};
|
|
147
159
|
},
|
|
148
160
|
pmPlugins: function pmPlugins() {
|
|
149
|
-
var _options$
|
|
161
|
+
var _options$appearance2;
|
|
150
162
|
if (
|
|
151
163
|
// @ts-ignore
|
|
152
|
-
!['full-page', 'full-width'].includes((_options$
|
|
164
|
+
!['full-page', 'full-width'].includes((_options$appearance2 = options.appearance) !== null && _options$appearance2 !== void 0 ? _options$appearance2 : '') || !(0, _experiments.editorExperiment)('insert-menu-in-right-rail', true)) {
|
|
153
165
|
[];
|
|
154
166
|
}
|
|
155
167
|
return [{
|
|
@@ -233,11 +245,11 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
|
|
|
233
245
|
// If we decide to ship the feature, we will consider a separate plugin if needed.
|
|
234
246
|
// Experiment one-pager: https://hello.atlassian.net/wiki/spaces/ETM/pages/3983684902/Experiment+Drive+element+usage+via+element+templates
|
|
235
247
|
quickInsert: function quickInsert(intl) {
|
|
236
|
-
var _options$
|
|
248
|
+
var _options$appearance3;
|
|
237
249
|
var locale = intl.locale;
|
|
238
250
|
var isEligible = locale.startsWith('en') &&
|
|
239
251
|
// @ts-ignore
|
|
240
|
-
['full-page', 'full-width'].includes((_options$
|
|
252
|
+
['full-page', 'full-width'].includes((_options$appearance3 = options.appearance) !== null && _options$appearance3 !== void 0 ? _options$appearance3 : '');
|
|
241
253
|
if (isEligible && (0, _experiments.editorExperiment)('element-level-templates', true, {
|
|
242
254
|
exposure: true
|
|
243
255
|
})) {
|
|
@@ -257,7 +269,7 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
|
|
|
257
269
|
};
|
|
258
270
|
if (
|
|
259
271
|
// @ts-ignore
|
|
260
|
-
['full-page', 'full-width'].includes((_options$
|
|
272
|
+
['full-page', 'full-width'].includes((_options$appearance4 = options.appearance) !== null && _options$appearance4 !== void 0 ? _options$appearance4 : '') && (0, _experiments.editorExperiment)('insert-menu-in-right-rail', true)) {
|
|
261
273
|
plugin.pluginsOptions.contextPanel = function (state) {
|
|
262
274
|
// api.getSharedState() will have an outdated reference to editorState on first mount of this component
|
|
263
275
|
// so instead just rely on plugin key as we don't need to be reactive to changes here
|
|
@@ -289,8 +301,9 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
|
|
|
289
301
|
providers = _ref3.providers,
|
|
290
302
|
pluginInjectionApi = _ref3.pluginInjectionApi,
|
|
291
303
|
options = _ref3.options,
|
|
292
|
-
registerToggleDropdownMenuOptions = _ref3.registerToggleDropdownMenuOptions
|
|
293
|
-
|
|
304
|
+
registerToggleDropdownMenuOptions = _ref3.registerToggleDropdownMenuOptions,
|
|
305
|
+
appearance = _ref3.appearance;
|
|
306
|
+
var buttons = toolbarSizeToButtons(toolbarSize, appearance);
|
|
294
307
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType', 'media', 'typeAhead', 'placeholderText']),
|
|
295
308
|
dateState = _useSharedPluginState.dateState,
|
|
296
309
|
hyperlinkState = _useSharedPluginState.hyperlinkState,
|
|
@@ -362,14 +375,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
|
|
|
362
375
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
363
376
|
showElementBrowserLink: options.showElementBrowserLink,
|
|
364
377
|
showSeparator: !isLastItem && toolbarSize <= _types.ToolbarSize.S,
|
|
365
|
-
registerToggleDropdownMenuOptions: registerToggleDropdownMenuOptions
|
|
366
|
-
|
|
367
|
-
* For insert menu in right rail experiment, ignore for now since editorAppearance has been kept
|
|
368
|
-
* internal due to temporary nature of experiment
|
|
369
|
-
* - Clean up ticket ED-24801
|
|
370
|
-
*/
|
|
371
|
-
// @ts-expect-error
|
|
372
|
-
,
|
|
373
|
-
editorAppearance: options.UNSAFE_editorAppearance
|
|
378
|
+
registerToggleDropdownMenuOptions: registerToggleDropdownMenuOptions,
|
|
379
|
+
editorAppearance: options.appearance
|
|
374
380
|
});
|
|
375
381
|
}
|
|
@@ -12,6 +12,7 @@ var _memoize = _interopRequireDefault(require("lodash/memoize"));
|
|
|
12
12
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
13
13
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
14
14
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _item = require("./item");
|
|
16
17
|
var _messages2 = require("./messages");
|
|
17
18
|
var _shallowEquals = require("./shallow-equals");
|
|
@@ -215,7 +216,10 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
|
|
|
215
216
|
disabled: false
|
|
216
217
|
}));
|
|
217
218
|
}
|
|
218
|
-
var numButtonsWithoutTableSelector =
|
|
219
|
+
var numButtonsWithoutTableSelector = numberOfButtons;
|
|
220
|
+
if (!(0, _platformFeatureFlags.fg)('platform_editor_toolbar_responsive_fixes')) {
|
|
221
|
+
numButtonsWithoutTableSelector = tableSupported && tableSelectorSupported ? numberOfButtons + 1 : numberOfButtons;
|
|
222
|
+
}
|
|
219
223
|
var buttonItems = items.slice(0, numButtonsWithoutTableSelector).map(buttonToItem);
|
|
220
224
|
var remainingItems = items.slice(numButtonsWithoutTableSelector).filter(function (_ref) {
|
|
221
225
|
var name = _ref.value.name;
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -16,7 +16,18 @@ import { InsertMenuRail } from './ui/ElementRail';
|
|
|
16
16
|
import { templateOptions } from './ui/templateOptions';
|
|
17
17
|
import ToolbarInsertBlock from './ui/ToolbarInsertBlock';
|
|
18
18
|
import { transformationOptions } from './ui/transformOptions';
|
|
19
|
-
const toolbarSizeToButtons = toolbarSize => {
|
|
19
|
+
const toolbarSizeToButtons = (toolbarSize, appearance) => {
|
|
20
|
+
if (appearance === 'full-page' && fg('platform_editor_toolbar_responsive_fixes')) {
|
|
21
|
+
switch (toolbarSize) {
|
|
22
|
+
case ToolbarSize.XXL:
|
|
23
|
+
case ToolbarSize.XL:
|
|
24
|
+
return 7;
|
|
25
|
+
case ToolbarSize.L:
|
|
26
|
+
return 5;
|
|
27
|
+
default:
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
20
31
|
switch (toolbarSize) {
|
|
21
32
|
case ToolbarSize.XXL:
|
|
22
33
|
case ToolbarSize.XL:
|
|
@@ -51,7 +62,7 @@ export const insertBlockPlugin = ({
|
|
|
51
62
|
config: options = {},
|
|
52
63
|
api
|
|
53
64
|
}) => {
|
|
54
|
-
var _api$primaryToolbar, _options$
|
|
65
|
+
var _api$primaryToolbar, _options$appearance4;
|
|
55
66
|
const toggleDropdownMenuOptionsRef = {
|
|
56
67
|
current: null
|
|
57
68
|
};
|
|
@@ -93,7 +104,8 @@ export const insertBlockPlugin = ({
|
|
|
93
104
|
isLastItem: isLastItem,
|
|
94
105
|
providers: providers,
|
|
95
106
|
options: options,
|
|
96
|
-
registerToggleDropdownMenuOptions: registerToggleDropdownMenuOptions
|
|
107
|
+
registerToggleDropdownMenuOptions: registerToggleDropdownMenuOptions,
|
|
108
|
+
appearance: options.appearance
|
|
97
109
|
});
|
|
98
110
|
};
|
|
99
111
|
return /*#__PURE__*/React.createElement(WithProviders, {
|
|
@@ -123,10 +135,10 @@ export const insertBlockPlugin = ({
|
|
|
123
135
|
*/
|
|
124
136
|
// @ts-expect-error
|
|
125
137
|
getSharedState: editorState => {
|
|
126
|
-
var _options$
|
|
138
|
+
var _options$appearance;
|
|
127
139
|
if (!editorState ||
|
|
128
140
|
// @ts-ignore
|
|
129
|
-
!['full-page', 'full-width'].includes((_options$
|
|
141
|
+
!['full-page', 'full-width'].includes((_options$appearance = options.appearance) !== null && _options$appearance !== void 0 ? _options$appearance : '') || !editorExperiment('insert-menu-in-right-rail', true)) {
|
|
130
142
|
return;
|
|
131
143
|
}
|
|
132
144
|
const pluginState = elementBrowserPmKey.getState(editorState);
|
|
@@ -135,10 +147,10 @@ export const insertBlockPlugin = ({
|
|
|
135
147
|
};
|
|
136
148
|
},
|
|
137
149
|
pmPlugins: () => {
|
|
138
|
-
var _options$
|
|
150
|
+
var _options$appearance2;
|
|
139
151
|
if (
|
|
140
152
|
// @ts-ignore
|
|
141
|
-
!['full-page', 'full-width'].includes((_options$
|
|
153
|
+
!['full-page', 'full-width'].includes((_options$appearance2 = options.appearance) !== null && _options$appearance2 !== void 0 ? _options$appearance2 : '') || !editorExperiment('insert-menu-in-right-rail', true)) {
|
|
142
154
|
[];
|
|
143
155
|
}
|
|
144
156
|
return [{
|
|
@@ -224,13 +236,13 @@ export const insertBlockPlugin = ({
|
|
|
224
236
|
// If we decide to ship the feature, we will consider a separate plugin if needed.
|
|
225
237
|
// Experiment one-pager: https://hello.atlassian.net/wiki/spaces/ETM/pages/3983684902/Experiment+Drive+element+usage+via+element+templates
|
|
226
238
|
quickInsert: intl => {
|
|
227
|
-
var _options$
|
|
239
|
+
var _options$appearance3;
|
|
228
240
|
const {
|
|
229
241
|
locale
|
|
230
242
|
} = intl;
|
|
231
243
|
const isEligible = locale.startsWith('en') &&
|
|
232
244
|
// @ts-ignore
|
|
233
|
-
['full-page', 'full-width'].includes((_options$
|
|
245
|
+
['full-page', 'full-width'].includes((_options$appearance3 = options.appearance) !== null && _options$appearance3 !== void 0 ? _options$appearance3 : '');
|
|
234
246
|
if (isEligible && editorExperiment('element-level-templates', true, {
|
|
235
247
|
exposure: true
|
|
236
248
|
})) {
|
|
@@ -250,7 +262,7 @@ export const insertBlockPlugin = ({
|
|
|
250
262
|
};
|
|
251
263
|
if (
|
|
252
264
|
// @ts-ignore
|
|
253
|
-
['full-page', 'full-width'].includes((_options$
|
|
265
|
+
['full-page', 'full-width'].includes((_options$appearance4 = options.appearance) !== null && _options$appearance4 !== void 0 ? _options$appearance4 : '') && editorExperiment('insert-menu-in-right-rail', true)) {
|
|
254
266
|
plugin.pluginsOptions.contextPanel = state => {
|
|
255
267
|
// api.getSharedState() will have an outdated reference to editorState on first mount of this component
|
|
256
268
|
// so instead just rely on plugin key as we don't need to be reactive to changes here
|
|
@@ -281,10 +293,11 @@ function ToolbarInsertBlockWithInjectionApi({
|
|
|
281
293
|
providers,
|
|
282
294
|
pluginInjectionApi,
|
|
283
295
|
options,
|
|
284
|
-
registerToggleDropdownMenuOptions
|
|
296
|
+
registerToggleDropdownMenuOptions,
|
|
297
|
+
appearance
|
|
285
298
|
}) {
|
|
286
299
|
var _ref, _pluginInjectionApi$i, _pluginInjectionApi$c2, _pluginInjectionApi$p, _pluginInjectionApi$b, _pluginInjectionApi$e;
|
|
287
|
-
const buttons = toolbarSizeToButtons(toolbarSize);
|
|
300
|
+
const buttons = toolbarSizeToButtons(toolbarSize, appearance);
|
|
288
301
|
const {
|
|
289
302
|
dateState,
|
|
290
303
|
hyperlinkState,
|
|
@@ -357,14 +370,7 @@ function ToolbarInsertBlockWithInjectionApi({
|
|
|
357
370
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
358
371
|
showElementBrowserLink: options.showElementBrowserLink,
|
|
359
372
|
showSeparator: !isLastItem && toolbarSize <= ToolbarSize.S,
|
|
360
|
-
registerToggleDropdownMenuOptions: registerToggleDropdownMenuOptions
|
|
361
|
-
|
|
362
|
-
* For insert menu in right rail experiment, ignore for now since editorAppearance has been kept
|
|
363
|
-
* internal due to temporary nature of experiment
|
|
364
|
-
* - Clean up ticket ED-24801
|
|
365
|
-
*/
|
|
366
|
-
// @ts-expect-error
|
|
367
|
-
,
|
|
368
|
-
editorAppearance: options.UNSAFE_editorAppearance
|
|
373
|
+
registerToggleDropdownMenuOptions: registerToggleDropdownMenuOptions,
|
|
374
|
+
editorAppearance: options.appearance
|
|
369
375
|
});
|
|
370
376
|
}
|
|
@@ -3,6 +3,7 @@ import memoize from 'lodash/memoize';
|
|
|
3
3
|
import memoizeOne from 'memoize-one';
|
|
4
4
|
import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
5
5
|
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { action, blockquote, codeblock, date, decision, emoji, expand, horizontalrule, imageUpload, layout, link, media, mention, more, panel, placeholder, status, table, tableSelector } from './item';
|
|
7
8
|
import { messages } from './messages';
|
|
8
9
|
import { shallowEquals } from './shallow-equals';
|
|
@@ -196,7 +197,10 @@ const createInsertBlockItems = config => {
|
|
|
196
197
|
disabled: false
|
|
197
198
|
}));
|
|
198
199
|
}
|
|
199
|
-
|
|
200
|
+
let numButtonsWithoutTableSelector = numberOfButtons;
|
|
201
|
+
if (!fg('platform_editor_toolbar_responsive_fixes')) {
|
|
202
|
+
numButtonsWithoutTableSelector = tableSupported && tableSelectorSupported ? numberOfButtons + 1 : numberOfButtons;
|
|
203
|
+
}
|
|
200
204
|
const buttonItems = items.slice(0, numButtonsWithoutTableSelector).map(buttonToItem);
|
|
201
205
|
const remainingItems = items.slice(numButtonsWithoutTableSelector).filter(({
|
|
202
206
|
value: {
|
package/dist/esm/plugin.js
CHANGED
|
@@ -16,7 +16,18 @@ import { InsertMenuRail } from './ui/ElementRail';
|
|
|
16
16
|
import { templateOptions } from './ui/templateOptions';
|
|
17
17
|
import ToolbarInsertBlock from './ui/ToolbarInsertBlock';
|
|
18
18
|
import { transformationOptions } from './ui/transformOptions';
|
|
19
|
-
var toolbarSizeToButtons = function toolbarSizeToButtons(toolbarSize) {
|
|
19
|
+
var toolbarSizeToButtons = function toolbarSizeToButtons(toolbarSize, appearance) {
|
|
20
|
+
if (appearance === 'full-page' && fg('platform_editor_toolbar_responsive_fixes')) {
|
|
21
|
+
switch (toolbarSize) {
|
|
22
|
+
case ToolbarSize.XXL:
|
|
23
|
+
case ToolbarSize.XL:
|
|
24
|
+
return 7;
|
|
25
|
+
case ToolbarSize.L:
|
|
26
|
+
return 5;
|
|
27
|
+
default:
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
20
31
|
switch (toolbarSize) {
|
|
21
32
|
case ToolbarSize.XXL:
|
|
22
33
|
case ToolbarSize.XL:
|
|
@@ -50,7 +61,7 @@ function handleInsertBlockType(insertCodeBlock, insertPanel, insertBlockQuote) {
|
|
|
50
61
|
};
|
|
51
62
|
}
|
|
52
63
|
export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
53
|
-
var _api$primaryToolbar, _options$
|
|
64
|
+
var _api$primaryToolbar, _options$appearance4;
|
|
54
65
|
var _ref$config = _ref.config,
|
|
55
66
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
56
67
|
api = _ref.api;
|
|
@@ -94,7 +105,8 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
94
105
|
isLastItem: isLastItem,
|
|
95
106
|
providers: providers,
|
|
96
107
|
options: options,
|
|
97
|
-
registerToggleDropdownMenuOptions: registerToggleDropdownMenuOptions
|
|
108
|
+
registerToggleDropdownMenuOptions: registerToggleDropdownMenuOptions,
|
|
109
|
+
appearance: options.appearance
|
|
98
110
|
});
|
|
99
111
|
};
|
|
100
112
|
return /*#__PURE__*/React.createElement(WithProviders, {
|
|
@@ -124,10 +136,10 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
124
136
|
*/
|
|
125
137
|
// @ts-expect-error
|
|
126
138
|
getSharedState: function getSharedState(editorState) {
|
|
127
|
-
var _options$
|
|
139
|
+
var _options$appearance;
|
|
128
140
|
if (!editorState ||
|
|
129
141
|
// @ts-ignore
|
|
130
|
-
!['full-page', 'full-width'].includes((_options$
|
|
142
|
+
!['full-page', 'full-width'].includes((_options$appearance = options.appearance) !== null && _options$appearance !== void 0 ? _options$appearance : '') || !editorExperiment('insert-menu-in-right-rail', true)) {
|
|
131
143
|
return;
|
|
132
144
|
}
|
|
133
145
|
var pluginState = elementBrowserPmKey.getState(editorState);
|
|
@@ -136,10 +148,10 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
136
148
|
};
|
|
137
149
|
},
|
|
138
150
|
pmPlugins: function pmPlugins() {
|
|
139
|
-
var _options$
|
|
151
|
+
var _options$appearance2;
|
|
140
152
|
if (
|
|
141
153
|
// @ts-ignore
|
|
142
|
-
!['full-page', 'full-width'].includes((_options$
|
|
154
|
+
!['full-page', 'full-width'].includes((_options$appearance2 = options.appearance) !== null && _options$appearance2 !== void 0 ? _options$appearance2 : '') || !editorExperiment('insert-menu-in-right-rail', true)) {
|
|
143
155
|
[];
|
|
144
156
|
}
|
|
145
157
|
return [{
|
|
@@ -223,11 +235,11 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
223
235
|
// If we decide to ship the feature, we will consider a separate plugin if needed.
|
|
224
236
|
// Experiment one-pager: https://hello.atlassian.net/wiki/spaces/ETM/pages/3983684902/Experiment+Drive+element+usage+via+element+templates
|
|
225
237
|
quickInsert: function quickInsert(intl) {
|
|
226
|
-
var _options$
|
|
238
|
+
var _options$appearance3;
|
|
227
239
|
var locale = intl.locale;
|
|
228
240
|
var isEligible = locale.startsWith('en') &&
|
|
229
241
|
// @ts-ignore
|
|
230
|
-
['full-page', 'full-width'].includes((_options$
|
|
242
|
+
['full-page', 'full-width'].includes((_options$appearance3 = options.appearance) !== null && _options$appearance3 !== void 0 ? _options$appearance3 : '');
|
|
231
243
|
if (isEligible && editorExperiment('element-level-templates', true, {
|
|
232
244
|
exposure: true
|
|
233
245
|
})) {
|
|
@@ -247,7 +259,7 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
247
259
|
};
|
|
248
260
|
if (
|
|
249
261
|
// @ts-ignore
|
|
250
|
-
['full-page', 'full-width'].includes((_options$
|
|
262
|
+
['full-page', 'full-width'].includes((_options$appearance4 = options.appearance) !== null && _options$appearance4 !== void 0 ? _options$appearance4 : '') && editorExperiment('insert-menu-in-right-rail', true)) {
|
|
251
263
|
plugin.pluginsOptions.contextPanel = function (state) {
|
|
252
264
|
// api.getSharedState() will have an outdated reference to editorState on first mount of this component
|
|
253
265
|
// so instead just rely on plugin key as we don't need to be reactive to changes here
|
|
@@ -279,8 +291,9 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
|
|
|
279
291
|
providers = _ref3.providers,
|
|
280
292
|
pluginInjectionApi = _ref3.pluginInjectionApi,
|
|
281
293
|
options = _ref3.options,
|
|
282
|
-
registerToggleDropdownMenuOptions = _ref3.registerToggleDropdownMenuOptions
|
|
283
|
-
|
|
294
|
+
registerToggleDropdownMenuOptions = _ref3.registerToggleDropdownMenuOptions,
|
|
295
|
+
appearance = _ref3.appearance;
|
|
296
|
+
var buttons = toolbarSizeToButtons(toolbarSize, appearance);
|
|
284
297
|
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType', 'media', 'typeAhead', 'placeholderText']),
|
|
285
298
|
dateState = _useSharedPluginState.dateState,
|
|
286
299
|
hyperlinkState = _useSharedPluginState.hyperlinkState,
|
|
@@ -352,14 +365,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
|
|
|
352
365
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
353
366
|
showElementBrowserLink: options.showElementBrowserLink,
|
|
354
367
|
showSeparator: !isLastItem && toolbarSize <= ToolbarSize.S,
|
|
355
|
-
registerToggleDropdownMenuOptions: registerToggleDropdownMenuOptions
|
|
356
|
-
|
|
357
|
-
* For insert menu in right rail experiment, ignore for now since editorAppearance has been kept
|
|
358
|
-
* internal due to temporary nature of experiment
|
|
359
|
-
* - Clean up ticket ED-24801
|
|
360
|
-
*/
|
|
361
|
-
// @ts-expect-error
|
|
362
|
-
,
|
|
363
|
-
editorAppearance: options.UNSAFE_editorAppearance
|
|
368
|
+
registerToggleDropdownMenuOptions: registerToggleDropdownMenuOptions,
|
|
369
|
+
editorAppearance: options.appearance
|
|
364
370
|
});
|
|
365
371
|
}
|
|
@@ -7,6 +7,7 @@ import memoize from 'lodash/memoize';
|
|
|
7
7
|
import memoizeOne from 'memoize-one';
|
|
8
8
|
import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
9
9
|
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { action, blockquote, codeblock, date, decision, emoji, expand, horizontalrule, imageUpload, layout, link, media, mention, more, panel, placeholder, status, table, tableSelector } from './item';
|
|
11
12
|
import { messages } from './messages';
|
|
12
13
|
import { shallowEquals } from './shallow-equals';
|
|
@@ -208,7 +209,10 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
|
|
|
208
209
|
disabled: false
|
|
209
210
|
}));
|
|
210
211
|
}
|
|
211
|
-
var numButtonsWithoutTableSelector =
|
|
212
|
+
var numButtonsWithoutTableSelector = numberOfButtons;
|
|
213
|
+
if (!fg('platform_editor_toolbar_responsive_fixes')) {
|
|
214
|
+
numButtonsWithoutTableSelector = tableSupported && tableSelectorSupported ? numberOfButtons + 1 : numberOfButtons;
|
|
215
|
+
}
|
|
212
216
|
var buttonItems = items.slice(0, numButtonsWithoutTableSelector).map(buttonToItem);
|
|
213
217
|
var remainingItems = items.slice(numButtonsWithoutTableSelector).filter(function (_ref) {
|
|
214
218
|
var name = _ref.value.name;
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { EditorAppearance, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { InsertBlockPluginDependencies } from './types';
|
|
3
3
|
export interface InsertBlockOptions {
|
|
4
4
|
allowTables?: boolean;
|
|
@@ -8,6 +8,7 @@ export interface InsertBlockOptions {
|
|
|
8
8
|
nativeStatusSupported?: boolean;
|
|
9
9
|
showElementBrowserLink?: boolean;
|
|
10
10
|
tableSelectorSupported?: boolean;
|
|
11
|
+
appearance?: EditorAppearance;
|
|
11
12
|
}
|
|
12
13
|
export type InsertBlockPlugin = NextEditorPlugin<'insertBlock', {
|
|
13
14
|
pluginConfiguration: InsertBlockOptions | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { EditorAppearance, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { InsertBlockPluginDependencies } from './types';
|
|
3
3
|
export interface InsertBlockOptions {
|
|
4
4
|
allowTables?: boolean;
|
|
@@ -8,6 +8,7 @@ export interface InsertBlockOptions {
|
|
|
8
8
|
nativeStatusSupported?: boolean;
|
|
9
9
|
showElementBrowserLink?: boolean;
|
|
10
10
|
tableSelectorSupported?: boolean;
|
|
11
|
+
appearance?: EditorAppearance;
|
|
11
12
|
}
|
|
12
13
|
export type InsertBlockPlugin = NextEditorPlugin<'insertBlock', {
|
|
13
14
|
pluginConfiguration: InsertBlockOptions | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-insert-block",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Insert block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/button": "^20.
|
|
35
|
-
"@atlaskit/editor-common": "^91.
|
|
34
|
+
"@atlaskit/button": "^20.2.0",
|
|
35
|
+
"@atlaskit/editor-common": "^91.1.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.8.0",
|
|
37
37
|
"@atlaskit/editor-plugin-block-type": "^3.15.0",
|
|
38
38
|
"@atlaskit/editor-plugin-code-block": "^3.3.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@atlaskit/editor-plugin-hyperlink": "^2.9.0",
|
|
45
45
|
"@atlaskit/editor-plugin-image-upload": "^1.2.0",
|
|
46
46
|
"@atlaskit/editor-plugin-layout": "^1.8.0",
|
|
47
|
-
"@atlaskit/editor-plugin-media": "^1.
|
|
47
|
+
"@atlaskit/editor-plugin-media": "^1.33.0",
|
|
48
48
|
"@atlaskit/editor-plugin-media-insert": "^2.8.0",
|
|
49
49
|
"@atlaskit/editor-plugin-mentions": "^2.6.0",
|
|
50
50
|
"@atlaskit/editor-plugin-panel": "^2.5.0",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"@atlaskit/editor-plugin-quick-insert": "^1.4.0",
|
|
54
54
|
"@atlaskit/editor-plugin-rule": "^1.8.0",
|
|
55
55
|
"@atlaskit/editor-plugin-status": "^2.4.0",
|
|
56
|
-
"@atlaskit/editor-plugin-table": "^7.
|
|
56
|
+
"@atlaskit/editor-plugin-table": "^7.28.0",
|
|
57
57
|
"@atlaskit/editor-plugin-tasks-and-decisions": "^2.6.0",
|
|
58
58
|
"@atlaskit/editor-plugin-type-ahead": "^1.8.0",
|
|
59
59
|
"@atlaskit/editor-prosemirror": "6.0.0",
|
|
60
|
-
"@atlaskit/editor-shared-styles": "^
|
|
60
|
+
"@atlaskit/editor-shared-styles": "^3.0.0",
|
|
61
61
|
"@atlaskit/emoji": "^67.8.0",
|
|
62
62
|
"@atlaskit/heading": "2.4.5",
|
|
63
63
|
"@atlaskit/icon": "^22.18.0",
|
|
@@ -124,6 +124,9 @@
|
|
|
124
124
|
"platform-feature-flags": {
|
|
125
125
|
"platform_editor_get_emoji_provider_from_config": {
|
|
126
126
|
"type": "boolean"
|
|
127
|
+
},
|
|
128
|
+
"platform_editor_toolbar_responsive_fixes": {
|
|
129
|
+
"type": "boolean"
|
|
127
130
|
}
|
|
128
131
|
}
|
|
129
132
|
}
|