@atlaskit/editor-plugin-panel 15.0.2 → 15.0.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 +14 -0
- package/dist/cjs/panelPlugin.js +23 -72
- package/dist/cjs/pm-plugins/commands/create-panel-action.js +53 -0
- package/dist/cjs/ui/quick-insert/PanelQuickInsertMenuItem.js +51 -0
- package/dist/cjs/ui/quick-insert/getPanelQuickInsertComponents.js +76 -0
- package/dist/es2019/panelPlugin.js +118 -171
- package/dist/es2019/pm-plugins/commands/create-panel-action.js +48 -0
- package/dist/es2019/ui/quick-insert/PanelQuickInsertMenuItem.js +42 -0
- package/dist/es2019/ui/quick-insert/getPanelQuickInsertComponents.js +66 -0
- package/dist/esm/panelPlugin.js +16 -65
- package/dist/esm/pm-plugins/commands/create-panel-action.js +46 -0
- package/dist/esm/ui/quick-insert/PanelQuickInsertMenuItem.js +43 -0
- package/dist/esm/ui/quick-insert/getPanelQuickInsertComponents.js +69 -0
- package/dist/types/panelPluginType.d.ts +3 -1
- package/dist/types/pm-plugins/commands/create-panel-action.d.ts +13 -0
- package/dist/types/ui/quick-insert/PanelQuickInsertMenuItem.d.ts +12 -0
- package/dist/types/ui/quick-insert/getPanelQuickInsertComponents.d.ts +8 -0
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-panel
|
|
2
2
|
|
|
3
|
+
## 15.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 15.0.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`7087f393ec725`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7087f393ec725) -
|
|
14
|
+
Add the categorized registered Quick Insert browse experience with representative native elements
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 15.0.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/cjs/panelPlugin.js
CHANGED
|
@@ -9,19 +9,18 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
12
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
12
|
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
14
|
-
var _insert = require("@atlaskit/editor-common/insert");
|
|
15
13
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
16
14
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
17
|
-
var
|
|
18
|
-
var _nodeTypeUtils = require("@atlaskit/editor-common/utils/node-type-utils");
|
|
15
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
19
16
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
17
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
21
18
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
19
|
+
var _createPanelAction = require("./pm-plugins/commands/create-panel-action");
|
|
22
20
|
var _keymaps = _interopRequireDefault(require("./pm-plugins/keymaps"));
|
|
23
21
|
var _main = require("./pm-plugins/main");
|
|
24
22
|
var _panelBlockMenuItem = require("./ui/panelBlockMenuItem");
|
|
23
|
+
var _getPanelQuickInsertComponents = require("./ui/quick-insert/getPanelQuickInsertComponents");
|
|
25
24
|
var _toolbar = require("./ui/toolbar");
|
|
26
25
|
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; }
|
|
27
26
|
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; }
|
|
@@ -51,6 +50,15 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
51
50
|
}
|
|
52
51
|
}]);
|
|
53
52
|
}
|
|
53
|
+
var isRegisteredSlashCommandEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command');
|
|
54
|
+
if (isRegisteredSlashCommandEnabled) {
|
|
55
|
+
var _api$uiControlRegistr;
|
|
56
|
+
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register((0, _getPanelQuickInsertComponents.getPanelQuickInsertComponents)({
|
|
57
|
+
allowCustomPanel: allowCustomPanel,
|
|
58
|
+
allowCustomPanelEdit: allowCustomPanelEdit,
|
|
59
|
+
api: api
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
54
62
|
return {
|
|
55
63
|
name: 'panel',
|
|
56
64
|
nodes: function nodes() {
|
|
@@ -97,7 +105,7 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
97
105
|
actions: {
|
|
98
106
|
insertPanel: function insertPanel(inputMethod) {
|
|
99
107
|
return function (state, dispatch) {
|
|
100
|
-
var tr = createPanelAction({
|
|
108
|
+
var tr = (0, _createPanelAction.createPanelAction)({
|
|
101
109
|
state: state,
|
|
102
110
|
attributes: {
|
|
103
111
|
panelType: _adfSchema.PanelType.INFO
|
|
@@ -115,7 +123,7 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
115
123
|
};
|
|
116
124
|
}
|
|
117
125
|
},
|
|
118
|
-
pluginsOptions: {
|
|
126
|
+
pluginsOptions: _objectSpread(_objectSpread({}, isRegisteredSlashCommandEnabled ? {} : {
|
|
119
127
|
quickInsert: function quickInsert(_ref3) {
|
|
120
128
|
var formatMessage = _ref3.formatMessage;
|
|
121
129
|
var quickInsertOptions = [{
|
|
@@ -128,7 +136,7 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
128
136
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconPanel, null);
|
|
129
137
|
},
|
|
130
138
|
action: function action(typeAheadInsert, state) {
|
|
131
|
-
return createPanelAction({
|
|
139
|
+
return (0, _createPanelAction.createPanelAction)({
|
|
132
140
|
state: state,
|
|
133
141
|
attributes: {
|
|
134
142
|
panelType: _adfSchema.PanelType.INFO
|
|
@@ -146,7 +154,7 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
146
154
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconPanelNote, null);
|
|
147
155
|
},
|
|
148
156
|
action: function action(typeAheadInsert, state) {
|
|
149
|
-
return createPanelAction({
|
|
157
|
+
return (0, _createPanelAction.createPanelAction)({
|
|
150
158
|
state: state,
|
|
151
159
|
attributes: {
|
|
152
160
|
panelType: _adfSchema.PanelType.NOTE
|
|
@@ -165,7 +173,7 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
165
173
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconPanelSuccess, null);
|
|
166
174
|
},
|
|
167
175
|
action: function action(typeAheadInsert, state) {
|
|
168
|
-
return createPanelAction({
|
|
176
|
+
return (0, _createPanelAction.createPanelAction)({
|
|
169
177
|
state: state,
|
|
170
178
|
attributes: {
|
|
171
179
|
panelType: _adfSchema.PanelType.SUCCESS
|
|
@@ -183,7 +191,7 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
183
191
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconPanelWarning, null);
|
|
184
192
|
},
|
|
185
193
|
action: function action(typeAheadInsert, state) {
|
|
186
|
-
return createPanelAction({
|
|
194
|
+
return (0, _createPanelAction.createPanelAction)({
|
|
187
195
|
state: state,
|
|
188
196
|
attributes: {
|
|
189
197
|
panelType: _adfSchema.PanelType.WARNING
|
|
@@ -201,7 +209,7 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
201
209
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconPanelError, null);
|
|
202
210
|
},
|
|
203
211
|
action: function action(typeAheadInsert, state) {
|
|
204
|
-
return createPanelAction({
|
|
212
|
+
return (0, _createPanelAction.createPanelAction)({
|
|
205
213
|
state: state,
|
|
206
214
|
attributes: {
|
|
207
215
|
panelType: _adfSchema.PanelType.ERROR
|
|
@@ -221,7 +229,7 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
221
229
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconCustomPanel, null);
|
|
222
230
|
},
|
|
223
231
|
action: function action(typeAheadInsert, state) {
|
|
224
|
-
return createPanelAction({
|
|
232
|
+
return (0, _createPanelAction.createPanelAction)({
|
|
225
233
|
state: state,
|
|
226
234
|
attributes: {
|
|
227
235
|
panelType: _adfSchema.PanelType.CUSTOM,
|
|
@@ -241,72 +249,15 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
241
249
|
});
|
|
242
250
|
}
|
|
243
251
|
return quickInsertOptions;
|
|
244
|
-
}
|
|
252
|
+
}
|
|
253
|
+
}), {}, {
|
|
245
254
|
floatingToolbar: function floatingToolbar(state, intl, providerFactory) {
|
|
246
255
|
return (0, _toolbar.getToolbarConfig)(state, intl, {
|
|
247
256
|
allowCustomPanel: allowCustomPanel,
|
|
248
257
|
allowCustomPanelEdit: allowCustomPanelEdit
|
|
249
258
|
}, providerFactory, api);
|
|
250
259
|
}
|
|
251
|
-
}
|
|
260
|
+
})
|
|
252
261
|
};
|
|
253
262
|
};
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Creates panel action and wrap selection transaction with analytics for the panel insertion.
|
|
257
|
-
*
|
|
258
|
-
* @example
|
|
259
|
-
* const tr = createPanelAction({
|
|
260
|
-
* state: editorState,
|
|
261
|
-
* attributes: { panelType: 'info' },
|
|
262
|
-
* });
|
|
263
|
-
* if (tr) {
|
|
264
|
-
* applyTransaction(tr);
|
|
265
|
-
* }
|
|
266
|
-
*/
|
|
267
|
-
function createPanelAction(_ref4) {
|
|
268
|
-
var state = _ref4.state,
|
|
269
|
-
attributes = _ref4.attributes,
|
|
270
|
-
api = _ref4.api,
|
|
271
|
-
typeAheadInsert = _ref4.typeAheadInsert,
|
|
272
|
-
_ref4$inputMethod = _ref4.inputMethod,
|
|
273
|
-
inputMethod = _ref4$inputMethod === void 0 ? _analytics.INPUT_METHOD.QUICK_INSERT : _ref4$inputMethod;
|
|
274
|
-
var panelNodeType = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.pickPanelTypeForInsertion)(state.selection.$from) : state.schema.nodes.panel;
|
|
275
|
-
var tr;
|
|
276
|
-
// If the selection is empty, we want to insert the panel on a new line
|
|
277
|
-
if (state.selection.empty) {
|
|
278
|
-
var node = panelNodeType.createAndFill(_objectSpread({}, attributes));
|
|
279
|
-
if (!node) {
|
|
280
|
-
return false;
|
|
281
|
-
}
|
|
282
|
-
if (typeAheadInsert !== undefined) {
|
|
283
|
-
// If the type-ahead insert is provided, we should use that to insert the node
|
|
284
|
-
tr = typeAheadInsert(node);
|
|
285
|
-
} else {
|
|
286
|
-
var _insertSelectedItem;
|
|
287
|
-
// Otherwise we can use insertSelectedItem to insert the node
|
|
288
|
-
tr = (_insertSelectedItem = (0, _insert.insertSelectedItem)(node)(state, state.tr, state.selection.head)) === null || _insertSelectedItem === void 0 ? void 0 : _insertSelectedItem.scrollIntoView();
|
|
289
|
-
}
|
|
290
|
-
} else {
|
|
291
|
-
tr = (0, _utils.createWrapSelectionTransaction)({
|
|
292
|
-
state: state,
|
|
293
|
-
type: panelNodeType,
|
|
294
|
-
nodeAttributes: _objectSpread({}, attributes)
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
if (tr) {
|
|
298
|
-
var _api$analytics;
|
|
299
|
-
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
300
|
-
action: _analytics.ACTION.INSERTED,
|
|
301
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
302
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PANEL,
|
|
303
|
-
attributes: {
|
|
304
|
-
inputMethod: inputMethod,
|
|
305
|
-
panelType: attributes.panelType
|
|
306
|
-
},
|
|
307
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
308
|
-
})(tr);
|
|
309
|
-
}
|
|
310
|
-
return tr !== null && tr !== void 0 ? tr : false;
|
|
311
|
-
}
|
|
312
263
|
var _default = exports.default = panelPlugin;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createPanelAction = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
+
var _insert = require("@atlaskit/editor-common/insert");
|
|
11
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
|
+
var _nodeTypeUtils = require("@atlaskit/editor-common/utils/node-type-utils");
|
|
13
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
var createPanelAction = exports.createPanelAction = function createPanelAction(_ref) {
|
|
17
|
+
var state = _ref.state,
|
|
18
|
+
attributes = _ref.attributes,
|
|
19
|
+
api = _ref.api,
|
|
20
|
+
typeAheadInsert = _ref.typeAheadInsert,
|
|
21
|
+
_ref$inputMethod = _ref.inputMethod,
|
|
22
|
+
inputMethod = _ref$inputMethod === void 0 ? _analytics.INPUT_METHOD.QUICK_INSERT : _ref$inputMethod;
|
|
23
|
+
var panelNodeType = (0, _expValEquals.expValEquals)('platform_editor_nest_table_in_panel', 'isEnabled', true) ? (0, _nodeTypeUtils.pickPanelTypeForInsertion)(state.selection.$from) : state.schema.nodes.panel;
|
|
24
|
+
var tr;
|
|
25
|
+
if (state.selection.empty) {
|
|
26
|
+
var _insertSelectedItem;
|
|
27
|
+
var node = panelNodeType.createAndFill(_objectSpread({}, attributes));
|
|
28
|
+
if (!node) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
tr = typeAheadInsert ? typeAheadInsert(node) : (_insertSelectedItem = (0, _insert.insertSelectedItem)(node)(state, state.tr, state.selection.head)) === null || _insertSelectedItem === void 0 ? void 0 : _insertSelectedItem.scrollIntoView();
|
|
32
|
+
} else {
|
|
33
|
+
tr = (0, _utils.createWrapSelectionTransaction)({
|
|
34
|
+
state: state,
|
|
35
|
+
type: panelNodeType,
|
|
36
|
+
nodeAttributes: _objectSpread({}, attributes)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (tr) {
|
|
40
|
+
var _api$analytics;
|
|
41
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
42
|
+
action: _analytics.ACTION.INSERTED,
|
|
43
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
44
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PANEL,
|
|
45
|
+
attributes: {
|
|
46
|
+
inputMethod: inputMethod,
|
|
47
|
+
panelType: attributes.panelType
|
|
48
|
+
},
|
|
49
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
50
|
+
})(tr);
|
|
51
|
+
}
|
|
52
|
+
return tr !== null && tr !== void 0 ? tr : false;
|
|
53
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.PanelQuickInsertMenuItem = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactIntl = require("react-intl");
|
|
10
|
+
var _panel = require("@atlaskit/adf-schema/panel");
|
|
11
|
+
var _menuItem = require("@atlaskit/editor-common/quick-insert/menu-item");
|
|
12
|
+
var _createPanelAction = require("../../pm-plugins/commands/create-panel-action");
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
14
|
+
var getPanelAttributes = function getPanelAttributes(panelType) {
|
|
15
|
+
return panelType === _panel.PanelType.CUSTOM ? {
|
|
16
|
+
panelType: panelType,
|
|
17
|
+
panelIcon: ':rainbow:',
|
|
18
|
+
panelIconId: '1f308',
|
|
19
|
+
panelIconText: '🌈',
|
|
20
|
+
// Custom panel color is stored in ADF, not applied as UI styling.
|
|
21
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
22
|
+
panelColor: '#E6FCFF'
|
|
23
|
+
} : {
|
|
24
|
+
panelType: panelType
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
var PanelQuickInsertMenuItem = exports.PanelQuickInsertMenuItem = function PanelQuickInsertMenuItem(_ref) {
|
|
28
|
+
var api = _ref.api,
|
|
29
|
+
Icon = _ref.icon,
|
|
30
|
+
panelType = _ref.panelType,
|
|
31
|
+
title = _ref.title;
|
|
32
|
+
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
33
|
+
formatMessage = _useIntl.formatMessage;
|
|
34
|
+
var onSelect = (0, _react.useCallback)(function (_ref2) {
|
|
35
|
+
var editorView = _ref2.editorView,
|
|
36
|
+
insert = _ref2.insert,
|
|
37
|
+
source = _ref2.source;
|
|
38
|
+
return (0, _createPanelAction.createPanelAction)({
|
|
39
|
+
api: api,
|
|
40
|
+
attributes: getPanelAttributes(panelType),
|
|
41
|
+
inputMethod: source,
|
|
42
|
+
state: editorView.state,
|
|
43
|
+
typeAheadInsert: insert
|
|
44
|
+
});
|
|
45
|
+
}, [api, panelType]);
|
|
46
|
+
return /*#__PURE__*/_react.default.createElement(_menuItem.QuickInsertMenuItem, {
|
|
47
|
+
iconBefore: /*#__PURE__*/_react.default.createElement(Icon, null),
|
|
48
|
+
onSelect: onSelect,
|
|
49
|
+
title: formatMessage(title)
|
|
50
|
+
});
|
|
51
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getPanelQuickInsertComponents = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _panel = require("@atlaskit/adf-schema/panel");
|
|
11
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
|
+
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
13
|
+
var _keys = require("@atlaskit/editor-common/quick-insert/keys");
|
|
14
|
+
var _rank = require("@atlaskit/editor-common/quick-insert/rank");
|
|
15
|
+
var _PanelQuickInsertMenuItem = require("./PanelQuickInsertMenuItem");
|
|
16
|
+
var standardPanelItems = [{
|
|
17
|
+
icon: _quickInsert.IconPanel,
|
|
18
|
+
menuItem: _keys.INFO_PANEL_MENU_ITEM,
|
|
19
|
+
panelType: _panel.PanelType.INFO,
|
|
20
|
+
title: _messages.blockTypeMessages.infoPanel
|
|
21
|
+
}, {
|
|
22
|
+
icon: _quickInsert.IconPanelNote,
|
|
23
|
+
menuItem: _keys.NOTE_PANEL_MENU_ITEM,
|
|
24
|
+
panelType: _panel.PanelType.NOTE,
|
|
25
|
+
title: _messages.blockTypeMessages.notePanel
|
|
26
|
+
}, {
|
|
27
|
+
icon: _quickInsert.IconPanelSuccess,
|
|
28
|
+
menuItem: _keys.SUCCESS_PANEL_MENU_ITEM,
|
|
29
|
+
panelType: _panel.PanelType.SUCCESS,
|
|
30
|
+
title: _messages.blockTypeMessages.successPanel
|
|
31
|
+
}, {
|
|
32
|
+
icon: _quickInsert.IconPanelWarning,
|
|
33
|
+
menuItem: _keys.WARNING_PANEL_MENU_ITEM,
|
|
34
|
+
panelType: _panel.PanelType.WARNING,
|
|
35
|
+
title: _messages.blockTypeMessages.warningPanel
|
|
36
|
+
}, {
|
|
37
|
+
icon: _quickInsert.IconPanelError,
|
|
38
|
+
menuItem: _keys.ERROR_PANEL_MENU_ITEM,
|
|
39
|
+
panelType: _panel.PanelType.ERROR,
|
|
40
|
+
title: _messages.blockTypeMessages.errorPanel
|
|
41
|
+
}];
|
|
42
|
+
var customPanelItem = {
|
|
43
|
+
icon: _quickInsert.IconCustomPanel,
|
|
44
|
+
menuItem: _keys.CUSTOM_PANEL_MENU_ITEM,
|
|
45
|
+
panelType: _panel.PanelType.CUSTOM,
|
|
46
|
+
title: _messages.blockTypeMessages.customPanel
|
|
47
|
+
};
|
|
48
|
+
var getPanelQuickInsertComponents = exports.getPanelQuickInsertComponents = function getPanelQuickInsertComponents(_ref) {
|
|
49
|
+
var api = _ref.api,
|
|
50
|
+
allowCustomPanel = _ref.allowCustomPanel,
|
|
51
|
+
allowCustomPanelEdit = _ref.allowCustomPanelEdit;
|
|
52
|
+
var allPanelItems = [].concat(standardPanelItems, (0, _toConsumableArray2.default)(allowCustomPanel && allowCustomPanelEdit ? [customPanelItem] : []));
|
|
53
|
+
return allPanelItems.map(function (_ref2) {
|
|
54
|
+
var icon = _ref2.icon,
|
|
55
|
+
menuItem = _ref2.menuItem,
|
|
56
|
+
panelType = _ref2.panelType,
|
|
57
|
+
title = _ref2.title;
|
|
58
|
+
return {
|
|
59
|
+
key: menuItem.key,
|
|
60
|
+
type: menuItem.type,
|
|
61
|
+
parents: [{
|
|
62
|
+
key: _keys.STRUCTURE_SECTION.key,
|
|
63
|
+
type: _keys.STRUCTURE_SECTION.type,
|
|
64
|
+
rank: _rank.STRUCTURE_SECTION_RANK[menuItem.key]
|
|
65
|
+
}],
|
|
66
|
+
component: function component() {
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement(_PanelQuickInsertMenuItem.PanelQuickInsertMenuItem, {
|
|
68
|
+
api: api,
|
|
69
|
+
icon: icon,
|
|
70
|
+
panelType: panelType,
|
|
71
|
+
title: title
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
};
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { extendedPanel, extendedPanelC1, extendedPanelC1WithLocalId, extendedPanelWithLocalId, PanelType } from '@atlaskit/adf-schema';
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
3
|
import { TRANSFORM_STRUCTURE_PANEL_MENU_ITEM, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION_RANK } from '@atlaskit/editor-common/block-menu';
|
|
5
|
-
import { insertSelectedItem } from '@atlaskit/editor-common/insert';
|
|
6
4
|
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
7
5
|
import { IconCustomPanel, IconPanel, IconPanelError, IconPanelNote, IconPanelSuccess, IconPanelWarning } from '@atlaskit/editor-common/quick-insert';
|
|
8
|
-
import {
|
|
9
|
-
import { pickPanelTypeForInsertion } from '@atlaskit/editor-common/utils/node-type-utils';
|
|
6
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
10
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
8
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
|
+
import { createPanelAction } from './pm-plugins/commands/create-panel-action';
|
|
13
11
|
import keymap from './pm-plugins/keymaps';
|
|
14
12
|
import { createPlugin } from './pm-plugins/main';
|
|
15
13
|
import { createPanelBlockMenuItem } from './ui/panelBlockMenuItem';
|
|
14
|
+
import { getPanelQuickInsertComponents } from './ui/quick-insert/getPanelQuickInsertComponents';
|
|
16
15
|
import { getToolbarConfig } from './ui/toolbar';
|
|
17
16
|
const PANEL_NODE_NAME = 'panel';
|
|
18
17
|
const panelPlugin = ({
|
|
@@ -39,6 +38,15 @@ const panelPlugin = ({
|
|
|
39
38
|
}
|
|
40
39
|
}]);
|
|
41
40
|
}
|
|
41
|
+
const isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
|
|
42
|
+
if (isRegisteredSlashCommandEnabled) {
|
|
43
|
+
var _api$uiControlRegistr;
|
|
44
|
+
api === null || api === void 0 ? void 0 : (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 ? void 0 : _api$uiControlRegistr.actions.register(getPanelQuickInsertComponents({
|
|
45
|
+
allowCustomPanel,
|
|
46
|
+
allowCustomPanelEdit,
|
|
47
|
+
api
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
42
50
|
return {
|
|
43
51
|
name: 'panel',
|
|
44
52
|
nodes() {
|
|
@@ -103,121 +111,123 @@ const panelPlugin = ({
|
|
|
103
111
|
}
|
|
104
112
|
},
|
|
105
113
|
pluginsOptions: {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
icon: () => /*#__PURE__*/React.createElement(IconPanelNote, null),
|
|
132
|
-
action(typeAheadInsert, state) {
|
|
133
|
-
return createPanelAction({
|
|
134
|
-
state,
|
|
135
|
-
attributes: {
|
|
136
|
-
panelType: PanelType.NOTE
|
|
137
|
-
},
|
|
138
|
-
api,
|
|
139
|
-
typeAheadInsert
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}, {
|
|
143
|
-
id: 'successpanel',
|
|
144
|
-
title: formatMessage(blockTypeMessages.successPanel),
|
|
145
|
-
description: formatMessage(blockTypeMessages.successPanelDescription),
|
|
146
|
-
keywords: ['tip'],
|
|
147
|
-
priority: 1000,
|
|
148
|
-
icon: () => /*#__PURE__*/React.createElement(IconPanelSuccess, null),
|
|
149
|
-
action(typeAheadInsert, state) {
|
|
150
|
-
return createPanelAction({
|
|
151
|
-
state,
|
|
152
|
-
attributes: {
|
|
153
|
-
panelType: PanelType.SUCCESS
|
|
154
|
-
},
|
|
155
|
-
api,
|
|
156
|
-
typeAheadInsert
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}, {
|
|
160
|
-
id: 'warningpanel',
|
|
161
|
-
title: formatMessage(blockTypeMessages.warningPanel),
|
|
162
|
-
description: formatMessage(blockTypeMessages.warningPanelDescription),
|
|
163
|
-
priority: 1000,
|
|
164
|
-
icon: () => /*#__PURE__*/React.createElement(IconPanelWarning, null),
|
|
165
|
-
action(typeAheadInsert, state) {
|
|
166
|
-
return createPanelAction({
|
|
167
|
-
state,
|
|
168
|
-
attributes: {
|
|
169
|
-
panelType: PanelType.WARNING
|
|
170
|
-
},
|
|
171
|
-
api,
|
|
172
|
-
typeAheadInsert
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}, {
|
|
176
|
-
id: 'errorpanel',
|
|
177
|
-
title: formatMessage(blockTypeMessages.errorPanel),
|
|
178
|
-
description: formatMessage(blockTypeMessages.errorPanelDescription),
|
|
179
|
-
priority: 1000,
|
|
180
|
-
icon: () => /*#__PURE__*/React.createElement(IconPanelError, null),
|
|
181
|
-
action(typeAheadInsert, state) {
|
|
182
|
-
return createPanelAction({
|
|
183
|
-
state,
|
|
184
|
-
attributes: {
|
|
185
|
-
panelType: PanelType.ERROR
|
|
186
|
-
},
|
|
187
|
-
api,
|
|
188
|
-
typeAheadInsert
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}];
|
|
192
|
-
if (allowCustomPanel && allowCustomPanelEdit) {
|
|
193
|
-
quickInsertOptions.push({
|
|
194
|
-
id: 'custompanel',
|
|
195
|
-
title: formatMessage(blockTypeMessages.customPanel),
|
|
196
|
-
description: formatMessage(blockTypeMessages.customPanelDescription),
|
|
114
|
+
...(isRegisteredSlashCommandEnabled ? {} : {
|
|
115
|
+
quickInsert: ({
|
|
116
|
+
formatMessage
|
|
117
|
+
}) => {
|
|
118
|
+
const quickInsertOptions = [{
|
|
119
|
+
id: 'infopanel',
|
|
120
|
+
title: formatMessage(blockTypeMessages.infoPanel),
|
|
121
|
+
keywords: ['panel'],
|
|
122
|
+
description: formatMessage(blockTypeMessages.infoPanelDescription),
|
|
123
|
+
priority: 800,
|
|
124
|
+
icon: () => /*#__PURE__*/React.createElement(IconPanel, null),
|
|
125
|
+
action(typeAheadInsert, state) {
|
|
126
|
+
return createPanelAction({
|
|
127
|
+
state,
|
|
128
|
+
attributes: {
|
|
129
|
+
panelType: PanelType.INFO
|
|
130
|
+
},
|
|
131
|
+
api,
|
|
132
|
+
typeAheadInsert
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}, {
|
|
136
|
+
id: 'notepanel',
|
|
137
|
+
title: formatMessage(blockTypeMessages.notePanel),
|
|
138
|
+
description: formatMessage(blockTypeMessages.notePanelDescription),
|
|
197
139
|
priority: 1000,
|
|
198
|
-
icon: () => /*#__PURE__*/React.createElement(
|
|
140
|
+
icon: () => /*#__PURE__*/React.createElement(IconPanelNote, null),
|
|
199
141
|
action(typeAheadInsert, state) {
|
|
200
142
|
return createPanelAction({
|
|
201
143
|
state,
|
|
202
144
|
attributes: {
|
|
203
|
-
panelType: PanelType.
|
|
204
|
-
panelIcon: ':rainbow:',
|
|
205
|
-
panelIconId: '1f308',
|
|
206
|
-
panelIconText: '🌈',
|
|
207
|
-
// Ignored via go/ees007
|
|
208
|
-
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
209
|
-
// TODO: https://product-fabric.atlassian.net/browse/DSP-7268
|
|
210
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
211
|
-
panelColor: '#E6FCFF'
|
|
145
|
+
panelType: PanelType.NOTE
|
|
212
146
|
},
|
|
213
147
|
api,
|
|
214
148
|
typeAheadInsert
|
|
215
149
|
});
|
|
216
150
|
}
|
|
217
|
-
}
|
|
151
|
+
}, {
|
|
152
|
+
id: 'successpanel',
|
|
153
|
+
title: formatMessage(blockTypeMessages.successPanel),
|
|
154
|
+
description: formatMessage(blockTypeMessages.successPanelDescription),
|
|
155
|
+
keywords: ['tip'],
|
|
156
|
+
priority: 1000,
|
|
157
|
+
icon: () => /*#__PURE__*/React.createElement(IconPanelSuccess, null),
|
|
158
|
+
action(typeAheadInsert, state) {
|
|
159
|
+
return createPanelAction({
|
|
160
|
+
state,
|
|
161
|
+
attributes: {
|
|
162
|
+
panelType: PanelType.SUCCESS
|
|
163
|
+
},
|
|
164
|
+
api,
|
|
165
|
+
typeAheadInsert
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}, {
|
|
169
|
+
id: 'warningpanel',
|
|
170
|
+
title: formatMessage(blockTypeMessages.warningPanel),
|
|
171
|
+
description: formatMessage(blockTypeMessages.warningPanelDescription),
|
|
172
|
+
priority: 1000,
|
|
173
|
+
icon: () => /*#__PURE__*/React.createElement(IconPanelWarning, null),
|
|
174
|
+
action(typeAheadInsert, state) {
|
|
175
|
+
return createPanelAction({
|
|
176
|
+
state,
|
|
177
|
+
attributes: {
|
|
178
|
+
panelType: PanelType.WARNING
|
|
179
|
+
},
|
|
180
|
+
api,
|
|
181
|
+
typeAheadInsert
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}, {
|
|
185
|
+
id: 'errorpanel',
|
|
186
|
+
title: formatMessage(blockTypeMessages.errorPanel),
|
|
187
|
+
description: formatMessage(blockTypeMessages.errorPanelDescription),
|
|
188
|
+
priority: 1000,
|
|
189
|
+
icon: () => /*#__PURE__*/React.createElement(IconPanelError, null),
|
|
190
|
+
action(typeAheadInsert, state) {
|
|
191
|
+
return createPanelAction({
|
|
192
|
+
state,
|
|
193
|
+
attributes: {
|
|
194
|
+
panelType: PanelType.ERROR
|
|
195
|
+
},
|
|
196
|
+
api,
|
|
197
|
+
typeAheadInsert
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}];
|
|
201
|
+
if (allowCustomPanel && allowCustomPanelEdit) {
|
|
202
|
+
quickInsertOptions.push({
|
|
203
|
+
id: 'custompanel',
|
|
204
|
+
title: formatMessage(blockTypeMessages.customPanel),
|
|
205
|
+
description: formatMessage(blockTypeMessages.customPanelDescription),
|
|
206
|
+
priority: 1000,
|
|
207
|
+
icon: () => /*#__PURE__*/React.createElement(IconCustomPanel, null),
|
|
208
|
+
action(typeAheadInsert, state) {
|
|
209
|
+
return createPanelAction({
|
|
210
|
+
state,
|
|
211
|
+
attributes: {
|
|
212
|
+
panelType: PanelType.CUSTOM,
|
|
213
|
+
panelIcon: ':rainbow:',
|
|
214
|
+
panelIconId: '1f308',
|
|
215
|
+
panelIconText: '🌈',
|
|
216
|
+
// Ignored via go/ees007
|
|
217
|
+
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
218
|
+
// TODO: https://product-fabric.atlassian.net/browse/DSP-7268
|
|
219
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
220
|
+
panelColor: '#E6FCFF'
|
|
221
|
+
},
|
|
222
|
+
api,
|
|
223
|
+
typeAheadInsert
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return quickInsertOptions;
|
|
218
229
|
}
|
|
219
|
-
|
|
220
|
-
},
|
|
230
|
+
}),
|
|
221
231
|
floatingToolbar: (state, intl, providerFactory) => getToolbarConfig(state, intl, {
|
|
222
232
|
allowCustomPanel,
|
|
223
233
|
allowCustomPanelEdit
|
|
@@ -225,67 +235,4 @@ const panelPlugin = ({
|
|
|
225
235
|
}
|
|
226
236
|
};
|
|
227
237
|
};
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Creates panel action and wrap selection transaction with analytics for the panel insertion.
|
|
231
|
-
*
|
|
232
|
-
* @example
|
|
233
|
-
* const tr = createPanelAction({
|
|
234
|
-
* state: editorState,
|
|
235
|
-
* attributes: { panelType: 'info' },
|
|
236
|
-
* });
|
|
237
|
-
* if (tr) {
|
|
238
|
-
* applyTransaction(tr);
|
|
239
|
-
* }
|
|
240
|
-
*/
|
|
241
|
-
function createPanelAction({
|
|
242
|
-
state,
|
|
243
|
-
attributes,
|
|
244
|
-
api,
|
|
245
|
-
typeAheadInsert,
|
|
246
|
-
inputMethod = INPUT_METHOD.QUICK_INSERT
|
|
247
|
-
}) {
|
|
248
|
-
var _tr;
|
|
249
|
-
const panelNodeType = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? pickPanelTypeForInsertion(state.selection.$from) : state.schema.nodes.panel;
|
|
250
|
-
let tr;
|
|
251
|
-
// If the selection is empty, we want to insert the panel on a new line
|
|
252
|
-
if (state.selection.empty) {
|
|
253
|
-
const node = panelNodeType.createAndFill({
|
|
254
|
-
...attributes
|
|
255
|
-
});
|
|
256
|
-
if (!node) {
|
|
257
|
-
return false;
|
|
258
|
-
}
|
|
259
|
-
if (typeAheadInsert !== undefined) {
|
|
260
|
-
// If the type-ahead insert is provided, we should use that to insert the node
|
|
261
|
-
tr = typeAheadInsert(node);
|
|
262
|
-
} else {
|
|
263
|
-
var _insertSelectedItem;
|
|
264
|
-
// Otherwise we can use insertSelectedItem to insert the node
|
|
265
|
-
tr = (_insertSelectedItem = insertSelectedItem(node)(state, state.tr, state.selection.head)) === null || _insertSelectedItem === void 0 ? void 0 : _insertSelectedItem.scrollIntoView();
|
|
266
|
-
}
|
|
267
|
-
} else {
|
|
268
|
-
tr = createWrapSelectionTransaction({
|
|
269
|
-
state,
|
|
270
|
-
type: panelNodeType,
|
|
271
|
-
nodeAttributes: {
|
|
272
|
-
...attributes
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
if (tr) {
|
|
277
|
-
var _api$analytics;
|
|
278
|
-
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
|
|
279
|
-
action: ACTION.INSERTED,
|
|
280
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
281
|
-
actionSubjectId: ACTION_SUBJECT_ID.PANEL,
|
|
282
|
-
attributes: {
|
|
283
|
-
inputMethod,
|
|
284
|
-
panelType: attributes.panelType
|
|
285
|
-
},
|
|
286
|
-
eventType: EVENT_TYPE.TRACK
|
|
287
|
-
})(tr);
|
|
288
|
-
}
|
|
289
|
-
return (_tr = tr) !== null && _tr !== void 0 ? _tr : false;
|
|
290
|
-
}
|
|
291
238
|
export default panelPlugin;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { insertSelectedItem } from '@atlaskit/editor-common/insert';
|
|
3
|
+
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
4
|
+
import { pickPanelTypeForInsertion } from '@atlaskit/editor-common/utils/node-type-utils';
|
|
5
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
|
+
export const createPanelAction = ({
|
|
7
|
+
state,
|
|
8
|
+
attributes,
|
|
9
|
+
api,
|
|
10
|
+
typeAheadInsert,
|
|
11
|
+
inputMethod = INPUT_METHOD.QUICK_INSERT
|
|
12
|
+
}) => {
|
|
13
|
+
var _tr;
|
|
14
|
+
const panelNodeType = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? pickPanelTypeForInsertion(state.selection.$from) : state.schema.nodes.panel;
|
|
15
|
+
let tr;
|
|
16
|
+
if (state.selection.empty) {
|
|
17
|
+
var _insertSelectedItem;
|
|
18
|
+
const node = panelNodeType.createAndFill({
|
|
19
|
+
...attributes
|
|
20
|
+
});
|
|
21
|
+
if (!node) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
tr = typeAheadInsert ? typeAheadInsert(node) : (_insertSelectedItem = insertSelectedItem(node)(state, state.tr, state.selection.head)) === null || _insertSelectedItem === void 0 ? void 0 : _insertSelectedItem.scrollIntoView();
|
|
25
|
+
} else {
|
|
26
|
+
tr = createWrapSelectionTransaction({
|
|
27
|
+
state,
|
|
28
|
+
type: panelNodeType,
|
|
29
|
+
nodeAttributes: {
|
|
30
|
+
...attributes
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (tr) {
|
|
35
|
+
var _api$analytics;
|
|
36
|
+
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
|
|
37
|
+
action: ACTION.INSERTED,
|
|
38
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
39
|
+
actionSubjectId: ACTION_SUBJECT_ID.PANEL,
|
|
40
|
+
attributes: {
|
|
41
|
+
inputMethod,
|
|
42
|
+
panelType: attributes.panelType
|
|
43
|
+
},
|
|
44
|
+
eventType: EVENT_TYPE.TRACK
|
|
45
|
+
})(tr);
|
|
46
|
+
}
|
|
47
|
+
return (_tr = tr) !== null && _tr !== void 0 ? _tr : false;
|
|
48
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { PanelType } from '@atlaskit/adf-schema/panel';
|
|
4
|
+
import { QuickInsertMenuItem } from '@atlaskit/editor-common/quick-insert/menu-item';
|
|
5
|
+
import { createPanelAction } from '../../pm-plugins/commands/create-panel-action';
|
|
6
|
+
const getPanelAttributes = panelType => panelType === PanelType.CUSTOM ? {
|
|
7
|
+
panelType,
|
|
8
|
+
panelIcon: ':rainbow:',
|
|
9
|
+
panelIconId: '1f308',
|
|
10
|
+
panelIconText: '🌈',
|
|
11
|
+
// Custom panel color is stored in ADF, not applied as UI styling.
|
|
12
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
13
|
+
panelColor: '#E6FCFF'
|
|
14
|
+
} : {
|
|
15
|
+
panelType
|
|
16
|
+
};
|
|
17
|
+
export const PanelQuickInsertMenuItem = ({
|
|
18
|
+
api,
|
|
19
|
+
icon: Icon,
|
|
20
|
+
panelType,
|
|
21
|
+
title
|
|
22
|
+
}) => {
|
|
23
|
+
const {
|
|
24
|
+
formatMessage
|
|
25
|
+
} = useIntl();
|
|
26
|
+
const onSelect = useCallback(({
|
|
27
|
+
editorView,
|
|
28
|
+
insert,
|
|
29
|
+
source
|
|
30
|
+
}) => createPanelAction({
|
|
31
|
+
api,
|
|
32
|
+
attributes: getPanelAttributes(panelType),
|
|
33
|
+
inputMethod: source,
|
|
34
|
+
state: editorView.state,
|
|
35
|
+
typeAheadInsert: insert
|
|
36
|
+
}), [api, panelType]);
|
|
37
|
+
return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
|
|
38
|
+
iconBefore: /*#__PURE__*/React.createElement(Icon, null),
|
|
39
|
+
onSelect: onSelect,
|
|
40
|
+
title: formatMessage(title)
|
|
41
|
+
});
|
|
42
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PanelType } from '@atlaskit/adf-schema/panel';
|
|
3
|
+
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import { IconCustomPanel, IconPanel, IconPanelError, IconPanelNote, IconPanelSuccess, IconPanelWarning } from '@atlaskit/editor-common/quick-insert';
|
|
5
|
+
import { CUSTOM_PANEL_MENU_ITEM, ERROR_PANEL_MENU_ITEM, INFO_PANEL_MENU_ITEM, NOTE_PANEL_MENU_ITEM, STRUCTURE_SECTION, SUCCESS_PANEL_MENU_ITEM, WARNING_PANEL_MENU_ITEM } from '@atlaskit/editor-common/quick-insert/keys';
|
|
6
|
+
import { STRUCTURE_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/rank';
|
|
7
|
+
import { PanelQuickInsertMenuItem } from './PanelQuickInsertMenuItem';
|
|
8
|
+
const standardPanelItems = [{
|
|
9
|
+
icon: IconPanel,
|
|
10
|
+
menuItem: INFO_PANEL_MENU_ITEM,
|
|
11
|
+
panelType: PanelType.INFO,
|
|
12
|
+
title: blockTypeMessages.infoPanel
|
|
13
|
+
}, {
|
|
14
|
+
icon: IconPanelNote,
|
|
15
|
+
menuItem: NOTE_PANEL_MENU_ITEM,
|
|
16
|
+
panelType: PanelType.NOTE,
|
|
17
|
+
title: blockTypeMessages.notePanel
|
|
18
|
+
}, {
|
|
19
|
+
icon: IconPanelSuccess,
|
|
20
|
+
menuItem: SUCCESS_PANEL_MENU_ITEM,
|
|
21
|
+
panelType: PanelType.SUCCESS,
|
|
22
|
+
title: blockTypeMessages.successPanel
|
|
23
|
+
}, {
|
|
24
|
+
icon: IconPanelWarning,
|
|
25
|
+
menuItem: WARNING_PANEL_MENU_ITEM,
|
|
26
|
+
panelType: PanelType.WARNING,
|
|
27
|
+
title: blockTypeMessages.warningPanel
|
|
28
|
+
}, {
|
|
29
|
+
icon: IconPanelError,
|
|
30
|
+
menuItem: ERROR_PANEL_MENU_ITEM,
|
|
31
|
+
panelType: PanelType.ERROR,
|
|
32
|
+
title: blockTypeMessages.errorPanel
|
|
33
|
+
}];
|
|
34
|
+
const customPanelItem = {
|
|
35
|
+
icon: IconCustomPanel,
|
|
36
|
+
menuItem: CUSTOM_PANEL_MENU_ITEM,
|
|
37
|
+
panelType: PanelType.CUSTOM,
|
|
38
|
+
title: blockTypeMessages.customPanel
|
|
39
|
+
};
|
|
40
|
+
export const getPanelQuickInsertComponents = ({
|
|
41
|
+
api,
|
|
42
|
+
allowCustomPanel,
|
|
43
|
+
allowCustomPanelEdit
|
|
44
|
+
}) => {
|
|
45
|
+
const allPanelItems = [...standardPanelItems, ...(allowCustomPanel && allowCustomPanelEdit ? [customPanelItem] : [])];
|
|
46
|
+
return allPanelItems.map(({
|
|
47
|
+
icon,
|
|
48
|
+
menuItem,
|
|
49
|
+
panelType,
|
|
50
|
+
title
|
|
51
|
+
}) => ({
|
|
52
|
+
key: menuItem.key,
|
|
53
|
+
type: menuItem.type,
|
|
54
|
+
parents: [{
|
|
55
|
+
key: STRUCTURE_SECTION.key,
|
|
56
|
+
type: STRUCTURE_SECTION.type,
|
|
57
|
+
rank: STRUCTURE_SECTION_RANK[menuItem.key]
|
|
58
|
+
}],
|
|
59
|
+
component: () => /*#__PURE__*/React.createElement(PanelQuickInsertMenuItem, {
|
|
60
|
+
api: api,
|
|
61
|
+
icon: icon,
|
|
62
|
+
panelType: panelType,
|
|
63
|
+
title: title
|
|
64
|
+
})
|
|
65
|
+
}));
|
|
66
|
+
};
|
package/dist/esm/panelPlugin.js
CHANGED
|
@@ -4,19 +4,18 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
4
4
|
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) { _defineProperty(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; }
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { extendedPanel, extendedPanelC1, extendedPanelC1WithLocalId, extendedPanelWithLocalId, PanelType } from '@atlaskit/adf-schema';
|
|
7
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
8
7
|
import { TRANSFORM_STRUCTURE_PANEL_MENU_ITEM, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION_RANK } from '@atlaskit/editor-common/block-menu';
|
|
9
|
-
import { insertSelectedItem } from '@atlaskit/editor-common/insert';
|
|
10
8
|
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
11
9
|
import { IconCustomPanel, IconPanel, IconPanelError, IconPanelNote, IconPanelSuccess, IconPanelWarning } from '@atlaskit/editor-common/quick-insert';
|
|
12
|
-
import {
|
|
13
|
-
import { pickPanelTypeForInsertion } from '@atlaskit/editor-common/utils/node-type-utils';
|
|
10
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
14
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
12
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
16
13
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
14
|
+
import { createPanelAction } from './pm-plugins/commands/create-panel-action';
|
|
17
15
|
import keymap from './pm-plugins/keymaps';
|
|
18
16
|
import { createPlugin } from './pm-plugins/main';
|
|
19
17
|
import { createPanelBlockMenuItem } from './ui/panelBlockMenuItem';
|
|
18
|
+
import { getPanelQuickInsertComponents } from './ui/quick-insert/getPanelQuickInsertComponents';
|
|
20
19
|
import { getToolbarConfig } from './ui/toolbar';
|
|
21
20
|
var PANEL_NODE_NAME = 'panel';
|
|
22
21
|
var panelPlugin = function panelPlugin(_ref) {
|
|
@@ -44,6 +43,15 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
44
43
|
}
|
|
45
44
|
}]);
|
|
46
45
|
}
|
|
46
|
+
var isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
|
|
47
|
+
if (isRegisteredSlashCommandEnabled) {
|
|
48
|
+
var _api$uiControlRegistr;
|
|
49
|
+
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register(getPanelQuickInsertComponents({
|
|
50
|
+
allowCustomPanel: allowCustomPanel,
|
|
51
|
+
allowCustomPanelEdit: allowCustomPanelEdit,
|
|
52
|
+
api: api
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
47
55
|
return {
|
|
48
56
|
name: 'panel',
|
|
49
57
|
nodes: function nodes() {
|
|
@@ -108,7 +116,7 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
108
116
|
};
|
|
109
117
|
}
|
|
110
118
|
},
|
|
111
|
-
pluginsOptions: {
|
|
119
|
+
pluginsOptions: _objectSpread(_objectSpread({}, isRegisteredSlashCommandEnabled ? {} : {
|
|
112
120
|
quickInsert: function quickInsert(_ref3) {
|
|
113
121
|
var formatMessage = _ref3.formatMessage;
|
|
114
122
|
var quickInsertOptions = [{
|
|
@@ -234,72 +242,15 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
234
242
|
});
|
|
235
243
|
}
|
|
236
244
|
return quickInsertOptions;
|
|
237
|
-
}
|
|
245
|
+
}
|
|
246
|
+
}), {}, {
|
|
238
247
|
floatingToolbar: function floatingToolbar(state, intl, providerFactory) {
|
|
239
248
|
return getToolbarConfig(state, intl, {
|
|
240
249
|
allowCustomPanel: allowCustomPanel,
|
|
241
250
|
allowCustomPanelEdit: allowCustomPanelEdit
|
|
242
251
|
}, providerFactory, api);
|
|
243
252
|
}
|
|
244
|
-
}
|
|
253
|
+
})
|
|
245
254
|
};
|
|
246
255
|
};
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Creates panel action and wrap selection transaction with analytics for the panel insertion.
|
|
250
|
-
*
|
|
251
|
-
* @example
|
|
252
|
-
* const tr = createPanelAction({
|
|
253
|
-
* state: editorState,
|
|
254
|
-
* attributes: { panelType: 'info' },
|
|
255
|
-
* });
|
|
256
|
-
* if (tr) {
|
|
257
|
-
* applyTransaction(tr);
|
|
258
|
-
* }
|
|
259
|
-
*/
|
|
260
|
-
function createPanelAction(_ref4) {
|
|
261
|
-
var state = _ref4.state,
|
|
262
|
-
attributes = _ref4.attributes,
|
|
263
|
-
api = _ref4.api,
|
|
264
|
-
typeAheadInsert = _ref4.typeAheadInsert,
|
|
265
|
-
_ref4$inputMethod = _ref4.inputMethod,
|
|
266
|
-
inputMethod = _ref4$inputMethod === void 0 ? INPUT_METHOD.QUICK_INSERT : _ref4$inputMethod;
|
|
267
|
-
var panelNodeType = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? pickPanelTypeForInsertion(state.selection.$from) : state.schema.nodes.panel;
|
|
268
|
-
var tr;
|
|
269
|
-
// If the selection is empty, we want to insert the panel on a new line
|
|
270
|
-
if (state.selection.empty) {
|
|
271
|
-
var node = panelNodeType.createAndFill(_objectSpread({}, attributes));
|
|
272
|
-
if (!node) {
|
|
273
|
-
return false;
|
|
274
|
-
}
|
|
275
|
-
if (typeAheadInsert !== undefined) {
|
|
276
|
-
// If the type-ahead insert is provided, we should use that to insert the node
|
|
277
|
-
tr = typeAheadInsert(node);
|
|
278
|
-
} else {
|
|
279
|
-
var _insertSelectedItem;
|
|
280
|
-
// Otherwise we can use insertSelectedItem to insert the node
|
|
281
|
-
tr = (_insertSelectedItem = insertSelectedItem(node)(state, state.tr, state.selection.head)) === null || _insertSelectedItem === void 0 ? void 0 : _insertSelectedItem.scrollIntoView();
|
|
282
|
-
}
|
|
283
|
-
} else {
|
|
284
|
-
tr = createWrapSelectionTransaction({
|
|
285
|
-
state: state,
|
|
286
|
-
type: panelNodeType,
|
|
287
|
-
nodeAttributes: _objectSpread({}, attributes)
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
if (tr) {
|
|
291
|
-
var _api$analytics;
|
|
292
|
-
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
293
|
-
action: ACTION.INSERTED,
|
|
294
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
295
|
-
actionSubjectId: ACTION_SUBJECT_ID.PANEL,
|
|
296
|
-
attributes: {
|
|
297
|
-
inputMethod: inputMethod,
|
|
298
|
-
panelType: attributes.panelType
|
|
299
|
-
},
|
|
300
|
-
eventType: EVENT_TYPE.TRACK
|
|
301
|
-
})(tr);
|
|
302
|
-
}
|
|
303
|
-
return tr !== null && tr !== void 0 ? tr : false;
|
|
304
|
-
}
|
|
305
256
|
export default panelPlugin;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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) { _defineProperty(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; }
|
|
4
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import { insertSelectedItem } from '@atlaskit/editor-common/insert';
|
|
6
|
+
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
7
|
+
import { pickPanelTypeForInsertion } from '@atlaskit/editor-common/utils/node-type-utils';
|
|
8
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
|
+
export var createPanelAction = function createPanelAction(_ref) {
|
|
10
|
+
var state = _ref.state,
|
|
11
|
+
attributes = _ref.attributes,
|
|
12
|
+
api = _ref.api,
|
|
13
|
+
typeAheadInsert = _ref.typeAheadInsert,
|
|
14
|
+
_ref$inputMethod = _ref.inputMethod,
|
|
15
|
+
inputMethod = _ref$inputMethod === void 0 ? INPUT_METHOD.QUICK_INSERT : _ref$inputMethod;
|
|
16
|
+
var panelNodeType = expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? pickPanelTypeForInsertion(state.selection.$from) : state.schema.nodes.panel;
|
|
17
|
+
var tr;
|
|
18
|
+
if (state.selection.empty) {
|
|
19
|
+
var _insertSelectedItem;
|
|
20
|
+
var node = panelNodeType.createAndFill(_objectSpread({}, attributes));
|
|
21
|
+
if (!node) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
tr = typeAheadInsert ? typeAheadInsert(node) : (_insertSelectedItem = insertSelectedItem(node)(state, state.tr, state.selection.head)) === null || _insertSelectedItem === void 0 ? void 0 : _insertSelectedItem.scrollIntoView();
|
|
25
|
+
} else {
|
|
26
|
+
tr = createWrapSelectionTransaction({
|
|
27
|
+
state: state,
|
|
28
|
+
type: panelNodeType,
|
|
29
|
+
nodeAttributes: _objectSpread({}, attributes)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (tr) {
|
|
33
|
+
var _api$analytics;
|
|
34
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
35
|
+
action: ACTION.INSERTED,
|
|
36
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
37
|
+
actionSubjectId: ACTION_SUBJECT_ID.PANEL,
|
|
38
|
+
attributes: {
|
|
39
|
+
inputMethod: inputMethod,
|
|
40
|
+
panelType: attributes.panelType
|
|
41
|
+
},
|
|
42
|
+
eventType: EVENT_TYPE.TRACK
|
|
43
|
+
})(tr);
|
|
44
|
+
}
|
|
45
|
+
return tr !== null && tr !== void 0 ? tr : false;
|
|
46
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { PanelType } from '@atlaskit/adf-schema/panel';
|
|
4
|
+
import { QuickInsertMenuItem } from '@atlaskit/editor-common/quick-insert/menu-item';
|
|
5
|
+
import { createPanelAction } from '../../pm-plugins/commands/create-panel-action';
|
|
6
|
+
var getPanelAttributes = function getPanelAttributes(panelType) {
|
|
7
|
+
return panelType === PanelType.CUSTOM ? {
|
|
8
|
+
panelType: panelType,
|
|
9
|
+
panelIcon: ':rainbow:',
|
|
10
|
+
panelIconId: '1f308',
|
|
11
|
+
panelIconText: '🌈',
|
|
12
|
+
// Custom panel color is stored in ADF, not applied as UI styling.
|
|
13
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
14
|
+
panelColor: '#E6FCFF'
|
|
15
|
+
} : {
|
|
16
|
+
panelType: panelType
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export var PanelQuickInsertMenuItem = function PanelQuickInsertMenuItem(_ref) {
|
|
20
|
+
var api = _ref.api,
|
|
21
|
+
Icon = _ref.icon,
|
|
22
|
+
panelType = _ref.panelType,
|
|
23
|
+
title = _ref.title;
|
|
24
|
+
var _useIntl = useIntl(),
|
|
25
|
+
formatMessage = _useIntl.formatMessage;
|
|
26
|
+
var onSelect = useCallback(function (_ref2) {
|
|
27
|
+
var editorView = _ref2.editorView,
|
|
28
|
+
insert = _ref2.insert,
|
|
29
|
+
source = _ref2.source;
|
|
30
|
+
return createPanelAction({
|
|
31
|
+
api: api,
|
|
32
|
+
attributes: getPanelAttributes(panelType),
|
|
33
|
+
inputMethod: source,
|
|
34
|
+
state: editorView.state,
|
|
35
|
+
typeAheadInsert: insert
|
|
36
|
+
});
|
|
37
|
+
}, [api, panelType]);
|
|
38
|
+
return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
|
|
39
|
+
iconBefore: /*#__PURE__*/React.createElement(Icon, null),
|
|
40
|
+
onSelect: onSelect,
|
|
41
|
+
title: formatMessage(title)
|
|
42
|
+
});
|
|
43
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { PanelType } from '@atlaskit/adf-schema/panel';
|
|
4
|
+
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { IconCustomPanel, IconPanel, IconPanelError, IconPanelNote, IconPanelSuccess, IconPanelWarning } from '@atlaskit/editor-common/quick-insert';
|
|
6
|
+
import { CUSTOM_PANEL_MENU_ITEM, ERROR_PANEL_MENU_ITEM, INFO_PANEL_MENU_ITEM, NOTE_PANEL_MENU_ITEM, STRUCTURE_SECTION, SUCCESS_PANEL_MENU_ITEM, WARNING_PANEL_MENU_ITEM } from '@atlaskit/editor-common/quick-insert/keys';
|
|
7
|
+
import { STRUCTURE_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/rank';
|
|
8
|
+
import { PanelQuickInsertMenuItem } from './PanelQuickInsertMenuItem';
|
|
9
|
+
var standardPanelItems = [{
|
|
10
|
+
icon: IconPanel,
|
|
11
|
+
menuItem: INFO_PANEL_MENU_ITEM,
|
|
12
|
+
panelType: PanelType.INFO,
|
|
13
|
+
title: blockTypeMessages.infoPanel
|
|
14
|
+
}, {
|
|
15
|
+
icon: IconPanelNote,
|
|
16
|
+
menuItem: NOTE_PANEL_MENU_ITEM,
|
|
17
|
+
panelType: PanelType.NOTE,
|
|
18
|
+
title: blockTypeMessages.notePanel
|
|
19
|
+
}, {
|
|
20
|
+
icon: IconPanelSuccess,
|
|
21
|
+
menuItem: SUCCESS_PANEL_MENU_ITEM,
|
|
22
|
+
panelType: PanelType.SUCCESS,
|
|
23
|
+
title: blockTypeMessages.successPanel
|
|
24
|
+
}, {
|
|
25
|
+
icon: IconPanelWarning,
|
|
26
|
+
menuItem: WARNING_PANEL_MENU_ITEM,
|
|
27
|
+
panelType: PanelType.WARNING,
|
|
28
|
+
title: blockTypeMessages.warningPanel
|
|
29
|
+
}, {
|
|
30
|
+
icon: IconPanelError,
|
|
31
|
+
menuItem: ERROR_PANEL_MENU_ITEM,
|
|
32
|
+
panelType: PanelType.ERROR,
|
|
33
|
+
title: blockTypeMessages.errorPanel
|
|
34
|
+
}];
|
|
35
|
+
var customPanelItem = {
|
|
36
|
+
icon: IconCustomPanel,
|
|
37
|
+
menuItem: CUSTOM_PANEL_MENU_ITEM,
|
|
38
|
+
panelType: PanelType.CUSTOM,
|
|
39
|
+
title: blockTypeMessages.customPanel
|
|
40
|
+
};
|
|
41
|
+
export var getPanelQuickInsertComponents = function getPanelQuickInsertComponents(_ref) {
|
|
42
|
+
var api = _ref.api,
|
|
43
|
+
allowCustomPanel = _ref.allowCustomPanel,
|
|
44
|
+
allowCustomPanelEdit = _ref.allowCustomPanelEdit;
|
|
45
|
+
var allPanelItems = [].concat(standardPanelItems, _toConsumableArray(allowCustomPanel && allowCustomPanelEdit ? [customPanelItem] : []));
|
|
46
|
+
return allPanelItems.map(function (_ref2) {
|
|
47
|
+
var icon = _ref2.icon,
|
|
48
|
+
menuItem = _ref2.menuItem,
|
|
49
|
+
panelType = _ref2.panelType,
|
|
50
|
+
title = _ref2.title;
|
|
51
|
+
return {
|
|
52
|
+
key: menuItem.key,
|
|
53
|
+
type: menuItem.type,
|
|
54
|
+
parents: [{
|
|
55
|
+
key: STRUCTURE_SECTION.key,
|
|
56
|
+
type: STRUCTURE_SECTION.type,
|
|
57
|
+
rank: STRUCTURE_SECTION_RANK[menuItem.key]
|
|
58
|
+
}],
|
|
59
|
+
component: function component() {
|
|
60
|
+
return /*#__PURE__*/React.createElement(PanelQuickInsertMenuItem, {
|
|
61
|
+
api: api,
|
|
62
|
+
icon: icon,
|
|
63
|
+
panelType: panelType,
|
|
64
|
+
title: title
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
};
|
|
@@ -6,6 +6,7 @@ import type { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
|
6
6
|
import type { EmojiPlugin } from '@atlaskit/editor-plugin-emoji';
|
|
7
7
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
8
8
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
9
|
+
import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry/ui-control-registry-plugin-type';
|
|
9
10
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
10
11
|
export declare const pluginKey: PluginKey;
|
|
11
12
|
export interface PanelPluginOptions extends LongPressSelectionPluginOptions, PanelPluginConfig {
|
|
@@ -35,7 +36,8 @@ export type PanelPluginDependencies = [
|
|
|
35
36
|
OptionalPlugin<ToolbarPlugin>,
|
|
36
37
|
EmojiPlugin,
|
|
37
38
|
OptionalPlugin<BlockMenuPlugin>,
|
|
38
|
-
OptionalPlugin<SelectionPlugin
|
|
39
|
+
OptionalPlugin<SelectionPlugin>,
|
|
40
|
+
OptionalPlugin<UiControlRegistryPlugin>
|
|
39
41
|
];
|
|
40
42
|
export type PanelPlugin = NextEditorPlugin<'panel', {
|
|
41
43
|
actions: {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PanelAttributes } from '@atlaskit/adf-schema/panel';
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { QuickInsertActionInsert } from '@atlaskit/editor-common/provider-factory';
|
|
4
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import type { PanelPlugin } from '../../panelPluginType';
|
|
7
|
+
export declare const createPanelAction: ({ state, attributes, api, typeAheadInsert, inputMethod, }: {
|
|
8
|
+
api: ExtractInjectionAPI<PanelPlugin> | undefined;
|
|
9
|
+
attributes: PanelAttributes;
|
|
10
|
+
inputMethod?: INPUT_METHOD.ELEMENT_BROWSER | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR;
|
|
11
|
+
state: EditorState;
|
|
12
|
+
typeAheadInsert?: QuickInsertActionInsert;
|
|
13
|
+
}) => ReturnType<QuickInsertActionInsert> | false;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { MessageDescriptor } from 'react-intl';
|
|
3
|
+
import { PanelType } from '@atlaskit/adf-schema/panel';
|
|
4
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { PanelPlugin } from '../../panelPluginType';
|
|
6
|
+
export type QuickInsertPanelType = Exclude<PanelType, PanelType.TIP>;
|
|
7
|
+
export declare const PanelQuickInsertMenuItem: ({ api, icon: Icon, panelType, title, }: {
|
|
8
|
+
api: ExtractInjectionAPI<PanelPlugin> | undefined;
|
|
9
|
+
icon: React.ComponentType;
|
|
10
|
+
panelType: QuickInsertPanelType;
|
|
11
|
+
title: MessageDescriptor;
|
|
12
|
+
}) => React.JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { RegisterMenuItem } from '@atlaskit/editor-ui-control-model/types';
|
|
3
|
+
import type { PanelPlugin } from '../../panelPluginType';
|
|
4
|
+
export declare const getPanelQuickInsertComponents: ({ api, allowCustomPanel, allowCustomPanelEdit, }: {
|
|
5
|
+
allowCustomPanel: boolean;
|
|
6
|
+
allowCustomPanelEdit: boolean;
|
|
7
|
+
api: ExtractInjectionAPI<PanelPlugin> | undefined;
|
|
8
|
+
}) => RegisterMenuItem[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-panel",
|
|
3
|
-
"version": "15.0.
|
|
3
|
+
"version": "15.0.4",
|
|
4
4
|
"description": "Panel plugin for @atlaskit/editor-core.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -27,19 +27,22 @@
|
|
|
27
27
|
"@atlaskit/editor-plugin-emoji": "^14.0.0",
|
|
28
28
|
"@atlaskit/editor-plugin-selection": "^13.0.0",
|
|
29
29
|
"@atlaskit/editor-plugin-toolbar": "^10.0.0",
|
|
30
|
+
"@atlaskit/editor-plugin-ui-control-registry": "^7.0.0",
|
|
30
31
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
31
32
|
"@atlaskit/editor-shared-styles": "^4.0.0",
|
|
32
33
|
"@atlaskit/editor-toolbar": "^2.4.0",
|
|
34
|
+
"@atlaskit/editor-ui-control-model": "^2.4.0",
|
|
33
35
|
"@atlaskit/emoji": "^71.15.0",
|
|
34
|
-
"@atlaskit/icon": "^37.
|
|
36
|
+
"@atlaskit/icon": "^37.3.0",
|
|
37
|
+
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
35
38
|
"@atlaskit/platform-feature-flags": "^2.1.0",
|
|
36
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
39
|
+
"@atlaskit/tmp-editor-statsig": "^140.0.0",
|
|
37
40
|
"@atlaskit/tokens": "^16.3.0",
|
|
38
41
|
"@babel/runtime": "^7.0.0",
|
|
39
42
|
"uuid": "^3.1.0"
|
|
40
43
|
},
|
|
41
44
|
"peerDependencies": {
|
|
42
|
-
"@atlaskit/editor-common": "^117.
|
|
45
|
+
"@atlaskit/editor-common": "^117.2.0",
|
|
43
46
|
"react": "^18.2.0 || ^19.2.0",
|
|
44
47
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
45
48
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|