@univerjs/sheets-find-replace 1.0.0-alpha.7 → 1.0.0-beta.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 -8
- package/lib/cjs/index.js +40 -32
- package/lib/es/facade.js +8 -8
- package/lib/es/index.js +42 -34
- package/lib/facade.js +8 -8
- package/lib/index.js +42 -34
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
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
|
-
//#region \0@oxc-project+runtime@0.
|
|
7
|
+
//#region \0@oxc-project+runtime@0.140.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) {
|
|
@@ -15,7 +15,7 @@ function _typeof(o) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
|
-
//#region \0@oxc-project+runtime@0.
|
|
18
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
19
19
|
function toPrimitive(t, r) {
|
|
20
20
|
if ("object" != _typeof(t) || !t) return t;
|
|
21
21
|
var e = t[Symbol.toPrimitive];
|
|
@@ -28,14 +28,14 @@ function toPrimitive(t, r) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
//#endregion
|
|
31
|
-
//#region \0@oxc-project+runtime@0.
|
|
31
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
32
32
|
function toPropertyKey(t) {
|
|
33
33
|
var i = toPrimitive(t, "string");
|
|
34
34
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
//#endregion
|
|
38
|
-
//#region \0@oxc-project+runtime@0.
|
|
38
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
39
39
|
function _defineProperty(e, r, t) {
|
|
40
40
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
41
41
|
value: t,
|
|
@@ -46,7 +46,7 @@ function _defineProperty(e, r, t) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
|
-
//#region \0@oxc-project+runtime@0.
|
|
49
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
50
50
|
function __decorateParam(paramIndex, decorator) {
|
|
51
51
|
return function(target, key) {
|
|
52
52
|
decorator(target, key, paramIndex);
|
|
@@ -54,7 +54,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
//#endregion
|
|
57
|
-
//#region \0@oxc-project+runtime@0.
|
|
57
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
58
58
|
function __decorate(decorators, target, key, desc) {
|
|
59
59
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
60
60
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -135,12 +135,12 @@ let FTextFinder = class FTextFinder extends _univerjs_core.Disposable {
|
|
|
135
135
|
return this;
|
|
136
136
|
}
|
|
137
137
|
async replaceAllWithAsync(replaceText) {
|
|
138
|
-
var _await$this$_model$re,
|
|
138
|
+
var _await$this$_model$re, _this$_model4;
|
|
139
139
|
await this._state.changeState({
|
|
140
140
|
replaceRevealed: true,
|
|
141
141
|
replaceString: replaceText
|
|
142
142
|
});
|
|
143
|
-
const res = (_await$this$_model$re =
|
|
143
|
+
const res = ((_await$this$_model$re = await ((_this$_model4 = this._model) === null || _this$_model4 === void 0 ? void 0 : _this$_model4.replaceAll())) === null || _await$this$_model$re === void 0 ? void 0 : _await$this$_model$re.success) ?? 0;
|
|
144
144
|
this._state.changeState({ replaceRevealed: false });
|
|
145
145
|
return res;
|
|
146
146
|
}
|
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.
|
|
46
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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.
|
|
57
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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.
|
|
70
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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.
|
|
77
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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.
|
|
165
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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.
|
|
173
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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);
|
|
@@ -364,11 +364,10 @@ let SheetFindModel = class SheetFindModel extends _univerjs_find_replace.FindMod
|
|
|
364
364
|
findInActiveWorksheet(query) {
|
|
365
365
|
const unitId = this._workbook.getUnitId();
|
|
366
366
|
const checkShouldFindInSelections = () => {
|
|
367
|
-
var _currentSelections$so;
|
|
368
367
|
const currentWorksheet = this._workbook.getActiveSheet();
|
|
369
368
|
if (!currentWorksheet) return false;
|
|
370
369
|
const currentSelections = this._workbookSelections.getCurrentSelections();
|
|
371
|
-
return (
|
|
370
|
+
return (currentSelections === null || currentSelections === void 0 ? void 0 : currentSelections.some((selection) => !isSelectionSingleCell(selection, currentWorksheet))) ?? false;
|
|
372
371
|
};
|
|
373
372
|
let complete;
|
|
374
373
|
let firstSearch = true;
|
|
@@ -423,8 +422,8 @@ let SheetFindModel = class SheetFindModel extends _univerjs_find_replace.FindMod
|
|
|
423
422
|
range: {
|
|
424
423
|
startRow: row,
|
|
425
424
|
startColumn: col,
|
|
426
|
-
endColumn: col + (colSpan
|
|
427
|
-
endRow: row + (rowSpan
|
|
425
|
+
endColumn: col + (colSpan ?? 1) - 1,
|
|
426
|
+
endRow: row + (rowSpan ?? 1) - 1
|
|
428
427
|
}
|
|
429
428
|
}
|
|
430
429
|
};
|
|
@@ -472,7 +471,7 @@ let SheetFindModel = class SheetFindModel extends _univerjs_find_replace.FindMod
|
|
|
472
471
|
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
473
472
|
if (!skeleton) return;
|
|
474
473
|
const unitId = this._workbook.getUnitId();
|
|
475
|
-
const currentRender = this._renderManagerService.
|
|
474
|
+
const currentRender = this._renderManagerService.getRenderUnitById(unitId);
|
|
476
475
|
if (currentRender == null) return;
|
|
477
476
|
const { scene } = currentRender;
|
|
478
477
|
const matches = this._matches;
|
|
@@ -497,12 +496,14 @@ let SheetFindModel = class SheetFindModel extends _univerjs_find_replace.FindMod
|
|
|
497
496
|
break;
|
|
498
497
|
}
|
|
499
498
|
const inHiddenRange = isAllRowHidden || isAllColHidden;
|
|
499
|
+
const width = isAllColHidden ? 2 : endX - startX;
|
|
500
|
+
const height = isAllRowHidden ? 2 : endY - startY;
|
|
500
501
|
const props = {
|
|
501
502
|
left: startX,
|
|
502
503
|
top: startY,
|
|
503
504
|
color,
|
|
504
|
-
width
|
|
505
|
-
height
|
|
505
|
+
width,
|
|
506
|
+
height,
|
|
506
507
|
evented: false,
|
|
507
508
|
inHiddenRange,
|
|
508
509
|
zIndex: FIND_REPLACE_Z_INDEX
|
|
@@ -551,12 +552,11 @@ let SheetFindModel = class SheetFindModel extends _univerjs_find_replace.FindMod
|
|
|
551
552
|
return index > -1 ? index + 1 : 0;
|
|
552
553
|
}
|
|
553
554
|
moveToNextMatch(params) {
|
|
554
|
-
var _params$loop, _params$stayIfOnMatch, _params$noFocus, _params$ignoreSelecti;
|
|
555
555
|
if (!this._matches.length) return null;
|
|
556
|
-
const loop = (
|
|
557
|
-
const stayIfOnMatch = (
|
|
558
|
-
const noFocus = (
|
|
559
|
-
const ignoreSelection = (
|
|
556
|
+
const loop = (params === null || params === void 0 ? void 0 : params.loop) ?? false;
|
|
557
|
+
const stayIfOnMatch = (params === null || params === void 0 ? void 0 : params.stayIfOnMatch) ?? false;
|
|
558
|
+
const noFocus = (params === null || params === void 0 ? void 0 : params.noFocus) ?? false;
|
|
559
|
+
const ignoreSelection = (params === null || params === void 0 ? void 0 : params.ignoreSelection) ?? false;
|
|
560
560
|
const matchToMove = this._findNextMatch(loop, stayIfOnMatch, ignoreSelection);
|
|
561
561
|
if (matchToMove) {
|
|
562
562
|
const [match, index] = matchToMove;
|
|
@@ -572,12 +572,11 @@ let SheetFindModel = class SheetFindModel extends _univerjs_find_replace.FindMod
|
|
|
572
572
|
return null;
|
|
573
573
|
}
|
|
574
574
|
moveToPreviousMatch(params) {
|
|
575
|
-
var _params$loop2, _params$stayIfOnMatch2, _params$noFocus2, _params$ignoreSelecti2;
|
|
576
575
|
if (!this._matches.length) return null;
|
|
577
|
-
const loop = (
|
|
578
|
-
const stayIfOnMatch = (
|
|
579
|
-
const noFocus = (
|
|
580
|
-
const ignoreSelection = (
|
|
576
|
+
const loop = (params === null || params === void 0 ? void 0 : params.loop) ?? false;
|
|
577
|
+
const stayIfOnMatch = (params === null || params === void 0 ? void 0 : params.stayIfOnMatch) ?? false;
|
|
578
|
+
const noFocus = (params === null || params === void 0 ? void 0 : params.noFocus) ?? false;
|
|
579
|
+
const ignoreSelection = (params === null || params === void 0 ? void 0 : params.ignoreSelection) ?? false;
|
|
581
580
|
const matchToMove = this._findPreviousMatch(loop, stayIfOnMatch, ignoreSelection);
|
|
582
581
|
if (matchToMove) {
|
|
583
582
|
const [match, index] = matchToMove;
|
|
@@ -638,14 +637,12 @@ let SheetFindModel = class SheetFindModel extends _univerjs_find_replace.FindMod
|
|
|
638
637
|
_findPreviousWorksheetThatHasAMatch(currentWorksheet, loop = false) {
|
|
639
638
|
const rawWorksheetsInOrder = this._workbook.getSheetOrders();
|
|
640
639
|
const currentSheetIndex = rawWorksheetsInOrder.findIndex((sheet) => sheet === currentWorksheet);
|
|
641
|
-
|
|
642
|
-
return first !== null && first !== void 0 ? first : null;
|
|
640
|
+
return (loop ? (0, _univerjs_core.rotate)(rawWorksheetsInOrder, currentSheetIndex + 1) : rawWorksheetsInOrder.slice(0, currentSheetIndex + 1)).findLast((worksheet) => this._matchesByWorksheet.has(worksheet)) ?? null;
|
|
643
641
|
}
|
|
644
642
|
_findNextWorksheetThatHasAMatch(currentWorksheet, loop = false) {
|
|
645
643
|
const rawWorksheetsInOrder = this._workbook.getSheetOrders();
|
|
646
644
|
const currentSheetIndex = rawWorksheetsInOrder.findIndex((sheet) => sheet === currentWorksheet);
|
|
647
|
-
|
|
648
|
-
return first !== null && first !== void 0 ? first : null;
|
|
645
|
+
return (loop ? (0, _univerjs_core.rotate)(rawWorksheetsInOrder, currentSheetIndex) : rawWorksheetsInOrder.slice(currentSheetIndex)).find((worksheet) => this._matchesByWorksheet.has(worksheet)) ?? null;
|
|
649
646
|
}
|
|
650
647
|
_findNextMatchByRange(matches, range, stayIfOnMatch = false) {
|
|
651
648
|
const findByRow = this._query.findDirection === _univerjs_find_replace.FindDirection.ROW;
|
|
@@ -753,14 +750,25 @@ let SheetsFindReplaceProvider = class SheetsFindReplaceProvider extends _univerj
|
|
|
753
750
|
this._univerInstanceService = _univerInstanceService;
|
|
754
751
|
this._renderManagerService = _renderManagerService;
|
|
755
752
|
this._injector = _injector;
|
|
753
|
+
_defineProperty(this, "capabilities", {
|
|
754
|
+
caseSensitive: true,
|
|
755
|
+
matchesTheWholeWord: false,
|
|
756
|
+
matchesTheWholeCell: true,
|
|
757
|
+
findDirection: true,
|
|
758
|
+
findScope: true,
|
|
759
|
+
findBy: true
|
|
760
|
+
});
|
|
756
761
|
_defineProperty(this, "_findModelsByUnitId", /* @__PURE__ */ new Map());
|
|
757
762
|
}
|
|
763
|
+
isSupported(unit) {
|
|
764
|
+
return unit.type === _univerjs_core.UniverInstanceType.UNIVER_SHEET;
|
|
765
|
+
}
|
|
758
766
|
async find(query) {
|
|
759
767
|
this._terminate();
|
|
760
768
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
761
769
|
if (!workbook) return [];
|
|
762
770
|
const parsedQuery = this._preprocessQuery(query);
|
|
763
|
-
const skeletonManagerService = this._renderManagerService.
|
|
771
|
+
const skeletonManagerService = this._renderManagerService.getRenderUnitById(workbook.getUnitId()).with(_univerjs_sheets_ui.SheetSkeletonManagerService);
|
|
764
772
|
const sheetFind = this._injector.createInstance(SheetFindModel, workbook, skeletonManagerService);
|
|
765
773
|
this._findModelsByUnitId.set(workbook.getUnitId(), sheetFind);
|
|
766
774
|
sheetFind.start(parsedQuery);
|
|
@@ -851,8 +859,8 @@ function matchCellData(cellData, query) {
|
|
|
851
859
|
return query.caseSensitive ? value.indexOf(query.findString) > -1 : value.toLowerCase().indexOf(query.findString) > -1;
|
|
852
860
|
}
|
|
853
861
|
function extractPureValue(cell) {
|
|
854
|
-
var _cell$p
|
|
855
|
-
const rawValue = (
|
|
862
|
+
var _cell$p;
|
|
863
|
+
const rawValue = (cell === null || cell === void 0 || (_cell$p = cell.p) === null || _cell$p === void 0 || (_cell$p = _cell$p.body) === null || _cell$p === void 0 ? void 0 : _cell$p.dataStream) ?? (cell === null || cell === void 0 ? void 0 : cell.v);
|
|
856
864
|
if (typeof rawValue === "number") return `${rawValue}`;
|
|
857
865
|
if (typeof rawValue === "boolean") return rawValue ? "1" : "0";
|
|
858
866
|
return rawValue;
|
|
@@ -868,7 +876,7 @@ function trimLeadingTrailingWhitespace(value) {
|
|
|
868
876
|
//#endregion
|
|
869
877
|
//#region package.json
|
|
870
878
|
var name = "@univerjs/sheets-find-replace";
|
|
871
|
-
var version = "1.0.0-
|
|
879
|
+
var version = "1.0.0-beta.0";
|
|
872
880
|
|
|
873
881
|
//#endregion
|
|
874
882
|
//#region src/config/config.ts
|
|
@@ -914,7 +922,7 @@ _defineProperty(UniverSheetsFindReplacePlugin, "packageName", name);
|
|
|
914
922
|
_defineProperty(UniverSheetsFindReplacePlugin, "version", version);
|
|
915
923
|
_defineProperty(UniverSheetsFindReplacePlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
916
924
|
UniverSheetsFindReplacePlugin = __decorate([
|
|
917
|
-
(0, _univerjs_core.DependentOn)(
|
|
925
|
+
(0, _univerjs_core.DependentOn)(_univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_find_replace.UniverFindReplacePlugin, _univerjs_sheets_ui.UniverSheetsUIPlugin),
|
|
918
926
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
919
927
|
__decorateParam(2, _univerjs_core.IConfigService)
|
|
920
928
|
], UniverSheetsFindReplacePlugin);
|
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
|
-
//#region \0@oxc-project+runtime@0.
|
|
7
|
+
//#region \0@oxc-project+runtime@0.140.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) {
|
|
@@ -15,7 +15,7 @@ function _typeof(o) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
|
-
//#region \0@oxc-project+runtime@0.
|
|
18
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
19
19
|
function toPrimitive(t, r) {
|
|
20
20
|
if ("object" != _typeof(t) || !t) return t;
|
|
21
21
|
var e = t[Symbol.toPrimitive];
|
|
@@ -28,14 +28,14 @@ function toPrimitive(t, r) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
//#endregion
|
|
31
|
-
//#region \0@oxc-project+runtime@0.
|
|
31
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
32
32
|
function toPropertyKey(t) {
|
|
33
33
|
var i = toPrimitive(t, "string");
|
|
34
34
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
//#endregion
|
|
38
|
-
//#region \0@oxc-project+runtime@0.
|
|
38
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
39
39
|
function _defineProperty(e, r, t) {
|
|
40
40
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
41
41
|
value: t,
|
|
@@ -46,7 +46,7 @@ function _defineProperty(e, r, t) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
|
-
//#region \0@oxc-project+runtime@0.
|
|
49
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
50
50
|
function __decorateParam(paramIndex, decorator) {
|
|
51
51
|
return function(target, key) {
|
|
52
52
|
decorator(target, key, paramIndex);
|
|
@@ -54,7 +54,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
//#endregion
|
|
57
|
-
//#region \0@oxc-project+runtime@0.
|
|
57
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
58
58
|
function __decorate(decorators, target, key, desc) {
|
|
59
59
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
60
60
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -135,12 +135,12 @@ let FTextFinder = class FTextFinder extends Disposable {
|
|
|
135
135
|
return this;
|
|
136
136
|
}
|
|
137
137
|
async replaceAllWithAsync(replaceText) {
|
|
138
|
-
var _await$this$_model$re,
|
|
138
|
+
var _await$this$_model$re, _this$_model4;
|
|
139
139
|
await this._state.changeState({
|
|
140
140
|
replaceRevealed: true,
|
|
141
141
|
replaceString: replaceText
|
|
142
142
|
});
|
|
143
|
-
const res = (_await$this$_model$re =
|
|
143
|
+
const res = ((_await$this$_model$re = await ((_this$_model4 = this._model) === null || _this$_model4 === void 0 ? void 0 : _this$_model4.replaceAll())) === null || _await$this$_model$re === void 0 ? void 0 : _await$this$_model$re.success) ?? 0;
|
|
144
144
|
this._state.changeState({ replaceRevealed: false });
|
|
145
145
|
return res;
|
|
146
146
|
}
|
package/lib/es/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ColorKit, CommandType, DependentOn, Disposable, EDITOR_ACTIVATED, ICommandService, IConfigService, IContextService, IUndoRedoService, IUniverInstanceService, Inject, Injector, ObjectMatrix, Plugin, Rectangle, ThemeService, Tools, UniverInstanceType, fromCallback, groupBy, merge, regexp, replaceInDocumentBody, rotate } from "@univerjs/core";
|
|
2
2
|
import { SelectRangeCommand, SetRangeValuesCommand, SetSelectionsOperation, SetWorksheetActivateCommand, SetWorksheetActiveOperation, SheetsSelectionsService, UniverSheetsPlugin } from "@univerjs/sheets";
|
|
3
|
-
import { IRenderManagerService, RENDER_RAW_FORMULA_KEY, Rect, Shape } from "@univerjs/engine-render";
|
|
3
|
+
import { IRenderManagerService, RENDER_RAW_FORMULA_KEY, Rect, Shape, UniverRenderEnginePlugin } from "@univerjs/engine-render";
|
|
4
4
|
import { FindBy, FindDirection, FindModel, FindReplaceController, FindScope, IFindReplaceService, UniverFindReplacePlugin } from "@univerjs/find-replace";
|
|
5
|
-
import { ScrollToCellCommand, SheetSkeletonManagerService, getCoordByCell, getSheetObject } from "@univerjs/sheets-ui";
|
|
5
|
+
import { ScrollToCellCommand, SheetSkeletonManagerService, UniverSheetsUIPlugin, getCoordByCell, getSheetObject } from "@univerjs/sheets-ui";
|
|
6
6
|
import { Subject, debounceTime, filter, merge as merge$1, skip, throttleTime } from "rxjs";
|
|
7
7
|
|
|
8
8
|
//#region src/commands/commands/sheet-replace.command.ts
|
|
@@ -42,7 +42,7 @@ function getReplaceAllResult(results, replacements) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
//#endregion
|
|
45
|
-
//#region \0@oxc-project+runtime@0.
|
|
45
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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.
|
|
56
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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.
|
|
69
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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.
|
|
76
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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.
|
|
164
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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.
|
|
172
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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);
|
|
@@ -363,11 +363,10 @@ let SheetFindModel = class SheetFindModel extends FindModel {
|
|
|
363
363
|
findInActiveWorksheet(query) {
|
|
364
364
|
const unitId = this._workbook.getUnitId();
|
|
365
365
|
const checkShouldFindInSelections = () => {
|
|
366
|
-
var _currentSelections$so;
|
|
367
366
|
const currentWorksheet = this._workbook.getActiveSheet();
|
|
368
367
|
if (!currentWorksheet) return false;
|
|
369
368
|
const currentSelections = this._workbookSelections.getCurrentSelections();
|
|
370
|
-
return (
|
|
369
|
+
return (currentSelections === null || currentSelections === void 0 ? void 0 : currentSelections.some((selection) => !isSelectionSingleCell(selection, currentWorksheet))) ?? false;
|
|
371
370
|
};
|
|
372
371
|
let complete;
|
|
373
372
|
let firstSearch = true;
|
|
@@ -422,8 +421,8 @@ let SheetFindModel = class SheetFindModel extends FindModel {
|
|
|
422
421
|
range: {
|
|
423
422
|
startRow: row,
|
|
424
423
|
startColumn: col,
|
|
425
|
-
endColumn: col + (colSpan
|
|
426
|
-
endRow: row + (rowSpan
|
|
424
|
+
endColumn: col + (colSpan ?? 1) - 1,
|
|
425
|
+
endRow: row + (rowSpan ?? 1) - 1
|
|
427
426
|
}
|
|
428
427
|
}
|
|
429
428
|
};
|
|
@@ -471,7 +470,7 @@ let SheetFindModel = class SheetFindModel extends FindModel {
|
|
|
471
470
|
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
472
471
|
if (!skeleton) return;
|
|
473
472
|
const unitId = this._workbook.getUnitId();
|
|
474
|
-
const currentRender = this._renderManagerService.
|
|
473
|
+
const currentRender = this._renderManagerService.getRenderUnitById(unitId);
|
|
475
474
|
if (currentRender == null) return;
|
|
476
475
|
const { scene } = currentRender;
|
|
477
476
|
const matches = this._matches;
|
|
@@ -496,12 +495,14 @@ let SheetFindModel = class SheetFindModel extends FindModel {
|
|
|
496
495
|
break;
|
|
497
496
|
}
|
|
498
497
|
const inHiddenRange = isAllRowHidden || isAllColHidden;
|
|
498
|
+
const width = isAllColHidden ? 2 : endX - startX;
|
|
499
|
+
const height = isAllRowHidden ? 2 : endY - startY;
|
|
499
500
|
const props = {
|
|
500
501
|
left: startX,
|
|
501
502
|
top: startY,
|
|
502
503
|
color,
|
|
503
|
-
width
|
|
504
|
-
height
|
|
504
|
+
width,
|
|
505
|
+
height,
|
|
505
506
|
evented: false,
|
|
506
507
|
inHiddenRange,
|
|
507
508
|
zIndex: FIND_REPLACE_Z_INDEX
|
|
@@ -550,12 +551,11 @@ let SheetFindModel = class SheetFindModel extends FindModel {
|
|
|
550
551
|
return index > -1 ? index + 1 : 0;
|
|
551
552
|
}
|
|
552
553
|
moveToNextMatch(params) {
|
|
553
|
-
var _params$loop, _params$stayIfOnMatch, _params$noFocus, _params$ignoreSelecti;
|
|
554
554
|
if (!this._matches.length) return null;
|
|
555
|
-
const loop = (
|
|
556
|
-
const stayIfOnMatch = (
|
|
557
|
-
const noFocus = (
|
|
558
|
-
const ignoreSelection = (
|
|
555
|
+
const loop = (params === null || params === void 0 ? void 0 : params.loop) ?? false;
|
|
556
|
+
const stayIfOnMatch = (params === null || params === void 0 ? void 0 : params.stayIfOnMatch) ?? false;
|
|
557
|
+
const noFocus = (params === null || params === void 0 ? void 0 : params.noFocus) ?? false;
|
|
558
|
+
const ignoreSelection = (params === null || params === void 0 ? void 0 : params.ignoreSelection) ?? false;
|
|
559
559
|
const matchToMove = this._findNextMatch(loop, stayIfOnMatch, ignoreSelection);
|
|
560
560
|
if (matchToMove) {
|
|
561
561
|
const [match, index] = matchToMove;
|
|
@@ -571,12 +571,11 @@ let SheetFindModel = class SheetFindModel extends FindModel {
|
|
|
571
571
|
return null;
|
|
572
572
|
}
|
|
573
573
|
moveToPreviousMatch(params) {
|
|
574
|
-
var _params$loop2, _params$stayIfOnMatch2, _params$noFocus2, _params$ignoreSelecti2;
|
|
575
574
|
if (!this._matches.length) return null;
|
|
576
|
-
const loop = (
|
|
577
|
-
const stayIfOnMatch = (
|
|
578
|
-
const noFocus = (
|
|
579
|
-
const ignoreSelection = (
|
|
575
|
+
const loop = (params === null || params === void 0 ? void 0 : params.loop) ?? false;
|
|
576
|
+
const stayIfOnMatch = (params === null || params === void 0 ? void 0 : params.stayIfOnMatch) ?? false;
|
|
577
|
+
const noFocus = (params === null || params === void 0 ? void 0 : params.noFocus) ?? false;
|
|
578
|
+
const ignoreSelection = (params === null || params === void 0 ? void 0 : params.ignoreSelection) ?? false;
|
|
580
579
|
const matchToMove = this._findPreviousMatch(loop, stayIfOnMatch, ignoreSelection);
|
|
581
580
|
if (matchToMove) {
|
|
582
581
|
const [match, index] = matchToMove;
|
|
@@ -637,14 +636,12 @@ let SheetFindModel = class SheetFindModel extends FindModel {
|
|
|
637
636
|
_findPreviousWorksheetThatHasAMatch(currentWorksheet, loop = false) {
|
|
638
637
|
const rawWorksheetsInOrder = this._workbook.getSheetOrders();
|
|
639
638
|
const currentSheetIndex = rawWorksheetsInOrder.findIndex((sheet) => sheet === currentWorksheet);
|
|
640
|
-
|
|
641
|
-
return first !== null && first !== void 0 ? first : null;
|
|
639
|
+
return (loop ? rotate(rawWorksheetsInOrder, currentSheetIndex + 1) : rawWorksheetsInOrder.slice(0, currentSheetIndex + 1)).findLast((worksheet) => this._matchesByWorksheet.has(worksheet)) ?? null;
|
|
642
640
|
}
|
|
643
641
|
_findNextWorksheetThatHasAMatch(currentWorksheet, loop = false) {
|
|
644
642
|
const rawWorksheetsInOrder = this._workbook.getSheetOrders();
|
|
645
643
|
const currentSheetIndex = rawWorksheetsInOrder.findIndex((sheet) => sheet === currentWorksheet);
|
|
646
|
-
|
|
647
|
-
return first !== null && first !== void 0 ? first : null;
|
|
644
|
+
return (loop ? rotate(rawWorksheetsInOrder, currentSheetIndex) : rawWorksheetsInOrder.slice(currentSheetIndex)).find((worksheet) => this._matchesByWorksheet.has(worksheet)) ?? null;
|
|
648
645
|
}
|
|
649
646
|
_findNextMatchByRange(matches, range, stayIfOnMatch = false) {
|
|
650
647
|
const findByRow = this._query.findDirection === FindDirection.ROW;
|
|
@@ -752,14 +749,25 @@ let SheetsFindReplaceProvider = class SheetsFindReplaceProvider extends Disposab
|
|
|
752
749
|
this._univerInstanceService = _univerInstanceService;
|
|
753
750
|
this._renderManagerService = _renderManagerService;
|
|
754
751
|
this._injector = _injector;
|
|
752
|
+
_defineProperty(this, "capabilities", {
|
|
753
|
+
caseSensitive: true,
|
|
754
|
+
matchesTheWholeWord: false,
|
|
755
|
+
matchesTheWholeCell: true,
|
|
756
|
+
findDirection: true,
|
|
757
|
+
findScope: true,
|
|
758
|
+
findBy: true
|
|
759
|
+
});
|
|
755
760
|
_defineProperty(this, "_findModelsByUnitId", /* @__PURE__ */ new Map());
|
|
756
761
|
}
|
|
762
|
+
isSupported(unit) {
|
|
763
|
+
return unit.type === UniverInstanceType.UNIVER_SHEET;
|
|
764
|
+
}
|
|
757
765
|
async find(query) {
|
|
758
766
|
this._terminate();
|
|
759
767
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
760
768
|
if (!workbook) return [];
|
|
761
769
|
const parsedQuery = this._preprocessQuery(query);
|
|
762
|
-
const skeletonManagerService = this._renderManagerService.
|
|
770
|
+
const skeletonManagerService = this._renderManagerService.getRenderUnitById(workbook.getUnitId()).with(SheetSkeletonManagerService);
|
|
763
771
|
const sheetFind = this._injector.createInstance(SheetFindModel, workbook, skeletonManagerService);
|
|
764
772
|
this._findModelsByUnitId.set(workbook.getUnitId(), sheetFind);
|
|
765
773
|
sheetFind.start(parsedQuery);
|
|
@@ -850,8 +858,8 @@ function matchCellData(cellData, query) {
|
|
|
850
858
|
return query.caseSensitive ? value.indexOf(query.findString) > -1 : value.toLowerCase().indexOf(query.findString) > -1;
|
|
851
859
|
}
|
|
852
860
|
function extractPureValue(cell) {
|
|
853
|
-
var _cell$p
|
|
854
|
-
const rawValue = (
|
|
861
|
+
var _cell$p;
|
|
862
|
+
const rawValue = (cell === null || cell === void 0 || (_cell$p = cell.p) === null || _cell$p === void 0 || (_cell$p = _cell$p.body) === null || _cell$p === void 0 ? void 0 : _cell$p.dataStream) ?? (cell === null || cell === void 0 ? void 0 : cell.v);
|
|
855
863
|
if (typeof rawValue === "number") return `${rawValue}`;
|
|
856
864
|
if (typeof rawValue === "boolean") return rawValue ? "1" : "0";
|
|
857
865
|
return rawValue;
|
|
@@ -867,7 +875,7 @@ function trimLeadingTrailingWhitespace(value) {
|
|
|
867
875
|
//#endregion
|
|
868
876
|
//#region package.json
|
|
869
877
|
var name = "@univerjs/sheets-find-replace";
|
|
870
|
-
var version = "1.0.0-
|
|
878
|
+
var version = "1.0.0-beta.0";
|
|
871
879
|
|
|
872
880
|
//#endregion
|
|
873
881
|
//#region src/config/config.ts
|
|
@@ -913,7 +921,7 @@ _defineProperty(UniverSheetsFindReplacePlugin, "packageName", name);
|
|
|
913
921
|
_defineProperty(UniverSheetsFindReplacePlugin, "version", version);
|
|
914
922
|
_defineProperty(UniverSheetsFindReplacePlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
915
923
|
UniverSheetsFindReplacePlugin = __decorate([
|
|
916
|
-
DependentOn(
|
|
924
|
+
DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverFindReplacePlugin, UniverSheetsUIPlugin),
|
|
917
925
|
__decorateParam(1, Inject(Injector)),
|
|
918
926
|
__decorateParam(2, IConfigService)
|
|
919
927
|
], 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
|
-
//#region \0@oxc-project+runtime@0.
|
|
7
|
+
//#region \0@oxc-project+runtime@0.140.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) {
|
|
@@ -15,7 +15,7 @@ function _typeof(o) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
|
-
//#region \0@oxc-project+runtime@0.
|
|
18
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
19
19
|
function toPrimitive(t, r) {
|
|
20
20
|
if ("object" != _typeof(t) || !t) return t;
|
|
21
21
|
var e = t[Symbol.toPrimitive];
|
|
@@ -28,14 +28,14 @@ function toPrimitive(t, r) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
//#endregion
|
|
31
|
-
//#region \0@oxc-project+runtime@0.
|
|
31
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
32
32
|
function toPropertyKey(t) {
|
|
33
33
|
var i = toPrimitive(t, "string");
|
|
34
34
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
//#endregion
|
|
38
|
-
//#region \0@oxc-project+runtime@0.
|
|
38
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
39
39
|
function _defineProperty(e, r, t) {
|
|
40
40
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
41
41
|
value: t,
|
|
@@ -46,7 +46,7 @@ function _defineProperty(e, r, t) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
|
-
//#region \0@oxc-project+runtime@0.
|
|
49
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
50
50
|
function __decorateParam(paramIndex, decorator) {
|
|
51
51
|
return function(target, key) {
|
|
52
52
|
decorator(target, key, paramIndex);
|
|
@@ -54,7 +54,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
//#endregion
|
|
57
|
-
//#region \0@oxc-project+runtime@0.
|
|
57
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
58
58
|
function __decorate(decorators, target, key, desc) {
|
|
59
59
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
60
60
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -135,12 +135,12 @@ let FTextFinder = class FTextFinder extends Disposable {
|
|
|
135
135
|
return this;
|
|
136
136
|
}
|
|
137
137
|
async replaceAllWithAsync(replaceText) {
|
|
138
|
-
var _await$this$_model$re,
|
|
138
|
+
var _await$this$_model$re, _this$_model4;
|
|
139
139
|
await this._state.changeState({
|
|
140
140
|
replaceRevealed: true,
|
|
141
141
|
replaceString: replaceText
|
|
142
142
|
});
|
|
143
|
-
const res = (_await$this$_model$re =
|
|
143
|
+
const res = ((_await$this$_model$re = await ((_this$_model4 = this._model) === null || _this$_model4 === void 0 ? void 0 : _this$_model4.replaceAll())) === null || _await$this$_model$re === void 0 ? void 0 : _await$this$_model$re.success) ?? 0;
|
|
144
144
|
this._state.changeState({ replaceRevealed: false });
|
|
145
145
|
return res;
|
|
146
146
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ColorKit, CommandType, DependentOn, Disposable, EDITOR_ACTIVATED, ICommandService, IConfigService, IContextService, IUndoRedoService, IUniverInstanceService, Inject, Injector, ObjectMatrix, Plugin, Rectangle, ThemeService, Tools, UniverInstanceType, fromCallback, groupBy, merge, regexp, replaceInDocumentBody, rotate } from "@univerjs/core";
|
|
2
2
|
import { SelectRangeCommand, SetRangeValuesCommand, SetSelectionsOperation, SetWorksheetActivateCommand, SetWorksheetActiveOperation, SheetsSelectionsService, UniverSheetsPlugin } from "@univerjs/sheets";
|
|
3
|
-
import { IRenderManagerService, RENDER_RAW_FORMULA_KEY, Rect, Shape } from "@univerjs/engine-render";
|
|
3
|
+
import { IRenderManagerService, RENDER_RAW_FORMULA_KEY, Rect, Shape, UniverRenderEnginePlugin } from "@univerjs/engine-render";
|
|
4
4
|
import { FindBy, FindDirection, FindModel, FindReplaceController, FindScope, IFindReplaceService, UniverFindReplacePlugin } from "@univerjs/find-replace";
|
|
5
|
-
import { ScrollToCellCommand, SheetSkeletonManagerService, getCoordByCell, getSheetObject } from "@univerjs/sheets-ui";
|
|
5
|
+
import { ScrollToCellCommand, SheetSkeletonManagerService, UniverSheetsUIPlugin, getCoordByCell, getSheetObject } from "@univerjs/sheets-ui";
|
|
6
6
|
import { Subject, debounceTime, filter, merge as merge$1, skip, throttleTime } from "rxjs";
|
|
7
7
|
|
|
8
8
|
//#region src/commands/commands/sheet-replace.command.ts
|
|
@@ -42,7 +42,7 @@ function getReplaceAllResult(results, replacements) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
//#endregion
|
|
45
|
-
//#region \0@oxc-project+runtime@0.
|
|
45
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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.
|
|
56
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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.
|
|
69
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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.
|
|
76
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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.
|
|
164
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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.
|
|
172
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/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);
|
|
@@ -363,11 +363,10 @@ let SheetFindModel = class SheetFindModel extends FindModel {
|
|
|
363
363
|
findInActiveWorksheet(query) {
|
|
364
364
|
const unitId = this._workbook.getUnitId();
|
|
365
365
|
const checkShouldFindInSelections = () => {
|
|
366
|
-
var _currentSelections$so;
|
|
367
366
|
const currentWorksheet = this._workbook.getActiveSheet();
|
|
368
367
|
if (!currentWorksheet) return false;
|
|
369
368
|
const currentSelections = this._workbookSelections.getCurrentSelections();
|
|
370
|
-
return (
|
|
369
|
+
return (currentSelections === null || currentSelections === void 0 ? void 0 : currentSelections.some((selection) => !isSelectionSingleCell(selection, currentWorksheet))) ?? false;
|
|
371
370
|
};
|
|
372
371
|
let complete;
|
|
373
372
|
let firstSearch = true;
|
|
@@ -422,8 +421,8 @@ let SheetFindModel = class SheetFindModel extends FindModel {
|
|
|
422
421
|
range: {
|
|
423
422
|
startRow: row,
|
|
424
423
|
startColumn: col,
|
|
425
|
-
endColumn: col + (colSpan
|
|
426
|
-
endRow: row + (rowSpan
|
|
424
|
+
endColumn: col + (colSpan ?? 1) - 1,
|
|
425
|
+
endRow: row + (rowSpan ?? 1) - 1
|
|
427
426
|
}
|
|
428
427
|
}
|
|
429
428
|
};
|
|
@@ -471,7 +470,7 @@ let SheetFindModel = class SheetFindModel extends FindModel {
|
|
|
471
470
|
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
472
471
|
if (!skeleton) return;
|
|
473
472
|
const unitId = this._workbook.getUnitId();
|
|
474
|
-
const currentRender = this._renderManagerService.
|
|
473
|
+
const currentRender = this._renderManagerService.getRenderUnitById(unitId);
|
|
475
474
|
if (currentRender == null) return;
|
|
476
475
|
const { scene } = currentRender;
|
|
477
476
|
const matches = this._matches;
|
|
@@ -496,12 +495,14 @@ let SheetFindModel = class SheetFindModel extends FindModel {
|
|
|
496
495
|
break;
|
|
497
496
|
}
|
|
498
497
|
const inHiddenRange = isAllRowHidden || isAllColHidden;
|
|
498
|
+
const width = isAllColHidden ? 2 : endX - startX;
|
|
499
|
+
const height = isAllRowHidden ? 2 : endY - startY;
|
|
499
500
|
const props = {
|
|
500
501
|
left: startX,
|
|
501
502
|
top: startY,
|
|
502
503
|
color,
|
|
503
|
-
width
|
|
504
|
-
height
|
|
504
|
+
width,
|
|
505
|
+
height,
|
|
505
506
|
evented: false,
|
|
506
507
|
inHiddenRange,
|
|
507
508
|
zIndex: FIND_REPLACE_Z_INDEX
|
|
@@ -550,12 +551,11 @@ let SheetFindModel = class SheetFindModel extends FindModel {
|
|
|
550
551
|
return index > -1 ? index + 1 : 0;
|
|
551
552
|
}
|
|
552
553
|
moveToNextMatch(params) {
|
|
553
|
-
var _params$loop, _params$stayIfOnMatch, _params$noFocus, _params$ignoreSelecti;
|
|
554
554
|
if (!this._matches.length) return null;
|
|
555
|
-
const loop = (
|
|
556
|
-
const stayIfOnMatch = (
|
|
557
|
-
const noFocus = (
|
|
558
|
-
const ignoreSelection = (
|
|
555
|
+
const loop = (params === null || params === void 0 ? void 0 : params.loop) ?? false;
|
|
556
|
+
const stayIfOnMatch = (params === null || params === void 0 ? void 0 : params.stayIfOnMatch) ?? false;
|
|
557
|
+
const noFocus = (params === null || params === void 0 ? void 0 : params.noFocus) ?? false;
|
|
558
|
+
const ignoreSelection = (params === null || params === void 0 ? void 0 : params.ignoreSelection) ?? false;
|
|
559
559
|
const matchToMove = this._findNextMatch(loop, stayIfOnMatch, ignoreSelection);
|
|
560
560
|
if (matchToMove) {
|
|
561
561
|
const [match, index] = matchToMove;
|
|
@@ -571,12 +571,11 @@ let SheetFindModel = class SheetFindModel extends FindModel {
|
|
|
571
571
|
return null;
|
|
572
572
|
}
|
|
573
573
|
moveToPreviousMatch(params) {
|
|
574
|
-
var _params$loop2, _params$stayIfOnMatch2, _params$noFocus2, _params$ignoreSelecti2;
|
|
575
574
|
if (!this._matches.length) return null;
|
|
576
|
-
const loop = (
|
|
577
|
-
const stayIfOnMatch = (
|
|
578
|
-
const noFocus = (
|
|
579
|
-
const ignoreSelection = (
|
|
575
|
+
const loop = (params === null || params === void 0 ? void 0 : params.loop) ?? false;
|
|
576
|
+
const stayIfOnMatch = (params === null || params === void 0 ? void 0 : params.stayIfOnMatch) ?? false;
|
|
577
|
+
const noFocus = (params === null || params === void 0 ? void 0 : params.noFocus) ?? false;
|
|
578
|
+
const ignoreSelection = (params === null || params === void 0 ? void 0 : params.ignoreSelection) ?? false;
|
|
580
579
|
const matchToMove = this._findPreviousMatch(loop, stayIfOnMatch, ignoreSelection);
|
|
581
580
|
if (matchToMove) {
|
|
582
581
|
const [match, index] = matchToMove;
|
|
@@ -637,14 +636,12 @@ let SheetFindModel = class SheetFindModel extends FindModel {
|
|
|
637
636
|
_findPreviousWorksheetThatHasAMatch(currentWorksheet, loop = false) {
|
|
638
637
|
const rawWorksheetsInOrder = this._workbook.getSheetOrders();
|
|
639
638
|
const currentSheetIndex = rawWorksheetsInOrder.findIndex((sheet) => sheet === currentWorksheet);
|
|
640
|
-
|
|
641
|
-
return first !== null && first !== void 0 ? first : null;
|
|
639
|
+
return (loop ? rotate(rawWorksheetsInOrder, currentSheetIndex + 1) : rawWorksheetsInOrder.slice(0, currentSheetIndex + 1)).findLast((worksheet) => this._matchesByWorksheet.has(worksheet)) ?? null;
|
|
642
640
|
}
|
|
643
641
|
_findNextWorksheetThatHasAMatch(currentWorksheet, loop = false) {
|
|
644
642
|
const rawWorksheetsInOrder = this._workbook.getSheetOrders();
|
|
645
643
|
const currentSheetIndex = rawWorksheetsInOrder.findIndex((sheet) => sheet === currentWorksheet);
|
|
646
|
-
|
|
647
|
-
return first !== null && first !== void 0 ? first : null;
|
|
644
|
+
return (loop ? rotate(rawWorksheetsInOrder, currentSheetIndex) : rawWorksheetsInOrder.slice(currentSheetIndex)).find((worksheet) => this._matchesByWorksheet.has(worksheet)) ?? null;
|
|
648
645
|
}
|
|
649
646
|
_findNextMatchByRange(matches, range, stayIfOnMatch = false) {
|
|
650
647
|
const findByRow = this._query.findDirection === FindDirection.ROW;
|
|
@@ -752,14 +749,25 @@ let SheetsFindReplaceProvider = class SheetsFindReplaceProvider extends Disposab
|
|
|
752
749
|
this._univerInstanceService = _univerInstanceService;
|
|
753
750
|
this._renderManagerService = _renderManagerService;
|
|
754
751
|
this._injector = _injector;
|
|
752
|
+
_defineProperty(this, "capabilities", {
|
|
753
|
+
caseSensitive: true,
|
|
754
|
+
matchesTheWholeWord: false,
|
|
755
|
+
matchesTheWholeCell: true,
|
|
756
|
+
findDirection: true,
|
|
757
|
+
findScope: true,
|
|
758
|
+
findBy: true
|
|
759
|
+
});
|
|
755
760
|
_defineProperty(this, "_findModelsByUnitId", /* @__PURE__ */ new Map());
|
|
756
761
|
}
|
|
762
|
+
isSupported(unit) {
|
|
763
|
+
return unit.type === UniverInstanceType.UNIVER_SHEET;
|
|
764
|
+
}
|
|
757
765
|
async find(query) {
|
|
758
766
|
this._terminate();
|
|
759
767
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
760
768
|
if (!workbook) return [];
|
|
761
769
|
const parsedQuery = this._preprocessQuery(query);
|
|
762
|
-
const skeletonManagerService = this._renderManagerService.
|
|
770
|
+
const skeletonManagerService = this._renderManagerService.getRenderUnitById(workbook.getUnitId()).with(SheetSkeletonManagerService);
|
|
763
771
|
const sheetFind = this._injector.createInstance(SheetFindModel, workbook, skeletonManagerService);
|
|
764
772
|
this._findModelsByUnitId.set(workbook.getUnitId(), sheetFind);
|
|
765
773
|
sheetFind.start(parsedQuery);
|
|
@@ -850,8 +858,8 @@ function matchCellData(cellData, query) {
|
|
|
850
858
|
return query.caseSensitive ? value.indexOf(query.findString) > -1 : value.toLowerCase().indexOf(query.findString) > -1;
|
|
851
859
|
}
|
|
852
860
|
function extractPureValue(cell) {
|
|
853
|
-
var _cell$p
|
|
854
|
-
const rawValue = (
|
|
861
|
+
var _cell$p;
|
|
862
|
+
const rawValue = (cell === null || cell === void 0 || (_cell$p = cell.p) === null || _cell$p === void 0 || (_cell$p = _cell$p.body) === null || _cell$p === void 0 ? void 0 : _cell$p.dataStream) ?? (cell === null || cell === void 0 ? void 0 : cell.v);
|
|
855
863
|
if (typeof rawValue === "number") return `${rawValue}`;
|
|
856
864
|
if (typeof rawValue === "boolean") return rawValue ? "1" : "0";
|
|
857
865
|
return rawValue;
|
|
@@ -867,7 +875,7 @@ function trimLeadingTrailingWhitespace(value) {
|
|
|
867
875
|
//#endregion
|
|
868
876
|
//#region package.json
|
|
869
877
|
var name = "@univerjs/sheets-find-replace";
|
|
870
|
-
var version = "1.0.0-
|
|
878
|
+
var version = "1.0.0-beta.0";
|
|
871
879
|
|
|
872
880
|
//#endregion
|
|
873
881
|
//#region src/config/config.ts
|
|
@@ -913,7 +921,7 @@ _defineProperty(UniverSheetsFindReplacePlugin, "packageName", name);
|
|
|
913
921
|
_defineProperty(UniverSheetsFindReplacePlugin, "version", version);
|
|
914
922
|
_defineProperty(UniverSheetsFindReplacePlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
915
923
|
UniverSheetsFindReplacePlugin = __decorate([
|
|
916
|
-
DependentOn(
|
|
924
|
+
DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverFindReplacePlugin, UniverSheetsUIPlugin),
|
|
917
925
|
__decorateParam(1, Inject(Injector)),
|
|
918
926
|
__decorateParam(2, IConfigService)
|
|
919
927
|
], UniverSheetsFindReplacePlugin);
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(require("@univerjs/core"),require("@univerjs/find-replace"),require("@univerjs/sheets/facade"),require("rxjs"),require("@univerjs/core/facade")):typeof define==`function`&&define.amd?define([`@univerjs/core`,`@univerjs/find-replace`,`@univerjs/sheets/facade`,`rxjs`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore,e.UniverFindReplace,e.UniverSheetsFacade,e.rxjs,e.UniverCoreFacade))})(this,function(e,t,n,r,i){function a(e){"@babel/helpers - typeof";return a=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},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){return function(n,r){t(n,r,e)}}function u(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 d=class extends e.Disposable{constructor(e,n,r,i){super(),this._injector=n,this._univerInstanceService=r,this._findReplaceService=i,c(this,`_state`,new t.FindReplaceState),c(this,`_model`,void 0),c(this,`_complete`,void 0);let a=this._findReplaceService.getProviders();this._model=this._injector.createInstance(t.FindReplaceModel,this._state,a);let o={...(0,t.createInitFindReplaceState)(),...e};this._state.changeState(o)}findAll(){return!this._state.findCompleted||!this._complete?[]:this._complete.results.map(e=>this._findMatchToFRange(e))}findNext(){var e;if(!this._state.findCompleted||!this._complete)return null;let t=(e=this._model)==null?void 0:e.moveToNextMatch();return t?this._findMatchToFRange(t):null}findPrevious(){var e;let t=(e=this._model)==null?void 0:e.moveToPreviousMatch();return t?this._findMatchToFRange(t):null}getCurrentMatch(){var e;if(!this._state.findCompleted||!this._complete)throw Error(`Find operation is not completed.`);let t=(e=this._model)==null?void 0:e.currentMatch$.value;return t?this._findMatchToFRange(t):null}async matchCaseAsync(e){return this._state.changeState({caseSensitive:e,findCompleted:!1}),await(0,r.firstValueFrom)(this._state.stateUpdates$.pipe((0,r.filter)(e=>e.findCompleted===!0))),await this.ensureCompleteAsync(),this}async matchEntireCellAsync(e){return this._state.changeState({matchesTheWholeCell:e,findCompleted:!1}),await(0,r.firstValueFrom)(this._state.stateUpdates$.pipe((0,r.filter)(e=>e.findCompleted===!0))),await this.ensureCompleteAsync(),this}async matchFormulaTextAsync(e){return this._state.changeState({findBy:e?t.FindBy.FORMULA:t.FindBy.VALUE,findCompleted:!1}),await(0,r.firstValueFrom)(this._state.stateUpdates$.pipe((0,r.filter)(e=>e.findCompleted===!0))),await this.ensureCompleteAsync(),this}async replaceAllWithAsync(e){var t,n
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(require("@univerjs/core"),require("@univerjs/find-replace"),require("@univerjs/sheets/facade"),require("rxjs"),require("@univerjs/core/facade")):typeof define==`function`&&define.amd?define([`@univerjs/core`,`@univerjs/find-replace`,`@univerjs/sheets/facade`,`rxjs`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore,e.UniverFindReplace,e.UniverSheetsFacade,e.rxjs,e.UniverCoreFacade))})(this,function(e,t,n,r,i){function a(e){"@babel/helpers - typeof";return a=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},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){return function(n,r){t(n,r,e)}}function u(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 d=class extends e.Disposable{constructor(e,n,r,i){super(),this._injector=n,this._univerInstanceService=r,this._findReplaceService=i,c(this,`_state`,new t.FindReplaceState),c(this,`_model`,void 0),c(this,`_complete`,void 0);let a=this._findReplaceService.getProviders();this._model=this._injector.createInstance(t.FindReplaceModel,this._state,a);let o={...(0,t.createInitFindReplaceState)(),...e};this._state.changeState(o)}findAll(){return!this._state.findCompleted||!this._complete?[]:this._complete.results.map(e=>this._findMatchToFRange(e))}findNext(){var e;if(!this._state.findCompleted||!this._complete)return null;let t=(e=this._model)==null?void 0:e.moveToNextMatch();return t?this._findMatchToFRange(t):null}findPrevious(){var e;let t=(e=this._model)==null?void 0:e.moveToPreviousMatch();return t?this._findMatchToFRange(t):null}getCurrentMatch(){var e;if(!this._state.findCompleted||!this._complete)throw Error(`Find operation is not completed.`);let t=(e=this._model)==null?void 0:e.currentMatch$.value;return t?this._findMatchToFRange(t):null}async matchCaseAsync(e){return this._state.changeState({caseSensitive:e,findCompleted:!1}),await(0,r.firstValueFrom)(this._state.stateUpdates$.pipe((0,r.filter)(e=>e.findCompleted===!0))),await this.ensureCompleteAsync(),this}async matchEntireCellAsync(e){return this._state.changeState({matchesTheWholeCell:e,findCompleted:!1}),await(0,r.firstValueFrom)(this._state.stateUpdates$.pipe((0,r.filter)(e=>e.findCompleted===!0))),await this.ensureCompleteAsync(),this}async matchFormulaTextAsync(e){return this._state.changeState({findBy:e?t.FindBy.FORMULA:t.FindBy.VALUE,findCompleted:!1}),await(0,r.firstValueFrom)(this._state.stateUpdates$.pipe((0,r.filter)(e=>e.findCompleted===!0))),await this.ensureCompleteAsync(),this}async replaceAllWithAsync(e){var t,n;await this._state.changeState({replaceRevealed:!0,replaceString:e});let r=((t=await((n=this._model)==null?void 0:n.replaceAll()))==null?void 0:t.success)??0;return this._state.changeState({replaceRevealed:!1}),r}async replaceWithAsync(e){var t;return await this._state.changeState({replaceRevealed:!0,replaceString:e}),await((t=this._model)==null?void 0:t.replace()),this._state.changeState({replaceRevealed:!1}),!0}async ensureCompleteAsync(){var e;this._complete=await((e=this._model)==null?void 0:e.start())}_findMatchToFRange(e){let{unitId:t}=e,{subUnitId:r,range:i}=e.range,a=this._univerInstanceService.getUnit(t),o=a.getSheetBySheetId(r);return this._injector.createInstance(n.FRange,a,o,i)}};d=u([l(1,(0,e.Inject)(e.Injector)),l(2,e.IUniverInstanceService),l(3,t.IFindReplaceService)],d);var f=class extends i.FUniver{async createTextFinderAsync(e){let t={findString:e},n=this._injector.createInstance(d,t);return await n.ensureCompleteAsync(),n}};i.FUniver.extend(f)});
|
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(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._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}=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==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)}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){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){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),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){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),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(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,`_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}}};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?(n=k(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 O(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 k(e){return e.replace(/^ +/g,``).replace(/ +$/g,``)}var A=`@univerjs/sheets-find-replace`,j=`1.0.0-alpha.7`;let M={},N=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(`sheets-find-replace.config`,i)}onStarting(){[[S]].forEach(e=>this._injector.add(e))}onSteady(){this._injector.get(S)}};f(N,`pluginName`,`SHEET_FIND_REPLACE_PLUGIN`),f(N,`packageName`,A),f(N,`version`,j),f(N,`type`,t.UniverInstanceType.UNIVER_SHEET),N=x([(0,t.DependentOn)(n.UniverSheetsPlugin,n.UniverSheetsPlugin,i.UniverFindReplacePlugin),b(1,(0,t.Inject)(t.Injector)),b(2,t.IConfigService)],N),e.SheetReplaceCommand=s,Object.defineProperty(e,"SheetsFindReplaceController",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"UniverSheetsFindReplacePlugin",{enumerable:!0,get:function(){return N}})});
|
|
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(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._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=()=>{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=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=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=y?2:g-m,S=v?2:_-h,C={left:m,top:h,color:s,width:x,height:S,evented:!1,inHiddenRange:b,zIndex:1e4};return new p(`find-highlight-${n}`,C)});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)}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._query.findScope===i.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(e.range.subUnitId).findIndex(t=>t===e):this._activeHighlightIndex=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._query.findScope===i.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(e.range.subUnitId).findIndex(t=>t===e):this._activeHighlightIndex=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});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`,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 t=t.trim(),{...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?(n=k(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 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}function k(e){return e.replace(/^ +/g,``).replace(/ +$/g,``)}var A=`@univerjs/sheets-find-replace`,j=`1.0.0-beta.0`;let M={},N=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(`sheets-find-replace.config`,i)}onStarting(){[[S]].forEach(e=>this._injector.add(e))}onSteady(){this._injector.get(S)}};f(N,`pluginName`,`SHEET_FIND_REPLACE_PLUGIN`),f(N,`packageName`,A),f(N,`version`,j),f(N,`type`,t.UniverInstanceType.UNIVER_SHEET),N=x([(0,t.DependentOn)(r.UniverRenderEnginePlugin,n.UniverSheetsPlugin,i.UniverFindReplacePlugin,a.UniverSheetsUIPlugin),b(1,(0,t.Inject)(t.Injector)),b(2,t.IConfigService)],N),e.SheetReplaceCommand=s,Object.defineProperty(e,"SheetsFindReplaceController",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"UniverSheetsFindReplacePlugin",{enumerable:!0,get:function(){return N}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-find-replace",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.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,17 +62,17 @@
|
|
|
62
62
|
"rxjs": ">=7.0.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@univerjs/core": "1.0.0-
|
|
66
|
-
"@univerjs/engine-render": "1.0.0-
|
|
67
|
-
"@univerjs/
|
|
68
|
-
"@univerjs/sheets-ui": "1.0.0-
|
|
69
|
-
"@univerjs/
|
|
65
|
+
"@univerjs/core": "1.0.0-beta.0",
|
|
66
|
+
"@univerjs/engine-render": "1.0.0-beta.0",
|
|
67
|
+
"@univerjs/find-replace": "1.0.0-beta.0",
|
|
68
|
+
"@univerjs/sheets-ui": "1.0.0-beta.0",
|
|
69
|
+
"@univerjs/sheets": "1.0.0-beta.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"rxjs": "^7.8.2",
|
|
73
73
|
"typescript": "^6.0.3",
|
|
74
74
|
"vitest": "^4.1.10",
|
|
75
|
-
"@univerjs-infra/shared": "1.0.0-
|
|
75
|
+
"@univerjs-infra/shared": "1.0.0-beta.0"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"test": "vitest run",
|