@atlaskit/editor-plugin-find-replace 2.7.1 → 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.
Files changed (42) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/pm-plugins/commands.js +5 -5
  3. package/dist/cjs/pm-plugins/main.js +2 -2
  4. package/dist/cjs/pm-plugins/reducer.js +2 -2
  5. package/dist/cjs/pm-plugins/utils/batch-decorations.js +7 -2
  6. package/dist/cjs/pm-plugins/utils/index.js +102 -54
  7. package/dist/cjs/ui/FindReplace.js +3 -2
  8. package/dist/cjs/ui/FindReplaceDropDownOrToolbarButtonWithState.js +3 -3
  9. package/dist/cjs/ui/Replace.js +3 -3
  10. package/dist/cjs/ui/ReplaceNext.js +3 -3
  11. package/dist/cjs/ui/styles.js +50 -1
  12. package/dist/es2019/pm-plugins/commands.js +5 -5
  13. package/dist/es2019/pm-plugins/main.js +2 -2
  14. package/dist/es2019/pm-plugins/reducer.js +2 -2
  15. package/dist/es2019/pm-plugins/utils/batch-decorations.js +7 -2
  16. package/dist/es2019/pm-plugins/utils/index.js +102 -55
  17. package/dist/es2019/ui/FindReplace.js +3 -2
  18. package/dist/es2019/ui/FindReplaceDropDownOrToolbarButtonWithState.js +3 -3
  19. package/dist/es2019/ui/Replace.js +3 -3
  20. package/dist/es2019/ui/ReplaceNext.js +3 -3
  21. package/dist/es2019/ui/styles.js +99 -0
  22. package/dist/esm/pm-plugins/commands.js +5 -5
  23. package/dist/esm/pm-plugins/main.js +2 -2
  24. package/dist/esm/pm-plugins/reducer.js +2 -2
  25. package/dist/esm/pm-plugins/utils/batch-decorations.js +7 -2
  26. package/dist/esm/pm-plugins/utils/index.js +102 -55
  27. package/dist/esm/ui/FindReplace.js +3 -2
  28. package/dist/esm/ui/FindReplaceDropDownOrToolbarButtonWithState.js +3 -3
  29. package/dist/esm/ui/Replace.js +3 -3
  30. package/dist/esm/ui/ReplaceNext.js +3 -3
  31. package/dist/esm/ui/styles.js +49 -0
  32. package/dist/types/findReplacePluginType.d.ts +3 -1
  33. package/dist/types/pm-plugins/main.d.ts +2 -2
  34. package/dist/types/pm-plugins/utils/index.d.ts +3 -6
  35. package/dist/types/types/index.d.ts +3 -1
  36. package/dist/types/ui/styles.d.ts +3 -0
  37. package/dist/types-ts4.5/findReplacePluginType.d.ts +3 -1
  38. package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -2
  39. package/dist/types-ts4.5/pm-plugins/utils/index.d.ts +3 -6
  40. package/dist/types-ts4.5/types/index.d.ts +3 -1
  41. package/dist/types-ts4.5/ui/styles.d.ts +3 -0
  42. package/package.json +8 -12
@@ -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
- import { fg } from '@atlaskit/platform-feature-flags';
7
- import { searchMatchClass, selectedSearchMatchClass } from '../../ui/styles';
7
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
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: fg('platform_editor_find_and_replace_1') ? 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
  }
