@atlaskit/editor-plugin-find-replace 2.7.2 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/editor-plugin-find-replace
2
2
 
3
+ ## 2.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#175569](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/175569)
8
+ [`3bcbd0cff0437`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3bcbd0cff0437) -
9
+ [ux] ED-27958 extend the find algorithm to search smart cards behind
10
+ platform_editor_find_and_replace_improvements
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
3
16
  ## 2.7.2
4
17
 
5
18
  ### Patch Changes
@@ -278,10 +278,10 @@ var updateSelectedHighlight = function updateSelectedHighlight(state, nextSelect
278
278
  decorationSet = (0, _utils.removeDecorationsFromSet)(decorationSet, decorationsToRemove, state.doc);
279
279
  }
280
280
  if (currentSelectedMatch) {
281
- decorationSet = decorationSet.add(state.doc, [(0, _utils.createDecoration)(currentSelectedMatch.start, currentSelectedMatch.end)]);
281
+ decorationSet = decorationSet.add(state.doc, [(0, _utils.createDecoration)(currentSelectedMatch.start, currentSelectedMatch.end, false, (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? currentSelectedMatch.nodeType : undefined)]);
282
282
  }
283
283
  if (nextSelectedMatch) {
284
- decorationSet = decorationSet.add(state.doc, [(0, _utils.createDecoration)(nextSelectedMatch.start, nextSelectedMatch.end, true)]);
284
+ decorationSet = decorationSet.add(state.doc, [(0, _utils.createDecoration)(nextSelectedMatch.start, nextSelectedMatch.end, true, (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? nextSelectedMatch.nodeType : undefined)]);
285
285
  }
286
286
  return decorationSet;
287
287
  };
@@ -9,6 +9,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
9
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
12
13
  var _pluginFactory = require("../plugin-factory");
13
14
  var _index = require("./index");
14
15
  // max number of decorations to apply at once
@@ -248,7 +249,7 @@ var BatchDecorations = /*#__PURE__*/function () {
248
249
  return {
249
250
  viewportStartPos: viewportStartPos,
250
251
  viewportEndPos: viewportEndPos,
251
- startPos: 1,
252
+ startPos: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? 0 : 1,
252
253
  endPos: editorView.state.doc.nodeSize
253
254
  };
254
255
  }
@@ -259,7 +260,11 @@ var BatchDecorations = /*#__PURE__*/function () {
259
260
  top: y,
260
261
  left: x
261
262
  });
262
- return startPos ? startPos.pos : 1;
263
+ if ((0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
264
+ return startPos ? startPos.pos : 0;
265
+ } else {
266
+ return startPos ? startPos.pos : 1;
267
+ }
263
268
  }
