@atlaskit/editor-plugin-find-replace 2.2.6 → 2.2.8

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,20 @@
1
1
  # @atlaskit/editor-plugin-find-replace
2
2
 
3
+ ## 2.2.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [#165597](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/165597)
8
+ [`7091d26926b74`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7091d26926b74) -
9
+ [ED-28128] this change is adding an optional field to the Match type in the FindReplace plugin
10
+ - Updated dependencies
11
+
12
+ ## 2.2.7
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 2.2.6
4
19
 
5
20
  ### Patch Changes
@@ -220,8 +220,8 @@ var updateSelectedHighlight = function updateSelectedHighlight(state, nextSelect
220
220
  var _getPluginState9 = (0, _pluginFactory.getPluginState)(state),
221
221
  index = _getPluginState9.index,
222
222
  matches = _getPluginState9.matches;
223
- var _getPluginState10 = (0, _pluginFactory.getPluginState)(state),
224
- decorationSet = _getPluginState10.decorationSet;
223
+ var _getPluginState0 = (0, _pluginFactory.getPluginState)(state),
224
+ decorationSet = _getPluginState0.decorationSet;
225
225
  var currentSelectedMatch = matches[index];
226
226
  var nextSelectedMatch = matches[nextSelectedIndex];
227
227
  if (index === nextSelectedIndex) {
@@ -40,7 +40,8 @@ var handleDocChanged = function handleDocChanged(tr, pluginState) {
40
40
  var mappedMatches = matches.map(function (match) {
41
41
  return {
42
42
  start: tr.mapping.map(match.start),
43
- end: tr.mapping.map(match.end)
43
+ end: tr.mapping.map(match.end),
44
+ canReplace: match.canReplace
44
45
  };
45
46
  });
46
47
  var matchesToAdd = [];
@@ -177,7 +177,7 @@ var BatchDecorations = /*#__PURE__*/function () {
177
177
  }
178
178
  }, _callee3, this);
179
179
  }));
180
- function addDecorationsBetween(_x8, _x9, _x10) {
180
+ function addDecorationsBetween(_x8, _x9, _x0) {
181
181
  return _addDecorationsBetween.apply(this, arguments);
182
182
  }
183
183
  return addDecorationsBetween;
@@ -227,7 +227,7 @@ var BatchDecorations = /*#__PURE__*/function () {
227
227
  }
228
228
  }, _callee4, this);
229
229
  }));
