@atlaskit/editor-plugin-extension 1.0.2 → 1.0.3

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,12 @@
1
1
  # @atlaskit/editor-plugin-extension
2
2
 
3
+ ## 1.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#74716](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/74716) [`e4dcc12c4f8d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e4dcc12c4f8d) - ED-22048 Disable MBE partial selection to fix unwanted extensionFrame deletion.
8
+ - Updated dependencies
9
+
3
10
  ## 1.0.2
4
11
 
5
12
  ### Patch Changes
@@ -180,7 +180,6 @@ function _onChangeAction() {
180
180
  _ref6,
181
181
  positions,
182
182
  node,
183
- newAttributes,
184
183
  newNode,
185
184
  positionUpdated,
186
185
  transaction,
@@ -238,18 +237,15 @@ function _onChangeAction() {
238
237
  return _context3.abrupt("return");
239
238
  case 23:
240
239
  node = nodeWithPos.node;
241
- newAttributes = _objectSpread(_objectSpread({}, node.attrs), {}, {
242
- parameters: _objectSpread(_objectSpread(_objectSpread({}, oldParameters), newParameters), {}, {
243
- macroParams: _objectSpread(_objectSpread({}, oldParameters === null || oldParameters === void 0 ? void 0 : oldParameters.macroParams), newParameters === null || newParameters === void 0 ? void 0 : newParameters.macroParams)
244
- })
245
- });
246
- newNode = (0, _actions.buildExtensionNode)(nodeWithPos.node.toJSON().type, editorView.state.schema, newAttributes, node.content, node.marks);
240
+ newNode = (0, _actions.buildExtensionNode)(nodeWithPos.node.toJSON().type, editorView.state.schema, _objectSpread(_objectSpread({}, node.attrs), {}, {
241
+ parameters: _objectSpread(_objectSpread({}, oldParameters), newParameters)
242
+ }), node.content, node.marks);
247
243
  if (newNode) {
248
- _context3.next = 28;
244
+ _context3.next = 27;
249
245
  break;
250
246
  }
251
247
  return _context3.abrupt("return");
252
- case 28:
248
+ case 27:
253
249
  positionUpdated = positions[key];
254
250
  transaction = editorView.state.tr.replaceWith(positionUpdated, positionUpdated + newNode.nodeSize, newNode); // Ensure we preserve the selection, tr.replaceWith causes it to be lost in some cases
255
251
  // when replacing the node
@@ -262,13 +258,13 @@ function _onChangeAction() {
262
258
  }
263
259
  positionsLess = _objectSpread({}, (0, _main.getPluginState)(editorView.state).positions);
264
260
  delete positionsLess[key];
265
- _context3.next = 36;
261
+ _context3.next = 35;
266
262
  return (0, _commands.updateState)({
267
263
  positions: positionsLess
268
264
  })(editorView.state, editorView.dispatch);
269
- case 36:
265
+ case 35:
270
266
  editorView.dispatch(transaction);
271
- case 37:
267
+ case 36:
272
268
  case "end":
273
269
  return _context3.stop();
274
270
  }
@@ -32,6 +32,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
32
32
  var _selection2 = require("@atlaskit/editor-common/selection");
33
33
  var _state = require("@atlaskit/editor-prosemirror/state");
34
34
  var _utils = require("@atlaskit/editor-prosemirror/utils");
35
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
35
36
  var _commands = require("../commands");
36
37
  var _pluginFactory = require("../plugin-factory");
37
38
  var _pluginKey = require("../plugin-key");
@@ -298,6 +299,32 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, provid
298
299
  inlineExtension: (0, _extensibility.ExtensionNodeView)(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi),
299
300
  multiBodiedExtension: (0, _extensibility.ExtensionNodeView)(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi)
300
301
  },