264
269
  }, {
265
270
  key: "getEndPos",
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -8,12 +9,15 @@ exports.findMatches = findMatches;
8
9
  exports.findSearchIndex = findSearchIndex;
9
10
  exports.getSelectedText = getSelectedText;
10
11
  exports.removeMatchesFromSet = exports.removeDecorationsFromSet = exports.prevIndex = exports.nextIndex = exports.isMatchAffectedByStep = exports.getSelectionForMatch = void 0;
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+ var _classnames2 = _interopRequireDefault(require("classnames"));
11
14
  var _utils = require("@atlaskit/editor-common/utils");
12
15
  var _state = require("@atlaskit/editor-prosemirror/state");
13
16
  var _view = require("@atlaskit/editor-prosemirror/view");
14
17
  var _resource = require("@atlaskit/mention/resource");
15
18
  var _types = require("@atlaskit/mention/types");
16
19
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
20
+ var _tokens = require("@atlaskit/tokens");
17
21
  var _styles = require("../../ui/styles");
18
22
  function getSelectedText(selection) {
19
23
  var text = '';
@@ -26,18 +30,37 @@ function getSelectedText(selection) {
26
30
  var createDecorations = exports.createDecorations = function createDecorations(selectedIndex, matches) {
27
31
  return matches.map(function (_ref, i) {
28
32
  var start = _ref.start,
29
- end = _ref.end;
30
- return createDecoration(start, end, i === selectedIndex);
33
+ end = _ref.end,
34
+ nodeType = _ref.nodeType;
35
+ return createDecoration(start, end, i === selectedIndex, nodeType);
31
36
  });
32
37
  };
33
- var createDecoration = exports.createDecoration = function createDecoration(start, end, isSelected) {
34
- var className = _styles.searchMatchClass;
35
- if (isSelected) {
36
- className += " ".concat(_styles.selectedSearchMatchClass);
38
+ var isBlock = function isBlock(nodeType) {
39
+ return nodeType === 'blockCard' || nodeType === 'embedCard';
40
+ };
41
+ var createDecoration = exports.createDecoration = function createDecoration(start, end, isSelected, nodeType) {
42
+ if ((0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
43
+ var _getGlobalTheme = (0, _tokens.getGlobalTheme)(),
44
+ colorMode = _getGlobalTheme.colorMode;
45
+ var className = (0, _classnames2.default)(_styles.searchMatchClass, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _styles.selectedSearchMatchClass, isSelected), _styles.blockSearchMatchClass, isBlock(nodeType)), _styles.darkModeSearchMatchClass, colorMode === 'dark'));
46
+ if (isBlock(nodeType)) {
47
+ return _view.Decoration.node(start, end, {
48
+ class: className
49
+ });
50
+ } else {
51
+ return _view.Decoration.inline(start, end, {
52
+ class: className
53
+ });
54
+ }
55
+ } else {
56
+ var _className = _styles.searchMatchClass;
57
+ if (isSelected) {
58
+ _className += " ".concat(_styles.selectedSearchMatchClass);
59
+ }
60
+ return _view.Decoration.inline(start, end, {
61
+ class: _className
62
+ });
37
63
  }
38
- return _view.Decoration.inline(start, end, {
39
- class: className
40
- });
41
64
  };
42
65
  function findMatches(_ref2) {
43
66
  var content = _ref2.content,
@@ -69,7 +92,8 @@ function findMatches(_ref2) {
69
92
  matches.push({
70
93
  start: pos + index,
71
94
  end: pos + end,
72
- canReplace: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? true : undefined
95
+ canReplace: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? true : undefined,
96
+ nodeType: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? 'text' : undefined
73
97
  });
74
98
  index = text.indexOf(searchText, end);
75
99
  }
@@ -92,11 +116,12 @@ function findMatches(_ref2) {
92
116
  matches.push({
93
117
  start: start,
94
118
  end: start + nodeSize,
95
- canReplace: false
119
+ canReplace: false,
120
+ nodeType: 'status'
96
121
  });
97
122
  }
98
123
  };
99
- var collectDateOrMentionMatch = function collectDateOrMentionMatch(textGrouping, nodeSize) {
124
+ var collectNodeMatch = function collectNodeMatch(textGrouping, node) {
100
125
  if (!textGrouping) {
101
126
  return;
102
127
  }
@@ -111,11 +136,39 @@ function findMatches(_ref2) {
111
136
  var start = pos;
112
137
  matches.push({
113
138
  start: start,
114
- end: start + nodeSize,
115
- canReplace: false
139
+ end: start + node.nodeSize,
140
+ canReplace: false,
141
+ nodeType: node.type.name
116
142
  });
117
143
  }
118
144
  };
145
+ var collectCardTitleMatch = function collectCardTitleMatch(node, pos) {
146
+ var _api$card;
147
+ var cards = api === null || api === void 0 || (_api$card = api.card) === null || _api$card === void 0 || (_api$card = _api$card.sharedState.currentState()) === null || _api$card === void 0 ? void 0 : _api$card.cards;
148
+ if (cards) {
149
+ var relevantCard = cards.find(function (card) {
150
+ return card.url === node.attrs.url;
151
+ });
152
+ var title = relevantCard === null || relevantCard === void 0 ? void 0 : relevantCard.title;
153
+ if (relevantCard) {
154
+ if (title) {
155
+ collectNodeMatch({
156
+ text: title,
157
+ pos: pos
158
+ }, node);
159
+ } else {
160
+ // when there is no title, e.g. in an error case like unauthorized
161
+ // the link card just shows the entire url as the title in inline card
162
+ if (node.type.name === 'inlineCard') {
163
+ collectNodeMatch({
164
+ text: node.attrs.url,
165
+ pos: pos
166
+ }, node);
167
+ }
168
+ }
169
+ }
170
+ }
171
+ };
119
172
  if (searchTextLength > 0) {
120
173
  content.descendants(function (node, pos) {
121
174
  if (node.isText) {
@@ -139,10 +192,10 @@ function findMatches(_ref2) {
139
192
  }, node.nodeSize);
140
193
  break;
141
194
  case 'date':
142
- collectDateOrMentionMatch({
195
+ collectNodeMatch({
143
196
  text: (0, _utils.timestampToString)(node.attrs.timestamp, getIntl ? getIntl() : null),
144
197
  pos: pos
145
- }, node.nodeSize);
198
+ }, node);
146
199
  break;
147
200
  case 'mention':
148
201
  var text;
@@ -167,12 +220,17 @@ function findMatches(_ref2) {
167
220
  }
168
221
  }
169
222
  if (text) {
170
- collectDateOrMentionMatch({
223
+ collectNodeMatch({
171
224
  text: text,
172
225
  pos: pos
173
- }, node.nodeSize);
226
+ }, node);
174
227
  }
175
228
  break;
229
+ case 'inlineCard':
230
+ case 'blockCard':
231
+ case 'embedCard':
232
+ collectCardTitleMatch(node, pos);
233
+ break;
176
234
  default:
177
235
  break;
178
236
  }
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.selectedSearchMatchClass = exports.searchMatchClass = exports.findReplaceStyles = void 0;
7
+ exports.selectedSearchMatchClass = exports.searchMatchClass = exports.findReplaceStylesNew = exports.findReplaceStyles = exports.darkModeSearchMatchClass = exports.blockSearchMatchClass = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = require("@emotion/react");
10
10
  var _colors = require("@atlaskit/theme/colors");
@@ -17,10 +17,59 @@ var _colors = require("@atlaskit/theme/colors");
17
17
 
18
18
  var searchMatchClass = exports.searchMatchClass = 'search-match';
19
19
  var selectedSearchMatchClass = exports.selectedSearchMatchClass = 'selected-search-match';
20
+ var blockSearchMatchClass = exports.blockSearchMatchClass = 'search-match-block';
21
+ var darkModeSearchMatchClass = exports.darkModeSearchMatchClass = 'search-match-dark';
20
22
  var findReplaceStyles = exports.findReplaceStyles = (0, _react.css)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, ".".concat(searchMatchClass), {
21
23
  borderRadius: '3px',
22
24
  backgroundColor: "var(--ds-background-accent-teal-subtlest, #E7F9FF)",
23
25
  boxShadow: "var(--ds-shadow-raised, ".concat("0 1px 1px 0 ".concat(_colors.N50A, ", 0 0 1px 0 ").concat(_colors.N60A), ")") + ', inset 0 0 0 1px ' + "var(--ds-border-input, ".concat("".concat(_colors.N40A), ")")
24
26
  }), ".".concat(selectedSearchMatchClass), {
25
27
  backgroundColor: "var(--ds-background-accent-teal-subtle, #6CC3E0)"
28
+ }));
29
+ var findReplaceStylesNew = exports.findReplaceStylesNew = (0, _react.css)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, ".".concat(searchMatchClass), {
30
+ borderRadius: '3px',
31
+ backgroundColor: "var(--ds-background-accent-teal-subtlest, #E7F9FF)",
32
+ boxShadow: "var(--ds-shadow-raised, 0 1px 1px 0 rgba(9, 30, 66, 0.25), 0 0 1px 0 rgba(9, 30, 66, 0.31))".concat(", inset 0 0 0 1px ", "var(--ds-border-input, #8590A2)")
33
+ }), ".".concat(selectedSearchMatchClass), {
34
+ backgroundColor: "var(--ds-background-accent-teal-subtle, #6CC3E0)"
35
+ }), ".".concat(blockSearchMatchClass), {
36
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
37
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
38
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-subtler-pressed, #E2B203)", ",\n\t\t\tinset 0 0 0 5px ", "var(--ds-background-accent-yellow-subtler, #F8E6A0)", "\n\t\t\t")
39
+ }
40
+ }), ".".concat(selectedSearchMatchClass, ".").concat(blockSearchMatchClass), {
41
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
42
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
43
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-subtler-pressed, #E2B203)", ",\n\t\t\tinset 0 0 0 4px ", "var(--ds-background-accent-yellow-subtlest-pressed, #F5CD47)", "\n\t\t\t")
44
+ }
45
+ }), ".".concat(blockSearchMatchClass, ".ak-editor-selected-node"), {
46
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
47
+ '.loader-wrapper>div::after': {
48
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-subtler-pressed, #E2B203)", ",\n\t\t\tinset 0 0 0 5px ", "var(--ds-background-accent-yellow-subtler, #F8E6A0)", ",\n\t\t\t0 0 0 1px ", "var(--ds-border-selected, #0C66E4)", "\n\t\t\t")
49
+ }
50
+ }), ".".concat(selectedSearchMatchClass, ".").concat(blockSearchMatchClass, ".ak-editor-selected-node"), {
51
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
52
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
53
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-subtler-pressed, #E2B203)", ",\n\t\t\tinset 0 0 0 4px ", "var(--ds-background-accent-yellow-subtlest-pressed, #F5CD47)", ",\n\t\t\t0 0 0 1px ", "var(--ds-border-selected, #0C66E4)", "\n\t\t\t")
54
+ }
55
+ }), ".".concat(blockSearchMatchClass, ".").concat(darkModeSearchMatchClass), {
56
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
57
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
58
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-bolder, #946F00)", ",\n\t\t\tinset 0 0 0 5px ", "var(--ds-background-accent-yellow-bolder-pressed, #533F04)", "\n\t\t\t")
59
+ }
60
+ }), ".".concat(selectedSearchMatchClass, ".").concat(blockSearchMatchClass, ".").concat(darkModeSearchMatchClass), {
61
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
62
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
63
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-bolder, #946F00)", ",\n\t\t\tinset 0 0 0 4px ", "var(--ds-background-accent-yellow-bolder-hovered, #7F5F01)", "\n\t\t\t")
64
+ }
65
+ }), ".".concat(blockSearchMatchClass, ".").concat(darkModeSearchMatchClass, ".ak-editor-selected-node"), {
66
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
67
+ '.loader-wrapper>div::after': {
68
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-bolder, #946F00)", ",\n\t\t\tinset 0 0 0 5px ", "var(--ds-background-accent-yellow-bolder-pressed, #533F04)", ",\n\t\t\t0 0 0 1px ", "var(--ds-border-selected, #0C66E4)", "\n\t\t\t")
69
+ }
70
+ }), ".".concat(selectedSearchMatchClass, ".").concat(blockSearchMatchClass, ".").concat(darkModeSearchMatchClass, ".ak-editor-selected-node"), {
71
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
72
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
73
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-bolder, #946F00)", ",\n\t\t\tinset 0 0 0 4px ", "var(--ds-background-accent-yellow-bolder-hovered, #7F5F01)", ",\n\t\t\t0 0 0 1px ", "var(--ds-border-selected, #0C66E4)", "\n\t\t\t")
74
+ }
26
75
  }));
