@univerjs/sheets-find-replace 0.20.1 → 0.21.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 +204 -1
- package/lib/cjs/index.js +936 -1
- package/lib/cjs/locale/ca-ES.js +9 -1
- package/lib/cjs/locale/en-US.js +24 -1
- package/lib/cjs/locale/es-ES.js +9 -1
- package/lib/cjs/locale/fa-IR.js +9 -1
- package/lib/cjs/locale/fr-FR.js +9 -1
- package/lib/cjs/locale/ja-JP.js +9 -1
- package/lib/cjs/locale/ko-KR.js +9 -1
- package/lib/cjs/locale/ru-RU.js +9 -1
- package/lib/cjs/locale/sk-SK.js +9 -1
- package/lib/cjs/locale/vi-VN.js +9 -1
- package/lib/cjs/locale/zh-CN.js +24 -1
- package/lib/cjs/locale/zh-TW.js +9 -1
- package/lib/es/facade.js +205 -1
- package/lib/es/index.js +923 -1
- package/lib/es/locale/ca-ES.js +8 -1
- package/lib/es/locale/en-US.js +23 -1
- package/lib/es/locale/es-ES.js +8 -1
- package/lib/es/locale/fa-IR.js +8 -1
- package/lib/es/locale/fr-FR.js +8 -1
- package/lib/es/locale/ja-JP.js +8 -1
- package/lib/es/locale/ko-KR.js +8 -1
- package/lib/es/locale/ru-RU.js +8 -1
- package/lib/es/locale/sk-SK.js +8 -1
- package/lib/es/locale/vi-VN.js +8 -1
- package/lib/es/locale/zh-CN.js +23 -1
- package/lib/es/locale/zh-TW.js +8 -1
- package/lib/facade.js +205 -1
- package/lib/index.js +923 -1
- package/lib/locale/ca-ES.js +8 -1
- package/lib/locale/en-US.js +23 -1
- package/lib/locale/es-ES.js +8 -1
- package/lib/locale/fa-IR.js +8 -1
- package/lib/locale/fr-FR.js +8 -1
- package/lib/locale/ja-JP.js +8 -1
- package/lib/locale/ko-KR.js +8 -1
- package/lib/locale/ru-RU.js +8 -1
- package/lib/locale/sk-SK.js +8 -1
- package/lib/locale/vi-VN.js +8 -1
- package/lib/locale/zh-CN.js +23 -1
- package/lib/locale/zh-TW.js +8 -1
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1,204 @@
|
|
|
1
|
-
let
|
|
1
|
+
let _univerjs_core = require("@univerjs/core");
|
|
2
|
+
let _univerjs_find_replace = require("@univerjs/find-replace");
|
|
3
|
+
let _univerjs_sheets_facade = require("@univerjs/sheets/facade");
|
|
4
|
+
let _univerjs_core_facade = require("@univerjs/core/facade");
|
|
5
|
+
|
|
6
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
|
|
7
|
+
function _typeof(o) {
|
|
8
|
+
"@babel/helpers - typeof";
|
|
9
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
10
|
+
return typeof o;
|
|
11
|
+
} : function(o) {
|
|
12
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
13
|
+
}, _typeof(o);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
|
|
18
|
+
function toPrimitive(t, r) {
|
|
19
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
20
|
+
var e = t[Symbol.toPrimitive];
|
|
21
|
+
if (void 0 !== e) {
|
|
22
|
+
var i = e.call(t, r || "default");
|
|
23
|
+
if ("object" != _typeof(i)) return i;
|
|
24
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
25
|
+
}
|
|
26
|
+
return ("string" === r ? String : Number)(t);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
|
|
31
|
+
function toPropertyKey(t) {
|
|
32
|
+
var i = toPrimitive(t, "string");
|
|
33
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
|
|
38
|
+
function _defineProperty(e, r, t) {
|
|
39
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
40
|
+
value: t,
|
|
41
|
+
enumerable: !0,
|
|
42
|
+
configurable: !0,
|
|
43
|
+
writable: !0
|
|
44
|
+
}) : e[r] = t, e;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
|
|
49
|
+
function __decorateParam(paramIndex, decorator) {
|
|
50
|
+
return function(target, key) {
|
|
51
|
+
decorator(target, key, paramIndex);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
|
|
57
|
+
function __decorate(decorators, target, key, desc) {
|
|
58
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
59
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
60
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
61
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/facade/f-text-finder.ts
|
|
66
|
+
let FTextFinder = class FTextFinder extends _univerjs_core.Disposable {
|
|
67
|
+
constructor(_initialState, _injector, _univerInstanceService, _findReplaceService) {
|
|
68
|
+
super();
|
|
69
|
+
this._injector = _injector;
|
|
70
|
+
this._univerInstanceService = _univerInstanceService;
|
|
71
|
+
this._findReplaceService = _findReplaceService;
|
|
72
|
+
_defineProperty(this, "_state", new _univerjs_find_replace.FindReplaceState());
|
|
73
|
+
_defineProperty(this, "_model", void 0);
|
|
74
|
+
_defineProperty(this, "_complete", void 0);
|
|
75
|
+
const providers = this._findReplaceService.getProviders();
|
|
76
|
+
this._model = this._injector.createInstance(_univerjs_find_replace.FindReplaceModel, this._state, providers);
|
|
77
|
+
const newState = {
|
|
78
|
+
...(0, _univerjs_find_replace.createInitFindReplaceState)(),
|
|
79
|
+
..._initialState
|
|
80
|
+
};
|
|
81
|
+
this._state.changeState(newState);
|
|
82
|
+
}
|
|
83
|
+
findAll() {
|
|
84
|
+
if (!this._state.findCompleted || !this._complete) return [];
|
|
85
|
+
return this._complete.results.map((result) => {
|
|
86
|
+
return this._findMatchToFRange(result);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
findNext() {
|
|
90
|
+
var _this$_model;
|
|
91
|
+
if (!this._state.findCompleted || !this._complete) return null;
|
|
92
|
+
const match = (_this$_model = this._model) === null || _this$_model === void 0 ? void 0 : _this$_model.moveToNextMatch();
|
|
93
|
+
if (!match) return null;
|
|
94
|
+
return this._findMatchToFRange(match);
|
|
95
|
+
}
|
|
96
|
+
findPrevious() {
|
|
97
|
+
var _this$_model2;
|
|
98
|
+
const match = (_this$_model2 = this._model) === null || _this$_model2 === void 0 ? void 0 : _this$_model2.moveToPreviousMatch();
|
|
99
|
+
if (!match) return null;
|
|
100
|
+
return this._findMatchToFRange(match);
|
|
101
|
+
}
|
|
102
|
+
getCurrentMatch() {
|
|
103
|
+
var _this$_model3;
|
|
104
|
+
if (!this._state.findCompleted || !this._complete) throw new Error("Find operation is not completed.");
|
|
105
|
+
const match = (_this$_model3 = this._model) === null || _this$_model3 === void 0 ? void 0 : _this$_model3.currentMatch$.value;
|
|
106
|
+
if (!match) return null;
|
|
107
|
+
return this._findMatchToFRange(match);
|
|
108
|
+
}
|
|
109
|
+
async matchCaseAsync(matchCase) {
|
|
110
|
+
this._state.changeState({
|
|
111
|
+
caseSensitive: matchCase,
|
|
112
|
+
findCompleted: false
|
|
113
|
+
});
|
|
114
|
+
return new Promise((resolve) => {
|
|
115
|
+
const subscribe = this._state.stateUpdates$.subscribe(async (state) => {
|
|
116
|
+
if (state.findCompleted === true) {
|
|
117
|
+
subscribe.unsubscribe();
|
|
118
|
+
await this.ensureCompleteAsync();
|
|
119
|
+
resolve(this);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async matchEntireCellAsync(matchEntireCell) {
|
|
125
|
+
this._state.changeState({
|
|
126
|
+
matchesTheWholeCell: matchEntireCell,
|
|
127
|
+
findCompleted: false
|
|
128
|
+
});
|
|
129
|
+
return new Promise((resolve) => {
|
|
130
|
+
const subscribe = this._state.stateUpdates$.subscribe(async (state) => {
|
|
131
|
+
if (state.findCompleted === true) {
|
|
132
|
+
subscribe.unsubscribe();
|
|
133
|
+
await this.ensureCompleteAsync();
|
|
134
|
+
resolve(this);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
async matchFormulaTextAsync(matchFormulaText) {
|
|
140
|
+
this._state.changeState({
|
|
141
|
+
findBy: matchFormulaText ? _univerjs_find_replace.FindBy.FORMULA : _univerjs_find_replace.FindBy.VALUE,
|
|
142
|
+
findCompleted: false
|
|
143
|
+
});
|
|
144
|
+
return new Promise((resolve) => {
|
|
145
|
+
const subscribe = this._state.stateUpdates$.subscribe(async (state) => {
|
|
146
|
+
if (state.findCompleted === true) {
|
|
147
|
+
subscribe.unsubscribe();
|
|
148
|
+
await this.ensureCompleteAsync();
|
|
149
|
+
resolve(this);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
async replaceAllWithAsync(replaceText) {
|
|
155
|
+
var _await$this$_model$re, _await$this$_model$re2, _this$_model4;
|
|
156
|
+
await this._state.changeState({
|
|
157
|
+
replaceRevealed: true,
|
|
158
|
+
replaceString: replaceText
|
|
159
|
+
});
|
|
160
|
+
const res = (_await$this$_model$re = (_await$this$_model$re2 = await ((_this$_model4 = this._model) === null || _this$_model4 === void 0 ? void 0 : _this$_model4.replaceAll())) === null || _await$this$_model$re2 === void 0 ? void 0 : _await$this$_model$re2.success) !== null && _await$this$_model$re !== void 0 ? _await$this$_model$re : 0;
|
|
161
|
+
this._state.changeState({ replaceRevealed: false });
|
|
162
|
+
return res;
|
|
163
|
+
}
|
|
164
|
+
async replaceWithAsync(replaceText) {
|
|
165
|
+
var _this$_model5;
|
|
166
|
+
await this._state.changeState({
|
|
167
|
+
replaceRevealed: true,
|
|
168
|
+
replaceString: replaceText
|
|
169
|
+
});
|
|
170
|
+
await ((_this$_model5 = this._model) === null || _this$_model5 === void 0 ? void 0 : _this$_model5.replace());
|
|
171
|
+
this._state.changeState({ replaceRevealed: false });
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
async ensureCompleteAsync() {
|
|
175
|
+
var _this$_model6;
|
|
176
|
+
this._complete = await ((_this$_model6 = this._model) === null || _this$_model6 === void 0 ? void 0 : _this$_model6.start());
|
|
177
|
+
}
|
|
178
|
+
_findMatchToFRange(match) {
|
|
179
|
+
const { unitId } = match;
|
|
180
|
+
const { subUnitId, range } = match.range;
|
|
181
|
+
const workbook = this._univerInstanceService.getUnit(unitId);
|
|
182
|
+
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
183
|
+
return this._injector.createInstance(_univerjs_sheets_facade.FRange, workbook, worksheet, range);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
FTextFinder = __decorate([
|
|
187
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
188
|
+
__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
189
|
+
__decorateParam(3, _univerjs_find_replace.IFindReplaceService)
|
|
190
|
+
], FTextFinder);
|
|
191
|
+
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/facade/f-univer.ts
|
|
194
|
+
var FUniverSheetsFindReplaceMixin = class extends _univerjs_core_facade.FUniver {
|
|
195
|
+
async createTextFinderAsync(text) {
|
|
196
|
+
const state = { findString: text };
|
|
197
|
+
const textFinder = this._injector.createInstance(FTextFinder, state);
|
|
198
|
+
await textFinder.ensureCompleteAsync();
|
|
199
|
+
return textFinder;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
_univerjs_core_facade.FUniver.extend(FUniverSheetsFindReplaceMixin);
|
|
203
|
+
|
|
204
|
+
//#endregion
|