@@ -75,14 +100,8 @@ export function findMatches({
75
100
  let {
76
101
  text
77
102
  } = textGrouping;
78
- // status text is rendered in all caps regardless so case matching should work if the search text is all caps
79
- if (fg('platform_editor_find_and_replace_part_2')) {
80
- if (shouldMatchCase) {
81
- text = text.toUpperCase();
82
- } else {
83
- text = text.toLowerCase();
84
- searchText = searchText.toLowerCase();
85
- }
103
+ if (shouldMatchCase) {
104
+ text = text.toUpperCase();
86
105
  } else {
87
106
  text = text.toLowerCase();
88
107
  searchText = searchText.toLowerCase();
@@ -93,11 +112,12 @@ export function findMatches({
93
112
  matches.push({
94
113
  start,
95
114
  end: start + nodeSize,
96
- canReplace: false
115
+ canReplace: false,
116
+ nodeType: 'status'
97
117
  });
98
118
  }
99
119
  };
100
- const collectDateOrMentionMatch = (textGrouping, nodeSize) => {
120
+ const collectNodeMatch = (textGrouping, node) => {
101
121
  if (!textGrouping) {
102
122
  return;
103
123
  }
@@ -116,11 +136,37 @@ export function findMatches({
116
136
  const start = pos;
117
137
  matches.push({
118
138
  start,
119
- end: start + nodeSize,
120
- canReplace: false
139
+ end: start + node.nodeSize,
140
+ canReplace: false,
141
+ nodeType: node.type.name
121
142
  });
122
143
  }
123
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
+ };
124
170
  if (searchTextLength > 0) {
125
171
  content.descendants((node, pos) => {
126
172
  if (node.isText) {
@@ -135,7 +181,7 @@ export function findMatches({
135
181
  } else {
136
182
  collectTextMatch(textGrouping);
137
183
  textGrouping = null;
138
- if (fg('platform_editor_find_and_replace_1')) {
184
+ if (expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
139
185
  switch (node.type.name) {
140
186
  case 'status':
141
187
  collectStatusMatch({
@@ -144,43 +190,44 @@ export function findMatches({
144
190
  }, node.nodeSize);
145
191
  break;
146
192
  case 'date':
147
- if (fg('platform_editor_find_and_replace_part_2')) {
148
- collectDateOrMentionMatch({
149
- text: timestampToString(node.attrs.timestamp, getIntl ? getIntl() : null),
150
- pos
151
- }, node.nodeSize);
152
- }
193
+ collectNodeMatch({
194
+ text: timestampToString(node.attrs.timestamp, getIntl ? getIntl() : null),
195
+ pos
196
+ }, node);
153
197
  break;
154
198
  case 'mention':
155
- if (fg('platform_editor_find_and_replace_part_2')) {
156
- let text;
157
- if (node.attrs.text) {
158
- text = node.attrs.text;
159
- } else {
160
- var _api$mention, _api$mention$sharedSt;
161
- // the text may be sanitised from the node for privacy reasons
162
- // so we need to use the mentionProvider to resolve it
163
- const mentionProvider = api === null || api === void 0 ? void 0 : (_api$mention = api.mention) === null || _api$mention === void 0 ? void 0 : (_api$mention$sharedSt = _api$mention.sharedState.currentState()) === null || _api$mention$sharedSt === void 0 ? void 0 : _api$mention$sharedSt.mentionProvider;
164
- if (isResolvingMentionProvider(mentionProvider)) {
165
- const nameDetail = mentionProvider.resolveMentionName(node.attrs.id);
166
- if (isPromise(nameDetail)) {
167
- text = '@...';
199
+ let text;
200
+ if (node.attrs.text) {
201
+ text = node.attrs.text;
202
+ } else {
203
+ var _api$mention, _api$mention$sharedSt;
204
+ // the text may be sanitised from the node for privacy reasons
205
+ // so we need to use the mentionProvider to resolve it
206
+ const mentionProvider = api === null || api === void 0 ? void 0 : (_api$mention = api.mention) === null || _api$mention === void 0 ? void 0 : (_api$mention$sharedSt = _api$mention.sharedState.currentState()) === null || _api$mention$sharedSt === void 0 ? void 0 : _api$mention$sharedSt.mentionProvider;
207
+ if (isResolvingMentionProvider(mentionProvider)) {
208
+ const nameDetail = mentionProvider.resolveMentionName(node.attrs.id);
209
+ if (isPromise(nameDetail)) {
210
+ text = '@...';
211
+ } else {
212
+ if (nameDetail.status === MentionNameStatus.OK) {
213
+ text = `@${nameDetail.name || ''}`;
168
214
  } else {
169
- if (nameDetail.status === MentionNameStatus.OK) {
170
- text = `@${nameDetail.name || ''}`;
171
- } else {
172
- text = '@_|unknown|_';
173
- }
215
+ text = '@_|unknown|_';
174
216
  }
175
217
  }
176
218
  }
177
- if (text) {
178
- collectDateOrMentionMatch({
179
- text,
180
- pos
181
- }, node.nodeSize);
182
- }
183
219
  }
220
+ if (text) {
221
+ collectNodeMatch({
222
+ text,
223
+ pos
224
+ }, node);
225
+ }
226
+ break;
227
+ case 'inlineCard':
228
+ case 'blockCard':
229
+ case 'embedCard':
230
+ collectCardTitleMatch(node, pos);
184
231
  break;
185
232
  default:
186
233
  break;
@@ -10,6 +10,7 @@ import React from 'react';
10
10
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
11
11
  import { jsx } from '@emotion/react';
12
12
  import { fg } from '@atlaskit/platform-feature-flags';
13
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
13
14
  import Find from './Find';
14
15
  import Replace from './Replace';
15
16
  import ReplaceNext from './ReplaceNext';
@@ -126,7 +127,7 @@ class FindReplace extends React.PureComponent {
126
127
  css: ruleStyles,
127
128
  id: "replace-hr-element"
128
129
  }), fg('editor_a11y_refactor_find_replace_style') ? jsx(ReplaceNext, {
129
- canReplace: fg('platform_editor_find_and_replace_1') ? !!isReplaceable : count.total > 0,
130
+ canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? !!isReplaceable : count.total > 0,
130
131
  replaceText: replaceText,
131
132
  onReplace: onReplace,
132
133
  onReplaceAll: onReplaceAll,
@@ -141,7 +142,7 @@ class FindReplace extends React.PureComponent {
141
142
  setFindTyped: this.setFindTyped,
142
143
  focusToolbarButton: focusToolbarButton
143
144
  }) : jsx(Replace, {
144
- canReplace: fg('platform_editor_find_and_replace_1') ? !!isReplaceable : count.total > 0,
145
+ canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? !!isReplaceable : count.total > 0,
145
146
  replaceText: replaceText,
146
147
  onReplace: onReplace,
147
148
  onReplaceAll: onReplaceAll,
@@ -1,7 +1,7 @@
1
1
  import React, { useLayoutEffect, useState } from 'react';
2
2
  import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
4
- import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
5
  import { blur, toggleMatchCase } from '../pm-plugins/commands';
6
6
  import { activateWithAnalytics, cancelSearchWithAnalytics, findNextWithAnalytics, findPrevWithAnalytics, findWithAnalytics, replaceAllWithAnalytics, replaceWithAnalytics } from '../pm-plugins/commands-with-analytics';
7
7
  import FindReplaceDropdown from './FindReplaceDropdown';
@@ -173,8 +173,8 @@ const FindReplaceToolbarButtonWithState = ({
173
173
  findText: findText,
174
174
  index: index,
175
175
  numMatches: matches.length,
176
- isReplaceable: fg('platform_editor_find_and_replace_1') ? (_matches$index = matches[index]) === null || _matches$index === void 0 ? void 0 : _matches$index.canReplace : undefined,
177
- numReplaceable: fg('platform_editor_find_and_replace_1') ? matches.filter(match => match.canReplace === true).length : undefined,
176
+ isReplaceable: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? (_matches$index = matches[index]) === null || _matches$index === void 0 ? void 0 : _matches$index.canReplace : undefined,
177
+ numReplaceable: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? matches.filter(match => match.canReplace === true).length : undefined,
178
178
  replaceText: replaceText,
179
179
  shouldFocus: shouldFocus,
180
180
  popupsBoundariesElement: popupsBoundariesElement,
@@ -15,9 +15,9 @@ import { findReplaceMessages as messages } from '@atlaskit/editor-common/message
15
15
  import { Label, ValidMessage } from '@atlaskit/form';
16
16
  import ChevronDownIcon from '@atlaskit/icon/core/migration/chevron-down--hipchat-chevron-down';
17
17
  import ChevronUpIcon from '@atlaskit/icon/core/migration/chevron-up--hipchat-chevron-up';
18
- import { fg } from '@atlaskit/platform-feature-flags';
19
18
  import { Inline, xcss } from '@atlaskit/primitives';
20
19
  import Textfield from '@atlaskit/textfield';
20
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
21
21
  import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
22
22
  import { nextPreviousItemStyles, orderOneStyles, orderZeroStyles, sectionWrapperJustified, sectionWrapperStyles, sectionWrapperStylesAlternate, textFieldWrapper } from './ui-styles';
23
23
  // eslint-disable-next-line @repo/internal/react/no-class-components
@@ -83,7 +83,7 @@ class Replace extends React.PureComponent {
83
83
  this.setState({
84
84
  isHelperMessageVisible: true
85
85
  });
86
- if (this.props.count.totalReplaceable && fg('platform_editor_find_and_replace_1')) {
86
+ if (this.props.count.totalReplaceable && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
87
87
  this.triggerSuccessReplacementMessageUpdate(this.props.count.totalReplaceable);
88
88
  this.setState({
89
89
  replaceCount: this.props.count.totalReplaceable
@@ -279,7 +279,7 @@ class Replace extends React.PureComponent {
279
279
  testId: this.replaceAll,
280
280
  id: "replaceAll-button",
281
281
  onClick: this.handleReplaceAllClick,
282
- isDisabled: fg('platform_editor_find_and_replace_1') ? count.totalReplaceable === 0 : !canReplace
282
+ isDisabled: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? count.totalReplaceable === 0 : !canReplace
283
283
  }, this.replaceAll))), jsx("div", {
284
284
  css: orderZeroStyles
285
285
  }, jsx(Button, {
@@ -6,9 +6,9 @@ import { findReplaceMessages as messages } from '@atlaskit/editor-common/message
6
6
  import { ValidMessage } from '@atlaskit/form';
7
7
  import ChevronDownIcon from '@atlaskit/icon/core/migration/chevron-down--hipchat-chevron-down';
8
8
  import ChevronUpIcon from '@atlaskit/icon/core/migration/chevron-up--hipchat-chevron-up';
9
- import { fg } from '@atlaskit/platform-feature-flags';
10
9
  import { Box, Inline, Text, xcss } from '@atlaskit/primitives';
11
10
  import Textfield from '@atlaskit/textfield';
11
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
12
12
  import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
13
13
  const replaceContainerStyles = xcss({
14
14
  padding: 'space.100'
@@ -115,7 +115,7 @@ const Replace = ({
115
115
  replaceText
116
116
  });
117
117
  setIsHelperMessageVisible(true);
118
- if (count.totalReplaceable && fg('platform_editor_find_and_replace_1')) {
118
+ if (count.totalReplaceable && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
119
119
  triggerSuccessReplacementMessageUpdate(count.totalReplaceable);
120
120
  setReplaceCount(count.totalReplaceable);
121
121
  } else {
@@ -215,7 +215,7 @@ const Replace = ({
215
215
  testId: replaceAll,
216
216
  id: "replaceAll-button",
217
217
  onClick: handleReplaceAllClick,
218
- isDisabled: fg('platform_editor_find_and_replace_1') ? count.totalReplaceable === 0 : !canReplace
218
+ isDisabled: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? count.totalReplaceable === 0 : !canReplace
219
219
  }, replaceAll)), /*#__PURE__*/React.createElement(Button, {
220
220
  appearance: "subtle",
221
221
  testId: closeFindReplaceDialog,
@@ -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
  });
@@ -1,6 +1,6 @@
1
1
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
- import { fg } from '@atlaskit/platform-feature-flags';
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
4
  import { FindReplaceActionTypes } from './actions';
5
5
  import { createCommand, getPluginState } from './plugin-factory';
6
6
  import { createDecoration, findDecorationFromMatch, findMatches, findSearchIndex, getSelectedText, getSelectionForMatch, nextIndex, prevIndex, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
@@ -171,7 +171,7 @@ export var replace = function replace(replaceText) {
171
171
  index = _getPluginState6.index,
172
172
  findText = _getPluginState6.findText;
173
173
  if (matches[index]) {
174
- if (!matches[index].canReplace && fg('platform_editor_find_and_replace_1')) {
174
+ if (!matches[index].canReplace && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
175
175
  return tr;
176
176
  }
177
177
  var _matches$index = matches[index],
@@ -193,7 +193,7 @@ export var replaceAll = function replaceAll(replaceText) {
193
193
  }, function (tr, state) {
194
194
  var pluginState = getPluginState(state);
195
195
  pluginState.matches.forEach(function (match) {
196
- if (!match.canReplace && fg('platform_editor_find_and_replace_1')) {
196
+ if (!match.canReplace && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
197
197
  return tr;
198
198
  }
199
199
  tr.insertText(replaceText, tr.mapping.map(match.start), tr.mapping.map(match.end));
@@ -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
  };
@@ -3,7 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
3
3
  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) { _defineProperty(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; }
4
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
5
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
- import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
7
  import { createPluginState, getPluginState } from './plugin-factory';
8
8
  import { findReplacePluginKey } from './plugin-key';
9
9
  export var initialState = {
@@ -20,7 +20,7 @@ export var createPlugin = function createPlugin(dispatch, getIntl, api) {
20
20
  return new SafePlugin({
21
21
  key: findReplacePluginKey,
22
22
  state: createPluginState(dispatch, function () {
23
- return fg('platform_editor_find_and_replace_part_2') ? _objectSpread(_objectSpread({}, initialState), {}, {
23
+ return expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? _objectSpread(_objectSpread({}, initialState), {}, {
24
24
  getIntl: getIntl,
25
25
  api: api
26
26
  }) : _objectSpread({}, initialState);
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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; }
3
3
  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) { _defineProperty(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; }
4
- import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
5
  import { FindReplaceActionTypes } from './actions';
6
6
  var reducer = function reducer(getInitialState) {
7
7
  return function (state, action) {
@@ -40,7 +40,7 @@ var reducer = function reducer(getInitialState) {
40
40
  case FindReplaceActionTypes.CANCEL:
41
41
  var getIntl = state.getIntl,
42
42
  api = state.api;
43
- return fg('platform_editor_find_and_replace_part_2') ? _objectSpread(_objectSpread({}, getInitialState()), {}, {
43
+ return expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? _objectSpread(_objectSpread({}, getInitialState()), {}, {
44
44
  getIntl: getIntl,
45
45
  api: api
46
46
  }) : getInitialState();
@@ -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",