@atlaskit/editor-plugin-find-replace 17.0.5 → 17.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-find-replace
2
2
 
3
+ ## 17.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`817bf38f29c51`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/817bf38f29c51) -
8
+ [ux] Expand collapsed heading sections when navigating find-and-replace matches under
9
+ `platform_editor_collapsible_headings`.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 17.0.6
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 17.0.5
4
22
 
5
23
  ### Patch Changes
@@ -7,6 +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 _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
10
11
  var _actions = require("./actions");
11
12
  var _pluginFactory = require("./plugin-factory");
12
13
  var _utils = require("./utils");
@@ -92,6 +93,12 @@ var find = exports.find = function find(editorView, containerElement, keyword) {
92
93
  api === null || api === void 0 || (_api$expand = api.expand) === null || _api$expand === void 0 || _api$expand.commands.toggleExpandWithMatch(newSelection)({
93
94
  tr: tr
94
95
  });
96
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_collapsible_headings')) {
97
+ var _api$blockCollapse;
98
+ api === null || api === void 0 || (_api$blockCollapse = api.blockCollapse) === null || _api$blockCollapse === void 0 || _api$blockCollapse.commands.expandHeadingsContainingRange(newSelection.from, newSelection.to)({
99
+ tr: tr
100
+ });
101
+ }
95
102
  return tr.setSelection(newSelection);
96
103
  }
97
104
  return tr;
@@ -118,6 +125,12 @@ var findNext = exports.findNext = function findNext(editorView) {
118
125
  api === null || api === void 0 || (_api$expand2 = api.expand) === null || _api$expand2 === void 0 || _api$expand2.commands.toggleExpandWithMatch(newSelection)({
119
126
  tr: tr
120
127
  });
128
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_collapsible_headings')) {
129
+ var _api$blockCollapse2;
130
+ api === null || api === void 0 || (_api$blockCollapse2 = api.blockCollapse) === null || _api$blockCollapse2 === void 0 || _api$blockCollapse2.commands.expandHeadingsContainingRange(newSelection.from, newSelection.to)({
131
+ tr: tr
132
+ });
133
+ }
121
134
  return tr.setSelection(newSelection);
122
135
  }));
123
136
  };
@@ -137,6 +150,12 @@ var findPrevious = exports.findPrevious = function findPrevious(editorView) {
137
150
  api === null || api === void 0 || (_api$expand3 = api.expand) === null || _api$expand3 === void 0 || _api$expand3.commands.toggleExpandWithMatch(newSelection)({
138
151
  tr: tr
139
152
  });
153
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_collapsible_headings')) {
154
+ var _api$blockCollapse3;
155
+ api === null || api === void 0 || (_api$blockCollapse3 = api.blockCollapse) === null || _api$blockCollapse3 === void 0 || _api$blockCollapse3.commands.expandHeadingsContainingRange(newSelection.from, newSelection.to)({
156
+ tr: tr
157
+ });
158
+ }
140
159
  return tr.setSelection(newSelection);
141
160
  }));
142
161
  };
@@ -192,7 +211,8 @@ var replace = exports.replace = function replace(replaceText) {
192
211
  var _getPluginState6 = (0, _pluginFactory.getPluginState)(state),
193
212
  matches = _getPluginState6.matches,
194
213
  index = _getPluginState6.index,
195
- findText = _getPluginState6.findText;
214
+ findText = _getPluginState6.findText,
215
+ api = _getPluginState6.api;
196
216
  if (matches[index]) {
197
217
  if (!matches[index].canReplace) {
198
218
  return tr;
@@ -201,7 +221,15 @@ var replace = exports.replace = function replace(replaceText) {
201
221
  start = _matches$index.start,
202
222
  end = _matches$index.end;
203
223
  var newIndex = (0, _utils.nextIndex)(index, matches.length);
204
- tr.insertText(replaceText, start, end).setSelection((0, _utils.getSelectionForMatch)(tr.selection, tr.doc, newIndex, matches, newIndex === 0 ? 0 : replaceText.length - findText.length));
224
+ tr.insertText(replaceText, start, end);
225
+ var newSelection = (0, _utils.getSelectionForMatch)(tr.selection, tr.doc, newIndex, matches, newIndex === 0 ? 0 : replaceText.length - findText.length);
226
+ tr.setSelection(newSelection);
227
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_collapsible_headings')) {
228
+ var _api$blockCollapse4;
229
+ api === null || api === void 0 || (_api$blockCollapse4 = api.blockCollapse) === null || _api$blockCollapse4 === void 0 || _api$blockCollapse4.commands.expandHeadingsContainingRange(newSelection.from, newSelection.to)({
230
+ tr: tr
231
+ });
232
+ }
205
233
  }
206
234
  return tr;
207
235
  }));
