@atlaskit/renderer 109.12.1 → 109.12.3

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/react/index.js +7 -31
  3. package/dist/cjs/react/nodes/text-wrapper.js +3 -1
  4. package/dist/cjs/react/utils/render-text-segments.js +35 -0
  5. package/dist/cjs/react/utils/segment-text.js +1 -1
  6. package/dist/cjs/steps/index.js +9 -5
  7. package/dist/cjs/ui/Renderer/index.js +1 -1
  8. package/dist/cjs/ui/annotations/draft/component.js +31 -16
  9. package/dist/es2019/react/index.js +7 -26
  10. package/dist/es2019/react/nodes/text-wrapper.js +3 -1
  11. package/dist/es2019/react/utils/render-text-segments.js +25 -0
  12. package/dist/es2019/react/utils/segment-text.js +1 -1
  13. package/dist/es2019/steps/index.js +9 -5
  14. package/dist/es2019/ui/Renderer/index.js +1 -1
  15. package/dist/es2019/ui/annotations/draft/component.js +29 -19
  16. package/dist/esm/react/index.js +7 -31
  17. package/dist/esm/react/nodes/text-wrapper.js +3 -1
  18. package/dist/esm/react/utils/render-text-segments.js +28 -0
  19. package/dist/esm/react/utils/segment-text.js +1 -1
  20. package/dist/esm/steps/index.js +9 -5
  21. package/dist/esm/ui/Renderer/index.js +1 -1
  22. package/dist/esm/ui/annotations/draft/component.js +29 -15
  23. package/dist/types/react/index.d.ts +0 -1
  24. package/dist/types/react/nodes/text-wrapper.d.ts +5 -1
  25. package/dist/types/react/types.d.ts +1 -0
  26. package/dist/types/react/utils/render-text-segments.d.ts +5 -0
  27. package/dist/types/steps/index.d.ts +1 -1
  28. package/dist/types/ui/annotations/draft/component.d.ts +8 -2
  29. package/dist/types-ts4.5/react/index.d.ts +0 -1
  30. package/dist/types-ts4.5/react/nodes/text-wrapper.d.ts +5 -1
  31. package/dist/types-ts4.5/react/types.d.ts +1 -0
  32. package/dist/types-ts4.5/react/utils/render-text-segments.d.ts +5 -0
  33. package/dist/types-ts4.5/steps/index.d.ts +1 -1
  34. package/dist/types-ts4.5/ui/annotations/draft/component.d.ts +8 -2
  35. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/renderer
2
2
 
3
+ ## 109.12.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#85984](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/85984) [`3689328bd7c4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3689328bd7c4) - Fix resolvePos for renderer TextHighlight
8
+
9
+ ## 109.12.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [#85922](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/85922) [`9cb0eef56b9d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9cb0eef56b9d) - Adjusted renderer TextHighlighter API added more tests and fixed off by 1 error
14
+
3
15
  ## 109.12.1
4
16
 
5
17
  ### Patch Changes
@@ -24,6 +24,7 @@ var _utils3 = require("@atlaskit/editor-prosemirror/utils");
24
24
  var _rendererNode = require("./renderer-node");
25
25
  var _code = require("./marks/code");
26
26
  var _segmentText = require("./utils/segment-text");
27
+ var _renderTextSegments = require("./utils/render-text-segments");
27
28
  var _excluded = ["key"];
28
29
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
29
30
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -304,7 +305,6 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
304
305
  var markKey = "".concat(mark.type.name, "-component__").concat(this.startPos, "__").concat(parentMark.path.length);
305
306
  return this.renderMark((0, _marks.toReact)(mark), this.getMarkProps(mark, parentMark.path), markKey, content);
306
307
  }
307
- var segments = (0, _segmentText.segmentText)(mark.text, this.textHighlighter);
308
308
  var startPos = this.startPos;
309
309
  var endPos = startPos + mark.nodeSize;
310
310
  this.startPos = endPos;
@@ -314,37 +314,13 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
314
314
  return /*#__PURE__*/_react.default.createElement(_textWrapper.default, {
315
315
  key: textKey,
316
316
  startPos: startPos + parentDepth,
317
- endPos: endPos + parentDepth
318
- }, this.renderTextSegments(segments, textKey, mark));
317
+ endPos: endPos + parentDepth,
318
+ textHighlighter: this.textHighlighter,
319
+ marks: mark.marks
320
+ }, mark.text);
319
321
  }
320
- return this.renderTextSegments(segments, textKey, mark);
321
- }
322
- }, {
323
- key: "renderTextSegments",
324
- value: function renderTextSegments(segments, key, text) {
325
- var _this$textHighlighter;
326
- var Component = (_this$textHighlighter = this.textHighlighter) === null || _this$textHighlighter === void 0 ? void 0 : _this$textHighlighter.component;
327
- var marks = new Set(text.marks.map(function (m) {
328
- return m.type.name;
329
- }));
330
- function renderSegment(segment) {
331
- var idx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
332
- if (segment.type === 'plain' || !Component) {
333
- return segment.text;
334
- }
335
- return /*#__PURE__*/_react.default.createElement(Component, {
336
- match: segment.text,
337
- groups: segment.groups,
338
- marks: marks,
339
- key: "".concat(segment.text, "_").concat(idx)
340
- }, segment.text);
341
- }
342
- if (segments.length === 1) {
343
- return renderSegment(segments[0]);
344
- }
345
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
346
- key: key
347
- }, segments.map(renderSegment));
322
+ var segments = (0, _segmentText.segmentText)(mark.text, this.textHighlighter);
323
+ return (0, _renderTextSegments.renderTextSegments)(segments, this.textHighlighter, mark.marks, startPos);
348
324
  }
349
325
  }, {
350
326
  key: "renderNode",
@@ -16,7 +16,9 @@ var TextWrapper = function TextWrapper(props) {
16
16
  }
17
17
  return /*#__PURE__*/_react.default.createElement(_annotations.TextWithAnnotationDraft, {
18
18
  startPos: startPos,
19
- endPos: endPos
19
+ endPos: endPos,
20
+ textHighlighter: props.textHighlighter,
21
+ marks: props.marks
20
22
  }, children);
21
23
  };