230
- function removeDecorationsBetween(_x11, _x12, _x13) {
230
+ function removeDecorationsBetween(_x1, _x10, _x11) {
231
231
  return _removeDecorationsBetween.apply(this, arguments);
232
232
  }
233
233
  return removeDecorationsBetween;
@@ -10,6 +10,7 @@ exports.getSelectedText = getSelectedText;
10
10
  exports.removeMatchesFromSet = exports.removeDecorationsFromSet = exports.prevIndex = exports.nextIndex = exports.isMatchAffectedByStep = exports.getSelectionForMatch = void 0;
11
11
  var _state = require("@atlaskit/editor-prosemirror/state");
12
12
  var _view = require("@atlaskit/editor-prosemirror/view");
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _styles = require("../../ui/styles");
14
15
  function getSelectedText(selection) {
15
16
  var text = '';
@@ -60,7 +61,8 @@ function findMatches(content, searchText, shouldMatchCase) {
60
61
  // Add the substring index to the position of the node
61
62
  matches.push({
62
63
  start: pos + index,
63
- end: pos + end
64
+ end: pos + end,
65
+ canReplace: (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1') ? true : undefined
64
66
  });
65
67
  index = text.indexOf(searchText, end);
66
68
  }
@@ -15,8 +15,7 @@ var _commandsWithAnalytics = require("../pm-plugins/commands-with-analytics");
15
15
  var _FindReplaceDropdown = _interopRequireDefault(require("./FindReplaceDropdown"));
16
16
  var _FindReplaceToolbarButton = _interopRequireDefault(require("./FindReplaceToolbarButton"));
17
17
  var _useFindReplacePluginStateSelector = require("./hooks/useFindReplacePluginStateSelector");
18
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
19
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
+ 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); }
20
19
  // light implementation of useSharedPluginState(). This is due to findreplace
21
20
  // being the only plugin that previously used WithPluginState with
22
21
  // debounce=false. That was implemented because of text sync issues
@@ -25,8 +25,7 @@ var _primitives = require("@atlaskit/primitives");
25
25
  var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
26
26
  var _FindReplaceTooltipButton = require("./FindReplaceTooltipButton");
27
27
  var _uiStyles = require("./ui-styles");
28
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
29
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
28
+ 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); }
30
29
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
31
30
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */ /**
32
31
  * @jsxRuntime classic
@@ -18,8 +18,7 @@ var _chevronUpHipchatChevronUp = _interopRequireDefault(require("@atlaskit/icon/
18
18
  var _primitives = require("@atlaskit/primitives");
19
19
  var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
20
20
  var _FindReplaceTooltipButton = require("./FindReplaceTooltipButton");
21
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
22
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
+ 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
22
  var replaceContainerStyles = (0, _primitives.xcss)({
24
23
  padding: 'space.100'
25
24
  });
@@ -69,9 +68,9 @@ var Replace = function Replace(_ref) {
69
68
  fakeSuccessReplacementMessageUpdate = _useState8[0],
70
69
  setFakeSuccessReplacementMessageUpdate = _useState8[1];
71
70
  var _useState9 = (0, _react.useState)(0),
72
- _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
73
- replaceCount = _useState10[0],
74
- setReplaceCount = _useState10[1];
71
+ _useState0 = (0, _slicedToArray2.default)(_useState9, 2),
72
+ replaceCount = _useState0[0],
73
+ setReplaceCount = _useState0[1];
75
74
  var replaceTextfieldRef = (0, _react.useRef)(null);
76
75
  var successReplacementMessageRef = (0, _react.useRef)(null);
77
76
  var replaceWith = formatMessage(_messages.findReplaceMessages.replaceWith);
@@ -31,7 +31,8 @@ const handleDocChanged = (tr, pluginState) => {
31
31
  const numDecorations = decorationSet.find().length;
32
32
  const mappedMatches = matches.map(match => ({
33
33
  start: tr.mapping.map(match.start),
34
- end: tr.mapping.map(match.end)
34
+ end: tr.mapping.map(match.end),
35
+ canReplace: match.canReplace
35
36
  }));
36
37
  let matchesToAdd = [];
37
38
  let matchesToDelete = [];
@@ -1,5 +1,6 @@
1
1
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { searchMatchClass, selectedSearchMatchClass } from '../../ui/styles';
4
5
  export function getSelectedText(selection) {
5
6
  let text = '';
@@ -48,7 +49,8 @@ export function findMatches(content, searchText, shouldMatchCase, contentIndex =
48
49
  // Add the substring index to the position of the node
49
50
  matches.push({
50
51
  start: pos + index,
51
- end: pos + end
52
+ end: pos + end,
53
+ canReplace: fg('platform_editor_find_and_replace_1') ? true : undefined
52
54
  });
53
55
  index = text.indexOf(searchText, end);
54
56
  }
@@ -213,8 +213,8 @@ var updateSelectedHighlight = function updateSelectedHighlight(state, nextSelect
213
213
  var _getPluginState9 = getPluginState(state),
214
214
  index = _getPluginState9.index,
215
215
  matches = _getPluginState9.matches;
216
- var _getPluginState10 = getPluginState(state),
217
- decorationSet = _getPluginState10.decorationSet;
216
+ var _getPluginState0 = getPluginState(state),
217
+ decorationSet = _getPluginState0.decorationSet;
218
218
  var currentSelectedMatch = matches[index];
219
219
  var nextSelectedMatch = matches[nextSelectedIndex];
220
220
  if (index === nextSelectedIndex) {
@@ -32,7 +32,8 @@ var handleDocChanged = function handleDocChanged(tr, pluginState) {
32
32
  var mappedMatches = matches.map(function (match) {
33
33
  return {
34
34
  start: tr.mapping.map(match.start),
35
- end: tr.mapping.map(match.end)
35
+ end: tr.mapping.map(match.end),
36
+ canReplace: match.canReplace
36
37
  };
37
38
  });
38
39
  var matchesToAdd = [];
@@ -171,7 +171,7 @@ var BatchDecorations = /*#__PURE__*/function () {
171
171
  }
172
172
  }, _callee3, this);
173
173
  }));