@@ -1,5 +1,6 @@
1
1
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
3
4
  import { FindReplaceActionTypes } from './actions';
4
5
  import { createCommand, getPluginState } from './plugin-factory';
5
6
  import { createDecoration, findClosestMatch, findDecorationFromMatch, findMatches, findSearchIndex, getSelectedText, getSelectionForMatch, nextIndex, prevIndex, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
@@ -87,6 +88,12 @@ export const find = (editorView, containerElement, keyword) => withScrollIntoVie
87
88
  api === null || api === void 0 ? void 0 : (_api$expand = api.expand) === null || _api$expand === void 0 ? void 0 : _api$expand.commands.toggleExpandWithMatch(newSelection)({
88
89
  tr
89
90
  });
91
+ if (isExperimentEnabled('platform_editor_collapsible_headings')) {
92
+ var _api$blockCollapse;
93
+ api === null || api === void 0 ? void 0 : (_api$blockCollapse = api.blockCollapse) === null || _api$blockCollapse === void 0 ? void 0 : _api$blockCollapse.commands.expandHeadingsContainingRange(newSelection.from, newSelection.to)({
94
+ tr
95
+ });
96
+ }
90
97
  return tr.setSelection(newSelection);
91
98
  }
92
99
  return tr;
@@ -110,6 +117,12 @@ export const findNext = editorView => withScrollIntoView(createCommand(state =>
110
117
  api === null || api === void 0 ? void 0 : (_api$expand2 = api.expand) === null || _api$expand2 === void 0 ? void 0 : _api$expand2.commands.toggleExpandWithMatch(newSelection)({
111
118
  tr
112
119
  });
120
+ if (isExperimentEnabled('platform_editor_collapsible_headings')) {
121
+ var _api$blockCollapse2;
122
+ api === null || api === void 0 ? void 0 : (_api$blockCollapse2 = api.blockCollapse) === null || _api$blockCollapse2 === void 0 ? void 0 : _api$blockCollapse2.commands.expandHeadingsContainingRange(newSelection.from, newSelection.to)({
123
+ tr
124
+ });
125
+ }
113
126
  return tr.setSelection(newSelection);
114
127
  }));
