@atlaskit/editor-plugin-block-controls 2.13.1 → 2.13.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,23 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 2.13.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`01ef5296f2ad8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/01ef5296f2ad8) -
8
+ ED-25331 Fix jittering after dropping blockquotes by setting cursor at inline end pos instead of
9
+ gap cursor
10
+ - Updated dependencies
11
+
12
+ ## 2.13.2
13
+
14
+ ### Patch Changes
15
+
16
+ - [#159192](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/159192)
17
+ [`0df45cd10dc0d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0df45cd10dc0d) -
18
+ ED-25539 fix bug drag a node to a node with breakout
19
+ - Updated dependencies
20
+
3
21
  ## 2.13.1
4
22
 
5
23
  ### Patch Changes
@@ -143,12 +143,22 @@ var moveToLayout = exports.moveToLayout = function moveToLayout(api) {
143
143
  var _toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize : to;
144
144
  return moveToExistingLayout(toLayout, toLayoutPos, fromNodeWithoutBreakout, from, _toPos, tr);
145
145
  } else {
146
- var layoutContents = options !== null && options !== void 0 && options.moveToEnd ? [toNode, fromNodeWithoutBreakout] : [fromNodeWithoutBreakout, toNode];
146
+ var toNodeWithoutBreakout = toNode;
147
+
148
+ // remove breakout from node;
149
+ if (breakout && $to.nodeAfter && $to.nodeAfter.marks.some(function (m) {
150
+ return m.type === breakout;
151
+ })) {
152
+ tr.removeNodeMark(to, breakout);
153
+ // resolve again the source node after node updated (remove breakout marks)
154
+ toNodeWithoutBreakout = tr.doc.resolve(to).nodeAfter || toNode;
155
+ }
156
+ var layoutContents = options !== null && options !== void 0 && options.moveToEnd ? [toNodeWithoutBreakout, fromNodeWithoutBreakout] : [fromNodeWithoutBreakout, toNodeWithoutBreakout];
147
157
  var newLayout = createNewLayout(tr.doc.type.schema, layoutContents);
148
158
  if (newLayout) {
149
159
  tr.delete(from, from + fromNode.nodeSize);
150
160
  var mappedTo = tr.mapping.map(to);
151
- tr.delete(mappedTo, mappedTo + toNode.nodeSize).insert(mappedTo, newLayout).setSelection(new _state.NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
161
+ tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout).setSelection(new _state.NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
152
162
  }
153
163
  return tr;
154
164
  }
@@ -7,6 +7,7 @@ exports.setCursorPositionAtMovedNode = exports.selectNode = exports.getSelection
7
7
  var _selection = require("@atlaskit/editor-common/selection");
8
8
  var _state = require("@atlaskit/editor-prosemirror/state");
9
9
  var _utils = require("@atlaskit/editor-tables/utils");
10
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
11
  var getInlineNodePos = exports.getInlineNodePos = function getInlineNodePos(tr, start, nodeSize) {
11
12
  var $startPos = tr.doc.resolve(start);
12
13
  // To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
@@ -80,7 +81,8 @@ var setCursorPositionAtMovedNode = exports.setCursorPositionAtMovedNode = functi
80
81
  var nodeSize = node ? node.nodeSize : 1;
81
82
  var selection;
82
83
  // decisionList node is not selectable, but we want to select the whole node not just text
83
- if (isNodeSelection || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
84
+ // blockQuote is selectable, but we want to set cursor at the inline end Pos instead of the gap cursor as this causes jittering post drop
85
+ if (isNodeSelection && ((0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_4') ? node.type.name !== 'blockquote' : true) || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
84
86
  selection = new _selection.GapCursorSelection(tr.doc.resolve(start + node.nodeSize), _selection.Side.RIGHT);
85
87
  } else {
86
88
  var _getInlineNodePos2 = getInlineNodePos(tr, start, nodeSize),
@@ -141,12 +141,20 @@ export const moveToLayout = api => (from, to, options) => ({
141
141
  const toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize : to;
142
142
  return moveToExistingLayout(toLayout, toLayoutPos, fromNodeWithoutBreakout, from, toPos, tr);
143
143
  } else {
144
- const layoutContents = options !== null && options !== void 0 && options.moveToEnd ? [toNode, fromNodeWithoutBreakout] : [fromNodeWithoutBreakout, toNode];
144
+ let toNodeWithoutBreakout = toNode;
145
+
146
+ // remove breakout from node;
147
+ if (breakout && $to.nodeAfter && $to.nodeAfter.marks.some(m => m.type === breakout)) {
148
+ tr.removeNodeMark(to, breakout);
149
+ // resolve again the source node after node updated (remove breakout marks)
150
+ toNodeWithoutBreakout = tr.doc.resolve(to).nodeAfter || toNode;
151
+ }
152
+ const layoutContents = options !== null && options !== void 0 && options.moveToEnd ? [toNodeWithoutBreakout, fromNodeWithoutBreakout] : [fromNodeWithoutBreakout, toNodeWithoutBreakout];
145
153
  const newLayout = createNewLayout(tr.doc.type.schema, layoutContents);
146
154
  if (newLayout) {
147
155
  tr.delete(from, from + fromNode.nodeSize);
148
156
  const mappedTo = tr.mapping.map(to);
149
- tr.delete(mappedTo, mappedTo + toNode.nodeSize).insert(mappedTo, newLayout).setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
157
+ tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout).setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
150
158
  }
151
159
  return tr;
152
160
  }
@@ -1,6 +1,7 @@
1
1
  import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
2
2
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  export const getInlineNodePos = (tr, start, nodeSize) => {
5
6
  const $startPos = tr.doc.resolve(start);
6
7
  // To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
@@ -75,7 +76,8 @@ export const setCursorPositionAtMovedNode = (tr, start) => {
75
76
  const nodeSize = node ? node.nodeSize : 1;
76
77
  let selection;
77
78
  // decisionList node is not selectable, but we want to select the whole node not just text
78
- if (isNodeSelection || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
79
+ // blockQuote is selectable, but we want to set cursor at the inline end Pos instead of the gap cursor as this causes jittering post drop
80
+ if (isNodeSelection && (fg('platform_editor_element_dnd_nested_fix_patch_4') ? node.type.name !== 'blockquote' : true) || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
79
81
  selection = new GapCursorSelection(tr.doc.resolve(start + node.nodeSize), Side.RIGHT);
80
82
  } else {
81
83
  const {
@@ -137,12 +137,22 @@ export var moveToLayout = function moveToLayout(api) {
137
137
  var _toPos = options !== null && options !== void 0 && options.moveToEnd ? to + toNode.nodeSize : to;
138
138
  return moveToExistingLayout(toLayout, toLayoutPos, fromNodeWithoutBreakout, from, _toPos, tr);
139
139
  } else {
140
- var layoutContents = options !== null && options !== void 0 && options.moveToEnd ? [toNode, fromNodeWithoutBreakout] : [fromNodeWithoutBreakout, toNode];
140
+ var toNodeWithoutBreakout = toNode;
141
+
142
+ // remove breakout from node;
143
+ if (breakout && $to.nodeAfter && $to.nodeAfter.marks.some(function (m) {
144
+ return m.type === breakout;
145
+ })) {
146
+ tr.removeNodeMark(to, breakout);
147
+ // resolve again the source node after node updated (remove breakout marks)
148
+ toNodeWithoutBreakout = tr.doc.resolve(to).nodeAfter || toNode;
149
+ }
150
+ var layoutContents = options !== null && options !== void 0 && options.moveToEnd ? [toNodeWithoutBreakout, fromNodeWithoutBreakout] : [fromNodeWithoutBreakout, toNodeWithoutBreakout];
141
151
  var newLayout = createNewLayout(tr.doc.type.schema, layoutContents);
142
152
  if (newLayout) {
143
153
  tr.delete(from, from + fromNode.nodeSize);
144
154
  var mappedTo = tr.mapping.map(to);
145
- tr.delete(mappedTo, mappedTo + toNode.nodeSize).insert(mappedTo, newLayout).setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
155
+ tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout).setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
146
156
  }
147
157
  return tr;
148
158
  }
@@ -1,6 +1,7 @@
1
1
  import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
2
2
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  export var getInlineNodePos = function getInlineNodePos(tr, start, nodeSize) {
5
6
  var $startPos = tr.doc.resolve(start);
6
7
  // To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
@@ -74,7 +75,8 @@ export var setCursorPositionAtMovedNode = function setCursorPositionAtMovedNode(
74
75
  var nodeSize = node ? node.nodeSize : 1;
75
76
  var selection;
76
77
  // decisionList node is not selectable, but we want to select the whole node not just text
77
- if (isNodeSelection || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
78
+ // blockQuote is selectable, but we want to set cursor at the inline end Pos instead of the gap cursor as this causes jittering post drop
79
+ if (isNodeSelection && (fg('platform_editor_element_dnd_nested_fix_patch_4') ? node.type.name !== 'blockquote' : true) || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
78
80
  selection = new GapCursorSelection(tr.doc.resolve(start + node.nodeSize), Side.RIGHT);
79
81
  } else {
80
82
  var _getInlineNodePos2 = getInlineNodePos(tr, start, nodeSize),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.13.1",
3
+ "version": "2.13.3",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@atlaskit/adf-schema": "^44.2.0",
34
- "@atlaskit/editor-common": "^94.9.0",
34
+ "@atlaskit/editor-common": "^94.10.0",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
37
37
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
49
49
  "@atlaskit/primitives": "^13.0.0",
50
50
  "@atlaskit/theme": "^14.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^2.10.0",
51
+ "@atlaskit/tmp-editor-statsig": "^2.11.0",
52
52
  "@atlaskit/tokens": "^2.0.0",
53
53
  "@atlaskit/tooltip": "^18.8.0",
54
54
  "@babel/runtime": "^7.0.0",
@@ -142,6 +142,9 @@
142
142
  "platform_editor_element_dnd_nested_fix_patch_3": {
143
143
  "type": "boolean"
144
144
  },
145
+ "platform_editor_element_dnd_nested_fix_patch_4": {
146
+ "type": "boolean"
147
+ },
145
148
  "platform_editor_element_dnd_nested_type_error_fix": {
146
149
  "type": "boolean"
147
150
  },