@atlaskit/editor-plugin-insert-block 2.4.23 → 2.4.25
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 +14 -0
- package/dist/cjs/insertBlockPlugin.js +38 -5
- package/dist/cjs/ui/ToolbarInsertBlock/create-items.js +30 -31
- package/dist/cjs/ui/ToolbarInsertBlock/index.js +2 -2
- package/dist/es2019/insertBlockPlugin.js +27 -1
- package/dist/es2019/ui/ToolbarInsertBlock/create-items.js +1 -2
- package/dist/es2019/ui/ToolbarInsertBlock/index.js +1 -1
- package/dist/esm/insertBlockPlugin.js +31 -1
- package/dist/esm/ui/ToolbarInsertBlock/create-items.js +1 -2
- package/dist/esm/ui/ToolbarInsertBlock/index.js +1 -1
- package/package.json +12 -9
- package/dist/cjs/ui/ToolbarInsertBlock/messages.js +0 -12
- package/dist/es2019/ui/ToolbarInsertBlock/messages.js +0 -1
- package/dist/esm/ui/ToolbarInsertBlock/messages.js +0 -1
- package/dist/types/ui/ToolbarInsertBlock/messages.d.ts +0 -1
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/messages.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-insert-block
|
|
2
2
|
|
|
3
|
+
## 2.4.25
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 2.4.24
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#179859](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/179859)
|
|
14
|
+
[`1a90382aae1c6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1a90382aae1c6) -
|
|
15
|
+
Optimise the insert menu dropdown by preloading it.
|
|
16
|
+
|
|
3
17
|
## 2.4.23
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.toolbarSizeToButtons = exports.insertBlockPlugin = void 0;
|
|
8
|
-
var _react =
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
+
var _elementBrowser = require("@atlaskit/editor-common/element-browser");
|
|
10
12
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
13
|
var _insert = require("@atlaskit/editor-common/insert");
|
|
12
14
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
@@ -18,12 +20,14 @@ var _consts = require("@atlaskit/editor-plugin-block-type/consts");
|
|
|
18
20
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
21
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
20
22
|
var _switch = _interopRequireDefault(require("./assets/switch"));
|
|
21
|
-
var
|
|
23
|
+
var _elementBrowser2 = require("./pm-plugins/elementBrowser");
|
|
22
24
|
var _toggleInsertBlock = require("./pm-plugins/toggleInsertBlock");
|
|
23
25
|
var _ElementRail = require("./ui/ElementRail");
|
|
24
26
|
var _templateOptions = require("./ui/templateOptions");
|
|
25
27
|
var _ToolbarInsertBlock = _interopRequireDefault(require("./ui/ToolbarInsertBlock"));
|
|
26
28
|
var _transformOptions = require("./ui/transformOptions");
|
|
29
|
+
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); }
|
|
30
|
+
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; }
|
|
27
31
|
var toolbarSizeToButtons = exports.toolbarSizeToButtons = function toolbarSizeToButtons(toolbarSize, appearance) {
|
|
28
32
|
// Different button numbers for full-page to better match full page toolbar breakpoints
|
|
29
33
|
if (appearance === 'full-page' && (0, _platformFeatureFlags.fg)('platform_editor_toolbar_responsive_fixes')) {
|
|
@@ -85,6 +89,23 @@ function handleInsertBlockType(insertCodeBlock, insertPanel, insertBlockQuote) {
|
|
|
85
89
|
};
|
|
86
90
|
};
|
|
87
91
|
}
|
|
92
|
+
function delayUntilIdle(cb) {
|
|
93
|
+
if (typeof window === 'undefined') {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// eslint-disable-next-line compat/compat
|
|
97
|
+
if (window.requestIdleCallback !== undefined) {
|
|
98
|
+
// eslint-disable-next-line compat/compat
|
|
99
|
+
return window.requestIdleCallback(function () {
|
|
100
|
+
return cb();
|
|
101
|
+
}, {
|
|
102
|
+
timeout: 500
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return window.requestAnimationFrame(function () {
|
|
106
|
+
return cb();
|
|
107
|
+
});
|
|
108
|
+
}
|
|
88
109
|
var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
89
110
|
var _api$primaryToolbar, _options$appearance4;
|
|
90
111
|
var _ref$config = _ref.config,
|
|
@@ -151,7 +172,7 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
|
|
|
151
172
|
return;
|
|
152
173
|
}
|
|
153
174
|
var toggleInsertBlockPluginState = _toggleInsertBlock.toggleInsertBlockPmKey.getState(editorState);
|
|
154
|
-
var elementBrowserPluginState =
|
|
175
|
+
var elementBrowserPluginState = _elementBrowser2.elementBrowserPmKey.getState(editorState);
|
|
155
176
|
return {
|
|
156
177
|
showElementBrowser: (toggleInsertBlockPluginState === null || toggleInsertBlockPluginState === void 0 ? void 0 : toggleInsertBlockPluginState.showElementBrowser) || false,
|
|
157
178
|
/**
|
|
@@ -162,6 +183,18 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
|
|
|
162
183
|
menuBrowserOpen: (0, _experiments.editorExperiment)('insert-menu-in-right-rail', true) ? elementBrowserPluginState === null || elementBrowserPluginState === void 0 ? void 0 : elementBrowserPluginState.menuBrowserOpen : false
|
|
163
184
|
};
|
|
164
185
|
},
|
|
186
|
+
usePluginHook: function usePluginHook() {
|
|
187
|
+
(0, _react.useEffect)(function () {
|
|
188
|
+
// This is to optimise the UI so that when the user first clicks on the insert
|
|
189
|
+
// menu it opens instantly. As we're delaying the loading this won't affect the
|
|
190
|
+
// initial editor rendering metrics.
|
|
191
|
+
delayUntilIdle(function () {
|
|
192
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_preload_insert_menu')) {
|
|
193
|
+
_elementBrowser.ElementBrowser.preload();
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}, []);
|
|
197
|
+
},
|
|
165
198
|
pmPlugins: function pmPlugins() {
|
|
166
199
|
var _options$appearance2;
|
|
167
200
|
if (!['full-page', 'full-width'].includes((_options$appearance2 = options.appearance) !== null && _options$appearance2 !== void 0 ? _options$appearance2 : '')) {
|
|
@@ -172,7 +205,7 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
|
|
|
172
205
|
plugins.push({
|
|
173
206
|
name: 'elementBrowserPmPlugin',
|
|
174
207
|
plugin: function plugin() {
|
|
175
|
-
return (0,
|
|
208
|
+
return (0, _elementBrowser2.elementBrowserPmPlugin)();
|
|
176
209
|
}
|
|
177
210
|
}, {
|
|
178
211
|
name: 'elementBrowserEditorViewRef',
|
|
@@ -279,7 +312,7 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
|
|
|
279
312
|
plugin.pluginsOptions.contextPanel = function (state) {
|
|
280
313
|
// api.getSharedState() will have an outdated reference to editorState on first mount of this component
|
|
281
314
|
// so instead just rely on plugin key as we don't need to be reactive to changes here
|
|
282
|
-
var pluginState =
|
|
315
|
+
var pluginState = _elementBrowser2.elementBrowserPmKey.getState(state);
|
|
283
316
|
if (pluginState !== null && pluginState !== void 0 && pluginState.menuBrowserOpen && editorViewRef.current) {
|
|
284
317
|
return /*#__PURE__*/_react.default.createElement(_ElementRail.InsertMenuRail, {
|
|
285
318
|
editorView: editorViewRef.current,
|
|
@@ -14,7 +14,6 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
|
14
14
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
15
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
16
|
var _item = require("./item");
|
|
17
|
-
var _messages2 = require("./messages");
|
|
18
17
|
var _shallowEquals = require("./shallow-equals");
|
|
19
18
|
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; }
|
|
20
19
|
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; }
|
|
@@ -69,67 +68,67 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
|
|
|
69
68
|
var isOffline = isEditorOffline === true;
|
|
70
69
|
if (actionSupported) {
|
|
71
70
|
items.push((0, _item.action)({
|
|
72
|
-
content: formatMessage(
|
|
73
|
-
tooltipDescription: formatMessage(
|
|
71
|
+
content: formatMessage(_messages.toolbarInsertBlockMessages.action),
|
|
72
|
+
tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.actionDescription),
|
|
74
73
|
disabled: false
|
|
75
74
|
}));
|
|
76
75
|
}
|
|
77
76
|
if (linkSupported) {
|
|
78
77
|
items.push((0, _item.link)({
|
|
79
|
-
content: formatMessage(
|
|
80
|
-
tooltipDescription: formatMessage(
|
|
78
|
+
content: formatMessage(_messages.toolbarInsertBlockMessages.link),
|
|
79
|
+
tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.linkDescription),
|
|
81
80
|
disabled: !!linkDisabled,
|
|
82
81
|
'aria-haspopup': 'dialog'
|
|
83
82
|
}));
|
|
84
83
|
}
|
|
85
84
|
if (mediaSupported && mediaUploadsEnabled) {
|
|
86
85
|
items.push((0, _item.media)({
|
|
87
|
-
content: formatMessage(
|
|
88
|
-
tooltipDescription: formatMessage(
|
|
86
|
+
content: formatMessage(_messages.toolbarInsertBlockMessages.addMediaFiles),
|
|
87
|
+
tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.mediaFilesDescription),
|
|
89
88
|
disabled: isOffline
|
|
90
89
|
}));
|
|
91
90
|
}
|
|
92
91
|
if (imageUploadSupported) {
|
|
93
92
|
items.push((0, _item.imageUpload)({
|
|
94
|
-
content: formatMessage(
|
|
93
|
+
content: formatMessage(_messages.toolbarInsertBlockMessages.image),
|
|
95
94
|
disabled: !imageUploadEnabled || isOffline
|
|
96
95
|
}));
|
|
97
96
|
}
|
|
98
97
|
if (mentionsSupported) {
|
|
99
98
|
items.push((0, _item.mention)({
|
|
100
|
-
content: formatMessage(
|
|
101
|
-
tooltipDescription: formatMessage(
|
|
99
|
+
content: formatMessage(_messages.toolbarInsertBlockMessages.mention),
|
|
100
|
+
tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.mentionDescription),
|
|
102
101
|
disabled: !isTypeAheadAllowed || !!mentionsDisabled || isOffline,
|
|
103
102
|
'aria-haspopup': 'listbox'
|
|
104
103
|
}));
|
|
105
104
|
}
|
|
106
105
|
if (emojiProvider) {
|
|
107
106
|
items.push((0, _item.emoji)({
|
|
108
|
-
content: formatMessage(
|
|
109
|
-
tooltipDescription: formatMessage(
|
|
107
|
+
content: formatMessage(_messages.toolbarInsertBlockMessages.emoji),
|
|
108
|
+
tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.emojiDescription),
|
|
110
109
|
disabled: emojiDisabled || !isTypeAheadAllowed || isOffline,
|
|
111
110
|
'aria-haspopup': 'dialog'
|
|
112
111
|
}));
|
|
113
112
|
}
|
|
114
113
|
if (tableSupported) {
|
|
115
114
|
items.push((0, _item.table)({
|
|
116
|
-
content: formatMessage(
|
|
117
|
-
tooltipDescription: formatMessage(
|
|
115
|
+
content: formatMessage(_messages.toolbarInsertBlockMessages.table),
|
|
116
|
+
tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.tableDescription),
|
|
118
117
|
disabled: false
|
|
119
118
|
}));
|
|
120
119
|
}
|
|
121
120
|
if (tableSupported && tableSelectorSupported) {
|
|
122
121
|
items.push((0, _item.tableSelector)({
|
|
123
|
-
content: formatMessage(
|
|
124
|
-
tooltipDescription: formatMessage(
|
|
122
|
+
content: formatMessage(_messages.toolbarInsertBlockMessages.tableSelector),
|
|
123
|
+
tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.tableSelectorDescription),
|
|
125
124
|
disabled: false
|
|
126
125
|
}));
|
|
127
126
|
}
|
|
128
127
|
if (layoutSectionEnabled) {
|
|
129
|
-
var labelColumns = formatMessage(
|
|
128
|
+
var labelColumns = formatMessage(_messages.toolbarInsertBlockMessages.columns);
|
|
130
129
|
items.push((0, _item.layout)({
|
|
131
130
|
content: labelColumns,
|
|
132
|
-
tooltipDescription: formatMessage(
|
|
131
|
+
tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.columnsDescription),
|
|
133
132
|
disabled: false
|
|
134
133
|
}));
|
|
135
134
|
}
|
|
@@ -168,44 +167,44 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
|
|
|
168
167
|
}
|
|
169
168
|
if (decisionSupported) {
|
|
170
169
|
items.push((0, _item.decision)({
|
|
171
|
-
content: formatMessage(
|
|
172
|
-
tooltipDescription: formatMessage(
|
|
170
|
+
content: formatMessage(_messages.toolbarInsertBlockMessages.decision),
|
|
171
|
+
tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.decisionDescription),
|
|
173
172
|
disabled: false
|
|
174
173
|
}));
|
|
175
174
|
}
|
|
176
175
|
if (horizontalRuleEnabled && schema.nodes.rule) {
|
|
177
176
|
items.push((0, _item.horizontalrule)({
|
|
178
|
-
content: formatMessage(
|
|
179
|
-
tooltipDescription: formatMessage(
|
|
177
|
+
content: formatMessage(_messages.toolbarInsertBlockMessages.horizontalRule),
|
|
178
|
+
tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.horizontalRuleDescription),
|
|
180
179
|
disabled: false
|
|
181
180
|
}));
|
|
182
181
|
}
|
|
183
182
|
if (expandEnabled && schema.nodes.expand) {
|
|
184
183
|
items.push((0, _item.expand)({
|
|
185
|
-
content: formatMessage(
|
|
186
|
-
tooltipDescription: formatMessage(
|
|
184
|
+
content: formatMessage(_messages.toolbarInsertBlockMessages.expand),
|
|
185
|
+
tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.expandDescription),
|
|
187
186
|
disabled: false
|
|
188
187
|
}));
|
|
189
188
|
}
|
|
190
189
|
if (dateEnabled) {
|
|
191
|
-
var labelDate = formatMessage(
|
|
190
|
+
var labelDate = formatMessage(_messages.toolbarInsertBlockMessages.date);
|
|
192
191
|
items.push((0, _item.date)({
|
|
193
192
|
content: labelDate,
|
|
194
|
-
tooltipDescription: formatMessage(
|
|
193
|
+
tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.dateDescription),
|
|
195
194
|
disabled: false
|
|
196
195
|
}));
|
|
197
196
|
}
|
|
198
197
|
if (placeholderTextEnabled) {
|
|
199
198
|
items.push((0, _item.placeholder)({
|
|
200
|
-
content: formatMessage(
|
|
199
|
+
content: formatMessage(_messages.toolbarInsertBlockMessages.placeholderText),
|
|
201
200
|
disabled: false
|
|
202
201
|
}));
|
|
203
202
|
}
|
|
204
203
|
if (nativeStatusSupported) {
|
|
205
|
-
var labelStatus = formatMessage(
|
|
204
|
+
var labelStatus = formatMessage(_messages.toolbarInsertBlockMessages.status);
|
|
206
205
|
items.push((0, _item.status)({
|
|
207
206
|
content: labelStatus,
|
|
208
|
-
tooltipDescription: formatMessage(
|
|
207
|
+
tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.statusDescription),
|
|
209
208
|
disabled: false
|
|
210
209
|
}));
|
|
211
210
|
}
|
|
@@ -214,7 +213,7 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
|
|
|
214
213
|
}
|
|
215
214
|
if (showElementBrowserLink) {
|
|
216
215
|
items.push((0, _item.more)({
|
|
217
|
-
content: formatMessage(
|
|
216
|
+
content: formatMessage(_messages.toolbarInsertBlockMessages.viewMore),
|
|
218
217
|
disabled: false
|
|
219
218
|
}));
|
|
220
219
|
}
|
|
@@ -233,7 +232,7 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
|
|
|
233
232
|
var name = _ref.value.name;
|
|
234
233
|
return name !== 'table selector';
|
|
235
234
|
});
|
|
236
|
-
var dropdownItems = remainingItems.map(buttonToDropdownItem(formatMessage(
|
|
235
|
+
var dropdownItems = remainingItems.map(buttonToDropdownItem(formatMessage(_messages.toolbarInsertBlockMessages.insertMenu)));
|
|
237
236
|
return [buttonItems, dropdownItems];
|
|
238
237
|
};
|
|
239
238
|
var createItems = exports.createItems = (0, _memoizeOne.default)(createInsertBlockItems, _shallowEquals.shallowEquals);
|
|
@@ -19,6 +19,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
19
19
|
var _react2 = require("@emotion/react");
|
|
20
20
|
var _reactIntlNext = require("react-intl-next");
|
|
21
21
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
22
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
22
23
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
23
24
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
24
25
|
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
@@ -30,7 +31,6 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
|
30
31
|
var _commands = require("../../pm-plugins/commands");
|
|
31
32
|
var _blockInsertMenu = require("./block-insert-menu");
|
|
32
33
|
var _createItems3 = require("./create-items");
|
|
33
|
-
var _messages = require("./messages");
|
|
34
34
|
var _tableSelectorPopupWithListeners = _interopRequireDefault(require("./table-selector-popup-with-listeners"));
|
|
35
35
|
var _templateObject;
|
|
36
36
|
/**
|
|
@@ -792,7 +792,7 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
|
|
|
792
792
|
disabled: (_this$props$isDisable = this.props.isDisabled) !== null && _this$props$isDisable !== void 0 ? _this$props$isDisable : false,
|
|
793
793
|
editorView: this.props.editorView,
|
|
794
794
|
spacing: this.props.isReducedSpacing ? 'none' : 'default',
|
|
795
|
-
label: this.props.intl.formatMessage(_messages.
|
|
795
|
+
label: this.props.intl.formatMessage(_messages.toolbarInsertBlockMessages.insertMenu),
|
|
796
796
|
open: (0, _experiments.editorExperiment)('insert-menu-in-right-rail', true) ? !isFullPageAppearance && this.state.isPlusMenuOpen : this.state.isPlusMenuOpen,
|
|
797
797
|
plusButtonRef: (_this$plusButtonRef = this.plusButtonRef) === null || _this$plusButtonRef === void 0 ? void 0 : _this$plusButtonRef.deref(),
|
|
798
798
|
items: this.state.dropdownItems,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { ElementBrowser } from '@atlaskit/editor-common/element-browser';
|
|
3
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
5
|
import { contentAllowedInCodeBlock, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
5
6
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
@@ -76,6 +77,19 @@ function handleInsertBlockType(insertCodeBlock, insertPanel, insertBlockQuote) {
|
|
|
76
77
|
return () => false;
|
|
77
78
|
};
|
|
78
79
|
}
|
|
80
|
+
function delayUntilIdle(cb) {
|
|
81
|
+
if (typeof window === 'undefined') {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// eslint-disable-next-line compat/compat
|
|
85
|
+
if (window.requestIdleCallback !== undefined) {
|
|
86
|
+
// eslint-disable-next-line compat/compat
|
|
87
|
+
return window.requestIdleCallback(() => cb(), {
|
|
88
|
+
timeout: 500
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return window.requestAnimationFrame(() => cb());
|
|
92
|
+
}
|
|
79
93
|
export const insertBlockPlugin = ({
|
|
80
94
|
config: options = {},
|
|
81
95
|
api
|
|
@@ -155,6 +169,18 @@ export const insertBlockPlugin = ({
|
|
|
155
169
|
menuBrowserOpen: editorExperiment('insert-menu-in-right-rail', true) ? elementBrowserPluginState === null || elementBrowserPluginState === void 0 ? void 0 : elementBrowserPluginState.menuBrowserOpen : false
|
|
156
170
|
};
|
|
157
171
|
},
|
|
172
|
+
usePluginHook() {
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
// This is to optimise the UI so that when the user first clicks on the insert
|
|
175
|
+
// menu it opens instantly. As we're delaying the loading this won't affect the
|
|
176
|
+
// initial editor rendering metrics.
|
|
177
|
+
delayUntilIdle(() => {
|
|
178
|
+
if (fg('platform_editor_preload_insert_menu')) {
|
|
179
|
+
ElementBrowser.preload();
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}, []);
|
|
183
|
+
},
|
|
158
184
|
pmPlugins: () => {
|
|
159
185
|
var _options$appearance2;
|
|
160
186
|
if (!['full-page', 'full-width'].includes((_options$appearance2 = options.appearance) !== null && _options$appearance2 !== void 0 ? _options$appearance2 : '')) {
|
|
@@ -2,10 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import memoize from 'lodash/memoize';
|
|
3
3
|
import memoizeOne from 'memoize-one';
|
|
4
4
|
import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
5
|
-
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { blockTypeMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import { action, blockquote, codeblock, date, decision, emoji, expand, horizontalrule, imageUpload, layout, link, media, mention, more, panel, placeholder, status, table, tableSelector } from './item';
|
|
8
|
-
import { messages } from './messages';
|
|
9
8
|
import { shallowEquals } from './shallow-equals';
|
|
10
9
|
const buttonToItem = memoize(button => ({
|
|
11
10
|
...button,
|
|
@@ -10,6 +10,7 @@ import React from 'react';
|
|
|
10
10
|
import { css, jsx } from '@emotion/react';
|
|
11
11
|
import { injectIntl } from 'react-intl-next';
|
|
12
12
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
13
|
+
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
13
14
|
import { buttonGroupStyle, separatorStyles, wrapperStyle } from '@atlaskit/editor-common/styles';
|
|
14
15
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
15
16
|
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
@@ -21,7 +22,6 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
|
21
22
|
import { toggleInsertMenuRightRail } from '../../pm-plugins/commands';
|
|
22
23
|
import { BlockInsertMenu } from './block-insert-menu';
|
|
23
24
|
import { createItems } from './create-items';
|
|
24
|
-
import { messages } from './messages';
|
|
25
25
|
import TableSelectorPopup from './table-selector-popup-with-listeners';
|
|
26
26
|
/**
|
|
27
27
|
* Checks if an element is detached (i.e. not in the current document)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { ElementBrowser } from '@atlaskit/editor-common/element-browser';
|
|
3
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
5
|
import { contentAllowedInCodeBlock, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
5
6
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
@@ -78,6 +79,23 @@ function handleInsertBlockType(insertCodeBlock, insertPanel, insertBlockQuote) {
|
|
|
78
79
|
};
|
|
79
80
|
};
|
|
80
81
|
}
|
|
82
|
+
function delayUntilIdle(cb) {
|
|
83
|
+
if (typeof window === 'undefined') {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// eslint-disable-next-line compat/compat
|
|
87
|
+
if (window.requestIdleCallback !== undefined) {
|
|
88
|
+
// eslint-disable-next-line compat/compat
|
|
89
|
+
return window.requestIdleCallback(function () {
|
|
90
|
+
return cb();
|
|
91
|
+
}, {
|
|
92
|
+
timeout: 500
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return window.requestAnimationFrame(function () {
|
|
96
|
+
return cb();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
81
99
|
export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
82
100
|
var _api$primaryToolbar, _options$appearance4;
|
|
83
101
|
var _ref$config = _ref.config,
|
|
@@ -155,6 +173,18 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
155
173
|
menuBrowserOpen: editorExperiment('insert-menu-in-right-rail', true) ? elementBrowserPluginState === null || elementBrowserPluginState === void 0 ? void 0 : elementBrowserPluginState.menuBrowserOpen : false
|
|
156
174
|
};
|
|
157
175
|
},
|
|
176
|
+
usePluginHook: function usePluginHook() {
|
|
177
|
+
useEffect(function () {
|
|
178
|
+
// This is to optimise the UI so that when the user first clicks on the insert
|
|
179
|
+
// menu it opens instantly. As we're delaying the loading this won't affect the
|
|
180
|
+
// initial editor rendering metrics.
|
|
181
|
+
delayUntilIdle(function () {
|
|
182
|
+
if (fg('platform_editor_preload_insert_menu')) {
|
|
183
|
+
ElementBrowser.preload();
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}, []);
|
|
187
|
+
},
|
|
158
188
|
pmPlugins: function pmPlugins() {
|
|
159
189
|
var _options$appearance2;
|
|
160
190
|
if (!['full-page', 'full-width'].includes((_options$appearance2 = options.appearance) !== null && _options$appearance2 !== void 0 ? _options$appearance2 : '')) {
|
|
@@ -6,10 +6,9 @@ import React from 'react';
|
|
|
6
6
|
import memoize from 'lodash/memoize';
|
|
7
7
|
import memoizeOne from 'memoize-one';
|
|
8
8
|
import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
9
|
-
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
9
|
+
import { blockTypeMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
10
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
11
|
import { action, blockquote, codeblock, date, decision, emoji, expand, horizontalrule, imageUpload, layout, link, media, mention, more, panel, placeholder, status, table, tableSelector } from './item';
|
|
12
|
-
import { messages } from './messages';
|
|
13
12
|
import { shallowEquals } from './shallow-equals';
|
|
14
13
|
var buttonToItem = memoize(function (button) {
|
|
15
14
|
return _objectSpread(_objectSpread({}, button), {}, {
|
|
@@ -25,6 +25,7 @@ import React from 'react';
|
|
|
25
25
|
import { css, jsx } from '@emotion/react';
|
|
26
26
|
import { injectIntl } from 'react-intl-next';
|
|
27
27
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
28
|
+
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
28
29
|
import { buttonGroupStyle, separatorStyles, wrapperStyle } from '@atlaskit/editor-common/styles';
|
|
29
30
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
30
31
|
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
@@ -36,7 +37,6 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
|
36
37
|
import { toggleInsertMenuRightRail } from '../../pm-plugins/commands';
|
|
37
38
|
import { BlockInsertMenu } from './block-insert-menu';
|
|
38
39
|
import { createItems } from './create-items';
|
|
39
|
-
import { messages } from './messages';
|
|
40
40
|
import TableSelectorPopup from './table-selector-popup-with-listeners';
|
|
41
41
|
/**
|
|
42
42
|
* Checks if an element is detached (i.e. not in the current document)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-insert-block",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.25",
|
|
4
4
|
"description": "Insert block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/button": "^20.3.0",
|
|
35
|
-
"@atlaskit/editor-common": "^
|
|
35
|
+
"@atlaskit/editor-common": "^97.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
37
37
|
"@atlaskit/editor-plugin-block-type": "^4.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-code-block": "^3.5.0",
|
|
39
|
-
"@atlaskit/editor-plugin-connectivity": "^1.
|
|
39
|
+
"@atlaskit/editor-plugin-connectivity": "^1.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-date": "^2.4.0",
|
|
41
41
|
"@atlaskit/editor-plugin-emoji": "^2.7.0",
|
|
42
42
|
"@atlaskit/editor-plugin-expand": "^2.10.0",
|
|
43
|
-
"@atlaskit/editor-plugin-extension": "^
|
|
43
|
+
"@atlaskit/editor-plugin-extension": "^3.0.0",
|
|
44
44
|
"@atlaskit/editor-plugin-feature-flags": "^1.2.0",
|
|
45
45
|
"@atlaskit/editor-plugin-hyperlink": "^3.2.0",
|
|
46
46
|
"@atlaskit/editor-plugin-image-upload": "^1.2.0",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"@atlaskit/editor-plugin-media": "^1.43.0",
|
|
49
49
|
"@atlaskit/editor-plugin-media-insert": "^4.0.0",
|
|
50
50
|
"@atlaskit/editor-plugin-mentions": "^2.10.0",
|
|
51
|
-
"@atlaskit/editor-plugin-panel": "^3.
|
|
52
|
-
"@atlaskit/editor-plugin-placeholder-text": "^1.
|
|
53
|
-
"@atlaskit/editor-plugin-primary-toolbar": "^2.
|
|
51
|
+
"@atlaskit/editor-plugin-panel": "^3.2.0",
|
|
52
|
+
"@atlaskit/editor-plugin-placeholder-text": "^1.9.0",
|
|
53
|
+
"@atlaskit/editor-plugin-primary-toolbar": "^2.1.0",
|
|
54
54
|
"@atlaskit/editor-plugin-quick-insert": "^1.8.0",
|
|
55
55
|
"@atlaskit/editor-plugin-rule": "^1.9.0",
|
|
56
56
|
"@atlaskit/editor-plugin-status": "^2.6.0",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
67
67
|
"@atlaskit/primitives": "^13.3.0",
|
|
68
68
|
"@atlaskit/theme": "^14.0.0",
|
|
69
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
70
|
-
"@atlaskit/tokens": "^2.
|
|
69
|
+
"@atlaskit/tmp-editor-statsig": "^2.29.0",
|
|
70
|
+
"@atlaskit/tokens": "^2.5.0",
|
|
71
71
|
"@atlaskit/tooltip": "19.0.0",
|
|
72
72
|
"@babel/runtime": "^7.0.0",
|
|
73
73
|
"@emotion/react": "^11.7.1",
|
|
@@ -130,6 +130,9 @@
|
|
|
130
130
|
"platform_editor_consistent_insert_menu": {
|
|
131
131
|
"type": "boolean"
|
|
132
132
|
},
|
|
133
|
+
"platform_editor_preload_insert_menu": {
|
|
134
|
+
"type": "boolean"
|
|
135
|
+
},
|
|
133
136
|
"platform_editor_reduce_element_browser_padding": {
|
|
134
137
|
"type": "boolean"
|
|
135
138
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "messages", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _messages.toolbarInsertBlockMessages;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|