@atlaskit/renderer 109.12.5 → 109.13.0

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,15 @@
1
1
  # @atlaskit/renderer
2
2
 
3
+ ## 109.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#86103](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/86103) [`af2544086b27`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/af2544086b27) - Changed comment create mutation to send pos if comment is added to a block node
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
3
13
  ## 109.12.5
4
14
 
5
15
  ### Patch Changes
@@ -231,13 +231,15 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
231
231
  var originalSelection = doc.textBetween(from, to);
232
232
  var _getIndexMatch = (0, _matchesUtils.getIndexMatch)(this.doc, this.schema, originalSelection, from),
233
233
  numMatches = _getIndexMatch.numMatches,
234
- matchIndex = _getIndexMatch.matchIndex;
234
+ matchIndex = _getIndexMatch.matchIndex,
235
+ blockNodePos = _getIndexMatch.blockNodePos;
235
236
  return {
236
237
  step: step,
237
238
  doc: this.transformer.encode(doc),
238
239
  originalSelection: originalSelection,
239
240
  numMatches: numMatches,
240
- matchIndex: matchIndex
241
+ matchIndex: matchIndex,
242
+ pos: blockNodePos
241
243
  };
242
244
  }
243
245
  }, {
@@ -251,11 +253,13 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
251
253
  var originalSelection = this.doc.textBetween(from, to);
252
254
  var _getIndexMatch2 = (0, _matchesUtils.getIndexMatch)(this.doc, this.schema, originalSelection, from),
253
255
  numMatches = _getIndexMatch2.numMatches,
254
- matchIndex = _getIndexMatch2.matchIndex;
256
+ matchIndex = _getIndexMatch2.matchIndex,
257
+ blockNodePos = _getIndexMatch2.blockNodePos;
255
258
  return {
256
259
  originalSelection: originalSelection,
257
260
  numMatches: numMatches,
258
- matchIndex: matchIndex
261
+ matchIndex: matchIndex,
262
+ pos: blockNodePos
259
263
  };
260
264
  }
261
265
  }]);