@@ -264,10 +264,10 @@ const updateSelectedHighlight = (state, nextSelectedIndex) => {
264
264
  decorationSet = removeDecorationsFromSet(decorationSet, decorationsToRemove, state.doc);
265
265
  }
266
266
  if (currentSelectedMatch) {
267
- decorationSet = decorationSet.add(state.doc, [createDecoration(currentSelectedMatch.start, currentSelectedMatch.end)]);
267
+ decorationSet = decorationSet.add(state.doc, [createDecoration(currentSelectedMatch.start, currentSelectedMatch.end, false, expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? currentSelectedMatch.nodeType : undefined)]);
268
268
  }
269
269
  if (nextSelectedMatch) {
270
- decorationSet = decorationSet.add(state.doc, [createDecoration(nextSelectedMatch.start, nextSelectedMatch.end, true)]);
270
+ decorationSet = decorationSet.add(state.doc, [createDecoration(nextSelectedMatch.start, nextSelectedMatch.end, true, expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? nextSelectedMatch.nodeType : undefined)]);
271
271
  }
272
272
  return decorationSet;
273
273
  };
@@ -1,3 +1,4 @@
1
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
1
2
  import { getPluginState } from '../plugin-factory';
2
3
  import { createDecorations, findDecorationFromMatch } from './index';
3
4
 
@@ -134,7 +135,7 @@ class BatchDecorations {
134
135
  return {
135
136
  viewportStartPos,
136
137
  viewportEndPos,
137
- startPos: 1,
138
+ startPos: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? 0 : 1,
138
139
  endPos: editorView.state.doc.nodeSize
139
140
  };
140
141
  }
@@ -143,7 +144,11 @@ class BatchDecorations {
143
144
  top: y,
144
145
  left: x
145
146
  });
146
- return startPos ? startPos.pos : 1;
147
+ if (expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
148
+ return startPos ? startPos.pos : 0;
149
+ } else {
150
+ return startPos ? startPos.pos : 1;
151
+ }
147
152
  }
