@univerjs/sheets-find-replace 0.5.2-nightly.202501031606 → 0.5.3-experimental.20250106-e3b7a39
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 +1 -0
- package/lib/es/facade.js +100 -0
- package/lib/types/facade/f-text-finder.d.ts +166 -0
- package/lib/types/facade/f-univer.d.ts +24 -0
- package/lib/types/facade/index.d.ts +19 -0
- package/lib/umd/facade.js +1 -0
- package/package.json +12 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var u=Object.defineProperty;var _=(i,e,t)=>e in i?u(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var l=(i,e,t)=>_(i,typeof e!="symbol"?e+"":e,t);const o=require("@univerjs/core"),c=require("@univerjs/find-replace"),p=require("@univerjs/sheets/facade");var m=Object.defineProperty,f=Object.getOwnPropertyDescriptor,v=(i,e,t,s)=>{for(var n=s>1?void 0:s?f(e,t):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(n=(s?a(e,t,n):a(n))||n);return s&&n&&m(e,t,n),n},h=(i,e)=>(t,s)=>e(t,s,i);let d=class extends o.Disposable{constructor(e,t,s,n){super();l(this,"_state",new c.FindReplaceState);l(this,"_model");l(this,"_complete");this._injector=t,this._univerInstanceService=s,this._findReplaceService=n;const r=this._findReplaceService.getProviders();this._model=this._injector.createInstance(c.FindReplaceModel,this._state,r);const a={...c.createInitFindReplaceState(),...e};this._state.changeState(a)}findAll(){return!this._state.findCompleted||!this._complete?[]:this._complete.results.map(e=>this._findMatchToFRange(e))}findNext(){var t;if(!this._state.findCompleted||!this._complete)return null;const e=(t=this._model)==null?void 0:t.moveToNextMatch();return e?this._findMatchToFRange(e):null}findPrevious(){var t;const e=(t=this._model)==null?void 0:t.moveToPreviousMatch();return e?this._findMatchToFRange(e):null}getCurrentMatch(){var t;if(!this._state.findCompleted||!this._complete)throw new Error("Find operation is not completed.");const e=(t=this._model)==null?void 0:t.currentMatch$.value;return e?this._findMatchToFRange(e):null}async matchCaseAsync(e){return this._state.changeState({caseSensitive:e}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(n=>{n.findCompleted===!0&&(s.unsubscribe(),t(this))})})}async matchEntireCellAsync(e){return this._state.changeState({matchesTheWholeCell:e}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(n=>{n.findCompleted===!0&&(s.unsubscribe(),t(this))})})}async matchFormulaTextAsync(e){return this._state.changeState({findBy:e?c.FindBy.FORMULA:c.FindBy.VALUE}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(n=>{n.findCompleted===!0&&(s.unsubscribe(),t(this))})})}async replaceAllWithAsync(e){var s,n,r;await this._state.changeState({replaceRevealed:!0,replaceString:e});const t=(r=(n=await((s=this._model)==null?void 0:s.replaceAll()))==null?void 0:n.success)!=null?r:0;return this._state.changeState({replaceRevealed:!1}),t}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;return(!this._state.findCompleted||!this._complete)&&(this._complete=await((e=this._model)==null?void 0:e.start())),this._complete}_findMatchToFRange(e){const{unitId:t}=e,{subUnitId:s,range:n}=e.range,r=this._univerInstanceService.getUnit(t),a=r.getSheetBySheetId(s);return this._injector.createInstance(p.FRange,r,a,n)}};d=v([h(1,o.Inject(o.Injector)),h(2,o.IUniverInstanceService),h(3,c.IFindReplaceService)],d);class b extends o.FUniver{async createTextFinderAsync(e){const t={findString:e},s=this._injector.createInstance(d,t);return await s.ensureCompleteAsync(),s}}o.FUniver.extend(b);
|
package/lib/es/facade.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
var u = Object.defineProperty;
|
|
2
|
+
var _ = (i, e, t) => e in i ? u(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var c = (i, e, t) => _(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Inject as p, Injector as m, IUniverInstanceService as f, Disposable as v, FUniver as d } from "@univerjs/core";
|
|
5
|
+
import { IFindReplaceService as b, FindReplaceModel as g, createInitFindReplaceState as S, FindReplaceState as F, FindBy as h } from "@univerjs/find-replace";
|
|
6
|
+
import { FRange as y } from "@univerjs/sheets/facade";
|
|
7
|
+
var R = Object.defineProperty, w = Object.getOwnPropertyDescriptor, C = (i, e, t, s) => {
|
|
8
|
+
for (var n = s > 1 ? void 0 : s ? w(e, t) : e, r = i.length - 1, a; r >= 0; r--)
|
|
9
|
+
(a = i[r]) && (n = (s ? a(e, t, n) : a(n)) || n);
|
|
10
|
+
return s && n && R(e, t, n), n;
|
|
11
|
+
}, o = (i, e) => (t, s) => e(t, s, i);
|
|
12
|
+
let l = class extends v {
|
|
13
|
+
constructor(e, t, s, n) {
|
|
14
|
+
super();
|
|
15
|
+
c(this, "_state", new F());
|
|
16
|
+
c(this, "_model");
|
|
17
|
+
c(this, "_complete");
|
|
18
|
+
this._injector = t, this._univerInstanceService = s, this._findReplaceService = n;
|
|
19
|
+
const r = this._findReplaceService.getProviders();
|
|
20
|
+
this._model = this._injector.createInstance(g, this._state, r);
|
|
21
|
+
const a = {
|
|
22
|
+
...S(),
|
|
23
|
+
...e
|
|
24
|
+
};
|
|
25
|
+
this._state.changeState(a);
|
|
26
|
+
}
|
|
27
|
+
findAll() {
|
|
28
|
+
return !this._state.findCompleted || !this._complete ? [] : this._complete.results.map((e) => this._findMatchToFRange(e));
|
|
29
|
+
}
|
|
30
|
+
findNext() {
|
|
31
|
+
var t;
|
|
32
|
+
if (!this._state.findCompleted || !this._complete)
|
|
33
|
+
return null;
|
|
34
|
+
const e = (t = this._model) == null ? void 0 : t.moveToNextMatch();
|
|
35
|
+
return e ? this._findMatchToFRange(e) : null;
|
|
36
|
+
}
|
|
37
|
+
findPrevious() {
|
|
38
|
+
var t;
|
|
39
|
+
const e = (t = this._model) == null ? void 0 : t.moveToPreviousMatch();
|
|
40
|
+
return e ? this._findMatchToFRange(e) : null;
|
|
41
|
+
}
|
|
42
|
+
getCurrentMatch() {
|
|
43
|
+
var t;
|
|
44
|
+
if (!this._state.findCompleted || !this._complete)
|
|
45
|
+
throw new Error("Find operation is not completed.");
|
|
46
|
+
const e = (t = this._model) == null ? void 0 : t.currentMatch$.value;
|
|
47
|
+
return e ? this._findMatchToFRange(e) : null;
|
|
48
|
+
}
|
|
49
|
+
async matchCaseAsync(e) {
|
|
50
|
+
return this._state.changeState({ caseSensitive: e }), new Promise((t) => {
|
|
51
|
+
const s = this._state.stateUpdates$.subscribe((n) => {
|
|
52
|
+
n.findCompleted === !0 && (s.unsubscribe(), t(this));
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async matchEntireCellAsync(e) {
|
|
57
|
+
return this._state.changeState({ matchesTheWholeCell: e }), new Promise((t) => {
|
|
58
|
+
const s = this._state.stateUpdates$.subscribe((n) => {
|
|
59
|
+
n.findCompleted === !0 && (s.unsubscribe(), t(this));
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
async matchFormulaTextAsync(e) {
|
|
64
|
+
return this._state.changeState({ findBy: e ? h.FORMULA : h.VALUE }), new Promise((t) => {
|
|
65
|
+
const s = this._state.stateUpdates$.subscribe((n) => {
|
|
66
|
+
n.findCompleted === !0 && (s.unsubscribe(), t(this));
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async replaceAllWithAsync(e) {
|
|
71
|
+
var s, n, r;
|
|
72
|
+
await this._state.changeState({ replaceRevealed: !0, replaceString: e });
|
|
73
|
+
const t = (r = (n = await ((s = this._model) == null ? void 0 : s.replaceAll())) == null ? void 0 : n.success) != null ? r : 0;
|
|
74
|
+
return this._state.changeState({ replaceRevealed: !1 }), t;
|
|
75
|
+
}
|
|
76
|
+
async replaceWithAsync(e) {
|
|
77
|
+
var t;
|
|
78
|
+
return await this._state.changeState({ replaceRevealed: !0, replaceString: e }), await ((t = this._model) == null ? void 0 : t.replace()), this._state.changeState({ replaceRevealed: !1 }), !0;
|
|
79
|
+
}
|
|
80
|
+
async ensureCompleteAsync() {
|
|
81
|
+
var e;
|
|
82
|
+
return (!this._state.findCompleted || !this._complete) && (this._complete = await ((e = this._model) == null ? void 0 : e.start())), this._complete;
|
|
83
|
+
}
|
|
84
|
+
_findMatchToFRange(e) {
|
|
85
|
+
const { unitId: t } = e, { subUnitId: s, range: n } = e.range, r = this._univerInstanceService.getUnit(t), a = r.getSheetBySheetId(s);
|
|
86
|
+
return this._injector.createInstance(y, r, a, n);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
l = C([
|
|
90
|
+
o(1, p(m)),
|
|
91
|
+
o(2, f),
|
|
92
|
+
o(3, b)
|
|
93
|
+
], l);
|
|
94
|
+
class I extends d {
|
|
95
|
+
async createTextFinderAsync(e) {
|
|
96
|
+
const t = { findString: e }, s = this._injector.createInstance(l, t);
|
|
97
|
+
return await s.ensureCompleteAsync(), s;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
d.extend(I);
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { Nullable, Disposable, Injector, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
+
import { IFindComplete, IFindReplaceState, IFindReplaceService } from '@univerjs/find-replace';
|
|
3
|
+
import { FRange } from '@univerjs/sheets/facade';
|
|
4
|
+
export interface IFTextFinder {
|
|
5
|
+
/**
|
|
6
|
+
* get all the matched range in the univer
|
|
7
|
+
* @returns all the matched range
|
|
8
|
+
* @throws if the find operation is not completed
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const textFinder = await univerAPI.createTextFinderAsync('hello');
|
|
13
|
+
* const ranges = textFinder.findAll();
|
|
14
|
+
* ranges.forEach((range) => {
|
|
15
|
+
* console.log(range.getA1Notation());
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
findAll(): FRange[];
|
|
20
|
+
/**
|
|
21
|
+
* find the next matched range in the univer
|
|
22
|
+
* @returns the next matched range
|
|
23
|
+
* @throws if the find operation is not completed
|
|
24
|
+
* @returns null if no more match
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const textFinder = await univerAPI.createTextFinderAsync('hello');
|
|
29
|
+
* const range = textFinder.findNext();
|
|
30
|
+
* if (range) {
|
|
31
|
+
* console.log(range.getA1Notation());
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
findNext(): Nullable<FRange>;
|
|
36
|
+
/**
|
|
37
|
+
* find the previous matched range in the univer
|
|
38
|
+
* @returns the previous matched range
|
|
39
|
+
* @throws if the find operation is not completed
|
|
40
|
+
* @returns null if no more match
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const textFinder = await univerAPI.createTextFinderAsync('hello');
|
|
45
|
+
* const range = textFinder.findPrevious();
|
|
46
|
+
* if (range) {
|
|
47
|
+
* console.log(range.getA1Notation());
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
findPrevious(): Nullable<FRange>;
|
|
52
|
+
/**
|
|
53
|
+
* get the current matched range in the univer
|
|
54
|
+
* @returns the current matched range
|
|
55
|
+
* @throws if the find operation is not completed
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const textFinder = await univerAPI.createTextFinderAsync('hello');
|
|
60
|
+
* const range = textFinder.getCurrentMatch();
|
|
61
|
+
* if (range) {
|
|
62
|
+
* console.log(range.getA1Notation());
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
getCurrentMatch(): Nullable<FRange>;
|
|
67
|
+
/**
|
|
68
|
+
* set the match case option
|
|
69
|
+
* @param {boolean} matchCase whether to match case
|
|
70
|
+
* @returns text-finder instance
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const textFinder = await univerAPI.createTextFinderAsync('hello');
|
|
75
|
+
* await textFinder.matchCaseAsync(true);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
matchCaseAsync(matchCase: boolean): Promise<IFTextFinder>;
|
|
79
|
+
/**
|
|
80
|
+
* set the match entire cell option
|
|
81
|
+
* @param {boolean} matchEntireCell whether to match entire cell
|
|
82
|
+
* @returns text-finder instance
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const textFinder = await univerAPI.createTextFinderAsync('hello');
|
|
87
|
+
* await textFinder.matchEntireCellAsync(true);
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
matchEntireCellAsync(matchEntireCell: boolean): Promise<IFTextFinder>;
|
|
91
|
+
/**
|
|
92
|
+
* set the match formula text option
|
|
93
|
+
* @param {boolean} matchFormulaText whether to match formula text
|
|
94
|
+
* @returns text-finder instance
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const textFinder = await univerAPI.createTextFinderAsync('hello');
|
|
99
|
+
* await textFinder.matchFormulaTextAsync(true);
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
matchFormulaTextAsync(matchFormulaText: boolean): Promise<IFTextFinder>;
|
|
103
|
+
/**
|
|
104
|
+
* replace all the matched text with the given text
|
|
105
|
+
* @param {string} replaceText the text to replace
|
|
106
|
+
* @returns the number of replaced text
|
|
107
|
+
* @throws if the find operation is not completed
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const textFinder = await univerAPI.createTextFinderAsync('hello');
|
|
112
|
+
* const replacedCount = await textFinder.replaceAllWithAsync('world');
|
|
113
|
+
* console.log(replacedCount);
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
replaceAllWithAsync(replaceText: string): Promise<number>;
|
|
117
|
+
/**
|
|
118
|
+
* replace the current matched text with the given text
|
|
119
|
+
* @param {string} replaceText the text to replace
|
|
120
|
+
* @returns whether the replace is successful
|
|
121
|
+
* @throws if the find operation is not completed
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const textFinder = await univerAPI.createTextFinderAsync('hello');
|
|
126
|
+
* const replaced = await textFinder.replaceWithAsync('world');
|
|
127
|
+
* console.log(replaced);
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
replaceWithAsync(replaceText: string): Promise<boolean>;
|
|
131
|
+
/**
|
|
132
|
+
* ensure the find operation is completed
|
|
133
|
+
* @returns the find complete result
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* const textFinder = await univerAPI.createTextFinderAsync('hello');
|
|
138
|
+
* const complete = await textFinder.ensureCompleteAsync();
|
|
139
|
+
* console.log(complete);
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
ensureCompleteAsync(): Promise<Nullable<IFindComplete>>;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* This interface class provides methods to find and replace text in the univer.
|
|
146
|
+
*/
|
|
147
|
+
export declare class FTextFinder extends Disposable implements IFTextFinder {
|
|
148
|
+
private readonly _injector;
|
|
149
|
+
private readonly _univerInstanceService;
|
|
150
|
+
private readonly _findReplaceService;
|
|
151
|
+
private readonly _state;
|
|
152
|
+
private _model;
|
|
153
|
+
private _complete;
|
|
154
|
+
constructor(_initialState: Partial<IFindReplaceState>, _injector: Injector, _univerInstanceService: IUniverInstanceService, _findReplaceService: IFindReplaceService);
|
|
155
|
+
findAll(): FRange[];
|
|
156
|
+
findNext(): Nullable<FRange>;
|
|
157
|
+
findPrevious(): Nullable<FRange>;
|
|
158
|
+
getCurrentMatch(): Nullable<FRange>;
|
|
159
|
+
matchCaseAsync(matchCase: boolean): Promise<IFTextFinder>;
|
|
160
|
+
matchEntireCellAsync(matchEntireCell: boolean): Promise<IFTextFinder>;
|
|
161
|
+
matchFormulaTextAsync(matchFormulaText: boolean): Promise<IFTextFinder>;
|
|
162
|
+
replaceAllWithAsync(replaceText: string): Promise<number>;
|
|
163
|
+
replaceWithAsync(replaceText: string): Promise<boolean>;
|
|
164
|
+
ensureCompleteAsync(): Promise<Nullable<IFindComplete>>;
|
|
165
|
+
private _findMatchToFRange;
|
|
166
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FUniver } from '@univerjs/core';
|
|
2
|
+
import { FTextFinder } from './f-text-finder';
|
|
3
|
+
export interface IFUniverFindReplaceMixin {
|
|
4
|
+
/**
|
|
5
|
+
* Create a text-finder for the current univer.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} text - The text to find.
|
|
8
|
+
*
|
|
9
|
+
* @returns {Promise<FTextFinder | null>} A promise that resolves to the text-finder instance.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const textFinder = await univerAPI.createTextFinderAsync('Hello');
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
createTextFinderAsync(text: string): Promise<FTextFinder | null>;
|
|
17
|
+
}
|
|
18
|
+
export declare class FUniverFindReplaceMixin extends FUniver implements IFUniverFindReplaceMixin {
|
|
19
|
+
createTextFinderAsync(text: string): Promise<FTextFinder | null>;
|
|
20
|
+
}
|
|
21
|
+
declare module '@univerjs/core' {
|
|
22
|
+
interface FUniver extends IFUniverFindReplaceMixin {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import './f-text-finder';
|
|
17
|
+
import './f-univer';
|
|
18
|
+
export type * from './f-text-finder';
|
|
19
|
+
export type * from './f-univer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(i,r){typeof exports=="object"&&typeof module<"u"?r(require("@univerjs/core"),require("@univerjs/find-replace"),require("@univerjs/sheets/facade")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace","@univerjs/sheets/facade"],r):(i=typeof globalThis<"u"?globalThis:i||self,r(i.UniverCore,i.UniverFindReplace,i.UniverSheetsFacade))})(this,function(i,r,o){"use strict";var v=Object.defineProperty;var F=(i,r,o)=>r in i?v(i,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[r]=o;var l=(i,r,o)=>F(i,typeof r!="symbol"?r+"":r,o);var _=Object.defineProperty,p=Object.getOwnPropertyDescriptor,f=(h,e,t,s)=>{for(var n=s>1?void 0:s?p(e,t):e,a=h.length-1,c;a>=0;a--)(c=h[a])&&(n=(s?c(e,t,n):c(n))||n);return s&&n&&_(e,t,n),n},u=(h,e)=>(t,s)=>e(t,s,h);let d=class extends i.Disposable{constructor(e,t,s,n){super();l(this,"_state",new r.FindReplaceState);l(this,"_model");l(this,"_complete");this._injector=t,this._univerInstanceService=s,this._findReplaceService=n;const a=this._findReplaceService.getProviders();this._model=this._injector.createInstance(r.FindReplaceModel,this._state,a);const c={...r.createInitFindReplaceState(),...e};this._state.changeState(c)}findAll(){return!this._state.findCompleted||!this._complete?[]:this._complete.results.map(e=>this._findMatchToFRange(e))}findNext(){var t;if(!this._state.findCompleted||!this._complete)return null;const e=(t=this._model)==null?void 0:t.moveToNextMatch();return e?this._findMatchToFRange(e):null}findPrevious(){var t;const e=(t=this._model)==null?void 0:t.moveToPreviousMatch();return e?this._findMatchToFRange(e):null}getCurrentMatch(){var t;if(!this._state.findCompleted||!this._complete)throw new Error("Find operation is not completed.");const e=(t=this._model)==null?void 0:t.currentMatch$.value;return e?this._findMatchToFRange(e):null}async matchCaseAsync(e){return this._state.changeState({caseSensitive:e}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(n=>{n.findCompleted===!0&&(s.unsubscribe(),t(this))})})}async matchEntireCellAsync(e){return this._state.changeState({matchesTheWholeCell:e}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(n=>{n.findCompleted===!0&&(s.unsubscribe(),t(this))})})}async matchFormulaTextAsync(e){return this._state.changeState({findBy:e?r.FindBy.FORMULA:r.FindBy.VALUE}),new Promise(t=>{const s=this._state.stateUpdates$.subscribe(n=>{n.findCompleted===!0&&(s.unsubscribe(),t(this))})})}async replaceAllWithAsync(e){var s,n,a;await this._state.changeState({replaceRevealed:!0,replaceString:e});const t=(a=(n=await((s=this._model)==null?void 0:s.replaceAll()))==null?void 0:n.success)!=null?a:0;return this._state.changeState({replaceRevealed:!1}),t}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;return(!this._state.findCompleted||!this._complete)&&(this._complete=await((e=this._model)==null?void 0:e.start())),this._complete}_findMatchToFRange(e){const{unitId:t}=e,{subUnitId:s,range:n}=e.range,a=this._univerInstanceService.getUnit(t),c=a.getSheetBySheetId(s);return this._injector.createInstance(o.FRange,a,c,n)}};d=f([u(1,i.Inject(i.Injector)),u(2,i.IUniverInstanceService),u(3,r.IFindReplaceService)],d);class m extends i.FUniver{async createTextFinderAsync(e){const t={findString:e},s=this._injector.createInstance(d,t);return await s.ensureCompleteAsync(),s}}i.FUniver.extend(m)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-find-replace",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3-experimental.20250106-e3b7a39",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "UniverSheet find replace plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"require": "./lib/cjs/locale/*.js",
|
|
37
37
|
"types": "./lib/types/locale/*.d.ts"
|
|
38
38
|
},
|
|
39
|
+
"./facade": {
|
|
40
|
+
"import": "./lib/es/facade.js",
|
|
41
|
+
"require": "./lib/cjs/facade.js",
|
|
42
|
+
"types": "./lib/types/facade/index.d.ts"
|
|
43
|
+
},
|
|
39
44
|
"./lib/*": "./lib/*"
|
|
40
45
|
},
|
|
41
46
|
"main": "./lib/es/index.js",
|
|
@@ -53,18 +58,18 @@
|
|
|
53
58
|
"rxjs": ">=7.0.0"
|
|
54
59
|
},
|
|
55
60
|
"dependencies": {
|
|
56
|
-
"@univerjs/core": "0.5.
|
|
57
|
-
"@univerjs/engine-render": "0.5.
|
|
58
|
-
"@univerjs/find-replace": "0.5.
|
|
59
|
-
"@univerjs/sheets-ui": "0.5.
|
|
60
|
-
"@univerjs/sheets": "0.5.
|
|
61
|
+
"@univerjs/core": "0.5.3-experimental.20250106-e3b7a39",
|
|
62
|
+
"@univerjs/engine-render": "0.5.3-experimental.20250106-e3b7a39",
|
|
63
|
+
"@univerjs/find-replace": "0.5.3-experimental.20250106-e3b7a39",
|
|
64
|
+
"@univerjs/sheets-ui": "0.5.3-experimental.20250106-e3b7a39",
|
|
65
|
+
"@univerjs/sheets": "0.5.3-experimental.20250106-e3b7a39"
|
|
61
66
|
},
|
|
62
67
|
"devDependencies": {
|
|
63
68
|
"rxjs": "^7.8.1",
|
|
64
69
|
"typescript": "^5.7.2",
|
|
65
70
|
"vite": "^6.0.6",
|
|
66
71
|
"vitest": "^2.1.8",
|
|
67
|
-
"@univerjs-infra/shared": "0.5.
|
|
72
|
+
"@univerjs-infra/shared": "0.5.3"
|
|
68
73
|
},
|
|
69
74
|
"scripts": {
|
|
70
75
|
"test": "vitest run",
|