@atlaskit/editor-plugin-block-controls 1.4.2 → 1.4.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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 1.4.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#104094](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/104094)
8
+ [`ae80ae898d90`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ae80ae898d90) -
9
+ Refactor getSelection and add tests
10
+
11
+ ## 1.4.3
12
+
13
+ ### Patch Changes
14
+
15
+ - [#103721](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103721)
16
+ [`8c44ebf695aa`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8c44ebf695aa) -
17
+ Adjust drag preview opacity
18
+
3
19
  ## 1.4.2
4
20
 
5
21
  ### Patch Changes
@@ -12,6 +12,7 @@ var dragPreview = exports.dragPreview = function dragPreview(container, domRef)
12
12
  var parent = document.createElement('div');
13
13
  // ProseMirror class is required to make sure the cloned dom is styled correctly
14
14
  parent.classList.add('ProseMirror');
15
+ parent.style.opacity = '0.3';
15
16
  var resizer = domRef.current.querySelector('.resizer-item');
16
17
  var clonedDom = resizer ? resizer.cloneNode(true) : domRef.current.cloneNode(true);
17
18
 
@@ -9,7 +9,7 @@ var _react = require("@emotion/react");
9
9
 
10
10
  var globalStyles = (0, _react.css)({
11
11
  '.ProseMirror-widget:first-child + *': {
12
- 'margin-top': '0 !important'
12
+ marginTop: '0 !important'
13
13
  }
14
14
  });
15
15
  var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper() {
@@ -13,16 +13,22 @@ var getSelection = exports.getSelection = function getSelection(tr, start) {
13
13
  if (isNodeSelection) {
14
14
  return new _state.NodeSelection($startPos);
15
15
  } else {
16
- var textNodesPos = [];
16
+ // To trigger the annotation floating toolbar for non-selectable node, we need to select on the text node
17
+ // Find the first text node in the node
18
+ var textNodesPos = start;
19
+ var foundTextNodes = false;
17
20
  tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, function (n, pos) {
21
+ if (foundTextNodes) {
22
+ return false;
23
+ }
18
24
  if (n.isText) {
19
- textNodesPos.push(pos);
25
+ textNodesPos = pos;
26
+ foundTextNodes = true;
20
27
  return false;
21
28
  }
22
29
  return true;
23
30
  });
24
- var textNodeStart = textNodesPos[0] || start;
25
- var textNodeDepth = textNodeStart - start;
26
- return new _state.TextSelection(tr.doc.resolve(textNodeStart), tr.doc.resolve(start + nodeSize - textNodeDepth));
31
+ var textNodeDepth = textNodesPos - start;
32
+ return new _state.TextSelection(tr.doc.resolve(textNodesPos), tr.doc.resolve(start + nodeSize - textNodeDepth));
27
33
  }
28
34
  };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "getSelection", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _getSelection.getSelection;
10
+ }
11
+ });
12
+ var _getSelection = require("./getSelection");
@@ -6,6 +6,7 @@ export const dragPreview = (container, domRef) => {
6
6
  const parent = document.createElement('div');
7
7
  // ProseMirror class is required to make sure the cloned dom is styled correctly
8
8
  parent.classList.add('ProseMirror');
9
+ parent.style.opacity = '0.3';
9
10
  const resizer = domRef.current.querySelector('.resizer-item');
10
11
  const clonedDom = resizer ? resizer.cloneNode(true) : domRef.current.cloneNode(true);
11
12
 
@@ -2,7 +2,7 @@
2
2
  import { css, Global, jsx } from '@emotion/react';
3
3
  const globalStyles = css({
4
4
  '.ProseMirror-widget:first-child + *': {
5
- 'margin-top': '0 !important'
5
+ marginTop: '0 !important'
6
6
  }
7
7
  });
8
8
  export const GlobalStylesWrapper = () => {
@@ -7,16 +7,22 @@ export const getSelection = (tr, start) => {
7
7
  if (isNodeSelection) {
8
8
  return new NodeSelection($startPos);
9
9
  } else {
10
- const textNodesPos = [];
10
+ // To trigger the annotation floating toolbar for non-selectable node, we need to select on the text node
11
+ // Find the first text node in the node
12
+ let textNodesPos = start;
13
+ let foundTextNodes = false;
11
14
  tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, (n, pos) => {
15
+ if (foundTextNodes) {
16
+ return false;
17
+ }
12
18
  if (n.isText) {
13
- textNodesPos.push(pos);
19
+ textNodesPos = pos;
20
+ foundTextNodes = true;
14
21
  return false;
15
22
  }
16
23
  return true;
17
24
  });
18
- const textNodeStart = textNodesPos[0] || start;
19
- const textNodeDepth = textNodeStart - start;
20
- return new TextSelection(tr.doc.resolve(textNodeStart), tr.doc.resolve(start + nodeSize - textNodeDepth));
25
+ const textNodeDepth = textNodesPos - start;
26
+ return new TextSelection(tr.doc.resolve(textNodesPos), tr.doc.resolve(start + nodeSize - textNodeDepth));
21
27
  }
22
28
  };
@@ -0,0 +1 @@
1
+ export { getSelection } from './getSelection';
@@ -6,6 +6,7 @@ export var dragPreview = function dragPreview(container, domRef) {
6
6
  var parent = document.createElement('div');
7
7
  // ProseMirror class is required to make sure the cloned dom is styled correctly
8
8
  parent.classList.add('ProseMirror');
9
+ parent.style.opacity = '0.3';
9
10
  var resizer = domRef.current.querySelector('.resizer-item');
10
11
  var clonedDom = resizer ? resizer.cloneNode(true) : domRef.current.cloneNode(true);
11
12
 
@@ -2,7 +2,7 @@
2
2
  import { css, Global, jsx } from '@emotion/react';
3
3
  var globalStyles = css({
4
4
  '.ProseMirror-widget:first-child + *': {
5
- 'margin-top': '0 !important'
5
+ marginTop: '0 !important'
6
6
  }
7
7
  });
8
8
  export var GlobalStylesWrapper = function GlobalStylesWrapper() {
@@ -7,16 +7,22 @@ export var getSelection = function getSelection(tr, start) {
7
7
  if (isNodeSelection) {
8
8
  return new NodeSelection($startPos);
9
9
  } else {
10
- var textNodesPos = [];
10
+ // To trigger the annotation floating toolbar for non-selectable node, we need to select on the text node
11
+ // Find the first text node in the node
12
+ var textNodesPos = start;
13
+ var foundTextNodes = false;
11
14
  tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, function (n, pos) {
15
+ if (foundTextNodes) {
16
+ return false;
17
+ }
12
18
  if (n.isText) {
13
- textNodesPos.push(pos);
19
+ textNodesPos = pos;
20
+ foundTextNodes = true;
14
21
  return false;
15
22
  }
16
23
  return true;
17
24
  });
18
- var textNodeStart = textNodesPos[0] || start;
19
- var textNodeDepth = textNodeStart - start;
20
- return new TextSelection(tr.doc.resolve(textNodeStart), tr.doc.resolve(start + nodeSize - textNodeDepth));
25
+ var textNodeDepth = textNodesPos - start;
26
+ return new TextSelection(tr.doc.resolve(textNodesPos), tr.doc.resolve(start + nodeSize - textNodeDepth));
21
27
  }
22
28
  };
@@ -0,0 +1 @@
1
+ export { getSelection } from './getSelection';
@@ -0,0 +1 @@
1
+ export { getSelection } from './getSelection';
@@ -0,0 +1 @@
1
+ export { getSelection } from './getSelection';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
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
  ".": "./src/index.ts"
32
32
  },
33
33
  "dependencies": {
34
- "@atlaskit/editor-common": "^81.0.0",
34
+ "@atlaskit/editor-common": "^81.1.0",
35
35
  "@atlaskit/editor-prosemirror": "4.0.1",
36
36
  "@atlaskit/icon": "^22.3.0",
37
37
  "@atlaskit/pragmatic-drag-and-drop": "^1.1.0",