@atlaskit/renderer 109.12.0 → 109.12.2

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 +9 -29
  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 +3 -3
  6. package/dist/cjs/steps/index.js +5 -1
  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 +9 -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 +3 -3
  13. package/dist/es2019/steps/index.js +5 -1
  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 +9 -29
  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 +3 -3
  20. package/dist/esm/steps/index.js +5 -1
  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 +2 -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 +2 -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.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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
8
+
9
+ ## 109.12.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#85780](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/85780) [`f9127d5f97ed`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f9127d5f97ed) - Add marks to TextHighlighter component
14
+
3
15
  ## 109.12.0
4
16
 
5
17
  ### Minor 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,33 +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));
319
- }
320
- return this.renderTextSegments(segments, textKey);
321
- }
322
- }, {
323
- key: "renderTextSegments",
324
- value: function renderTextSegments(segments, key) {
325
- var _this$textHighlighter;
326
- var Component = (_this$textHighlighter = this.textHighlighter) === null || _this$textHighlighter === void 0 ? void 0 : _this$textHighlighter.component;
327
- function renderSegment(segment) {
328
- var idx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
329
- if (segment.type === 'plain' || !Component) {
330
- return segment.text;
331
- }
332
- return /*#__PURE__*/_react.default.createElement(Component, {
333
- match: segment.text,
334
- groups: segment.groups,
335
- key: "".concat(segment.text, "_").concat(idx)
336
- }, segment.text);
337
- }
338
- if (segments.length === 1) {
339
- return renderSegment(segments[0]);
317
+ endPos: endPos + parentDepth,
318
+ textHighlighter: this.textHighlighter,
319
+ marks: mark.marks
320
+ }, mark.text);
340
321
  }
341
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
342
- key: key
343
- }, segments.map(renderSegment));
322
+ var segments = (0, _segmentText.segmentText)(mark.text, this.textHighlighter);
323
+ return (0, _renderTextSegments.renderTextSegments)(segments, this.textHighlighter, mark.marks, startPos);
344
324
  }
345
325
  }, {
346
326
  key: "renderNode",
@@ -370,14 +350,14 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
370
350
  // TODO: https://product-fabric.atlassian.net/browse/CEMS-1048
371
351
  var stickyHeaders = !(0, _rendererNode.insideBreakoutLayout)(path) ? this.stickyHeaders : undefined;
372
352
  var isInsideOfBlockNode = (0, _rendererNode.insideBlockNode)(path, node.type.schema);
373
- var isinsideMultiBodiedExtension = (0, _rendererNode.insideMultiBodiedExtension)(path, node.type.schema);
353
+ var isInsideMultiBodiedExtension = (0, _rendererNode.insideMultiBodiedExtension)(path, node.type.schema);
374
354
  return _objectSpread(_objectSpread({}, this.getProps(node)), {}, {
375
355
  allowColumnSorting: this.allowColumnSorting,
376
356
  columnWidths: (0, _utils.calcTableColumnWidths)(node),
377
357
  tableNode: node,
378
358
  stickyHeaders: stickyHeaders,
379
359
  isInsideOfBlockNode: isInsideOfBlockNode,
380
- isinsideMultiBodiedExtension: isinsideMultiBodiedExtension
360
+ isInsideMultiBodiedExtension: isInsideMultiBodiedExtension
381
361
  });
382
362
  }
383
363
  }, {
@@ -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
+ }
@@ -17,8 +17,8 @@ function segmentText(text, highlighter) {
17
17
  var segments = [];
18
18
  var pos = 0;
19
19
  try {
20
- var markTextSeggmentMatches = text.matchAll(highlighter.pattern);
21
- var _iterator = _createForOfIteratorHelper(markTextSeggmentMatches),
20
+ var markTextSegmentMatches = text.matchAll(highlighter.pattern);
21
+ var _iterator = _createForOfIteratorHelper(markTextSegmentMatches),
22
22
  _step;
23
23
  try {
24
24
  var _loop = function _loop() {
@@ -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 !!((_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) {
@@ -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.0";
58
+ var packageVersion = "109.12.2";
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,30 +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));
287
- }
288
- return this.renderTextSegments(segments, textKey);
289
- }
290
- renderTextSegments(segments, key) {
291
- var _this$textHighlighter;
292
- const Component = (_this$textHighlighter = this.textHighlighter) === null || _this$textHighlighter === void 0 ? void 0 : _this$textHighlighter.component;
293
- function renderSegment(segment, idx = 0) {
294
- if (segment.type === 'plain' || !Component) {
295
- return segment.text;
296
- }
297
- return /*#__PURE__*/React.createElement(Component, {
298
- match: segment.text,
299
- groups: segment.groups,
300
- key: `${segment.text}_${idx}`
301
- }, segment.text);
285
+ endPos: endPos + parentDepth,
286
+ textHighlighter: this.textHighlighter,
287
+ marks: mark.marks
288
+ }, mark.text);
302
289
  }
303
- if (segments.length === 1) {
304
- return renderSegment(segments[0]);
305
- }
306
- return /*#__PURE__*/React.createElement(React.Fragment, {
307
- key: key
308
- }, segments.map(renderSegment));
290
+ const segments = segmentText(mark.text, this.textHighlighter);
291
+ return renderTextSegments(segments, this.textHighlighter, mark.marks, startPos);
309
292
  }