148
153
  getEndPos(editorView, y, x) {
149
154
  const maxPos = editorView.state.doc.nodeSize;
@@ -1,10 +1,12 @@
1
+ import classnames from 'classnames';
1
2
  import { timestampToString } from '@atlaskit/editor-common/utils';
2
3
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
4
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
5
  import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
5
6
  import { isPromise, MentionNameStatus } from '@atlaskit/mention/types';
6
7
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
- import { searchMatchClass, selectedSearchMatchClass } from '../../ui/styles';
8
+ import { getGlobalTheme } from '@atlaskit/tokens';
9
+ import { searchMatchClass, selectedSearchMatchClass, blockSearchMatchClass, darkModeSearchMatchClass } from '../../ui/styles';
8
10
  export function getSelectedText(selection) {
9
11
  let text = '';
10
12
  const selectedContent = selection.content().content;
@@ -15,16 +17,38 @@ export function getSelectedText(selection) {
15
17
  }
16
18
  export const createDecorations = (selectedIndex, matches) => matches.map(({
17
19
  start,
18
- end
19
- }, i) => createDecoration(start, end, i === selectedIndex));
20
- export const createDecoration = (start, end, isSelected) => {
21
- let className = searchMatchClass;
22
- if (isSelected) {
23
- className += ` ${selectedSearchMatchClass}`;
20
+ end,
21
+ nodeType
22
+ }, i) => createDecoration(start, end, i === selectedIndex, nodeType));
23
+ const isBlock = nodeType => nodeType === 'blockCard' || nodeType === 'embedCard';
24
+ export const createDecoration = (start, end, isSelected, nodeType) => {
25
+ if (expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
26
+ const {
27
+ colorMode
28
+ } = getGlobalTheme();
29
+ const className = classnames(searchMatchClass, {
30
+ [selectedSearchMatchClass]: isSelected,
31
+ [blockSearchMatchClass]: isBlock(nodeType),
32
+ [darkModeSearchMatchClass]: colorMode === 'dark'
33
+ });
34
+ if (isBlock(nodeType)) {
35
+ return Decoration.node(start, end, {
36
+ class: className
37
+ });
38
+ } else {
39
+ return Decoration.inline(start, end, {
40
+ class: className
41
+ });
42
+ }
43
+ } else {
44
+ let className = searchMatchClass;
45
+ if (isSelected) {
46
+ className += ` ${selectedSearchMatchClass}`;
47
+ }
48
+ return Decoration.inline(start, end, {
49
+ class: className
50
+ });
24
51
  }
25
- return Decoration.inline(start, end, {
26
- class: className
27
- });
28
52
  };
29
53
  export function findMatches({
30
54
  content,
@@ -60,7 +84,8 @@ export function findMatches({
60
84
  matches.push({
61
85
  start: pos + index,
62
86
  end: pos + end,
63
- canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? true : undefined
87
+ canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? true : undefined,
88
+ nodeType: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? 'text' : undefined
64
89
  });
65
90
  index = text.indexOf(searchText, end);
66
91
  }
@@ -87,11 +112,12 @@ export function findMatches({
87
112
  matches.push({
88
113
  start,
89
114
  end: start + nodeSize,
90
- canReplace: false
115
+ canReplace: false,
116
+ nodeType: 'status'
91
117
  });
92
118
  }
93
119
  };
94
- const collectDateOrMentionMatch = (textGrouping, nodeSize) => {
120
+ const collectNodeMatch = (textGrouping, node) => {
95
121
  if (!textGrouping) {
96
122
  return;
97
123
  }
@@ -110,11 +136,37 @@ export function findMatches({
110
136
  const start = pos;
111
137
  matches.push({
112
138
  start,
113
- end: start + nodeSize,
114
- canReplace: false
139
+ end: start + node.nodeSize,
140
+ canReplace: false,
141
+ nodeType: node.type.name
115
142
  });
116
143
  }
117
144
  };
145
+ const collectCardTitleMatch = (node, pos) => {
146
+ var _api$card, _api$card$sharedState;
147
+ const cards = api === null || api === void 0 ? void 0 : (_api$card = api.card) === null || _api$card === void 0 ? void 0 : (_api$card$sharedState = _api$card.sharedState.currentState()) === null || _api$card$sharedState === void 0 ? void 0 : _api$card$sharedState.cards;
148
+ if (cards) {
149
+ const relevantCard = cards.find(card => card.url === node.attrs.url);
150
+ const title = relevantCard === null || relevantCard === void 0 ? void 0 : relevantCard.title;
151
+ if (relevantCard) {
152
+ if (title) {
153
+ collectNodeMatch({
154
+ text: title,
155
+ pos
156
+ }, node);
157
+ } else {
158
+ // when there is no title, e.g. in an error case like unauthorized
159
+ // the link card just shows the entire url as the title in inline card
160
+ if (node.type.name === 'inlineCard') {
161
+ collectNodeMatch({
162
+ text: node.attrs.url,
163
+ pos
164
+ }, node);
165
+ }
166
+ }
167
+ }
168
+ }
169
+ };
118
170
  if (searchTextLength > 0) {
119
171
  content.descendants((node, pos) => {
120
172
  if (node.isText) {
@@ -138,10 +190,10 @@ export function findMatches({
138
190
  }, node.nodeSize);
139
191
  break;
140
192
  case 'date':
141
- collectDateOrMentionMatch({
193
+ collectNodeMatch({
142
194
  text: timestampToString(node.attrs.timestamp, getIntl ? getIntl() : null),
143
195
  pos
144
- }, node.nodeSize);
196
+ }, node);
145
197
  break;
146
198
  case 'mention':
147
199
  let text;
@@ -166,12 +218,17 @@ export function findMatches({
166
218
  }
167
219
  }
168
220
  if (text) {
169
- collectDateOrMentionMatch({
221
+ collectNodeMatch({
170
222
  text,
171
223
  pos
172
- }, node.nodeSize);
224
+ }, node);
173
225
  }
174
226
  break;
227
+ case 'inlineCard':
228
+ case 'blockCard':
229
+ case 'embedCard':
230
+ collectCardTitleMatch(node, pos);
231
+ break;
175
232
  default:
176
233
  break;
177
234
  }
@@ -9,6 +9,8 @@ import { css } from '@emotion/react';
9
9
  import { N40A, N50A, N60A } from '@atlaskit/theme/colors';
10
10
  export const searchMatchClass = 'search-match';
11
11
  export const selectedSearchMatchClass = 'selected-search-match';
12
+ export const blockSearchMatchClass = 'search-match-block';
13
+ export const darkModeSearchMatchClass = 'search-match-dark';
12
14
  export const findReplaceStyles = css({
13
15
  [`.${searchMatchClass}`]: {
14
16
  borderRadius: '3px',
@@ -18,4 +20,101 @@ export const findReplaceStyles = css({
18
20
  [`.${selectedSearchMatchClass}`]: {
19
21
  backgroundColor: "var(--ds-background-accent-teal-subtle, #6CC3E0)"
20
22
  }
23
+ });
24
+ export const findReplaceStylesNew = css({
25
+ /** Text match styles */
26
+ [`.${searchMatchClass}`]: {
27
+ borderRadius: '3px',
28
+ backgroundColor: "var(--ds-background-accent-teal-subtlest, #E7F9FF)",
29
+ boxShadow: `${"var(--ds-shadow-raised, 0 1px 1px 0 rgba(9, 30, 66, 0.25), 0 0 1px 0 rgba(9, 30, 66, 0.31))"}, inset 0 0 0 1px ${"var(--ds-border-input, #8590A2)"}`
30
+ },
31
+ [`.${selectedSearchMatchClass}`]: {
32
+ backgroundColor: "var(--ds-background-accent-teal-subtle, #6CC3E0)"
33
+ },
34
+ /** Block match styles */
35
+
36
+ /** Light mode */
37
+
38
+ /** Without node selection */
39
+ [`.${blockSearchMatchClass}`]: {
40
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
41
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
42
+ boxShadow: `
43
+ inset 0 0 0 1px ${"var(--ds-background-accent-yellow-subtler-pressed, #E2B203)"},
44
+ inset 0 0 0 5px ${"var(--ds-background-accent-yellow-subtler, #F8E6A0)"}
45
+ `
46
+ }
47
+ },
48
+ [`.${selectedSearchMatchClass}.${blockSearchMatchClass}`]: {
49
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
50
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
51
+ boxShadow: `
52
+ inset 0 0 0 1px ${"var(--ds-background-accent-yellow-subtler-pressed, #E2B203)"},
53
+ inset 0 0 0 4px ${"var(--ds-background-accent-yellow-subtlest-pressed, #F5CD47)"}
54
+ `
55
+ }
56
+ },
57
+ /** With node selection */
58
+ [`.${blockSearchMatchClass}.ak-editor-selected-node`]: {
59
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
60
+ '.loader-wrapper>div::after': {
61
+ boxShadow: `
62
+ inset 0 0 0 1px ${"var(--ds-background-accent-yellow-subtler-pressed, #E2B203)"},
63
+ inset 0 0 0 5px ${"var(--ds-background-accent-yellow-subtler, #F8E6A0)"},
64
+ 0 0 0 1px ${"var(--ds-border-selected, #0C66E4)"}
65
+ `
66
+ }
67
+ },
68
+ [`.${selectedSearchMatchClass}.${blockSearchMatchClass}.ak-editor-selected-node`]: {
69
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
70
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
71
+ boxShadow: `
72
+ inset 0 0 0 1px ${"var(--ds-background-accent-yellow-subtler-pressed, #E2B203)"},
73
+ inset 0 0 0 4px ${"var(--ds-background-accent-yellow-subtlest-pressed, #F5CD47)"},
74
+ 0 0 0 1px ${"var(--ds-border-selected, #0C66E4)"}
75
+ `
76
+ }
77
+ },
78
+ /** Dark mode */
79
+
80
+ /** Without node selection */
81
+ [`.${blockSearchMatchClass}.${darkModeSearchMatchClass}`]: {
82
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
83
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
84
+ boxShadow: `
85
+ inset 0 0 0 1px ${"var(--ds-background-accent-yellow-bolder, #946F00)"},
86
+ inset 0 0 0 5px ${"var(--ds-background-accent-yellow-bolder-pressed, #533F04)"}
87
+ `
88
+ }
89
+ },
90
+ [`.${selectedSearchMatchClass}.${blockSearchMatchClass}.${darkModeSearchMatchClass}`]: {
91
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
92
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
93
+ boxShadow: `
94
+ inset 0 0 0 1px ${"var(--ds-background-accent-yellow-bolder, #946F00)"},
95
+ inset 0 0 0 4px ${"var(--ds-background-accent-yellow-bolder-hovered, #7F5F01)"}
96
+ `
97
+ }
98
+ },
99
+ /** With node selection */
100
+ [`.${blockSearchMatchClass}.${darkModeSearchMatchClass}.ak-editor-selected-node`]: {
101
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
102
+ '.loader-wrapper>div::after': {
103
+ boxShadow: `
104
+ inset 0 0 0 1px ${"var(--ds-background-accent-yellow-bolder, #946F00)"},
105
+ inset 0 0 0 5px ${"var(--ds-background-accent-yellow-bolder-pressed, #533F04)"},
106
+ 0 0 0 1px ${"var(--ds-border-selected, #0C66E4)"}
107
+ `
108
+ }
109
+ },
110
+ [`.${selectedSearchMatchClass}.${blockSearchMatchClass}.${darkModeSearchMatchClass}.ak-editor-selected-node`]: {
111
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
112
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
113
+ boxShadow: `
114
+ inset 0 0 0 1px ${"var(--ds-background-accent-yellow-bolder, #946F00)"},
115
+ inset 0 0 0 4px ${"var(--ds-background-accent-yellow-bolder-hovered, #7F5F01)"},
116
+ 0 0 0 1px ${"var(--ds-border-selected, #0C66E4)"}
117
+ `
118
+ }
119
+ }
21
120
  });
@@ -271,10 +271,10 @@ var updateSelectedHighlight = function updateSelectedHighlight(state, nextSelect
271
271
  decorationSet = removeDecorationsFromSet(decorationSet, decorationsToRemove, state.doc);
272
272
  }
273
273
  if (currentSelectedMatch) {
274
- decorationSet = decorationSet.add(state.doc, [createDecoration(currentSelectedMatch.start, currentSelectedMatch.end)]);
274
+ decorationSet = decorationSet.add(state.doc, [createDecoration(currentSelectedMatch.start, currentSelectedMatch.end, false, expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? currentSelectedMatch.nodeType : undefined)]);
275
275
  }
276
276
  if (nextSelectedMatch) {
277
- decorationSet = decorationSet.add(state.doc, [createDecoration(nextSelectedMatch.start, nextSelectedMatch.end, true)]);
277
+ decorationSet = decorationSet.add(state.doc, [createDecoration(nextSelectedMatch.start, nextSelectedMatch.end, true, expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? nextSelectedMatch.nodeType : undefined)]);
278
278
  }
279
279
  return decorationSet;
280
280
  };
@@ -2,6 +2,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/createClass";
4
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
6
  import { getPluginState } from '../plugin-factory';
6
7
  import { createDecorations, findDecorationFromMatch } from './index';
7
8
 
@@ -242,7 +243,7 @@ var BatchDecorations = /*#__PURE__*/function () {
242
243
  return {
243
244
  viewportStartPos: viewportStartPos,
244
245
  viewportEndPos: viewportEndPos,
245
- startPos: 1,
246
+ startPos: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? 0 : 1,
246
247
  endPos: editorView.state.doc.nodeSize
247
248
  };
248
249
  }
@@ -253,7 +254,11 @@ var BatchDecorations = /*#__PURE__*/function () {
253
254
  top: y,
254
255
  left: x
255
256
  });
256
- return startPos ? startPos.pos : 1;
257
+ if (expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
258
+ return startPos ? startPos.pos : 0;
259
+ } else {
260
+ return startPos ? startPos.pos : 1;
261
+ }
257
262
  }
258
263
  }, {
259
264
  key: "getEndPos",
@@ -1,10 +1,13 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import classnames from 'classnames';
1
3
  import { timestampToString } from '@atlaskit/editor-common/utils';
2
4
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
5
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
6
  import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
5
7
  import { isPromise, MentionNameStatus } from '@atlaskit/mention/types';
6
8
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
- import { searchMatchClass, selectedSearchMatchClass } from '../../ui/styles';
9
+ import { getGlobalTheme } from '@atlaskit/tokens';
10
+ import { searchMatchClass, selectedSearchMatchClass, blockSearchMatchClass, darkModeSearchMatchClass } from '../../ui/styles';
8
11
  export function getSelectedText(selection) {
9
12
  var text = '';
10
13
  var selectedContent = selection.content().content;
@@ -16,18 +19,37 @@ export function getSelectedText(selection) {
16
19
  export var createDecorations = function createDecorations(selectedIndex, matches) {
17
20
  return matches.map(function (_ref, i) {
18
21
  var start = _ref.start,
19
- end = _ref.end;
20
- return createDecoration(start, end, i === selectedIndex);
22
+ end = _ref.end,
23
+ nodeType = _ref.nodeType;
24
+ return createDecoration(start, end, i === selectedIndex, nodeType);
21
25
  });
22
26
  };
23
- export var createDecoration = function createDecoration(start, end, isSelected) {
24
- var className = searchMatchClass;
25
- if (isSelected) {
26
- className += " ".concat(selectedSearchMatchClass);
27
+ var isBlock = function isBlock(nodeType) {
28
+ return nodeType === 'blockCard' || nodeType === 'embedCard';
29
+ };
30
+ export var createDecoration = function createDecoration(start, end, isSelected, nodeType) {
31
+ if (expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
32
+ var _getGlobalTheme = getGlobalTheme(),
33
+ colorMode = _getGlobalTheme.colorMode;
34
+ var className = classnames(searchMatchClass, _defineProperty(_defineProperty(_defineProperty({}, selectedSearchMatchClass, isSelected), blockSearchMatchClass, isBlock(nodeType)), darkModeSearchMatchClass, colorMode === 'dark'));
35
+ if (isBlock(nodeType)) {
36
+ return Decoration.node(start, end, {
37
+ class: className
38
+ });
39
+ } else {
40
+ return Decoration.inline(start, end, {
41
+ class: className
42
+ });
43
+ }
44
+ } else {
45
+ var _className = searchMatchClass;
46
+ if (isSelected) {
47
+ _className += " ".concat(selectedSearchMatchClass);
48
+ }
49
+ return Decoration.inline(start, end, {
50
+ class: _className
51
+ });
27
52
  }
28
- return Decoration.inline(start, end, {
29
- class: className
30
- });
31
53
  };
32
54
  export function findMatches(_ref2) {
33
55
  var content = _ref2.content,
@@ -59,7 +81,8 @@ export function findMatches(_ref2) {
59
81
  matches.push({
60
82
  start: pos + index,
61
83
  end: pos + end,
62
- canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? true : undefined
84
+ canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? true : undefined,
85
+ nodeType: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? 'text' : undefined
63
86
  });
64
87
  index = text.indexOf(searchText, end);
65
88
  }
@@ -82,11 +105,12 @@ export function findMatches(_ref2) {
82
105
  matches.push({
83
106
  start: start,
84
107
  end: start + nodeSize,
85
- canReplace: false
108
+ canReplace: false,
109
+ nodeType: 'status'
86
110
  });
87
111
  }
88
112
  };
89
- var collectDateOrMentionMatch = function collectDateOrMentionMatch(textGrouping, nodeSize) {
113
+ var collectNodeMatch = function collectNodeMatch(textGrouping, node) {
90
114
  if (!textGrouping) {
91
115
  return;
92
116
  }
@@ -101,11 +125,39 @@ export function findMatches(_ref2) {
101
125
  var start = pos;
102
126
  matches.push({
103
127
  start: start,
104
- end: start + nodeSize,
105
- canReplace: false
128
+ end: start + node.nodeSize,
129
+ canReplace: false,
130
+ nodeType: node.type.name
106
131
  });
107
132
  }
108
133
  };
134
+ var collectCardTitleMatch = function collectCardTitleMatch(node, pos) {
135
+ var _api$card;
136
+ var cards = api === null || api === void 0 || (_api$card = api.card) === null || _api$card === void 0 || (_api$card = _api$card.sharedState.currentState()) === null || _api$card === void 0 ? void 0 : _api$card.cards;
137
+ if (cards) {
138
+ var relevantCard = cards.find(function (card) {
139
+ return card.url === node.attrs.url;
140
+ });
141
+ var title = relevantCard === null || relevantCard === void 0 ? void 0 : relevantCard.title;
142
+ if (relevantCard) {
143
+ if (title) {
144
+ collectNodeMatch({
145
+ text: title,
146
+ pos: pos
147
+ }, node);
148
+ } else {
149
+ // when there is no title, e.g. in an error case like unauthorized
150
+ // the link card just shows the entire url as the title in inline card
151
+ if (node.type.name === 'inlineCard') {
152
+ collectNodeMatch({
153
+ text: node.attrs.url,
154
+ pos: pos
155
+ }, node);
156
+ }
157
+ }
158
+ }
159
+ }
160
+ };
109
161
  if (searchTextLength > 0) {
110
162
  content.descendants(function (node, pos) {
111
163
  if (node.isText) {
@@ -129,10 +181,10 @@ export function findMatches(_ref2) {
129
181
  }, node.nodeSize);
130
182
  break;
131
183
  case 'date':
132
- collectDateOrMentionMatch({
184
+ collectNodeMatch({
133
185
  text: timestampToString(node.attrs.timestamp, getIntl ? getIntl() : null),
134
186
  pos: pos
135
- }, node.nodeSize);
187
+ }, node);
136
188
  break;
137
189
  case 'mention':
138
190
  var text;
@@ -157,12 +209,17 @@ export function findMatches(_ref2) {
157
209
  }
158
210
  }
159
211
  if (text) {
160
- collectDateOrMentionMatch({
212
+ collectNodeMatch({
161
213
  text: text,
162
214
  pos: pos
163
- }, node.nodeSize);
215
+ }, node);
164
216
  }
165
217
  break;
218
+ case 'inlineCard':
219
+ case 'blockCard':
220
+ case 'embedCard':
221
+ collectCardTitleMatch(node, pos);
222
+ break;
166
223
  default:
167
224
  break;
168
225
  }
@@ -10,10 +10,59 @@ import { css } from '@emotion/react';
10
10
  import { N40A, N50A, N60A } from '@atlaskit/theme/colors';
11
11
  export var searchMatchClass = 'search-match';
12
12
  export var selectedSearchMatchClass = 'selected-search-match';
13
+ export var blockSearchMatchClass = 'search-match-block';
14
+ export var darkModeSearchMatchClass = 'search-match-dark';
13
15
  export var findReplaceStyles = css(_defineProperty(_defineProperty({}, ".".concat(searchMatchClass), {
14
16
  borderRadius: '3px',
15
17
  backgroundColor: "var(--ds-background-accent-teal-subtlest, #E7F9FF)",
16
18
  boxShadow: "var(--ds-shadow-raised, ".concat("0 1px 1px 0 ".concat(N50A, ", 0 0 1px 0 ").concat(N60A), ")") + ', inset 0 0 0 1px ' + "var(--ds-border-input, ".concat("".concat(N40A), ")")
17
19
  }), ".".concat(selectedSearchMatchClass), {
18
20
  backgroundColor: "var(--ds-background-accent-teal-subtle, #6CC3E0)"
21
+ }));
22
+ export var findReplaceStylesNew = css(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ".".concat(searchMatchClass), {
23
+ borderRadius: '3px',
24
+ backgroundColor: "var(--ds-background-accent-teal-subtlest, #E7F9FF)",
25
+ boxShadow: "var(--ds-shadow-raised, 0 1px 1px 0 rgba(9, 30, 66, 0.25), 0 0 1px 0 rgba(9, 30, 66, 0.31))".concat(", inset 0 0 0 1px ", "var(--ds-border-input, #8590A2)")
26
+ }), ".".concat(selectedSearchMatchClass), {
27
+ backgroundColor: "var(--ds-background-accent-teal-subtle, #6CC3E0)"
28
+ }), ".".concat(blockSearchMatchClass), {
29
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
30
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
31
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-subtler-pressed, #E2B203)", ",\n\t\t\tinset 0 0 0 5px ", "var(--ds-background-accent-yellow-subtler, #F8E6A0)", "\n\t\t\t")
32
+ }
33
+ }), ".".concat(selectedSearchMatchClass, ".").concat(blockSearchMatchClass), {
34
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
35
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
36
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-subtler-pressed, #E2B203)", ",\n\t\t\tinset 0 0 0 4px ", "var(--ds-background-accent-yellow-subtlest-pressed, #F5CD47)", "\n\t\t\t")
37
+ }
38
+ }), ".".concat(blockSearchMatchClass, ".ak-editor-selected-node"), {
39
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
40
+ '.loader-wrapper>div::after': {
41
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-subtler-pressed, #E2B203)", ",\n\t\t\tinset 0 0 0 5px ", "var(--ds-background-accent-yellow-subtler, #F8E6A0)", ",\n\t\t\t0 0 0 1px ", "var(--ds-border-selected, #0C66E4)", "\n\t\t\t")
42
+ }
43
+ }), ".".concat(selectedSearchMatchClass, ".").concat(blockSearchMatchClass, ".ak-editor-selected-node"), {
44
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
45
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
46
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-subtler-pressed, #E2B203)", ",\n\t\t\tinset 0 0 0 4px ", "var(--ds-background-accent-yellow-subtlest-pressed, #F5CD47)", ",\n\t\t\t0 0 0 1px ", "var(--ds-border-selected, #0C66E4)", "\n\t\t\t")
47
+ }
48
+ }), ".".concat(blockSearchMatchClass, ".").concat(darkModeSearchMatchClass), {
49
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
50
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
51
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-bolder, #946F00)", ",\n\t\t\tinset 0 0 0 5px ", "var(--ds-background-accent-yellow-bolder-pressed, #533F04)", "\n\t\t\t")
52
+ }
53
+ }), ".".concat(selectedSearchMatchClass, ".").concat(blockSearchMatchClass, ".").concat(darkModeSearchMatchClass), {
54
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
55
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
56
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-bolder, #946F00)", ",\n\t\t\tinset 0 0 0 4px ", "var(--ds-background-accent-yellow-bolder-hovered, #7F5F01)", "\n\t\t\t")
57
+ }
58
+ }), ".".concat(blockSearchMatchClass, ".").concat(darkModeSearchMatchClass, ".ak-editor-selected-node"), {
59
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
60
+ '.loader-wrapper>div::after': {
61
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-bolder, #946F00)", ",\n\t\t\tinset 0 0 0 5px ", "var(--ds-background-accent-yellow-bolder-pressed, #533F04)", ",\n\t\t\t0 0 0 1px ", "var(--ds-border-selected, #0C66E4)", "\n\t\t\t")
62
+ }
63
+ }), ".".concat(selectedSearchMatchClass, ".").concat(blockSearchMatchClass, ".").concat(darkModeSearchMatchClass, ".ak-editor-selected-node"), {
64
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
65
+ '[data-smart-link-container="true"], .loader-wrapper>div::after': {
66
+ boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-bolder, #946F00)", ",\n\t\t\tinset 0 0 0 4px ", "var(--ds-background-accent-yellow-bolder-hovered, #7F5F01)", ",\n\t\t\t0 0 0 1px ", "var(--ds-border-selected, #0C66E4)", "\n\t\t\t")
67
+ }
19
68
  }));
