@atlaskit/editor-plugin-block-controls 1.5.8 → 1.5.9

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,13 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 1.5.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#116092](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/116092)
8
+ [`2d7842663b057`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2d7842663b057) -
9
+ ED-23905 Fix selection on click for nested lists and task lists
10
+
3
11
  ## 1.5.8
4
12
 
5
13
  ### Patch Changes
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.selectNode = exports.getSelection = void 0;
7
7
  var _state = require("@atlaskit/editor-prosemirror/state");
8
8
  var _utils = require("@atlaskit/editor-tables/utils");
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
10
  var getSelection = exports.getSelection = function getSelection(tr, start) {
10
11
  var node = tr.doc.nodeAt(start);
11
12
  var isNodeSelection = node && _state.NodeSelection.isSelectable(node);
@@ -24,19 +25,30 @@ var getSelection = exports.getSelection = function getSelection(tr, start) {
24
25
  // Find the first inline node in the node
25
26
  var inlineNodePos = start;
26
27
  var foundInlineNode = false;
28
+ var inlineNodeEndPos = 0;
27
29
  tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, function (n, pos) {
28
- if (foundInlineNode) {
29
- return false;
30
- }
31
- if (n.isInline) {
32
- inlineNodePos = pos;
33
- foundInlineNode = true;
34
- return false;
30
+ if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-ed-23905')) {
31
+ if (n.isInline) {
32
+ inlineNodeEndPos = pos + n.nodeSize;
33
+ }
34
+ if (n.isInline && !foundInlineNode) {
35
+ inlineNodePos = pos;
36
+ foundInlineNode = true;
37
+ }
38
+ } else {
39
+ if (foundInlineNode) {
40
+ return false;
41
+ }
42
+ if (n.isInline) {
43
+ inlineNodePos = pos;
44
+ foundInlineNode = true;
45
+ return false;
46
+ }
35
47
  }
36
48
  return true;
37
49
  });
38
50
  var inlineNodeDepth = inlineNodePos - start;
39
- return new _state.TextSelection(tr.doc.resolve(start + nodeSize - inlineNodeDepth), tr.doc.resolve(inlineNodePos));
51
+ return new _state.TextSelection(tr.doc.resolve((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-ed-23905') ? inlineNodeEndPos : start + nodeSize - inlineNodeDepth), tr.doc.resolve(inlineNodePos));
40
52
  }
41
53
  };
42
54
  var selectNode = exports.selectNode = function selectNode(tr, start, nodeType) {
@@ -1,5 +1,6 @@
1
1
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  export const getSelection = (tr, start) => {
4
5
  const node = tr.doc.nodeAt(start);
5
6
  const isNodeSelection = node && NodeSelection.isSelectable(node);
@@ -18,19 +19,30 @@ export const getSelection = (tr, start) => {
18
19
  // Find the first inline node in the node
19
20
  let inlineNodePos = start;
20
21
  let foundInlineNode = false;
22
+ let inlineNodeEndPos = 0;
21
23
  tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, (n, pos) => {
22
- if (foundInlineNode) {
23
- return false;
24
- }
25
- if (n.isInline) {
26
- inlineNodePos = pos;
27
- foundInlineNode = true;
28
- return false;
24
+ if (fg('platform.editor.elements.drag-and-drop-ed-23905')) {
25
+ if (n.isInline) {
26
+ inlineNodeEndPos = pos + n.nodeSize;
27
+ }
28
+ if (n.isInline && !foundInlineNode) {
29
+ inlineNodePos = pos;
30
+ foundInlineNode = true;
31
+ }
32
+ } else {
33
+ if (foundInlineNode) {
34
+ return false;
35
+ }
36
+ if (n.isInline) {
37
+ inlineNodePos = pos;
38
+ foundInlineNode = true;
39
+ return false;
40
+ }
29
41
  }
30
42
  return true;
31
43
  });
32
44
  const inlineNodeDepth = inlineNodePos - start;
33
- return new TextSelection(tr.doc.resolve(start + nodeSize - inlineNodeDepth), tr.doc.resolve(inlineNodePos));
45
+ return new TextSelection(tr.doc.resolve(fg('platform.editor.elements.drag-and-drop-ed-23905') ? inlineNodeEndPos : start + nodeSize - inlineNodeDepth), tr.doc.resolve(inlineNodePos));
34
46
  }
35
47
  };
36
48
  export const selectNode = (tr, start, nodeType) => {
@@ -1,5 +1,6 @@
1
1
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  export var getSelection = function getSelection(tr, start) {
4
5
  var node = tr.doc.nodeAt(start);
5
6
  var isNodeSelection = node && NodeSelection.isSelectable(node);
@@ -18,19 +19,30 @@ export var getSelection = function getSelection(tr, start) {
18
19
  // Find the first inline node in the node
19
20
  var inlineNodePos = start;
20
21
  var foundInlineNode = false;
22
+ var inlineNodeEndPos = 0;
21
23
  tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, function (n, pos) {
22
- if (foundInlineNode) {
23
- return false;
24
- }
25
- if (n.isInline) {
26
- inlineNodePos = pos;
27
- foundInlineNode = true;
28
- return false;
24
+ if (fg('platform.editor.elements.drag-and-drop-ed-23905')) {
25
+ if (n.isInline) {
26
+ inlineNodeEndPos = pos + n.nodeSize;
27
+ }
28
+ if (n.isInline && !foundInlineNode) {
29
+ inlineNodePos = pos;
30
+ foundInlineNode = true;
31
+ }
32
+ } else {
33
+ if (foundInlineNode) {
34
+ return false;
35
+ }
36
+ if (n.isInline) {
37
+ inlineNodePos = pos;
38
+ foundInlineNode = true;
39
+ return false;
40
+ }
29
41
  }
30
42
  return true;
31
43
  });
32
44
  var inlineNodeDepth = inlineNodePos - start;
33
- return new TextSelection(tr.doc.resolve(start + nodeSize - inlineNodeDepth), tr.doc.resolve(inlineNodePos));
45
+ return new TextSelection(tr.doc.resolve(fg('platform.editor.elements.drag-and-drop-ed-23905') ? inlineNodeEndPos : start + nodeSize - inlineNodeDepth), tr.doc.resolve(inlineNodePos));
34
46
  }
35
47
  };
36
48
  export var selectNode = function selectNode(tr, start, nodeType) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "1.5.8",
3
+ "version": "1.5.9",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -113,6 +113,9 @@
113
113
  },
114
114
  "platform.editor.elements.drag-and-drop-ed-23816": {
115
115
  "type": "boolean"
116
+ },
117
+ "platform.editor.elements.drag-and-drop-ed-23905": {
118
+ "type": "boolean"
116
119
  }
117
120
  }
118
121
  }