@atlaskit/editor-plugin-panel 5.2.4 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @atlaskit/editor-plugin-panel
2
2
 
3
+ ## 5.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`a0e6cdeb5a90c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a0e6cdeb5a90c) -
8
+ [ux] New experiment to unify the handling of panel insertion to more consistent behaviour.
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 5.2.5
15
+
16
+ ### Patch Changes
17
+
18
+ - [#195353](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/195353)
19
+ [`dc5e7898ce269`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dc5e7898ce269) -
20
+ EDITOR-1104 Replace panel with panelWithLocalId behind platform_editor_adf_with_localid feature
21
+ gate.
22
+ - [#195649](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/195649)
23
+ [`231bb33e06dfe`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/231bb33e06dfe) -
24
+ EDITOR-1131 Bump adf-schema version to 50.2.0
25
+ - Updated dependencies
26
+
3
27
  ## 5.2.4
4
28
 
5
29
  ### Patch Changes
@@ -15,6 +15,7 @@ var _panel = require("@atlaskit/editor-common/panel");
15
15
  var _utils = require("@atlaskit/editor-common/utils");
16
16
  var _state = require("@atlaskit/editor-prosemirror/state");
17
17
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
18
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
19
  var _utils3 = require("../pm-plugins/utils/utils");
19
20
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
21
  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 +52,7 @@ var changePanelType = exports.changePanelType = function changePanelType(editorA
51
52
  var panelOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
52
53
  var allowCustomPanel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
53
54
  return function (state, dispatch) {
55
+ var _panelNode$node$attrs;
54
56
  var nodes = state.schema.nodes,
55
57
  tr = state.tr;
56
58
  var panelNode = (0, _utils3.findPanel)(state);
@@ -60,6 +62,7 @@ var changePanelType = exports.changePanelType = function changePanelType(editorA
60
62
  var newType = panelType;
61
63
  var previousType = panelNode.node.attrs.panelType;
62
64
  var newTr;
65
+ var localId = (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? ((_panelNode$node$attrs = panelNode.node.attrs) === null || _panelNode$node$attrs === void 0 ? void 0 : _panelNode$node$attrs.localId) || _adfSchema.uuid.generate() : undefined;
63
66
  if (allowCustomPanel) {
64
67
  var previousColor = panelNode.node.attrs.panelType === 'custom' ? panelNode.node.attrs.panelColor || 'none' : (0, _panel.getPanelTypeBackgroundNoTokens)(previousType);
65
68
  var previousIcon = panelNode.node.attrs.panelIcon;
@@ -76,11 +79,13 @@ var changePanelType = exports.changePanelType = function changePanelType(editorA
76
79
  panelIconId: newPanelOptions.emojiId,
77
80
  panelIconText: newPanelOptions.emojiText,
78
81
  panelColor: newPanelOptions.color,
79
- panelType: panelType
82
+ panelType: panelType,
83
+ localId: localId
80
84
  });
81
85
  } else {
82
86
  newTr = tr.setNodeMarkup(panelNode.pos, nodes.panel, {
83
- panelType: panelType
87
+ panelType: panelType,
88
+ localId: localId
84
89
  });
85
90
  }
86
91
  var payload = {
@@ -104,6 +109,8 @@ var changePanelType = exports.changePanelType = function changePanelType(editorA
104
109
  };
105
110
  };
106
111
  };
112
+
113
+ // Delete with 'platform_editor_fix_quick_insert_consistency_exp'
107
114
  function insertPanelWithAnalytics(inputMethod, analyticsAPI) {
108
115
  return (0, _editorAnalytics.withAnalytics)(analyticsAPI, {
109
116
  action: _analytics.ACTION.INSERTED,
@@ -117,7 +124,10 @@ function insertPanelWithAnalytics(inputMethod, analyticsAPI) {
117
124
  })(function (state, dispatch) {
118
125
  var nodes = state.schema.nodes;
119
126
  if (nodes.panel && nodes.paragraph) {
120
- return (0, _utils.wrapSelectionIn)(nodes.panel)(state, dispatch);
127
+ var panelAttrs = (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? {
128
+ localId: _adfSchema.uuid.generate()
129
+ } : {};
130
+ return (0, _utils.wrapSelectionIn)(nodes.panel, panelAttrs)(state, dispatch);
121
131
  }
122
132
  return false;
123
133
  });
@@ -5,18 +5,24 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
8
9
  var _react = _interopRequireDefault(require("react"));
9
10
  var _adfSchema = require("@atlaskit/adf-schema");
10
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
+ var _insert = require("@atlaskit/editor-common/insert");
11
13
  var _messages = require("@atlaskit/editor-common/messages");
12
14
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
13
15
  var _utils = require("@atlaskit/editor-common/utils");
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
17
  var _colors = require("@atlaskit/theme/colors");
18
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
15
19
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
16
20
  var _actions = require("./editor-actions/actions");
17
21
  var _keymaps = _interopRequireDefault(require("./pm-plugins/keymaps"));
18
22
  var _main = require("./pm-plugins/main");
19
23
  var _toolbar = require("./ui/toolbar");
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; }
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; }
20
26
  var panelPlugin = function panelPlugin(_ref) {
21
27
  var _ref$config = _ref.config,
22
28
  options = _ref$config === void 0 ? {} : _ref$config,
@@ -24,10 +30,15 @@ var panelPlugin = function panelPlugin(_ref) {
24
30
  return {
25
31
  name: 'panel',
26
32
  nodes: function nodes() {
27
- var panelNode = (0, _adfSchema.extendedPanel)(!!options.allowCustomPanel);
33
+ if ((0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid')) {
34
+ return [{
35
+ name: 'panel',
36
+ node: (0, _adfSchema.extendedPanelWithLocalId)(!!options.allowCustomPanel)
37
+ }];
38
+ }
28
39
  return [{
29
40
  name: 'panel',
30
- node: panelNode
41
+ node: (0, _adfSchema.extendedPanel)(!!options.allowCustomPanel)
31
42
  }];
32
43
  },
33
44
  pmPlugins: function pmPlugins() {
@@ -48,8 +59,28 @@ var panelPlugin = function panelPlugin(_ref) {
48
59
  },
49
60
  actions: {
50
61
  insertPanel: function insertPanel(inputMethod) {
51
- var _api$analytics;
52
- return (0, _actions.insertPanelWithAnalytics)(inputMethod, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
62
+ if ((0, _expValEquals.expValEquals)('platform_editor_fix_quick_insert_consistency_exp', 'isEnabled', true)) {
63
+ return function (state, dispatch) {
64
+ var tr = createPanelAction({
65
+ state: state,
66
+ attributes: {
67
+ panelType: _adfSchema.PanelType.INFO
68
+ },
69
+ api: api,
70
+ inputMethod: inputMethod
71
+ });
72
+ if (!tr) {
73
+ return false;
74
+ }
75
+ if (dispatch) {
76
+ dispatch(tr);
77
+ }
78
+ return true;
79
+ };
80
+ } else {
81
+ var _api$analytics;
82
+ return (0, _actions.insertPanelWithAnalytics)(inputMethod, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
83
+ }
53
84
  }
54
85
  },
55
86
  pluginsOptions: {
@@ -65,14 +96,14 @@ var panelPlugin = function panelPlugin(_ref) {
65
96
  icon: function icon() {
66
97
  return /*#__PURE__*/_react.default.createElement(_quickInsert.IconPanel, null);
67
98
  },
68
- action: function action(insert, state) {
99
+ action: function action(typeAheadInsert, state) {
69
100
  return createPanelAction({
70
101
  state: state,
71
102
  attributes: {
72
103
  panelType: _adfSchema.PanelType.INFO
73
104
  },
74
105
  api: api,
75
- insert: insert
106
+ typeAheadInsert: typeAheadInsert
76
107
  });
77
108
  }
78
109
  }];
@@ -86,14 +117,14 @@ var panelPlugin = function panelPlugin(_ref) {
86
117
  icon: function icon() {
87
118
  return /*#__PURE__*/_react.default.createElement(_quickInsert.IconPanel, null);
88
119
  },
89
- action: function action(insert, state) {
120
+ action: function action(typeAheadInsert, state) {
90
121
  return createPanelAction({
91
122
  state: state,
92
123
  attributes: {
93
124
  panelType: _adfSchema.PanelType.INFO
94
125
  },
95
126
  api: api,
96
- insert: insert
127
+ typeAheadInsert: typeAheadInsert
97
128
  });
98
129
  }
99
130
  }, {
@@ -104,14 +135,14 @@ var panelPlugin = function panelPlugin(_ref) {
104
135
  icon: function icon() {
105
136
  return /*#__PURE__*/_react.default.createElement(_quickInsert.IconPanelNote, null);
106
137
  },
107
- action: function action(insert, state) {
138
+ action: function action(typeAheadInsert, state) {
108
139
  return createPanelAction({
109
140
  state: state,
110
141
  attributes: {
111
142
  panelType: _adfSchema.PanelType.NOTE
112
143
  },
113
144
  api: api,
114
- insert: insert
145
+ typeAheadInsert: typeAheadInsert
115
146
  });
116
147
  }
117
148
  }, {
@@ -123,14 +154,14 @@ var panelPlugin = function panelPlugin(_ref) {
123
154
  icon: function icon() {
124
155
  return /*#__PURE__*/_react.default.createElement(_quickInsert.IconPanelSuccess, null);
125
156
  },
126
- action: function action(insert, state) {
157
+ action: function action(typeAheadInsert, state) {
127
158
  return createPanelAction({
128
159
  state: state,
129
160
  attributes: {
130
161
  panelType: _adfSchema.PanelType.SUCCESS
131
162
  },
132
163
  api: api,
133
- insert: insert
164
+ typeAheadInsert: typeAheadInsert
134
165
  });
135
166
  }
136
167
  }, {
@@ -141,14 +172,14 @@ var panelPlugin = function panelPlugin(_ref) {
141
172
  icon: function icon() {
142
173
  return /*#__PURE__*/_react.default.createElement(_quickInsert.IconPanelWarning, null);
143
174
  },
144
- action: function action(insert, state) {
175
+ action: function action(typeAheadInsert, state) {
145
176
  return createPanelAction({
146
177
  state: state,
147
178
  attributes: {
148
179
  panelType: _adfSchema.PanelType.WARNING
149
180
  },
150
181
  api: api,
151
- insert: insert
182
+ typeAheadInsert: typeAheadInsert
152
183
  });
153
184
  }
154
185
  }, {
@@ -159,14 +190,14 @@ var panelPlugin = function panelPlugin(_ref) {
159
190
  icon: function icon() {
160
191
  return /*#__PURE__*/_react.default.createElement(_quickInsert.IconPanelError, null);
161
192
  },
162
- action: function action(insert, state) {
193
+ action: function action(typeAheadInsert, state) {
163
194
  return createPanelAction({
164
195
  state: state,
165
196
  attributes: {
166
197
  panelType: _adfSchema.PanelType.ERROR
167
198
  },
168
199
  api: api,
169
- insert: insert
200
+ typeAheadInsert: typeAheadInsert
170
201
  });
171
202
  }
172
203
  }];
@@ -179,7 +210,7 @@ var panelPlugin = function panelPlugin(_ref) {
179
210
  icon: function icon() {
180
211
  return /*#__PURE__*/_react.default.createElement(_quickInsert.IconCustomPanel, null);
181
212
  },
182
- action: function action(insert, state) {
213
+ action: function action(typeAheadInsert, state) {
183
214
  return createPanelAction({
184
215
  state: state,
185
216
  attributes: {
@@ -194,7 +225,7 @@ var panelPlugin = function panelPlugin(_ref) {
194
225
  panelColor: _colors.T50
195
226
  },
196
227
  api: api,
197
- insert: insert
228
+ typeAheadInsert: typeAheadInsert
198
229
  });
199
230
  }
200
231
  });
@@ -225,24 +256,60 @@ function createPanelAction(_ref4) {
225
256
  var state = _ref4.state,
226
257
  attributes = _ref4.attributes,
227
258
  api = _ref4.api,
228
- insert = _ref4.insert;
259
+ typeAheadInsert = _ref4.typeAheadInsert,
260
+ _ref4$inputMethod = _ref4.inputMethod,
261
+ inputMethod = _ref4$inputMethod === void 0 ? _analytics.INPUT_METHOD.QUICK_INSERT : _ref4$inputMethod;
229
262
  var panel = state.schema.nodes.panel;
230
263
  var tr;
264
+ var panelAttrs = (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _objectSpread(_objectSpread({}, attributes), {}, {
265
+ localId: attributes.localId || _adfSchema.uuid.generate()
266
+ }) : _objectSpread({}, attributes);
231
267
 
232
- // Panels should wrap content by default when inserted, the quickInsert `insert` method
233
- // will insert the node on a newline
234
- if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
235
- tr = state.selection.empty && (0, _utils.createWrapSelectionTransaction)({
236
- state: state,
237
- type: panel,
238
- nodeAttributes: attributes
239
- });
268
+ /*
269
+ During investigation of go/j/ED-26928 I found that the behaviour of this experience was very
270
+ inconsistent. I reached out to Nicole* for a design review, and she confirmed that the desired
271
+ behaviour is to insert the panel on a new line if the selection is empty.
272
+ *Confluence Editor Lead Product Designer
273
+ */
274
+ if ((0, _expValEquals.expValEquals)('platform_editor_fix_quick_insert_consistency_exp', 'isEnabled', true)) {
275
+ // If the selection is empty, we want to insert the panel on a new line
276
+ if (state.selection.empty) {
277
+ var node = panel.createAndFill(panelAttrs);
278
+ if (!node) {
279
+ return false;
280
+ }
281
+ if (typeAheadInsert !== undefined) {
282
+ // If the type-ahead insert is provided, we should use that to insert the node
283
+ tr = typeAheadInsert(node);
284
+ } else {
285
+ var _insertSelectedItem;
286
+ // Otherwise we can use insertSelectedItem to insert the node
287
+ tr = (_insertSelectedItem = (0, _insert.insertSelectedItem)(node)(state, state.tr, state.selection.head)) === null || _insertSelectedItem === void 0 ? void 0 : _insertSelectedItem.scrollIntoView();
288
+ }
289
+ } else {
290
+ tr = (0, _utils.createWrapSelectionTransaction)({
291
+ state: state,
292
+ type: panel,
293
+ nodeAttributes: panelAttrs
294
+ });
295
+ }
240
296
  } else {
241
- var node = panel.createAndFill(attributes);
242
- if (!node) {
243
- return false;
297
+ // Panels should wrap content by default when inserted, the quickInsert `insert` method
298
+ // will insert the node on a newline
299
+ if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
300
+ tr = state.selection.empty && (0, _utils.createWrapSelectionTransaction)({
301
+ state: state,
302
+ type: panel,
303
+ nodeAttributes: panelAttrs
304
+ });
305
+ } else {
306
+ var _node = panel.createAndFill(panelAttrs);
307
+ if (!_node) {
308
+ return false;
309
+ }
310
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- This is only optional within the experiment, so safe to assume non-null here
311
+ tr = state.selection.empty && typeAheadInsert(_node);
244
312
  }
245
- tr = state.selection.empty && insert(node);
246
313
  }
247
314
  if (tr) {
248
315
  var _api$analytics2;
@@ -251,12 +318,12 @@ function createPanelAction(_ref4) {
251
318
  actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
252
319
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.PANEL,
253
320
  attributes: {
254
- inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT,
321
+ inputMethod: inputMethod,
255
322
  panelType: attributes.panelType
256
323
  },
257
324
  eventType: _analytics.EVENT_TYPE.TRACK
258
325
  })(tr);
259
326
  }
260
- return tr;
327
+ return tr !== null && tr !== void 0 ? tr : false;
261
328
  }
262
329
  var _default = exports.default = panelPlugin;
@@ -69,7 +69,9 @@ var handleCut = exports.handleCut = function handleCut(newState, oldState) {
69
69
  return node.type.name === 'panel';
70
70
  })(oldState.tr.selection);
71
71
  var clonedPanelNode = oldPanelNode === null || oldPanelNode === void 0 ? void 0 : oldPanelNode.node.copy();
72
- var newPanelNode = schema.nodes.panel.create(_objectSpread({}, clonedPanelNode === null || clonedPanelNode === void 0 ? void 0 : clonedPanelNode.attrs), emptyParagraph);
72
+ var newPanelNode = schema.nodes.panel.create(_objectSpread(_objectSpread({}, clonedPanelNode === null || clonedPanelNode === void 0 ? void 0 : clonedPanelNode.attrs), (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') && {
73
+ localId: _adfSchema.uuid.generate()
74
+ }), emptyParagraph);
73
75
  var endPos = oldState.tr.selection.$from.pos;
74
76
  if (oldPanelNode) {
75
77
  newTr.insert(oldPanelNode.pos, newPanelNode).setSelection(new _state.TextSelection(newTr.doc.resolve(endPos)));
@@ -1,10 +1,11 @@
1
- import { PanelType } from '@atlaskit/adf-schema';
1
+ import { PanelType, uuid } from '@atlaskit/adf-schema';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
4
4
  import { getPanelTypeBackgroundNoTokens } from '@atlaskit/editor-common/panel';
5
5
  import { wrapSelectionIn } from '@atlaskit/editor-common/utils';
6
6
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { findParentNodeOfType, findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { findPanel } from '../pm-plugins/utils/utils';
9
10
  export const removePanel = editorAnalyticsAPI => (state, dispatch) => {
10
11
  const {
@@ -37,6 +38,7 @@ export const removePanel = editorAnalyticsAPI => (state, dispatch) => {
37
38
  return true;
38
39
  };
39
40
  export const changePanelType = editorAnalyticsAPI => (panelType, panelOptions = {}, allowCustomPanel = false) => (state, dispatch) => {
41
+ var _panelNode$node$attrs;
40
42
  const {
41
43
  schema: {
42
44
  nodes
@@ -50,6 +52,7 @@ export const changePanelType = editorAnalyticsAPI => (panelType, panelOptions =
50
52
  const newType = panelType;
51
53
  const previousType = panelNode.node.attrs.panelType;
52
54
  let newTr;
55
+ const localId = fg('platform_editor_adf_with_localid') ? ((_panelNode$node$attrs = panelNode.node.attrs) === null || _panelNode$node$attrs === void 0 ? void 0 : _panelNode$node$attrs.localId) || uuid.generate() : undefined;
53
56
  if (allowCustomPanel) {
54
57
  const previousColor = panelNode.node.attrs.panelType === 'custom' ? panelNode.node.attrs.panelColor || 'none' : getPanelTypeBackgroundNoTokens(previousType);
55
58
  const previousIcon = panelNode.node.attrs.panelIcon;
@@ -67,11 +70,13 @@ export const changePanelType = editorAnalyticsAPI => (panelType, panelOptions =
67
70
  panelIconId: newPanelOptions.emojiId,
68
71
  panelIconText: newPanelOptions.emojiText,
69
72
  panelColor: newPanelOptions.color,
70
- panelType
73
+ panelType,
74
+ localId
71
75
  });
72
76
  } else {
73
77
  newTr = tr.setNodeMarkup(panelNode.pos, nodes.panel, {
74
- panelType
78
+ panelType,
79
+ localId
75
80
  });
76
81
  }
77
82
  const payload = {
@@ -93,6 +98,8 @@ export const changePanelType = editorAnalyticsAPI => (panelType, panelOptions =
93
98
  }
94
99
  return true;
95
100
  };
101
+
102
+ // Delete with 'platform_editor_fix_quick_insert_consistency_exp'
96
103
  export function insertPanelWithAnalytics(inputMethod, analyticsAPI) {
97
104
  return withAnalytics(analyticsAPI, {
98
105
  action: ACTION.INSERTED,
@@ -108,7 +115,10 @@ export function insertPanelWithAnalytics(inputMethod, analyticsAPI) {
108
115
  nodes
109
116
  } = state.schema;
110
117
  if (nodes.panel && nodes.paragraph) {
111
- return wrapSelectionIn(nodes.panel)(state, dispatch);
118
+ const panelAttrs = fg('platform_editor_adf_with_localid') ? {
119
+ localId: uuid.generate()
120
+ } : {};
121
+ return wrapSelectionIn(nodes.panel, panelAttrs)(state, dispatch);
112
122
  }
113
123
  return false;
114
124
  });
@@ -1,10 +1,13 @@
1
1
  import React from 'react';
2
- import { extendedPanel, PanelType } from '@atlaskit/adf-schema';
2
+ import { extendedPanel, extendedPanelWithLocalId, PanelType, uuid } from '@atlaskit/adf-schema';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { insertSelectedItem } from '@atlaskit/editor-common/insert';
4
5
  import { blockTypeMessages } from '@atlaskit/editor-common/messages';
5
6
  import { IconCustomPanel, IconPanel, IconPanelError, IconPanelNote, IconPanelSuccess, IconPanelWarning } from '@atlaskit/editor-common/quick-insert';
6
7
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
7
9
  import { T50 } from '@atlaskit/theme/colors';
10
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
11
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
12
  import { insertPanelWithAnalytics } from './editor-actions/actions';
10
13
  import keymap from './pm-plugins/keymaps';
@@ -16,10 +19,15 @@ const panelPlugin = ({
16
19
  }) => ({
17
20
  name: 'panel',
18
21
  nodes() {
19
- const panelNode = extendedPanel(!!options.allowCustomPanel);
22
+ if (fg('platform_editor_adf_with_localid')) {
23
+ return [{
24
+ name: 'panel',
25
+ node: extendedPanelWithLocalId(!!options.allowCustomPanel)
26
+ }];
27
+ }
20
28
  return [{
21
29
  name: 'panel',
22
- node: panelNode
30
+ node: extendedPanel(!!options.allowCustomPanel)
23
31
  }];
24
32
  },
25
33
  pmPlugins() {
@@ -37,8 +45,28 @@ const panelPlugin = ({
37
45
  },
38
46
  actions: {
39
47
  insertPanel(inputMethod) {
40
- var _api$analytics;
41
- return insertPanelWithAnalytics(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
48
+ if (expValEquals('platform_editor_fix_quick_insert_consistency_exp', 'isEnabled', true)) {
49
+ return function (state, dispatch) {
50
+ const tr = createPanelAction({
51
+ state,
52
+ attributes: {
53
+ panelType: PanelType.INFO
54
+ },
55
+ api,
56
+ inputMethod
57
+ });
58
+ if (!tr) {
59
+ return false;
60
+ }
61
+ if (dispatch) {
62
+ dispatch(tr);
63
+ }
64
+ return true;
65
+ };
66
+ } else {
67
+ var _api$analytics;
68
+ return insertPanelWithAnalytics(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
69
+ }
42
70
  }
43
71
  },
44
72
  pluginsOptions: {
@@ -53,14 +81,14 @@ const panelPlugin = ({
53
81
  description: formatMessage(blockTypeMessages.infoPanelDescription),
54
82
  priority: 800,
55
83
  icon: () => /*#__PURE__*/React.createElement(IconPanel, null),
56
- action(insert, state) {
84
+ action(typeAheadInsert, state) {
57
85
  return createPanelAction({
58
86
  state,
59
87
  attributes: {
60
88
  panelType: PanelType.INFO
61
89
  },
62
90
  api,
63
- insert
91
+ typeAheadInsert
64
92
  });
65
93
  }
66
94
  }];
@@ -72,14 +100,14 @@ const panelPlugin = ({
72
100
  description: formatMessage(blockTypeMessages.infoPanelDescription),
73
101
  priority: 800,
74
102
  icon: () => /*#__PURE__*/React.createElement(IconPanel, null),
75
- action(insert, state) {
103
+ action(typeAheadInsert, state) {
76
104
  return createPanelAction({
77
105
  state,
78
106
  attributes: {
79
107
  panelType: PanelType.INFO
80
108
  },
81
109
  api,
82
- insert
110
+ typeAheadInsert
83
111
  });
84
112
  }
85
113
  }, {
@@ -88,14 +116,14 @@ const panelPlugin = ({
88
116
  description: formatMessage(blockTypeMessages.notePanelDescription),
89
117
  priority: 1000,
90
118
  icon: () => /*#__PURE__*/React.createElement(IconPanelNote, null),
91
- action(insert, state) {
119
+ action(typeAheadInsert, state) {
92
120
  return createPanelAction({
93
121
  state,
94
122
  attributes: {
95
123
  panelType: PanelType.NOTE
96
124
  },
97
125
  api,
98
- insert
126
+ typeAheadInsert
99
127
  });
100
128
  }
101
129
  }, {
@@ -105,14 +133,14 @@ const panelPlugin = ({
105
133
  keywords: ['tip'],
106
134
  priority: 1000,
107
135
  icon: () => /*#__PURE__*/React.createElement(IconPanelSuccess, null),
108
- action(insert, state) {
136
+ action(typeAheadInsert, state) {
109
137
  return createPanelAction({
110
138
  state,
111
139
  attributes: {
112
140
  panelType: PanelType.SUCCESS
113
141
  },
114
142
  api,
115
- insert
143
+ typeAheadInsert
116
144
  });
117
145
  }
118
146
  }, {
@@ -121,14 +149,14 @@ const panelPlugin = ({
121
149
  description: formatMessage(blockTypeMessages.warningPanelDescription),
122
150
  priority: 1000,
123
151
  icon: () => /*#__PURE__*/React.createElement(IconPanelWarning, null),
124
- action(insert, state) {
152
+ action(typeAheadInsert, state) {
125
153
  return createPanelAction({
126
154
  state,
127
155
  attributes: {
128
156
  panelType: PanelType.WARNING
129
157
  },
130
158
  api,
131
- insert
159
+ typeAheadInsert
132
160
  });
133
161
  }
134
162
  }, {
@@ -137,14 +165,14 @@ const panelPlugin = ({
137
165
  description: formatMessage(blockTypeMessages.errorPanelDescription),
138
166
  priority: 1000,
139
167
  icon: () => /*#__PURE__*/React.createElement(IconPanelError, null),
140
- action(insert, state) {
168
+ action(typeAheadInsert, state) {
141
169
  return createPanelAction({
142
170
  state,
143
171
  attributes: {
144
172
  panelType: PanelType.ERROR
145
173
  },
146
174
  api,
147
- insert
175
+ typeAheadInsert
148
176
  });
149
177
  }
150
178
  }];
@@ -155,7 +183,7 @@ const panelPlugin = ({
155
183
  description: formatMessage(blockTypeMessages.customPanelDescription),
156
184
  priority: 1000,
157
185
  icon: () => /*#__PURE__*/React.createElement(IconCustomPanel, null),
158
- action(insert, state) {
186
+ action(typeAheadInsert, state) {
159
187
  return createPanelAction({
160
188
  state,
161
189
  attributes: {
@@ -170,7 +198,7 @@ const panelPlugin = ({
170
198
  panelColor: T50
171
199
  },
172
200
  api,
173
- insert
201
+ typeAheadInsert
174
202
  });
175
203
  }
176
204
  });
@@ -198,27 +226,66 @@ function createPanelAction({
198
226
  state,
199
227
  attributes,
200
228
  api,
201
- insert
229
+ typeAheadInsert,
230
+ inputMethod = INPUT_METHOD.QUICK_INSERT
202
231
  }) {
232
+ var _tr;
203
233
  const {
204
234
  panel
205
235
  } = state.schema.nodes;
206
236
  let tr;
237
+ const panelAttrs = fg('platform_editor_adf_with_localid') ? {
238
+ ...attributes,
239
+ localId: attributes.localId || uuid.generate()
240
+ } : {
241
+ ...attributes
242
+ };
207
243
 
208
- // Panels should wrap content by default when inserted, the quickInsert `insert` method
209
- // will insert the node on a newline
210
- if (editorExperiment('platform_editor_controls', 'variant1')) {
211
- tr = state.selection.empty && createWrapSelectionTransaction({
212
- state,
213
- type: panel,
214
- nodeAttributes: attributes
215
- });
244
+ /*
245
+ During investigation of go/j/ED-26928 I found that the behaviour of this experience was very
246
+ inconsistent. I reached out to Nicole* for a design review, and she confirmed that the desired
247
+ behaviour is to insert the panel on a new line if the selection is empty.
248
+ *Confluence Editor Lead Product Designer
249
+ */
250
+ if (expValEquals('platform_editor_fix_quick_insert_consistency_exp', 'isEnabled', true)) {
251
+ // If the selection is empty, we want to insert the panel on a new line
252
+ if (state.selection.empty) {
253
+ const node = panel.createAndFill(panelAttrs);
254
+ if (!node) {
255
+ return false;
256
+ }
257
+ if (typeAheadInsert !== undefined) {
258
+ // If the type-ahead insert is provided, we should use that to insert the node
259
+ tr = typeAheadInsert(node);
260
+ } else {
261
+ var _insertSelectedItem;
262
+ // Otherwise we can use insertSelectedItem to insert the node
263
+ tr = (_insertSelectedItem = insertSelectedItem(node)(state, state.tr, state.selection.head)) === null || _insertSelectedItem === void 0 ? void 0 : _insertSelectedItem.scrollIntoView();
264
+ }
265
+ } else {
266
+ tr = createWrapSelectionTransaction({
267
+ state,
268
+ type: panel,
269
+ nodeAttributes: panelAttrs
270
+ });
271
+ }
216
272
  } else {
217
- const node = panel.createAndFill(attributes);
218
- if (!node) {
219
- return false;
273
+ // Panels should wrap content by default when inserted, the quickInsert `insert` method
274
+ // will insert the node on a newline
275
+ if (editorExperiment('platform_editor_controls', 'variant1')) {
276
+ tr = state.selection.empty && createWrapSelectionTransaction({
277
+ state,
278
+ type: panel,
279
+ nodeAttributes: panelAttrs
280
+ });
281
+ } else {
282
+ const node = panel.createAndFill(panelAttrs);
283
+ if (!node) {
284
+ return false;
285
+ }
286
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- This is only optional within the experiment, so safe to assume non-null here
287
+ tr = state.selection.empty && typeAheadInsert(node);
220
288
  }
221
- tr = state.selection.empty && insert(node);
222
289
  }
223
290
  if (tr) {
224
291
  var _api$analytics2;
@@ -227,12 +294,12 @@ function createPanelAction({
227
294
  actionSubject: ACTION_SUBJECT.DOCUMENT,
228
295
  actionSubjectId: ACTION_SUBJECT_ID.PANEL,
229
296
  attributes: {
230
- inputMethod: INPUT_METHOD.QUICK_INSERT,
297
+ inputMethod,
231
298
  panelType: attributes.panelType
232
299
  },
233
300
  eventType: EVENT_TYPE.TRACK
234
301
  })(tr);
235
302
  }
236
- return tr;
303
+ return (_tr = tr) !== null && _tr !== void 0 ? _tr : false;
237
304
  }
238
305
  export default panelPlugin;
@@ -1,4 +1,4 @@
1
- import { PanelType } from '@atlaskit/adf-schema';
1
+ import { PanelType, uuid } from '@atlaskit/adf-schema';
2
2
  import { PanelSharedCssClassName } from '@atlaskit/editor-common/panel';
3
3
  import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
4
4
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
@@ -65,7 +65,10 @@ export const handleCut = (newState, oldState) => {
65
65
  const oldPanelNode = findParentNode(node => node.type.name === 'panel')(oldState.tr.selection);
66
66
  const clonedPanelNode = oldPanelNode === null || oldPanelNode === void 0 ? void 0 : oldPanelNode.node.copy();
67
67
  const newPanelNode = schema.nodes.panel.create({
68
- ...(clonedPanelNode === null || clonedPanelNode === void 0 ? void 0 : clonedPanelNode.attrs)
68
+ ...(clonedPanelNode === null || clonedPanelNode === void 0 ? void 0 : clonedPanelNode.attrs),
69
+ ...(fg('platform_editor_adf_with_localid') && {
70
+ localId: uuid.generate()
71
+ })
69
72
  }, emptyParagraph);
70
73
  const endPos = oldState.tr.selection.$from.pos;
71
74
  if (oldPanelNode) {
@@ -1,13 +1,14 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
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
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 { PanelType } from '@atlaskit/adf-schema';
4
+ import { PanelType, uuid } from '@atlaskit/adf-schema';
5
5
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
6
  import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
7
7
  import { getPanelTypeBackgroundNoTokens } from '@atlaskit/editor-common/panel';
8
8
  import { wrapSelectionIn } from '@atlaskit/editor-common/utils';
9
9
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
10
10
  import { findParentNodeOfType, findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { findPanel } from '../pm-plugins/utils/utils';
12
13
  export var removePanel = function removePanel(editorAnalyticsAPI) {
13
14
  return function (state, dispatch) {
@@ -42,6 +43,7 @@ export var changePanelType = function changePanelType(editorAnalyticsAPI) {
42
43
  var panelOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
43
44
  var allowCustomPanel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
44
45
  return function (state, dispatch) {
46
+ var _panelNode$node$attrs;
45
47
  var nodes = state.schema.nodes,
46
48
  tr = state.tr;
47
49
  var panelNode = findPanel(state);
@@ -51,6 +53,7 @@ export var changePanelType = function changePanelType(editorAnalyticsAPI) {
51
53
  var newType = panelType;
52
54
  var previousType = panelNode.node.attrs.panelType;
53
55
  var newTr;
56
+ var localId = fg('platform_editor_adf_with_localid') ? ((_panelNode$node$attrs = panelNode.node.attrs) === null || _panelNode$node$attrs === void 0 ? void 0 : _panelNode$node$attrs.localId) || uuid.generate() : undefined;
54
57
  if (allowCustomPanel) {
55
58
  var previousColor = panelNode.node.attrs.panelType === 'custom' ? panelNode.node.attrs.panelColor || 'none' : getPanelTypeBackgroundNoTokens(previousType);
56
59
  var previousIcon = panelNode.node.attrs.panelIcon;
@@ -67,11 +70,13 @@ export var changePanelType = function changePanelType(editorAnalyticsAPI) {
67
70
  panelIconId: newPanelOptions.emojiId,
68
71
  panelIconText: newPanelOptions.emojiText,
69
72
  panelColor: newPanelOptions.color,
70
- panelType: panelType
73
+ panelType: panelType,
74
+ localId: localId
71
75
  });
72
76
  } else {
73
77
  newTr = tr.setNodeMarkup(panelNode.pos, nodes.panel, {
74
- panelType: panelType
78
+ panelType: panelType,
79
+ localId: localId
75
80
  });
76
81
  }
77
82
  var payload = {
@@ -95,6 +100,8 @@ export var changePanelType = function changePanelType(editorAnalyticsAPI) {
95
100
  };
96
101
  };
97
102
  };
103
+
104
+ // Delete with 'platform_editor_fix_quick_insert_consistency_exp'
98
105
  export function insertPanelWithAnalytics(inputMethod, analyticsAPI) {
99
106
  return withAnalytics(analyticsAPI, {
100
107
  action: ACTION.INSERTED,
@@ -108,7 +115,10 @@ export function insertPanelWithAnalytics(inputMethod, analyticsAPI) {
108
115
  })(function (state, dispatch) {
109
116
  var nodes = state.schema.nodes;
110
117
  if (nodes.panel && nodes.paragraph) {
111
- return wrapSelectionIn(nodes.panel)(state, dispatch);
118
+ var panelAttrs = fg('platform_editor_adf_with_localid') ? {
119
+ localId: uuid.generate()
120
+ } : {};
121
+ return wrapSelectionIn(nodes.panel, panelAttrs)(state, dispatch);
112
122
  }
113
123
  return false;
114
124
  });
@@ -1,10 +1,16 @@
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; }
1
4
  import React from 'react';
2
- import { extendedPanel, PanelType } from '@atlaskit/adf-schema';
5
+ import { extendedPanel, extendedPanelWithLocalId, PanelType, uuid } from '@atlaskit/adf-schema';
3
6
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
7
+ import { insertSelectedItem } from '@atlaskit/editor-common/insert';
4
8
  import { blockTypeMessages } from '@atlaskit/editor-common/messages';
5
9
  import { IconCustomPanel, IconPanel, IconPanelError, IconPanelNote, IconPanelSuccess, IconPanelWarning } from '@atlaskit/editor-common/quick-insert';
6
10
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
7
12
  import { T50 } from '@atlaskit/theme/colors';
13
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
14
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
15
  import { insertPanelWithAnalytics } from './editor-actions/actions';
10
16
  import keymap from './pm-plugins/keymaps';
@@ -17,10 +23,15 @@ var panelPlugin = function panelPlugin(_ref) {
17
23
  return {
18
24
  name: 'panel',
19
25
  nodes: function nodes() {
20
- var panelNode = extendedPanel(!!options.allowCustomPanel);
26
+ if (fg('platform_editor_adf_with_localid')) {
27
+ return [{
28
+ name: 'panel',
29
+ node: extendedPanelWithLocalId(!!options.allowCustomPanel)
30
+ }];
31
+ }
21
32
  return [{
22
33
  name: 'panel',
23
- node: panelNode
34
+ node: extendedPanel(!!options.allowCustomPanel)
24
35
  }];
25
36
  },
26
37
  pmPlugins: function pmPlugins() {
@@ -41,8 +52,28 @@ var panelPlugin = function panelPlugin(_ref) {
41
52
  },
42
53
  actions: {
43
54
  insertPanel: function insertPanel(inputMethod) {
44
- var _api$analytics;
45
- return insertPanelWithAnalytics(inputMethod, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
55
+ if (expValEquals('platform_editor_fix_quick_insert_consistency_exp', 'isEnabled', true)) {
56
+ return function (state, dispatch) {
57
+ var tr = createPanelAction({
58
+ state: state,
59
+ attributes: {
60
+ panelType: PanelType.INFO
61
+ },
62
+ api: api,
63
+ inputMethod: inputMethod
64
+ });
65
+ if (!tr) {
66
+ return false;
67
+ }
68
+ if (dispatch) {
69
+ dispatch(tr);
70
+ }
71
+ return true;
72
+ };
73
+ } else {
74
+ var _api$analytics;
75
+ return insertPanelWithAnalytics(inputMethod, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
76
+ }
46
77
  }
47
78
  },
48
79
  pluginsOptions: {
@@ -58,14 +89,14 @@ var panelPlugin = function panelPlugin(_ref) {
58
89
  icon: function icon() {
59
90
  return /*#__PURE__*/React.createElement(IconPanel, null);
60
91
  },
61
- action: function action(insert, state) {
92
+ action: function action(typeAheadInsert, state) {
62
93
  return createPanelAction({
63
94
  state: state,
64
95
  attributes: {
65
96
  panelType: PanelType.INFO
66
97
  },
67
98
  api: api,
68
- insert: insert
99
+ typeAheadInsert: typeAheadInsert
69
100
  });
70
101
  }
71
102
  }];
@@ -79,14 +110,14 @@ var panelPlugin = function panelPlugin(_ref) {
79
110
  icon: function icon() {
80
111
  return /*#__PURE__*/React.createElement(IconPanel, null);
81
112
  },
82
- action: function action(insert, state) {
113
+ action: function action(typeAheadInsert, state) {
83
114
  return createPanelAction({
84
115
  state: state,
85
116
  attributes: {
86
117
  panelType: PanelType.INFO
87
118
  },
88
119
  api: api,
89
- insert: insert
120
+ typeAheadInsert: typeAheadInsert
90
121
  });
91
122
  }
92
123
  }, {
@@ -97,14 +128,14 @@ var panelPlugin = function panelPlugin(_ref) {
97
128
  icon: function icon() {
98
129
  return /*#__PURE__*/React.createElement(IconPanelNote, null);
99
130
  },
100
- action: function action(insert, state) {
131
+ action: function action(typeAheadInsert, state) {
101
132
  return createPanelAction({
102
133
  state: state,
103
134
  attributes: {
104
135
  panelType: PanelType.NOTE
105
136
  },
106
137
  api: api,
107
- insert: insert
138
+ typeAheadInsert: typeAheadInsert
108
139
  });
109
140
  }
110
141
  }, {
@@ -116,14 +147,14 @@ var panelPlugin = function panelPlugin(_ref) {
116
147
  icon: function icon() {
117
148
  return /*#__PURE__*/React.createElement(IconPanelSuccess, null);
118
149
  },
119
- action: function action(insert, state) {
150
+ action: function action(typeAheadInsert, state) {
120
151
  return createPanelAction({
121
152
  state: state,
122
153
  attributes: {
123
154
  panelType: PanelType.SUCCESS
124
155
  },
125
156
  api: api,
126
- insert: insert
157
+ typeAheadInsert: typeAheadInsert
127
158
  });
128
159
  }
129
160
  }, {
@@ -134,14 +165,14 @@ var panelPlugin = function panelPlugin(_ref) {
134
165
  icon: function icon() {
135
166
  return /*#__PURE__*/React.createElement(IconPanelWarning, null);
136
167
  },
137
- action: function action(insert, state) {
168
+ action: function action(typeAheadInsert, state) {
138
169
  return createPanelAction({
139
170
  state: state,
140
171
  attributes: {
141
172
  panelType: PanelType.WARNING
142
173
  },
143
174
  api: api,
144
- insert: insert
175
+ typeAheadInsert: typeAheadInsert
145
176
  });
146
177
  }
147
178
  }, {
@@ -152,14 +183,14 @@ var panelPlugin = function panelPlugin(_ref) {
152
183
  icon: function icon() {
153
184
  return /*#__PURE__*/React.createElement(IconPanelError, null);
154
185
  },
155
- action: function action(insert, state) {
186
+ action: function action(typeAheadInsert, state) {
156
187
  return createPanelAction({
157
188
  state: state,
158
189
  attributes: {
159
190
  panelType: PanelType.ERROR
160
191
  },
161
192
  api: api,
162
- insert: insert
193
+ typeAheadInsert: typeAheadInsert
163
194
  });
164
195
  }
165
196
  }];
@@ -172,7 +203,7 @@ var panelPlugin = function panelPlugin(_ref) {
172
203
  icon: function icon() {
173
204
  return /*#__PURE__*/React.createElement(IconCustomPanel, null);
174
205
  },
175
- action: function action(insert, state) {
206
+ action: function action(typeAheadInsert, state) {
176
207
  return createPanelAction({
177
208
  state: state,
178
209
  attributes: {
@@ -187,7 +218,7 @@ var panelPlugin = function panelPlugin(_ref) {
187
218
  panelColor: T50
188
219
  },
189
220
  api: api,
190
- insert: insert
221
+ typeAheadInsert: typeAheadInsert
191
222
  });
192
223
  }
193
224
  });
@@ -218,24 +249,60 @@ function createPanelAction(_ref4) {
218
249
  var state = _ref4.state,
219
250
  attributes = _ref4.attributes,
220
251
  api = _ref4.api,
221
- insert = _ref4.insert;
252
+ typeAheadInsert = _ref4.typeAheadInsert,
253
+ _ref4$inputMethod = _ref4.inputMethod,
254
+ inputMethod = _ref4$inputMethod === void 0 ? INPUT_METHOD.QUICK_INSERT : _ref4$inputMethod;
222
255
  var panel = state.schema.nodes.panel;
223
256
  var tr;
257
+ var panelAttrs = fg('platform_editor_adf_with_localid') ? _objectSpread(_objectSpread({}, attributes), {}, {
258
+ localId: attributes.localId || uuid.generate()
259
+ }) : _objectSpread({}, attributes);
224
260
 
225
- // Panels should wrap content by default when inserted, the quickInsert `insert` method
226
- // will insert the node on a newline
227
- if (editorExperiment('platform_editor_controls', 'variant1')) {
228
- tr = state.selection.empty && createWrapSelectionTransaction({
229
- state: state,
230
- type: panel,
231
- nodeAttributes: attributes
232
- });
261
+ /*
262
+ During investigation of go/j/ED-26928 I found that the behaviour of this experience was very
263
+ inconsistent. I reached out to Nicole* for a design review, and she confirmed that the desired
264
+ behaviour is to insert the panel on a new line if the selection is empty.
265
+ *Confluence Editor Lead Product Designer
266
+ */
267
+ if (expValEquals('platform_editor_fix_quick_insert_consistency_exp', 'isEnabled', true)) {
268
+ // If the selection is empty, we want to insert the panel on a new line
269
+ if (state.selection.empty) {
270
+ var node = panel.createAndFill(panelAttrs);
271
+ if (!node) {
272
+ return false;
273
+ }
274
+ if (typeAheadInsert !== undefined) {
275
+ // If the type-ahead insert is provided, we should use that to insert the node
276
+ tr = typeAheadInsert(node);
277
+ } else {
278
+ var _insertSelectedItem;
279
+ // Otherwise we can use insertSelectedItem to insert the node
280
+ tr = (_insertSelectedItem = insertSelectedItem(node)(state, state.tr, state.selection.head)) === null || _insertSelectedItem === void 0 ? void 0 : _insertSelectedItem.scrollIntoView();
281
+ }
282
+ } else {
283
+ tr = createWrapSelectionTransaction({
284
+ state: state,
285
+ type: panel,
286
+ nodeAttributes: panelAttrs
287
+ });
288
+ }
233
289
  } else {
234
- var node = panel.createAndFill(attributes);
235
- if (!node) {
236
- return false;
290
+ // Panels should wrap content by default when inserted, the quickInsert `insert` method
291
+ // will insert the node on a newline
292
+ if (editorExperiment('platform_editor_controls', 'variant1')) {
293
+ tr = state.selection.empty && createWrapSelectionTransaction({
294
+ state: state,
295
+ type: panel,
296
+ nodeAttributes: panelAttrs
297
+ });
298
+ } else {
299
+ var _node = panel.createAndFill(panelAttrs);
300
+ if (!_node) {
301
+ return false;
302
+ }
303
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- This is only optional within the experiment, so safe to assume non-null here
304
+ tr = state.selection.empty && typeAheadInsert(_node);
237
305
  }
238
- tr = state.selection.empty && insert(node);
239
306
  }
240
307
  if (tr) {
241
308
  var _api$analytics2;
@@ -244,12 +311,12 @@ function createPanelAction(_ref4) {
244
311
  actionSubject: ACTION_SUBJECT.DOCUMENT,
245
312
  actionSubjectId: ACTION_SUBJECT_ID.PANEL,
246
313
  attributes: {
247
- inputMethod: INPUT_METHOD.QUICK_INSERT,
314
+ inputMethod: inputMethod,
248
315
  panelType: attributes.panelType
249
316
  },
250
317
  eventType: EVENT_TYPE.TRACK
251
318
  })(tr);
252
319
  }
253
- return tr;
320
+ return tr !== null && tr !== void 0 ? tr : false;
254
321
  }
255
322
  export default panelPlugin;
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
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
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 { PanelType } from '@atlaskit/adf-schema';
4
+ import { PanelType, uuid } from '@atlaskit/adf-schema';
5
5
  import { PanelSharedCssClassName } from '@atlaskit/editor-common/panel';
6
6
  import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
7
7
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
@@ -62,7 +62,9 @@ export var handleCut = function handleCut(newState, oldState) {
62
62
  return node.type.name === 'panel';
63
63
  })(oldState.tr.selection);
64
64
  var clonedPanelNode = oldPanelNode === null || oldPanelNode === void 0 ? void 0 : oldPanelNode.node.copy();
65
- var newPanelNode = schema.nodes.panel.create(_objectSpread({}, clonedPanelNode === null || clonedPanelNode === void 0 ? void 0 : clonedPanelNode.attrs), emptyParagraph);
65
+ var newPanelNode = schema.nodes.panel.create(_objectSpread(_objectSpread({}, clonedPanelNode === null || clonedPanelNode === void 0 ? void 0 : clonedPanelNode.attrs), fg('platform_editor_adf_with_localid') && {
66
+ localId: uuid.generate()
67
+ }), emptyParagraph);
66
68
  var endPos = oldState.tr.selection.$from.pos;
67
69
  if (oldPanelNode) {
68
70
  newTr.insert(oldPanelNode.pos, newPanelNode).setSelection(new TextSelection(newTr.doc.resolve(endPos)));
@@ -33,6 +33,6 @@ export type PanelPlugin = NextEditorPlugin<'panel', {
33
33
  pluginConfiguration: PanelPluginOptions | undefined;
34
34
  dependencies: PanelPluginDependencies;
35
35
  actions: {
36
- insertPanel: (inputMethod: INPUT_METHOD) => Command;
36
+ insertPanel: (inputMethod: INPUT_METHOD.INSERT_MENU | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR) => Command;
37
37
  };
38
38
  }>;
@@ -33,6 +33,6 @@ export type PanelPlugin = NextEditorPlugin<'panel', {
33
33
  pluginConfiguration: PanelPluginOptions | undefined;
34
34
  dependencies: PanelPluginDependencies;
35
35
  actions: {
36
- insertPanel: (inputMethod: INPUT_METHOD) => Command;
36
+ insertPanel: (inputMethod: INPUT_METHOD.INSERT_MENU | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR) => Command;
37
37
  };
38
38
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-panel",
3
- "version": "5.2.4",
3
+ "version": "5.3.0",
4
4
  "description": "Panel plugin for @atlaskit/editor-core.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -30,7 +30,7 @@
30
30
  ".": "./src/index.ts"
31
31
  },
32
32
  "dependencies": {
33
- "@atlaskit/adf-schema": "^50.0.1",
33
+ "@atlaskit/adf-schema": "^50.2.0",
34
34
  "@atlaskit/editor-palette": "^2.1.0",
35
35
  "@atlaskit/editor-plugin-analytics": "^3.0.0",
36
36
  "@atlaskit/editor-plugin-decorations": "^3.0.0",
@@ -41,20 +41,17 @@
41
41
  "@atlaskit/icon": "^27.9.0",
42
42
  "@atlaskit/platform-feature-flags": "^1.1.0",
43
43
  "@atlaskit/theme": "^19.0.0",
44
- "@atlaskit/tmp-editor-statsig": "^9.22.0",
44
+ "@atlaskit/tmp-editor-statsig": "^9.25.0",
45
45
  "@atlaskit/tokens": "^6.0.0",
46
46
  "@babel/runtime": "^7.0.0",
47
47
  "uuid": "^3.1.0"
48
48
  },
49
49
  "peerDependencies": {
50
- "@atlaskit/editor-common": "^107.16.0",
50
+ "@atlaskit/editor-common": "^107.18.0",
51
51
  "react": "^18.2.0",
52
52
  "react-dom": "^18.2.0",
53
53
  "react-intl-next": "npm:react-intl@^5.18.1"
54
54
  },
55
- "devDependencies": {
56
- "typescript": "~5.4.2"
57
- },
58
55
  "techstack": {
59
56
  "@atlassian/frontend": {
60
57
  "import-structure": [
@@ -94,6 +91,9 @@
94
91
  "platform-feature-flags": {
95
92
  "platform_editor_nested_dnd_styles_changes": {
96
93
  "type": "boolean"
94
+ },
95
+ "platform_editor_adf_with_localid": {
96
+ "type": "boolean"
97
97
  }
98
98
  },
99
99
  "stricter": {