@@ -2,6 +2,7 @@
2
2
  import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
4
4
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
+ import type { CardPlugin } from '@atlaskit/editor-plugin-card';
5
6
  import type { MentionsPlugin } from '@atlaskit/editor-plugin-mentions';
6
7
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
7
8
  import type { FindReplacePluginState, FindReplaceToolbarButtonActionProps } from './types';
@@ -12,7 +13,8 @@ export type FindReplacePluginOptions = {
12
13
  export type FindReplacePluginDependencies = [
13
14
  OptionalPlugin<AnalyticsPlugin>,
14
15
  OptionalPlugin<PrimaryToolbarPlugin>,
15
- OptionalPlugin<MentionsPlugin>
16
+ OptionalPlugin<MentionsPlugin>,
17
+ OptionalPlugin<CardPlugin>
16
18
  ];
17
19
  export type FindReplacePlugin = NextEditorPlugin<'findReplace', {
18
20
  pluginConfiguration: FindReplacePluginOptions;
@@ -9,11 +9,8 @@ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
9
  import { FindReplacePlugin } from '../../findReplacePluginType';
10
10
  import type { Match } from '../../types';
11
11
  export declare function getSelectedText(selection: TextSelection): string;
12
- export declare const createDecorations: (selectedIndex: number, matches: {
13
- start: number;
14
- end: number;
15
- }[]) => Decoration[];
16
- export declare const createDecoration: (start: number, end: number, isSelected?: boolean) => Decoration;
12
+ export declare const createDecorations: (selectedIndex: number, matches: Match[]) => Decoration[];
13
+ export declare const createDecoration: (start: number, end: number, isSelected?: Boolean, nodeType?: string) => Decoration;
17
14
  type FindMatchesType = {
18
15
  content: PmNode | Fragment;
19
16
  searchText: string;
@@ -49,6 +49,8 @@ export type Match = {
49
49
  end: number;
50
50
  /** Boolean for whether the match can be replaced */
51
51
  canReplace?: boolean;
52
+ /** Type of the node of the match */
53
+ nodeType?: string;
52
54
  };
53
55
  export type TextGrouping = {
54
56
  /** The concatenated text across nodes */
@@ -1,3 +1,6 @@
1
1
  export declare const searchMatchClass = "search-match";
2
2
  export declare const selectedSearchMatchClass = "selected-search-match";
3
+ export declare const blockSearchMatchClass = "search-match-block";
4
+ export declare const darkModeSearchMatchClass = "search-match-dark";
3
5
  export declare const findReplaceStyles: import("@emotion/react").SerializedStyles;
6
+ export declare const findReplaceStylesNew: import("@emotion/react").SerializedStyles;
@@ -2,6 +2,7 @@
2
2
  import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
4
4
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
+ import type { CardPlugin } from '@atlaskit/editor-plugin-card';
5
6
  import type { MentionsPlugin } from '@atlaskit/editor-plugin-mentions';
6
7
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
7
8
  import type { FindReplacePluginState, FindReplaceToolbarButtonActionProps } from './types';
@@ -12,7 +13,8 @@ export type FindReplacePluginOptions = {
12
13
  export type FindReplacePluginDependencies = [
13
14
  OptionalPlugin<AnalyticsPlugin>,
14
15
  OptionalPlugin<PrimaryToolbarPlugin>,
15
- OptionalPlugin<MentionsPlugin>
16
+ OptionalPlugin<MentionsPlugin>,
17
+ OptionalPlugin<CardPlugin>
16
18
  ];
17
19
  export type FindReplacePlugin = NextEditorPlugin<'findReplace', {
18
20
  pluginConfiguration: FindReplacePluginOptions;
@@ -9,11 +9,8 @@ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
9
  import { FindReplacePlugin } from '../../findReplacePluginType';
10
10
  import type { Match } from '../../types';
11
11
  export declare function getSelectedText(selection: TextSelection): string;
12
- export declare const createDecorations: (selectedIndex: number, matches: {
13
- start: number;
14
- end: number;
15
- }[]) => Decoration[];
16
- export declare const createDecoration: (start: number, end: number, isSelected?: boolean) => Decoration;
12
+ export declare const createDecorations: (selectedIndex: number, matches: Match[]) => Decoration[];
13
+ export declare const createDecoration: (start: number, end: number, isSelected?: Boolean, nodeType?: string) => Decoration;
17
14
  type FindMatchesType = {
18
15
  content: PmNode | Fragment;
19
16
  searchText: string;
@@ -49,6 +49,8 @@ export type Match = {
49
49
  end: number;
50
50
  /** Boolean for whether the match can be replaced */
51
51
  canReplace?: boolean;
52
+ /** Type of the node of the match */
53
+ nodeType?: string;
52
54
  };
53
55
  export type TextGrouping = {
54
56
  /** The concatenated text across nodes */
@@ -1,3 +1,6 @@
1
1
  export declare const searchMatchClass = "search-match";
2
2
  export declare const selectedSearchMatchClass = "selected-search-match";
3
+ export declare const blockSearchMatchClass = "search-match-block";
4
+ export declare const darkModeSearchMatchClass = "search-match-dark";
3
5
  export declare const findReplaceStyles: import("@emotion/react").SerializedStyles;
6
+ export declare const findReplaceStylesNew: import("@emotion/react").SerializedStyles;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-find-replace",
3
- "version": "2.7.2",
3
+ "version": "2.8.0",
4
4
  "description": "find replace plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,12 +35,13 @@
35
35
  "@atlaskit/button": "^23.2.0",
36
36
  "@atlaskit/editor-common": "^107.2.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^2.3.0",
38
+ "@atlaskit/editor-plugin-card": "^6.6.0",
38
39
  "@atlaskit/editor-plugin-mentions": "^4.7.0",
39
40
  "@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
40
41
  "@atlaskit/editor-prosemirror": "7.0.0",
41
42
  "@atlaskit/editor-shared-styles": "^3.4.0",
42
43
  "@atlaskit/form": "^12.0.0",
43
- "@atlaskit/icon": "^27.1.0",
44
+ "@atlaskit/icon": "^27.2.0",
44
45
  "@atlaskit/mention": "^24.2.0",
45
46
  "@atlaskit/platform-feature-flags": "^1.1.0",
46
47
  "@atlaskit/primitives": "^14.9.0",
@@ -51,6 +52,7 @@
51
52
  "@atlaskit/tooltip": "^20.3.0",
52
53
  "@babel/runtime": "^7.0.0",
53
54
  "@emotion/react": "^11.7.1",
55
+ "classnames": "^2.2.5",
54
56
  "lodash": "^4.17.21",
55
57
  "raf-schd": "^4.0.3"
56
58
  },