115
128
  export const findPrevious = editorView => withScrollIntoView(createCommand(state => findInDirection(state, 'previous'), (tr, state) => {
@@ -126,6 +139,12 @@ export const findPrevious = editorView => withScrollIntoView(createCommand(state
126
139
  api === null || api === void 0 ? void 0 : (_api$expand3 = api.expand) === null || _api$expand3 === void 0 ? void 0 : _api$expand3.commands.toggleExpandWithMatch(newSelection)({
127
140
  tr
128
141
  });
142
+ if (isExperimentEnabled('platform_editor_collapsible_headings')) {
143
+ var _api$blockCollapse3;
144
+ api === null || api === void 0 ? void 0 : (_api$blockCollapse3 = api.blockCollapse) === null || _api$blockCollapse3 === void 0 ? void 0 : _api$blockCollapse3.commands.expandHeadingsContainingRange(newSelection.from, newSelection.to)({
145
+ tr
146
+ });
147
+ }
129
148
  return tr.setSelection(newSelection);
130
149
  }));
131
150
  const findInDirection = (state, dir) => {
@@ -187,7 +206,8 @@ export const replace = replaceText => withScrollIntoView(createCommand(state =>
187
206
  const {
188
207
  matches,
189
208
  index,
190
- findText
209
+ findText,
210
+ api
191
211
  } = getPluginState(state);
192
212
  if (matches[index]) {
193
213
  if (!matches[index].canReplace) {
@@ -198,7 +218,15 @@ export const replace = replaceText => withScrollIntoView(createCommand(state =>
198
218
  end
199
219
  } = matches[index];
200
220
  const newIndex = nextIndex(index, matches.length);
201
- tr.insertText(replaceText, start, end).setSelection(getSelectionForMatch(tr.selection, tr.doc, newIndex, matches, newIndex === 0 ? 0 : replaceText.length - findText.length));
221
+ tr.insertText(replaceText, start, end);
222
+ const newSelection = getSelectionForMatch(tr.selection, tr.doc, newIndex, matches, newIndex === 0 ? 0 : replaceText.length - findText.length);
223
+ tr.setSelection(newSelection);
224
+ if (isExperimentEnabled('platform_editor_collapsible_headings')) {
225
+ var _api$blockCollapse4;
226
+ api === null || api === void 0 ? void 0 : (_api$blockCollapse4 = api.blockCollapse) === null || _api$blockCollapse4 === void 0 ? void 0 : _api$blockCollapse4.commands.expandHeadingsContainingRange(newSelection.from, newSelection.to)({
227
+ tr
228
+ });
229
+ }
202
230
  }
203
231
  return tr;
204
232
  }));
@@ -1,5 +1,6 @@
1
1
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
3
4
  import { FindReplaceActionTypes } from './actions';
4
5
  import { createCommand, getPluginState } from './plugin-factory';
5
6
  import { createDecoration, findClosestMatch, findDecorationFromMatch, findMatches, findSearchIndex, getSelectedText, getSelectionForMatch, nextIndex, prevIndex, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
@@ -85,6 +86,12 @@ export var find = function find(editorView, containerElement, keyword) {
85
86
  api === null || api === void 0 || (_api$expand = api.expand) === null || _api$expand === void 0 || _api$expand.commands.toggleExpandWithMatch(newSelection)({
86
87
  tr: tr
87
88
  });
89
+ if (isExperimentEnabled('platform_editor_collapsible_headings')) {
90
+ var _api$blockCollapse;
91
+ api === null || api === void 0 || (_api$blockCollapse = api.blockCollapse) === null || _api$blockCollapse === void 0 || _api$blockCollapse.commands.expandHeadingsContainingRange(newSelection.from, newSelection.to)({
92
+ tr: tr
93
+ });
94
+ }
88
95
  return tr.setSelection(newSelection);
89
96
  }
90
97
  return tr;
@@ -111,6 +118,12 @@ export var findNext = function findNext(editorView) {
111
118
  api === null || api === void 0 || (_api$expand2 = api.expand) === null || _api$expand2 === void 0 || _api$expand2.commands.toggleExpandWithMatch(newSelection)({
112
119
  tr: tr
113
120
  });
121
+ if (isExperimentEnabled('platform_editor_collapsible_headings')) {
122
+ var _api$blockCollapse2;
123
+ api === null || api === void 0 || (_api$blockCollapse2 = api.blockCollapse) === null || _api$blockCollapse2 === void 0 || _api$blockCollapse2.commands.expandHeadingsContainingRange(newSelection.from, newSelection.to)({
124
+ tr: tr
125
+ });
126
+ }
114
127
  return tr.setSelection(newSelection);
115
128
  }));
116
129
  };
@@ -130,6 +143,12 @@ export var findPrevious = function findPrevious(editorView) {
130
143
  api === null || api === void 0 || (_api$expand3 = api.expand) === null || _api$expand3 === void 0 || _api$expand3.commands.toggleExpandWithMatch(newSelection)({
131
144
  tr: tr
132
145
  });
146
+ if (isExperimentEnabled('platform_editor_collapsible_headings')) {
147
+ var _api$blockCollapse3;
148
+ api === null || api === void 0 || (_api$blockCollapse3 = api.blockCollapse) === null || _api$blockCollapse3 === void 0 || _api$blockCollapse3.commands.expandHeadingsContainingRange(newSelection.from, newSelection.to)({
149
+ tr: tr
150
+ });
151
+ }
133
152
  return tr.setSelection(newSelection);
134
153
  }));
135
154
  };