310
293
  renderNode(NodeComponent, props, key, content) {
311
294
  return /*#__PURE__*/React.createElement(NodeComponent, _extends({
@@ -327,7 +310,7 @@ export default class ReactSerializer {
327
310
  // TODO: https://product-fabric.atlassian.net/browse/CEMS-1048
328
311
  const stickyHeaders = !insideBreakoutLayout(path) ? this.stickyHeaders : undefined;
329
312
  const isInsideOfBlockNode = insideBlockNode(path, node.type.schema);
330
- const isinsideMultiBodiedExtension = insideMultiBodiedExtension(path, node.type.schema);
313
+ const isInsideMultiBodiedExtension = insideMultiBodiedExtension(path, node.type.schema);
331
314
  return {
332
315
  ...this.getProps(node),
333
316
  allowColumnSorting: this.allowColumnSorting,
@@ -335,7 +318,7 @@ export default class ReactSerializer {
335
318
  tableNode: node,
336
319
  stickyHeaders,
337
320
  isInsideOfBlockNode,
338
- isinsideMultiBodiedExtension
321
+ isInsideMultiBodiedExtension
339
322
  };
340
323
  }
341
324
  getDateProps(node, parentInfo) {
@@ -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
+ }
@@ -8,8 +8,8 @@ export function segmentText(text, highlighter) {
8
8
  const segments = [];
9
9
  let pos = 0;
10
10
  try {
11
- const markTextSeggmentMatches = text.matchAll(highlighter.pattern);
12
- for (const markTextMatch of markTextSeggmentMatches) {
11
+ const markTextSegmentMatches = text.matchAll(highlighter.pattern);
12
+ for (const markTextMatch of markTextSegmentMatches) {
13
13
  if (markTextMatch.index !== 0) {
14
14
  segments.push({
15
15
  type: 'plain',
@@ -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 !!((_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) {
@@ -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.0";
39
+ const packageVersion = "109.12.2";
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,33 +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));
312
- }
313
- return this.renderTextSegments(segments, textKey);
314
- }
315
- }, {
316
- key: "renderTextSegments",
317
- value: function renderTextSegments(segments, key) {
318
- var _this$textHighlighter;
319
- var Component = (_this$textHighlighter = this.textHighlighter) === null || _this$textHighlighter === void 0 ? void 0 : _this$textHighlighter.component;
320
- function renderSegment(segment) {
321
- var idx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
322
- if (segment.type === 'plain' || !Component) {
323
- return segment.text;
324
- }
325
- return /*#__PURE__*/React.createElement(Component, {
326
- match: segment.text,
327
- groups: segment.groups,
328
- key: "".concat(segment.text, "_").concat(idx)
329
- }, segment.text);
330
- }
331
- if (segments.length === 1) {
332
- return renderSegment(segments[0]);
310
+ endPos: endPos + parentDepth,
311
+ textHighlighter: this.textHighlighter,
312
+ marks: mark.marks
313
+ }, mark.text);
333
314
  }
334
- return /*#__PURE__*/React.createElement(React.Fragment, {
335
- key: key
336
- }, segments.map(renderSegment));
315
+ var segments = segmentText(mark.text, this.textHighlighter);
316
+ return renderTextSegments(segments, this.textHighlighter, mark.marks, startPos);
337
317
  }
338
318
  }, {
339
319
  key: "renderNode",
@@ -363,14 +343,14 @@ var ReactSerializer = /*#__PURE__*/function () {
363
343
  // TODO: https://product-fabric.atlassian.net/browse/CEMS-1048
364
344
  var stickyHeaders = !insideBreakoutLayout(path) ? this.stickyHeaders : undefined;
365
345
  var isInsideOfBlockNode = insideBlockNode(path, node.type.schema);
366
- var isinsideMultiBodiedExtension = insideMultiBodiedExtension(path, node.type.schema);
346
+ var isInsideMultiBodiedExtension = insideMultiBodiedExtension(path, node.type.schema);
367
347
  return _objectSpread(_objectSpread({}, this.getProps(node)), {}, {
368
348
  allowColumnSorting: this.allowColumnSorting,
369
349
  columnWidths: calcTableColumnWidths(node),
370
350
  tableNode: node,
371
351
  stickyHeaders: stickyHeaders,
372
352
  isInsideOfBlockNode: isInsideOfBlockNode,
373
- isinsideMultiBodiedExtension: isinsideMultiBodiedExtension
353
+ isInsideMultiBodiedExtension: isInsideMultiBodiedExtension
374
354
  });
375
355
  }
376
356
  }, {
@@ -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
+ }
@@ -11,8 +11,8 @@ export function segmentText(text, highlighter) {
11
11
  var segments = [];
12
12
  var pos = 0;
13
13
  try {
14
- var markTextSeggmentMatches = text.matchAll(highlighter.pattern);
15
- var _iterator = _createForOfIteratorHelper(markTextSeggmentMatches),
14
+ var markTextSegmentMatches = text.matchAll(highlighter.pattern);
15
+ var _iterator = _createForOfIteratorHelper(markTextSegmentMatches),
16
16
  _step;
17
17
  try {
18
18
  var _loop = function _loop() {
@@ -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 !!((_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) {
@@ -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.0";
49
+ var packageVersion = "109.12.2";
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;
@@ -62,6 +62,8 @@ export type TextHighlighter = {
62
62
  component: React.ComponentType<{
63
63
  children: React.ReactNode;
64
64
  match: string;
65
+ marks: Set<string>;
65
66
  groups: Array<string> | undefined;
67
+ startPos: number;
66
68
  }>;
67
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;
@@ -62,6 +62,8 @@ export type TextHighlighter = {
62
62
  component: React.ComponentType<{
63
63
  children: React.ReactNode;
64
64
  match: string;
65
+ marks: Set<string>;
65
66
  groups: Array<string> | undefined;
67
+ startPos: number;
66
68
  }>;
67
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.0",
3
+ "version": "109.12.2",
4
4
  "description": "Renderer component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"