@univerjs/sheets-find-replace 1.3.0 → 1.4.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/lib/cjs/facade.js +8 -17
- package/lib/cjs/index.js +16 -31
- package/lib/es/facade.js +8 -16
- package/lib/es/index.js +16 -31
- package/lib/facade.js +8 -16
- package/lib/index.js +16 -31
- package/lib/umd/index.js +1 -1
- package/package.json +11 -11
package/lib/cjs/facade.js
CHANGED
|
@@ -4,7 +4,7 @@ let _univerjs_sheets_facade = require("@univerjs/sheets/facade");
|
|
|
4
4
|
let rxjs = require("rxjs");
|
|
5
5
|
let _univerjs_core_facade = require("@univerjs/core/facade");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
|
|
8
8
|
function _typeof(o) {
|
|
9
9
|
"@babel/helpers - typeof";
|
|
10
10
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -14,8 +14,7 @@ function _typeof(o) {
|
|
|
14
14
|
}, _typeof(o);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
17
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
|
|
19
18
|
function toPrimitive(t, r) {
|
|
20
19
|
if ("object" != _typeof(t) || !t) return t;
|
|
21
20
|
var e = t[Symbol.toPrimitive];
|
|
@@ -27,15 +26,13 @@ function toPrimitive(t, r) {
|
|
|
27
26
|
return ("string" === r ? String : Number)(t);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
29
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
|
|
32
30
|
function toPropertyKey(t) {
|
|
33
31
|
var i = toPrimitive(t, "string");
|
|
34
32
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
35
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
|
|
39
36
|
function _defineProperty(e, r, t) {
|
|
40
37
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
41
38
|
value: t,
|
|
@@ -45,16 +42,14 @@ function _defineProperty(e, r, t) {
|
|
|
45
42
|
}) : e[r] = t, e;
|
|
46
43
|
}
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
45
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
|
|
50
46
|
function __decorateParam(paramIndex, decorator) {
|
|
51
47
|
return function(target, key) {
|
|
52
48
|
decorator(target, key, paramIndex);
|
|
53
49
|
};
|
|
54
50
|
}
|
|
55
51
|
|
|
56
|
-
|
|
57
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
52
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
|
|
58
53
|
function __decorate(decorators, target, key, desc) {
|
|
59
54
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
60
55
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -62,8 +57,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
62
57
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
63
58
|
}
|
|
64
59
|
|
|
65
|
-
|
|
66
|
-
//#region src/facade/f-text-finder.ts
|
|
60
|
+
// src/facade/f-text-finder.ts
|
|
67
61
|
let FTextFinder = class FTextFinder extends _univerjs_core.Disposable {
|
|
68
62
|
constructor(_initialState, _injector, _univerInstanceService, _findReplaceService) {
|
|
69
63
|
super();
|
|
@@ -172,8 +166,7 @@ FTextFinder = __decorate([
|
|
|
172
166
|
__decorateParam(3, _univerjs_find_replace.IFindReplaceService)
|
|
173
167
|
], FTextFinder);
|
|
174
168
|
|
|
175
|
-
|
|
176
|
-
//#region src/facade/f-univer.ts
|
|
169
|
+
// src/facade/f-univer.ts
|
|
177
170
|
var FUniverSheetsFindReplaceMixin = class extends _univerjs_core_facade.FUniver {
|
|
178
171
|
async createTextFinderAsync(text) {
|
|
179
172
|
const state = { findString: text };
|
|
@@ -183,5 +176,3 @@ var FUniverSheetsFindReplaceMixin = class extends _univerjs_core_facade.FUniver
|
|
|
183
176
|
}
|
|
184
177
|
};
|
|
185
178
|
_univerjs_core_facade.FUniver.extend(FUniverSheetsFindReplaceMixin);
|
|
186
|
-
|
|
187
|
-
//#endregion
|
package/lib/cjs/index.js
CHANGED
|
@@ -6,7 +6,7 @@ let _univerjs_find_replace = require("@univerjs/find-replace");
|
|
|
6
6
|
let _univerjs_sheets_ui = require("@univerjs/sheets-ui");
|
|
7
7
|
let rxjs = require("rxjs");
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// src/commands/commands/sheet-replace.command.ts
|
|
10
10
|
/**
|
|
11
11
|
* This command is used for the SheetFindReplaceController to deal with replacing, including undo redo.
|
|
12
12
|
*
|
|
@@ -42,8 +42,7 @@ function getReplaceAllResult(results, replacements) {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
45
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
|
|
47
46
|
function _typeof(o) {
|
|
48
47
|
"@babel/helpers - typeof";
|
|
49
48
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -53,8 +52,7 @@ function _typeof(o) {
|
|
|
53
52
|
}, _typeof(o);
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
55
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
|
|
58
56
|
function toPrimitive(t, r) {
|
|
59
57
|
if ("object" != _typeof(t) || !t) return t;
|
|
60
58
|
var e = t[Symbol.toPrimitive];
|
|
@@ -66,15 +64,13 @@ function toPrimitive(t, r) {
|
|
|
66
64
|
return ("string" === r ? String : Number)(t);
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
67
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
|
|
71
68
|
function toPropertyKey(t) {
|
|
72
69
|
var i = toPrimitive(t, "string");
|
|
73
70
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
74
71
|
}
|
|
75
72
|
|
|
76
|
-
|
|
77
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
73
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
|
|
78
74
|
function _defineProperty(e, r, t) {
|
|
79
75
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
80
76
|
value: t,
|
|
@@ -84,8 +80,7 @@ function _defineProperty(e, r, t) {
|
|
|
84
80
|
}) : e[r] = t, e;
|
|
85
81
|
}
|
|
86
82
|
|
|
87
|
-
|
|
88
|
-
//#region src/views/shapes/find-replace-highlight.shape.ts
|
|
83
|
+
// src/views/shapes/find-replace-highlight.shape.ts
|
|
89
84
|
var SheetFindReplaceHighlightShape = class extends _univerjs_engine_render.Shape {
|
|
90
85
|
constructor(key, props) {
|
|
91
86
|
super(key, props);
|
|
@@ -118,8 +113,7 @@ var SheetFindReplaceHighlightShape = class extends _univerjs_engine_render.Shape
|
|
|
118
113
|
}
|
|
119
114
|
};
|
|
120
115
|
|
|
121
|
-
|
|
122
|
-
//#region src/controllers/utils.ts
|
|
116
|
+
// src/controllers/utils.ts
|
|
123
117
|
function isSamePosition(range1, range2) {
|
|
124
118
|
return range1.startRow === range2.startRow && range1.startColumn === range2.startColumn;
|
|
125
119
|
}
|
|
@@ -161,16 +155,14 @@ function isSelectionSingleCell(selection, worksheet) {
|
|
|
161
155
|
else return range.endRow === range.startRow && range.endColumn === range.startColumn;
|
|
162
156
|
}
|
|
163
157
|
|
|
164
|
-
|
|
165
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
158
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
|
|
166
159
|
function __decorateParam(paramIndex, decorator) {
|
|
167
160
|
return function(target, key) {
|
|
168
161
|
decorator(target, key, paramIndex);
|
|
169
162
|
};
|
|
170
163
|
}
|
|
171
164
|
|
|
172
|
-
|
|
173
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
165
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
|
|
174
166
|
function __decorate(decorators, target, key, desc) {
|
|
175
167
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
176
168
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -178,8 +170,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
178
170
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
179
171
|
}
|
|
180
172
|
|
|
181
|
-
|
|
182
|
-
//#region src/controllers/sheet-find-replace.controller.ts
|
|
173
|
+
// src/controllers/sheet-find-replace.controller.ts
|
|
183
174
|
let SheetsFindReplaceController = class SheetsFindReplaceController extends _univerjs_core.Disposable {
|
|
184
175
|
constructor(_injector, _contextService, _findReplaceService, _commandService) {
|
|
185
176
|
super();
|
|
@@ -861,13 +852,11 @@ function extractPureValue(cell) {
|
|
|
861
852
|
return rawValue;
|
|
862
853
|
}
|
|
863
854
|
|
|
864
|
-
|
|
865
|
-
//#region package.json
|
|
855
|
+
// package.json
|
|
866
856
|
var name = "@univerjs/sheets-find-replace";
|
|
867
|
-
var version = "1.
|
|
857
|
+
var version = "1.4.0";
|
|
868
858
|
|
|
869
|
-
|
|
870
|
-
//#region src/config/config.ts
|
|
859
|
+
// src/config/config.ts
|
|
871
860
|
/**
|
|
872
861
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
873
862
|
*
|
|
@@ -887,8 +876,7 @@ const SHEETS_FIND_REPLACE_PLUGIN_CONFIG_KEY = "sheets-find-replace.config";
|
|
|
887
876
|
const configSymbol = Symbol(SHEETS_FIND_REPLACE_PLUGIN_CONFIG_KEY);
|
|
888
877
|
const defaultPluginConfig = {};
|
|
889
878
|
|
|
890
|
-
|
|
891
|
-
//#region src/controllers/mobile/sheet-find-replace-mobile.controller.ts
|
|
879
|
+
// src/controllers/mobile/sheet-find-replace-mobile.controller.ts
|
|
892
880
|
const MOBILE_FIND_REPLACE_BAR_SELECTOR = "[data-u-comp=\"mobile-find-replace-bar\"]";
|
|
893
881
|
const MOBILE_FIND_MATCH_SAFE_PADDING = 8;
|
|
894
882
|
function getMobileFindMatchScrollOffset(cellBottom, barTop, safePadding) {
|
|
@@ -953,8 +941,7 @@ SheetsFindReplaceMobileController = __decorate([
|
|
|
953
941
|
__decorateParam(2, _univerjs_engine_render.IRenderManagerService)
|
|
954
942
|
], SheetsFindReplaceMobileController);
|
|
955
943
|
|
|
956
|
-
|
|
957
|
-
//#region src/mobile-plugin.ts
|
|
944
|
+
// src/mobile-plugin.ts
|
|
958
945
|
let UniverSheetsFindReplaceMobileUIPlugin = class UniverSheetsFindReplaceMobileUIPlugin extends _univerjs_core.Plugin {
|
|
959
946
|
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
960
947
|
super();
|
|
@@ -984,8 +971,7 @@ UniverSheetsFindReplaceMobileUIPlugin = __decorate([
|
|
|
984
971
|
__decorateParam(2, _univerjs_core.IConfigService)
|
|
985
972
|
], UniverSheetsFindReplaceMobileUIPlugin);
|
|
986
973
|
|
|
987
|
-
|
|
988
|
-
//#region src/plugin.ts
|
|
974
|
+
// src/plugin.ts
|
|
989
975
|
let UniverSheetsFindReplacePlugin = class UniverSheetsFindReplacePlugin extends _univerjs_core.Plugin {
|
|
990
976
|
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
991
977
|
super();
|
|
@@ -1012,7 +998,6 @@ UniverSheetsFindReplacePlugin = __decorate([
|
|
|
1012
998
|
__decorateParam(2, _univerjs_core.IConfigService)
|
|
1013
999
|
], UniverSheetsFindReplacePlugin);
|
|
1014
1000
|
|
|
1015
|
-
//#endregion
|
|
1016
1001
|
exports.SheetReplaceCommand = SheetReplaceCommand;
|
|
1017
1002
|
Object.defineProperty(exports, "SheetsFindReplaceController", {
|
|
1018
1003
|
enumerable: true,
|
package/lib/es/facade.js
CHANGED
|
@@ -4,7 +4,7 @@ import { FRange } from "@univerjs/sheets/facade";
|
|
|
4
4
|
import { filter, firstValueFrom } from "rxjs";
|
|
5
5
|
import { FUniver } from "@univerjs/core/facade";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
|
|
8
8
|
function _typeof(o) {
|
|
9
9
|
"@babel/helpers - typeof";
|
|
10
10
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -14,8 +14,7 @@ function _typeof(o) {
|
|
|
14
14
|
}, _typeof(o);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
17
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
|
|
19
18
|
function toPrimitive(t, r) {
|
|
20
19
|
if ("object" != _typeof(t) || !t) return t;
|
|
21
20
|
var e = t[Symbol.toPrimitive];
|
|
@@ -27,15 +26,13 @@ function toPrimitive(t, r) {
|
|
|
27
26
|
return ("string" === r ? String : Number)(t);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
29
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
|
|
32
30
|
function toPropertyKey(t) {
|
|
33
31
|
var i = toPrimitive(t, "string");
|
|
34
32
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
35
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
|
|
39
36
|
function _defineProperty(e, r, t) {
|
|
40
37
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
41
38
|
value: t,
|
|
@@ -45,16 +42,14 @@ function _defineProperty(e, r, t) {
|
|
|
45
42
|
}) : e[r] = t, e;
|
|
46
43
|
}
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
45
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
|
|
50
46
|
function __decorateParam(paramIndex, decorator) {
|
|
51
47
|
return function(target, key) {
|
|
52
48
|
decorator(target, key, paramIndex);
|
|
53
49
|
};
|
|
54
50
|
}
|
|
55
51
|
|
|
56
|
-
|
|
57
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
52
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
|
|
58
53
|
function __decorate(decorators, target, key, desc) {
|
|
59
54
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
60
55
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -62,8 +57,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
62
57
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
63
58
|
}
|
|
64
59
|
|
|
65
|
-
|
|
66
|
-
//#region src/facade/f-text-finder.ts
|
|
60
|
+
// src/facade/f-text-finder.ts
|
|
67
61
|
let FTextFinder = class FTextFinder extends Disposable {
|
|
68
62
|
constructor(_initialState, _injector, _univerInstanceService, _findReplaceService) {
|
|
69
63
|
super();
|
|
@@ -172,8 +166,7 @@ FTextFinder = __decorate([
|
|
|
172
166
|
__decorateParam(3, IFindReplaceService)
|
|
173
167
|
], FTextFinder);
|
|
174
168
|
|
|
175
|
-
|
|
176
|
-
//#region src/facade/f-univer.ts
|
|
169
|
+
// src/facade/f-univer.ts
|
|
177
170
|
var FUniverSheetsFindReplaceMixin = class extends FUniver {
|
|
178
171
|
async createTextFinderAsync(text) {
|
|
179
172
|
const state = { findString: text };
|
|
@@ -184,5 +177,4 @@ var FUniverSheetsFindReplaceMixin = class extends FUniver {
|
|
|
184
177
|
};
|
|
185
178
|
FUniver.extend(FUniverSheetsFindReplaceMixin);
|
|
186
179
|
|
|
187
|
-
//#endregion
|
|
188
180
|
export { };
|
package/lib/es/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { CloseFindDialogOperation, FindBy, FindDirection, FindModel, FindScope,
|
|
|
5
5
|
import { ScrollToCellCommand, SetScrollRelativeCommand, SheetSkeletonManagerService, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, getCoordByCell, getSheetObject, getViewportByCell } from "@univerjs/sheets-ui";
|
|
6
6
|
import { Subject, debounceTime, filter, merge as merge$1, skip, throttleTime } from "rxjs";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// src/commands/commands/sheet-replace.command.ts
|
|
9
9
|
/**
|
|
10
10
|
* This command is used for the SheetFindReplaceController to deal with replacing, including undo redo.
|
|
11
11
|
*
|
|
@@ -41,8 +41,7 @@ function getReplaceAllResult(results, replacements) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
44
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
|
|
46
45
|
function _typeof(o) {
|
|
47
46
|
"@babel/helpers - typeof";
|
|
48
47
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -52,8 +51,7 @@ function _typeof(o) {
|
|
|
52
51
|
}, _typeof(o);
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
54
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
|
|
57
55
|
function toPrimitive(t, r) {
|
|
58
56
|
if ("object" != _typeof(t) || !t) return t;
|
|
59
57
|
var e = t[Symbol.toPrimitive];
|
|
@@ -65,15 +63,13 @@ function toPrimitive(t, r) {
|
|
|
65
63
|
return ("string" === r ? String : Number)(t);
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
|
|
69
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
66
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
|
|
70
67
|
function toPropertyKey(t) {
|
|
71
68
|
var i = toPrimitive(t, "string");
|
|
72
69
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
73
70
|
}
|
|
74
71
|
|
|
75
|
-
|
|
76
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
72
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
|
|
77
73
|
function _defineProperty(e, r, t) {
|
|
78
74
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
79
75
|
value: t,
|
|
@@ -83,8 +79,7 @@ function _defineProperty(e, r, t) {
|
|
|
83
79
|
}) : e[r] = t, e;
|
|
84
80
|
}
|
|
85
81
|
|
|
86
|
-
|
|
87
|
-
//#region src/views/shapes/find-replace-highlight.shape.ts
|
|
82
|
+
// src/views/shapes/find-replace-highlight.shape.ts
|
|
88
83
|
var SheetFindReplaceHighlightShape = class extends Shape {
|
|
89
84
|
constructor(key, props) {
|
|
90
85
|
super(key, props);
|
|
@@ -117,8 +112,7 @@ var SheetFindReplaceHighlightShape = class extends Shape {
|
|
|
117
112
|
}
|
|
118
113
|
};
|
|
119
114
|
|
|
120
|
-
|
|
121
|
-
//#region src/controllers/utils.ts
|
|
115
|
+
// src/controllers/utils.ts
|
|
122
116
|
function isSamePosition(range1, range2) {
|
|
123
117
|
return range1.startRow === range2.startRow && range1.startColumn === range2.startColumn;
|
|
124
118
|
}
|
|
@@ -160,16 +154,14 @@ function isSelectionSingleCell(selection, worksheet) {
|
|
|
160
154
|
else return range.endRow === range.startRow && range.endColumn === range.startColumn;
|
|
161
155
|
}
|
|
162
156
|
|
|
163
|
-
|
|
164
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
157
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
|
|
165
158
|
function __decorateParam(paramIndex, decorator) {
|
|
166
159
|
return function(target, key) {
|
|
167
160
|
decorator(target, key, paramIndex);
|
|
168
161
|
};
|
|
169
162
|
}
|
|
170
163
|
|
|
171
|
-
|
|
172
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
164
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
|
|
173
165
|
function __decorate(decorators, target, key, desc) {
|
|
174
166
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
175
167
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -177,8 +169,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
177
169
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
178
170
|
}
|
|
179
171
|
|
|
180
|
-
|
|
181
|
-
//#region src/controllers/sheet-find-replace.controller.ts
|
|
172
|
+
// src/controllers/sheet-find-replace.controller.ts
|
|
182
173
|
let SheetsFindReplaceController = class SheetsFindReplaceController extends Disposable {
|
|
183
174
|
constructor(_injector, _contextService, _findReplaceService, _commandService) {
|
|
184
175
|
super();
|
|
@@ -860,13 +851,11 @@ function extractPureValue(cell) {
|
|
|
860
851
|
return rawValue;
|
|
861
852
|
}
|
|
862
853
|
|
|
863
|
-
|
|
864
|
-
//#region package.json
|
|
854
|
+
// package.json
|
|
865
855
|
var name = "@univerjs/sheets-find-replace";
|
|
866
|
-
var version = "1.
|
|
856
|
+
var version = "1.4.0";
|
|
867
857
|
|
|
868
|
-
|
|
869
|
-
//#region src/config/config.ts
|
|
858
|
+
// src/config/config.ts
|
|
870
859
|
/**
|
|
871
860
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
872
861
|
*
|
|
@@ -886,8 +875,7 @@ const SHEETS_FIND_REPLACE_PLUGIN_CONFIG_KEY = "sheets-find-replace.config";
|
|
|
886
875
|
const configSymbol = Symbol(SHEETS_FIND_REPLACE_PLUGIN_CONFIG_KEY);
|
|
887
876
|
const defaultPluginConfig = {};
|
|
888
877
|
|
|
889
|
-
|
|
890
|
-
//#region src/controllers/mobile/sheet-find-replace-mobile.controller.ts
|
|
878
|
+
// src/controllers/mobile/sheet-find-replace-mobile.controller.ts
|
|
891
879
|
const MOBILE_FIND_REPLACE_BAR_SELECTOR = "[data-u-comp=\"mobile-find-replace-bar\"]";
|
|
892
880
|
const MOBILE_FIND_MATCH_SAFE_PADDING = 8;
|
|
893
881
|
function getMobileFindMatchScrollOffset(cellBottom, barTop, safePadding) {
|
|
@@ -952,8 +940,7 @@ SheetsFindReplaceMobileController = __decorate([
|
|
|
952
940
|
__decorateParam(2, IRenderManagerService)
|
|
953
941
|
], SheetsFindReplaceMobileController);
|
|
954
942
|
|
|
955
|
-
|
|
956
|
-
//#region src/mobile-plugin.ts
|
|
943
|
+
// src/mobile-plugin.ts
|
|
957
944
|
let UniverSheetsFindReplaceMobileUIPlugin = class UniverSheetsFindReplaceMobileUIPlugin extends Plugin {
|
|
958
945
|
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
959
946
|
super();
|
|
@@ -983,8 +970,7 @@ UniverSheetsFindReplaceMobileUIPlugin = __decorate([
|
|
|
983
970
|
__decorateParam(2, IConfigService)
|
|
984
971
|
], UniverSheetsFindReplaceMobileUIPlugin);
|
|
985
972
|
|
|
986
|
-
|
|
987
|
-
//#region src/plugin.ts
|
|
973
|
+
// src/plugin.ts
|
|
988
974
|
let UniverSheetsFindReplacePlugin = class UniverSheetsFindReplacePlugin extends Plugin {
|
|
989
975
|
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
990
976
|
super();
|
|
@@ -1011,5 +997,4 @@ UniverSheetsFindReplacePlugin = __decorate([
|
|
|
1011
997
|
__decorateParam(2, IConfigService)
|
|
1012
998
|
], UniverSheetsFindReplacePlugin);
|
|
1013
999
|
|
|
1014
|
-
//#endregion
|
|
1015
1000
|
export { SheetReplaceCommand, SheetsFindReplaceController, UniverSheetsFindReplaceMobileUIPlugin, UniverSheetsFindReplacePlugin };
|
package/lib/facade.js
CHANGED
|
@@ -4,7 +4,7 @@ import { FRange } from "@univerjs/sheets/facade";
|
|
|
4
4
|
import { filter, firstValueFrom } from "rxjs";
|
|
5
5
|
import { FUniver } from "@univerjs/core/facade";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
|
|
8
8
|
function _typeof(o) {
|
|
9
9
|
"@babel/helpers - typeof";
|
|
10
10
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -14,8 +14,7 @@ function _typeof(o) {
|
|
|
14
14
|
}, _typeof(o);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
17
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
|
|
19
18
|
function toPrimitive(t, r) {
|
|
20
19
|
if ("object" != _typeof(t) || !t) return t;
|
|
21
20
|
var e = t[Symbol.toPrimitive];
|
|
@@ -27,15 +26,13 @@ function toPrimitive(t, r) {
|
|
|
27
26
|
return ("string" === r ? String : Number)(t);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
29
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
|
|
32
30
|
function toPropertyKey(t) {
|
|
33
31
|
var i = toPrimitive(t, "string");
|
|
34
32
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
35
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
|
|
39
36
|
function _defineProperty(e, r, t) {
|
|
40
37
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
41
38
|
value: t,
|
|
@@ -45,16 +42,14 @@ function _defineProperty(e, r, t) {
|
|
|
45
42
|
}) : e[r] = t, e;
|
|
46
43
|
}
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
45
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
|
|
50
46
|
function __decorateParam(paramIndex, decorator) {
|
|
51
47
|
return function(target, key) {
|
|
52
48
|
decorator(target, key, paramIndex);
|
|
53
49
|
};
|
|
54
50
|
}
|
|
55
51
|
|
|
56
|
-
|
|
57
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
52
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
|
|
58
53
|
function __decorate(decorators, target, key, desc) {
|
|
59
54
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
60
55
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -62,8 +57,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
62
57
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
63
58
|
}
|
|
64
59
|
|
|
65
|
-
|
|
66
|
-
//#region src/facade/f-text-finder.ts
|
|
60
|
+
// src/facade/f-text-finder.ts
|
|
67
61
|
let FTextFinder = class FTextFinder extends Disposable {
|
|
68
62
|
constructor(_initialState, _injector, _univerInstanceService, _findReplaceService) {
|
|
69
63
|
super();
|
|
@@ -172,8 +166,7 @@ FTextFinder = __decorate([
|
|
|
172
166
|
__decorateParam(3, IFindReplaceService)
|
|
173
167
|
], FTextFinder);
|
|
174
168
|
|
|
175
|
-
|
|
176
|
-
//#region src/facade/f-univer.ts
|
|
169
|
+
// src/facade/f-univer.ts
|
|
177
170
|
var FUniverSheetsFindReplaceMixin = class extends FUniver {
|
|
178
171
|
async createTextFinderAsync(text) {
|
|
179
172
|
const state = { findString: text };
|
|
@@ -184,5 +177,4 @@ var FUniverSheetsFindReplaceMixin = class extends FUniver {
|
|
|
184
177
|
};
|
|
185
178
|
FUniver.extend(FUniverSheetsFindReplaceMixin);
|
|
186
179
|
|
|
187
|
-
//#endregion
|
|
188
180
|
export { };
|
package/lib/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { CloseFindDialogOperation, FindBy, FindDirection, FindModel, FindScope,
|
|
|
5
5
|
import { ScrollToCellCommand, SetScrollRelativeCommand, SheetSkeletonManagerService, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, getCoordByCell, getSheetObject, getViewportByCell } from "@univerjs/sheets-ui";
|
|
6
6
|
import { Subject, debounceTime, filter, merge as merge$1, skip, throttleTime } from "rxjs";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// src/commands/commands/sheet-replace.command.ts
|
|
9
9
|
/**
|
|
10
10
|
* This command is used for the SheetFindReplaceController to deal with replacing, including undo redo.
|
|
11
11
|
*
|
|
@@ -41,8 +41,7 @@ function getReplaceAllResult(results, replacements) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
44
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
|
|
46
45
|
function _typeof(o) {
|
|
47
46
|
"@babel/helpers - typeof";
|
|
48
47
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -52,8 +51,7 @@ function _typeof(o) {
|
|
|
52
51
|
}, _typeof(o);
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
54
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
|
|
57
55
|
function toPrimitive(t, r) {
|
|
58
56
|
if ("object" != _typeof(t) || !t) return t;
|
|
59
57
|
var e = t[Symbol.toPrimitive];
|
|
@@ -65,15 +63,13 @@ function toPrimitive(t, r) {
|
|
|
65
63
|
return ("string" === r ? String : Number)(t);
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
|
|
69
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
66
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
|
|
70
67
|
function toPropertyKey(t) {
|
|
71
68
|
var i = toPrimitive(t, "string");
|
|
72
69
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
73
70
|
}
|
|
74
71
|
|
|
75
|
-
|
|
76
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
72
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
|
|
77
73
|
function _defineProperty(e, r, t) {
|
|
78
74
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
79
75
|
value: t,
|
|
@@ -83,8 +79,7 @@ function _defineProperty(e, r, t) {
|
|
|
83
79
|
}) : e[r] = t, e;
|
|
84
80
|
}
|
|
85
81
|
|
|
86
|
-
|
|
87
|
-
//#region src/views/shapes/find-replace-highlight.shape.ts
|
|
82
|
+
// src/views/shapes/find-replace-highlight.shape.ts
|
|
88
83
|
var SheetFindReplaceHighlightShape = class extends Shape {
|
|
89
84
|
constructor(key, props) {
|
|
90
85
|
super(key, props);
|
|
@@ -117,8 +112,7 @@ var SheetFindReplaceHighlightShape = class extends Shape {
|
|
|
117
112
|
}
|
|
118
113
|
};
|
|
119
114
|
|
|
120
|
-
|
|
121
|
-
//#region src/controllers/utils.ts
|
|
115
|
+
// src/controllers/utils.ts
|
|
122
116
|
function isSamePosition(range1, range2) {
|
|
123
117
|
return range1.startRow === range2.startRow && range1.startColumn === range2.startColumn;
|
|
124
118
|
}
|
|
@@ -160,16 +154,14 @@ function isSelectionSingleCell(selection, worksheet) {
|
|
|
160
154
|
else return range.endRow === range.startRow && range.endColumn === range.startColumn;
|
|
161
155
|
}
|
|
162
156
|
|
|
163
|
-
|
|
164
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
157
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
|
|
165
158
|
function __decorateParam(paramIndex, decorator) {
|
|
166
159
|
return function(target, key) {
|
|
167
160
|
decorator(target, key, paramIndex);
|
|
168
161
|
};
|
|
169
162
|
}
|
|
170
163
|
|
|
171
|
-
|
|
172
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
164
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
|
|
173
165
|
function __decorate(decorators, target, key, desc) {
|
|
174
166
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
175
167
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -177,8 +169,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
177
169
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
178
170
|
}
|
|
179
171
|
|
|
180
|
-
|
|
181
|
-
//#region src/controllers/sheet-find-replace.controller.ts
|
|
172
|
+
// src/controllers/sheet-find-replace.controller.ts
|
|
182
173
|
let SheetsFindReplaceController = class SheetsFindReplaceController extends Disposable {
|
|
183
174
|
constructor(_injector, _contextService, _findReplaceService, _commandService) {
|
|
184
175
|
super();
|
|
@@ -860,13 +851,11 @@ function extractPureValue(cell) {
|
|
|
860
851
|
return rawValue;
|
|
861
852
|
}
|
|
862
853
|
|
|
863
|
-
|
|
864
|
-
//#region package.json
|
|
854
|
+
// package.json
|
|
865
855
|
var name = "@univerjs/sheets-find-replace";
|
|
866
|
-
var version = "1.
|
|
856
|
+
var version = "1.4.0";
|
|
867
857
|
|
|
868
|
-
|
|
869
|
-
//#region src/config/config.ts
|
|
858
|
+
// src/config/config.ts
|
|
870
859
|
/**
|
|
871
860
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
872
861
|
*
|
|
@@ -886,8 +875,7 @@ const SHEETS_FIND_REPLACE_PLUGIN_CONFIG_KEY = "sheets-find-replace.config";
|
|
|
886
875
|
const configSymbol = Symbol(SHEETS_FIND_REPLACE_PLUGIN_CONFIG_KEY);
|
|
887
876
|
const defaultPluginConfig = {};
|
|
888
877
|
|
|
889
|
-
|
|
890
|
-
//#region src/controllers/mobile/sheet-find-replace-mobile.controller.ts
|
|
878
|
+
// src/controllers/mobile/sheet-find-replace-mobile.controller.ts
|
|
891
879
|
const MOBILE_FIND_REPLACE_BAR_SELECTOR = "[data-u-comp=\"mobile-find-replace-bar\"]";
|
|
892
880
|
const MOBILE_FIND_MATCH_SAFE_PADDING = 8;
|
|
893
881
|
function getMobileFindMatchScrollOffset(cellBottom, barTop, safePadding) {
|
|
@@ -952,8 +940,7 @@ SheetsFindReplaceMobileController = __decorate([
|
|
|
952
940
|
__decorateParam(2, IRenderManagerService)
|
|
953
941
|
], SheetsFindReplaceMobileController);
|
|
954
942
|
|
|
955
|
-
|
|
956
|
-
//#region src/mobile-plugin.ts
|
|
943
|
+
// src/mobile-plugin.ts
|
|
957
944
|
let UniverSheetsFindReplaceMobileUIPlugin = class UniverSheetsFindReplaceMobileUIPlugin extends Plugin {
|
|
958
945
|
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
959
946
|
super();
|
|
@@ -983,8 +970,7 @@ UniverSheetsFindReplaceMobileUIPlugin = __decorate([
|
|
|
983
970
|
__decorateParam(2, IConfigService)
|
|
984
971
|
], UniverSheetsFindReplaceMobileUIPlugin);
|
|
985
972
|
|
|
986
|
-
|
|
987
|
-
//#region src/plugin.ts
|
|
973
|
+
// src/plugin.ts
|
|
988
974
|
let UniverSheetsFindReplacePlugin = class UniverSheetsFindReplacePlugin extends Plugin {
|
|
989
975
|
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
990
976
|
super();
|
|
@@ -1011,5 +997,4 @@ UniverSheetsFindReplacePlugin = __decorate([
|
|
|
1011
997
|
__decorateParam(2, IConfigService)
|
|
1012
998
|
], UniverSheetsFindReplacePlugin);
|
|
1013
999
|
|
|
1014
|
-
//#endregion
|
|
1015
1000
|
export { SheetReplaceCommand, SheetsFindReplaceController, UniverSheetsFindReplaceMobileUIPlugin, UniverSheetsFindReplacePlugin };
|
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){super(),this._injector=e,this._contextService=t,this._findReplaceService=n,this._commandService=r,f(this,`_provider`,void 0),this._init(),this._initCommands()}dispose(){super.dispose(),this._findReplaceService.terminate(),this._provider.dispose()}_init(){let e=this._injector.createInstance(w);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._commandService.executeCommand(i.CloseFindDialogOperation.id).catch(()=>void 0)}))}_initCommands(){[s].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};S=x([b(0,(0,t.Inject)(t.Injector)),b(1,t.IContextService),b(2,i.IFindReplaceService),b(3,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`,/* @__PURE__ */ 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)}}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=()=>{let e=this._workbook.getActiveSheet();if(!e)return!1;let t=this._workbookSelections.getCurrentSelections();return(t==null?void 0:t.some(t=>!y(t,e)))??!1},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}=E(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??1)-1,endRow:i+(u??1)-1}}};o.push(e)}}return{results:o}}_findInSelections(e,t,n,r){let{findDirection:a}=n,o=a===i.FindDirection.ROW?h:g,s=/* @__PURE__ */ 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.getRenderUnitById(n);if(r==null)return;let{scene:i}=r,o=this._matches,s=this._themeService.getColorFromTheme(`yellow.400`),c=new t.ColorKit(s).toRgb(),l=this._workbook.getActiveSheet();if(!l)return;let u=l.getSheetId(),d=o.filter(e=>e.range.subUnitId===u).map((t,n)=>{let{startColumn:r,startRow:o,endColumn:s,endRow:u}=t.range.range,d=(0,a.getCoordByCell)(o,r,i,e),f=(0,a.getCoordByCell)(u,s,i,e),{startX:m,startY:h}=d,{endX:g,endY:_}=f,v=!0;for(let e=o;e<=u;e++)if(l.getRowRawVisible(e)){v=!1;break}let y=!0;for(let e=r;e<=s;e++)if(l.getColVisible(e)){y=!1;break}let b=v||y,x=y?2:g-m,S=v?2:_-h,C={left:m,top:h,color:c,width:x,height:S,evented:!1,inHiddenRange:b,zIndex:1e4};return new p(`find-highlight-${n}`,C)});i.addObjects(d),this._highlightShapes=d,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)}async _focusMatch(e){var t;let{subUnitId:r,range:i}=e.range;if(r!==((t=this._workbook.getActiveSheet())==null?void 0:t.getSheetId())){let e=this._workbook.getUnitId();await this._commandService.executeCommand(n.SetWorksheetActivateCommand.id,{unitId:e,subUnitId:r},{fromFindReplace:!0})}this._commandService.executeCommand(a.ScrollToCellCommand.id,{range:i},{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){if(!this._matches.length)return null;let t=(e==null?void 0:e.loop)??!1,n=(e==null?void 0:e.stayIfOnMatch)??!1,r=(e==null?void 0:e.noFocus)??!1,a=(e==null?void 0:e.ignoreSelection)??!1,o=this._findNextMatch(t,n,a);if(o){let[e,t]=o;return this._matchesPosition=t+1,this._activeHighlightIndex=this._query.findScope===i.FindScope.UNIT?this._matchesByWorksheet.get(e.range.subUnitId).findIndex(t=>t===e):t,r||this._focusMatch(e),this._updateCurrentHighlightShape(this._activeHighlightIndex),e}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}moveToPreviousMatch(e){if(!this._matches.length)return null;let t=(e==null?void 0:e.loop)??!1,n=(e==null?void 0:e.stayIfOnMatch)??!1,r=(e==null?void 0:e.noFocus)??!1,a=(e==null?void 0:e.ignoreSelection)??!1,o=this._findPreviousMatch(t,n,a);if(o){let[e,t]=o;return this._matchesPosition=t+1,this._activeHighlightIndex=this._query.findScope===i.FindScope.UNIT?this._matchesByWorksheet.get(e.range.subUnitId).findIndex(t=>t===e):t,r||this._focusMatch(e),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);return(n?(0,t.rotate)(r,i+1):r.slice(0,i+1)).findLast(e=>this._matchesByWorksheet.has(e))??null}_findNextWorksheetThatHasAMatch(e,n=!1){let r=this._workbook.getSheetOrders(),i=r.findIndex(t=>t===e);return(n?(0,t.rotate)(r,i):r.slice(i)).find(e=>this._matchesByWorksheet.has(e))??null}_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===-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(t.regexp.createLiteralRegExp(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(t.regexp.createLiteralRegExp(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);let w=class extends t.Disposable{constructor(e,t,n){super(),this._univerInstanceService=e,this._renderManagerService=t,this._injector=n,f(this,`capabilities`,{caseSensitive:!0,matchesTheWholeWord:!1,matchesTheWholeCell:!0,findDirection:!0,findScope:!0,findBy:!0}),f(this,`_findModelsByUnitId`,/* @__PURE__ */ new Map)}isSupported(e){return e.type===t.UniverInstanceType.UNIVER_SHEET}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.getRenderUnitById(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{...e,findString:t}}};w=x([b(0,t.IUniverInstanceService),b(1,r.IRenderManagerService),b(2,(0,t.Inject)(t.Injector))],w);let T={hit:!1,replaceable:!1,isFormula:!1,rawData:null};function E(e,t,n,r,a){let{findBy:o}=r,s=o===i.FindBy.FORMULA,c=e.getCellRaw(t,n);return T.rawData=c,c!=null&&c.f?(T.isFormula=!0,s?D({v:c.f},r)?(T.hit=!0,T.replaceable=!0,T):(T.hit=!1,T.replaceable=!1,T):(T.replaceable=!1,D(a,r)?T.hit=!0:T.hit=!1,T)):(T.isFormula=!1,D(a,r)?c?(T.hit=!0,T.replaceable=!0):(T.hit=!0,T.replaceable=!1):(T.hit=!1,T.replaceable=!1),T)}function D(e,t){let n=O(e);return n?t.matchesTheWholeCell?t.caseSensitive?n===t.findString:n.toLowerCase()===t.findString:t.caseSensitive?n.indexOf(t.findString)>-1:n.toLowerCase().indexOf(t.findString)>-1:!1}function O(e){var t;let n=(e==null||(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream)??(e==null?void 0:e.v);return typeof n==`number`?`${n}`:typeof n==`boolean`?n?`1`:`0`:n}var k=`@univerjs/sheets-find-replace`,A=`1.3.0`;let j=`sheets-find-replace.config`,M={};function N(e,t,n){return Math.max(0,e-t+n)}let P=class extends t.Disposable{constructor(e,n,r){super(),this._commandService=e,this._univerInstanceService=n,this._renderManagerService=r,f(this,`_pendingFrameId`,null),this.disposeWithMe(this._commandService.onCommandExecuted((e,n)=>{var r;if(e.id!==a.ScrollToCellCommand.id||(n==null?void 0:n.fromFindReplace)!==!0)return;let i=(r=e.params)==null?void 0:r.range;if(!i)return;let o=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),s=o==null?void 0:o.getActiveSheet();o&&s&&this._scheduleReveal(o.getUnitId(),s.getSheetId(),i.endRow,i.endColumn)}))}dispose(){this._pendingFrameId!==null&&(cancelAnimationFrame(this._pendingFrameId),this._pendingFrameId=null),super.dispose()}_scheduleReveal(e,t,n,r){this._pendingFrameId!==null&&cancelAnimationFrame(this._pendingFrameId),this._pendingFrameId=requestAnimationFrame(()=>{this._pendingFrameId=null,this._revealMatch(e,t,n,r)})}_revealMatch(e,n,i,o){let s=document.querySelector(`[data-u-comp="mobile-find-replace-bar"]`);if(!s)return;let c=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),l=c==null?void 0:c.getActiveSheet();if(!c||!l||c.getUnitId()!==e||l.getSheetId()!==n)return;let u=this._renderManagerService.getRenderUnitById(c.getUnitId()),d=(0,a.getSheetObject)(c,this._renderManagerService),f=u==null?void 0:u.with(a.SheetSkeletonManagerService).getSkeleton(l.getSheetId());if(!d||!f)return;let{scene:p,engine:m}=d,h=(0,a.getViewportByCell)(i,o,p,l);if(!h)return;let{endY:g}=(0,a.getCoordByCell)(i,o,p,f),{scaleY:_}=p.getAncestorScale(),v=p.getViewportScrollXY(h),y=N(m.getCanvasElement().getBoundingClientRect().top+(0,r.convertTransformToOffsetY)(g,_,v),s.getBoundingClientRect().top,8);y!==0&&this._commandService.executeCommand(a.SetScrollRelativeCommand.id,{offsetY:y}).catch(()=>void 0)}};P=x([b(0,t.ICommandService),b(1,t.IUniverInstanceService),b(2,r.IRenderManagerService)],P);let F=class extends t.Plugin{constructor(e=M,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},M,this._config);this._configService.setConfig(j,i)}onStarting(){[[S],[P]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(P)}onSteady(){this._injector.get(S)}};f(F,`pluginName`,`SHEET_FIND_REPLACE_PLUGIN`),f(F,`packageName`,k),f(F,`version`,A),f(F,`type`,t.UniverInstanceType.UNIVER_SHEET),F=x([(0,t.DependentOn)(r.UniverRenderEnginePlugin,n.UniverSheetsPlugin,i.UniverFindReplaceMobileUIPlugin,a.UniverSheetsMobileUIPlugin),b(1,(0,t.Inject)(t.Injector)),b(2,t.IConfigService)],F);let I=class extends t.Plugin{constructor(e=M,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},M,this._config);this._configService.setConfig(j,i)}onStarting(){[[S]].forEach(e=>this._injector.add(e))}onSteady(){this._injector.get(S)}};f(I,`pluginName`,`SHEET_FIND_REPLACE_PLUGIN`),f(I,`packageName`,k),f(I,`version`,A),f(I,`type`,t.UniverInstanceType.UNIVER_SHEET),I=x([(0,t.DependentOn)(r.UniverRenderEnginePlugin,n.UniverSheetsPlugin,i.UniverFindReplacePlugin,a.UniverSheetsUIPlugin),b(1,(0,t.Inject)(t.Injector)),b(2,t.IConfigService)],I),e.SheetReplaceCommand=s,Object.defineProperty(e,"SheetsFindReplaceController",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"UniverSheetsFindReplaceMobileUIPlugin",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"UniverSheetsFindReplacePlugin",{enumerable:!0,get:function(){return I}})});
|
|
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){super(),this._injector=e,this._contextService=t,this._findReplaceService=n,this._commandService=r,f(this,`_provider`,void 0),this._init(),this._initCommands()}dispose(){super.dispose(),this._findReplaceService.terminate(),this._provider.dispose()}_init(){let e=this._injector.createInstance(w);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._commandService.executeCommand(i.CloseFindDialogOperation.id).catch(()=>void 0)}))}_initCommands(){[s].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};S=x([b(0,(0,t.Inject)(t.Injector)),b(1,t.IContextService),b(2,i.IFindReplaceService),b(3,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`,/* @__PURE__ */ 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)}}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=()=>{let e=this._workbook.getActiveSheet();if(!e)return!1;let t=this._workbookSelections.getCurrentSelections();return(t==null?void 0:t.some(t=>!y(t,e)))??!1},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}=E(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??1)-1,endRow:i+(u??1)-1}}};o.push(e)}}return{results:o}}_findInSelections(e,t,n,r){let{findDirection:a}=n,o=a===i.FindDirection.ROW?h:g,s=/* @__PURE__ */ 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.getRenderUnitById(n);if(r==null)return;let{scene:i}=r,o=this._matches,s=this._themeService.getColorFromTheme(`yellow.400`),c=new t.ColorKit(s).toRgb(),l=this._workbook.getActiveSheet();if(!l)return;let u=l.getSheetId(),d=o.filter(e=>e.range.subUnitId===u).map((t,n)=>{let{startColumn:r,startRow:o,endColumn:s,endRow:u}=t.range.range,d=(0,a.getCoordByCell)(o,r,i,e),f=(0,a.getCoordByCell)(u,s,i,e),{startX:m,startY:h}=d,{endX:g,endY:_}=f,v=!0;for(let e=o;e<=u;e++)if(l.getRowRawVisible(e)){v=!1;break}let y=!0;for(let e=r;e<=s;e++)if(l.getColVisible(e)){y=!1;break}let b=v||y,x=y?2:g-m,S=v?2:_-h,C={left:m,top:h,color:c,width:x,height:S,evented:!1,inHiddenRange:b,zIndex:1e4};return new p(`find-highlight-${n}`,C)});i.addObjects(d),this._highlightShapes=d,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)}async _focusMatch(e){var t;let{subUnitId:r,range:i}=e.range;if(r!==((t=this._workbook.getActiveSheet())==null?void 0:t.getSheetId())){let e=this._workbook.getUnitId();await this._commandService.executeCommand(n.SetWorksheetActivateCommand.id,{unitId:e,subUnitId:r},{fromFindReplace:!0})}this._commandService.executeCommand(a.ScrollToCellCommand.id,{range:i},{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){if(!this._matches.length)return null;let t=(e==null?void 0:e.loop)??!1,n=(e==null?void 0:e.stayIfOnMatch)??!1,r=(e==null?void 0:e.noFocus)??!1,a=(e==null?void 0:e.ignoreSelection)??!1,o=this._findNextMatch(t,n,a);if(o){let[e,t]=o;return this._matchesPosition=t+1,this._activeHighlightIndex=this._query.findScope===i.FindScope.UNIT?this._matchesByWorksheet.get(e.range.subUnitId).findIndex(t=>t===e):t,r||this._focusMatch(e),this._updateCurrentHighlightShape(this._activeHighlightIndex),e}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}moveToPreviousMatch(e){if(!this._matches.length)return null;let t=(e==null?void 0:e.loop)??!1,n=(e==null?void 0:e.stayIfOnMatch)??!1,r=(e==null?void 0:e.noFocus)??!1,a=(e==null?void 0:e.ignoreSelection)??!1,o=this._findPreviousMatch(t,n,a);if(o){let[e,t]=o;return this._matchesPosition=t+1,this._activeHighlightIndex=this._query.findScope===i.FindScope.UNIT?this._matchesByWorksheet.get(e.range.subUnitId).findIndex(t=>t===e):t,r||this._focusMatch(e),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);return(n?(0,t.rotate)(r,i+1):r.slice(0,i+1)).findLast(e=>this._matchesByWorksheet.has(e))??null}_findNextWorksheetThatHasAMatch(e,n=!1){let r=this._workbook.getSheetOrders(),i=r.findIndex(t=>t===e);return(n?(0,t.rotate)(r,i):r.slice(i)).find(e=>this._matchesByWorksheet.has(e))??null}_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===-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(t.regexp.createLiteralRegExp(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(t.regexp.createLiteralRegExp(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);let w=class extends t.Disposable{constructor(e,t,n){super(),this._univerInstanceService=e,this._renderManagerService=t,this._injector=n,f(this,`capabilities`,{caseSensitive:!0,matchesTheWholeWord:!1,matchesTheWholeCell:!0,findDirection:!0,findScope:!0,findBy:!0}),f(this,`_findModelsByUnitId`,/* @__PURE__ */ new Map)}isSupported(e){return e.type===t.UniverInstanceType.UNIVER_SHEET}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.getRenderUnitById(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{...e,findString:t}}};w=x([b(0,t.IUniverInstanceService),b(1,r.IRenderManagerService),b(2,(0,t.Inject)(t.Injector))],w);let T={hit:!1,replaceable:!1,isFormula:!1,rawData:null};function E(e,t,n,r,a){let{findBy:o}=r,s=o===i.FindBy.FORMULA,c=e.getCellRaw(t,n);return T.rawData=c,c!=null&&c.f?(T.isFormula=!0,s?D({v:c.f},r)?(T.hit=!0,T.replaceable=!0,T):(T.hit=!1,T.replaceable=!1,T):(T.replaceable=!1,D(a,r)?T.hit=!0:T.hit=!1,T)):(T.isFormula=!1,D(a,r)?c?(T.hit=!0,T.replaceable=!0):(T.hit=!0,T.replaceable=!1):(T.hit=!1,T.replaceable=!1),T)}function D(e,t){let n=O(e);return n?t.matchesTheWholeCell?t.caseSensitive?n===t.findString:n.toLowerCase()===t.findString:t.caseSensitive?n.indexOf(t.findString)>-1:n.toLowerCase().indexOf(t.findString)>-1:!1}function O(e){var t;let n=(e==null||(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream)??(e==null?void 0:e.v);return typeof n==`number`?`${n}`:typeof n==`boolean`?n?`1`:`0`:n}var k=`@univerjs/sheets-find-replace`,A=`1.4.0`;let j=`sheets-find-replace.config`,M={};function N(e,t,n){return Math.max(0,e-t+n)}let P=class extends t.Disposable{constructor(e,n,r){super(),this._commandService=e,this._univerInstanceService=n,this._renderManagerService=r,f(this,`_pendingFrameId`,null),this.disposeWithMe(this._commandService.onCommandExecuted((e,n)=>{var r;if(e.id!==a.ScrollToCellCommand.id||(n==null?void 0:n.fromFindReplace)!==!0)return;let i=(r=e.params)==null?void 0:r.range;if(!i)return;let o=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),s=o==null?void 0:o.getActiveSheet();o&&s&&this._scheduleReveal(o.getUnitId(),s.getSheetId(),i.endRow,i.endColumn)}))}dispose(){this._pendingFrameId!==null&&(cancelAnimationFrame(this._pendingFrameId),this._pendingFrameId=null),super.dispose()}_scheduleReveal(e,t,n,r){this._pendingFrameId!==null&&cancelAnimationFrame(this._pendingFrameId),this._pendingFrameId=requestAnimationFrame(()=>{this._pendingFrameId=null,this._revealMatch(e,t,n,r)})}_revealMatch(e,n,i,o){let s=document.querySelector(`[data-u-comp="mobile-find-replace-bar"]`);if(!s)return;let c=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),l=c==null?void 0:c.getActiveSheet();if(!c||!l||c.getUnitId()!==e||l.getSheetId()!==n)return;let u=this._renderManagerService.getRenderUnitById(c.getUnitId()),d=(0,a.getSheetObject)(c,this._renderManagerService),f=u==null?void 0:u.with(a.SheetSkeletonManagerService).getSkeleton(l.getSheetId());if(!d||!f)return;let{scene:p,engine:m}=d,h=(0,a.getViewportByCell)(i,o,p,l);if(!h)return;let{endY:g}=(0,a.getCoordByCell)(i,o,p,f),{scaleY:_}=p.getAncestorScale(),v=p.getViewportScrollXY(h),y=N(m.getCanvasElement().getBoundingClientRect().top+(0,r.convertTransformToOffsetY)(g,_,v),s.getBoundingClientRect().top,8);y!==0&&this._commandService.executeCommand(a.SetScrollRelativeCommand.id,{offsetY:y}).catch(()=>void 0)}};P=x([b(0,t.ICommandService),b(1,t.IUniverInstanceService),b(2,r.IRenderManagerService)],P);let F=class extends t.Plugin{constructor(e=M,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},M,this._config);this._configService.setConfig(j,i)}onStarting(){[[S],[P]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(P)}onSteady(){this._injector.get(S)}};f(F,`pluginName`,`SHEET_FIND_REPLACE_PLUGIN`),f(F,`packageName`,k),f(F,`version`,A),f(F,`type`,t.UniverInstanceType.UNIVER_SHEET),F=x([(0,t.DependentOn)(r.UniverRenderEnginePlugin,n.UniverSheetsPlugin,i.UniverFindReplaceMobileUIPlugin,a.UniverSheetsMobileUIPlugin),b(1,(0,t.Inject)(t.Injector)),b(2,t.IConfigService)],F);let I=class extends t.Plugin{constructor(e=M,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},M,this._config);this._configService.setConfig(j,i)}onStarting(){[[S]].forEach(e=>this._injector.add(e))}onSteady(){this._injector.get(S)}};f(I,`pluginName`,`SHEET_FIND_REPLACE_PLUGIN`),f(I,`packageName`,k),f(I,`version`,A),f(I,`type`,t.UniverInstanceType.UNIVER_SHEET),I=x([(0,t.DependentOn)(r.UniverRenderEnginePlugin,n.UniverSheetsPlugin,i.UniverFindReplacePlugin,a.UniverSheetsUIPlugin),b(1,(0,t.Inject)(t.Injector)),b(2,t.IConfigService)],I),e.SheetReplaceCommand=s,Object.defineProperty(e,"SheetsFindReplaceController",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"UniverSheetsFindReplaceMobileUIPlugin",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"UniverSheetsFindReplacePlugin",{enumerable:!0,get:function(){return I}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-find-replace",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Find and replace integration for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -62,25 +62,25 @@
|
|
|
62
62
|
"rxjs": ">=7.0.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@univerjs/core": "1.
|
|
66
|
-
"@univerjs/engine-render": "1.
|
|
67
|
-
"@univerjs/find-replace": "1.
|
|
68
|
-
"@univerjs/sheets": "1.
|
|
69
|
-
"@univerjs/sheets-ui": "1.
|
|
65
|
+
"@univerjs/core": "1.4.0",
|
|
66
|
+
"@univerjs/engine-render": "1.4.0",
|
|
67
|
+
"@univerjs/find-replace": "1.4.0",
|
|
68
|
+
"@univerjs/sheets": "1.4.0",
|
|
69
|
+
"@univerjs/sheets-ui": "1.4.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@univerjs-infra/shared": "1.
|
|
72
|
+
"@univerjs-infra/shared": "1.4.0",
|
|
73
73
|
"rxjs": "7.8.2",
|
|
74
|
-
"
|
|
75
|
-
"vitest": "^5.0.
|
|
74
|
+
"tsrs": "0.20.1-ts7.1.0-beta",
|
|
75
|
+
"vitest": "^5.0.5"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"test": "vitest run",
|
|
79
79
|
"test:watch": "vitest",
|
|
80
80
|
"coverage": "vitest run --coverage",
|
|
81
|
-
"typecheck": "
|
|
81
|
+
"typecheck": "tsrs --noEmit",
|
|
82
82
|
"build:bundle": "univer-cli build",
|
|
83
|
-
"build:types": "
|
|
83
|
+
"build:types": "tsrs -p tsconfig.node.json",
|
|
84
84
|
"build": "pnpm run build:bundle && pnpm run build:types"
|
|
85
85
|
},
|
|
86
86
|
"module": "./lib/es/index.js"
|