@univerjs/sheets-find-replace 0.21.1 → 0.22.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/README.md CHANGED
@@ -1,39 +1,45 @@
1
1
  # @univerjs/sheets-find-replace
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@univerjs/sheets-find-replace?style=flat-square)](https://npmjs.com/package/@univerjs/sheets-find-replace)
4
+ [![license](https://img.shields.io/npm/l/@univerjs/sheets-find-replace?style=flat-square)](https://npmjs.com/package/@univerjs/sheets-find-replace)
5
+ [![downloads](https://img.shields.io/npm/dm/@univerjs/sheets-find-replace?style=flat-square)](https://npmjs.com/package/@univerjs/sheets-find-replace)
6
+
7
+ `@univerjs/sheets-find-replace` extends shared find and replace capabilities to worksheets in Univer Sheets.
8
+
3
9
  ## Package Overview
4
10
 
5
- | Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
6
- | --- | --- | --- | --- | --- | :---: | :---: |
7
- | `@univerjs/sheets-find-replace` | `UniverSheetsFindReplace` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ❌ | ⭕️ |
11
+ | Package | UMD global | CSS | Locales | Facade entry |
12
+ | --- | --- | :---: | :---: | :---: |
13
+ | `@univerjs/sheets-find-replace` | `UniverSheetsFindReplace` | No | Yes | Yes |
8
14
 
9
- ## Introduction
15
+ ## Installation
10
16
 
11
- This package provides the feature to find and replace text in spreadsheets.
17
+ ```sh
18
+ pnpm add @univerjs/sheets-find-replace
19
+ # or
20
+ npm install @univerjs/sheets-find-replace
21
+ ```
12
22
 
13
- ## Usage
23
+ Keep all `@univerjs/*` packages on the same version.
14
24
 
15
- You should use this plugin with the `@univerjs/find-replace` package.
25
+ ## Usage
16
26
 
17
- ```typescript
18
- import { UniverFindReplacePlugin } from '@univerjs/find-replace';
27
+ ```ts
28
+ import EnUS from '@univerjs/sheets-find-replace/locale/en-US';
19
29
  import { UniverSheetsFindReplacePlugin } from '@univerjs/sheets-find-replace';
20
30
 
21
- univer.registerPlugin(UniverFindReplacePlugin);
22
31
  univer.registerPlugin(UniverSheetsFindReplacePlugin);
32
+
33
+ // Merge EnUS into your Univer locale map when this package contributes UI text.
23
34
  ```
24
35
 
25
- ### Installation
36
+ ## Integration Notes
26
37
 
27
- ```shell
28
- # Using npm
29
- npm install @univerjs/sheets-find-replace
38
+ Use this package with `@univerjs/find-replace` to share find and replace infrastructure across Univer surfaces.
30
39
 
31
- # Using pnpm
32
- pnpm add @univerjs/sheets-find-replace
33
- ```
40
+ ## Resources
41
+
42
+ - [Documentation](https://docs.univer.ai)
43
+ - [NPM package](https://npmjs.com/package/@univerjs/sheets-find-replace)
44
+ - [GitHub repository](https://github.com/dream-num/univer)
34
45
 
35
- <!-- Links -->
36
- [npm-version-shield]: https://img.shields.io/npm/v/@univerjs/sheets-find-replace?style=flat-square
37
- [npm-version-link]: https://npmjs.com/package/@univerjs/sheets-find-replace
38
- [npm-license-shield]: https://img.shields.io/npm/l/@univerjs/sheets-find-replace?style=flat-square
39
- [npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/sheets-find-replace?style=flat-square
package/lib/cjs/facade.js CHANGED
@@ -3,7 +3,7 @@ let _univerjs_find_replace = require("@univerjs/find-replace");
3
3
  let _univerjs_sheets_facade = require("@univerjs/sheets/facade");
4
4
  let _univerjs_core_facade = require("@univerjs/core/facade");
5
5
 
6
- //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
6
+ //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
7
7
  function _typeof(o) {
8
8
  "@babel/helpers - typeof";
9
9
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -14,7 +14,7 @@ function _typeof(o) {
14
14
  }
15
15
 
16
16
  //#endregion
17
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
17
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
18
18
  function toPrimitive(t, r) {
19
19
  if ("object" != _typeof(t) || !t) return t;
20
20
  var e = t[Symbol.toPrimitive];
@@ -27,14 +27,14 @@ function toPrimitive(t, r) {
27
27
  }
28
28
 
29
29
  //#endregion
30
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
30
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
31
31
  function toPropertyKey(t) {
32
32
  var i = toPrimitive(t, "string");
33
33
  return "symbol" == _typeof(i) ? i : i + "";
34
34
  }
35
35
 
36
36
  //#endregion
37
- //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
37
+ //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
38
38
  function _defineProperty(e, r, t) {
39
39
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
40
40
  value: t,
@@ -45,7 +45,7 @@ function _defineProperty(e, r, t) {
45
45
  }
46
46
 
47
47
  //#endregion
48
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
48
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
49
49
  function __decorateParam(paramIndex, decorator) {
50
50
  return function(target, key) {
51
51
  decorator(target, key, paramIndex);
@@ -53,7 +53,7 @@ function __decorateParam(paramIndex, decorator) {
53
53
  }
54
54
 
55
55
  //#endregion
56
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
56
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
57
57
  function __decorate(decorators, target, key, desc) {
58
58
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
59
59
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
package/lib/cjs/index.js CHANGED
@@ -43,7 +43,7 @@ function getReplaceAllResult(results, replacements) {
43
43
  }
44
44
 
45
45
  //#endregion
46
- //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
46
+ //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
47
47
  function _typeof(o) {
48
48
  "@babel/helpers - typeof";
49
49
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -54,7 +54,7 @@ function _typeof(o) {
54
54
  }
55
55
 
56
56
  //#endregion
57
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
57
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
58
58
  function toPrimitive(t, r) {
59
59
  if ("object" != _typeof(t) || !t) return t;
60
60
  var e = t[Symbol.toPrimitive];
@@ -67,14 +67,14 @@ function toPrimitive(t, r) {
67
67
  }
68
68
 
69
69
  //#endregion
70
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
70
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
71
71
  function toPropertyKey(t) {
72
72
  var i = toPrimitive(t, "string");
73
73
  return "symbol" == _typeof(i) ? i : i + "";
74
74
  }
75
75
 
76
76
  //#endregion
77
- //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
77
+ //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
78
78
  function _defineProperty(e, r, t) {
79
79
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
80
80
  value: t,
@@ -162,7 +162,7 @@ function isSelectionSingleCell(selection, worksheet) {
162
162
  }
163
163
 
164
164
  //#endregion
165
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
165
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
166
166
  function __decorateParam(paramIndex, decorator) {
167
167
  return function(target, key) {
168
168
  decorator(target, key, paramIndex);
@@ -170,7 +170,7 @@ function __decorateParam(paramIndex, decorator) {
170
170
  }
171
171
 
172
172
  //#endregion
173
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
173
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
174
174
  function __decorate(decorators, target, key, desc) {
175
175
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
176
176
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -299,14 +299,15 @@ let SheetFindModel = class SheetFindModel extends _univerjs_find_replace.FindMod
299
299
  let complete;
300
300
  let firstSearch = true;
301
301
  const findInWorkbook = () => {
302
- this._matches = this._workbook.getSheets().filter((worksheet) => !worksheet.isSheetHidden()).map((worksheet) => {
302
+ const allCompletes = this._workbook.getSheets().filter((worksheet) => !worksheet.isSheetHidden()).map((worksheet) => {
303
303
  const complete = this._findInWorksheet(worksheet, query, unitId);
304
304
  const sheetId = worksheet.getSheetId();
305
305
  const { results } = complete;
306
306
  if (results.length) this._matchesByWorksheet.set(sheetId, complete.results);
307
307
  else this._matchesByWorksheet.delete(sheetId);
308
308
  return complete;
309
- }).map((c) => c.results).flat();
309
+ });
310
+ this._matches = allCompletes.map((c) => c.results).flat();
310
311
  this._updateFindHighlight();
311
312
  if (firstSearch) {
312
313
  complete = { results: this._matches };
@@ -869,7 +870,7 @@ function trimLeadingTrailingWhitespace(value) {
869
870
  //#endregion
870
871
  //#region package.json
871
872
  var name = "@univerjs/sheets-find-replace";
872
- var version = "0.21.1";
873
+ var version = "0.22.0";
873
874
 
874
875
  //#endregion
875
876
  //#region src/config/config.ts
package/lib/es/facade.js CHANGED
@@ -3,7 +3,7 @@ import { FindBy, FindReplaceModel, FindReplaceState, IFindReplaceService, create
3
3
  import { FRange } from "@univerjs/sheets/facade";
4
4
  import { FUniver } from "@univerjs/core/facade";
5
5
 
6
- //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
6
+ //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
7
7
  function _typeof(o) {
8
8
  "@babel/helpers - typeof";
9
9
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -14,7 +14,7 @@ function _typeof(o) {
14
14
  }
15
15
 
16
16
  //#endregion
17
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
17
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
18
18
  function toPrimitive(t, r) {
19
19
  if ("object" != _typeof(t) || !t) return t;
20
20
  var e = t[Symbol.toPrimitive];
@@ -27,14 +27,14 @@ function toPrimitive(t, r) {
27
27
  }
28
28
 
29
29
  //#endregion
30
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
30
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
31
31
  function toPropertyKey(t) {
32
32
  var i = toPrimitive(t, "string");
33
33
  return "symbol" == _typeof(i) ? i : i + "";
34
34
  }
35
35
 
36
36
  //#endregion
37
- //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
37
+ //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
38
38
  function _defineProperty(e, r, t) {
39
39
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
40
40
  value: t,
@@ -45,7 +45,7 @@ function _defineProperty(e, r, t) {
45
45
  }
46
46
 
47
47
  //#endregion
48
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
48
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
49
49
  function __decorateParam(paramIndex, decorator) {
50
50
  return function(target, key) {
51
51
  decorator(target, key, paramIndex);
@@ -53,7 +53,7 @@ function __decorateParam(paramIndex, decorator) {
53
53
  }
54
54
 
55
55
  //#endregion
56
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
56
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
57
57
  function __decorate(decorators, target, key, desc) {
58
58
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
59
59
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
package/lib/es/index.js CHANGED
@@ -42,7 +42,7 @@ function getReplaceAllResult(results, replacements) {
42
42
  }
43
43
 
44
44
  //#endregion
45
- //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
45
+ //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
46
46
  function _typeof(o) {
47
47
  "@babel/helpers - typeof";
48
48
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -53,7 +53,7 @@ function _typeof(o) {
53
53
  }
54
54
 
55
55
  //#endregion
56
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
56
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
57
57
  function toPrimitive(t, r) {
58
58
  if ("object" != _typeof(t) || !t) return t;
59
59
  var e = t[Symbol.toPrimitive];
@@ -66,14 +66,14 @@ function toPrimitive(t, r) {
66
66
  }
67
67
 
68
68
  //#endregion
69
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
69
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
70
70
  function toPropertyKey(t) {
71
71
  var i = toPrimitive(t, "string");
72
72
  return "symbol" == _typeof(i) ? i : i + "";
73
73
  }
74
74
 
75
75
  //#endregion
76
- //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
76
+ //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
77
77
  function _defineProperty(e, r, t) {
78
78
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
79
79
  value: t,
@@ -161,7 +161,7 @@ function isSelectionSingleCell(selection, worksheet) {
161
161
  }
162
162
 
163
163
  //#endregion
164
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
164
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
165
165
  function __decorateParam(paramIndex, decorator) {
166
166
  return function(target, key) {
167
167
  decorator(target, key, paramIndex);
@@ -169,7 +169,7 @@ function __decorateParam(paramIndex, decorator) {
169
169
  }
170
170
 
171
171
  //#endregion
172
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
172
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
173
173
  function __decorate(decorators, target, key, desc) {
174
174
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
175
175
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -298,14 +298,15 @@ let SheetFindModel = class SheetFindModel extends FindModel {
298
298
  let complete;
299
299
  let firstSearch = true;
300
300
  const findInWorkbook = () => {
301
- this._matches = this._workbook.getSheets().filter((worksheet) => !worksheet.isSheetHidden()).map((worksheet) => {
301
+ const allCompletes = this._workbook.getSheets().filter((worksheet) => !worksheet.isSheetHidden()).map((worksheet) => {
302
302
  const complete = this._findInWorksheet(worksheet, query, unitId);
303
303
  const sheetId = worksheet.getSheetId();
304
304
  const { results } = complete;
305
305
  if (results.length) this._matchesByWorksheet.set(sheetId, complete.results);
306
306
  else this._matchesByWorksheet.delete(sheetId);
307
307
  return complete;
308
- }).map((c) => c.results).flat();
308
+ });
309
+ this._matches = allCompletes.map((c) => c.results).flat();
309
310
  this._updateFindHighlight();
310
311
  if (firstSearch) {
311
312
  complete = { results: this._matches };
@@ -868,7 +869,7 @@ function trimLeadingTrailingWhitespace(value) {
868
869
  //#endregion
869
870
  //#region package.json
870
871
  var name = "@univerjs/sheets-find-replace";
871
- var version = "0.21.1";
872
+ var version = "0.22.0";
872
873
 
873
874
  //#endregion
874
875
  //#region src/config/config.ts
package/lib/facade.js CHANGED
@@ -3,7 +3,7 @@ import { FindBy, FindReplaceModel, FindReplaceState, IFindReplaceService, create
3
3
  import { FRange } from "@univerjs/sheets/facade";
4
4
  import { FUniver } from "@univerjs/core/facade";
5
5
 
6
- //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
6
+ //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
7
7
  function _typeof(o) {
8
8
  "@babel/helpers - typeof";
9
9
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -14,7 +14,7 @@ function _typeof(o) {
14
14
  }
15
15
 
16
16
  //#endregion
17
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
17
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
18
18
  function toPrimitive(t, r) {
19
19
  if ("object" != _typeof(t) || !t) return t;
20
20
  var e = t[Symbol.toPrimitive];
@@ -27,14 +27,14 @@ function toPrimitive(t, r) {
27
27
  }
28
28
 
29
29
  //#endregion
30
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
30
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
31
31
  function toPropertyKey(t) {
32
32
  var i = toPrimitive(t, "string");
33
33
  return "symbol" == _typeof(i) ? i : i + "";
34
34
  }
35
35
 
36
36
  //#endregion
37
- //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
37
+ //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
38
38
  function _defineProperty(e, r, t) {
39
39
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
40
40
  value: t,
@@ -45,7 +45,7 @@ function _defineProperty(e, r, t) {
45
45
  }
46
46
 
47
47
  //#endregion
48
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
48
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
49
49
  function __decorateParam(paramIndex, decorator) {
50
50
  return function(target, key) {
51
51
  decorator(target, key, paramIndex);
@@ -53,7 +53,7 @@ function __decorateParam(paramIndex, decorator) {
53
53
  }
54
54
 
55
55
  //#endregion
56
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
56
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
57
57
  function __decorate(decorators, target, key, desc) {
58
58
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
59
59
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
package/lib/index.js CHANGED
@@ -42,7 +42,7 @@ function getReplaceAllResult(results, replacements) {
42
42
  }
43
43
 
44
44
  //#endregion
45
- //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
45
+ //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
46
46
  function _typeof(o) {
47
47
  "@babel/helpers - typeof";
48
48
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -53,7 +53,7 @@ function _typeof(o) {
53
53
  }
54
54
 
55
55
  //#endregion
56
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
56
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
57
57
  function toPrimitive(t, r) {
58
58
  if ("object" != _typeof(t) || !t) return t;
59
59
  var e = t[Symbol.toPrimitive];
@@ -66,14 +66,14 @@ function toPrimitive(t, r) {
66
66
  }
67
67
 
68
68
  //#endregion
69
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
69
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
70
70
  function toPropertyKey(t) {
71
71
  var i = toPrimitive(t, "string");
72
72
  return "symbol" == _typeof(i) ? i : i + "";
73
73
  }
74
74
 
75
75
  //#endregion
76
- //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
76
+ //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
77
77
  function _defineProperty(e, r, t) {
78
78
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
79
79
  value: t,
@@ -161,7 +161,7 @@ function isSelectionSingleCell(selection, worksheet) {
161
161
  }
162
162
 
163
163
  //#endregion
164
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
164
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
165
165
  function __decorateParam(paramIndex, decorator) {
166
166
  return function(target, key) {
167
167
  decorator(target, key, paramIndex);
@@ -169,7 +169,7 @@ function __decorateParam(paramIndex, decorator) {
169
169
  }
170
170
 
171
171
  //#endregion
172
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
172
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
173
173
  function __decorate(decorators, target, key, desc) {
174
174
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
175
175
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -298,14 +298,15 @@ let SheetFindModel = class SheetFindModel extends FindModel {
298
298
  let complete;
299
299
  let firstSearch = true;
300
300
  const findInWorkbook = () => {
301
- this._matches = this._workbook.getSheets().filter((worksheet) => !worksheet.isSheetHidden()).map((worksheet) => {
301
+ const allCompletes = this._workbook.getSheets().filter((worksheet) => !worksheet.isSheetHidden()).map((worksheet) => {
302
302
  const complete = this._findInWorksheet(worksheet, query, unitId);
303
303
  const sheetId = worksheet.getSheetId();
304
304
  const { results } = complete;
305
305
  if (results.length) this._matchesByWorksheet.set(sheetId, complete.results);
306
306
  else this._matchesByWorksheet.delete(sheetId);
307
307
  return complete;
308
- }).map((c) => c.results).flat();
308
+ });
309
+ this._matches = allCompletes.map((c) => c.results).flat();
309
310
  this._updateFindHighlight();
310
311
  if (firstSearch) {
311
312
  complete = { results: this._matches };
@@ -868,7 +869,7 @@ function trimLeadingTrailingWhitespace(value) {
868
869
  //#endregion
869
870
  //#region package.json
870
871
  var name = "@univerjs/sheets-find-replace";
871
- var version = "0.21.1";
872
+ var version = "0.22.0";
872
873
 
873
874
  //#endregion
874
875
  //#region src/config/config.ts
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/sheets`),require(`@univerjs/engine-render`),require(`@univerjs/find-replace`),require(`@univerjs/sheets-ui`),require(`rxjs`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/engine-render`,`@univerjs/find-replace`,`@univerjs/sheets-ui`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsFindReplace={},e.UniverCore,e.UniverSheets,e.UniverEngineRender,e.UniverFindReplace,e.UniverSheetsUi,e.rxjs))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let s={id:`sheet.command.replace`,type:t.CommandType.COMMAND,handler:async(e,r)=>{let i=e.get(t.IUndoRedoService),a=e.get(t.ICommandService),{unitId:o,replacements:s}=r,l=i.__tempBatchingUndoRedo(o),u=await Promise.all(s.map(e=>a.executeCommand(n.SetRangeValuesCommand.id,{unitId:o,subUnitId:e.subUnitId,value:e.value})));return l.dispose(),c(u,s)}};function c(e,t){let n=0,r=0;return e.forEach((e,i)=>{let a=t[i].count;e?n+=a:r+=a}),{success:n,failure:r}}function l(e){"@babel/helpers - typeof";return l=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},l(e)}function u(e,t){if(l(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(l(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function d(e){var t=u(e,`string`);return l(t)==`symbol`?t:t+``}function f(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var p=class extends r.Shape{constructor(e,t){super(e,t),f(this,`_activated`,!1),f(this,`_inHiddenRange`,!1),f(this,`_color`,void 0),t&&this.setShapeProps(t)}setShapeProps(e){this._activated=!!e.activated,e.inHiddenRange!==void 0&&(this._inHiddenRange=e.inHiddenRange),e.color!==void 0&&(this._color=e.color),this.transformByState({width:e.width,height:e.height})}_draw(e){let t=this._activated,n=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, 0.35)`,i=`rgb(${this._color.r}, ${this._color.g}, ${this._color.b})`;r.Rect.drawWith(e,{width:this.width,height:this.height,fill:n,stroke:t?i:void 0,strokeWidth:t?2:0,evented:!1})}};function m(e,t){return e.startRow===t.startRow&&e.startColumn===t.startColumn}function h(e,t){return e.startRow<t.startRow||e.startRow===t.startRow&&e.startColumn<=t.startColumn}function g(e,t){return e.startColumn<t.startColumn||e.startColumn===t.startColumn&&e.startRow<=t.startRow}function _(e,t){return e.startRow>t.startRow||e.startRow===t.startRow&&e.startColumn>=t.startColumn}function v(e,t){return e.startColumn>t.startColumn||e.startColumn===t.startColumn&&e.startRow>=t.startRow}function y(e,n){let{range:r}=e,{startRow:i,startColumn:a}=r,o=n.getMergedCell(i,a);return o?t.Rectangle.equals(r,o):r.endRow===r.startRow&&r.endColumn===r.startColumn}function b(e,t){return function(n,r){t(n,r,e)}}function x(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let S=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._findReplaceController=t,this._contextService=n,this._findReplaceService=r,this._commandService=i,f(this,`_provider`,void 0),this._init(),this._initCommands()}dispose(){super.dispose(),this._findReplaceController.closePanel(),this._provider.dispose()}_init(){let e=this._injector.createInstance(T);this._provider=e,this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(e)),this.disposeWithMe(this._contextService.subscribeContextValue$(t.EDITOR_ACTIVATED).pipe((0,o.filter)(e=>!!e)).subscribe(()=>this._findReplaceController.closePanel()))}_initCommands(){[s].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};S=x([b(0,(0,t.Inject)(t.Injector)),b(1,(0,t.Inject)(i.FindReplaceController)),b(2,t.IContextService),b(3,i.IFindReplaceService),b(4,t.ICommandService)],S);let C=class extends i.FindModel{get _matchesCount(){return this._matches.length}get unitId(){return this._workbook.getUnitId()}get matchesCount(){return this._matchesCount}get matchesPosition(){return this._matchesPosition}get currentMatch(){return this._matchesPosition>0?this._matches[this._matchesPosition-1]:null}constructor(e,t,n,r,i,a,s,c){super(),this._workbook=e,this._sheetSkeletonManagerService=t,this._univerInstanceService=n,this._renderManagerService=r,this._commandService=i,this._contextService=a,this._themeService=s,f(this,`_matchesUpdate$`,new o.Subject),f(this,`matchesUpdate$`,this._matchesUpdate$.asObservable()),f(this,`_activelyChangingMatch$`,new o.Subject),f(this,`activelyChangingMatch$`,this._activelyChangingMatch$.asObservable()),f(this,`_matchesByWorksheet`,new Map),f(this,`_matches`,[]),f(this,`_matchesPosition`,0),f(this,`_activeHighlightIndex`,-1),f(this,`_highlightShapes`,[]),f(this,`_currentHighlightShape`,null),f(this,`_query`,null),f(this,`_workbookSelections`,void 0),this._workbookSelections=c.getWorkbookSelections(this.unitId)}dispose(){super.dispose(),this._disposeHighlights(),this._toggleDisplayRawFormula(!1)}getMatches(){return this._matches}start(e){switch(this._query=e,e.findBy===i.FindBy.FORMULA?this._toggleDisplayRawFormula(!0):this._toggleDisplayRawFormula(!1),e.findScope){case i.FindScope.UNIT:this.findInWorkbook(e);break;case i.FindScope.SUBUNIT:default:this.findInActiveWorksheet(e);break}}focusSelection(){let e=this.currentMatch;e&&this._commandService.executeCommand(n.SelectRangeCommand.id,{unitId:e.unitId,subUnit:e.range.subUnitId,range:e.range.range})}_toggleDisplayRawFormula(e){this._contextService.setContextValue(r.RENDER_RAW_FORMULA_KEY,e)}findInWorkbook(e){let r=this._workbook.getUnitId(),i,a=!0,s=()=>{this._matches=this._workbook.getSheets().filter(e=>!e.isSheetHidden()).map(t=>{let n=this._findInWorksheet(t,e,r),i=t.getSheetId(),{results:a}=n;return a.length?this._matchesByWorksheet.set(i,n.results):this._matchesByWorksheet.delete(i),n}).map(e=>e.results).flat(),this._updateFindHighlight(),a?(i={results:this._matches},a=!1):this._matchesUpdate$.next(this._matches)};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._updateFindHighlight(),this._updateCurrentHighlightShape(this._activeHighlightIndex)})),this.disposeWithMe((0,t.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0,o.filter)(([e,t])=>e.id===n.SetWorksheetActiveOperation.id&&!(t!=null&&t.fromFindReplace))).subscribe(()=>{let e=this._workbook.getActiveSheet();if(!e)return;let t=e.getSheetId();this._matchesByWorksheet.has(t)&&this._findNextMatchOnActiveSheetChange(e)})),this.disposeWithMe((0,t.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0,o.filter)(([e])=>e.type===t.CommandType.MUTATION&&e.params.unitId===this._workbook.getUnitId()),(0,o.throttleTime)(600,void 0,{leading:!1,trailing:!0})).subscribe(()=>s())),s(),i}_findNextMatchOnActiveSheetChange(e){let t,n,r=0,i=this._matchesByWorksheet.get(e.getSheetId()),a=this._workbookSelections.getCurrentSelections();a!=null&&a.length?([t,r]=this._findNextMatchByRange(i,a[0].range),n=i.findIndex(e=>e===t)):(t=i[0],n=0,r=this._matches.findIndex(e=>e===t)),this._matchesPosition=r+1,this._activelyChangingMatch$.next(t),this._activeHighlightIndex=n,this._updateFindHighlight(),this._updateCurrentHighlightShape(n)}findInActiveWorksheet(e){let r=this._workbook.getUnitId(),i=()=>{var e;let t=this._workbook.getActiveSheet();if(!t)return!1;let n=this._workbookSelections.getCurrentSelections();return(e=n==null?void 0:n.some(e=>!y(e,t)))==null?!1:e},a,s=!0,c=!1,l=()=>{let t=this._workbook.getActiveSheet();if(!t)return{results:[]};let n=this.currentMatch;c=i();let o=this._workbookSelections.getCurrentSelections(),l=c?this._findInSelections(t,o,e,r):this._findInWorksheet(t,e,r);return this._matches=l.results,this._matchesPosition=this._tryRestoreLastMatchesPosition(n,this._matches),s?(a=l,s=!1):this._matchesUpdate$.next(this._matches),this._updateFindHighlight(),l};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>this._updateFindHighlight())),this.disposeWithMe((0,o.merge)((0,t.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0,o.filter)(([e])=>{if(e.type===t.CommandType.MUTATION&&e.params.unitId===this._workbook.getUnitId())return!0;if(e.id===n.SetSelectionsOperation.id&&e.params.unitId===r){let e=i();return e===!1&&c===!1?!1:(c=e,!0)}return!1})),this._workbook.activeSheet$.pipe((0,o.skip)(1))).pipe((0,o.debounceTime)(200)).subscribe(()=>l())),l(),a}_findInRange(e,t,n,r,a){let o=[],s=e.getSheetId(),c=(t.findDirection===i.FindDirection.COLUMN?e.iterateByColumn:e.iterateByRow).bind(e)(n);for(let n of c){let{row:i,col:c,colSpan:l,rowSpan:u,value:d}=n;if(a!=null&&a(i,c)||!d||e.getRowFiltered(i))continue;let{hit:f,replaceable:p,isFormula:m}=D(e,i,c,t,d);if(f){let e={provider:`sheets-find-replace-provider`,unitId:r,replaceable:p,isFormula:m,range:{subUnitId:s,range:{startRow:i,startColumn:c,endColumn:c+(l==null?1:l)-1,endRow:i+(u==null?1:u)-1}}};o.push(e)}}return{results:o}}_findInSelections(e,t,n,r){let{findDirection:a}=n,o=a===i.FindDirection.ROW?h:g,s=new Set;return{results:t.map(t=>this._findInRange(e,n,t.range,r,(e,t)=>{let n=`${e}-${t}`;return s.has(n)?!0:(s.add(n),!1)}).results).flat().sort((e,t)=>o(e.range.range,t.range.range)?-1:1)}}_findInWorksheet(e,t,n){let r=e.getRowCount(),i=e.getColumnCount(),a={startRow:0,startColumn:0,endRow:r-1,endColumn:i-1};return this._findInRange(e,t,a,n)}_disposeHighlights(){var e;this._highlightShapes.forEach(e=>{var t;(t=e.getScene())==null||t.makeDirty(),e.dispose()}),this._highlightShapes=[],(e=this._currentHighlightShape)==null||e.dispose(),this._currentHighlightShape=null}_updateFindHighlight(){this._disposeHighlights();let e=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!e)return;let n=this._workbook.getUnitId(),r=this._renderManagerService.getRenderById(n);if(r==null)return;let{scene:i}=r,o=this._matches,s=new t.ColorKit(this._themeService.getColorFromTheme(`yellow.400`)).toRgb(),c=this._workbook.getActiveSheet();if(!c)return;let l=c.getSheetId(),u=o.filter(e=>e.range.subUnitId===l).map((t,n)=>{let{startColumn:r,startRow:o,endColumn:l,endRow:u}=t.range.range,d=(0,a.getCoordByCell)(o,r,i,e),f=(0,a.getCoordByCell)(u,l,i,e),{startX:m,startY:h}=d,{endX:g,endY:_}=f,v=!0;for(let e=o;e<=u;e++)if(c.getRowRawVisible(e)){v=!1;break}let y=!0;for(let e=r;e<=l;e++)if(c.getColVisible(e)){y=!1;break}let b=v||y,x={left:m,top:h,color:s,width:y?2:g-m,height:v?2:_-h,evented:!1,inHiddenRange:b,zIndex:1e4};return new p(`find-highlight-${n}`,x)});i.addObjects(u),this._highlightShapes=u,i.makeDirty()}_updateCurrentHighlightShape(e){var t;if((t=this._currentHighlightShape)==null||t.setShapeProps({activated:!1}),this._currentHighlightShape=null,e!==void 0){let t=this._highlightShapes[e];if(!t)return;this._currentHighlightShape=t,t.setShapeProps({activated:!0})}}_getSheetObject(){return(0,a.getSheetObject)(this._univerInstanceService,this._renderManagerService)}_focusMatch(e){var t;let r=e.range.subUnitId;r!==((t=this._workbook.getActiveSheet())==null?void 0:t.getSheetId())&&this._commandService.executeCommand(n.SetWorksheetActivateCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:r},{fromFindReplace:!0}),this._commandService.executeCommand(a.ScrollToCellCommand.id,{range:e.range.range},{fromFindReplace:!0})}_tryRestoreLastMatchesPosition(e,t){if(!e)return 0;let{subUnitId:n}=e.range,{startColumn:r,startRow:i}=e.range.range,a=t.findIndex(e=>{if(n!==e.range.subUnitId)return!1;let{startColumn:t,startRow:a}=e.range.range;return t===r&&a===i});return a>-1?a+1:0}moveToNextMatch(e){var t,n,r,a;if(!this._matches.length)return null;let o=(t=e==null?void 0:e.loop)==null?!1:t,s=(n=e==null?void 0:e.stayIfOnMatch)==null?!1:n,c=(r=e==null?void 0:e.noFocus)==null?!1:r,l=(a=e==null?void 0:e.ignoreSelection)==null?!1:a,u=this._findNextMatch(o,s,l);if(u){var d;let[e,t]=u;return this._matchesPosition=t+1,this._query.findScope===i.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(e.range.subUnitId).findIndex(t=>t===e):this._activeHighlightIndex=t,c||this._focusMatch(e),((d=this._workbook.getActiveSheet())==null?void 0:d.getSheetId())===e.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),e}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}moveToPreviousMatch(e){var t,n,r,a;if(!this._matches.length)return null;let o=(t=e==null?void 0:e.loop)==null?!1:t,s=(n=e==null?void 0:e.stayIfOnMatch)==null?!1:n,c=(r=e==null?void 0:e.noFocus)==null?!1:r,l=(a=e==null?void 0:e.ignoreSelection)==null?!1:a,u=this._findPreviousMatch(o,s,l);if(u){var d;let[e,t]=u;return this._matchesPosition=t+1,this._query.findScope===i.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(e.range.subUnitId).findIndex(t=>t===e):this._activeHighlightIndex=t,c||this._focusMatch(e),((d=this._workbook.getActiveSheet())==null?void 0:d.getSheetId())===e.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),e}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}_findPreviousMatch(e=!1,t=!1,n=!1){var r;if(this.currentMatch){let n=this._matches.findIndex(e=>e===this.currentMatch);if(t)return[this.currentMatch,n];let r=n-1;if(!e&&r<0)return null;let i=this._matches.length,a=(r+i)%i;return[this._matches[a],a]}let a=this._workbookSelections.getCurrentLastSelection();if(n||!a){let e=this._matches.length-1;return[this._matches[e],e]}if(this._query.findScope!==i.FindScope.UNIT)return this._findPreviousMatchByRange(this._matches,a.range);let o=(r=this._workbook.getActiveSheet())==null?void 0:r.getSheetId();if(!o)return null;let s=this._findPreviousWorksheetThatHasAMatch(o,e);return s?this._findPreviousMatchByRange(this._matchesByWorksheet.get(s),a.range):null}_findNextMatch(e=!1,t=!1,n=!1){var r;if(this.currentMatch){let n=this._matches.findIndex(e=>e===this.currentMatch);if(t)return[this.currentMatch,n];let r=n+1,i=this._matches.length;if(!e&&r>=i)return null;let a=r%i;return[this._matches[a],a]}let a=this._workbookSelections.getCurrentLastSelection();if(n||!a)return[this._matches[0],0];if(this._query.findScope!==i.FindScope.UNIT)return this._findNextMatchByRange(this._matches,a.range,t);let o=(r=this._workbook.getActiveSheet())==null?void 0:r.getSheetId();if(!o)return null;let s=this._findNextWorksheetThatHasAMatch(o,e);return s?this._findNextMatchByRange(this._matchesByWorksheet.get(s),a.range):null}_findPreviousWorksheetThatHasAMatch(e,n=!1){let r=this._workbook.getSheetOrders(),i=r.findIndex(t=>t===e),a=(n?(0,t.rotate)(r,i+1):r.slice(0,i+1)).findLast(e=>this._matchesByWorksheet.has(e));return a==null?null:a}_findNextWorksheetThatHasAMatch(e,n=!1){let r=this._workbook.getSheetOrders(),i=r.findIndex(t=>t===e),a=(n?(0,t.rotate)(r,i):r.slice(i)).find(e=>this._matchesByWorksheet.has(e));return a==null?null:a}_findNextMatchByRange(e,t,n=!1){let r=this._query.findDirection===i.FindDirection.ROW,a=e.findIndex(e=>{let i=e.range.range;if(!(r?h(t,i):g(t,i)))return!1;let a=m(t,i);return n?a:!a});a===-1&&(a=e.length-1);let o=e[a];return[o,this._matches.findIndex(e=>e===o)]}_findPreviousMatchByRange(e,t,n=!1){let r=this._query.findDirection===i.FindDirection.ROW,a=this._matches.findLastIndex(e=>{let i=e.range.range;if(!(r?_(t,i):v(t,i)))return!1;let a=m(t,i);return n?a:!a});a===-1&&(a=0);let o=e[a];return[o,this._matches.findIndex(e=>e===o)]}async replace(e){if(this._matchesCount===0||!this.currentMatch||!this._query||!this.currentMatch.replaceable)return!1;let t=this.currentMatch.range,r=this._workbook.getSheetBySheetId(this.currentMatch.range.subUnitId),a=this._getReplacedCellData(this.currentMatch,r,this._query.findBy===i.FindBy.FORMULA,this._query.findString,e,this._query.caseSensitive?`g`:`ig`),o={unitId:this.currentMatch.unitId,subUnitId:t.subUnitId,value:{[t.range.startRow]:{[t.range.startColumn]:a}}};return this._commandService.executeCommand(n.SetRangeValuesCommand.id,o)}async replaceAll(e){if(this._matchesCount===0||!this._query)return{success:0,failure:0};let n=this._workbook.getUnitId(),{findString:r,caseSensitive:a,findBy:o}=this._query,c=o===i.FindBy.FORMULA,l=a?`g`:`ig`,u=[];return(0,t.groupBy)(this._matches.filter(e=>e.replaceable),e=>e.range.subUnitId).forEach((n,i)=>{let a=new t.ObjectMatrix,o=this._workbook.getSheetBySheetId(i);n.forEach(t=>{let{startColumn:n,startRow:i}=t.range.range,s=this._getReplacedCellData(t,o,c,r,e,l);s&&a.setValue(i,n,s)}),u.push({count:n.length,subUnitId:i,value:a.getMatrix()})}),u?this._commandService.executeCommand(s.id,{unitId:n,replacements:u}):{success:0,failure:0}}_getReplacedCellData(e,n,r,i,a,o){var s;let{startRow:c,startColumn:l}=e.range.range,u=n.getCellRaw(c,l);if(e.isFormula)return r?{f:u.f.replace(new RegExp(w(i),o),a),v:null}:null;if((s=u.p)!=null&&s.body){let e=t.Tools.deepClone(u.p);return(0,t.replaceInDocumentBody)(e.body,i,a,this._query.caseSensitive),{p:e}}return{v:u.v.toString().replace(new RegExp(w(i),o),a)}}};C=x([b(2,t.IUniverInstanceService),b(3,r.IRenderManagerService),b(4,t.ICommandService),b(5,t.IContextService),b(6,(0,t.Inject)(t.ThemeService)),b(7,(0,t.Inject)(n.SheetsSelectionsService))],C);function w(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`)}let T=class extends t.Disposable{constructor(e,t,n){super(),this._univerInstanceService=e,this._renderManagerService=t,this._injector=n,f(this,`_findModelsByUnitId`,new Map)}async find(e){this._terminate();let n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!n)return[];let r=this._preprocessQuery(e),i=this._renderManagerService.getRenderById(n.getUnitId()).with(a.SheetSkeletonManagerService),o=this._injector.createInstance(C,n,i);return this._findModelsByUnitId.set(n.getUnitId(),o),o.start(r),[o]}terminate(){this._terminate()}_terminate(){this._findModelsByUnitId.forEach(e=>e.dispose()),this._findModelsByUnitId.clear()}_preprocessQuery(e){let t=e.caseSensitive?e.findString:e.findString.toLowerCase();return t=t.trim(),{...e,findString:t}}};T=x([b(0,t.IUniverInstanceService),b(1,r.IRenderManagerService),b(2,(0,t.Inject)(t.Injector))],T);let E={hit:!1,replaceable:!1,isFormula:!1,rawData:null};function D(e,t,n,r,a){let{findBy:o}=r,s=o===i.FindBy.FORMULA,c=e.getCellRaw(t,n);return E.rawData=c,c!=null&&c.f?(E.isFormula=!0,s?O({v:c.f},r)?(E.hit=!0,E.replaceable=!0,E):(E.hit=!1,E.replaceable=!1,E):(E.replaceable=!1,O(a,r)?E.hit=!0:E.hit=!1,E)):(E.isFormula=!1,O(a,r)?c?(E.hit=!0,E.replaceable=!0):(E.hit=!0,E.replaceable=!1):(E.hit=!1,E.replaceable=!1),E)}function O(e,t){let n=k(e);return n?t.matchesTheWholeCell?(n=A(n),t.caseSensitive?n===t.findString:n.toLowerCase()===t.findString):t.caseSensitive?n.indexOf(t.findString)>-1:n.toLowerCase().indexOf(t.findString)>-1:!1}function k(e){var t,n;let r=(t=e==null||(n=e.p)==null||(n=n.body)==null?void 0:n.dataStream)==null?e==null?void 0:e.v:t;return typeof r==`number`?`${r}`:typeof r==`boolean`?r?`1`:`0`:r}function A(e){return e.replace(/^ +/g,``).replace(/ +$/g,``)}var j=`@univerjs/sheets-find-replace`,M=`0.21.1`;let N=`sheets-find-replace.config`;Symbol(N);let P={},F=class extends t.Plugin{constructor(e=P,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},P,this._config);this._configService.setConfig(N,i)}onStarting(){[[S]].forEach(e=>this._injector.add(e))}onSteady(){this._injector.get(S)}};f(F,`pluginName`,`SHEET_FIND_REPLACE_PLUGIN`),f(F,`packageName`,j),f(F,`version`,M),f(F,`type`,t.UniverInstanceType.UNIVER_SHEET),F=x([(0,t.DependentOn)(n.UniverSheetsPlugin,n.UniverSheetsPlugin,i.UniverFindReplacePlugin),b(1,(0,t.Inject)(t.Injector)),b(2,t.IConfigService)],F),e.SheetReplaceCommand=s,Object.defineProperty(e,`SheetsFindReplaceController`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,`UniverSheetsFindReplacePlugin`,{enumerable:!0,get:function(){return F}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/sheets`),require(`@univerjs/engine-render`),require(`@univerjs/find-replace`),require(`@univerjs/sheets-ui`),require(`rxjs`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/engine-render`,`@univerjs/find-replace`,`@univerjs/sheets-ui`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsFindReplace={},e.UniverCore,e.UniverSheets,e.UniverEngineRender,e.UniverFindReplace,e.UniverSheetsUi,e.rxjs))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let s={id:`sheet.command.replace`,type:t.CommandType.COMMAND,handler:async(e,r)=>{let i=e.get(t.IUndoRedoService),a=e.get(t.ICommandService),{unitId:o,replacements:s}=r,l=i.__tempBatchingUndoRedo(o),u=await Promise.all(s.map(e=>a.executeCommand(n.SetRangeValuesCommand.id,{unitId:o,subUnitId:e.subUnitId,value:e.value})));return l.dispose(),c(u,s)}};function c(e,t){let n=0,r=0;return e.forEach((e,i)=>{let a=t[i].count;e?n+=a:r+=a}),{success:n,failure:r}}function l(e){"@babel/helpers - typeof";return l=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},l(e)}function u(e,t){if(l(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(l(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function d(e){var t=u(e,`string`);return l(t)==`symbol`?t:t+``}function f(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var p=class extends r.Shape{constructor(e,t){super(e,t),f(this,`_activated`,!1),f(this,`_inHiddenRange`,!1),f(this,`_color`,void 0),t&&this.setShapeProps(t)}setShapeProps(e){this._activated=!!e.activated,e.inHiddenRange!==void 0&&(this._inHiddenRange=e.inHiddenRange),e.color!==void 0&&(this._color=e.color),this.transformByState({width:e.width,height:e.height})}_draw(e){let t=this._activated,n=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, 0.35)`,i=`rgb(${this._color.r}, ${this._color.g}, ${this._color.b})`;r.Rect.drawWith(e,{width:this.width,height:this.height,fill:n,stroke:t?i:void 0,strokeWidth:t?2:0,evented:!1})}};function m(e,t){return e.startRow===t.startRow&&e.startColumn===t.startColumn}function h(e,t){return e.startRow<t.startRow||e.startRow===t.startRow&&e.startColumn<=t.startColumn}function g(e,t){return e.startColumn<t.startColumn||e.startColumn===t.startColumn&&e.startRow<=t.startRow}function _(e,t){return e.startRow>t.startRow||e.startRow===t.startRow&&e.startColumn>=t.startColumn}function v(e,t){return e.startColumn>t.startColumn||e.startColumn===t.startColumn&&e.startRow>=t.startRow}function y(e,n){let{range:r}=e,{startRow:i,startColumn:a}=r,o=n.getMergedCell(i,a);return o?t.Rectangle.equals(r,o):r.endRow===r.startRow&&r.endColumn===r.startColumn}function b(e,t){return function(n,r){t(n,r,e)}}function x(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let S=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._findReplaceController=t,this._contextService=n,this._findReplaceService=r,this._commandService=i,f(this,`_provider`,void 0),this._init(),this._initCommands()}dispose(){super.dispose(),this._findReplaceController.closePanel(),this._provider.dispose()}_init(){let e=this._injector.createInstance(T);this._provider=e,this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(e)),this.disposeWithMe(this._contextService.subscribeContextValue$(t.EDITOR_ACTIVATED).pipe((0,o.filter)(e=>!!e)).subscribe(()=>this._findReplaceController.closePanel()))}_initCommands(){[s].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};S=x([b(0,(0,t.Inject)(t.Injector)),b(1,(0,t.Inject)(i.FindReplaceController)),b(2,t.IContextService),b(3,i.IFindReplaceService),b(4,t.ICommandService)],S);let C=class extends i.FindModel{get _matchesCount(){return this._matches.length}get unitId(){return this._workbook.getUnitId()}get matchesCount(){return this._matchesCount}get matchesPosition(){return this._matchesPosition}get currentMatch(){return this._matchesPosition>0?this._matches[this._matchesPosition-1]:null}constructor(e,t,n,r,i,a,s,c){super(),this._workbook=e,this._sheetSkeletonManagerService=t,this._univerInstanceService=n,this._renderManagerService=r,this._commandService=i,this._contextService=a,this._themeService=s,f(this,`_matchesUpdate$`,new o.Subject),f(this,`matchesUpdate$`,this._matchesUpdate$.asObservable()),f(this,`_activelyChangingMatch$`,new o.Subject),f(this,`activelyChangingMatch$`,this._activelyChangingMatch$.asObservable()),f(this,`_matchesByWorksheet`,new Map),f(this,`_matches`,[]),f(this,`_matchesPosition`,0),f(this,`_activeHighlightIndex`,-1),f(this,`_highlightShapes`,[]),f(this,`_currentHighlightShape`,null),f(this,`_query`,null),f(this,`_workbookSelections`,void 0),this._workbookSelections=c.getWorkbookSelections(this.unitId)}dispose(){super.dispose(),this._disposeHighlights(),this._toggleDisplayRawFormula(!1)}getMatches(){return this._matches}start(e){switch(this._query=e,e.findBy===i.FindBy.FORMULA?this._toggleDisplayRawFormula(!0):this._toggleDisplayRawFormula(!1),e.findScope){case i.FindScope.UNIT:this.findInWorkbook(e);break;case i.FindScope.SUBUNIT:default:this.findInActiveWorksheet(e);break}}focusSelection(){let e=this.currentMatch;e&&this._commandService.executeCommand(n.SelectRangeCommand.id,{unitId:e.unitId,subUnit:e.range.subUnitId,range:e.range.range})}_toggleDisplayRawFormula(e){this._contextService.setContextValue(r.RENDER_RAW_FORMULA_KEY,e)}findInWorkbook(e){let r=this._workbook.getUnitId(),i,a=!0,s=()=>{let t=this._workbook.getSheets().filter(e=>!e.isSheetHidden()).map(t=>{let n=this._findInWorksheet(t,e,r),i=t.getSheetId(),{results:a}=n;return a.length?this._matchesByWorksheet.set(i,n.results):this._matchesByWorksheet.delete(i),n});this._matches=t.map(e=>e.results).flat(),this._updateFindHighlight(),a?(i={results:this._matches},a=!1):this._matchesUpdate$.next(this._matches)};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._updateFindHighlight(),this._updateCurrentHighlightShape(this._activeHighlightIndex)})),this.disposeWithMe((0,t.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0,o.filter)(([e,t])=>e.id===n.SetWorksheetActiveOperation.id&&!(t!=null&&t.fromFindReplace))).subscribe(()=>{let e=this._workbook.getActiveSheet();if(!e)return;let t=e.getSheetId();this._matchesByWorksheet.has(t)&&this._findNextMatchOnActiveSheetChange(e)})),this.disposeWithMe((0,t.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0,o.filter)(([e])=>e.type===t.CommandType.MUTATION&&e.params.unitId===this._workbook.getUnitId()),(0,o.throttleTime)(600,void 0,{leading:!1,trailing:!0})).subscribe(()=>s())),s(),i}_findNextMatchOnActiveSheetChange(e){let t,n,r=0,i=this._matchesByWorksheet.get(e.getSheetId()),a=this._workbookSelections.getCurrentSelections();a!=null&&a.length?([t,r]=this._findNextMatchByRange(i,a[0].range),n=i.findIndex(e=>e===t)):(t=i[0],n=0,r=this._matches.findIndex(e=>e===t)),this._matchesPosition=r+1,this._activelyChangingMatch$.next(t),this._activeHighlightIndex=n,this._updateFindHighlight(),this._updateCurrentHighlightShape(n)}findInActiveWorksheet(e){let r=this._workbook.getUnitId(),i=()=>{var e;let t=this._workbook.getActiveSheet();if(!t)return!1;let n=this._workbookSelections.getCurrentSelections();return(e=n==null?void 0:n.some(e=>!y(e,t)))==null?!1:e},a,s=!0,c=!1,l=()=>{let t=this._workbook.getActiveSheet();if(!t)return{results:[]};let n=this.currentMatch;c=i();let o=this._workbookSelections.getCurrentSelections(),l=c?this._findInSelections(t,o,e,r):this._findInWorksheet(t,e,r);return this._matches=l.results,this._matchesPosition=this._tryRestoreLastMatchesPosition(n,this._matches),s?(a=l,s=!1):this._matchesUpdate$.next(this._matches),this._updateFindHighlight(),l};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>this._updateFindHighlight())),this.disposeWithMe((0,o.merge)((0,t.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0,o.filter)(([e])=>{if(e.type===t.CommandType.MUTATION&&e.params.unitId===this._workbook.getUnitId())return!0;if(e.id===n.SetSelectionsOperation.id&&e.params.unitId===r){let e=i();return e===!1&&c===!1?!1:(c=e,!0)}return!1})),this._workbook.activeSheet$.pipe((0,o.skip)(1))).pipe((0,o.debounceTime)(200)).subscribe(()=>l())),l(),a}_findInRange(e,t,n,r,a){let o=[],s=e.getSheetId(),c=(t.findDirection===i.FindDirection.COLUMN?e.iterateByColumn:e.iterateByRow).bind(e)(n);for(let n of c){let{row:i,col:c,colSpan:l,rowSpan:u,value:d}=n;if(a!=null&&a(i,c)||!d||e.getRowFiltered(i))continue;let{hit:f,replaceable:p,isFormula:m}=D(e,i,c,t,d);if(f){let e={provider:`sheets-find-replace-provider`,unitId:r,replaceable:p,isFormula:m,range:{subUnitId:s,range:{startRow:i,startColumn:c,endColumn:c+(l==null?1:l)-1,endRow:i+(u==null?1:u)-1}}};o.push(e)}}return{results:o}}_findInSelections(e,t,n,r){let{findDirection:a}=n,o=a===i.FindDirection.ROW?h:g,s=new Set;return{results:t.map(t=>this._findInRange(e,n,t.range,r,(e,t)=>{let n=`${e}-${t}`;return s.has(n)?!0:(s.add(n),!1)}).results).flat().sort((e,t)=>o(e.range.range,t.range.range)?-1:1)}}_findInWorksheet(e,t,n){let r=e.getRowCount(),i=e.getColumnCount(),a={startRow:0,startColumn:0,endRow:r-1,endColumn:i-1};return this._findInRange(e,t,a,n)}_disposeHighlights(){var e;this._highlightShapes.forEach(e=>{var t;(t=e.getScene())==null||t.makeDirty(),e.dispose()}),this._highlightShapes=[],(e=this._currentHighlightShape)==null||e.dispose(),this._currentHighlightShape=null}_updateFindHighlight(){this._disposeHighlights();let e=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!e)return;let n=this._workbook.getUnitId(),r=this._renderManagerService.getRenderById(n);if(r==null)return;let{scene:i}=r,o=this._matches,s=new t.ColorKit(this._themeService.getColorFromTheme(`yellow.400`)).toRgb(),c=this._workbook.getActiveSheet();if(!c)return;let l=c.getSheetId(),u=o.filter(e=>e.range.subUnitId===l).map((t,n)=>{let{startColumn:r,startRow:o,endColumn:l,endRow:u}=t.range.range,d=(0,a.getCoordByCell)(o,r,i,e),f=(0,a.getCoordByCell)(u,l,i,e),{startX:m,startY:h}=d,{endX:g,endY:_}=f,v=!0;for(let e=o;e<=u;e++)if(c.getRowRawVisible(e)){v=!1;break}let y=!0;for(let e=r;e<=l;e++)if(c.getColVisible(e)){y=!1;break}let b=v||y,x={left:m,top:h,color:s,width:y?2:g-m,height:v?2:_-h,evented:!1,inHiddenRange:b,zIndex:1e4};return new p(`find-highlight-${n}`,x)});i.addObjects(u),this._highlightShapes=u,i.makeDirty()}_updateCurrentHighlightShape(e){var t;if((t=this._currentHighlightShape)==null||t.setShapeProps({activated:!1}),this._currentHighlightShape=null,e!==void 0){let t=this._highlightShapes[e];if(!t)return;this._currentHighlightShape=t,t.setShapeProps({activated:!0})}}_getSheetObject(){return(0,a.getSheetObject)(this._univerInstanceService,this._renderManagerService)}_focusMatch(e){var t;let r=e.range.subUnitId;r!==((t=this._workbook.getActiveSheet())==null?void 0:t.getSheetId())&&this._commandService.executeCommand(n.SetWorksheetActivateCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:r},{fromFindReplace:!0}),this._commandService.executeCommand(a.ScrollToCellCommand.id,{range:e.range.range},{fromFindReplace:!0})}_tryRestoreLastMatchesPosition(e,t){if(!e)return 0;let{subUnitId:n}=e.range,{startColumn:r,startRow:i}=e.range.range,a=t.findIndex(e=>{if(n!==e.range.subUnitId)return!1;let{startColumn:t,startRow:a}=e.range.range;return t===r&&a===i});return a>-1?a+1:0}moveToNextMatch(e){var t,n,r,a;if(!this._matches.length)return null;let o=(t=e==null?void 0:e.loop)==null?!1:t,s=(n=e==null?void 0:e.stayIfOnMatch)==null?!1:n,c=(r=e==null?void 0:e.noFocus)==null?!1:r,l=(a=e==null?void 0:e.ignoreSelection)==null?!1:a,u=this._findNextMatch(o,s,l);if(u){var d;let[e,t]=u;return this._matchesPosition=t+1,this._query.findScope===i.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(e.range.subUnitId).findIndex(t=>t===e):this._activeHighlightIndex=t,c||this._focusMatch(e),((d=this._workbook.getActiveSheet())==null?void 0:d.getSheetId())===e.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),e}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}moveToPreviousMatch(e){var t,n,r,a;if(!this._matches.length)return null;let o=(t=e==null?void 0:e.loop)==null?!1:t,s=(n=e==null?void 0:e.stayIfOnMatch)==null?!1:n,c=(r=e==null?void 0:e.noFocus)==null?!1:r,l=(a=e==null?void 0:e.ignoreSelection)==null?!1:a,u=this._findPreviousMatch(o,s,l);if(u){var d;let[e,t]=u;return this._matchesPosition=t+1,this._query.findScope===i.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(e.range.subUnitId).findIndex(t=>t===e):this._activeHighlightIndex=t,c||this._focusMatch(e),((d=this._workbook.getActiveSheet())==null?void 0:d.getSheetId())===e.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),e}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}_findPreviousMatch(e=!1,t=!1,n=!1){var r;if(this.currentMatch){let n=this._matches.findIndex(e=>e===this.currentMatch);if(t)return[this.currentMatch,n];let r=n-1;if(!e&&r<0)return null;let i=this._matches.length,a=(r+i)%i;return[this._matches[a],a]}let a=this._workbookSelections.getCurrentLastSelection();if(n||!a){let e=this._matches.length-1;return[this._matches[e],e]}if(this._query.findScope!==i.FindScope.UNIT)return this._findPreviousMatchByRange(this._matches,a.range);let o=(r=this._workbook.getActiveSheet())==null?void 0:r.getSheetId();if(!o)return null;let s=this._findPreviousWorksheetThatHasAMatch(o,e);return s?this._findPreviousMatchByRange(this._matchesByWorksheet.get(s),a.range):null}_findNextMatch(e=!1,t=!1,n=!1){var r;if(this.currentMatch){let n=this._matches.findIndex(e=>e===this.currentMatch);if(t)return[this.currentMatch,n];let r=n+1,i=this._matches.length;if(!e&&r>=i)return null;let a=r%i;return[this._matches[a],a]}let a=this._workbookSelections.getCurrentLastSelection();if(n||!a)return[this._matches[0],0];if(this._query.findScope!==i.FindScope.UNIT)return this._findNextMatchByRange(this._matches,a.range,t);let o=(r=this._workbook.getActiveSheet())==null?void 0:r.getSheetId();if(!o)return null;let s=this._findNextWorksheetThatHasAMatch(o,e);return s?this._findNextMatchByRange(this._matchesByWorksheet.get(s),a.range):null}_findPreviousWorksheetThatHasAMatch(e,n=!1){let r=this._workbook.getSheetOrders(),i=r.findIndex(t=>t===e),a=(n?(0,t.rotate)(r,i+1):r.slice(0,i+1)).findLast(e=>this._matchesByWorksheet.has(e));return a==null?null:a}_findNextWorksheetThatHasAMatch(e,n=!1){let r=this._workbook.getSheetOrders(),i=r.findIndex(t=>t===e),a=(n?(0,t.rotate)(r,i):r.slice(i)).find(e=>this._matchesByWorksheet.has(e));return a==null?null:a}_findNextMatchByRange(e,t,n=!1){let r=this._query.findDirection===i.FindDirection.ROW,a=e.findIndex(e=>{let i=e.range.range;if(!(r?h(t,i):g(t,i)))return!1;let a=m(t,i);return n?a:!a});a===-1&&(a=e.length-1);let o=e[a];return[o,this._matches.findIndex(e=>e===o)]}_findPreviousMatchByRange(e,t,n=!1){let r=this._query.findDirection===i.FindDirection.ROW,a=this._matches.findLastIndex(e=>{let i=e.range.range;if(!(r?_(t,i):v(t,i)))return!1;let a=m(t,i);return n?a:!a});a===-1&&(a=0);let o=e[a];return[o,this._matches.findIndex(e=>e===o)]}async replace(e){if(this._matchesCount===0||!this.currentMatch||!this._query||!this.currentMatch.replaceable)return!1;let t=this.currentMatch.range,r=this._workbook.getSheetBySheetId(this.currentMatch.range.subUnitId),a=this._getReplacedCellData(this.currentMatch,r,this._query.findBy===i.FindBy.FORMULA,this._query.findString,e,this._query.caseSensitive?`g`:`ig`),o={unitId:this.currentMatch.unitId,subUnitId:t.subUnitId,value:{[t.range.startRow]:{[t.range.startColumn]:a}}};return this._commandService.executeCommand(n.SetRangeValuesCommand.id,o)}async replaceAll(e){if(this._matchesCount===0||!this._query)return{success:0,failure:0};let n=this._workbook.getUnitId(),{findString:r,caseSensitive:a,findBy:o}=this._query,c=o===i.FindBy.FORMULA,l=a?`g`:`ig`,u=[];return(0,t.groupBy)(this._matches.filter(e=>e.replaceable),e=>e.range.subUnitId).forEach((n,i)=>{let a=new t.ObjectMatrix,o=this._workbook.getSheetBySheetId(i);n.forEach(t=>{let{startColumn:n,startRow:i}=t.range.range,s=this._getReplacedCellData(t,o,c,r,e,l);s&&a.setValue(i,n,s)}),u.push({count:n.length,subUnitId:i,value:a.getMatrix()})}),u?this._commandService.executeCommand(s.id,{unitId:n,replacements:u}):{success:0,failure:0}}_getReplacedCellData(e,n,r,i,a,o){var s;let{startRow:c,startColumn:l}=e.range.range,u=n.getCellRaw(c,l);if(e.isFormula)return r?{f:u.f.replace(new RegExp(w(i),o),a),v:null}:null;if((s=u.p)!=null&&s.body){let e=t.Tools.deepClone(u.p);return(0,t.replaceInDocumentBody)(e.body,i,a,this._query.caseSensitive),{p:e}}return{v:u.v.toString().replace(new RegExp(w(i),o),a)}}};C=x([b(2,t.IUniverInstanceService),b(3,r.IRenderManagerService),b(4,t.ICommandService),b(5,t.IContextService),b(6,(0,t.Inject)(t.ThemeService)),b(7,(0,t.Inject)(n.SheetsSelectionsService))],C);function w(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`)}let T=class extends t.Disposable{constructor(e,t,n){super(),this._univerInstanceService=e,this._renderManagerService=t,this._injector=n,f(this,`_findModelsByUnitId`,new Map)}async find(e){this._terminate();let n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!n)return[];let r=this._preprocessQuery(e),i=this._renderManagerService.getRenderById(n.getUnitId()).with(a.SheetSkeletonManagerService),o=this._injector.createInstance(C,n,i);return this._findModelsByUnitId.set(n.getUnitId(),o),o.start(r),[o]}terminate(){this._terminate()}_terminate(){this._findModelsByUnitId.forEach(e=>e.dispose()),this._findModelsByUnitId.clear()}_preprocessQuery(e){let t=e.caseSensitive?e.findString:e.findString.toLowerCase();return t=t.trim(),{...e,findString:t}}};T=x([b(0,t.IUniverInstanceService),b(1,r.IRenderManagerService),b(2,(0,t.Inject)(t.Injector))],T);let E={hit:!1,replaceable:!1,isFormula:!1,rawData:null};function D(e,t,n,r,a){let{findBy:o}=r,s=o===i.FindBy.FORMULA,c=e.getCellRaw(t,n);return E.rawData=c,c!=null&&c.f?(E.isFormula=!0,s?O({v:c.f},r)?(E.hit=!0,E.replaceable=!0,E):(E.hit=!1,E.replaceable=!1,E):(E.replaceable=!1,O(a,r)?E.hit=!0:E.hit=!1,E)):(E.isFormula=!1,O(a,r)?c?(E.hit=!0,E.replaceable=!0):(E.hit=!0,E.replaceable=!1):(E.hit=!1,E.replaceable=!1),E)}function O(e,t){let n=k(e);return n?t.matchesTheWholeCell?(n=A(n),t.caseSensitive?n===t.findString:n.toLowerCase()===t.findString):t.caseSensitive?n.indexOf(t.findString)>-1:n.toLowerCase().indexOf(t.findString)>-1:!1}function k(e){var t,n;let r=(t=e==null||(n=e.p)==null||(n=n.body)==null?void 0:n.dataStream)==null?e==null?void 0:e.v:t;return typeof r==`number`?`${r}`:typeof r==`boolean`?r?`1`:`0`:r}function A(e){return e.replace(/^ +/g,``).replace(/ +$/g,``)}var j=`@univerjs/sheets-find-replace`,M=`0.22.0`;let N=`sheets-find-replace.config`;Symbol(N);let P={},F=class extends t.Plugin{constructor(e=P,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},P,this._config);this._configService.setConfig(N,i)}onStarting(){[[S]].forEach(e=>this._injector.add(e))}onSteady(){this._injector.get(S)}};f(F,`pluginName`,`SHEET_FIND_REPLACE_PLUGIN`),f(F,`packageName`,j),f(F,`version`,M),f(F,`type`,t.UniverInstanceType.UNIVER_SHEET),F=x([(0,t.DependentOn)(n.UniverSheetsPlugin,n.UniverSheetsPlugin,i.UniverFindReplacePlugin),b(1,(0,t.Inject)(t.Injector)),b(2,t.IConfigService)],F),e.SheetReplaceCommand=s,Object.defineProperty(e,`SheetsFindReplaceController`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,`UniverSheetsFindReplacePlugin`,{enumerable:!0,get:function(){return F}})});
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-find-replace",
3
- "version": "0.21.1",
3
+ "version": "0.22.0",
4
4
  "private": false,
5
- "description": "UniverSheet find replace plugin",
6
- "author": "DreamNum <developer@univer.ai>",
5
+ "description": "Find and replace integration for Univer Sheets.",
6
+ "author": "DreamNum Co., Ltd. <developer@univer.ai>",
7
7
  "license": "Apache-2.0",
8
8
  "funding": {
9
9
  "type": "opencollective",
@@ -18,7 +18,11 @@
18
18
  "url": "https://github.com/dream-num/univer/issues"
19
19
  },
20
20
  "keywords": [
21
- "univer"
21
+ "univer",
22
+ "sheets",
23
+ "find-replace",
24
+ "search",
25
+ "plugin"
22
26
  ],
23
27
  "exports": {
24
28
  ".": {
@@ -63,17 +67,17 @@
63
67
  "rxjs": ">=7.0.0"
64
68
  },
65
69
  "dependencies": {
66
- "@univerjs/core": "0.21.1",
67
- "@univerjs/engine-render": "0.21.1",
68
- "@univerjs/sheets": "0.21.1",
69
- "@univerjs/find-replace": "0.21.1",
70
- "@univerjs/sheets-ui": "0.21.1"
70
+ "@univerjs/engine-render": "0.22.0",
71
+ "@univerjs/sheets": "0.22.0",
72
+ "@univerjs/sheets-ui": "0.22.0",
73
+ "@univerjs/core": "0.22.0",
74
+ "@univerjs/find-replace": "0.22.0"
71
75
  },
72
76
  "devDependencies": {
73
77
  "rxjs": "^7.8.2",
74
- "typescript": "^6.0.2",
75
- "vitest": "^4.1.4",
76
- "@univerjs-infra/shared": "0.21.1"
78
+ "typescript": "^6.0.3",
79
+ "vitest": "^4.1.5",
80
+ "@univerjs-infra/shared": "0.22.0"
77
81
  },
78
82
  "scripts": {
79
83
  "test": "vitest run",