22
24
  var _default = exports.default = TextWrapper;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.renderTextSegments = renderTextSegments;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ function renderTextSegments(segments, textHighlighter, marksList, startPos) {
10
+ var Component = textHighlighter === null || textHighlighter === void 0 ? void 0 : textHighlighter.component;
11
+ var marks = new Set(marksList.map(function (m) {
12
+ return m.type.name;
13
+ }));
14
+ function renderSegment(segment) {
15
+ var idx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
16
+ if (segment.type === 'plain' || !Component) {
17
+ return segment.text;
18
+ }
19
+ return /*#__PURE__*/_react.default.createElement("span", {
20
+ "data-highlighted": true
21
+ }, /*#__PURE__*/_react.default.createElement(Component, {
22
+ match: segment.text,
23
+ groups: segment.groups,
24
+ marks: marks,
25
+ key: "".concat(segment.text, "_").concat(startPos, "_").concat(idx),
26
+ startPos: startPos + idx
27
+ }, segment.text));
28
+ }
29
+ if (segments.length === 1) {
30
+ return renderSegment(segments[0]);
31
+ }
32
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
33
+ key: "text-wrapper_".concat(startPos)
34
+ }, segments.map(renderSegment));
35
+ }
@@ -46,7 +46,7 @@ function segmentText(text, highlighter) {
46
46
  } finally {
47
47
  _iterator.f();
48
48
  }