@@ -11,18 +11,28 @@ exports.getIndexMatch = getIndexMatch;
11
11
  function getIndexMatch(doc, schema, selectedText, startIndex) {
12
12
  var textContent = '';
13
13
  var matchIndex = 0;
14
+ var numMatches = 0;
15
+ var blockNodePos;
14
16
  doc.descendants(function (node, pos) {
17
+ var nodeType = node.type;
18
+ var media = schema.nodes.media;
19
+
15
20
  // Mirrors Confluence backend and doesn't construct textContent if it doesn't allow annotations
16
- if (node.isText || !node.type.allowsMarkType(schema.marks.annotation)) {
21
+ // Don't skip media node so that block node can be defined its startIndex in within [nodeStart, nodeEnd]
22
+ if ((node.isText || !nodeType.allowsMarkType(schema.marks.annotation)) && nodeType !== media) {
17
23
  // Note: `return true` as a parent disallowing annotations does not mean a child disallows annotations.
18
24
  // Eg: panel (invalid) > p (valid)
19
25
  return true;
20
26
  }
21
27
  var nodeStart = pos;
22
28
  var nodeEnd = nodeStart + node.nodeSize;
23
-
24
- // If the start of the annotation selection is within the current node, we scan the document for previous occurrences
25
29
  if (startIndex >= nodeStart && startIndex <= nodeEnd) {
30
+ // if it's a node block, set position to pos to indicate to the backend
31
+ // that it's an annotation on a block node
32
+ if (nodeType === media) {
33
+ blockNodePos = pos;
34
+ }
35
+ // If the start of the annotation selection is within the current node, we scan the document for previous occurrences
26
36
  // Find the index by counting all previous instances of the selectedText in the partial textContent
27
37
  // Need to scan from start, up to `startIndex` (which includes partial of the current node)
28
38
  textContent += doc.textBetween(nodeStart, startIndex - 1);
@@ -37,11 +47,12 @@ function getIndexMatch(doc, schema, selectedText, startIndex) {
37
47
  });
38
48
 
39
49
  // Count total number of matches in final text
40
- var numMatches = countMatches(textContent, selectedText);
50
+ numMatches = countMatches(textContent, selectedText);
41
51
  return {
42
52
  numMatches: numMatches,
43
53
  matchIndex: matchIndex,
44
- textContent: textContent
54
+ textContent: textContent,
55
+ blockNodePos: blockNodePos
45
56
  };
46
57
  }
47
58
 
@@ -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.12.5";
58
+ var packageVersion = "109.13.0";
59
59
  var Renderer = exports.Renderer = /*#__PURE__*/function (_PureComponent) {
60
60
  (0, _inherits2.default)(Renderer, _PureComponent);
61
61
  var _super = _createSuper(Renderer);
@@ -210,14 +210,16 @@ export default class RendererActions {
210
210
  const originalSelection = doc.textBetween(from, to);
211
211
  const {
212
212
  numMatches,
213
- matchIndex
213
+ matchIndex,
214
+ blockNodePos
214
215
  } = getIndexMatch(this.doc, this.schema, originalSelection, from);
215
216
  return {
216
217
  step,
217
218
  doc: this.transformer.encode(doc),
218
219
  originalSelection,
219
220
  numMatches,
220
- matchIndex
221
+ matchIndex,
222
+ pos: blockNodePos
221
223
  };
222
224
  }
223
225
  generateAnnotationIndexMatch(pos) {
@@ -231,12 +233,14 @@ export default class RendererActions {
231
233
  const originalSelection = this.doc.textBetween(from, to);
232
234
  const {
233
235
  numMatches,
234
- matchIndex
236
+ matchIndex,
237
+ blockNodePos
235
238
  } = getIndexMatch(this.doc, this.schema, originalSelection, from);
236
239
  return {
237
240
  originalSelection,
238
241
  numMatches,
239
- matchIndex
242
+ matchIndex,
243
+ pos: blockNodePos
240
244
  };
241
245
  }
242
246
  }
@@ -4,18 +4,30 @@
4
4
  export function getIndexMatch(doc, schema, selectedText, startIndex) {
5
5
  let textContent = '';
6
6
  let matchIndex = 0;
7
+ let numMatches = 0;
8
+ let blockNodePos;
7
9
  doc.descendants((node, pos) => {
10
+ const nodeType = node.type;
11
+ const {
12
+ media
13
+ } = schema.nodes;
14
+
8
15
  // Mirrors Confluence backend and doesn't construct textContent if it doesn't allow annotations
9
- if (node.isText || !node.type.allowsMarkType(schema.marks.annotation)) {
16
+ // Don't skip media node so that block node can be defined its startIndex in within [nodeStart, nodeEnd]
17
+ if ((node.isText || !nodeType.allowsMarkType(schema.marks.annotation)) && nodeType !== media) {
10
18
  // Note: `return true` as a parent disallowing annotations does not mean a child disallows annotations.
11
19
  // Eg: panel (invalid) > p (valid)
12
20
  return true;
13
21
  }
14
22
  const nodeStart = pos;
15
23
  const nodeEnd = nodeStart + node.nodeSize;
16
-
17
- // If the start of the annotation selection is within the current node, we scan the document for previous occurrences
18
24
  if (startIndex >= nodeStart && startIndex <= nodeEnd) {
25
+ // if it's a node block, set position to pos to indicate to the backend
26
+ // that it's an annotation on a block node
27
+ if (nodeType === media) {
28
+ blockNodePos = pos;
29
+ }
30
+ // If the start of the annotation selection is within the current node, we scan the document for previous occurrences
19
31
  // Find the index by counting all previous instances of the selectedText in the partial textContent
20
32
  // Need to scan from start, up to `startIndex` (which includes partial of the current node)
21
33
  textContent += doc.textBetween(nodeStart, startIndex - 1);
@@ -30,11 +42,12 @@ export function getIndexMatch(doc, schema, selectedText, startIndex) {
30
42
  });
31
43
 
32
44
  // Count total number of matches in final text
33
- const numMatches = countMatches(textContent, selectedText);
45
+ numMatches = countMatches(textContent, selectedText);
34
46
  return {
35
47
  numMatches,
36
48
  matchIndex,
37
- textContent
49
+ textContent,
50
+ blockNodePos
38
51
  };
39
52
  }
40
53
 
@@ -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.12.5";
39
+ const packageVersion = "109.13.0";
40
40
  export class Renderer extends PureComponent {
41
41
  constructor(props) {
42
42
  super(props);
@@ -224,13 +224,15 @@ var RendererActions = /*#__PURE__*/function () {
224
224
  var originalSelection = doc.textBetween(from, to);
225
225
  var _getIndexMatch = getIndexMatch(this.doc, this.schema, originalSelection, from),
226
226
  numMatches = _getIndexMatch.numMatches,
227
- matchIndex = _getIndexMatch.matchIndex;
227
+ matchIndex = _getIndexMatch.matchIndex,
228
+ blockNodePos = _getIndexMatch.blockNodePos;
228
229
  return {
229
230
  step: step,
230
231
  doc: this.transformer.encode(doc),
231
232
  originalSelection: originalSelection,
232
233
  numMatches: numMatches,
233
- matchIndex: matchIndex
234
+ matchIndex: matchIndex,
235
+ pos: blockNodePos
234
236
  };
235
237
  }
236
238
  }, {
@@ -244,11 +246,13 @@ var RendererActions = /*#__PURE__*/function () {
244
246
  var originalSelection = this.doc.textBetween(from, to);
245
247
  var _getIndexMatch2 = getIndexMatch(this.doc, this.schema, originalSelection, from),
246
248
  numMatches = _getIndexMatch2.numMatches,
247
- matchIndex = _getIndexMatch2.matchIndex;
249
+ matchIndex = _getIndexMatch2.matchIndex,
250
+ blockNodePos = _getIndexMatch2.blockNodePos;
248
251
  return {
249
252
  originalSelection: originalSelection,
250
253
  numMatches: numMatches,
251
- matchIndex: matchIndex
254
+ matchIndex: matchIndex,
255
+ pos: blockNodePos
252
256
  };
253
257
  }
254
258
  }]);
@@ -4,18 +4,28 @@
4
4
  export function getIndexMatch(doc, schema, selectedText, startIndex) {
5
5
  var textContent = '';
6
6
  var matchIndex = 0;
7
+ var numMatches = 0;
8
+ var blockNodePos;
7
9
  doc.descendants(function (node, pos) {
10
+ var nodeType = node.type;
11
+ var media = schema.nodes.media;
12
+
8
13
  // Mirrors Confluence backend and doesn't construct textContent if it doesn't allow annotations
9
- if (node.isText || !node.type.allowsMarkType(schema.marks.annotation)) {
14
+ // Don't skip media node so that block node can be defined its startIndex in within [nodeStart, nodeEnd]
15
+ if ((node.isText || !nodeType.allowsMarkType(schema.marks.annotation)) && nodeType !== media) {
10
16
  // Note: `return true` as a parent disallowing annotations does not mean a child disallows annotations.
11
17
  // Eg: panel (invalid) > p (valid)
12
18
  return true;
13
19
  }
14
20
  var nodeStart = pos;
15
21
  var nodeEnd = nodeStart + node.nodeSize;
16
-
17
- // If the start of the annotation selection is within the current node, we scan the document for previous occurrences
18
22
  if (startIndex >= nodeStart && startIndex <= nodeEnd) {
23
+ // if it's a node block, set position to pos to indicate to the backend
24
+ // that it's an annotation on a block node
25
+ if (nodeType === media) {
26
+ blockNodePos = pos;
27
+ }
28
+ // If the start of the annotation selection is within the current node, we scan the document for previous occurrences
19
29
  // Find the index by counting all previous instances of the selectedText in the partial textContent
20
30
  // Need to scan from start, up to `startIndex` (which includes partial of the current node)
21
31
  textContent += doc.textBetween(nodeStart, startIndex - 1);
@@ -30,11 +40,12 @@ export function getIndexMatch(doc, schema, selectedText, startIndex) {
30
40
  });
31
41
 
32
42
  // Count total number of matches in final text
33
- var numMatches = countMatches(textContent, selectedText);
43
+ numMatches = countMatches(textContent, selectedText);
34
44
  return {
35
45
  numMatches: numMatches,
36
46
  matchIndex: matchIndex,
37
- textContent: textContent
47
+ textContent: textContent,
48
+ blockNodePos: blockNodePos
38
49
  };
39
50
  }
40
51
 
@@ -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.12.5";
49
+ var packageVersion = "109.13.0";
50
50
  export var Renderer = /*#__PURE__*/function (_PureComponent) {
51
51
  _inherits(Renderer, _PureComponent);
52
52
  var _super = _createSuper(Renderer);
@@ -1,7 +1,8 @@
1
- import { Node, Schema } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Node, Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  export declare function getIndexMatch(doc: Node, schema: Schema, selectedText: string, startIndex: number): {
3
3
  numMatches: number;
4
4
  matchIndex: number;
5
5
  textContent: string;
6
+ blockNodePos?: number;
6
7
  };
7
8
  export declare function countMatches(searchString: string, query: string): number;
@@ -1,7 +1,8 @@
1
- import { Node, Schema } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Node, Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  export declare function getIndexMatch(doc: Node, schema: Schema, selectedText: string, startIndex: number): {
3
3
  numMatches: number;
4
4
  matchIndex: number;
5
5
  textContent: string;
6
+ blockNodePos?: number;
6
7
  };
7
8
  export declare function countMatches(searchString: string, query: string): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "109.12.5",
3
+ "version": "109.13.0",
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.8.0",
33
33
  "@atlaskit/code": "^15.1.0",
34
- "@atlaskit/editor-common": "^78.22.0",
34
+ "@atlaskit/editor-common": "^78.23.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",
@@ -47,7 +47,7 @@
47
47
  "@atlaskit/media-ui": "^25.4.0",
48
48
  "@atlaskit/media-viewer": "^48.4.0",
49
49
  "@atlaskit/platform-feature-flags": "^0.2.0",
50
- "@atlaskit/smart-card": "^26.50.0",
50
+ "@atlaskit/smart-card": "^26.51.0",
51
51
  "@atlaskit/status": "^1.4.0",
52
52
  "@atlaskit/task-decision": "^17.9.0",
53
53
  "@atlaskit/theme": "^12.7.0",