@atlaskit/editor-plugin-find-replace 3.0.2 → 3.1.1

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,24 @@
1
1
  # @atlaskit/editor-plugin-find-replace
2
2
 
3
+ ## 3.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 3.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#179798](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/179798)
14
+ [`b74544d17393f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b74544d17393f) -
15
+ [ux] [ED-27963] this change is creating a new Editor Command inside expandPlugin to toggle open
16
+ expands with active matches from Find&Replace
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 3.0.2
4
23
 
5
24
  ### Patch Changes
@@ -36,7 +36,7 @@ var findWithAnalytics = exports.findWithAnalytics = function findWithAnalytics(e
36
36
  })((0, _commands.find)(editorView, containerElement, keyword));
37
37
  };
38
38
  };
39
- var findNextWithAnalytics = exports.findNextWithAnalytics = function findNextWithAnalytics(editorAnalyticsAPI) {
39
+ var findNextWithAnalytics = exports.findNextWithAnalytics = function findNextWithAnalytics(editorAnalyticsAPI, editorView) {
40
40
  return function (_ref3) {
41
41
  var triggerMethod = _ref3.triggerMethod;
42
42
  return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
@@ -46,10 +46,10 @@ var findNextWithAnalytics = exports.findNextWithAnalytics = function findNextWit
46
46
  attributes: {
47
47
  triggerMethod: triggerMethod
48
48
  }
49
- })((0, _commands.findNext)());
49
+ })((0, _commands.findNext)(editorView));
50
50
  };
51
51
  };
52
- var findPrevWithAnalytics = exports.findPrevWithAnalytics = function findPrevWithAnalytics(editorAnalyticsAPI) {
52
+ var findPrevWithAnalytics = exports.findPrevWithAnalytics = function findPrevWithAnalytics(editorAnalyticsAPI, editorView) {
53
53
  return function (_ref4) {
54
54
  var triggerMethod = _ref4.triggerMethod;
55
55
  return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
@@ -59,7 +59,7 @@ var findPrevWithAnalytics = exports.findPrevWithAnalytics = function findPrevWit
59
59
  attributes: {
60
60
  triggerMethod: triggerMethod
61
61
  }
62
- })((0, _commands.findPrevious)());
62
+ })((0, _commands.findPrevious)(editorView));
63
63
  };
64
64
  };
65
65
  var replaceWithAnalytics = exports.replaceWithAnalytics = function replaceWithAnalytics(editorAnalyticsAPI) {
@@ -9,6 +9,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
9
9
  var _view = require("@atlaskit/editor-prosemirror/view");
10
10
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
11
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
12
+ var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
12
13
  var _actions = require("./actions");
13
14
  var _pluginFactory = require("./plugin-factory");
14
15
  var _utils = require("./utils");
@@ -89,18 +90,27 @@ var find = exports.find = function find(editorView, containerElement, keyword) {
89
90
  }) : [];
90
91
  if (matches.length > 0) {
91
92
  var index = (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_improvements_1') ? (0, _utils.findClosestMatch)(selection.from, matches) : (0, _utils.findSearchIndex)(selection.from, matches);
92
- return tr.setSelection((0, _utils.getSelectionForMatch)(tr.selection, tr.doc, index, matches));
93
+ var newSelection = (0, _utils.getSelectionForMatch)(tr.selection, tr.doc, index, matches);
94
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_toggle_expand_on_match_found', 'isEnabled', true)) {
95
+ var _api$expand;
96
+ // the exposure is fired inside toggleExpandWithMatch when user is exposed to the experiment
97
+ api === null || api === void 0 || (_api$expand = api.expand) === null || _api$expand === void 0 || _api$expand.commands.toggleExpandWithMatch(newSelection)({
98
+ tr: tr
99
+ });
100
+ }
101
+ return tr.setSelection(newSelection);
93
102
  }
94
103
  return tr;
95
104
  }));
96
105
  };
97
- var findNext = exports.findNext = function findNext() {
106
+ var findNext = exports.findNext = function findNext(editorView) {
98
107
  return (0, _commands.withScrollIntoView)((0, _pluginFactory.createCommand)(function (state) {
99
108
  return findInDirection(state, 'next');
100
109
  }, function (tr, state) {
101
110
  var _getPluginState4 = (0, _pluginFactory.getPluginState)(state),
102
111
  matches = _getPluginState4.matches,
103
- index = _getPluginState4.index;
112
+ index = _getPluginState4.index,
113
+ api = _getPluginState4.api;
104
114
  // can't use index from plugin state because if the cursor has moved, it will still be the
105
115
  // OLD index (the find next operation should look for the first match forward starting
106
116
  // from the current cursor position)
@@ -109,20 +119,37 @@ var findNext = exports.findNext = function findNext() {
109
119
  // cursor has not moved, so we just want to find the next in matches array
110
120
  searchIndex = (0, _utils.nextIndex)(searchIndex, matches.length);
111
121
  }
112
- return tr.setSelection((0, _utils.getSelectionForMatch)(tr.selection, tr.doc, searchIndex, matches));
122
+ var newSelection = (0, _utils.getSelectionForMatch)(tr.selection, tr.doc, searchIndex, matches);
123
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_toggle_expand_on_match_found', 'isEnabled', true)) {
124
+ var _api$expand2;
125
+ // the exposure is fired inside toggleExpandWithMatch when user is exposed to the experiment
126
+ api === null || api === void 0 || (_api$expand2 = api.expand) === null || _api$expand2 === void 0 || _api$expand2.commands.toggleExpandWithMatch(newSelection)({
127
+ tr: tr
128
+ });
129
+ }
130
+ return tr.setSelection(newSelection);
113
131
  }));
114
132
  };
115
- var findPrevious = exports.findPrevious = function findPrevious() {
133
+ var findPrevious = exports.findPrevious = function findPrevious(editorView) {
116
134
  return (0, _commands.withScrollIntoView)((0, _pluginFactory.createCommand)(function (state) {
117
135
  return findInDirection(state, 'previous');
118
136
  }, function (tr, state) {
119
137
  var _getPluginState5 = (0, _pluginFactory.getPluginState)(state),
120
- matches = _getPluginState5.matches;
138
+ matches = _getPluginState5.matches,
139
+ api = _getPluginState5.api;
121
140
  // can't use index from plugin state because if the cursor has moved, it will still be the
122
141
  // OLD index (the find prev operation should look for the first match backward starting
123
142
  // from the current cursor position)
124
143
  var searchIndex = (0, _utils.findSearchIndex)(state.selection.from, matches, true);
125
- return tr.setSelection((0, _utils.getSelectionForMatch)(tr.selection, tr.doc, searchIndex, matches));
144
+ var newSelection = (0, _utils.getSelectionForMatch)(tr.selection, tr.doc, searchIndex, matches);
145
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_toggle_expand_on_match_found', 'isEnabled', true)) {
146
+ var _api$expand3;
147
+ // the exposure is fired inside toggleExpandWithMatch when user is exposed to the experiment
148
+ api === null || api === void 0 || (_api$expand3 = api.expand) === null || _api$expand3 === void 0 || _api$expand3.commands.toggleExpandWithMatch(newSelection)({
149
+ tr: tr
150
+ });
151
+ }
152
+ return tr.setSelection(newSelection);
126
153
  }));
127
154
  };
128
155
  var findInDirection = function findInDirection(state, dir) {
@@ -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, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? _objectSpread(_objectSpread({}, initialState), {}, {
30
+ return (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) || (0, _expValEquals.expValEquals)('platform_editor_toggle_expand_on_match_found', 'isEnabled', true) ? _objectSpread(_objectSpread({}, initialState), {}, {
31
31
  getIntl: getIntl,
32
32
  api: api
33
33
  }) : _objectSpread({}, initialState);
@@ -11,6 +11,7 @@ var _utils = require("@atlaskit/editor-common/utils");
11
11
  var _view = require("@atlaskit/editor-prosemirror/view");
12
12
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
13
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
14
+ var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
14
15
  var _main = require("./main");
15
16
  var _pluginKey = require("./plugin-key");
16
17
  var _reducer = _interopRequireDefault(require("./reducer"));
@@ -110,6 +111,14 @@ var handleDocChanged = function handleDocChanged(tr, pluginState) {
110
111
  if (newSelectedMatch) {
111
112
  decorationSet = decorationSet.add(tr.doc, (0, _utils2.createDecorations)(0, [newSelectedMatch]));
112
113
  }
114
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_toggle_expand_on_match_found', 'isEnabled', true)) {
115
+ var _api$expand;
116
+ var newSelection = (0, _utils2.getSelectionForMatch)(tr.selection, tr.doc, newIndex, newMatches);
117
+ // the exposure is fired inside toggleExpandWithMatch when user is exposed to the experiment
118
+ api === null || api === void 0 || (_api$expand = api.expand) === null || _api$expand === void 0 || _api$expand.commands.toggleExpandWithMatch(newSelection)({
119
+ tr: tr
120
+ });
121
+ }
113
122
  return _objectSpread(_objectSpread({}, pluginState), {}, {
114
123
  matches: newMatches,
115
124
  index: newIndex,
@@ -100,7 +100,7 @@ var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithSta
100
100
  var handleFindNext = function handleFindNext(_ref3) {
101
101
  var triggerMethod = _ref3.triggerMethod;
102
102
  runWithEditorFocused(function () {
103
- return dispatchCommand((0, _commandsWithAnalytics.findNextWithAnalytics)(editorAnalyticsAPI)({
103
+ return dispatchCommand((0, _commandsWithAnalytics.findNextWithAnalytics)(editorAnalyticsAPI, editorView)({
104
104
  triggerMethod: triggerMethod
105
105
  }));
106
106
  });
@@ -108,7 +108,7 @@ var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithSta
108
108
  var handleFindPrev = function handleFindPrev(_ref4) {
109
109
  var triggerMethod = _ref4.triggerMethod;
110
110
  runWithEditorFocused(function () {
111
- return dispatchCommand((0, _commandsWithAnalytics.findPrevWithAnalytics)(editorAnalyticsAPI)({
111
+ return dispatchCommand((0, _commandsWithAnalytics.findPrevWithAnalytics)(editorAnalyticsAPI, editorView)({
112
112
  triggerMethod: triggerMethod
113
113
  }));
114
114
  });
@@ -22,17 +22,19 @@ export const findWithAnalytics = editorAnalyticsAPI => ({
22
22
  action: ACTION.FIND_PERFORMED,
23
23
  actionSubject: ACTION_SUBJECT.TEXT
24
24
  })(find(editorView, containerElement, keyword));
25
- export const findNextWithAnalytics = editorAnalyticsAPI => ({
25
+ export const findNextWithAnalytics = (editorAnalyticsAPI, editorView) => ({
26
26
  triggerMethod
27
- }) => withAnalytics(editorAnalyticsAPI, {
28
- eventType: EVENT_TYPE.TRACK,
29
- action: ACTION.FIND_NEXT_PERFORMED,
30
- actionSubject: ACTION_SUBJECT.TEXT,
31
- attributes: {
32
- triggerMethod
33
- }
34
- })(findNext());
35
- export const findPrevWithAnalytics = editorAnalyticsAPI => ({
27
+ }) => {
28
+ return withAnalytics(editorAnalyticsAPI, {
29
+ eventType: EVENT_TYPE.TRACK,
30
+ action: ACTION.FIND_NEXT_PERFORMED,
31
+ actionSubject: ACTION_SUBJECT.TEXT,
32
+ attributes: {
33
+ triggerMethod
34
+ }
35
+ })(findNext(editorView));
36
+ };
37
+ export const findPrevWithAnalytics = (editorAnalyticsAPI, editorView) => ({
36
38
  triggerMethod
37
39
  }) => withAnalytics(editorAnalyticsAPI, {
38
40
  eventType: EVENT_TYPE.TRACK,
@@ -41,7 +43,7 @@ export const findPrevWithAnalytics = editorAnalyticsAPI => ({
41
43
  attributes: {
42
44
  triggerMethod
43
45
  }
44
- })(findPrevious());
46
+ })(findPrevious(editorView));
45
47
  export const replaceWithAnalytics = editorAnalyticsAPI => ({
46
48
  triggerMethod,
47
49
  replaceText
@@ -2,6 +2,7 @@ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
4
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
5
6
  import { FindReplaceActionTypes } from './actions';
6
7
  import { createCommand, getPluginState } from './plugin-factory';
7
8
  import { createDecoration, findClosestMatch, findDecorationFromMatch, findMatches, findSearchIndex, getSelectedText, getSelectionForMatch, nextIndex, prevIndex, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
@@ -84,14 +85,23 @@ export const find = (editorView, containerElement, keyword) => withScrollIntoVie
84
85
  }) : [];
85
86
  if (matches.length > 0) {
86
87
  const index = expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) && fg('platform_editor_find_and_replace_improvements_1') ? findClosestMatch(selection.from, matches) : findSearchIndex(selection.from, matches);
87
- return tr.setSelection(getSelectionForMatch(tr.selection, tr.doc, index, matches));
88
+ const newSelection = getSelectionForMatch(tr.selection, tr.doc, index, matches);
89
+ if (expValEqualsNoExposure('platform_editor_toggle_expand_on_match_found', 'isEnabled', true)) {
90
+ var _api$expand;
91
+ // the exposure is fired inside toggleExpandWithMatch when user is exposed to the experiment
92
+ api === null || api === void 0 ? void 0 : (_api$expand = api.expand) === null || _api$expand === void 0 ? void 0 : _api$expand.commands.toggleExpandWithMatch(newSelection)({
93
+ tr
94
+ });
95
+ }
96
+ return tr.setSelection(newSelection);
88
97
  }
89
98
  return tr;
90
99
  }));
91
- export const findNext = () => withScrollIntoView(createCommand(state => findInDirection(state, 'next'), (tr, state) => {
100
+ export const findNext = editorView => withScrollIntoView(createCommand(state => findInDirection(state, 'next'), (tr, state) => {
92
101
  const {
93
102
  matches,
94
- index
103
+ index,
104
+ api
95
105
  } = getPluginState(state);
96
106
  // can't use index from plugin state because if the cursor has moved, it will still be the
97
107
  // OLD index (the find next operation should look for the first match forward starting
@@ -101,17 +111,34 @@ export const findNext = () => withScrollIntoView(createCommand(state => findInDi
101
111
  // cursor has not moved, so we just want to find the next in matches array
102
112
  searchIndex = nextIndex(searchIndex, matches.length);
103
113
  }
104
- return tr.setSelection(getSelectionForMatch(tr.selection, tr.doc, searchIndex, matches));
114
+ const newSelection = getSelectionForMatch(tr.selection, tr.doc, searchIndex, matches);
115
+ if (expValEqualsNoExposure('platform_editor_toggle_expand_on_match_found', 'isEnabled', true)) {
116
+ var _api$expand2;
117
+ // the exposure is fired inside toggleExpandWithMatch when user is exposed to the experiment
118
+ api === null || api === void 0 ? void 0 : (_api$expand2 = api.expand) === null || _api$expand2 === void 0 ? void 0 : _api$expand2.commands.toggleExpandWithMatch(newSelection)({
119
+ tr
120
+ });
121
+ }
122
+ return tr.setSelection(newSelection);
105
123
  }));
106
- export const findPrevious = () => withScrollIntoView(createCommand(state => findInDirection(state, 'previous'), (tr, state) => {
124
+ export const findPrevious = editorView => withScrollIntoView(createCommand(state => findInDirection(state, 'previous'), (tr, state) => {
107
125
  const {
108
- matches
126
+ matches,
127
+ api
109
128
  } = getPluginState(state);
110
129
  // can't use index from plugin state because if the cursor has moved, it will still be the
111
130
  // OLD index (the find prev operation should look for the first match backward starting
112
131
  // from the current cursor position)
113
132
  const searchIndex = findSearchIndex(state.selection.from, matches, true);
114
- return tr.setSelection(getSelectionForMatch(tr.selection, tr.doc, searchIndex, matches));
133
+ const newSelection = getSelectionForMatch(tr.selection, tr.doc, searchIndex, matches);
134
+ if (expValEqualsNoExposure('platform_editor_toggle_expand_on_match_found', 'isEnabled', true)) {
135
+ var _api$expand3;
136
+ // the exposure is fired inside toggleExpandWithMatch when user is exposed to the experiment
137
+ api === null || api === void 0 ? void 0 : (_api$expand3 = api.expand) === null || _api$expand3 === void 0 ? void 0 : _api$expand3.commands.toggleExpandWithMatch(newSelection)({
138
+ tr
139
+ });
140
+ }
141
+ return tr.setSelection(newSelection);
115
142
  }));
116
143
  const findInDirection = (state, dir) => {
117
144
  const pluginState = getPluginState(state);
@@ -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, () => expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? {
19
+ state: createPluginState(dispatch, () => expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) || expValEquals('platform_editor_toggle_expand_on_match_found', 'isEnabled', true) ? {
20
20
  ...initialState,
21
21
  getIntl,
22
22
  api
@@ -2,10 +2,11 @@ import { pluginFactory, stepHasSlice } from '@atlaskit/editor-common/utils';
2
2
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
4
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
5
6
  import { initialState } from './main';
6
7
  import { findReplacePluginKey } from './plugin-key';
7
8
  import reducer from './reducer';
8
- import { createDecorations, findClosestMatch, findDecorationFromMatch, findMatches, findSearchIndex, isMatchAffectedByStep, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
9
+ import { createDecorations, findClosestMatch, findDecorationFromMatch, findMatches, findSearchIndex, getSelectionForMatch, isMatchAffectedByStep, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
9
10
  import { findUniqueItemsIn } from './utils/array'; // TODO: ED-26959 - move into index export
10
11
 
11
12
  const handleDocChanged = (tr, pluginState) => {
@@ -90,6 +91,14 @@ const handleDocChanged = (tr, pluginState) => {
90
91
  if (newSelectedMatch) {
91
92
  decorationSet = decorationSet.add(tr.doc, createDecorations(0, [newSelectedMatch]));
92
93
  }
94
+ if (expValEqualsNoExposure('platform_editor_toggle_expand_on_match_found', 'isEnabled', true)) {
95
+ var _api$expand;
96
+ const newSelection = getSelectionForMatch(tr.selection, tr.doc, newIndex, newMatches);
97
+ // the exposure is fired inside toggleExpandWithMatch when user is exposed to the experiment
98
+ api === null || api === void 0 ? void 0 : (_api$expand = api.expand) === null || _api$expand === void 0 ? void 0 : _api$expand.commands.toggleExpandWithMatch(newSelection)({
99
+ tr: tr
100
+ });
101
+ }
93
102
  return {
94
103
  ...pluginState,
95
104
  matches: newMatches,
@@ -89,14 +89,14 @@ const FindReplaceToolbarButtonWithState = ({
89
89
  const handleFindNext = ({
90
90
  triggerMethod
91
91
  }) => {
92
- runWithEditorFocused(() => dispatchCommand(findNextWithAnalytics(editorAnalyticsAPI)({
92
+ runWithEditorFocused(() => dispatchCommand(findNextWithAnalytics(editorAnalyticsAPI, editorView)({
93
93
  triggerMethod
94
94
  })));
95
95
  };
96
96
  const handleFindPrev = ({
97
97
  triggerMethod
98
98
  }) => {
99
- runWithEditorFocused(() => dispatchCommand(findPrevWithAnalytics(editorAnalyticsAPI)({
99
+ runWithEditorFocused(() => dispatchCommand(findPrevWithAnalytics(editorAnalyticsAPI, editorView)({
100
100
  triggerMethod
101
101
  })));
102
102
  };
@@ -30,7 +30,7 @@ export var findWithAnalytics = function findWithAnalytics(editorAnalyticsAPI) {
30
30
  })(find(editorView, containerElement, keyword));
31
31
  };
32
32
  };
33
- export var findNextWithAnalytics = function findNextWithAnalytics(editorAnalyticsAPI) {
33
+ export var findNextWithAnalytics = function findNextWithAnalytics(editorAnalyticsAPI, editorView) {
34
34
  return function (_ref3) {
35
35
  var triggerMethod = _ref3.triggerMethod;
36
36
  return withAnalytics(editorAnalyticsAPI, {
@@ -40,10 +40,10 @@ export var findNextWithAnalytics = function findNextWithAnalytics(editorAnalytic
40
40
  attributes: {
41
41
  triggerMethod: triggerMethod
42
42
  }
43
- })(findNext());
43
+ })(findNext(editorView));
44
44
  };
45
45
  };
46
- export var findPrevWithAnalytics = function findPrevWithAnalytics(editorAnalyticsAPI) {
46
+ export var findPrevWithAnalytics = function findPrevWithAnalytics(editorAnalyticsAPI, editorView) {
47
47
  return function (_ref4) {
48
48
  var triggerMethod = _ref4.triggerMethod;
49
49
  return withAnalytics(editorAnalyticsAPI, {
@@ -53,7 +53,7 @@ export var findPrevWithAnalytics = function findPrevWithAnalytics(editorAnalytic
53
53
  attributes: {
54
54
  triggerMethod: triggerMethod
55
55
  }
56
- })(findPrevious());
56
+ })(findPrevious(editorView));
57
57
  };
58
58
  };
59
59
  export var replaceWithAnalytics = function replaceWithAnalytics(editorAnalyticsAPI) {
@@ -2,6 +2,7 @@ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
4
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
5
6
  import { FindReplaceActionTypes } from './actions';
6
7
  import { createCommand, getPluginState } from './plugin-factory';
7
8
  import { createDecoration, findClosestMatch, findDecorationFromMatch, findMatches, findSearchIndex, getSelectedText, getSelectionForMatch, nextIndex, prevIndex, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
@@ -82,18 +83,27 @@ export var find = function find(editorView, containerElement, keyword) {
82
83
  }) : [];
83
84
  if (matches.length > 0) {
84
85
  var index = expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) && fg('platform_editor_find_and_replace_improvements_1') ? findClosestMatch(selection.from, matches) : findSearchIndex(selection.from, matches);
85
- return tr.setSelection(getSelectionForMatch(tr.selection, tr.doc, index, matches));
86
+ var newSelection = getSelectionForMatch(tr.selection, tr.doc, index, matches);
87
+ if (expValEqualsNoExposure('platform_editor_toggle_expand_on_match_found', 'isEnabled', true)) {
88
+ var _api$expand;
89
+ // the exposure is fired inside toggleExpandWithMatch when user is exposed to the experiment
90
+ api === null || api === void 0 || (_api$expand = api.expand) === null || _api$expand === void 0 || _api$expand.commands.toggleExpandWithMatch(newSelection)({
91
+ tr: tr
92
+ });
93
+ }
94
+ return tr.setSelection(newSelection);
86
95
  }
87
96
  return tr;
88
97
  }));
89
98
  };
90
- export var findNext = function findNext() {
99
+ export var findNext = function findNext(editorView) {
91
100
  return withScrollIntoView(createCommand(function (state) {
92
101
  return findInDirection(state, 'next');
93
102
  }, function (tr, state) {
94
103
  var _getPluginState4 = getPluginState(state),
95
104
  matches = _getPluginState4.matches,
96
- index = _getPluginState4.index;
105
+ index = _getPluginState4.index,
106
+ api = _getPluginState4.api;
97
107
  // can't use index from plugin state because if the cursor has moved, it will still be the
98
108
  // OLD index (the find next operation should look for the first match forward starting
99
109
  // from the current cursor position)
@@ -102,20 +112,37 @@ export var findNext = function findNext() {
102
112
  // cursor has not moved, so we just want to find the next in matches array
103
113
  searchIndex = nextIndex(searchIndex, matches.length);
104
114
  }
105
- return tr.setSelection(getSelectionForMatch(tr.selection, tr.doc, searchIndex, matches));
115
+ var newSelection = getSelectionForMatch(tr.selection, tr.doc, searchIndex, matches);
116
+ if (expValEqualsNoExposure('platform_editor_toggle_expand_on_match_found', 'isEnabled', true)) {
117
+ var _api$expand2;
118
+ // the exposure is fired inside toggleExpandWithMatch when user is exposed to the experiment
119
+ api === null || api === void 0 || (_api$expand2 = api.expand) === null || _api$expand2 === void 0 || _api$expand2.commands.toggleExpandWithMatch(newSelection)({
120
+ tr: tr
121
+ });
122
+ }
123
+ return tr.setSelection(newSelection);
106
124
  }));
107
125
  };
108
- export var findPrevious = function findPrevious() {
126
+ export var findPrevious = function findPrevious(editorView) {
109
127
  return withScrollIntoView(createCommand(function (state) {
110
128
  return findInDirection(state, 'previous');
111
129
  }, function (tr, state) {
112
130
  var _getPluginState5 = getPluginState(state),
113
- matches = _getPluginState5.matches;
131
+ matches = _getPluginState5.matches,
132
+ api = _getPluginState5.api;
114
133
  // can't use index from plugin state because if the cursor has moved, it will still be the
115
134
  // OLD index (the find prev operation should look for the first match backward starting
116
135
  // from the current cursor position)
117
136
  var searchIndex = findSearchIndex(state.selection.from, matches, true);
118
- return tr.setSelection(getSelectionForMatch(tr.selection, tr.doc, searchIndex, matches));
137
+ var newSelection = getSelectionForMatch(tr.selection, tr.doc, searchIndex, matches);
138
+ if (expValEqualsNoExposure('platform_editor_toggle_expand_on_match_found', 'isEnabled', true)) {
139
+ var _api$expand3;
140
+ // the exposure is fired inside toggleExpandWithMatch when user is exposed to the experiment
141
+ api === null || api === void 0 || (_api$expand3 = api.expand) === null || _api$expand3 === void 0 || _api$expand3.commands.toggleExpandWithMatch(newSelection)({
142
+ tr: tr
143
+ });
144
+ }
145
+ return tr.setSelection(newSelection);
119
146
  }));
120
147
  };
121
148
  var findInDirection = function findInDirection(state, dir) {
@@ -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 expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? _objectSpread(_objectSpread({}, initialState), {}, {
23
+ return expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) || expValEquals('platform_editor_toggle_expand_on_match_found', 'isEnabled', true) ? _objectSpread(_objectSpread({}, initialState), {}, {
24
24
  getIntl: getIntl,
25
25
  api: api
26
26
  }) : _objectSpread({}, initialState);
@@ -6,10 +6,11 @@ import { pluginFactory, stepHasSlice } from '@atlaskit/editor-common/utils';
6
6
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
8
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
9
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
9
10
  import { initialState } from './main';
10
11
  import { findReplacePluginKey } from './plugin-key';
11
12
  import reducer from './reducer';
12
- import { createDecorations, findClosestMatch, findDecorationFromMatch, findMatches, findSearchIndex, isMatchAffectedByStep, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
13
+ import { createDecorations, findClosestMatch, findDecorationFromMatch, findMatches, findSearchIndex, getSelectionForMatch, isMatchAffectedByStep, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
13
14
  import { findUniqueItemsIn } from './utils/array'; // TODO: ED-26959 - move into index export
14
15
 
15
16
  var handleDocChanged = function handleDocChanged(tr, pluginState) {
@@ -102,6 +103,14 @@ var handleDocChanged = function handleDocChanged(tr, pluginState) {
102
103
  if (newSelectedMatch) {
103
104
  decorationSet = decorationSet.add(tr.doc, createDecorations(0, [newSelectedMatch]));
104
105
  }
106
+ if (expValEqualsNoExposure('platform_editor_toggle_expand_on_match_found', 'isEnabled', true)) {
107
+ var _api$expand;
108
+ var newSelection = getSelectionForMatch(tr.selection, tr.doc, newIndex, newMatches);
109
+ // the exposure is fired inside toggleExpandWithMatch when user is exposed to the experiment
110
+ api === null || api === void 0 || (_api$expand = api.expand) === null || _api$expand === void 0 || _api$expand.commands.toggleExpandWithMatch(newSelection)({
111
+ tr: tr
112
+ });
113
+ }
105
114
  return _objectSpread(_objectSpread({}, pluginState), {}, {
106
115
  matches: newMatches,
107
116
  index: newIndex,
@@ -92,7 +92,7 @@ var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithSta
92
92
  var handleFindNext = function handleFindNext(_ref3) {
93
93
  var triggerMethod = _ref3.triggerMethod;
94
94
  runWithEditorFocused(function () {
95
- return dispatchCommand(findNextWithAnalytics(editorAnalyticsAPI)({
95
+ return dispatchCommand(findNextWithAnalytics(editorAnalyticsAPI, editorView)({
96
96
  triggerMethod: triggerMethod
97
97
  }));
98
98
  });
@@ -100,7 +100,7 @@ var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithSta
100
100
  var handleFindPrev = function handleFindPrev(_ref4) {
101
101
  var triggerMethod = _ref4.triggerMethod;
102
102
  runWithEditorFocused(function () {
103
- return dispatchCommand(findPrevWithAnalytics(editorAnalyticsAPI)({
103
+ return dispatchCommand(findPrevWithAnalytics(editorAnalyticsAPI, editorView)({
104
104
  triggerMethod: triggerMethod
105
105
  }));
106
106
  });
@@ -3,6 +3,7 @@ import { type 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
5
  import type { CardPlugin } from '@atlaskit/editor-plugin-card';
6
+ import type { ExpandPlugin } from '@atlaskit/editor-plugin-expand';
6
7
  import type { MentionsPlugin } from '@atlaskit/editor-plugin-mentions';
7
8
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
8
9
  import type { FindReplacePluginState, FindReplaceToolbarButtonActionProps } from './types';
@@ -14,7 +15,8 @@ export type FindReplacePluginDependencies = [
14
15
  OptionalPlugin<AnalyticsPlugin>,
15
16
  OptionalPlugin<PrimaryToolbarPlugin>,
16
17
  OptionalPlugin<MentionsPlugin>,
17
- OptionalPlugin<CardPlugin>
18
+ OptionalPlugin<CardPlugin>,
19
+ OptionalPlugin<ExpandPlugin>
18
20
  ];
19
21
  export type FindReplacePlugin = NextEditorPlugin<'findReplace', {
20
22
  pluginConfiguration: FindReplacePluginOptions;
@@ -9,10 +9,10 @@ export declare const findWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI
9
9
  containerElement: HTMLElement | null;
10
10
  keyword?: string | undefined;
11
11
  }) => Command;
12
- export declare const findNextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ triggerMethod, }: {
12
+ export declare const findNextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorView: EditorView) => ({ triggerMethod, }: {
13
13
  triggerMethod: TRIGGER_METHOD.KEYBOARD | TRIGGER_METHOD.BUTTON;
14
14
  }) => Command;
15
- export declare const findPrevWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ triggerMethod, }: {
15
+ export declare const findPrevWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorView: EditorView) => ({ triggerMethod, }: {
16
16
  triggerMethod: TRIGGER_METHOD.KEYBOARD | TRIGGER_METHOD.BUTTON;
17
17
  }) => Command;
18
18
  export declare const replaceWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ triggerMethod, replaceText, }: {
@@ -1,8 +1,8 @@
1
1
  import type { Decoration, EditorView } from '@atlaskit/editor-prosemirror/view';
2
2
  export declare const activate: () => import("@atlaskit/editor-common/types").Command;
3
3
  export declare const find: (editorView: EditorView, containerElement: HTMLElement | null, keyword?: string) => import("@atlaskit/editor-common/types").Command;
4
- export declare const findNext: () => import("@atlaskit/editor-common/types").Command;
5
- export declare const findPrevious: () => import("@atlaskit/editor-common/types").Command;
4
+ export declare const findNext: (editorView: EditorView) => import("@atlaskit/editor-common/types").Command;
5
+ export declare const findPrevious: (editorView: EditorView) => import("@atlaskit/editor-common/types").Command;
6
6
  export declare const replace: (replaceText: string) => import("@atlaskit/editor-common/types").Command;
7
7
  export declare const replaceAll: (replaceText: string) => import("@atlaskit/editor-common/types").Command;
8
8
  export declare const addDecorations: (decorations: Decoration[]) => import("@atlaskit/editor-common/types").Command;
@@ -1,2 +1,3 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
1
2
  import type { FindReplacePluginState } from '../types';
2
- export declare const createCommand: <A = import("./actions").FindReplaceAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => FindReplacePluginState, createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: FindReplacePluginState | ((state: import("prosemirror-state").EditorState) => FindReplacePluginState)) => import("prosemirror-state").SafeStateField<FindReplacePluginState>;
3
+ export declare const createCommand: <A = import("./actions").FindReplaceAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: Transaction, state: import("prosemirror-state").EditorState) => Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => FindReplacePluginState, createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: FindReplacePluginState | ((state: import("prosemirror-state").EditorState) => FindReplacePluginState)) => import("prosemirror-state").SafeStateField<FindReplacePluginState>;
@@ -3,6 +3,7 @@ import { type 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
5
  import type { CardPlugin } from '@atlaskit/editor-plugin-card';
6
+ import type { ExpandPlugin } from '@atlaskit/editor-plugin-expand';
6
7
  import type { MentionsPlugin } from '@atlaskit/editor-plugin-mentions';
7
8
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
8
9
  import type { FindReplacePluginState, FindReplaceToolbarButtonActionProps } from './types';
@@ -14,7 +15,8 @@ export type FindReplacePluginDependencies = [
14
15
  OptionalPlugin<AnalyticsPlugin>,
15
16
  OptionalPlugin<PrimaryToolbarPlugin>,
16
17
  OptionalPlugin<MentionsPlugin>,
17
- OptionalPlugin<CardPlugin>
18
+ OptionalPlugin<CardPlugin>,
19
+ OptionalPlugin<ExpandPlugin>
18
20
  ];
19
21
  export type FindReplacePlugin = NextEditorPlugin<'findReplace', {
20
22
  pluginConfiguration: FindReplacePluginOptions;
@@ -9,10 +9,10 @@ export declare const findWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI
9
9
  containerElement: HTMLElement | null;
10
10
  keyword?: string | undefined;
11
11
  }) => Command;
12
- export declare const findNextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ triggerMethod, }: {
12
+ export declare const findNextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorView: EditorView) => ({ triggerMethod, }: {
13
13
  triggerMethod: TRIGGER_METHOD.KEYBOARD | TRIGGER_METHOD.BUTTON;
14
14
  }) => Command;
15
- export declare const findPrevWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ triggerMethod, }: {
15
+ export declare const findPrevWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorView: EditorView) => ({ triggerMethod, }: {
16
16
  triggerMethod: TRIGGER_METHOD.KEYBOARD | TRIGGER_METHOD.BUTTON;
17
17
  }) => Command;
18
18
  export declare const replaceWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ triggerMethod, replaceText, }: {
@@ -1,8 +1,8 @@
1
1
  import type { Decoration, EditorView } from '@atlaskit/editor-prosemirror/view';
2
2
  export declare const activate: () => import("@atlaskit/editor-common/types").Command;
3
3
  export declare const find: (editorView: EditorView, containerElement: HTMLElement | null, keyword?: string) => import("@atlaskit/editor-common/types").Command;
4
- export declare const findNext: () => import("@atlaskit/editor-common/types").Command;
5
- export declare const findPrevious: () => import("@atlaskit/editor-common/types").Command;
4
+ export declare const findNext: (editorView: EditorView) => import("@atlaskit/editor-common/types").Command;
5
+ export declare const findPrevious: (editorView: EditorView) => import("@atlaskit/editor-common/types").Command;
6
6
  export declare const replace: (replaceText: string) => import("@atlaskit/editor-common/types").Command;
7
7
  export declare const replaceAll: (replaceText: string) => import("@atlaskit/editor-common/types").Command;
8
8
  export declare const addDecorations: (decorations: Decoration[]) => import("@atlaskit/editor-common/types").Command;
@@ -1,2 +1,3 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
1
2
  import type { FindReplacePluginState } from '../types';
2
- export declare const createCommand: <A = import("./actions").FindReplaceAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => FindReplacePluginState, createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: FindReplacePluginState | ((state: import("prosemirror-state").EditorState) => FindReplacePluginState)) => import("prosemirror-state").SafeStateField<FindReplacePluginState>;
3
+ export declare const createCommand: <A = import("./actions").FindReplaceAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: Transaction, state: import("prosemirror-state").EditorState) => Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => FindReplacePluginState, createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: FindReplacePluginState | ((state: import("prosemirror-state").EditorState) => FindReplacePluginState)) => import("prosemirror-state").SafeStateField<FindReplacePluginState>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-find-replace",
3
- "version": "3.0.2",
3
+ "version": "3.1.1",
4
4
  "description": "find replace plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,6 +35,7 @@
35
35
  "@atlaskit/button": "^23.2.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^3.0.0",
37
37
  "@atlaskit/editor-plugin-card": "^7.0.0",
38
+ "@atlaskit/editor-plugin-expand": "^4.1.0",
38
39
  "@atlaskit/editor-plugin-mentions": "^5.1.0",
39
40
  "@atlaskit/editor-plugin-primary-toolbar": "^4.0.0",
40
41
  "@atlaskit/editor-prosemirror": "7.0.0",
@@ -46,8 +47,8 @@
46
47
  "@atlaskit/platform-feature-flags": "^1.1.0",
47
48
  "@atlaskit/primitives": "^14.10.0",
48
49
  "@atlaskit/textfield": "^8.0.0",
49
- "@atlaskit/theme": "^18.0.0",
50
- "@atlaskit/tmp-editor-statsig": "^9.0.0",
50
+ "@atlaskit/theme": "^19.0.0",
51
+ "@atlaskit/tmp-editor-statsig": "^9.1.0",
51
52
  "@atlaskit/tokens": "^5.4.0",
52
53
  "@atlaskit/tooltip": "^20.3.0",
53
54
  "@babel/runtime": "^7.0.0",