@@ -185,7 +204,8 @@ export var replace = function replace(replaceText) {
185
204
  var _getPluginState6 = getPluginState(state),
186
205
  matches = _getPluginState6.matches,
187
206
  index = _getPluginState6.index,
188
- findText = _getPluginState6.findText;
207
+ findText = _getPluginState6.findText,
208
+ api = _getPluginState6.api;
189
209
  if (matches[index]) {
190
210
  if (!matches[index].canReplace) {
191
211
  return tr;
@@ -194,7 +214,15 @@ export var replace = function replace(replaceText) {
194
214
  start = _matches$index.start,
195
215
  end = _matches$index.end;
196
216
  var newIndex = nextIndex(index, matches.length);
197
- tr.insertText(replaceText, start, end).setSelection(getSelectionForMatch(tr.selection, tr.doc, newIndex, matches, newIndex === 0 ? 0 : replaceText.length - findText.length));
217
+ tr.insertText(replaceText, start, end);
218
+ var newSelection = getSelectionForMatch(tr.selection, tr.doc, newIndex, matches, newIndex === 0 ? 0 : replaceText.length - findText.length);
219
+ tr.setSelection(newSelection);
220
+ if (isExperimentEnabled('platform_editor_collapsible_headings')) {
221
+ var _api$blockCollapse4;
222
+ api === null || api === void 0 || (_api$blockCollapse4 = api.blockCollapse) === null || _api$blockCollapse4 === void 0 || _api$blockCollapse4.commands.expandHeadingsContainingRange(newSelection.from, newSelection.to)({
223
+ tr: tr
224
+ });
225
+ }
198
226
  }
199
227
  return tr;
200
228
  }));
@@ -1,6 +1,7 @@
1
1
  import type { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
+ import type { BlockCollapsePlugin } from '@atlaskit/editor-plugin-block-collapse/blockCollapsePluginType';
4
5
  import type { CardPlugin } from '@atlaskit/editor-plugin-card';
5
6
  import type { ExpandPlugin } from '@atlaskit/editor-plugin-expand';
6
7
  import type { MentionsPlugin } from '@atlaskit/editor-plugin-mentions';
@@ -17,6 +18,7 @@ export type FindReplacePluginDependencies = [
17
18
  OptionalPlugin<MentionsPlugin>,
18
19
  OptionalPlugin<CardPlugin>,
19
20
  OptionalPlugin<ExpandPlugin>,
21
+ OptionalPlugin<BlockCollapsePlugin>,
20
22
  OptionalPlugin<SyncedBlockPlugin>
21
23
  ];
22
24
  export type FindReplacePlugin = NextEditorPlugin<'findReplace', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-find-replace",
3
- "version": "17.0.5",
3
+ "version": "17.1.0",
4
4
  "description": "find replace plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -22,6 +22,7 @@
22
22
  "dependencies": {
23
23
  "@atlaskit/button": "^25.3.0",
24
24
  "@atlaskit/editor-plugin-analytics": "^17.0.0",
25
+ "@atlaskit/editor-plugin-block-collapse": "^3.1.0",
25
26
  "@atlaskit/editor-plugin-card": "^23.0.0",
26
27
  "@atlaskit/editor-plugin-expand": "^18.1.0",
27
28
  "@atlaskit/editor-plugin-mentions": "^19.1.0",
@@ -33,10 +34,11 @@
33
34
  "@atlaskit/icon": "^37.6.0",
34
35
  "@atlaskit/icon-lab": "^7.8.0",
35
36
  "@atlaskit/mention": "^28.0.0",
37
+ "@atlaskit/platform-feature-experiments": "^0.3.0",
36
38
  "@atlaskit/platform-feature-flags": "^2.2.0",
37
39
  "@atlaskit/primitives": "^22.5.0",
38
40
  "@atlaskit/textfield": "^10.2.0",
39
- "@atlaskit/tmp-editor-statsig": "^184.0.0",
41
+ "@atlaskit/tmp-editor-statsig": "^185.0.0",
40
42
  "@atlaskit/tokens": "^16.11.0",
41
43
  "@atlaskit/tooltip": "^24.3.0",
42
44
  "@babel/runtime": "^7.0.0",
@@ -55,7 +57,7 @@
55
57
  "react-intl": "^7.0.0"
56
58
  },
57
59
  "peerDependencies": {
58
- "@atlaskit/editor-common": "^121.2.0",
60
+ "@atlaskit/editor-common": "^121.4.0",
59
61
  "react": "^18.2.0 || ^19.2.0",
60
62
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
61
63
  },