302
+ createSelectionBetween: function createSelectionBetween(view, anchor, head) {
303
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.multi-bodied-extension_0rygg')) {
304
+ return null;
305
+ }
306
+ var _view$state3 = view.state,
307
+ schema = _view$state3.schema,
308
+ doc = _view$state3.doc;
309
+ var multiBodiedExtension = schema.nodes.multiBodiedExtension;
310
+ var isAnchorInMBE = (0, _utils.findParentNodeOfTypeClosestToPos)(anchor, multiBodiedExtension);
311
+ var isHeadInMBE = (0, _utils.findParentNodeOfTypeClosestToPos)(head, multiBodiedExtension);
312
+ if (isAnchorInMBE !== undefined && isHeadInMBE === undefined) {
313
+ // Anchor is in MBE, where user started selecting within MBE and then moved outside
314
+ var newSelection = _state.TextSelection.create(doc, isAnchorInMBE.pos < head.pos ? isAnchorInMBE.pos : isAnchorInMBE.pos + isAnchorInMBE.node.nodeSize,
315
+ // isAnchorInMBE.pos < head.pos represents downwards selection
316
+ head.pos);
317
+ return newSelection;
318
+ }
319
+ if (isAnchorInMBE === undefined && isHeadInMBE !== undefined) {
320
+ // Head is in MBE, where user started selecting outside MBE and then moved inside
321
+ var _newSelection3 = _state.TextSelection.create(doc, anchor.pos, isHeadInMBE.pos < anchor.pos ? isHeadInMBE.pos : isHeadInMBE.pos + isHeadInMBE.node.nodeSize // isHeadInMBE.pos < anchor.pos represents upwards selection
322
+ );
323
+
324
+ return _newSelection3;
325
+ }
326
+ return null;
327
+ },
301
328
  handleClickOn: (0, _selection2.createSelectionClickHandler)(['extension', 'bodiedExtension', 'multiBodiedExtension'], function (target) {
302
329
  return !target.closest('.extension-content');
303
330
  }, {
@@ -152,18 +152,13 @@ export async function onChangeAction(editorView, updatedParameters = {}, oldPara
152
152
  const {
153
153
  node
154
154
  } = nodeWithPos;
155
- const newAttributes = {
155
+ const newNode = buildExtensionNode(nodeWithPos.node.toJSON().type, editorView.state.schema, {
156
156
  ...node.attrs,
157
157
  parameters: {
158
158
  ...oldParameters,
159
- ...newParameters,
160
- macroParams: {
161
- ...(oldParameters === null || oldParameters === void 0 ? void 0 : oldParameters.macroParams),
162
- ...(newParameters === null || newParameters === void 0 ? void 0 : newParameters.macroParams)
163
- }
159
+ ...newParameters
164
160
  }
165
- };
166
- const newNode = buildExtensionNode(nodeWithPos.node.toJSON().type, editorView.state.schema, newAttributes, node.content, node.marks);
161
+ }, node.content, node.marks);
167
162
  if (!newNode) {
168
163
  return;
169
164
  }
@@ -3,6 +3,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import { createSelectionClickHandler, GapCursorSelection, isSelectionAtEndOfNode, isSelectionAtStartOfNode } from '@atlaskit/editor-common/selection';
4
4
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { findParentNodeOfTypeClosestToPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
7
  import { clearEditingContext, updateState } from '../commands';
7
8
  import { createCommand, createPluginState, getPluginState } from '../plugin-factory';
8
9
  import { pluginKey } from '../plugin-key';
@@ -234,6 +235,35 @@ const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProvid
234
235
  inlineExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi),
235
236
  multiBodiedExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi)
236
237
  },
238
+ createSelectionBetween: function (view, anchor, head) {
239
+ if (!getBooleanFF('platform.editor.multi-bodied-extension_0rygg')) {
240
+ return null;
241
+ }
242
+ const {
243
+ schema,
244
+ doc
245
+ } = view.state;
246
+ const {
247
+ multiBodiedExtension
248
+ } = schema.nodes;
249
+ const isAnchorInMBE = findParentNodeOfTypeClosestToPos(anchor, multiBodiedExtension);
250
+ const isHeadInMBE = findParentNodeOfTypeClosestToPos(head, multiBodiedExtension);
251
+ if (isAnchorInMBE !== undefined && isHeadInMBE === undefined) {
252
+ // Anchor is in MBE, where user started selecting within MBE and then moved outside
253
+ const newSelection = TextSelection.create(doc, isAnchorInMBE.pos < head.pos ? isAnchorInMBE.pos : isAnchorInMBE.pos + isAnchorInMBE.node.nodeSize,
254
+ // isAnchorInMBE.pos < head.pos represents downwards selection
255
+ head.pos);
256
+ return newSelection;
257
+ }
258
+ if (isAnchorInMBE === undefined && isHeadInMBE !== undefined) {
259
+ // Head is in MBE, where user started selecting outside MBE and then moved inside
260
+ const newSelection = TextSelection.create(doc, anchor.pos, isHeadInMBE.pos < anchor.pos ? isHeadInMBE.pos : isHeadInMBE.pos + isHeadInMBE.node.nodeSize // isHeadInMBE.pos < anchor.pos represents upwards selection
261
+ );
262
+
263
+ return newSelection;
264
+ }
265
+ return null;
266
+ },
237
267
  handleClickOn: createSelectionClickHandler(['extension', 'bodiedExtension', 'multiBodiedExtension'], target => !target.closest('.extension-content'), {
238
268
  useLongPressSelection
239
269
  })
@@ -173,7 +173,6 @@ function _onChangeAction() {
173
173
  _ref6,
174
174
  positions,
175
175
  node,
176
- newAttributes,
177
176
  newNode,
178
177
  positionUpdated,
179
178
  transaction,
@@ -231,18 +230,15 @@ function _onChangeAction() {
231
230
  return _context3.abrupt("return");
232
231
  case 23:
233
232
  node = nodeWithPos.node;
234
- newAttributes = _objectSpread(_objectSpread({}, node.attrs), {}, {
235
- parameters: _objectSpread(_objectSpread(_objectSpread({}, oldParameters), newParameters), {}, {
236
- macroParams: _objectSpread(_objectSpread({}, oldParameters === null || oldParameters === void 0 ? void 0 : oldParameters.macroParams), newParameters === null || newParameters === void 0 ? void 0 : newParameters.macroParams)
237
- })
238
- });
239
- newNode = buildExtensionNode(nodeWithPos.node.toJSON().type, editorView.state.schema, newAttributes, node.content, node.marks);
233
+ newNode = buildExtensionNode(nodeWithPos.node.toJSON().type, editorView.state.schema, _objectSpread(_objectSpread({}, node.attrs), {}, {
234
+ parameters: _objectSpread(_objectSpread({}, oldParameters), newParameters)
235
+ }), node.content, node.marks);
240
236
  if (newNode) {
241
- _context3.next = 28;
237
+ _context3.next = 27;
242
238
  break;
243
239
  }
244
240
  return _context3.abrupt("return");
245
- case 28:
241
+ case 27:
246
242
  positionUpdated = positions[key];
247
243
  transaction = editorView.state.tr.replaceWith(positionUpdated, positionUpdated + newNode.nodeSize, newNode); // Ensure we preserve the selection, tr.replaceWith causes it to be lost in some cases
248
244
  // when replacing the node
@@ -255,13 +251,13 @@ function _onChangeAction() {
255
251
  }
256
252
  positionsLess = _objectSpread({}, getPluginState(editorView.state).positions);
257
253
  delete positionsLess[key];
258
- _context3.next = 36;
254
+ _context3.next = 35;
259
255
  return updateState({
260
256
  positions: positionsLess
261
257
  })(editorView.state, editorView.dispatch);
262
- case 36:
258
+ case 35:
263
259
  editorView.dispatch(transaction);
264
- case 37:
260
+ case 36:
265
261
  case "end":
266
262
  return _context3.stop();
267
263
  }
@@ -6,6 +6,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
6
  import { createSelectionClickHandler, GapCursorSelection, isSelectionAtEndOfNode, isSelectionAtStartOfNode } from '@atlaskit/editor-common/selection';
7
7
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
8
8
  import { findParentNodeOfTypeClosestToPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
9
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
10
  import { clearEditingContext, updateState } from '../commands';
10
11
  import { createCommand, createPluginState, getPluginState } from '../plugin-factory';
11
12
  import { pluginKey } from '../plugin-key';
@@ -272,6 +273,32 @@ var createPlugin = function createPlugin(dispatch, providerFactory, extensionHan
272
273
  inlineExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi),
273
274
  multiBodiedExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi)
274
275
  },
276
+ createSelectionBetween: function createSelectionBetween(view, anchor, head) {
277
+ if (!getBooleanFF('platform.editor.multi-bodied-extension_0rygg')) {
278
+ return null;
279
+ }
280
+ var _view$state3 = view.state,
281
+ schema = _view$state3.schema,
282
+ doc = _view$state3.doc;
283
+ var multiBodiedExtension = schema.nodes.multiBodiedExtension;
284
+ var isAnchorInMBE = findParentNodeOfTypeClosestToPos(anchor, multiBodiedExtension);
285
+ var isHeadInMBE = findParentNodeOfTypeClosestToPos(head, multiBodiedExtension);
286
+ if (isAnchorInMBE !== undefined && isHeadInMBE === undefined) {
287
+ // Anchor is in MBE, where user started selecting within MBE and then moved outside
288
+ var newSelection = TextSelection.create(doc, isAnchorInMBE.pos < head.pos ? isAnchorInMBE.pos : isAnchorInMBE.pos + isAnchorInMBE.node.nodeSize,
289
+ // isAnchorInMBE.pos < head.pos represents downwards selection
290
+ head.pos);
291
+ return newSelection;
292
+ }
293
+ if (isAnchorInMBE === undefined && isHeadInMBE !== undefined) {
294
+ // Head is in MBE, where user started selecting outside MBE and then moved inside
295
+ var _newSelection3 = TextSelection.create(doc, anchor.pos, isHeadInMBE.pos < anchor.pos ? isHeadInMBE.pos : isHeadInMBE.pos + isHeadInMBE.node.nodeSize // isHeadInMBE.pos < anchor.pos represents upwards selection
296
+ );
297
+
298
+ return _newSelection3;
299
+ }
300
+ return null;
301
+ },
275
302
  handleClickOn: createSelectionClickHandler(['extension', 'bodiedExtension', 'multiBodiedExtension'], function (target) {
276
303
  return !target.closest('.extension-content');
277
304
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-extension",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "editor-plugin-extension plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -27,11 +27,11 @@
27
27
  "@atlaskit/adf-schema": "^35.5.1",
28
28
  "@atlaskit/adf-utils": "^19.0.0",
29
29
  "@atlaskit/analytics-next": "^9.2.0",
30
- "@atlaskit/avatar": "^21.4.0",
30
+ "@atlaskit/avatar": "^21.5.0",
31
31
  "@atlaskit/button": "^17.4.0",
32
32
  "@atlaskit/checkbox": "^13.0.0",
33
33
  "@atlaskit/datetime-picker": "^13.0.3",
34
- "@atlaskit/editor-common": "^78.1.0",
34
+ "@atlaskit/editor-common": "^78.4.0",
35
35
  "@atlaskit/editor-json-transformer": "^8.10.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.0.0",
37
37
  "@atlaskit/editor-plugin-context-identifier": "^1.0.0",
@@ -44,20 +44,20 @@
44
44
  "@atlaskit/editor-tables": "^2.5.0",
45
45
  "@atlaskit/empty-state": "^7.7.0",
46
46
  "@atlaskit/form": "^9.0.3",
47
- "@atlaskit/icon": "^22.0.0",
47
+ "@atlaskit/icon": "^22.1.0",
48
48
  "@atlaskit/platform-feature-flags": "^0.2.0",
49
- "@atlaskit/primitives": "^2.0.0",
49
+ "@atlaskit/primitives": "^2.1.0",
50
50
  "@atlaskit/radio": "^6.0.0",
51
51
  "@atlaskit/section-message": "^6.4.0",
52
52
  "@atlaskit/select": "^17.1.0",
53
- "@atlaskit/smart-user-picker": "^6.7.0",
53
+ "@atlaskit/smart-user-picker": "^6.8.0",
54
54
  "@atlaskit/spinner": "^16.0.0",
55
55
  "@atlaskit/tabs": "^14.0.0",
56
56
  "@atlaskit/textarea": "^5.0.0",
57
57
  "@atlaskit/textfield": "^6.0.0",
58
58
  "@atlaskit/theme": "^12.6.0",
59
59
  "@atlaskit/toggle": "^13.0.0",
60
- "@atlaskit/tokens": "^1.37.0",
60
+ "@atlaskit/tokens": "^1.38.0",
61
61
  "@atlaskit/tooltip": "^18.1.0",
62
62
  "@babel/runtime": "^7.0.0",
63
63
  "@emotion/react": "^11.7.1",