@atlaskit/editor-plugin-insert-block 3.1.2 → 3.1.4
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 +15 -0
- package/dist/cjs/insertBlockPlugin.js +2 -54
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +14 -64
- package/dist/cjs/ui/ToolbarInsertBlock/block-insert-element-browser.js +1 -1
- package/dist/cjs/ui/ToolbarInsertBlock/block-insert-menu.js +1 -6
- package/dist/cjs/ui/ToolbarInsertBlock/index.js +28 -77
- package/dist/es2019/insertBlockPlugin.js +2 -52
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +14 -64
- package/dist/es2019/ui/ToolbarInsertBlock/block-insert-element-browser.js +1 -1
- package/dist/es2019/ui/ToolbarInsertBlock/block-insert-menu.js +1 -7
- package/dist/es2019/ui/ToolbarInsertBlock/index.js +19 -72
- package/dist/esm/insertBlockPlugin.js +2 -54
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +14 -64
- package/dist/esm/ui/ToolbarInsertBlock/block-insert-element-browser.js +1 -1
- package/dist/esm/ui/ToolbarInsertBlock/block-insert-menu.js +1 -6
- package/dist/esm/ui/ToolbarInsertBlock/index.js +28 -77
- package/dist/types/types/index.d.ts +0 -1
- package/dist/types/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +0 -1
- package/dist/types-ts4.5/types/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +0 -1
- package/package.json +4 -4
- package/dist/cjs/pm-plugins/commands.js +0 -16
- package/dist/cjs/pm-plugins/elementBrowser.js +0 -39
- package/dist/cjs/ui/ElementRail/index.js +0 -236
- package/dist/cjs/ui/assets/expand.js +0 -40
- package/dist/cjs/ui/assets/switch.js +0 -26
- package/dist/cjs/ui/transformOptions.js +0 -36
- package/dist/es2019/pm-plugins/commands.js +0 -11
- package/dist/es2019/pm-plugins/elementBrowser.js +0 -31
- package/dist/es2019/ui/ElementRail/index.js +0 -233
- package/dist/es2019/ui/assets/expand.js +0 -34
- package/dist/es2019/ui/assets/switch.js +0 -18
- package/dist/es2019/ui/transformOptions.js +0 -29
- package/dist/esm/pm-plugins/commands.js +0 -11
- package/dist/esm/pm-plugins/elementBrowser.js +0 -33
- package/dist/esm/ui/ElementRail/index.js +0 -225
- package/dist/esm/ui/assets/expand.js +0 -33
- package/dist/esm/ui/assets/switch.js +0 -18
- package/dist/esm/ui/transformOptions.js +0 -29
- package/dist/types/pm-plugins/commands.d.ts +0 -6
- package/dist/types/pm-plugins/elementBrowser.d.ts +0 -16
- package/dist/types/ui/ElementRail/index.d.ts +0 -21
- package/dist/types/ui/assets/expand.d.ts +0 -8
- package/dist/types/ui/assets/switch.d.ts +0 -6
- package/dist/types/ui/transformOptions.d.ts +0 -27
- package/dist/types-ts4.5/pm-plugins/commands.d.ts +0 -6
- package/dist/types-ts4.5/pm-plugins/elementBrowser.d.ts +0 -16
- package/dist/types-ts4.5/ui/ElementRail/index.d.ts +0 -21
- package/dist/types-ts4.5/ui/assets/expand.d.ts +0 -8
- package/dist/types-ts4.5/ui/assets/switch.d.ts +0 -6
- package/dist/types-ts4.5/ui/transformOptions.d.ts +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-insert-block
|
|
2
2
|
|
|
3
|
+
## 3.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#132261](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/132261)
|
|
8
|
+
[`a8fe96525eb2c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a8fe96525eb2c) -
|
|
9
|
+
ED-24801 Clean up platform_editor_insert_menu_in_right_rail
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 3.1.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 3.1.2
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -11,14 +11,10 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
11
11
|
var _elementBrowser = require("@atlaskit/editor-common/element-browser");
|
|
12
12
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
13
13
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
14
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
15
14
|
var _types = require("@atlaskit/editor-common/types");
|
|
16
15
|
var _consts = require("@atlaskit/editor-plugin-block-type/consts");
|
|
17
16
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
19
|
-
var _elementBrowser2 = require("./pm-plugins/elementBrowser");
|
|
20
17
|
var _toggleInsertBlock = require("./pm-plugins/toggleInsertBlock");
|
|
21
|
-
var _ElementRail = require("./ui/ElementRail");
|
|
22
18
|
var _ToolbarInsertBlock = _interopRequireDefault(require("./ui/ToolbarInsertBlock"));
|
|
23
19
|
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); }
|
|
24
20
|
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; }
|
|
@@ -105,13 +101,10 @@ function delayUntilIdle(cb) {
|
|
|
105
101
|
});
|
|
106
102
|
}
|
|
107
103
|
var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
108
|
-
var _api$primaryToolbar
|
|
104
|
+
var _api$primaryToolbar;
|
|
109
105
|
var _ref$config = _ref.config,
|
|
110
106
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
111
107
|
api = _ref.api;
|
|
112
|
-
var editorViewRef = {
|
|
113
|
-
current: null
|
|
114
|
-
};
|
|
115
108
|
var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
|
|
116
109
|
var editorView = _ref2.editorView,
|
|
117
110
|
editorActions = _ref2.editorActions,
|
|
@@ -170,15 +163,8 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
|
|
|
170
163
|
return;
|
|
171
164
|
}
|
|
172
165
|
var toggleInsertBlockPluginState = _toggleInsertBlock.toggleInsertBlockPmKey.getState(editorState);
|
|
173
|
-
var elementBrowserPluginState = _elementBrowser2.elementBrowserPmKey.getState(editorState);
|
|
174
166
|
return {
|
|
175
|
-
showElementBrowser: (toggleInsertBlockPluginState === null || toggleInsertBlockPluginState === void 0 ? void 0 : toggleInsertBlockPluginState.showElementBrowser) || false
|
|
176
|
-
/**
|
|
177
|
-
* For insert menu in right rail experiment
|
|
178
|
-
* - Clean up ticket ED-24801
|
|
179
|
-
* Experiment: `insert-menu-in-right-rail`
|
|
180
|
-
*/
|
|
181
|
-
menuBrowserOpen: (0, _experiments.editorExperiment)('insert-menu-in-right-rail', true) ? elementBrowserPluginState === null || elementBrowserPluginState === void 0 ? void 0 : elementBrowserPluginState.menuBrowserOpen : false
|
|
167
|
+
showElementBrowser: (toggleInsertBlockPluginState === null || toggleInsertBlockPluginState === void 0 ? void 0 : toggleInsertBlockPluginState.showElementBrowser) || false
|
|
182
168
|
};
|
|
183
169
|
},
|
|
184
170
|
usePluginHook: function usePluginHook() {
|
|
@@ -197,25 +183,6 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
|
|
|
197
183
|
[];
|
|
198
184
|
}
|
|
199
185
|
var plugins = [];
|
|
200
|
-
if ((0, _experiments.editorExperiment)('insert-menu-in-right-rail', true)) {
|
|
201
|
-
plugins.push({
|
|
202
|
-
name: 'elementBrowserPmPlugin',
|
|
203
|
-
plugin: function plugin() {
|
|
204
|
-
return (0, _elementBrowser2.elementBrowserPmPlugin)();
|
|
205
|
-
}
|
|
206
|
-
}, {
|
|
207
|
-
name: 'elementBrowserEditorViewRef',
|
|
208
|
-
plugin: function plugin() {
|
|
209
|
-
return new _safePlugin.SafePlugin({
|
|
210
|
-
view: function view(editorView) {
|
|
211
|
-
// Workaround - need reference to editorView for contextPanel component
|
|
212
|
-
editorViewRef.current = editorView;
|
|
213
|
-
return {};
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
186
|
plugins.push({
|
|
220
187
|
name: 'toggleInsertBlockPmPlugin',
|
|
221
188
|
plugin: function plugin() {
|
|
@@ -227,25 +194,6 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
|
|
|
227
194
|
pluginsOptions: {},
|
|
228
195
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
229
196
|
};
|
|
230
|
-
if (
|
|
231
|
-
// @ts-ignore
|
|
232
|
-
['full-page', 'full-width'].includes((_options$appearance3 = options.appearance) !== null && _options$appearance3 !== void 0 ? _options$appearance3 : '') && (0, _experiments.editorExperiment)('insert-menu-in-right-rail', true)) {
|
|
233
|
-
// Ignored via go/ees005
|
|
234
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
235
|
-
plugin.pluginsOptions.contextPanel = function (state) {
|
|
236
|
-
// api.getSharedState() will have an outdated reference to editorState on first mount of this component
|
|
237
|
-
// so instead just rely on plugin key as we don't need to be reactive to changes here
|
|
238
|
-
var pluginState = _elementBrowser2.elementBrowserPmKey.getState(state);
|
|
239
|
-
if (pluginState !== null && pluginState !== void 0 && pluginState.menuBrowserOpen && editorViewRef.current) {
|
|
240
|
-
return /*#__PURE__*/_react.default.createElement(_ElementRail.InsertMenuRail, {
|
|
241
|
-
editorView: editorViewRef.current,
|
|
242
|
-
options: options,
|
|
243
|
-
api: api
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
return;
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
197
|
return plugin;
|
|
250
198
|
};
|
|
251
199
|
function ToolbarInsertBlockWithInjectionApi(_ref4) {
|
|
@@ -20,7 +20,6 @@ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
|
20
20
|
var _uiReact = require("@atlaskit/editor-common/ui-react");
|
|
21
21
|
var _theme = require("@atlaskit/theme");
|
|
22
22
|
var _colors = require("@atlaskit/theme/colors");
|
|
23
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
24
23
|
var _excluded = ["children"];
|
|
25
24
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
26
25
|
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; } /**
|
|
@@ -31,7 +30,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
31
30
|
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
32
31
|
var DEFAULT_HEIGHT = exports.DEFAULT_HEIGHT = 560;
|
|
33
32
|
var InsertMenu = function InsertMenu(_ref) {
|
|
34
|
-
var _pluginInjectionApi$
|
|
33
|
+
var _pluginInjectionApi$q6, _pluginInjectionApi$q7;
|
|
35
34
|
var editorView = _ref.editorView,
|
|
36
35
|
dropdownItems = _ref.dropdownItems,
|
|
37
36
|
showElementBrowserLink = _ref.showElementBrowserLink,
|
|
@@ -95,20 +94,13 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
95
94
|
var quickInsertDropdownItems = dropdownItems.map(transform);
|
|
96
95
|
var viewMoreItem = showElementBrowserLink ? quickInsertDropdownItems.pop() : undefined;
|
|
97
96
|
var onInsertItem = (0, _react.useCallback)(function (item) {
|
|
97
|
+
var _pluginInjectionApi$q;
|
|
98
98
|
toggleVisiblity();
|
|
99
99
|
if (!editorView.hasFocus()) {
|
|
100
100
|
editorView.focus();
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$q = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q === void 0 || _pluginInjectionApi$q.actions.insertItem(item,
|
|
105
|
-
// @ts-expect-error
|
|
106
|
-
_analytics.INPUT_METHOD.INSERT_MENU_RIGHT_RAIL)(editorView.state, editorView.dispatch);
|
|
107
|
-
} else {
|
|
108
|
-
var _pluginInjectionApi$q2;
|
|
109
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$q2 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q2 === void 0 || _pluginInjectionApi$q2.actions.insertItem(item, _analytics.INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
110
|
-
}
|
|
111
|
-
}, [editorView, toggleVisiblity, pluginInjectionApi, isFullPageAppearance]);
|
|
102
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$q = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q === void 0 || _pluginInjectionApi$q.actions.insertItem(item, _analytics.INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
103
|
+
}, [editorView, toggleVisiblity, pluginInjectionApi]);
|
|
112
104
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['connectivity']),
|
|
113
105
|
connectivityState = _useSharedPluginState.connectivityState;
|
|
114
106
|
var getItems = (0, _react.useCallback)(function (query, category) {
|
|
@@ -120,60 +112,31 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
120
112
|
* @see above transform function for more details.
|
|
121
113
|
*/
|
|
122
114
|
if (query) {
|
|
123
|
-
var _pluginInjectionApi$
|
|
124
|
-
result = (_pluginInjectionApi$
|
|
115
|
+
var _pluginInjectionApi$q2, _pluginInjectionApi$q3;
|
|
116
|
+
result = (_pluginInjectionApi$q2 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$q3 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q3 === void 0 || (_pluginInjectionApi$q3 = _pluginInjectionApi$q3.actions.getSuggestions({
|
|
125
117
|
query: query,
|
|
126
118
|
category: category
|
|
127
|
-
})) === null || _pluginInjectionApi$
|
|
119
|
+
})) === null || _pluginInjectionApi$q3 === void 0 ? void 0 : _pluginInjectionApi$q3.map(function (item) {
|
|
128
120
|
return (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'offline' && item.isDisabledOffline ? _objectSpread(_objectSpread({}, item), {}, {
|
|
129
121
|
isDisabled: true
|
|
130
122
|
}) : item;
|
|
131
|
-
})) !== null && _pluginInjectionApi$
|
|
123
|
+
})) !== null && _pluginInjectionApi$q2 !== void 0 ? _pluginInjectionApi$q2 : [];
|
|
132
124
|
} else {
|
|
133
|
-
var _pluginInjectionApi$
|
|
134
|
-
var featuredQuickInsertSuggestions = (_pluginInjectionApi$
|
|
125
|
+
var _pluginInjectionApi$q4, _pluginInjectionApi$q5;
|
|
126
|
+
var featuredQuickInsertSuggestions = (_pluginInjectionApi$q4 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$q5 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q5 === void 0 || (_pluginInjectionApi$q5 = _pluginInjectionApi$q5.actions.getSuggestions({
|
|
135
127
|
category: category,
|
|
136
128
|
featuredItems: true
|
|
137
|
-
})) === null || _pluginInjectionApi$
|
|
129
|
+
})) === null || _pluginInjectionApi$q5 === void 0 ? void 0 : _pluginInjectionApi$q5.map(function (item) {
|
|
138
130
|
return (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'offline' && item.isDisabledOffline ? _objectSpread(_objectSpread({}, item), {}, {
|
|
139
131
|
isDisabled: true
|
|
140
132
|
}) : item;
|
|
141
|
-
})) !== null && _pluginInjectionApi$
|
|
133
|
+
})) !== null && _pluginInjectionApi$q4 !== void 0 ? _pluginInjectionApi$q4 : [];
|
|
142
134
|
result = quickInsertDropdownItems.concat(featuredQuickInsertSuggestions);
|
|
143
135
|
}
|
|
144
136
|
setItemCount(result.length);
|
|
145
137
|
return result;
|
|
146
|
-
}, [pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
147
|
-
var emptyStateHandler = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* For insert menu in right rail experiment
|
|
151
|
-
* - Clean up ticket ED-24801
|
|
152
|
-
*
|
|
153
|
-
* The insert menu is not rendered in a popup so need to avoid wrapping it in outer click
|
|
154
|
-
* listeners because it will cause the editor to focus certain extensions (e.g. Jira legacy)
|
|
155
|
-
*/
|
|
156
|
-
|
|
157
|
-
if (isFullPageAppearance && (0, _experiments.editorExperiment)('insert-menu-in-right-rail', true)) {
|
|
158
|
-
return (
|
|
159
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
160
|
-
(0, _react2.jsx)("div", {
|
|
161
|
-
css: insertMenuWrapper(height, isFullPageAppearance)
|
|
162
|
-
}, (0, _react2.jsx)(FlexWrapper, null, (0, _react2.jsx)(_elementBrowser.ElementBrowser, {
|
|
163
|
-
mode: "inline",
|
|
164
|
-
getItems: getItems,
|
|
165
|
-
emptyStateHandler: emptyStateHandler,
|
|
166
|
-
onInsertItem: onInsertItem,
|
|
167
|
-
showSearch: true,
|
|
168
|
-
showCategories: false
|
|
169
|
-
// On page resize we want the InlineElementBrowser to show updated tools/overflow items
|
|
170
|
-
,
|
|
171
|
-
key: quickInsertDropdownItems.length,
|
|
172
|
-
viewMoreItem: viewMoreItem,
|
|
173
|
-
cache: cache
|
|
174
|
-
})))
|
|
175
|
-
);
|
|
176
|
-
}
|
|
138
|
+
}, [pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$q6 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q6 === void 0 ? void 0 : _pluginInjectionApi$q6.actions, quickInsertDropdownItems, connectivityState]);
|
|
139
|
+
var emptyStateHandler = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$q7 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q7 === void 0 || (_pluginInjectionApi$q7 = _pluginInjectionApi$q7.sharedState.currentState()) === null || _pluginInjectionApi$q7 === void 0 ? void 0 : _pluginInjectionApi$q7.emptyStateHandler;
|
|
177
140
|
return (
|
|
178
141
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
179
142
|
(0, _react2.jsx)("div", {
|
|
@@ -214,19 +177,6 @@ var getSvgIconForItem = function getSvgIconForItem(_ref2) {
|
|
|
214
177
|
}) : undefined;
|
|
215
178
|
};
|
|
216
179
|
var insertMenuWrapper = function insertMenuWrapper(height, isFullPageAppearance) {
|
|
217
|
-
if (isFullPageAppearance && (0, _experiments.editorExperiment)('insert-menu-in-right-rail', true)) {
|
|
218
|
-
return (0, _react2.css)({
|
|
219
|
-
display: 'flex',
|
|
220
|
-
flexDirection: 'column',
|
|
221
|
-
width: '314px',
|
|
222
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
223
|
-
height: 'calc(100% - 32px)',
|
|
224
|
-
margin: "0 -12px",
|
|
225
|
-
backgroundColor: "".concat("var(--ds-surface-overlay, ".concat(_colors.N0, ")")),
|
|
226
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
227
|
-
borderRadius: "".concat((0, _theme.borderRadius)(), "px")
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
180
|
return (0, _react2.css)({
|
|
231
181
|
display: 'flex',
|
|
232
182
|
flexDirection: 'column',
|
|
@@ -39,7 +39,7 @@ var BlockInsertElementBrowser = exports.BlockInsertElementBrowser = function Blo
|
|
|
39
39
|
"aria-expanded": props.open,
|
|
40
40
|
"aria-haspopup": true,
|
|
41
41
|
handleRef: props.onRef,
|
|
42
|
-
selected: props.open
|
|
42
|
+
selected: props.open,
|
|
43
43
|
disabled: props.disabled,
|
|
44
44
|
onClick: props.onClick,
|
|
45
45
|
onKeyDown: props.onKeyDown,
|
|
@@ -6,13 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.BlockInsertMenu = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
9
|
var _blockInsertElementBrowser = require("./block-insert-element-browser");
|
|
11
10
|
var _dropdownButton = require("./dropdown-button");
|
|
12
11
|
var BlockInsertMenu = exports.BlockInsertMenu = function BlockInsertMenu(props) {
|
|
13
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(props.pluginInjectionApi, ['insertBlock']),
|
|
14
|
-
insertBlockState = _useSharedPluginState.insertBlockState;
|
|
15
|
-
var isActive = (insertBlockState === null || insertBlockState === void 0 ? void 0 : insertBlockState.menuBrowserOpen) || false;
|
|
16
12
|
if (props.items.length === 0) {
|
|
17
13
|
return null;
|
|
18
14
|
}
|
|
@@ -48,7 +44,6 @@ var BlockInsertMenu = exports.BlockInsertMenu = function BlockInsertMenu(props)
|
|
|
48
44
|
togglePlusMenuVisibility: props.togglePlusMenuVisibility,
|
|
49
45
|
showElementBrowserLink: props.showElementBrowserLink,
|
|
50
46
|
pluginInjectionApi: props.pluginInjectionApi,
|
|
51
|
-
isFullPageAppearance: props.isFullPageAppearance
|
|
52
|
-
isActive: isActive
|
|
47
|
+
isFullPageAppearance: props.isFullPageAppearance
|
|
53
48
|
});
|
|
54
49
|
};
|
|
@@ -27,8 +27,6 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
27
27
|
var _picker = require("@atlaskit/emoji/picker");
|
|
28
28
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
29
29
|
var _colors = require("@atlaskit/theme/colors");
|
|
30
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
31
|
-
var _commands = require("../../pm-plugins/commands");
|
|
32
30
|
var _blockInsertMenu = require("./block-insert-menu");
|
|
33
31
|
var _createItems3 = require("./create-items");
|
|
34
32
|
var _tableSelectorPopupWithListeners = _interopRequireDefault(require("./table-selector-popup-with-listeners"));
|
|
@@ -248,57 +246,10 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
|
|
|
248
246
|
}
|
|
249
247
|
});
|
|
250
248
|
(0, _defineProperty2.default)(_this, "handleClick", function () {
|
|
251
|
-
var _this$props$editorApp;
|
|
252
|
-
/**
|
|
253
|
-
* For insert menu in right rail experiment
|
|
254
|
-
* - Clean up ticket ED-24801
|
|
255
|
-
*/
|
|
256
|
-
if (['full-page', 'full-width'].includes((_this$props$editorApp = _this.props.editorAppearance) !== null && _this$props$editorApp !== void 0 ? _this$props$editorApp : '') && (0, _experiments.editorExperiment)('insert-menu-in-right-rail', true, {
|
|
257
|
-
exposure: true
|
|
258
|
-
})) {
|
|
259
|
-
var pluginInjectionApi = _this.props.pluginInjectionApi;
|
|
260
|
-
if (!pluginInjectionApi) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
pluginInjectionApi.core.actions.execute(function (_ref4) {
|
|
264
|
-
var _pluginInjectionApi$c, _pluginInjectionApi$a;
|
|
265
|
-
var tr = _ref4.tr;
|
|
266
|
-
(0, _commands.toggleInsertMenuRightRail)(tr);
|
|
267
|
-
(_pluginInjectionApi$c = pluginInjectionApi.contextPanel) === null || _pluginInjectionApi$c === void 0 || _pluginInjectionApi$c.actions.applyChange(tr);
|
|
268
|
-
(_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 || _pluginInjectionApi$a.actions.attachAnalyticsEvent({
|
|
269
|
-
action: _analytics.ACTION.CLICKED,
|
|
270
|
-
// @ts-expect-error
|
|
271
|
-
actionSubject: _analytics.ACTION_SUBJECT.TOOLBAR_BUTTON,
|
|
272
|
-
// @ts-expect-error
|
|
273
|
-
actionSubjectId: _analytics.INPUT_METHOD.INSERT_MENU_RIGHT_RAIL,
|
|
274
|
-
eventType: _analytics.EVENT_TYPE.UI
|
|
275
|
-
})(tr);
|
|
276
|
-
return tr;
|
|
277
|
-
});
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
249
|
_this.togglePlusMenuVisibility();
|
|
281
250
|
});
|
|
282
251
|
(0, _defineProperty2.default)(_this, "handleOpenByKeyboard", function (event) {
|
|
283
252
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
284
|
-
var _this$props$editorApp2;
|
|
285
|
-
/**
|
|
286
|
-
* For insert menu in right rail experiment
|
|
287
|
-
* - Clean up ticket ED-24801
|
|
288
|
-
*/
|
|
289
|
-
if (['full-page', 'full-width'].includes((_this$props$editorApp2 = _this.props.editorAppearance) !== null && _this$props$editorApp2 !== void 0 ? _this$props$editorApp2 : '') && (0, _experiments.editorExperiment)('insert-menu-in-right-rail', true, {
|
|
290
|
-
exposure: true
|
|
291
|
-
})) {
|
|
292
|
-
var _this$props$pluginInj;
|
|
293
|
-
(_this$props$pluginInj = _this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 || _this$props$pluginInj.core.actions.execute(function (_ref5) {
|
|
294
|
-
var _this$props$pluginInj2;
|
|
295
|
-
var tr = _ref5.tr;
|
|
296
|
-
(0, _commands.toggleInsertMenuRightRail)(tr);
|
|
297
|
-
(_this$props$pluginInj2 = _this.props.pluginInjectionApi) === null || _this$props$pluginInj2 === void 0 || (_this$props$pluginInj2 = _this$props$pluginInj2.contextPanel) === null || _this$props$pluginInj2 === void 0 || _this$props$pluginInj2.actions.applyChange(tr);
|
|
298
|
-
return tr;
|
|
299
|
-
});
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
253
|
_this.setState(_objectSpread(_objectSpread({}, _this.state), {}, {
|
|
303
254
|
isOpenedByKeyboard: true
|
|
304
255
|
}));
|
|
@@ -314,9 +265,9 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
|
|
|
314
265
|
}
|
|
315
266
|
});
|
|
316
267
|
(0, _defineProperty2.default)(_this, "toggleLinkPanel", function (inputMethod) {
|
|
317
|
-
var _pluginInjectionApi$
|
|
268
|
+
var _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$h;
|
|
318
269
|
var pluginInjectionApi = _this.props.pluginInjectionApi;
|
|
319
|
-
return (_pluginInjectionApi$
|
|
270
|
+
return (_pluginInjectionApi$c = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$h = pluginInjectionApi.hyperlink) === null || _pluginInjectionApi$h === void 0 ? void 0 : _pluginInjectionApi$h.commands.showLinkToolbar(inputMethod))) !== null && _pluginInjectionApi$c !== void 0 ? _pluginInjectionApi$c : false;
|
|
320
271
|
});
|
|
321
272
|
(0, _defineProperty2.default)(_this, "insertMention", function (inputMethod) {
|
|
322
273
|
var _pluginInjectionApi$m3, _pluginInjectionApi$m4;
|
|
@@ -359,15 +310,15 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
|
|
|
359
310
|
|
|
360
311
|
// workaround to solve race condition where cursor is not placed correctly inside table
|
|
361
312
|
queueMicrotask(function () {
|
|
362
|
-
var _pluginInjectionApi$
|
|
363
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
313
|
+
var _pluginInjectionApi$c3, _pluginInjectionApi$t4;
|
|
314
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c3 = pluginInjectionApi.core) === null || _pluginInjectionApi$c3 === void 0 || _pluginInjectionApi$c3.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$t4 = pluginInjectionApi.table) === null || _pluginInjectionApi$t4 === void 0 ? void 0 : _pluginInjectionApi$t4.commands.insertTableWithSize(rowsCount, colsCount, _analytics.INPUT_METHOD.PICKER));
|
|
364
315
|
});
|
|
365
316
|
};
|
|
366
317
|
});
|
|
367
318
|
(0, _defineProperty2.default)(_this, "createDate", function (inputMethod) {
|
|
368
|
-
var _pluginInjectionApi$
|
|
319
|
+
var _pluginInjectionApi$c4, _pluginInjectionApi$d;
|
|
369
320
|
var pluginInjectionApi = _this.props.pluginInjectionApi;
|
|
370
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
321
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c4 = pluginInjectionApi.core) === null || _pluginInjectionApi$c4 === void 0 || _pluginInjectionApi$c4.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d = pluginInjectionApi.date) === null || _pluginInjectionApi$d === void 0 || (_pluginInjectionApi$d = _pluginInjectionApi$d.commands) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.insertDate({
|
|
371
322
|
inputMethod: inputMethod
|
|
372
323
|
}));
|
|
373
324
|
return true;
|
|
@@ -389,9 +340,9 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
|
|
|
389
340
|
return true;
|
|
390
341
|
});
|
|
391
342
|
(0, _defineProperty2.default)(_this, "createStatus", function (inputMethod) {
|
|
392
|
-
var _pluginInjectionApi$
|
|
343
|
+
var _pluginInjectionApi$c5, _pluginInjectionApi$s;
|
|
393
344
|
var pluginInjectionApi = _this.props.pluginInjectionApi;
|
|
394
|
-
return Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
345
|
+
return Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c5 = pluginInjectionApi.core) === null || _pluginInjectionApi$c5 === void 0 ? void 0 : _pluginInjectionApi$c5.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$s = pluginInjectionApi.status) === null || _pluginInjectionApi$s === void 0 || (_pluginInjectionApi$s = _pluginInjectionApi$s.commands) === null || _pluginInjectionApi$s === void 0 ? void 0 : _pluginInjectionApi$s.insertStatus(inputMethod)));
|
|
395
346
|
});
|
|
396
347
|
(0, _defineProperty2.default)(_this, "openMediaPicker", function (inputMethod) {
|
|
397
348
|
var _this$props5 = _this.props,
|
|
@@ -464,21 +415,21 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
|
|
|
464
415
|
};
|
|
465
416
|
});
|
|
466
417
|
(0, _defineProperty2.default)(_this, "handleSelectedEmoji", function (emojiId) {
|
|
467
|
-
var _pluginInjectionApi$
|
|
418
|
+
var _pluginInjectionApi$c6, _pluginInjectionApi$e3;
|
|
468
419
|
var pluginInjectionApi = _this.props.pluginInjectionApi;
|
|
469
420
|
_this.props.editorView.focus();
|
|
470
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
421
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c6 = pluginInjectionApi.core) === null || _pluginInjectionApi$c6 === void 0 || _pluginInjectionApi$c6.actions.execute((_pluginInjectionApi$e3 = pluginInjectionApi.emoji) === null || _pluginInjectionApi$e3 === void 0 ? void 0 : _pluginInjectionApi$e3.commands.insertEmoji(emojiId, _analytics.INPUT_METHOD.PICKER));
|
|
471
422
|
_this.toggleEmojiPicker();
|
|
472
423
|
return true;
|
|
473
424
|
});
|
|
474
425
|
(0, _defineProperty2.default)(_this, "openElementBrowser", function () {
|
|
475
|
-
var _pluginInjectionApi$
|
|
426
|
+
var _pluginInjectionApi$c7, _pluginInjectionApi$q;
|
|
476
427
|
var pluginInjectionApi = _this.props.pluginInjectionApi;
|
|
477
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
428
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c7 = pluginInjectionApi.core) === null || _pluginInjectionApi$c7 === void 0 || _pluginInjectionApi$c7.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$q = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q === void 0 ? void 0 : _pluginInjectionApi$q.commands.openElementBrowserModal);
|
|
478
429
|
});
|
|
479
|
-
(0, _defineProperty2.default)(_this, "onItemActivated", function (
|
|
480
|
-
var item =
|
|
481
|
-
inputMethod =
|
|
430
|
+
(0, _defineProperty2.default)(_this, "onItemActivated", function (_ref4) {
|
|
431
|
+
var item = _ref4.item,
|
|
432
|
+
inputMethod = _ref4.inputMethod;
|
|
482
433
|
var _this$props10 = _this.props,
|
|
483
434
|
editorView = _this$props10.editorView,
|
|
484
435
|
handleImageUpload = _this$props10.handleImageUpload,
|
|
@@ -567,8 +518,8 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
|
|
|
567
518
|
inputMethod: _analytics.INPUT_METHOD.TOOLBAR
|
|
568
519
|
});
|
|
569
520
|
});
|
|
570
|
-
(0, _defineProperty2.default)(_this, "insertInsertMenuItem", function (
|
|
571
|
-
var item =
|
|
521
|
+
(0, _defineProperty2.default)(_this, "insertInsertMenuItem", function (_ref5) {
|
|
522
|
+
var item = _ref5.item;
|
|
572
523
|
return _this.onItemActivated({
|
|
573
524
|
item: item,
|
|
574
525
|
inputMethod: _analytics.INPUT_METHOD.INSERT_MENU
|
|
@@ -620,8 +571,8 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
|
|
|
620
571
|
popupsBoundariesElement = _this$props11.popupsBoundariesElement,
|
|
621
572
|
popupsScrollableElement = _this$props11.popupsScrollableElement,
|
|
622
573
|
emojiProvider = _this$props11.emojiProvider;
|
|
623
|
-
var dropdownEmoji = this.state.dropdownItems.some(function (
|
|
624
|
-
var name =
|
|
574
|
+
var dropdownEmoji = this.state.dropdownItems.some(function (_ref6) {
|
|
575
|
+
var name = _ref6.value.name;
|
|
625
576
|
return name === 'emoji';
|
|
626
577
|
});
|
|
627
578
|
var dropDownButtonRef = this.plusButtonRef;
|
|
@@ -676,8 +627,8 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
|
|
|
676
627
|
// Popup will be unmounted to ensure that the new table has a selection with a blinking cursor.
|
|
677
628
|
// So we can start typing right away.
|
|
678
629
|
var onUnmount = function onUnmount() {
|
|
679
|
-
var _pluginInjectionApi$
|
|
680
|
-
return pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
630
|
+
var _pluginInjectionApi$c8;
|
|
631
|
+
return pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c8 = pluginInjectionApi.core) === null || _pluginInjectionApi$c8 === void 0 || (_pluginInjectionApi$c8 = _pluginInjectionApi$c8.actions) === null || _pluginInjectionApi$c8 === void 0 ? void 0 : _pluginInjectionApi$c8.focus();
|
|
681
632
|
};
|
|
682
633
|
return (0, _react2.jsx)(_tableSelectorPopupWithListeners.default, {
|
|
683
634
|
target: ref,
|
|
@@ -710,7 +661,7 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
|
|
|
710
661
|
_tableSelectorButton6,
|
|
711
662
|
_this$props$isDisable,
|
|
712
663
|
_this$plusButtonRef,
|
|
713
|
-
_this$props$
|
|
664
|
+
_this$props$pluginInj;
|
|
714
665
|
var _this$state2 = this.state,
|
|
715
666
|
buttons = _this$state2.buttons,
|
|
716
667
|
dropdownItems = _this$state2.dropdownItems,
|
|
@@ -720,12 +671,12 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
|
|
|
720
671
|
isDisabled = _this$props13.isDisabled,
|
|
721
672
|
isReducedSpacing = _this$props13.isReducedSpacing,
|
|
722
673
|
editorAppearance = _this$props13.editorAppearance;
|
|
723
|
-
var isTableButtonVisible = buttons.some(function (
|
|
724
|
-
var value =
|
|
674
|
+
var isTableButtonVisible = buttons.some(function (_ref7) {
|
|
675
|
+
var value = _ref7.value;
|
|
725
676
|
return value.name === 'table';
|
|
726
677
|
});
|
|
727
|
-
var isTableSizeVisible = buttons.some(function (
|
|
728
|
-
var value =
|
|
678
|
+
var isTableSizeVisible = buttons.some(function (_ref8) {
|
|
679
|
+
var value = _ref8.value;
|
|
729
680
|
return value.name === 'table selector';
|
|
730
681
|
});
|
|
731
682
|
if (buttons.length === 0 && dropdownItems.length === 0) {
|
|
@@ -830,7 +781,7 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
|
|
|
830
781
|
editorView: this.props.editorView,
|
|
831
782
|
spacing: this.props.isReducedSpacing ? 'none' : 'default',
|
|
832
783
|
label: this.props.intl.formatMessage(_messages.toolbarInsertBlockMessages.insertMenu),
|
|
833
|
-
open:
|
|
784
|
+
open: this.state.isPlusMenuOpen,
|
|
834
785
|
plusButtonRef: (_this$plusButtonRef = this.plusButtonRef) === null || _this$plusButtonRef === void 0 ? void 0 : _this$plusButtonRef.deref(),
|
|
835
786
|
items: this.state.dropdownItems,
|
|
836
787
|
onRef: this.handleDropDownButtonRef,
|
|
@@ -844,7 +795,7 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
|
|
|
844
795
|
showElementBrowserLink: this.props.showElementBrowserLink || false,
|
|
845
796
|
pluginInjectionApi: this.props.pluginInjectionApi,
|
|
846
797
|
isFullPageAppearance: isFullPageAppearance
|
|
847
|
-
})), !((_this$props$
|
|
798
|
+
})), !((_this$props$pluginInj = this.props.pluginInjectionApi) !== null && _this$props$pluginInj !== void 0 && _this$props$pluginInj.primaryToolbar) && this.props.showSeparator && /* eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage */
|
|
848
799
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
849
800
|
(0, _react2.jsx)("span", {
|
|
850
801
|
css: _styles.separatorStyles
|
|
@@ -3,14 +3,10 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
3
3
|
import { ElementBrowser } from '@atlaskit/editor-common/element-browser';
|
|
4
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
6
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
6
|
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
8
7
|
import { BLOCK_QUOTE, CODE_BLOCK, PANEL } from '@atlaskit/editor-plugin-block-type/consts';
|
|
9
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
|
-
import { elementBrowserPmKey, elementBrowserPmPlugin } from './pm-plugins/elementBrowser';
|
|
12
9
|
import { toggleInsertBlockPmKey, toggleInsertBlockPmPlugin } from './pm-plugins/toggleInsertBlock';
|
|
13
|
-
import { InsertMenuRail } from './ui/ElementRail';
|
|
14
10
|
// Ignored via go/ees005
|
|
15
11
|
// eslint-disable-next-line import/no-named-as-default
|
|
16
12
|
import ToolbarInsertBlock from './ui/ToolbarInsertBlock';
|
|
@@ -91,10 +87,7 @@ export const insertBlockPlugin = ({
|
|
|
91
87
|
config: options = {},
|
|
92
88
|
api
|
|
93
89
|
}) => {
|
|
94
|
-
var _api$primaryToolbar
|
|
95
|
-
const editorViewRef = {
|
|
96
|
-
current: null
|
|
97
|
-
};
|
|
90
|
+
var _api$primaryToolbar;
|
|
98
91
|
const primaryToolbarComponent = ({
|
|
99
92
|
editorView,
|
|
100
93
|
editorActions,
|
|
@@ -155,15 +148,8 @@ export const insertBlockPlugin = ({
|
|
|
155
148
|
return;
|
|
156
149
|
}
|
|
157
150
|
const toggleInsertBlockPluginState = toggleInsertBlockPmKey.getState(editorState);
|
|
158
|
-
const elementBrowserPluginState = elementBrowserPmKey.getState(editorState);
|
|
159
151
|
return {
|
|
160
|
-
showElementBrowser: (toggleInsertBlockPluginState === null || toggleInsertBlockPluginState === void 0 ? void 0 : toggleInsertBlockPluginState.showElementBrowser) || false
|
|
161
|
-
/**
|
|
162
|
-
* For insert menu in right rail experiment
|
|
163
|
-
* - Clean up ticket ED-24801
|
|
164
|
-
* Experiment: `insert-menu-in-right-rail`
|
|
165
|
-
*/
|
|
166
|
-
menuBrowserOpen: editorExperiment('insert-menu-in-right-rail', true) ? elementBrowserPluginState === null || elementBrowserPluginState === void 0 ? void 0 : elementBrowserPluginState.menuBrowserOpen : false
|
|
152
|
+
showElementBrowser: (toggleInsertBlockPluginState === null || toggleInsertBlockPluginState === void 0 ? void 0 : toggleInsertBlockPluginState.showElementBrowser) || false
|
|
167
153
|
};
|
|
168
154
|
},
|
|
169
155
|
usePluginHook() {
|
|
@@ -182,23 +168,6 @@ export const insertBlockPlugin = ({
|
|
|
182
168
|
[];
|
|
183
169
|
}
|
|
184
170
|
const plugins = [];
|
|
185
|
-
if (editorExperiment('insert-menu-in-right-rail', true)) {
|
|
186
|
-
plugins.push({
|
|
187
|
-
name: 'elementBrowserPmPlugin',
|
|
188
|
-
plugin: () => elementBrowserPmPlugin()
|
|
189
|
-
}, {
|
|
190
|
-
name: 'elementBrowserEditorViewRef',
|
|
191
|
-
plugin: () => {
|
|
192
|
-
return new SafePlugin({
|
|
193
|
-
view: editorView => {
|
|
194
|
-
// Workaround - need reference to editorView for contextPanel component
|
|
195
|
-
editorViewRef.current = editorView;
|
|
196
|
-
return {};
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
171
|
plugins.push({
|
|
203
172
|
name: 'toggleInsertBlockPmPlugin',
|
|
204
173
|
plugin: () => toggleInsertBlockPmPlugin()
|
|
@@ -208,25 +177,6 @@ export const insertBlockPlugin = ({
|
|
|
208
177
|
pluginsOptions: {},
|
|
209
178
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
210
179
|
};
|
|
211
|
-
if (
|
|
212
|
-
// @ts-ignore
|
|
213
|
-
['full-page', 'full-width'].includes((_options$appearance3 = options.appearance) !== null && _options$appearance3 !== void 0 ? _options$appearance3 : '') && editorExperiment('insert-menu-in-right-rail', true)) {
|
|
214
|
-
// Ignored via go/ees005
|
|
215
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
216
|
-
plugin.pluginsOptions.contextPanel = state => {
|
|
217
|
-
// api.getSharedState() will have an outdated reference to editorState on first mount of this component
|
|
218
|
-
// so instead just rely on plugin key as we don't need to be reactive to changes here
|
|
219
|
-
const pluginState = elementBrowserPmKey.getState(state);
|
|
220
|
-
if (pluginState !== null && pluginState !== void 0 && pluginState.menuBrowserOpen && editorViewRef.current) {
|
|
221
|
-
return /*#__PURE__*/React.createElement(InsertMenuRail, {
|
|
222
|
-
editorView: editorViewRef.current,
|
|
223
|
-
options: options,
|
|
224
|
-
api: api
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
return;
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
180
|
return plugin;
|
|
231
181
|
};
|
|
232
182
|
function ToolbarInsertBlockWithInjectionApi({
|