49
- if (pos < text.length - 1) {
49
+ if (pos < text.length) {
50
50
  segments.push({
51
51
  type: 'plain',
52
52
  text: text.substring(pos)
@@ -39,6 +39,10 @@ function isElementNode(node) {
39
39
  function isTextNode(node) {
40
40
  return node.nodeType === Node.TEXT_NODE;
41
41
  }
42
+ function isHighlightTextNode(node) {
43
+ var _dataset;
44
+ return !!(node !== null && node !== void 0 && (_dataset = node.dataset) !== null && _dataset !== void 0 && _dataset.highlighted);
45
+ }
42
46
  function isNodeInlineMark(node) {
43
47
  return isElementNode(node) && Boolean(node.dataset.rendererMark);
44
48
  }
@@ -49,7 +53,7 @@ function resolveNodePos(node) {
49
53
  var resolvedPos = 0;
50
54
  var prev = node.previousSibling;
51
55
  while (prev) {
52
- if (prev && isTextNode(prev)) {
56
+ if (prev && (isTextNode(prev) || isHighlightTextNode(prev))) {
53
57
  resolvedPos += (prev.textContent || '').length;
54
58
  } else if (prev) {
55
59
  if (isNodeInlineMark(prev) && prev.textContent) {
@@ -66,7 +70,7 @@ function isRoot(element) {
66
70
  return !!element && element.classList.contains('ak-renderer-document');
67
71
  }
68
72
  function resolvePos(node, offset) {
69
- // If the passed node doesnt exist, we should abort
73
+ // If the passed node doesn't exist, we should abort
70
74
  if (!node) {
71
75
  return false;
72
76
  }
@@ -84,12 +88,12 @@ function resolvePos(node, offset) {
84
88
  var current = node;
85
89
  if (current.parentElement && current.parentElement !== parent) {
86
90
  // Find the parent element that is a direct child of the position pointer
87
- // the outter most element from our text position.
91
+ // the outer most element from our text position.
88
92
  var preParentPointer = findParentBeforePointer(current.parentElement);
89
93
  // If our range is inside an inline node
90
94
  // We need to move our pointers to parent element
91
- // since we dont want to count text inside inline nodes at all
92
- if (!isElementInlineMark(preParentPointer)) {
95
+ // since we don't want to count text inside inline nodes at all
96
+ if (!(isElementInlineMark(preParentPointer) || isHighlightTextNode(preParentPointer))) {
93
97
  current = current.parentElement;
94
98
  offset = 0;
95
99
  }
@@ -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.1";
58
+ var packageVersion = "109.12.3";
59
59
  var Renderer = exports.Renderer = /*#__PURE__*/function (_PureComponent) {
60
60
  (0, _inherits2.default)(Renderer, _PureComponent);
61
61
  var _super = _createSuper(Renderer);
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.getAnnotationIndex = exports.applyAnnotationOnText = exports.TextWithAnnotationDraft = exports.AnnotationDraft = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
11
10
  var _react = _interopRequireWildcard(require("react"));
12
11
  var _react2 = require("@emotion/react");
13
12
  var _types = require("../types");
@@ -16,12 +15,18 @@ var _text = require("./text");
16
15
  var _position = require("./position");
17
16
  var _dom = require("./dom");
18
17
  var _styles = require("@atlaskit/editor-common/styles");
19
- var _templateObject;
20
- /** @jsx jsx */
18
+ var _segmentText = require("../../../react/utils/segment-text");
19
+ var _renderTextSegments = require("../../../react/utils/render-text-segments");
21
20
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
22
21
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
+ /** @jsx jsx */
23
+
23
24
  var markStyles = function markStyles() {
24
- return (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n color: inherit;\n background-color: unset;\n -webkit-tap-highlight-color: transparent;\n\n ", ";\n"])), (0, _styles.AnnotationSharedCSSByState)().focus);
25
+ return (0, _react2.css)({
26
+ color: 'inherit',
27
+ backgroundColor: 'unset',
28
+ WebkitTapHighlightColor: 'transparent'
29
+ }, (0, _styles.AnnotationSharedCSSByState)().focus);
25
30
  };
26
31
  var AnnotationDraft = exports.AnnotationDraft = function AnnotationDraft(_ref) {
27
32
  var draftPosition = _ref.draftPosition,
@@ -47,24 +52,29 @@ var getAnnotationIndex = exports.getAnnotationIndex = function getAnnotationInde
47
52
  var applyAnnotationOnText = exports.applyAnnotationOnText = function applyAnnotationOnText(_ref2) {
48
53
  var texts = _ref2.texts,
49
54
  shouldApplyAnnotationAt = _ref2.shouldApplyAnnotationAt,
50
- draftPosition = _ref2.draftPosition;
55
+ draftPosition = _ref2.draftPosition,
56
+ textHighlighter = _ref2.textHighlighter,
57
+ marks = _ref2.marks;
51
58
  var annotateIndex = getAnnotationIndex(shouldApplyAnnotationAt, texts.length);
52
59
  return texts.map(function (value, index) {
60
+ var segments = (0, _segmentText.segmentText)(value, textHighlighter);
53
61
  if (annotateIndex === index) {
54
62
  return (0, _react2.jsx)(AnnotationDraft, {
55
63
  key: index,
56
64
  draftPosition: draftPosition
57
- }, value);
65
+ }, (0, _renderTextSegments.renderTextSegments)(segments, textHighlighter, marks || [], draftPosition.from));
58
66
  }
59
67
  return (0, _react2.jsx)(_react.default.Fragment, {
60
68
  key: index
61
- }, value);
69
+ }, (0, _renderTextSegments.renderTextSegments)(segments, textHighlighter, marks || [], draftPosition.from));
62
70
  });
63
71
  };
64
72
  var TextWithAnnotationDraft = exports.TextWithAnnotationDraft = function TextWithAnnotationDraft(_ref3) {
65
73
  var startPos = _ref3.startPos,
66
74
  endPos = _ref3.endPos,
67
- children = _ref3.children;
75
+ children = _ref3.children,
76
+ textHighlighter = _ref3.textHighlighter,
77
+ marks = _ref3.marks;
68
78
  var textPosition = _react.default.useMemo(function () {
69
79
  return {
70
80
  start: startPos,
@@ -78,28 +88,33 @@ var TextWithAnnotationDraft = exports.TextWithAnnotationDraft = function TextWit
78
88
  }
79
89
  return (0, _position.calcInsertDraftPositionOnText)(textPosition, nextDraftPosition);
80
90
  }, [nextDraftPosition, textPosition]);
81
- if (shouldApplyAnnotationAt === false || !nextDraftPosition) {
91
+ var textString = (0, _text.findTextString)(children);
92
+ if (!textString) {
82
93
  return (0, _react2.jsx)(_react.Fragment, null, children);
83
94
  }
95
+ if (shouldApplyAnnotationAt === false || !nextDraftPosition) {
96
+ var segments = (0, _segmentText.segmentText)(textString, textHighlighter);
97
+ return (0, _react2.jsx)(_react.Fragment, null, (0, _renderTextSegments.renderTextSegments)(segments, textHighlighter, marks || [], startPos));
98
+ }
84
99
  if (shouldApplyAnnotationAt === _types.InsertDraftPosition.AROUND_TEXT) {
100
+ var _segments = (0, _segmentText.segmentText)(textString, textHighlighter);
85
101
  return (0, _react2.jsx)(AnnotationDraft, {
86
102
  key: 0,
87
103
  draftPosition: nextDraftPosition
88
- }, children);
89
- }
90
- var textString = (0, _text.findTextString)(children);
91
- if (!textString) {
92
- return (0, _react2.jsx)(_react.Fragment, null, children);
104
+ }, (0, _renderTextSegments.renderTextSegments)(_segments, textHighlighter, marks || [], startPos));
93
105
  }
94
106
  var offsets = (0, _text.calcTextSplitOffset)(nextDraftPosition, textPosition, textString);
95
107
  var texts = (0, _text.splitText)(textString, offsets);
96
108
  if (!texts) {
97
- return (0, _react2.jsx)(_react.Fragment, null, children);
109
+ var _segments2 = (0, _segmentText.segmentText)(textString, textHighlighter);
110
+ return (0, _react2.jsx)(_react.Fragment, null, (0, _renderTextSegments.renderTextSegments)(_segments2, textHighlighter, marks || [], startPos));
98
111
  }
99
112
  var components = applyAnnotationOnText({
100
113
  texts: texts,
101
114
  shouldApplyAnnotationAt: shouldApplyAnnotationAt,
102
- draftPosition: nextDraftPosition
115
+ draftPosition: nextDraftPosition,
116
+ textHighlighter: textHighlighter,
117
+ marks: marks
103
118
  });
104
119
  return (0, _react2.jsx)(_react.Fragment, null, components);
105
120
  };
@@ -13,6 +13,7 @@ import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
13
13
  import { insideBlockNode, insideBreakoutLayout, insideMultiBodiedExtension } from './renderer-node';
14
14
  import { isCodeMark } from './marks/code';
15
15
  import { segmentText } from './utils/segment-text';
16
+ import { renderTextSegments } from './utils/render-text-segments';
16
17
  function mergeMarks(marksAndNodes) {
17
18
  return marksAndNodes.reduce((acc, markOrNode) => {
18
19
  const prev = acc.length && acc[acc.length - 1] || null;
@@ -272,7 +273,6 @@ export default class ReactSerializer {
272
273
  const markKey = `${mark.type.name}-component__${this.startPos}__${parentMark.path.length}`;
273
274
  return this.renderMark(markToReact(mark), this.getMarkProps(mark, parentMark.path), markKey, content);
274
275
  }
275
- const segments = segmentText(mark.text, this.textHighlighter);
276
276
  const startPos = this.startPos;
277
277
  const endPos = startPos + mark.nodeSize;
278
278
  this.startPos = endPos;
@@ -282,32 +282,13 @@ export default class ReactSerializer {
282
282
  return /*#__PURE__*/React.createElement(TextWrapperComponent, {
283
283
  key: textKey,
284
284
  startPos: startPos + parentDepth,
285
- endPos: endPos + parentDepth
286
- }, this.renderTextSegments(segments, textKey, mark));
287
- }
288
- return this.renderTextSegments(segments, textKey, mark);
289
- }
290
- renderTextSegments(segments, key, text) {
291
- var _this$textHighlighter;
292
- const Component = (_this$textHighlighter = this.textHighlighter) === null || _this$textHighlighter === void 0 ? void 0 : _this$textHighlighter.component;
293
- const marks = new Set(text.marks.map(m => m.type.name));
294
- function renderSegment(segment, idx = 0) {
295
- if (segment.type === 'plain' || !Component) {
296
- return segment.text;
297
- }
298
- return /*#__PURE__*/React.createElement(Component, {
299
- match: segment.text,
300
- groups: segment.groups,
301
- marks: marks,
302
- key: `${segment.text}_${idx}`
303
- }, segment.text);
285
+ endPos: endPos + parentDepth,
286
+ textHighlighter: this.textHighlighter,
287
+ marks: mark.marks
288
+ }, mark.text);
304
289
  }
305
- if (segments.length === 1) {
306
- return renderSegment(segments[0]);
307
- }
308
- return /*#__PURE__*/React.createElement(React.Fragment, {
309
- key: key
310
- }, segments.map(renderSegment));
290
+ const segments = segmentText(mark.text, this.textHighlighter);
291
+ return renderTextSegments(segments, this.textHighlighter, mark.marks, startPos);
311
292
  }
312
293
  renderNode(NodeComponent, props, key, content) {
313
294
  return /*#__PURE__*/React.createElement(NodeComponent, _extends({
@@ -13,7 +13,9 @@ const TextWrapper = props => {
13
13
  }
14
14
  return /*#__PURE__*/React.createElement(TextWithAnnotationDraft, {
15
15
  startPos: startPos,
16
- endPos: endPos
16
+ endPos: endPos,
17
+ textHighlighter: props.textHighlighter,
18
+ marks: props.marks
17
19
  }, children);
18
20
  };
19
21
  export default TextWrapper;
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ export function renderTextSegments(segments, textHighlighter, marksList, startPos) {
3
+ const Component = textHighlighter === null || textHighlighter === void 0 ? void 0 : textHighlighter.component;
4
+ const marks = new Set(marksList.map(m => m.type.name));
5
+ function renderSegment(segment, idx = 0) {
6
+ if (segment.type === 'plain' || !Component) {
7
+ return segment.text;
8
+ }
9
+ return /*#__PURE__*/React.createElement("span", {
10
+ "data-highlighted": true
11
+ }, /*#__PURE__*/React.createElement(Component, {
12
+ match: segment.text,
13
+ groups: segment.groups,
14
+ marks: marks,
15
+ key: `${segment.text}_${startPos}_${idx}`,
16
+ startPos: startPos + idx
17
+ }, segment.text));
18
+ }
19
+ if (segments.length === 1) {
20
+ return renderSegment(segments[0]);
21
+ }
22
+ return /*#__PURE__*/React.createElement(React.Fragment, {
23
+ key: `text-wrapper_${startPos}`
24
+ }, segments.map(renderSegment));
25
+ }
@@ -23,7 +23,7 @@ export function segmentText(text, highlighter) {
23
23
  });
24
24
  pos = markTextMatch.index + markTextMatch[0].length;
25
25
  }
26
- if (pos < text.length - 1) {
26
+ if (pos < text.length) {
27
27
  segments.push({
28
28
  type: 'plain',
29
29
  text: text.substring(pos)
@@ -35,6 +35,10 @@ function isElementNode(node) {
35
35
  function isTextNode(node) {
36
36
  return node.nodeType === Node.TEXT_NODE;
37
37
  }
38
+ function isHighlightTextNode(node) {
39
+ var _dataset;
40
+ return !!(node !== null && node !== void 0 && (_dataset = node.dataset) !== null && _dataset !== void 0 && _dataset.highlighted);
41
+ }
38
42
  function isNodeInlineMark(node) {
39
43
  return isElementNode(node) && Boolean(node.dataset.rendererMark);
40
44
  }
@@ -45,7 +49,7 @@ function resolveNodePos(node) {
45
49
  let resolvedPos = 0;
46
50
  let prev = node.previousSibling;
47
51
  while (prev) {
48
- if (prev && isTextNode(prev)) {
52
+ if (prev && (isTextNode(prev) || isHighlightTextNode(prev))) {
49
53
  resolvedPos += (prev.textContent || '').length;
50
54
  } else if (prev) {
51
55
  if (isNodeInlineMark(prev) && prev.textContent) {
@@ -62,7 +66,7 @@ function isRoot(element) {
62
66
  return !!element && element.classList.contains('ak-renderer-document');
63
67
  }
64
68
  export function resolvePos(node, offset) {
65
- // If the passed node doesnt exist, we should abort
69
+ // If the passed node doesn't exist, we should abort
66
70
  if (!node) {
67
71
  return false;
68
72
  }
@@ -80,12 +84,12 @@ export function resolvePos(node, offset) {
80
84
  let current = node;
81
85
  if (current.parentElement && current.parentElement !== parent) {
82
86
  // Find the parent element that is a direct child of the position pointer
83
- // the outter most element from our text position.
87
+ // the outer most element from our text position.
84
88
  const preParentPointer = findParentBeforePointer(current.parentElement);
85
89
  // If our range is inside an inline node
86
90
  // We need to move our pointers to parent element
87
- // since we dont want to count text inside inline nodes at all
88
- if (!isElementInlineMark(preParentPointer)) {
91
+ // since we don't want to count text inside inline nodes at all
92
+ if (!(isElementInlineMark(preParentPointer) || isHighlightTextNode(preParentPointer))) {
89
93
  current = current.parentElement;
90
94
  offset = 0;
91
95
  }
@@ -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.1";
39
+ const packageVersion = "109.12.3";
40
40
  export class Renderer extends PureComponent {
41
41
  constructor(props) {
42
42
  super(props);
@@ -8,13 +8,13 @@ import { splitText, calcTextSplitOffset, findTextString } from './text';
8
8
  import { calcInsertDraftPositionOnText } from './position';
9
9
  import { dataAttributes } from './dom';
10
10
  import { AnnotationSharedCSSByState } from '@atlaskit/editor-common/styles';
11
- const markStyles = () => css`
12
- color: inherit;
13
- background-color: unset;
14
- -webkit-tap-highlight-color: transparent;
15
-
16
- ${AnnotationSharedCSSByState().focus};
17
- `;
11
+ import { segmentText } from '../../../react/utils/segment-text';
12
+ import { renderTextSegments } from '../../../react/utils/render-text-segments';
13
+ const markStyles = () => css({
14
+ color: 'inherit',
15
+ backgroundColor: 'unset',
16
+ WebkitTapHighlightColor: 'transparent'
17
+ }, AnnotationSharedCSSByState().focus);
18
18
  export const AnnotationDraft = ({
19
19
  draftPosition,
20
20
  children
@@ -40,25 +40,30 @@ export const getAnnotationIndex = (annotationPosition, fragmentCount) => {
40
40
  export const applyAnnotationOnText = ({
41
41
  texts,
42
42
  shouldApplyAnnotationAt,
43
- draftPosition
43
+ draftPosition,
44
+ textHighlighter,
45
+ marks
44
46
  }) => {
45
47
  const annotateIndex = getAnnotationIndex(shouldApplyAnnotationAt, texts.length);
46
48
  return texts.map((value, index) => {
49
+ const segments = segmentText(value, textHighlighter);
47
50
  if (annotateIndex === index) {
48
51
  return jsx(AnnotationDraft, {
49
52
  key: index,
50
53
  draftPosition: draftPosition
51
- }, value);
54
+ }, renderTextSegments(segments, textHighlighter, marks || [], draftPosition.from));
52
55
  }
53
56
  return jsx(React.Fragment, {
54
57
  key: index
55
- }, value);
58
+ }, renderTextSegments(segments, textHighlighter, marks || [], draftPosition.from));
56
59
  });
57
60
  };
58
61
  export const TextWithAnnotationDraft = ({
59
62
  startPos,
60
63
  endPos,
61
- children
64
+ children,
65
+ textHighlighter,
66
+ marks
62
67
  }) => {
63
68
  const textPosition = React.useMemo(() => ({
64
69
  start: startPos,
@@ -71,28 +76,33 @@ export const TextWithAnnotationDraft = ({
71
76
  }
72
77
  return calcInsertDraftPositionOnText(textPosition, nextDraftPosition);
73
78
  }, [nextDraftPosition, textPosition]);
74
- if (shouldApplyAnnotationAt === false || !nextDraftPosition) {
79
+ const textString = findTextString(children);
80
+ if (!textString) {
75
81
  return jsx(Fragment, null, children);
76
82
  }
83
+ if (shouldApplyAnnotationAt === false || !nextDraftPosition) {
84
+ const segments = segmentText(textString, textHighlighter);
85
+ return jsx(Fragment, null, renderTextSegments(segments, textHighlighter, marks || [], startPos));
86
+ }
77
87
  if (shouldApplyAnnotationAt === InsertDraftPosition.AROUND_TEXT) {
88
+ const segments = segmentText(textString, textHighlighter);
78
89
  return jsx(AnnotationDraft, {
79
90
  key: 0,
80
91
  draftPosition: nextDraftPosition
81
- }, children);
82
- }
83
- const textString = findTextString(children);
84
- if (!textString) {
85
- return jsx(Fragment, null, children);
92
+ }, renderTextSegments(segments, textHighlighter, marks || [], startPos));
86
93
  }
87
94
  const offsets = calcTextSplitOffset(nextDraftPosition, textPosition, textString);
88
95
  const texts = splitText(textString, offsets);
89
96
  if (!texts) {
90
- return jsx(Fragment, null, children);
97
+ const segments = segmentText(textString, textHighlighter);
98
+ return jsx(Fragment, null, renderTextSegments(segments, textHighlighter, marks || [], startPos));
91
99
  }
92
100
  const components = applyAnnotationOnText({
93
101
  texts,
94
102
  shouldApplyAnnotationAt,
95
- draftPosition: nextDraftPosition
103
+ draftPosition: nextDraftPosition,
104
+ textHighlighter,
105
+ marks
96
106
  });
97
107
  return jsx(Fragment, null, components);
98
108
  };
@@ -20,6 +20,7 @@ import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
20
20
  import { insideBlockNode, insideBreakoutLayout, insideMultiBodiedExtension } from './renderer-node';
21
21
  import { isCodeMark } from './marks/code';
22
22
  import { segmentText } from './utils/segment-text';
23
+ import { renderTextSegments } from './utils/render-text-segments';
23
24
  function mergeMarks(marksAndNodes) {
24
25
  return marksAndNodes.reduce(function (acc, markOrNode) {
25
26
  var prev = acc.length && acc[acc.length - 1] || null;
@@ -297,7 +298,6 @@ var ReactSerializer = /*#__PURE__*/function () {
297
298
  var markKey = "".concat(mark.type.name, "-component__").concat(this.startPos, "__").concat(parentMark.path.length);
298
299
  return this.renderMark(markToReact(mark), this.getMarkProps(mark, parentMark.path), markKey, content);
299
300
  }
300
- var segments = segmentText(mark.text, this.textHighlighter);
301
301
  var startPos = this.startPos;
302
302
  var endPos = startPos + mark.nodeSize;
303
303
  this.startPos = endPos;
@@ -307,37 +307,13 @@ var ReactSerializer = /*#__PURE__*/function () {
307
307
  return /*#__PURE__*/React.createElement(TextWrapperComponent, {
308
308
  key: textKey,
309
309
  startPos: startPos + parentDepth,
310
- endPos: endPos + parentDepth
311
- }, this.renderTextSegments(segments, textKey, mark));
310
+ endPos: endPos + parentDepth,
311
+ textHighlighter: this.textHighlighter,
312
+ marks: mark.marks
313
+ }, mark.text);
312
314
  }
313
- return this.renderTextSegments(segments, textKey, mark);
314
- }
315
- }, {
316
- key: "renderTextSegments",
317
- value: function renderTextSegments(segments, key, text) {
318
- var _this$textHighlighter;
319
- var Component = (_this$textHighlighter = this.textHighlighter) === null || _this$textHighlighter === void 0 ? void 0 : _this$textHighlighter.component;
320
- var marks = new Set(text.marks.map(function (m) {
321
- return m.type.name;
322
- }));
323
- function renderSegment(segment) {
324
- var idx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
325
- if (segment.type === 'plain' || !Component) {
326
- return segment.text;
327
- }
328
- return /*#__PURE__*/React.createElement(Component, {
329
- match: segment.text,
330
- groups: segment.groups,
331
- marks: marks,
332
- key: "".concat(segment.text, "_").concat(idx)
333
- }, segment.text);
334
- }
335
- if (segments.length === 1) {
336
- return renderSegment(segments[0]);
337
- }
338
- return /*#__PURE__*/React.createElement(React.Fragment, {
339
- key: key
340
- }, segments.map(renderSegment));
315
+ var segments = segmentText(mark.text, this.textHighlighter);
316
+ return renderTextSegments(segments, this.textHighlighter, mark.marks, startPos);
341
317
  }
342
318
  }, {
343
319
  key: "renderNode",
@@ -9,7 +9,9 @@ var TextWrapper = function TextWrapper(props) {
9
9
  }
10
10
  return /*#__PURE__*/React.createElement(TextWithAnnotationDraft, {
11
11
  startPos: startPos,
12
- endPos: endPos
12
+ endPos: endPos,
13
+ textHighlighter: props.textHighlighter,
14
+ marks: props.marks
13
15
  }, children);
14
16
  };
15
17
  export default TextWrapper;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ export function renderTextSegments(segments, textHighlighter, marksList, startPos) {
3
+ var Component = textHighlighter === null || textHighlighter === void 0 ? void 0 : textHighlighter.component;
4
+ var marks = new Set(marksList.map(function (m) {
5
+ return m.type.name;
6
+ }));
7
+ function renderSegment(segment) {
8
+ var idx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
9
+ if (segment.type === 'plain' || !Component) {
10
+ return segment.text;
11
+ }
12
+ return /*#__PURE__*/React.createElement("span", {
13
+ "data-highlighted": true
14
+ }, /*#__PURE__*/React.createElement(Component, {
15
+ match: segment.text,
16
+ groups: segment.groups,
17
+ marks: marks,
18
+ key: "".concat(segment.text, "_").concat(startPos, "_").concat(idx),
19
+ startPos: startPos + idx
20
+ }, segment.text));
21
+ }
22
+ if (segments.length === 1) {
23
+ return renderSegment(segments[0]);
24
+ }
25
+ return /*#__PURE__*/React.createElement(React.Fragment, {
26
+ key: "text-wrapper_".concat(startPos)
27
+ }, segments.map(renderSegment));
28
+ }
@@ -40,7 +40,7 @@ export function segmentText(text, highlighter) {
40
40
  } finally {
41
41
  _iterator.f();
42
42
  }
43
- if (pos < text.length - 1) {
43
+ if (pos < text.length) {
44
44
  segments.push({
45
45
  type: 'plain',
46
46
  text: text.substring(pos)
@@ -31,6 +31,10 @@ function isElementNode(node) {
31
31
  function isTextNode(node) {
32
32
  return node.nodeType === Node.TEXT_NODE;
33
33
  }
34
+ function isHighlightTextNode(node) {
35
+ var _dataset;
36
+ return !!(node !== null && node !== void 0 && (_dataset = node.dataset) !== null && _dataset !== void 0 && _dataset.highlighted);
37
+ }
34
38
  function isNodeInlineMark(node) {
35
39
  return isElementNode(node) && Boolean(node.dataset.rendererMark);
36
40
  }
@@ -41,7 +45,7 @@ function resolveNodePos(node) {
41
45
  var resolvedPos = 0;
42
46
  var prev = node.previousSibling;
43
47
  while (prev) {
44
- if (prev && isTextNode(prev)) {
48
+ if (prev && (isTextNode(prev) || isHighlightTextNode(prev))) {
45
49
  resolvedPos += (prev.textContent || '').length;
46
50
  } else if (prev) {
47
51
  if (isNodeInlineMark(prev) && prev.textContent) {
@@ -58,7 +62,7 @@ function isRoot(element) {
58
62
  return !!element && element.classList.contains('ak-renderer-document');
59
63
  }
60
64
  export function resolvePos(node, offset) {
61
- // If the passed node doesnt exist, we should abort
65
+ // If the passed node doesn't exist, we should abort
62
66
  if (!node) {
63
67
  return false;
64
68
  }
@@ -76,12 +80,12 @@ export function resolvePos(node, offset) {
76
80
  var current = node;
77
81
  if (current.parentElement && current.parentElement !== parent) {
78
82
  // Find the parent element that is a direct child of the position pointer
79
- // the outter most element from our text position.
83
+ // the outer most element from our text position.
80
84
  var preParentPointer = findParentBeforePointer(current.parentElement);
81
85
  // If our range is inside an inline node
82
86
  // We need to move our pointers to parent element
83
- // since we dont want to count text inside inline nodes at all
84
- if (!isElementInlineMark(preParentPointer)) {
87
+ // since we don't want to count text inside inline nodes at all
88
+ if (!(isElementInlineMark(preParentPointer) || isHighlightTextNode(preParentPointer))) {
85
89
  current = current.parentElement;
86
90
  offset = 0;
87
91
  }
@@ -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.1";
49
+ var packageVersion = "109.12.3";
50
50
  export var Renderer = /*#__PURE__*/function (_PureComponent) {
51
51
  _inherits(Renderer, _PureComponent);
52
52
  var _super = _createSuper(Renderer);
@@ -1,6 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
3
- var _templateObject;
4
2
  /** @jsx jsx */
5
3
  import React, { Fragment } from 'react';
6
4
  import { css, jsx } from '@emotion/react';
@@ -10,8 +8,14 @@ import { splitText, calcTextSplitOffset, findTextString } from './text';
10
8
  import { calcInsertDraftPositionOnText } from './position';
11
9
  import { dataAttributes } from './dom';
12
10
  import { AnnotationSharedCSSByState } from '@atlaskit/editor-common/styles';
11
+ import { segmentText } from '../../../react/utils/segment-text';
12
+ import { renderTextSegments } from '../../../react/utils/render-text-segments';
13
13
  var markStyles = function markStyles() {
14
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: inherit;\n background-color: unset;\n -webkit-tap-highlight-color: transparent;\n\n ", ";\n"])), AnnotationSharedCSSByState().focus);
14
+ return css({
15
+ color: 'inherit',
16
+ backgroundColor: 'unset',
17
+ WebkitTapHighlightColor: 'transparent'
18
+ }, AnnotationSharedCSSByState().focus);
15
19
  };
16
20
  export var AnnotationDraft = function AnnotationDraft(_ref) {
17
21
  var draftPosition = _ref.draftPosition,
@@ -37,24 +41,29 @@ export var getAnnotationIndex = function getAnnotationIndex(annotationPosition,
37
41
  export var applyAnnotationOnText = function applyAnnotationOnText(_ref2) {
38
42
  var texts = _ref2.texts,
39
43
  shouldApplyAnnotationAt = _ref2.shouldApplyAnnotationAt,
40
- draftPosition = _ref2.draftPosition;
44
+ draftPosition = _ref2.draftPosition,
45
+ textHighlighter = _ref2.textHighlighter,
46
+ marks = _ref2.marks;
41
47
  var annotateIndex = getAnnotationIndex(shouldApplyAnnotationAt, texts.length);
42
48
  return texts.map(function (value, index) {
49
+ var segments = segmentText(value, textHighlighter);
43
50
  if (annotateIndex === index) {
44
51
  return jsx(AnnotationDraft, {
45
52
  key: index,
46
53
  draftPosition: draftPosition
47
- }, value);
54
+ }, renderTextSegments(segments, textHighlighter, marks || [], draftPosition.from));
48
55
  }
49
56
  return jsx(React.Fragment, {
50
57
  key: index
51
- }, value);
58
+ }, renderTextSegments(segments, textHighlighter, marks || [], draftPosition.from));
52
59
  });
53
60
  };
54
61
  export var TextWithAnnotationDraft = function TextWithAnnotationDraft(_ref3) {
55
62
  var startPos = _ref3.startPos,
56
63
  endPos = _ref3.endPos,
57
- children = _ref3.children;
64
+ children = _ref3.children,
65
+ textHighlighter = _ref3.textHighlighter,
66
+ marks = _ref3.marks;
58
67
  var textPosition = React.useMemo(function () {
59
68
  return {
60
69
  start: startPos,
@@ -68,28 +77,33 @@ export var TextWithAnnotationDraft = function TextWithAnnotationDraft(_ref3) {
68
77
  }
69
78
  return calcInsertDraftPositionOnText(textPosition, nextDraftPosition);
70
79
  }, [nextDraftPosition, textPosition]);
71
- if (shouldApplyAnnotationAt === false || !nextDraftPosition) {
80
+ var textString = findTextString(children);
81
+ if (!textString) {
72
82
  return jsx(Fragment, null, children);
73
83
  }
84
+ if (shouldApplyAnnotationAt === false || !nextDraftPosition) {
85
+ var segments = segmentText(textString, textHighlighter);
86
+ return jsx(Fragment, null, renderTextSegments(segments, textHighlighter, marks || [], startPos));
87
+ }
74
88
  if (shouldApplyAnnotationAt === InsertDraftPosition.AROUND_TEXT) {
89
+ var _segments = segmentText(textString, textHighlighter);
75
90
  return jsx(AnnotationDraft, {
76
91
  key: 0,
77
92
  draftPosition: nextDraftPosition
78
- }, children);
79
- }
80
- var textString = findTextString(children);
81
- if (!textString) {
82
- return jsx(Fragment, null, children);
93
+ }, renderTextSegments(_segments, textHighlighter, marks || [], startPos));
83
94
  }
84
95
  var offsets = calcTextSplitOffset(nextDraftPosition, textPosition, textString);
85
96
  var texts = splitText(textString, offsets);
86
97
  if (!texts) {
87
- return jsx(Fragment, null, children);
98
+ var _segments2 = segmentText(textString, textHighlighter);
99
+ return jsx(Fragment, null, renderTextSegments(_segments2, textHighlighter, marks || [], startPos));
88
100
  }
89
101
  var components = applyAnnotationOnText({
90
102
  texts: texts,
91
103
  shouldApplyAnnotationAt: shouldApplyAnnotationAt,
92
- draftPosition: nextDraftPosition
104
+ draftPosition: nextDraftPosition,
105
+ textHighlighter: textHighlighter,
106
+ marks: marks
93
107
  });
94
108
  return jsx(Fragment, null, components);
95
109
  };
@@ -96,7 +96,6 @@ export default class ReactSerializer implements Serializer<JSX.Element> {
96
96
  private withMediaMarkProps;
97
97
  private serializeTextWrapper;
98
98
  private serializeMark;
99
- private renderTextSegments;
100
99
  private renderNode;
101
100
  private renderMark;
102
101
  private getTableChildrenProps;
@@ -1,8 +1,12 @@
1
- import { ReactNode } from 'react';
1
+ import type { ReactNode } from 'react';
2
+ import type { TextHighlighter } from '../types';
3
+ import type { Mark } from '@atlaskit/editor-prosemirror/model';
2
4
  type Props = {
3
5
  startPos: number;
4
6
  endPos: number;
5
7
  children?: ReactNode | null;
8
+ textHighlighter?: TextHighlighter;
9
+ marks?: readonly Mark[];
6
10
  };
7
11
  declare const TextWrapper: (props: Props) => JSX.Element | null;
8
12
  export default TextWrapper;
@@ -64,5 +64,6 @@ export type TextHighlighter = {
64
64
  match: string;
65
65
  marks: Set<string>;
66
66
  groups: Array<string> | undefined;
67
+ startPos: number;
67
68
  }>;
68
69
  };
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import type { Mark } from '@atlaskit/editor-prosemirror/model';
3
+ import type { TextSegment } from './segment-text';
4
+ import type { TextHighlighter } from '../types';
5
+ export declare function renderTextSegments(segments: Array<TextSegment>, textHighlighter: TextHighlighter | undefined, marksList: readonly Mark[], startPos: number): string | JSX.Element;
@@ -1,4 +1,4 @@
1
- import { Schema } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
3
3
  export declare function resolvePos(node: Node | null, offset: number): number | false;
4
4
  interface AnnotationStepOptions {
@@ -3,6 +3,8 @@ import React from 'react';
3
3
  import { jsx } from '@emotion/react';
4
4
  import type { Position } from '../types';
5
5
  import { InsertDraftPosition } from '../types';
6
+ import type { Mark } from '@atlaskit/editor-prosemirror/model';
7
+ import type { TextHighlighter } from '../../../react/types';
6
8
  export declare const AnnotationDraft: ({ draftPosition, children, }: React.PropsWithChildren<{
7
9
  draftPosition: Position;
8
10
  }>) => jsx.JSX.Element;
@@ -10,12 +12,16 @@ type ApplyAnnotationsProps = {
10
12
  texts: string[];
11
13
  shouldApplyAnnotationAt: InsertDraftPosition.INSIDE | InsertDraftPosition.START | InsertDraftPosition.END;
12
14
  draftPosition: Position;
15
+ textHighlighter?: TextHighlighter;
16
+ marks?: readonly Mark[];
13
17
  };
14
18
  export declare const getAnnotationIndex: (annotationPosition: InsertDraftPosition, fragmentCount: number) => number;
15
- export declare const applyAnnotationOnText: ({ texts, shouldApplyAnnotationAt, draftPosition, }: ApplyAnnotationsProps) => JSX.Element[];
19
+ export declare const applyAnnotationOnText: ({ texts, shouldApplyAnnotationAt, draftPosition, textHighlighter, marks, }: ApplyAnnotationsProps) => JSX.Element[];
16
20
  type Props = React.PropsWithChildren<{
17
21
  startPos: number;
18
22
  endPos: number;
23
+ textHighlighter?: TextHighlighter;
24
+ marks?: readonly Mark[];
19
25
  }>;
20
- export declare const TextWithAnnotationDraft: ({ startPos, endPos, children, }: Props) => jsx.JSX.Element;
26
+ export declare const TextWithAnnotationDraft: ({ startPos, endPos, children, textHighlighter, marks, }: Props) => jsx.JSX.Element;
21
27
  export {};
@@ -96,7 +96,6 @@ export default class ReactSerializer implements Serializer<JSX.Element> {
96
96
  private withMediaMarkProps;
97
97
  private serializeTextWrapper;
98
98
  private serializeMark;
99
- private renderTextSegments;
100
99
  private renderNode;
101
100
  private renderMark;
102
101
  private getTableChildrenProps;
@@ -1,8 +1,12 @@
1
- import { ReactNode } from 'react';
1
+ import type { ReactNode } from 'react';
2
+ import type { TextHighlighter } from '../types';
3
+ import type { Mark } from '@atlaskit/editor-prosemirror/model';
2
4
  type Props = {
3
5
  startPos: number;
4
6
  endPos: number;
5
7
  children?: ReactNode | null;
8
+ textHighlighter?: TextHighlighter;
9
+ marks?: readonly Mark[];
6
10
  };
7
11
  declare const TextWrapper: (props: Props) => JSX.Element | null;
8
12
  export default TextWrapper;
@@ -64,5 +64,6 @@ export type TextHighlighter = {
64
64
  match: string;
65
65
  marks: Set<string>;
66
66
  groups: Array<string> | undefined;
67
+ startPos: number;
67
68
  }>;
68
69
  };
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import type { Mark } from '@atlaskit/editor-prosemirror/model';
3
+ import type { TextSegment } from './segment-text';
4
+ import type { TextHighlighter } from '../types';
5
+ export declare function renderTextSegments(segments: Array<TextSegment>, textHighlighter: TextHighlighter | undefined, marksList: readonly Mark[], startPos: number): string | JSX.Element;
@@ -1,4 +1,4 @@
1
- import { Schema } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
3
3
  export declare function resolvePos(node: Node | null, offset: number): number | false;
4
4
  interface AnnotationStepOptions {
@@ -3,6 +3,8 @@ import React from 'react';
3
3
  import { jsx } from '@emotion/react';
4
4
  import type { Position } from '../types';
5
5
  import { InsertDraftPosition } from '../types';
6
+ import type { Mark } from '@atlaskit/editor-prosemirror/model';
7
+ import type { TextHighlighter } from '../../../react/types';
6
8
  export declare const AnnotationDraft: ({ draftPosition, children, }: React.PropsWithChildren<{
7
9
  draftPosition: Position;
8
10
  }>) => jsx.JSX.Element;
@@ -10,12 +12,16 @@ type ApplyAnnotationsProps = {
10
12
  texts: string[];
11
13
  shouldApplyAnnotationAt: InsertDraftPosition.INSIDE | InsertDraftPosition.START | InsertDraftPosition.END;
12
14
  draftPosition: Position;
15
+ textHighlighter?: TextHighlighter;
16
+ marks?: readonly Mark[];
13
17
  };
14
18
  export declare const getAnnotationIndex: (annotationPosition: InsertDraftPosition, fragmentCount: number) => number;
15
- export declare const applyAnnotationOnText: ({ texts, shouldApplyAnnotationAt, draftPosition, }: ApplyAnnotationsProps) => JSX.Element[];
19
+ export declare const applyAnnotationOnText: ({ texts, shouldApplyAnnotationAt, draftPosition, textHighlighter, marks, }: ApplyAnnotationsProps) => JSX.Element[];
16
20
  type Props = React.PropsWithChildren<{
17
21
  startPos: number;
18
22
  endPos: number;
23
+ textHighlighter?: TextHighlighter;
24
+ marks?: readonly Mark[];
19
25
  }>;
20
- export declare const TextWithAnnotationDraft: ({ startPos, endPos, children, }: Props) => jsx.JSX.Element;
26
+ export declare const TextWithAnnotationDraft: ({ startPos, endPos, children, textHighlighter, marks, }: Props) => jsx.JSX.Element;
21
27
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "109.12.1",
3
+ "version": "109.12.3",
4
4
  "description": "Renderer component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"