@atlaskit/editor-plugin-insert-block 2.2.12 → 2.3.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/plugin.js +66 -77
- package/dist/cjs/pm-plugins/toggleInsertBlock.js +30 -0
- package/dist/cjs/ui/ElementRail/MainToolBarIcon.js +0 -2
- package/dist/cjs/ui/ToolbarInsertBlock/index.js +13 -14
- package/dist/es2019/plugin.js +47 -56
- package/dist/es2019/pm-plugins/toggleInsertBlock.js +22 -0
- package/dist/es2019/ui/ElementRail/MainToolBarIcon.js +0 -2
- package/dist/es2019/ui/ToolbarInsertBlock/index.js +8 -8
- package/dist/esm/plugin.js +65 -73
- package/dist/esm/pm-plugins/toggleInsertBlock.js +24 -0
- package/dist/esm/ui/ElementRail/MainToolBarIcon.js +0 -2
- package/dist/esm/ui/ToolbarInsertBlock/index.js +13 -14
- package/dist/types/index.d.ts +1 -1
- package/dist/types/plugin.d.ts +7 -0
- package/dist/types/pm-plugins/toggleInsertBlock.d.ts +8 -0
- package/dist/types/ui/ElementRail/index.d.ts +1 -0
- package/dist/types/ui/ToolbarInsertBlock/index.d.ts +3 -9
- package/dist/types/ui/ToolbarInsertBlock/types.d.ts +1 -0
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/plugin.d.ts +7 -0
- package/dist/types-ts4.5/pm-plugins/toggleInsertBlock.d.ts +8 -0
- package/dist/types-ts4.5/ui/ElementRail/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/index.d.ts +3 -9
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/types.d.ts +1 -0
- package/package.json +23 -23
package/dist/esm/plugin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { contentAllowedInCodeBlock, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
@@ -12,11 +12,12 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
12
12
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
13
|
import SwitchIcon from './assets/switch';
|
|
14
14
|
import { elementBrowserPmKey, elementBrowserPmPlugin } from './pm-plugins/elementBrowser';
|
|
15
|
+
import { toggleInsertBlockPmKey, toggleInsertBlockPmPlugin } from './pm-plugins/toggleInsertBlock';
|
|
15
16
|
import { InsertMenuRail } from './ui/ElementRail';
|
|
16
17
|
import { templateOptions } from './ui/templateOptions';
|
|
17
18
|
import ToolbarInsertBlock from './ui/ToolbarInsertBlock';
|
|
18
19
|
import { transformationOptions } from './ui/transformOptions';
|
|
19
|
-
var toolbarSizeToButtons = function toolbarSizeToButtons(toolbarSize, appearance) {
|
|
20
|
+
export var toolbarSizeToButtons = function toolbarSizeToButtons(toolbarSize, appearance) {
|
|
20
21
|
// Different button numbers for full-page to better match full page toolbar breakpoints
|
|
21
22
|
if (appearance === 'full-page' && fg('platform_editor_toolbar_responsive_fixes')) {
|
|
22
23
|
switch (toolbarSize) {
|
|
@@ -82,18 +83,9 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
82
83
|
var _ref$config = _ref.config,
|
|
83
84
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
84
85
|
api = _ref.api;
|
|
85
|
-
var toggleDropdownMenuOptionsRef = {
|
|
86
|
-
current: null
|
|
87
|
-
};
|
|
88
86
|
var editorViewRef = {
|
|
89
87
|
current: null
|
|
90
88
|
};
|
|
91
|
-
var registerToggleDropdownMenuOptions = function registerToggleDropdownMenuOptions(cb) {
|
|
92
|
-
toggleDropdownMenuOptionsRef.current = cb;
|
|
93
|
-
return function () {
|
|
94
|
-
toggleDropdownMenuOptionsRef.current = null;
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
89
|
var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
|
|
98
90
|
var editorView = _ref2.editorView,
|
|
99
91
|
editorActions = _ref2.editorActions,
|
|
@@ -122,7 +114,6 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
122
114
|
isLastItem: isLastItem,
|
|
123
115
|
providers: providers,
|
|
124
116
|
options: options,
|
|
125
|
-
registerToggleDropdownMenuOptions: registerToggleDropdownMenuOptions,
|
|
126
117
|
appearance: options.appearance
|
|
127
118
|
});
|
|
128
119
|
};
|
|
@@ -140,54 +131,62 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
140
131
|
name: 'insertBlock',
|
|
141
132
|
actions: {
|
|
142
133
|
toggleAdditionalMenu: function toggleAdditionalMenu() {
|
|
143
|
-
var
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
134
|
+
var _api$core;
|
|
135
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
|
|
136
|
+
var tr = _ref3.tr;
|
|
137
|
+
return tr.setMeta(toggleInsertBlockPmKey, true);
|
|
138
|
+
});
|
|
148
139
|
}
|
|
149
140
|
},
|
|
150
|
-
/**
|
|
151
|
-
* For insert menu in right rail experiment - I don't want to expose state as it might not ship
|
|
152
|
-
* - Clean up ticket ED-24801
|
|
153
|
-
*/
|
|
154
|
-
// @ts-expect-error
|
|
155
141
|
getSharedState: function getSharedState(editorState) {
|
|
156
142
|
var _options$appearance;
|
|
157
|
-
if (!editorState ||
|
|
158
|
-
// @ts-ignore
|
|
159
|
-
!['full-page', 'full-width'].includes((_options$appearance = options.appearance) !== null && _options$appearance !== void 0 ? _options$appearance : '') || !editorExperiment('insert-menu-in-right-rail', true)) {
|
|
143
|
+
if (!editorState || !['full-page', 'full-width'].includes((_options$appearance = options.appearance) !== null && _options$appearance !== void 0 ? _options$appearance : '')) {
|
|
160
144
|
return;
|
|
161
145
|
}
|
|
162
|
-
var
|
|
146
|
+
var toggleInsertBlockPluginState = toggleInsertBlockPmKey.getState(editorState);
|
|
147
|
+
var elementBrowserPluginState = elementBrowserPmKey.getState(editorState);
|
|
163
148
|
return {
|
|
164
|
-
|
|
149
|
+
showElementBrowser: (toggleInsertBlockPluginState === null || toggleInsertBlockPluginState === void 0 ? void 0 : toggleInsertBlockPluginState.showElementBrowser) || false,
|
|
150
|
+
/**
|
|
151
|
+
* For insert menu in right rail experiment
|
|
152
|
+
* - Clean up ticket ED-24801
|
|
153
|
+
* Experiment: `insert-menu-in-right-rail`
|
|
154
|
+
*/
|
|
155
|
+
menuBrowserOpen: editorExperiment('insert-menu-in-right-rail', true) ? elementBrowserPluginState === null || elementBrowserPluginState === void 0 ? void 0 : elementBrowserPluginState.menuBrowserOpen : false
|
|
165
156
|
};
|
|
166
157
|
},
|
|
167
158
|
pmPlugins: function pmPlugins() {
|
|
168
159
|
var _options$appearance2;
|
|
169
|
-
if (
|
|
170
|
-
// @ts-ignore
|
|
171
|
-
!['full-page', 'full-width'].includes((_options$appearance2 = options.appearance) !== null && _options$appearance2 !== void 0 ? _options$appearance2 : '') || !editorExperiment('insert-menu-in-right-rail', true)) {
|
|
160
|
+
if (!['full-page', 'full-width'].includes((_options$appearance2 = options.appearance) !== null && _options$appearance2 !== void 0 ? _options$appearance2 : '')) {
|
|
172
161
|
[];
|
|
173
162
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
163
|
+
var plugins = [];
|
|
164
|
+
if (editorExperiment('insert-menu-in-right-rail', true)) {
|
|
165
|
+
plugins.push({
|
|
166
|
+
name: 'elementBrowserPmPlugin',
|
|
167
|
+
plugin: function plugin() {
|
|
168
|
+
return elementBrowserPmPlugin();
|
|
169
|
+
}
|
|
170
|
+
}, {
|
|
171
|
+
name: 'elementBrowserEditorViewRef',
|
|
172
|
+
plugin: function plugin() {
|
|
173
|
+
return new SafePlugin({
|
|
174
|
+
view: function view(editorView) {
|
|
175
|
+
// Workaround - need reference to editorView for contextPanel component
|
|
176
|
+
editorViewRef.current = editorView;
|
|
177
|
+
return {};
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
plugins.push({
|
|
184
|
+
name: 'toggleInsertBlockPmPlugin',
|
|
181
185
|
plugin: function plugin() {
|
|
182
|
-
return
|
|
183
|
-
view: function view(editorView) {
|
|
184
|
-
// Workaround - need reference to editorView for contextPanel component
|
|
185
|
-
editorViewRef.current = editorView;
|
|
186
|
-
return {};
|
|
187
|
-
}
|
|
188
|
-
});
|
|
186
|
+
return toggleInsertBlockPmPlugin();
|
|
189
187
|
}
|
|
190
|
-
}
|
|
188
|
+
});
|
|
189
|
+
return plugins;
|
|
191
190
|
},
|
|
192
191
|
pluginsOptions: {
|
|
193
192
|
// This is added for basic text transformations experiment.
|
|
@@ -265,13 +264,6 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
265
264
|
return [];
|
|
266
265
|
}
|
|
267
266
|
},
|
|
268
|
-
usePluginHook: function usePluginHook() {
|
|
269
|
-
useLayoutEffect(function () {
|
|
270
|
-
return function () {
|
|
271
|
-
toggleDropdownMenuOptionsRef.current = null;
|
|
272
|
-
};
|
|
273
|
-
}, []);
|
|
274
|
-
},
|
|
275
267
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
276
268
|
};
|
|
277
269
|
if (
|
|
@@ -293,25 +285,24 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
293
285
|
}
|
|
294
286
|
return plugin;
|
|
295
287
|
};
|
|
296
|
-
function ToolbarInsertBlockWithInjectionApi(
|
|
297
|
-
var
|
|
298
|
-
var editorView =
|
|
299
|
-
editorActions =
|
|
300
|
-
dispatchAnalyticsEvent =
|
|
301
|
-
popupsMountPoint =
|
|
302
|
-
popupsBoundariesElement =
|
|
303
|
-
popupsScrollableElement =
|
|
304
|
-
toolbarSize =
|
|
305
|
-
disabled =
|
|
306
|
-
isToolbarReducedSpacing =
|
|
307
|
-
isLastItem =
|
|
308
|
-
providers =
|
|
309
|
-
pluginInjectionApi =
|
|
310
|
-
options =
|
|
311
|
-
|
|
312
|
-
appearance = _ref3.appearance;
|
|
288
|
+
function ToolbarInsertBlockWithInjectionApi(_ref4) {
|
|
289
|
+
var _ref5, _pluginInjectionApi$i, _pluginInjectionApi$c2, _pluginInjectionApi$p, _pluginInjectionApi$b, _pluginInjectionApi$e;
|
|
290
|
+
var editorView = _ref4.editorView,
|
|
291
|
+
editorActions = _ref4.editorActions,
|
|
292
|
+
dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent,
|
|
293
|
+
popupsMountPoint = _ref4.popupsMountPoint,
|
|
294
|
+
popupsBoundariesElement = _ref4.popupsBoundariesElement,
|
|
295
|
+
popupsScrollableElement = _ref4.popupsScrollableElement,
|
|
296
|
+
toolbarSize = _ref4.toolbarSize,
|
|
297
|
+
disabled = _ref4.disabled,
|
|
298
|
+
isToolbarReducedSpacing = _ref4.isToolbarReducedSpacing,
|
|
299
|
+
isLastItem = _ref4.isLastItem,
|
|
300
|
+
providers = _ref4.providers,
|
|
301
|
+
pluginInjectionApi = _ref4.pluginInjectionApi,
|
|
302
|
+
options = _ref4.options,
|
|
303
|
+
appearance = _ref4.appearance;
|
|
313
304
|
var buttons = toolbarSizeToButtons(toolbarSize, appearance);
|
|
314
|
-
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType', 'media', 'typeAhead', 'placeholderText']),
|
|
305
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType', 'media', 'typeAhead', 'placeholderText', 'insertBlock']),
|
|
315
306
|
dateState = _useSharedPluginState.dateState,
|
|
316
307
|
hyperlinkState = _useSharedPluginState.hyperlinkState,
|
|
317
308
|
imageUploadState = _useSharedPluginState.imageUploadState,
|
|
@@ -320,7 +311,8 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
|
|
|
320
311
|
blockTypeState = _useSharedPluginState.blockTypeState,
|
|
321
312
|
mediaState = _useSharedPluginState.mediaState,
|
|
322
313
|
typeAheadState = _useSharedPluginState.typeAheadState,
|
|
323
|
-
placeholderTextState = _useSharedPluginState.placeholderTextState
|
|
314
|
+
placeholderTextState = _useSharedPluginState.placeholderTextState,
|
|
315
|
+
insertBlockState = _useSharedPluginState.insertBlockState;
|
|
324
316
|
var getEmojiProvider = function getEmojiProvider() {
|
|
325
317
|
if (emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider) {
|
|
326
318
|
return Promise.resolve(emojiState === null || emojiState === void 0 ? void 0 : emojiState.emojiProvider);
|
|
@@ -339,6 +331,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
|
|
|
339
331
|
}
|
|
340
332
|
};
|
|
341
333
|
return /*#__PURE__*/React.createElement(ToolbarInsertBlock, {
|
|
334
|
+
showElementBrowser: (insertBlockState === null || insertBlockState === void 0 ? void 0 : insertBlockState.showElementBrowser) || false,
|
|
342
335
|
pluginInjectionApi: pluginInjectionApi,
|
|
343
336
|
buttons: buttons,
|
|
344
337
|
isReducedSpacing: isToolbarReducedSpacing,
|
|
@@ -355,7 +348,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
|
|
|
355
348
|
placeholderTextEnabled: placeholderTextState && placeholderTextState.allowInserting,
|
|
356
349
|
layoutSectionEnabled: Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.layout),
|
|
357
350
|
expandEnabled: !!options.allowExpand,
|
|
358
|
-
mediaUploadsEnabled: (
|
|
351
|
+
mediaUploadsEnabled: (_ref5 = mediaState && mediaState.allowsUploads) !== null && _ref5 !== void 0 ? _ref5 : undefined,
|
|
359
352
|
onShowMediaPicker: onShowMediaPicker,
|
|
360
353
|
mediaSupported: !!mediaState,
|
|
361
354
|
imageUploadSupported: !!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.imageUpload),
|
|
@@ -378,7 +371,6 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
|
|
|
378
371
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
379
372
|
showElementBrowserLink: options.showElementBrowserLink,
|
|
380
373
|
showSeparator: !isLastItem && toolbarSize <= ToolbarSize.S,
|
|
381
|
-
registerToggleDropdownMenuOptions: registerToggleDropdownMenuOptions,
|
|
382
374
|
editorAppearance: options.appearance
|
|
383
375
|
});
|
|
384
376
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
export var toggleInsertBlockPmKey = new PluginKey('toggleInsertBlockPmKey');
|
|
4
|
+
export var toggleInsertBlockPmPlugin = function toggleInsertBlockPmPlugin() {
|
|
5
|
+
return new SafePlugin({
|
|
6
|
+
key: toggleInsertBlockPmKey,
|
|
7
|
+
state: {
|
|
8
|
+
init: function init() {
|
|
9
|
+
return {
|
|
10
|
+
showElementBrowser: false
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
apply: function apply(tr, pluginState) {
|
|
14
|
+
var meta = tr.getMeta(toggleInsertBlockPmKey);
|
|
15
|
+
if (!meta) {
|
|
16
|
+
return pluginState;
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
showElementBrowser: !pluginState.showElementBrowser
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
@@ -64,8 +64,6 @@ export var RightRailIcon = function RightRailIcon(_ref) {
|
|
|
64
64
|
formatMessage = _useIntl.formatMessage;
|
|
65
65
|
var _useSharedPluginState = useSharedPluginState(api, ['insertBlock']),
|
|
66
66
|
insertBlockState = _useSharedPluginState.insertBlockState;
|
|
67
|
-
|
|
68
|
-
// @ts-expect-error
|
|
69
67
|
var isOpen = insertBlockState === null || insertBlockState === void 0 ? void 0 : insertBlockState.menuBrowserOpen;
|
|
70
68
|
return /*#__PURE__*/React.createElement(Box, {
|
|
71
69
|
xcss: [wrapperStyles]
|
|
@@ -59,6 +59,7 @@ export var tableButtonWrapper = function tableButtonWrapper(_ref) {
|
|
|
59
59
|
css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\t\tdisplay: flex;\n\t\t", "\n\t\t", "\n\n .table-toolbar-btn {\n\t\t\tborder-top-right-radius: ", ";\n\t\t\tborder-bottom-right-radius: ", ";\n\t\t\tmargin-right: ", ";\n\t\t\tpadding: ", ";\n\t\t\t& > span {\n\t\t\t\tmin-width: 16px;\n\t\t\t\tmargin: ", ";\n\t\t\t}\n\t\t}\n\t\t.table-selector-toolbar-btn {\n\t\t\tpadding: ", ";\n\t\t\t& > span {\n\t\t\t\tmargin: ", ";\n\t\t\t\twidth: 16px !important;\n\t\t\t\tdisplay: flex;\n\t\t\t\tjustify-content: center;\n\t\t\t}\n\n\t\t\tborder-top-left-radius: ", " !important;\n\t\t\tborder-bottom-left-radius: ", " !important;\n\t\t}\n\t"])), !isTableSelectorOpen && !isButtonDisabled && getHoverStyles('.table-selector-toolbar-btn'), !isTableSelectorOpen && !isButtonDisabled && getHoverStyles('.table-toolbar-btn'), "var(--ds-border-radius-200, 0px)", "var(--ds-border-radius-200, 0px)", "var(--ds-space-025, 1px)", "var(--ds-space-0, 0px)", "var(--ds-space-0, 0px)", "var(--ds-space-0, 0px)", "var(--ds-space-0, 0px)", "var(--ds-border-radius-200, 0px)", "var(--ds-border-radius-200, 0px)")
|
|
60
60
|
);
|
|
61
61
|
};
|
|
62
|
+
|
|
62
63
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
63
64
|
export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
64
65
|
_inherits(ToolbarInsertBlock, _React$PureComponent);
|
|
@@ -72,7 +73,6 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
72
73
|
_this = _super.call.apply(_super, [this].concat(_args));
|
|
73
74
|
_defineProperty(_assertThisInitialized(_this), "tableButtonRef", /*#__PURE__*/React.createRef());
|
|
74
75
|
_defineProperty(_assertThisInitialized(_this), "tableSelectorButtonRef", /*#__PURE__*/React.createRef());
|
|
75
|
-
_defineProperty(_assertThisInitialized(_this), "unregisterToggleDropdownMenuOptions", null);
|
|
76
76
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
77
77
|
isPlusMenuOpen: false,
|
|
78
78
|
emojiPickerOpen: false,
|
|
@@ -205,13 +205,6 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
205
205
|
_this.toggleTableSelector(INPUT_METHOD.TOOLBAR);
|
|
206
206
|
}
|
|
207
207
|
});
|
|
208
|
-
_defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
|
|
209
|
-
_this.unregisterToggleDropdownMenuOptions = _this.props.registerToggleDropdownMenuOptions ? _this.props.registerToggleDropdownMenuOptions(_this.handleClick) : null;
|
|
210
|
-
});
|
|
211
|
-
_defineProperty(_assertThisInitialized(_this), "componentWillUnmount", function () {
|
|
212
|
-
var _this$unregisterToggl, _this2;
|
|
213
|
-
(_this$unregisterToggl = (_this2 = _this).unregisterToggleDropdownMenuOptions) === null || _this$unregisterToggl === void 0 || _this$unregisterToggl.call(_this2);
|
|
214
|
-
});
|
|
215
208
|
_defineProperty(_assertThisInitialized(_this), "handleClick", function () {
|
|
216
209
|
var _this$props$editorApp;
|
|
217
210
|
/**
|
|
@@ -563,11 +556,17 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
563
556
|
isTableSelectorOpenedByKeyboard: false
|
|
564
557
|
});
|
|
565
558
|
}
|
|
559
|
+
if (this.props.showElementBrowser !== prevProps.showElementBrowser) {
|
|
560
|
+
this.handleClick();
|
|
561
|
+
this.setState(_objectSpread(_objectSpread({}, this.state), {}, {
|
|
562
|
+
isPlusMenuOpen: this.props.showElementBrowser
|
|
563
|
+
}));
|
|
564
|
+
}
|
|
566
565
|
}
|
|
567
566
|
}, {
|
|
568
567
|
key: "renderPopup",
|
|
569
568
|
value: function renderPopup() {
|
|
570
|
-
var
|
|
569
|
+
var _this2 = this;
|
|
571
570
|
var emojiPickerOpen = this.state.emojiPickerOpen;
|
|
572
571
|
var _this$props11 = this.props,
|
|
573
572
|
popupsMountPoint = _this$props11.popupsMountPoint,
|
|
@@ -585,8 +584,8 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
585
584
|
}
|
|
586
585
|
var onUnmount = function onUnmount() {
|
|
587
586
|
requestAnimationFrame(function () {
|
|
588
|
-
var
|
|
589
|
-
return (
|
|
587
|
+
var _this2$props$pluginIn;
|
|
588
|
+
return (_this2$props$pluginIn = _this2.props.pluginInjectionApi) === null || _this2$props$pluginIn === void 0 || (_this2$props$pluginIn = _this2$props$pluginIn.core) === null || _this2$props$pluginIn === void 0 || (_this2$props$pluginIn = _this2$props$pluginIn.actions) === null || _this2$props$pluginIn === void 0 ? void 0 : _this2$props$pluginIn.focus();
|
|
590
589
|
});
|
|
591
590
|
};
|
|
592
591
|
return jsx(Popup, {
|
|
@@ -648,7 +647,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
648
647
|
}, {
|
|
649
648
|
key: "render",
|
|
650
649
|
value: function render() {
|
|
651
|
-
var
|
|
650
|
+
var _this3 = this,
|
|
652
651
|
_tableButton,
|
|
653
652
|
_tableButton2,
|
|
654
653
|
_tableButton3,
|
|
@@ -717,7 +716,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
717
716
|
return jsx(ToolbarButton, {
|
|
718
717
|
item: btn,
|
|
719
718
|
testId: String(btn.content),
|
|
720
|
-
ref:
|
|
719
|
+
ref: _this3.handleToolbarRef(btn.value.name),
|
|
721
720
|
key: btn.value.name,
|
|
722
721
|
spacing: isReducedSpacing ? 'none' : 'default',
|
|
723
722
|
disabled: isDisabled || btn.isDisabled,
|
|
@@ -727,7 +726,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
727
726
|
"aria-label": btn['aria-label'],
|
|
728
727
|
"aria-haspopup": btn['aria-haspopup'],
|
|
729
728
|
"aria-keyshortcuts": btn['aria-keyshortcuts'],
|
|
730
|
-
onItemClick:
|
|
729
|
+
onItemClick: _this3.insertToolbarMenuItem
|
|
731
730
|
});
|
|
732
731
|
}), this.props.tableSelectorSupported && (isTableButtonVisible || isTableSizeVisible) && jsx("div", {
|
|
733
732
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { insertBlockPlugin } from './plugin';
|
|
2
|
-
export type { InsertBlockPlugin, InsertBlockOptions } from './plugin';
|
|
2
|
+
export type { InsertBlockPlugin, InsertBlockOptions, InsertBlockPluginState } from './plugin';
|
|
3
3
|
export type { InsertBlockPluginDependencies } from './types';
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
1
2
|
import type { EditorAppearance, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { InsertBlockPluginDependencies } from './types';
|
|
4
|
+
export declare const toolbarSizeToButtons: (toolbarSize: ToolbarSize, appearance?: EditorAppearance) => 2 | 0 | 3 | 5 | 7;
|
|
3
5
|
export interface InsertBlockOptions {
|
|
4
6
|
allowTables?: boolean;
|
|
5
7
|
allowExpand?: boolean;
|
|
@@ -10,11 +12,16 @@ export interface InsertBlockOptions {
|
|
|
10
12
|
tableSelectorSupported?: boolean;
|
|
11
13
|
appearance?: EditorAppearance;
|
|
12
14
|
}
|
|
15
|
+
export interface InsertBlockPluginState {
|
|
16
|
+
showElementBrowser: boolean;
|
|
17
|
+
menuBrowserOpen?: boolean;
|
|
18
|
+
}
|
|
13
19
|
export type InsertBlockPlugin = NextEditorPlugin<'insertBlock', {
|
|
14
20
|
pluginConfiguration: InsertBlockOptions | undefined;
|
|
15
21
|
dependencies: InsertBlockPluginDependencies;
|
|
16
22
|
actions: {
|
|
17
23
|
toggleAdditionalMenu: () => void;
|
|
18
24
|
};
|
|
25
|
+
sharedState: InsertBlockPluginState | undefined;
|
|
19
26
|
}>;
|
|
20
27
|
export declare const insertBlockPlugin: InsertBlockPlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
type ToggleInsertBlockPmPluginState = {
|
|
4
|
+
showElementBrowser: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const toggleInsertBlockPmKey: PluginKey<ToggleInsertBlockPmPluginState>;
|
|
7
|
+
export declare const toggleInsertBlockPmPlugin: () => SafePlugin<ToggleInsertBlockPmPluginState>;
|
|
8
|
+
export {};
|
|
@@ -10,17 +10,13 @@ export declare const tableButtonWrapper: ({ isTableSelectorOpen, isButtonDisable
|
|
|
10
10
|
isTableSelectorOpen: boolean;
|
|
11
11
|
isButtonDisabled: boolean | undefined;
|
|
12
12
|
}) => import("@emotion/react").SerializedStyles;
|
|
13
|
-
|
|
14
|
-
registerToggleDropdownMenuOptions?: (cb: () => void) => () => void;
|
|
15
|
-
};
|
|
16
|
-
export declare class ToolbarInsertBlock extends React.PureComponent<Props & WrappedComponentProps & InternalActions, State> {
|
|
13
|
+
export declare class ToolbarInsertBlock extends React.PureComponent<Props & WrappedComponentProps, State> {
|
|
17
14
|
private dropdownButtonRef?;
|
|
18
15
|
private emojiButtonRef?;
|
|
19
16
|
private mediaButtonRef?;
|
|
20
17
|
private plusButtonRef?;
|
|
21
18
|
private tableButtonRef;
|
|
22
19
|
private tableSelectorButtonRef;
|
|
23
|
-
private unregisterToggleDropdownMenuOptions;
|
|
24
20
|
state: State;
|
|
25
21
|
static getDerivedStateFromProps(props: Props & WrappedComponentProps, state: State): State | null;
|
|
26
22
|
componentDidUpdate(prevProps: Props): void;
|
|
@@ -38,8 +34,6 @@ export declare class ToolbarInsertBlock extends React.PureComponent<Props & Wrap
|
|
|
38
34
|
private handleSelectedTableSize;
|
|
39
35
|
private handleTableSelectorPressEscape;
|
|
40
36
|
private handleTableSelectorClickOutside;
|
|
41
|
-
componentDidMount: () => void;
|
|
42
|
-
componentWillUnmount: () => void;
|
|
43
37
|
render(): jsx.JSX.Element | null;
|
|
44
38
|
private handleClick;
|
|
45
39
|
private handleOpenByKeyboard;
|
|
@@ -63,7 +57,7 @@ export declare class ToolbarInsertBlock extends React.PureComponent<Props & Wrap
|
|
|
63
57
|
private insertToolbarMenuItem;
|
|
64
58
|
private insertInsertMenuItem;
|
|
65
59
|
}
|
|
66
|
-
declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps
|
|
67
|
-
WrappedComponent: React.ComponentType<Props & WrappedComponentProps
|
|
60
|
+
declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps>> & {
|
|
61
|
+
WrappedComponent: React.ComponentType<Props & WrappedComponentProps>;
|
|
68
62
|
};
|
|
69
63
|
export default _default;
|
|
@@ -10,6 +10,7 @@ import type { InsertBlockPlugin } from '../../index';
|
|
|
10
10
|
import type { BlockMenuItem } from './create-items';
|
|
11
11
|
export interface Props {
|
|
12
12
|
buttons: number;
|
|
13
|
+
showElementBrowser: boolean;
|
|
13
14
|
isReducedSpacing: boolean;
|
|
14
15
|
isDisabled?: boolean;
|
|
15
16
|
isTypeAheadAllowed?: boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { insertBlockPlugin } from './plugin';
|
|
2
|
-
export type { InsertBlockPlugin, InsertBlockOptions } from './plugin';
|
|
2
|
+
export type { InsertBlockPlugin, InsertBlockOptions, InsertBlockPluginState } from './plugin';
|
|
3
3
|
export type { InsertBlockPluginDependencies } from './types';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
1
2
|
import type { EditorAppearance, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { InsertBlockPluginDependencies } from './types';
|
|
4
|
+
export declare const toolbarSizeToButtons: (toolbarSize: ToolbarSize, appearance?: EditorAppearance) => 2 | 0 | 3 | 5 | 7;
|
|
3
5
|
export interface InsertBlockOptions {
|
|
4
6
|
allowTables?: boolean;
|
|
5
7
|
allowExpand?: boolean;
|
|
@@ -10,11 +12,16 @@ export interface InsertBlockOptions {
|
|
|
10
12
|
tableSelectorSupported?: boolean;
|
|
11
13
|
appearance?: EditorAppearance;
|
|
12
14
|
}
|
|
15
|
+
export interface InsertBlockPluginState {
|
|
16
|
+
showElementBrowser: boolean;
|
|
17
|
+
menuBrowserOpen?: boolean;
|
|
18
|
+
}
|
|
13
19
|
export type InsertBlockPlugin = NextEditorPlugin<'insertBlock', {
|
|
14
20
|
pluginConfiguration: InsertBlockOptions | undefined;
|
|
15
21
|
dependencies: InsertBlockPluginDependencies;
|
|
16
22
|
actions: {
|
|
17
23
|
toggleAdditionalMenu: () => void;
|
|
18
24
|
};
|
|
25
|
+
sharedState: InsertBlockPluginState | undefined;
|
|
19
26
|
}>;
|
|
20
27
|
export declare const insertBlockPlugin: InsertBlockPlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
type ToggleInsertBlockPmPluginState = {
|
|
4
|
+
showElementBrowser: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const toggleInsertBlockPmKey: PluginKey<ToggleInsertBlockPmPluginState>;
|
|
7
|
+
export declare const toggleInsertBlockPmPlugin: () => SafePlugin<ToggleInsertBlockPmPluginState>;
|
|
8
|
+
export {};
|
|
@@ -10,17 +10,13 @@ export declare const tableButtonWrapper: ({ isTableSelectorOpen, isButtonDisable
|
|
|
10
10
|
isTableSelectorOpen: boolean;
|
|
11
11
|
isButtonDisabled: boolean | undefined;
|
|
12
12
|
}) => import("@emotion/react").SerializedStyles;
|
|
13
|
-
|
|
14
|
-
registerToggleDropdownMenuOptions?: (cb: () => void) => () => void;
|
|
15
|
-
};
|
|
16
|
-
export declare class ToolbarInsertBlock extends React.PureComponent<Props & WrappedComponentProps & InternalActions, State> {
|
|
13
|
+
export declare class ToolbarInsertBlock extends React.PureComponent<Props & WrappedComponentProps, State> {
|
|
17
14
|
private dropdownButtonRef?;
|
|
18
15
|
private emojiButtonRef?;
|
|
19
16
|
private mediaButtonRef?;
|
|
20
17
|
private plusButtonRef?;
|
|
21
18
|
private tableButtonRef;
|
|
22
19
|
private tableSelectorButtonRef;
|
|
23
|
-
private unregisterToggleDropdownMenuOptions;
|
|
24
20
|
state: State;
|
|
25
21
|
static getDerivedStateFromProps(props: Props & WrappedComponentProps, state: State): State | null;
|
|
26
22
|
componentDidUpdate(prevProps: Props): void;
|
|
@@ -38,8 +34,6 @@ export declare class ToolbarInsertBlock extends React.PureComponent<Props & Wrap
|
|
|
38
34
|
private handleSelectedTableSize;
|
|
39
35
|
private handleTableSelectorPressEscape;
|
|
40
36
|
private handleTableSelectorClickOutside;
|
|
41
|
-
componentDidMount: () => void;
|
|
42
|
-
componentWillUnmount: () => void;
|
|
43
37
|
render(): jsx.JSX.Element | null;
|
|
44
38
|
private handleClick;
|
|
45
39
|
private handleOpenByKeyboard;
|
|
@@ -63,7 +57,7 @@ export declare class ToolbarInsertBlock extends React.PureComponent<Props & Wrap
|
|
|
63
57
|
private insertToolbarMenuItem;
|
|
64
58
|
private insertInsertMenuItem;
|
|
65
59
|
}
|
|
66
|
-
declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps
|
|
67
|
-
WrappedComponent: React.ComponentType<Props & WrappedComponentProps
|
|
60
|
+
declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps>> & {
|
|
61
|
+
WrappedComponent: React.ComponentType<Props & WrappedComponentProps>;
|
|
68
62
|
};
|
|
69
63
|
export default _default;
|
|
@@ -10,6 +10,7 @@ import type { InsertBlockPlugin } from '../../index';
|
|
|
10
10
|
import type { BlockMenuItem } from './create-items';
|
|
11
11
|
export interface Props {
|
|
12
12
|
buttons: number;
|
|
13
|
+
showElementBrowser: boolean;
|
|
13
14
|
isReducedSpacing: boolean;
|
|
14
15
|
isDisabled?: boolean;
|
|
15
16
|
isTypeAheadAllowed?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-insert-block",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Insert block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,42 +32,42 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/button": "^20.2.0",
|
|
35
|
-
"@atlaskit/editor-common": "^93.
|
|
36
|
-
"@atlaskit/editor-plugin-analytics": "^1.
|
|
37
|
-
"@atlaskit/editor-plugin-block-type": "^3.
|
|
38
|
-
"@atlaskit/editor-plugin-code-block": "^3.
|
|
39
|
-
"@atlaskit/editor-plugin-date": "^2.
|
|
40
|
-
"@atlaskit/editor-plugin-emoji": "^2.
|
|
41
|
-
"@atlaskit/editor-plugin-expand": "^2.
|
|
42
|
-
"@atlaskit/editor-plugin-extension": "^1.
|
|
35
|
+
"@atlaskit/editor-common": "^93.4.0",
|
|
36
|
+
"@atlaskit/editor-plugin-analytics": "^1.9.0",
|
|
37
|
+
"@atlaskit/editor-plugin-block-type": "^3.16.0",
|
|
38
|
+
"@atlaskit/editor-plugin-code-block": "^3.5.0",
|
|
39
|
+
"@atlaskit/editor-plugin-date": "^2.4.0",
|
|
40
|
+
"@atlaskit/editor-plugin-emoji": "^2.7.0",
|
|
41
|
+
"@atlaskit/editor-plugin-expand": "^2.9.0",
|
|
42
|
+
"@atlaskit/editor-plugin-extension": "^1.15.0",
|
|
43
43
|
"@atlaskit/editor-plugin-feature-flags": "^1.2.0",
|
|
44
|
-
"@atlaskit/editor-plugin-hyperlink": "^3.
|
|
44
|
+
"@atlaskit/editor-plugin-hyperlink": "^3.1.0",
|
|
45
45
|
"@atlaskit/editor-plugin-image-upload": "^1.2.0",
|
|
46
|
-
"@atlaskit/editor-plugin-layout": "^1.
|
|
47
|
-
"@atlaskit/editor-plugin-media": "^1.
|
|
48
|
-
"@atlaskit/editor-plugin-media-insert": "^3.
|
|
49
|
-
"@atlaskit/editor-plugin-mentions": "^2.
|
|
50
|
-
"@atlaskit/editor-plugin-panel": "^2.
|
|
51
|
-
"@atlaskit/editor-plugin-placeholder-text": "^1.
|
|
46
|
+
"@atlaskit/editor-plugin-layout": "^1.9.0",
|
|
47
|
+
"@atlaskit/editor-plugin-media": "^1.35.0",
|
|
48
|
+
"@atlaskit/editor-plugin-media-insert": "^3.2.0",
|
|
49
|
+
"@atlaskit/editor-plugin-mentions": "^2.8.0",
|
|
50
|
+
"@atlaskit/editor-plugin-panel": "^2.6.0",
|
|
51
|
+
"@atlaskit/editor-plugin-placeholder-text": "^1.8.0",
|
|
52
52
|
"@atlaskit/editor-plugin-primary-toolbar": "^2.0.0",
|
|
53
53
|
"@atlaskit/editor-plugin-quick-insert": "^1.4.0",
|
|
54
|
-
"@atlaskit/editor-plugin-rule": "^1.
|
|
55
|
-
"@atlaskit/editor-plugin-status": "^2.
|
|
56
|
-
"@atlaskit/editor-plugin-table": "^7.
|
|
57
|
-
"@atlaskit/editor-plugin-tasks-and-decisions": "^2.
|
|
58
|
-
"@atlaskit/editor-plugin-type-ahead": "^1.
|
|
54
|
+
"@atlaskit/editor-plugin-rule": "^1.9.0",
|
|
55
|
+
"@atlaskit/editor-plugin-status": "^2.5.0",
|
|
56
|
+
"@atlaskit/editor-plugin-table": "^7.29.0",
|
|
57
|
+
"@atlaskit/editor-plugin-tasks-and-decisions": "^2.11.0",
|
|
58
|
+
"@atlaskit/editor-plugin-type-ahead": "^1.9.0",
|
|
59
59
|
"@atlaskit/editor-prosemirror": "6.0.0",
|
|
60
60
|
"@atlaskit/editor-shared-styles": "^3.0.0",
|
|
61
61
|
"@atlaskit/emoji": "^67.8.0",
|
|
62
62
|
"@atlaskit/heading": "2.4.6",
|
|
63
|
-
"@atlaskit/icon": "^22.
|
|
63
|
+
"@atlaskit/icon": "^22.22.0",
|
|
64
64
|
"@atlaskit/icon-lab": "^1.0.0",
|
|
65
65
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
66
66
|
"@atlaskit/primitives": "^12.2.0",
|
|
67
67
|
"@atlaskit/theme": "^13.0.0",
|
|
68
68
|
"@atlaskit/tmp-editor-statsig": "^2.3.0",
|
|
69
69
|
"@atlaskit/tokens": "^2.0.0",
|
|
70
|
-
"@atlaskit/tooltip": "18.8.
|
|
70
|
+
"@atlaskit/tooltip": "18.8.3",
|
|
71
71
|
"@babel/runtime": "^7.0.0",
|
|
72
72
|
"@emotion/react": "^11.7.1",
|
|
73
73
|
"bind-event-listener": "^3.0.0",
|