@atlaskit/renderer 109.19.3 → 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 +7 -0
- package/dist/cjs/actions/index.js +1 -1
- package/dist/cjs/react/nodes/media/index.js +2 -2
- package/dist/cjs/steps/index.js +53 -27
- package/dist/cjs/ui/Renderer/index.js +1 -1
- package/dist/es2019/actions/index.js +1 -1
- package/dist/es2019/react/nodes/media/index.js +2 -2
- package/dist/es2019/steps/index.js +51 -29
- package/dist/es2019/ui/Renderer/index.js +1 -1
- package/dist/esm/actions/index.js +1 -1
- package/dist/esm/react/nodes/media/index.js +2 -2
- package/dist/esm/steps/index.js +53 -27
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
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
|
+
|
|
3
10
|
## 109.19.3
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -230,7 +230,7 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
230
230
|
|
|
231
231
|
// If from points to a node position,
|
|
232
232
|
// we need to 1 position before it for nodeAt to return the node itself
|
|
233
|
-
var beforeNodePos = Math.max(from, 0);
|
|
233
|
+
var beforeNodePos = Math.max(from - 1, 0);
|
|
234
234
|
var possibleNode = this.doc.nodeAt(beforeNodePos);
|
|
235
235
|
if ((possibleNode === null || possibleNode === void 0 ? void 0 : possibleNode.type.name) === 'media') {
|
|
236
236
|
step = new _transform.AddNodeMarkStep(beforeNodePos, this.schema.marks.annotation.create({
|
|
@@ -307,9 +307,9 @@ var MediaWithDraftAnnotation = function MediaWithDraftAnnotation(props) {
|
|
|
307
307
|
if (pos === undefined) {
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
310
|
-
if (draftPosition !== null && draftPosition.from
|
|
310
|
+
if (draftPosition !== null && draftPosition.from === pos) {
|
|
311
311
|
setShouldApplyDraftAnnotation(true);
|
|
312
|
-
setPosition(
|
|
312
|
+
setPosition(draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from);
|
|
313
313
|
} else if (draftPosition === null && shouldApplyDraftAnnotation) {
|
|
314
314
|
setShouldApplyDraftAnnotation(false);
|
|
315
315
|
setPosition(undefined);
|
package/dist/cjs/steps/index.js
CHANGED
|
@@ -6,10 +6,14 @@ 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);
|
|
12
13
|
}
|
|
14
|
+
var getNodeType = function getNodeType(element) {
|
|
15
|
+
return element.dataset.nodeType;
|
|
16
|
+
};
|
|
13
17
|
function isPositionPointer(element) {
|
|
14
18
|
return getStartPos(element) > -1;
|
|
15
19
|
}
|
|
@@ -23,16 +27,6 @@ function findParent(element) {
|
|
|
23
27
|
}
|
|
24
28
|
return findParent(parentElement);
|
|
25
29
|
}
|
|
26
|
-
function findMediaParent(element) {
|
|
27
|
-
var parentElement = element.parentElement;
|
|
28
|
-
if (!parentElement || isRoot(parentElement)) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
if (parentElement.dataset.nodeType === 'mediaSingle') {
|
|
32
|
-
return parentElement;
|
|
33
|
-
}
|
|
34
|
-
return findParent(parentElement);
|
|
35
|
-
}
|
|
36
30
|
function findParentBeforePointer(element) {
|
|
37
31
|
var parentElement = element.parentElement;
|
|
38
32
|
if (isRoot(parentElement) || !parentElement) {
|
|
@@ -59,22 +53,39 @@ function isNodeInlineMark(node) {
|
|
|
59
53
|
function isElementInlineMark(element) {
|
|
60
54
|
return !!element && Boolean(element.dataset.rendererMark);
|
|
61
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
|
+
}
|
|
62
76
|
|
|
63
77
|
/**
|
|
64
|
-
* This
|
|
65
|
-
*
|
|
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'.
|
|
66
80
|
*/
|
|
67
|
-
function
|
|
68
|
-
if (isTextNode(node)) {
|
|
69
|
-
return node.textContent;
|
|
70
|
-
}
|
|
81
|
+
function hasInlineCardDescendant(node) {
|
|
71
82
|
if (isElementNode(node)) {
|
|
72
83
|
if (node.dataset.inlineCard === 'true') {
|
|
73
|
-
return
|
|
84
|
+
return true;
|
|
74
85
|
}
|
|
75
|
-
return Array.from(node.childNodes).
|
|
86
|
+
return Array.from(node.childNodes).some(hasInlineCardDescendant);
|
|
76
87
|
}
|
|
77
|
-
return
|
|
88
|
+
return false;
|
|
78
89
|
}
|
|
79
90
|
function resolveNodePos(node) {
|
|
80
91
|
var resolvedPos = 0;
|
|
@@ -83,10 +94,18 @@ function resolveNodePos(node) {
|
|
|
83
94
|
if (prev && (isTextNode(prev) || isHighlightTextNode(prev))) {
|
|
84
95
|
resolvedPos += (prev.textContent || '').length;
|
|
85
96
|
} else if (prev) {
|
|
86
|
-
if (
|
|
87
|
-
|
|
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
|
+
}
|
|
88
103
|
} else {
|
|
89
|
-
|
|
104
|
+
if (isNodeInlineMark(prev) && prev.textContent) {
|
|
105
|
+
resolvedPos += prev.textContent.length;
|
|
106
|
+
} else {
|
|
107
|
+
resolvedPos += 1;
|
|
108
|
+
}
|
|
90
109
|
}
|
|
91
110
|
}
|
|
92
111
|
prev = prev.previousSibling;
|
|
@@ -120,9 +139,16 @@ function resolvePos(node, offset) {
|
|
|
120
139
|
// If our range is inside an inline node
|
|
121
140
|
// We need to move our pointers to parent element
|
|
122
141
|
// since we don't want to count text inside inline nodes at all
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
|
|
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
|
+
}
|
|
126
152
|
}
|
|
127
153
|
resolvedPos += resolveNodePos(current);
|
|
128
154
|
while (current && current.parentElement !== parent) {
|
|
@@ -142,8 +168,8 @@ function getPosFromRange(range) {
|
|
|
142
168
|
startOffset = range.startOffset,
|
|
143
169
|
endContainer = range.endContainer,
|
|
144
170
|
endOffset = range.endOffset;
|
|
145
|
-
var parent =
|
|
146
|
-
if (parent) {
|
|
171
|
+
var parent = findParent(startContainer);
|
|
172
|
+
if (parent && getNodeType(parent) === 'media') {
|
|
147
173
|
var pos = getStartPos(parent);
|
|
148
174
|
return {
|
|
149
175
|
from: pos,
|
|
@@ -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.
|
|
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);
|
|
@@ -208,7 +208,7 @@ export default class RendererActions {
|
|
|
208
208
|
|
|
209
209
|
// If from points to a node position,
|
|
210
210
|
// we need to 1 position before it for nodeAt to return the node itself
|
|
211
|
-
const beforeNodePos = Math.max(from, 0);
|
|
211
|
+
const beforeNodePos = Math.max(from - 1, 0);
|
|
212
212
|
const possibleNode = this.doc.nodeAt(beforeNodePos);
|
|
213
213
|
if ((possibleNode === null || possibleNode === void 0 ? void 0 : possibleNode.type.name) === 'media') {
|
|
214
214
|
step = new AddNodeMarkStep(beforeNodePos, this.schema.marks.annotation.create({
|
|
@@ -281,9 +281,9 @@ const MediaWithDraftAnnotation = props => {
|
|
|
281
281
|
if (pos === undefined) {
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
|
-
if (draftPosition !== null && draftPosition.from
|
|
284
|
+
if (draftPosition !== null && draftPosition.from === pos) {
|
|
285
285
|
setShouldApplyDraftAnnotation(true);
|
|
286
|
-
setPosition(
|
|
286
|
+
setPosition(draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from);
|
|
287
287
|
} else if (draftPosition === null && shouldApplyDraftAnnotation) {
|
|
288
288
|
setShouldApplyDraftAnnotation(false);
|
|
289
289
|
setPosition(undefined);
|
|
@@ -1,7 +1,9 @@
|
|
|
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);
|
|
4
5
|
}
|
|
6
|
+
const getNodeType = element => element.dataset.nodeType;
|
|
5
7
|
function isPositionPointer(element) {
|
|
6
8
|
return getStartPos(element) > -1;
|
|
7
9
|
}
|
|
@@ -17,18 +19,6 @@ function findParent(element) {
|
|
|
17
19
|
}
|
|
18
20
|
return findParent(parentElement);
|
|
19
21
|
}
|
|
20
|
-
function findMediaParent(element) {
|
|
21
|
-
const {
|
|
22
|
-
parentElement
|
|
23
|
-
} = element;
|
|
24
|
-
if (!parentElement || isRoot(parentElement)) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
if (parentElement.dataset.nodeType === 'mediaSingle') {
|
|
28
|
-
return parentElement;
|
|
29
|
-
}
|
|
30
|
-
return findParent(parentElement);
|
|
31
|
-
}
|
|
32
22
|
function findParentBeforePointer(element) {
|
|
33
23
|
const {
|
|
34
24
|
parentElement
|
|
@@ -57,22 +47,39 @@ function isNodeInlineMark(node) {
|
|
|
57
47
|
function isElementInlineMark(element) {
|
|
58
48
|
return !!element && Boolean(element.dataset.rendererMark);
|
|
59
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
|
+
}
|
|
60
70
|
|
|
61
71
|
/**
|
|
62
|
-
* This
|
|
63
|
-
*
|
|
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'.
|
|
64
74
|
*/
|
|
65
|
-
function
|
|
66
|
-
if (isTextNode(node)) {
|
|
67
|
-
return node.textContent;
|
|
68
|
-
}
|
|
75
|
+
function hasInlineCardDescendant(node) {
|
|
69
76
|
if (isElementNode(node)) {
|
|
70
77
|
if (node.dataset.inlineCard === 'true') {
|
|
71
|
-
return
|
|
78
|
+
return true;
|
|
72
79
|
}
|
|
73
|
-
return Array.from(node.childNodes).
|
|
80
|
+
return Array.from(node.childNodes).some(hasInlineCardDescendant);
|
|
74
81
|
}
|
|
75
|
-
return
|
|
82
|
+
return false;
|
|
76
83
|
}
|
|
77
84
|
function resolveNodePos(node) {
|
|
78
85
|
let resolvedPos = 0;
|
|
@@ -81,10 +88,18 @@ function resolveNodePos(node) {
|
|
|
81
88
|
if (prev && (isTextNode(prev) || isHighlightTextNode(prev))) {
|
|
82
89
|
resolvedPos += (prev.textContent || '').length;
|
|
83
90
|
} else if (prev) {
|
|
84
|
-
if (
|
|
85
|
-
|
|
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
|
+
}
|
|
86
97
|
} else {
|
|
87
|
-
|
|
98
|
+
if (isNodeInlineMark(prev) && prev.textContent) {
|
|
99
|
+
resolvedPos += prev.textContent.length;
|
|
100
|
+
} else {
|
|
101
|
+
resolvedPos += 1;
|
|
102
|
+
}
|
|
88
103
|
}
|
|
89
104
|
}
|
|
90
105
|
prev = prev.previousSibling;
|
|
@@ -118,9 +133,16 @@ export function resolvePos(node, offset) {
|
|
|
118
133
|
// If our range is inside an inline node
|
|
119
134
|
// We need to move our pointers to parent element
|
|
120
135
|
// since we don't want to count text inside inline nodes at all
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
|
|
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
|
+
}
|
|
124
146
|
}
|
|
125
147
|
resolvedPos += resolveNodePos(current);
|
|
126
148
|
while (current && current.parentElement !== parent) {
|
|
@@ -142,8 +164,8 @@ export function getPosFromRange(range) {
|
|
|
142
164
|
endContainer,
|
|
143
165
|
endOffset
|
|
144
166
|
} = range;
|
|
145
|
-
const parent =
|
|
146
|
-
if (parent) {
|
|
167
|
+
const parent = findParent(startContainer);
|
|
168
|
+
if (parent && getNodeType(parent) === 'media') {
|
|
147
169
|
const pos = getStartPos(parent);
|
|
148
170
|
return {
|
|
149
171
|
from: pos,
|
|
@@ -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.
|
|
39
|
+
const packageVersion = "109.19.4";
|
|
40
40
|
export class Renderer extends PureComponent {
|
|
41
41
|
constructor(props) {
|
|
42
42
|
super(props);
|
|
@@ -223,7 +223,7 @@ var RendererActions = /*#__PURE__*/function () {
|
|
|
223
223
|
|
|
224
224
|
// If from points to a node position,
|
|
225
225
|
// we need to 1 position before it for nodeAt to return the node itself
|
|
226
|
-
var beforeNodePos = Math.max(from, 0);
|
|
226
|
+
var beforeNodePos = Math.max(from - 1, 0);
|
|
227
227
|
var possibleNode = this.doc.nodeAt(beforeNodePos);
|
|
228
228
|
if ((possibleNode === null || possibleNode === void 0 ? void 0 : possibleNode.type.name) === 'media') {
|
|
229
229
|
step = new AddNodeMarkStep(beforeNodePos, this.schema.marks.annotation.create({
|
|
@@ -298,9 +298,9 @@ var MediaWithDraftAnnotation = function MediaWithDraftAnnotation(props) {
|
|
|
298
298
|
if (pos === undefined) {
|
|
299
299
|
return;
|
|
300
300
|
}
|
|
301
|
-
if (draftPosition !== null && draftPosition.from
|
|
301
|
+
if (draftPosition !== null && draftPosition.from === pos) {
|
|
302
302
|
setShouldApplyDraftAnnotation(true);
|
|
303
|
-
setPosition(
|
|
303
|
+
setPosition(draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from);
|
|
304
304
|
} else if (draftPosition === null && shouldApplyDraftAnnotation) {
|
|
305
305
|
setShouldApplyDraftAnnotation(false);
|
|
306
306
|
setPosition(undefined);
|
package/dist/esm/steps/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
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);
|
|
4
5
|
}
|
|
6
|
+
var getNodeType = function getNodeType(element) {
|
|
7
|
+
return element.dataset.nodeType;
|
|
8
|
+
};
|
|
5
9
|
function isPositionPointer(element) {
|
|
6
10
|
return getStartPos(element) > -1;
|
|
7
11
|
}
|
|
@@ -15,16 +19,6 @@ function findParent(element) {
|
|
|
15
19
|
}
|
|
16
20
|
return findParent(parentElement);
|
|
17
21
|
}
|
|
18
|
-
function findMediaParent(element) {
|
|
19
|
-
var parentElement = element.parentElement;
|
|
20
|
-
if (!parentElement || isRoot(parentElement)) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
if (parentElement.dataset.nodeType === 'mediaSingle') {
|
|
24
|
-
return parentElement;
|
|
25
|
-
}
|
|
26
|
-
return findParent(parentElement);
|
|
27
|
-
}
|
|
28
22
|
function findParentBeforePointer(element) {
|
|
29
23
|
var parentElement = element.parentElement;
|
|
30
24
|
if (isRoot(parentElement) || !parentElement) {
|
|
@@ -51,22 +45,39 @@ function isNodeInlineMark(node) {
|
|
|
51
45
|
function isElementInlineMark(element) {
|
|
52
46
|
return !!element && Boolean(element.dataset.rendererMark);
|
|
53
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
|
+
}
|
|
54
68
|
|
|
55
69
|
/**
|
|
56
|
-
* This
|
|
57
|
-
*
|
|
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'.
|
|
58
72
|
*/
|
|
59
|
-
function
|
|
60
|
-
if (isTextNode(node)) {
|
|
61
|
-
return node.textContent;
|
|
62
|
-
}
|
|
73
|
+
function hasInlineCardDescendant(node) {
|
|
63
74
|
if (isElementNode(node)) {
|
|
64
75
|
if (node.dataset.inlineCard === 'true') {
|
|
65
|
-
return
|
|
76
|
+
return true;
|
|
66
77
|
}
|
|
67
|
-
return Array.from(node.childNodes).
|
|
78
|
+
return Array.from(node.childNodes).some(hasInlineCardDescendant);
|
|
68
79
|
}
|
|
69
|
-
return
|
|
80
|
+
return false;
|
|
70
81
|
}
|
|
71
82
|
function resolveNodePos(node) {
|
|
72
83
|
var resolvedPos = 0;
|
|
@@ -75,10 +86,18 @@ function resolveNodePos(node) {
|
|
|
75
86
|
if (prev && (isTextNode(prev) || isHighlightTextNode(prev))) {
|
|
76
87
|
resolvedPos += (prev.textContent || '').length;
|
|
77
88
|
} else if (prev) {
|
|
78
|
-
if (
|
|
79
|
-
|
|
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
|
+
}
|
|
80
95
|
} else {
|
|
81
|
-
|
|
96
|
+
if (isNodeInlineMark(prev) && prev.textContent) {
|
|
97
|
+
resolvedPos += prev.textContent.length;
|
|
98
|
+
} else {
|
|
99
|
+
resolvedPos += 1;
|
|
100
|
+
}
|
|
82
101
|
}
|
|
83
102
|
}
|
|
84
103
|
prev = prev.previousSibling;
|
|
@@ -112,9 +131,16 @@ export function resolvePos(node, offset) {
|
|
|
112
131
|
// If our range is inside an inline node
|
|
113
132
|
// We need to move our pointers to parent element
|
|
114
133
|
// since we don't want to count text inside inline nodes at all
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
|
|
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
|
+
}
|
|
118
144
|
}
|
|
119
145
|
resolvedPos += resolveNodePos(current);
|
|
120
146
|
while (current && current.parentElement !== parent) {
|
|
@@ -134,8 +160,8 @@ export function getPosFromRange(range) {
|
|
|
134
160
|
startOffset = range.startOffset,
|
|
135
161
|
endContainer = range.endContainer,
|
|
136
162
|
endOffset = range.endOffset;
|
|
137
|
-
var parent =
|
|
138
|
-
if (parent) {
|
|
163
|
+
var parent = findParent(startContainer);
|
|
164
|
+
if (parent && getNodeType(parent) === 'media') {
|
|
139
165
|
var pos = getStartPos(parent);
|
|
140
166
|
return {
|
|
141
167
|
from: pos,
|
|
@@ -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.
|
|
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.
|
|
3
|
+
"version": "109.19.4",
|
|
4
4
|
"description": "Renderer component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -31,7 +31,7 @@
|
|
|
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.
|
|
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",
|
|
@@ -44,7 +44,7 @@
|
|
|
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.
|
|
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",
|