@atlaskit/renderer 109.19.2 → 109.19.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,18 @@
1
1
  # @atlaskit/renderer
2
2
 
3
+ ## 109.19.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#91941](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91941) [`fded4cd65773`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fded4cd65773) - [ED-22917] fixes position calculation logic for comments on commented inline cards
8
+ - [#92745](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92745) [`0058e08c0a70`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0058e08c0a70) - Revert fix for "Allow realtime comments to correctly infer position of comment on media" (HOT-108750)
9
+
10
+ ## 109.19.3
11
+
12
+ ### Patch Changes
13
+
14
+ - [#92483](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92483) [`bd8804c2b4ad`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bd8804c2b4ad) - Allow realtime comments to correctly infer position of comment on media
15
+
3
16
  ## 109.19.2
4
17
 
5
18
  ### Patch Changes
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.createAnnotationStep = createAnnotationStep;
7
7
  exports.getPosFromRange = getPosFromRange;
8
8
  exports.resolvePos = resolvePos;
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
10
  var _transform = require("@atlaskit/editor-prosemirror/transform");
10
11
  function getStartPos(element) {
11
12
  return parseInt(element.dataset.rendererStartPos || '-1', 10);
@@ -52,22 +53,39 @@ function isNodeInlineMark(node) {
52
53
  function isElementInlineMark(element) {
53
54
  return !!element && Boolean(element.dataset.rendererMark);
54
55
  }
56
+ function isNodeInlineTextMark(node) {
57
+ if (node === null) {
58
+ return false;
59
+ }
60
+ var isInlineMark = isElementNode(node) && Boolean(node.dataset.rendererMark);
61
+ if (!isInlineMark) {
62
+ return false;
63
+ }
64
+
65
+ /**
66
+ * This checks if the element has any descendents with the data-inline-card
67
+ * attribute set to 'true'. If it does, we should not consider it as an
68
+ * inline text mark.
69
+ **/
70
+
71
+ if (hasInlineCardDescendant(node)) {
72
+ return false;
73
+ }
74
+ return true;
75
+ }
55
76
 
56
77
  /**
57
- * This returns the text content of a node excluding content
58
- * inside inline cards (spans with data-inline-card="true").
78
+ * This checks all the descendents of a node and returns true if it reaches
79
+ * a descendant with the data-inline-card attribute set to 'true'.
59
80
  */
60
- function getPMTextContent(node) {
61
- if (isTextNode(node)) {
62
- return node.textContent;
63
- }
81
+ function hasInlineCardDescendant(node) {
64
82
  if (isElementNode(node)) {
65
83
  if (node.dataset.inlineCard === 'true') {
66
- return '';
84
+ return true;
67
85
  }
68
- return Array.from(node.childNodes).map(getPMTextContent).join('');
86
+ return Array.from(node.childNodes).some(hasInlineCardDescendant);
69
87
  }
70
- return '';
88
+ return false;
71
89
  }
72
90
  function resolveNodePos(node) {
73
91
  var resolvedPos = 0;
@@ -76,10 +94,18 @@ function resolveNodePos(node) {
76
94
  if (prev && (isTextNode(prev) || isHighlightTextNode(prev))) {
77
95
  resolvedPos += (prev.textContent || '').length;
78
96
  } else if (prev) {
79
- if (isNodeInlineMark(prev) && prev.textContent) {
80
- resolvedPos += getPMTextContent(prev).length;
97
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes')) {
98
+ if (isNodeInlineTextMark(prev) && prev.textContent) {
99
+ resolvedPos += prev.textContent.length;
100
+ } else {
101
+ resolvedPos += 1;
102
+ }
81
103
  } else {
82
- resolvedPos += 1;
104
+ if (isNodeInlineMark(prev) && prev.textContent) {
105
+ resolvedPos += prev.textContent.length;
106
+ } else {
107
+ resolvedPos += 1;
108
+ }
83
109
  }
84
110
  }
85
111
  prev = prev.previousSibling;
@@ -113,9 +139,16 @@ function resolvePos(node, offset) {
113
139
  // If our range is inside an inline node
114
140
  // We need to move our pointers to parent element
115
141
  // since we don't want to count text inside inline nodes at all
116
- if (!(isElementInlineMark(preParentPointer) || isHighlightTextNode(preParentPointer))) {
117
- current = current.parentElement;
118
- offset = 0;
142
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes')) {
143
+ if (!(isNodeInlineTextMark(preParentPointer) || isHighlightTextNode(preParentPointer))) {
144
+ current = current.parentElement;
145
+ offset = 0;
146
+ }
147
+ } else {
148
+ if (!(isElementInlineMark(preParentPointer) || isHighlightTextNode(preParentPointer))) {
149
+ current = current.parentElement;
150
+ offset = 0;
151
+ }
119
152
  }
120
153
  resolvedPos += resolveNodePos(current);
121
154
  while (current && current.parentElement !== parent) {
@@ -55,7 +55,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
55
55
  var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
56
56
  var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
57
57
  var packageName = "@atlaskit/renderer";
58
- var packageVersion = "109.19.2";
58
+ var packageVersion = "109.19.4";
59
59
  var Renderer = exports.Renderer = /*#__PURE__*/function (_PureComponent) {
60
60
  (0, _inherits2.default)(Renderer, _PureComponent);
61
61
  var _super = _createSuper(Renderer);
@@ -1,3 +1,4 @@
1
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
1
2
  import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
2
3
  function getStartPos(element) {
3
4
  return parseInt(element.dataset.rendererStartPos || '-1', 10);
@@ -46,22 +47,39 @@ function isNodeInlineMark(node) {
46
47
  function isElementInlineMark(element) {
47
48
  return !!element && Boolean(element.dataset.rendererMark);
48
49
  }
50
+ function isNodeInlineTextMark(node) {
51
+ if (node === null) {
52
+ return false;
53
+ }
54
+ const isInlineMark = isElementNode(node) && Boolean(node.dataset.rendererMark);
55
+ if (!isInlineMark) {
56
+ return false;
57
+ }
58
+
59
+ /**
60
+ * This checks if the element has any descendents with the data-inline-card
61
+ * attribute set to 'true'. If it does, we should not consider it as an
62
+ * inline text mark.
63
+ **/
64
+
65
+ if (hasInlineCardDescendant(node)) {
66
+ return false;
67
+ }
68
+ return true;
69
+ }
49
70
 
50
71
  /**
51
- * This returns the text content of a node excluding content
52
- * inside inline cards (spans with data-inline-card="true").
72
+ * This checks all the descendents of a node and returns true if it reaches
73
+ * a descendant with the data-inline-card attribute set to 'true'.
53
74
  */
54
- function getPMTextContent(node) {
55
- if (isTextNode(node)) {
56
- return node.textContent;
57
- }
75
+ function hasInlineCardDescendant(node) {
58
76
  if (isElementNode(node)) {
59
77
  if (node.dataset.inlineCard === 'true') {
60
- return '';
78
+ return true;
61
79
  }
62
- return Array.from(node.childNodes).map(getPMTextContent).join('');
80
+ return Array.from(node.childNodes).some(hasInlineCardDescendant);
63
81
  }
64
- return '';
82
+ return false;
65
83
  }
66
84
  function resolveNodePos(node) {
67
85
  let resolvedPos = 0;
@@ -70,10 +88,18 @@ function resolveNodePos(node) {
70
88
  if (prev && (isTextNode(prev) || isHighlightTextNode(prev))) {
71
89
  resolvedPos += (prev.textContent || '').length;
72
90
  } else if (prev) {
73
- if (isNodeInlineMark(prev) && prev.textContent) {
74
- resolvedPos += getPMTextContent(prev).length;
91
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes')) {
92
+ if (isNodeInlineTextMark(prev) && prev.textContent) {
93
+ resolvedPos += prev.textContent.length;
94
+ } else {
95
+ resolvedPos += 1;
96
+ }
75
97
  } else {
76
- resolvedPos += 1;
98
+ if (isNodeInlineMark(prev) && prev.textContent) {
99
+ resolvedPos += prev.textContent.length;
100
+ } else {
101
+ resolvedPos += 1;
102
+ }
77
103
  }
78
104
  }
79
105
  prev = prev.previousSibling;
@@ -107,9 +133,16 @@ export function resolvePos(node, offset) {
107
133
  // If our range is inside an inline node
108
134
  // We need to move our pointers to parent element
109
135
  // since we don't want to count text inside inline nodes at all
110
- if (!(isElementInlineMark(preParentPointer) || isHighlightTextNode(preParentPointer))) {
111
- current = current.parentElement;
112
- offset = 0;
136
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes')) {
137
+ if (!(isNodeInlineTextMark(preParentPointer) || isHighlightTextNode(preParentPointer))) {
138
+ current = current.parentElement;
139
+ offset = 0;
140
+ }
141
+ } else {
142
+ if (!(isElementInlineMark(preParentPointer) || isHighlightTextNode(preParentPointer))) {
143
+ current = current.parentElement;
144
+ offset = 0;
145
+ }
113
146
  }
114
147
  resolvedPos += resolveNodePos(current);
115
148
  while (current && current.parentElement !== parent) {
@@ -36,7 +36,7 @@ import { EditorMediaClientProvider } from '../../react/utils/EditorMediaClientPr
36
36
  export const NORMAL_SEVERITY_THRESHOLD = 2000;
37
37
  export const DEGRADED_SEVERITY_THRESHOLD = 3000;
38
38
  const packageName = "@atlaskit/renderer";
39
- const packageVersion = "109.19.2";
39
+ const packageVersion = "109.19.4";
40
40
  export class Renderer extends PureComponent {
41
41
  constructor(props) {
42
42
  super(props);
@@ -1,3 +1,4 @@
1
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
1
2
  import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
2
3
  function getStartPos(element) {
3
4
  return parseInt(element.dataset.rendererStartPos || '-1', 10);
@@ -44,22 +45,39 @@ function isNodeInlineMark(node) {
44
45
  function isElementInlineMark(element) {
45
46
  return !!element && Boolean(element.dataset.rendererMark);
46
47
  }
48
+ function isNodeInlineTextMark(node) {
49
+ if (node === null) {
50
+ return false;
51
+ }
52
+ var isInlineMark = isElementNode(node) && Boolean(node.dataset.rendererMark);
53
+ if (!isInlineMark) {
54
+ return false;
55
+ }
56
+
57
+ /**
58
+ * This checks if the element has any descendents with the data-inline-card
59
+ * attribute set to 'true'. If it does, we should not consider it as an
60
+ * inline text mark.
61
+ **/
62
+
63
+ if (hasInlineCardDescendant(node)) {
64
+ return false;
65
+ }
66
+ return true;
67
+ }
47
68
 
48
69
  /**
49
- * This returns the text content of a node excluding content
50
- * inside inline cards (spans with data-inline-card="true").
70
+ * This checks all the descendents of a node and returns true if it reaches
71
+ * a descendant with the data-inline-card attribute set to 'true'.
51
72
  */
52
- function getPMTextContent(node) {
53
- if (isTextNode(node)) {
54
- return node.textContent;
55
- }
73
+ function hasInlineCardDescendant(node) {
56
74
  if (isElementNode(node)) {
57
75
  if (node.dataset.inlineCard === 'true') {
58
- return '';
76
+ return true;
59
77
  }
60
- return Array.from(node.childNodes).map(getPMTextContent).join('');
78
+ return Array.from(node.childNodes).some(hasInlineCardDescendant);
61
79
  }
62
- return '';
80
+ return false;
63
81
  }
64
82
  function resolveNodePos(node) {
65
83
  var resolvedPos = 0;
@@ -68,10 +86,18 @@ function resolveNodePos(node) {
68
86
  if (prev && (isTextNode(prev) || isHighlightTextNode(prev))) {
69
87
  resolvedPos += (prev.textContent || '').length;
70
88
  } else if (prev) {
71
- if (isNodeInlineMark(prev) && prev.textContent) {
72
- resolvedPos += getPMTextContent(prev).length;
89
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes')) {
90
+ if (isNodeInlineTextMark(prev) && prev.textContent) {
91
+ resolvedPos += prev.textContent.length;
92
+ } else {
93
+ resolvedPos += 1;
94
+ }
73
95
  } else {
74
- resolvedPos += 1;
96
+ if (isNodeInlineMark(prev) && prev.textContent) {
97
+ resolvedPos += prev.textContent.length;
98
+ } else {
99
+ resolvedPos += 1;
100
+ }
75
101
  }
76
102
  }
77
103
  prev = prev.previousSibling;
@@ -105,9 +131,16 @@ export function resolvePos(node, offset) {
105
131
  // If our range is inside an inline node
106
132
  // We need to move our pointers to parent element
107
133
  // since we don't want to count text inside inline nodes at all
108
- if (!(isElementInlineMark(preParentPointer) || isHighlightTextNode(preParentPointer))) {
109
- current = current.parentElement;
110
- offset = 0;
134
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes')) {
135
+ if (!(isNodeInlineTextMark(preParentPointer) || isHighlightTextNode(preParentPointer))) {
136
+ current = current.parentElement;
137
+ offset = 0;
138
+ }
139
+ } else {
140
+ if (!(isElementInlineMark(preParentPointer) || isHighlightTextNode(preParentPointer))) {
141
+ current = current.parentElement;
142
+ offset = 0;
143
+ }
111
144
  }
112
145
  resolvedPos += resolveNodePos(current);
113
146
  while (current && current.parentElement !== parent) {
@@ -46,7 +46,7 @@ import { EditorMediaClientProvider } from '../../react/utils/EditorMediaClientPr
46
46
  export var NORMAL_SEVERITY_THRESHOLD = 2000;
47
47
  export var DEGRADED_SEVERITY_THRESHOLD = 3000;
48
48
  var packageName = "@atlaskit/renderer";
49
- var packageVersion = "109.19.2";
49
+ var packageVersion = "109.19.4";
50
50
  export var Renderer = /*#__PURE__*/function (_PureComponent) {
51
51
  _inherits(Renderer, _PureComponent);
52
52
  var _super = _createSuper(Renderer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "109.19.2",
3
+ "version": "109.19.4",
4
4
  "description": "Renderer component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -31,20 +31,20 @@
31
31
  "@atlaskit/analytics-next": "^9.2.0",
32
32
  "@atlaskit/button": "^17.12.0",
33
33
  "@atlaskit/code": "^15.1.0",
34
- "@atlaskit/editor-common": "^78.29.0",
34
+ "@atlaskit/editor-common": "^78.30.0",
35
35
  "@atlaskit/editor-json-transformer": "^8.10.0",
36
36
  "@atlaskit/editor-palette": "1.5.3",
37
37
  "@atlaskit/editor-prosemirror": "3.0.0",
38
38
  "@atlaskit/editor-shared-styles": "^2.9.0",
39
39
  "@atlaskit/emoji": "^67.6.0",
40
40
  "@atlaskit/icon": "^22.1.0",
41
- "@atlaskit/link-datasource": "^1.27.0",
41
+ "@atlaskit/link-datasource": "^1.28.0",
42
42
  "@atlaskit/media-card": "^77.11.0",
43
43
  "@atlaskit/media-client": "^26.3.0",
44
44
  "@atlaskit/media-client-react": "^2.0.0",
45
45
  "@atlaskit/media-common": "^11.1.0",
46
46
  "@atlaskit/media-filmstrip": "^47.0.0",
47
- "@atlaskit/media-ui": "^25.7.0",
47
+ "@atlaskit/media-ui": "^25.8.0",
48
48
  "@atlaskit/media-viewer": "^48.4.0",
49
49
  "@atlaskit/platform-feature-flags": "^0.2.0",
50
50
  "@atlaskit/smart-card": "^26.56.0",