@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
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
+
16
+ ## 2.7.2
17
+
18
+ ### Patch Changes
19
+
20
+ - [#176094](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/176094)
21
+ [`09e338a3d7dab`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/09e338a3d7dab) -
22
+ [ED-28357] move find&replace work from behind feature gates to the new experiment
23
+ platform_editor_find_and_replace_improvements
24
+ - Updated dependencies
25
+
3
26
  ## 2.7.1
4
27
 
5
28
  ### Patch Changes
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.toggleMatchCase = exports.replaceAll = exports.replace = exports.removeDecorations = exports.findPrevious = exports.findNext = exports.find = exports.cancelSearch = exports.blur = exports.addDecorations = exports.activate = void 0;
8
8
  var _state = require("@atlaskit/editor-prosemirror/state");
9
9
  var _view = require("@atlaskit/editor-prosemirror/view");
10
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
11
11
  var _actions = require("./actions");
12
12
  var _pluginFactory = require("./plugin-factory");
13
13
  var _utils = require("./utils");
@@ -178,7 +178,7 @@ var replace = exports.replace = function replace(replaceText) {
178
178
  index = _getPluginState6.index,
179
179
  findText = _getPluginState6.findText;
180
180
  if (matches[index]) {
181
- if (!matches[index].canReplace && (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1')) {
181
+ if (!matches[index].canReplace && (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
182
182
  return tr;
183
183
  }
184
184
  var _matches$index = matches[index],
@@ -200,7 +200,7 @@ var replaceAll = exports.replaceAll = function replaceAll(replaceText) {
200
200
  }, function (tr, state) {
201
201
  var pluginState = (0, _pluginFactory.getPluginState)(state);
202
202
  pluginState.matches.forEach(function (match) {
203
- if (!match.canReplace && (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1')) {
203
+ if (!match.canReplace && (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
204
204
  return tr;
205
205
  }
206
206
  tr.insertText(replaceText, tr.mapping.map(match.start), tr.mapping.map(match.end));
@@ -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
  };
@@ -8,7 +8,7 @@ exports.initialState = exports.createPlugin = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
10
10
  var _view = require("@atlaskit/editor-prosemirror/view");
11
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
12
12
  var _pluginFactory = require("./plugin-factory");
13
13
  var _pluginKey = require("./plugin-key");
14
14
  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; }
@@ -27,7 +27,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
27
27
  return new _safePlugin.SafePlugin({
28
28
  key: _pluginKey.findReplacePluginKey,
29
29
  state: (0, _pluginFactory.createPluginState)(dispatch, function () {
30
- return (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_part_2') ? _objectSpread(_objectSpread({}, initialState), {}, {
30
+ return (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? _objectSpread(_objectSpread({}, initialState), {}, {
31
31
  getIntl: getIntl,
32
32
  api: api
33
33
  }) : _objectSpread({}, initialState);
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
10
10
  var _actions = require("./actions");
11
11
  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; }
12
12
  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; }
@@ -47,7 +47,7 @@ var reducer = function reducer(getInitialState) {
47
47
  case _actions.FindReplaceActionTypes.CANCEL:
48
48
  var getIntl = state.getIntl,
49
49
  api = state.api;
50
- return (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_part_2') ? _objectSpread(_objectSpread({}, getInitialState()), {}, {
50
+ return (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? _objectSpread(_objectSpread({}, getInitialState()), {}, {
51
51
  getIntl: getIntl,
52
52
  api: api
53
53
  }) : getInitialState();
@@ -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
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
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, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1') ? 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
  }
@@ -80,14 +104,8 @@ function findMatches(_ref2) {
80
104
  }
81
105
  var pos = textGrouping.pos;
82
106
  var text = textGrouping.text;
83
- // status text is rendered in all caps regardless so case matching should work if the search text is all caps
84
- if ((0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_part_2')) {
85
- if (shouldMatchCase) {
86
- text = text.toUpperCase();
87
- } else {
88
- text = text.toLowerCase();
89
- searchText = searchText.toLowerCase();
90
- }
107
+ if (shouldMatchCase) {
108
+ text = text.toUpperCase();
91
109
  } else {
92
110
  text = text.toLowerCase();
93
111
  searchText = searchText.toLowerCase();
@@ -98,11 +116,12 @@ function findMatches(_ref2) {
98
116
  matches.push({
99
117
  start: start,
100
118
  end: start + nodeSize,
101
- canReplace: false
119
+ canReplace: false,
120
+ nodeType: 'status'
102
121
  });
103
122
  }
104
123
  };
105
- var collectDateOrMentionMatch = function collectDateOrMentionMatch(textGrouping, nodeSize) {
124
+ var collectNodeMatch = function collectNodeMatch(textGrouping, node) {
106
125
  if (!textGrouping) {
107
126
  return;
108
127
  }
@@ -117,9 +136,37 @@ function findMatches(_ref2) {
117
136
  var start = pos;
118
137
  matches.push({
119
138
  start: start,
120
- end: start + nodeSize,
121
- canReplace: false
139
+ end: start + node.nodeSize,
140
+ canReplace: false,
141
+ nodeType: node.type.name
142
+ });
143
+ }
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;
122
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
+ }
123
170
  }
124
171
  };
125
172
  if (searchTextLength > 0) {
@@ -136,7 +183,7 @@ function findMatches(_ref2) {
136
183
  } else {
137
184
  collectTextMatch(textGrouping);
138
185
  textGrouping = null;
139
- if ((0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1')) {
186
+ if ((0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
140
187
  switch (node.type.name) {
141
188
  case 'status':
142
189
  collectStatusMatch({
@@ -145,43 +192,44 @@ function findMatches(_ref2) {
145
192
  }, node.nodeSize);
146
193
  break;
147
194
  case 'date':
148
- if ((0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_part_2')) {
149
- collectDateOrMentionMatch({
150
- text: (0, _utils.timestampToString)(node.attrs.timestamp, getIntl ? getIntl() : null),
151
- pos: pos
152
- }, node.nodeSize);
153
- }
195
+ collectNodeMatch({
196
+ text: (0, _utils.timestampToString)(node.attrs.timestamp, getIntl ? getIntl() : null),
197
+ pos: pos
198
+ }, node);
154
199
  break;
155
200
  case 'mention':
156
- if ((0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_part_2')) {
157
- var text;
158
- if (node.attrs.text) {
159
- text = node.attrs.text;
160
- } else {
161
- var _api$mention;
162
- // the text may be sanitised from the node for privacy reasons
163
- // so we need to use the mentionProvider to resolve it
164
- var mentionProvider = api === null || api === void 0 || (_api$mention = api.mention) === null || _api$mention === void 0 || (_api$mention = _api$mention.sharedState.currentState()) === null || _api$mention === void 0 ? void 0 : _api$mention.mentionProvider;
165
- if ((0, _resource.isResolvingMentionProvider)(mentionProvider)) {
166
- var nameDetail = mentionProvider.resolveMentionName(node.attrs.id);
167
- if ((0, _types.isPromise)(nameDetail)) {
168
- text = '@...';
201
+ var text;
202
+ if (node.attrs.text) {
203
+ text = node.attrs.text;
204
+ } else {
205
+ var _api$mention;
206
+ // the text may be sanitised from the node for privacy reasons
207
+ // so we need to use the mentionProvider to resolve it
208
+ var mentionProvider = api === null || api === void 0 || (_api$mention = api.mention) === null || _api$mention === void 0 || (_api$mention = _api$mention.sharedState.currentState()) === null || _api$mention === void 0 ? void 0 : _api$mention.mentionProvider;
209
+ if ((0, _resource.isResolvingMentionProvider)(mentionProvider)) {
210
+ var nameDetail = mentionProvider.resolveMentionName(node.attrs.id);
211
+ if ((0, _types.isPromise)(nameDetail)) {
212
+ text = '@...';
213
+ } else {
214
+ if (nameDetail.status === _types.MentionNameStatus.OK) {
215
+ text = "@".concat(nameDetail.name || '');
169
216
  } else {
170
- if (nameDetail.status === _types.MentionNameStatus.OK) {
171
- text = "@".concat(nameDetail.name || '');
172
- } else {
173
- text = '@_|unknown|_';
174
- }
217
+ text = '@_|unknown|_';
175
218
  }
176
219
  }
177
220
  }
178
- if (text) {
179
- collectDateOrMentionMatch({
180
- text: text,
181
- pos: pos
182
- }, node.nodeSize);
183
- }
184
221
  }
222
+ if (text) {
223
+ collectNodeMatch({
224
+ text: text,
225
+ pos: pos
226
+ }, node);
227
+ }
228
+ break;
229
+ case 'inlineCard':
230
+ case 'blockCard':
231
+ case 'embedCard':
232
+ collectCardTitleMatch(node, pos);
185
233
  break;
186
234
  default:
187
235
  break;
@@ -14,6 +14,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
14
14
  var _react = _interopRequireDefault(require("react"));
15
15
  var _react2 = require("@emotion/react");
16
16
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
17
18
  var _Find = _interopRequireDefault(require("./Find"));
18
19
  var _Replace = _interopRequireDefault(require("./Replace"));
19
20
  var _ReplaceNext = _interopRequireDefault(require("./ReplaceNext"));
@@ -148,7 +149,7 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
148
149
  css: _uiStyles.ruleStyles,
149
150
  id: "replace-hr-element"
150
151
  }), (0, _platformFeatureFlags.fg)('editor_a11y_refactor_find_replace_style') ? (0, _react2.jsx)(_ReplaceNext.default, {
151
- canReplace: (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1') ? !!isReplaceable : count.total > 0,
152
+ canReplace: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? !!isReplaceable : count.total > 0,
152
153
  replaceText: replaceText,
153
154
  onReplace: onReplace,
154
155
  onReplaceAll: onReplaceAll,
@@ -163,7 +164,7 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
163
164
  setFindTyped: this.setFindTyped,
164
165
  focusToolbarButton: focusToolbarButton
165
166
  }) : (0, _react2.jsx)(_Replace.default, {
166
- canReplace: (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1') ? !!isReplaceable : count.total > 0,
167
+ canReplace: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? !!isReplaceable : count.total > 0,
167
168
  replaceText: replaceText,
168
169
  onReplace: onReplace,
169
170
  onReplaceAll: onReplaceAll,
@@ -10,7 +10,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
12
  var _hooks = require("@atlaskit/editor-common/hooks");
13
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
14
14
  var _commands = require("../pm-plugins/commands");
15
15
  var _commandsWithAnalytics = require("../pm-plugins/commands-with-analytics");
16
16
  var _FindReplaceDropdown = _interopRequireDefault(require("./FindReplaceDropdown"));
@@ -186,8 +186,8 @@ var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithSta
186
186
  findText: findText,
187
187
  index: index,
188
188
  numMatches: matches.length,
189
- isReplaceable: (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1') ? (_matches$index = matches[index]) === null || _matches$index === void 0 ? void 0 : _matches$index.canReplace : undefined,
190
- numReplaceable: (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1') ? matches.filter(function (match) {
189
+ isReplaceable: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? (_matches$index = matches[index]) === null || _matches$index === void 0 ? void 0 : _matches$index.canReplace : undefined,
190
+ numReplaceable: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? matches.filter(function (match) {
191
191
  return match.canReplace === true;
192
192
  }).length : undefined,
193
193
  replaceText: replaceText,
@@ -21,9 +21,9 @@ var _messages = require("@atlaskit/editor-common/messages");
21
21
  var _form = require("@atlaskit/form");
22
22
  var _chevronDownHipchatChevronDown = _interopRequireDefault(require("@atlaskit/icon/core/migration/chevron-down--hipchat-chevron-down"));
23
23
  var _chevronUpHipchatChevronUp = _interopRequireDefault(require("@atlaskit/icon/core/migration/chevron-up--hipchat-chevron-up"));
24
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
25
24
  var _primitives = require("@atlaskit/primitives");
26
25
  var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
26
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
27
27
  var _FindReplaceTooltipButton = require("./FindReplaceTooltipButton");
28
28
  var _uiStyles = require("./ui-styles");
29
29
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -102,7 +102,7 @@ var Replace = /*#__PURE__*/function (_React$PureComponent) {
102
102
  _this.setState({
103
103
  isHelperMessageVisible: true
104
104
  });
105
- if (_this.props.count.totalReplaceable && (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1')) {
105
+ if (_this.props.count.totalReplaceable && (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
106
106
  _this.triggerSuccessReplacementMessageUpdate(_this.props.count.totalReplaceable);
107
107
  _this.setState({
108
108
  replaceCount: _this.props.count.totalReplaceable
@@ -302,7 +302,7 @@ var Replace = /*#__PURE__*/function (_React$PureComponent) {
302
302
  testId: this.replaceAll,
303
303
  id: "replaceAll-button",
304
304
  onClick: this.handleReplaceAllClick,
305
- isDisabled: (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1') ? count.totalReplaceable === 0 : !canReplace
305
+ isDisabled: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? count.totalReplaceable === 0 : !canReplace
306
306
  }, this.replaceAll))), (0, _react2.jsx)("div", {
307
307
  css: _uiStyles.orderZeroStyles
308
308
  }, (0, _react2.jsx)(_new.default, {
@@ -15,9 +15,9 @@ var _messages = require("@atlaskit/editor-common/messages");
15
15
  var _form = require("@atlaskit/form");
16
16
  var _chevronDownHipchatChevronDown = _interopRequireDefault(require("@atlaskit/icon/core/migration/chevron-down--hipchat-chevron-down"));
17
17
  var _chevronUpHipchatChevronUp = _interopRequireDefault(require("@atlaskit/icon/core/migration/chevron-up--hipchat-chevron-up"));
18
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
19
18
  var _primitives = require("@atlaskit/primitives");
20
19
  var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
20
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
21
21
  var _FindReplaceTooltipButton = require("./FindReplaceTooltipButton");
22
22
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
23
23
  var replaceContainerStyles = (0, _primitives.xcss)({
@@ -144,7 +144,7 @@ var Replace = function Replace(_ref) {
144
144
  replaceText: replaceText
145
145
  });
146
146
  setIsHelperMessageVisible(true);
147
- if (count.totalReplaceable && (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1')) {
147
+ if (count.totalReplaceable && (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
148
148
  triggerSuccessReplacementMessageUpdate(count.totalReplaceable);
149
149
  setReplaceCount(count.totalReplaceable);
150
150
  } else {
@@ -249,7 +249,7 @@ var Replace = function Replace(_ref) {
249
249
  testId: replaceAll,
250
250
  id: "replaceAll-button",
251
251
  onClick: handleReplaceAllClick,
252
- isDisabled: (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1') ? count.totalReplaceable === 0 : !canReplace
252
+ isDisabled: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? count.totalReplaceable === 0 : !canReplace
253
253
  }, replaceAll)), /*#__PURE__*/_react.default.createElement(_new.default, {
254
254
  appearance: "subtle",
255
255
  testId: closeFindReplaceDialog,
@@ -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
  }));
@@ -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';
@@ -174,7 +174,7 @@ export const replace = replaceText => withScrollIntoView(createCommand(state =>
174
174
  findText
175
175
  } = getPluginState(state);
176
176
  if (matches[index]) {
177
- if (!matches[index].canReplace && fg('platform_editor_find_and_replace_1')) {
177
+ if (!matches[index].canReplace && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
178
178
  return tr;
179
179
  }
180
180
  const {
@@ -195,7 +195,7 @@ export const replaceAll = replaceText => createCommand({
195
195
  }, (tr, state) => {
196
196
  const pluginState = getPluginState(state);
197
197
  pluginState.matches.forEach(match => {
198
- if (!match.canReplace && fg('platform_editor_find_and_replace_1')) {
198
+ if (!match.canReplace && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
199
199
  return tr;
200
200
  }
201
201
  tr.insertText(replaceText, tr.mapping.map(match.start), tr.mapping.map(match.end));
@@ -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,6 +1,6 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
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 { createPluginState, getPluginState } from './plugin-factory';
5
5
  import { findReplacePluginKey } from './plugin-key';
6
6
  export const initialState = {
@@ -16,7 +16,7 @@ export const initialState = {
16
16
  export const createPlugin = (dispatch, getIntl, api) => {
17
17
  return new SafePlugin({
18
18
  key: findReplacePluginKey,
19
- state: createPluginState(dispatch, () => fg('platform_editor_find_and_replace_part_2') ? {
19
+ state: createPluginState(dispatch, () => expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? {
20
20
  ...initialState,
21
21
  getIntl,
22
22
  api
@@ -1,4 +1,4 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
1
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
2
  import { FindReplaceActionTypes } from './actions';
3
3
  const reducer = getInitialState => (state, action) => {
4
4
  switch (action.type) {
@@ -43,7 +43,7 @@ const reducer = getInitialState => (state, action) => {
43
43
  getIntl,
44
44
  api
45
45
  } = state;
46
- return fg('platform_editor_find_and_replace_part_2') ? {
46
+ return expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? {
47
47
  ...getInitialState(),
48
48
  getIntl,
49
49
  api