174
- function addDecorationsBetween(_x8, _x9, _x10) {
174
+ function addDecorationsBetween(_x8, _x9, _x0) {
175
175
  return _addDecorationsBetween.apply(this, arguments);
176
176
  }
177
177
  return addDecorationsBetween;
@@ -221,7 +221,7 @@ var BatchDecorations = /*#__PURE__*/function () {
221
221
  }
222
222
  }, _callee4, this);
223
223
  }));
224
- function removeDecorationsBetween(_x11, _x12, _x13) {
224
+ function removeDecorationsBetween(_x1, _x10, _x11) {
225
225
  return _removeDecorationsBetween.apply(this, arguments);
226
226
  }
227
227
  return removeDecorationsBetween;
@@ -1,5 +1,6 @@
1
1
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { searchMatchClass, selectedSearchMatchClass } from '../../ui/styles';
4
5
  export function getSelectedText(selection) {
5
6
  var text = '';
@@ -50,7 +51,8 @@ export function findMatches(content, searchText, shouldMatchCase) {
50
51
  // Add the substring index to the position of the node
51
52
  matches.push({
52
53
  start: pos + index,
53
- end: pos + end
54
+ end: pos + end,
55
+ canReplace: fg('platform_editor_find_and_replace_1') ? true : undefined
54
56
  });
55
57
  index = text.indexOf(searchText, end);
56
58
  }
@@ -59,9 +59,9 @@ var Replace = function Replace(_ref) {
59
59
  fakeSuccessReplacementMessageUpdate = _useState8[0],
60
60
  setFakeSuccessReplacementMessageUpdate = _useState8[1];
61
61
  var _useState9 = useState(0),
62
- _useState10 = _slicedToArray(_useState9, 2),
63
- replaceCount = _useState10[0],
64
- setReplaceCount = _useState10[1];
62
+ _useState0 = _slicedToArray(_useState9, 2),
63
+ replaceCount = _useState0[0],
64
+ setReplaceCount = _useState0[1];
65
65
  var replaceTextfieldRef = useRef(null);
66
66
  var successReplacementMessageRef = useRef(null);
67
67
  var replaceWith = formatMessage(messages.replaceWith);
@@ -42,6 +42,8 @@ export type Match = {
42
42
  start: number;
43
43
  /** End position */
44
44
  end: number;
45
+ /** Boolean for whether the match can be replaced */
46
+ canReplace?: boolean;
45
47
  };
46
48
  export type TextGrouping = {
47
49
  /** The concatenated text across nodes */
@@ -42,6 +42,8 @@ export type Match = {
42
42
  start: number;
43
43
  /** End position */
44
44
  end: number;
45
+ /** Boolean for whether the match can be replaced */
46
+ canReplace?: boolean;
45
47
  };
46
48
  export type TextGrouping = {
47
49
  /** The concatenated text across nodes */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-find-replace",
3
- "version": "2.2.6",
3
+ "version": "2.2.8",
4
4
  "description": "find replace plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@atlaskit/button": "^23.2.0",
36
- "@atlaskit/editor-common": "^106.0.0",
36
+ "@atlaskit/editor-common": "^106.2.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^2.3.0",
38
38
  "@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
39
39
  "@atlaskit/editor-prosemirror": "7.0.0",
@@ -44,9 +44,9 @@
44
44
  "@atlaskit/primitives": "^14.8.0",
45
45
  "@atlaskit/textfield": "^8.0.0",
46
46
  "@atlaskit/theme": "^18.0.0",
47
- "@atlaskit/tmp-editor-statsig": "^5.2.0",
48
- "@atlaskit/tokens": "^4.9.0",
49
- "@atlaskit/tooltip": "^20.2.0",
47
+ "@atlaskit/tmp-editor-statsig": "^5.12.0",
48
+ "@atlaskit/tokens": "^5.0.0",
49
+ "@atlaskit/tooltip": "^20.3.0",
50
50
  "@babel/runtime": "^7.0.0",
51
51
  "@emotion/react": "^11.7.1",
52
52
  "lodash": "^4.17.21",
@@ -118,6 +118,9 @@
118
118
  },
119
119
  "editor_a11y_refactor_find_replace_style": {
120
120
  "type": "boolean"
121
+ },
122
+ "platform_editor_find_and_replace_1": {
123
+ "type": "boolean"
121
124
  }
122
125
  }
123
126
  }