@univerjs/find-replace 0.1.12 → 0.1.13-nightly.202406041140
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/index.js +2 -2
- package/lib/es/index.js +150 -295
- package/lib/locale/en-US.json +48 -0
- package/lib/locale/ru-RU.json +48 -0
- package/lib/locale/zh-CN.json +48 -0
- package/lib/types/index.d.ts +0 -1
- package/lib/types/locale/en-US.d.ts +3 -63
- package/lib/umd/index.js +2 -2
- package/package.json +16 -15
- package/LICENSE +0 -176
- package/lib/types/locale/index.d.ts +0 -18
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"find-replace": {
|
|
3
|
+
"toolbar": "Find & Replace",
|
|
4
|
+
"shortcut": {
|
|
5
|
+
"open-find-dialog": "Open Find Dialog",
|
|
6
|
+
"open-replace-dialog": "Open Replace Dialog",
|
|
7
|
+
"close-dialog": "Close Find & Replace Dialog",
|
|
8
|
+
"go-to-next-match": "Go to Next Match",
|
|
9
|
+
"go-to-previous-match": "Go to Previous Match"
|
|
10
|
+
},
|
|
11
|
+
"dialog": {
|
|
12
|
+
"title": "Find",
|
|
13
|
+
"find": "Find",
|
|
14
|
+
"replace": "Replace",
|
|
15
|
+
"replace-all": "Replace All",
|
|
16
|
+
"case-sensitive": "Case Sensitive",
|
|
17
|
+
"find-placeholder": "Find in this Sheet",
|
|
18
|
+
"advanced-finding": "Advanced Searching & Replace",
|
|
19
|
+
"replace-placeholder": "Input Replace String",
|
|
20
|
+
"match-the-whole-cell": "Match the Whole Cell",
|
|
21
|
+
"find-direction": {
|
|
22
|
+
"title": "Find Direction",
|
|
23
|
+
"row": "Search by Row",
|
|
24
|
+
"column": "Search by Column"
|
|
25
|
+
},
|
|
26
|
+
"find-scope": {
|
|
27
|
+
"title": "Find Range",
|
|
28
|
+
"current-sheet": "Current Sheet",
|
|
29
|
+
"workbook": "Workbook"
|
|
30
|
+
},
|
|
31
|
+
"find-by": {
|
|
32
|
+
"title": "Find By",
|
|
33
|
+
"value": "Find by Value",
|
|
34
|
+
"formula": "Find Formula"
|
|
35
|
+
},
|
|
36
|
+
"no-match": "Finding completed but no match found.",
|
|
37
|
+
"no-result": "No Result"
|
|
38
|
+
},
|
|
39
|
+
"replace": {
|
|
40
|
+
"all-success": "Replaced all {0} matches",
|
|
41
|
+
"all-failure": "Replace failed",
|
|
42
|
+
"confirm": {
|
|
43
|
+
"title": "Are you sure to replace all matches?"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"find-replace-shortcuts": "Find & Replace"
|
|
48
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"find-replace": {
|
|
3
|
+
"toolbar": "Найти и заменить",
|
|
4
|
+
"shortcut": {
|
|
5
|
+
"open-find-dialog": "Открыть диалог поиска",
|
|
6
|
+
"open-replace-dialog": "Открыть диалог замены",
|
|
7
|
+
"close-dialog": "Закрыть диалог поиска и замены",
|
|
8
|
+
"go-to-next-match": "Перейти к следующему совпадению",
|
|
9
|
+
"go-to-previous-match": "Перейти к предыдущему совпадению"
|
|
10
|
+
},
|
|
11
|
+
"dialog": {
|
|
12
|
+
"title": "Найти",
|
|
13
|
+
"find": "Найти",
|
|
14
|
+
"replace": "Заменить",
|
|
15
|
+
"replace-all": "Заменить все",
|
|
16
|
+
"case-sensitive": "С учетом регистра",
|
|
17
|
+
"find-placeholder": "Найти в этом листе",
|
|
18
|
+
"advanced-finding": "Расширенный поиск и замена",
|
|
19
|
+
"replace-placeholder": "Введите строку для замены",
|
|
20
|
+
"match-the-whole-cell": "Точное совпадение",
|
|
21
|
+
"find-direction": {
|
|
22
|
+
"title": "Направление поиска",
|
|
23
|
+
"row": "Поиск по строкам",
|
|
24
|
+
"column": "Поиск по столбцам"
|
|
25
|
+
},
|
|
26
|
+
"find-scope": {
|
|
27
|
+
"title": "Область поиска",
|
|
28
|
+
"current-sheet": "Текущий лист",
|
|
29
|
+
"workbook": "Книга"
|
|
30
|
+
},
|
|
31
|
+
"find-by": {
|
|
32
|
+
"title": "Поиск по",
|
|
33
|
+
"value": "Поиск по значению",
|
|
34
|
+
"formula": "Поиск по формуле"
|
|
35
|
+
},
|
|
36
|
+
"no-match": "Поиск завершен, совпадений не найдено.",
|
|
37
|
+
"no-result": "Нет результатов"
|
|
38
|
+
},
|
|
39
|
+
"replace": {
|
|
40
|
+
"all-success": "Заменены все {0} совпадений",
|
|
41
|
+
"all-failure": "Не удалось заменить",
|
|
42
|
+
"confirm": {
|
|
43
|
+
"title": "Вы уверены, что хотите заменить все совпадения?"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"find-replace-shortcuts": "Найти и заменить"
|
|
48
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"find-replace": {
|
|
3
|
+
"toolbar": "查找替换",
|
|
4
|
+
"shortcut": {
|
|
5
|
+
"open-find-dialog": "打开查找对话框",
|
|
6
|
+
"open-replace-dialog": "打开替换对话框",
|
|
7
|
+
"close-dialog": "关闭查找替换对话框",
|
|
8
|
+
"go-to-next-match": "下一个匹配项",
|
|
9
|
+
"go-to-previous-match": "下一个匹配项"
|
|
10
|
+
},
|
|
11
|
+
"dialog": {
|
|
12
|
+
"title": "查找",
|
|
13
|
+
"find": "查找",
|
|
14
|
+
"replace": "替换",
|
|
15
|
+
"replace-all": "替换全部",
|
|
16
|
+
"find-placeholder": "输入查找内容",
|
|
17
|
+
"advanced-finding": "替换 / 高级查找",
|
|
18
|
+
"replace-placeholder": "输入替换内容",
|
|
19
|
+
"case-sensitive": "匹配大小写",
|
|
20
|
+
"match-the-whole-cell": "匹配整个单元格",
|
|
21
|
+
"find-scope": {
|
|
22
|
+
"title": "查找范围",
|
|
23
|
+
"current-sheet": "当前子表",
|
|
24
|
+
"workbook": "整个工作簿"
|
|
25
|
+
},
|
|
26
|
+
"find-direction": {
|
|
27
|
+
"title": "查找顺序",
|
|
28
|
+
"column": "按列查找",
|
|
29
|
+
"row": "按行查找"
|
|
30
|
+
},
|
|
31
|
+
"find-by": {
|
|
32
|
+
"title": "查找方式",
|
|
33
|
+
"formula": "查找公式",
|
|
34
|
+
"value": "查找值"
|
|
35
|
+
},
|
|
36
|
+
"no-match": "已完成搜索,但是未找到任何匹配项",
|
|
37
|
+
"no-result": "无结果"
|
|
38
|
+
},
|
|
39
|
+
"replace": {
|
|
40
|
+
"all-success": "已全部替换 {0} 个匹配项",
|
|
41
|
+
"all-failure": "替换失败",
|
|
42
|
+
"confirm": {
|
|
43
|
+
"title": "确定要替换所有的匹配项吗?"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"find-replace-shortcuts": "查找替换"
|
|
48
|
+
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -17,4 +17,3 @@ export { UniverFindReplacePlugin } from './plugin';
|
|
|
17
17
|
export { FindReplaceController } from './controllers/find-replace.controller';
|
|
18
18
|
export type { IFindComplete, IFindMoveParams, IFindMatch, IFindQuery, IFindReplaceProvider, IReplaceAllResult, } from './services/find-replace.service';
|
|
19
19
|
export { FindModel, IFindReplaceService, FindBy, FindScope, FindDirection } from './services/find-replace.service';
|
|
20
|
-
export { enUS, zhCN, ruRU } from './locale';
|
|
@@ -1,64 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
declare const locale: {
|
|
17
|
-
'find-replace': {
|
|
18
|
-
toolbar: string;
|
|
19
|
-
shortcut: {
|
|
20
|
-
'open-find-dialog': string;
|
|
21
|
-
'open-replace-dialog': string;
|
|
22
|
-
'close-dialog': string;
|
|
23
|
-
'go-to-next-match': string;
|
|
24
|
-
'go-to-previous-match': string;
|
|
25
|
-
};
|
|
26
|
-
dialog: {
|
|
27
|
-
title: string;
|
|
28
|
-
find: string;
|
|
29
|
-
replace: string;
|
|
30
|
-
'replace-all': string;
|
|
31
|
-
'case-sensitive': string;
|
|
32
|
-
'find-placeholder': string;
|
|
33
|
-
'advanced-finding': string;
|
|
34
|
-
'replace-placeholder': string;
|
|
35
|
-
'match-the-whole-cell': string;
|
|
36
|
-
'find-direction': {
|
|
37
|
-
title: string;
|
|
38
|
-
row: string;
|
|
39
|
-
column: string;
|
|
40
|
-
};
|
|
41
|
-
'find-scope': {
|
|
42
|
-
title: string;
|
|
43
|
-
'current-sheet': string;
|
|
44
|
-
workbook: string;
|
|
45
|
-
};
|
|
46
|
-
'find-by': {
|
|
47
|
-
title: string;
|
|
48
|
-
value: string;
|
|
49
|
-
formula: string;
|
|
50
|
-
};
|
|
51
|
-
'no-match': string;
|
|
52
|
-
'no-result': string;
|
|
53
|
-
};
|
|
54
|
-
replace: {
|
|
55
|
-
'all-success': string;
|
|
56
|
-
'all-failure': string;
|
|
57
|
-
confirm: {
|
|
58
|
-
title: string;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
'find-replace-shortcuts': string;
|
|
63
|
-
};
|
|
1
|
+
import { default as zhCN } from './zh-CN';
|
|
2
|
+
|
|
3
|
+
declare const locale: typeof zhCN;
|
|
64
4
|
export default locale;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(l,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","@univerjs/engine-render","react","@univerjs/design","@wendellhu/redi/react-bindings"],r):(l=typeof globalThis<"u"?globalThis:l||self,r(l.UniverFindReplace={},l.UniverCore,l["@wendellhu/redi"],l.UniverUi,l.rxjs,l.UniverEngineRender,l.React,l.UniverDesign,l["@wendellhu/redi/react-bindings"]))})(this,function(l,r,m,f,C,ue,d,p,M){"use strict";var yt=Object.defineProperty;var Mt=(l,r,m)=>r in l?yt(l,r,{enumerable:!0,configurable:!0,writable:!0,value:m}):l[r]=m;var h=(l,r,m)=>(Mt(l,typeof r!="symbol"?r+"":r,m),m);var H;var b=function(){return b=Object.assign||function(n){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a])}return n},b.apply(this,arguments)},fe=function(n,e){var i={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.indexOf(t)<0&&(i[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,t=Object.getOwnPropertySymbols(n);a<t.length;a++)e.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(n,t[a])&&(i[t[a]]=n[t[a]]);return i},K=d.forwardRef(function(n,e){var i=n.icon,t=n.id,a=n.className,s=n.extend,o=fe(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(a||"").trim(),_=d.useRef("_".concat(ge()));return z(i,"".concat(t),{defIds:i.defIds,idSuffix:_.current},b({ref:e,className:c},o),s)});function z(n,e,i,t,a){return d.createElement(n.tag,b(b({key:e},pe(n,i,a)),t),(_e(n,i).children||[]).map(function(s,o){return z(s,"".concat(e,"-").concat(n.tag,"-").concat(o),i,void 0,a)}))}function pe(n,e,i){var t=b({},n.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1);var a=e.defIds;return!a||a.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(s){var o=s[0],c=s[1];typeof c=="string"&&(t[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function _e(n,e){var i,t=e.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?b(b({},n),{children:n.children.map(function(a){return typeof a.attrs.id=="string"&&t&&t.indexOf(a.attrs.id)>-1?b(b({},a),{attrs:b(b({},a.attrs),{id:a.attrs.id+e.idSuffix})}):a})}):n}function ge(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var me={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_217_40",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.9 0.09H16.9V16.09H0.9z"}}]},{tag:"g",attrs:{mask:"url(#mask0_217_40)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},Y=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"search-single-16",ref:e,icon:me}))});Y.displayName="SearchSingle16";const Z="FIND_REPLACE_INPUT_FOCUS",J="FIND_REPLACE_DIALOG_FOCUS",Q="FIND_REPLACE_REPLACE_REVEALED";var ve=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,X=(n,e,i,t)=>{for(var a=t>1?void 0:t?Se(e,i):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(a=(t?o(e,i,a):o(a))||a);return t&&a&&ve(e,i,a),a},x=(n,e)=>(i,t)=>e(i,t,n);class Ce extends r.Disposable{}const y=m.createIdentifier("find-replace.service");function Re(n){return typeof n.findString<"u"||typeof n.inputtingFindString<"u"||typeof n.findDirection<"u"||typeof n.matchesTheWholeCell<"u"||typeof n.caseSensitive<"u"||typeof n.findScope<"u"||typeof n.findBy<"u"}let U=class extends r.Disposable{constructor(e,i,t,a){super();h(this,"currentMatch$",new C.BehaviorSubject(null));h(this,"replaceables$",new C.BehaviorSubject([]));h(this,"_findModels",[]);h(this,"_matchingModel",null);h(this,"_matches",[]);h(this,"_currentSearchingDisposables",null);this._state=e,this._providers=i,this._univerInstanceService=t,this._logService=a,this.disposeWithMe(this._state.stateUpdates$.pipe(C.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async s=>{const o=this._state.state;Re(s)&&(o.findString!==""&&!o.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):s.replaceRevealed!==!0&&this._stopSearching())}))}get searched(){return this._findModels.length>0}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...B(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const e=await this._startSearching();return this._state.changeState({findCompleted:!0}),e}async _startSearching(){if(!this._state.findString)return{results:[]};const e=Array.from(this._providers),i=this._findModels=(await Promise.all(e.map(s=>s.find({findString:this._state.findString,findDirection:this._state.findDirection,findScope:this._state.findScope,findBy:this._state.findBy,replaceRevealed:this._state.replaceRevealed,caseSensitive:this._state.caseSensitive,matchesTheWholeCell:this._state.matchesTheWholeCell})))).flat();this._subscribeToModelsChanges(i);const t=this._matches=i.map(s=>s.getMatches()).flat();if(this.replaceables$.next(t.filter(s=>s.replaceable)),!t.length)return this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]};const a=this._moveToInitialMatch(i,t);return this._state.changeState({matchesCount:t.length,matchesPosition:a+1}),{results:t}}_stopSearching(){var e;this._providers.forEach(i=>i.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(e=this._currentSearchingDisposables)==null||e.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(e){const i=this._currentSearchingDisposables=new r.DisposableCollection,t=C.combineLatest(e.map(a=>a.matchesUpdate$)).pipe(C.debounceTime(220)).subscribe(([...a])=>{const s=this._matches=a.flat();if(s.length){const o=this._moveToInitialMatch(this._findModels,s,!0);this._state.changeState({matchesCount:s.length,matchesPosition:o+1}),this.replaceables$.next(s.filter(c=>c.replaceable))}else this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([])});e.forEach(a=>i.add(r.toDisposable(a.activelyChangingMatch$.subscribe(s=>{const o=this._matches.findIndex(c=>c===s);this._state.changeState({matchesPosition:o+1})})))),i.add(r.toDisposable(t))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const e=await Promise.all(this._findModels.map(i=>i.replaceAll(this._state.replaceString))).then(i=>i.reduce((t,a)=>(t.success+=a.success,t.failure+=a.failure,t),{success:0,failure:0}));return e.failure===0&&this._stopSearching(),e}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}moveToNextMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToNextMatch({loop:e});if(i){const t=this._matches.findIndex(a=>a===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:t+1})}else{const t=this._findModels.findIndex(c=>c===this._matchingModel),a=this._findModels[(t+1)%this._findModels.length],s=a.moveToNextMatch(),o=this._matches.findIndex(c=>c===s);this.currentMatch$.next(s),this._matchingModel=a,this._state.changeState({matchesPosition:o+1})}}moveToPreviousMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToPreviousMatch({loop:e});if(i){const t=this._matches.findIndex(a=>a===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:t+1})}else{const t=this._findModels.findIndex(c=>c===this._matchingModel),a=this._findModels[(t-1+this._findModels.length)%this._findModels.length],s=a.moveToPreviousMatch(),o=this._matches.findIndex(c=>c===s);this.currentMatch$.next(s),this._matchingModel=a,this._state.changeState({matchesPosition:o+1})}}_moveToInitialMatch(e,i,t=!1){var _;const a=(_=this._univerInstanceService.getFocusedUnit())==null?void 0:_.getUnitId();if(!a)return-1;const s=e.find(v=>v.unitId===a);if(s){this._matchingModel=s;const v=s.moveToNextMatch({stayIfOnMatch:!0,noFocus:t}),R=i.findIndex(S=>S===v);return this.currentMatch$.next(v),R}this._matchingModel=e[0];const o=this._matchingModel.moveToNextMatch({noFocus:t}),c=this._matches.findIndex(v=>v===o);return this.currentMatch$.next(o),c}};U=X([x(2,r.IUniverInstanceService),x(3,r.ILogService)],U);var O=(n=>(n.ROW="row",n.COLUMN="column",n))(O||{}),P=(n=>(n.VALUE="value",n.FORMULA="formula",n))(P||{}),T=(n=>(n.SUBUNIT="subunit",n.UNIT="unit",n))(T||{});function B(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class be{constructor(){h(this,"_stateUpdates$",new C.Subject);h(this,"stateUpdates$",this._stateUpdates$.asObservable());h(this,"_state$",new C.BehaviorSubject(B()));h(this,"state$",this._state$.asObservable());h(this,"_findString","");h(this,"_inputtingFindString","");h(this,"_replaceString","");h(this,"_revealed",!1);h(this,"_replaceRevealed",!1);h(this,"_matchesPosition",0);h(this,"_matchesCount",0);h(this,"_caseSensitive",!0);h(this,"_matchesTheWholeCell",!1);h(this,"_findDirection","row");h(this,"_findScope","subunit");h(this,"_findBy","value");h(this,"_findCompleted",!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let i=!1;const t={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,t.findString=this._findString,i=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,t.revealed=e.revealed,i=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,t.replaceRevealed=e.replaceRevealed,i=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,t.replaceString=e.replaceString,i=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,t.matchesCount=e.matchesCount,i=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,t.matchesPosition=e.matchesPosition,i=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,t.findBy=e.findBy,i=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,t.findScope=e.findScope,i=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,t.findDirection=e.findDirection,i=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,t.caseSensitive=e.caseSensitive,i=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,t.matchesTheWholeCell=e.matchesTheWholeCell,i=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,t.inputtingFindString=e.inputtingFindString,i=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,t.findCompleted=e.findCompleted,i=!0),i&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(t))}}let k=class extends r.Disposable{constructor(e,i){super();h(this,"_providers",new Set);h(this,"_state",new be);h(this,"_model");h(this,"_currentMatch$",new C.BehaviorSubject(null));h(this,"currentMatch$",this._currentMatch$.asObservable());h(this,"_replaceables$",new C.BehaviorSubject([]));h(this,"replaceables$",this._replaceables$.asObservable());h(this,"_focusSignal$",new C.Subject);h(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e==="formula")}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(U,this._state,this._providers),this._model.currentMatch$.subscribe(t=>this._currentMatch$.next(t)),this._model.replaceables$.subscribe(t=>this._replaceables$.next(t));const i=B();return e&&(i.replaceRevealed=!0),this._state.changeState(i),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),r.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(Q,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(ue.RENDER_RAW_FORMULA_KEY,e)}};k=X([x(0,m.Inject(m.Injector)),x(1,r.IContextService)],k);const E={id:"ui.operation.open-find-dialog",type:r.CommandType.OPERATION,handler:n=>{const e=n.get(y);return e.revealed?e.focusFindInput():e.start(),!0}},W={id:"ui.operation.open-replace-dialog",type:r.CommandType.OPERATION,handler:n=>{const e=n.get(y);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},q={type:r.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:n=>(n.get(y).moveToNextMatch(),!0)},ee={type:r.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:n=>(n.get(y).moveToPreviousMatch(),!0)};var te={exports:{}},N={};/**
|
|
1
|
+
(function(h,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","@univerjs/engine-render","react","@univerjs/design","@wendellhu/redi/react-bindings"],o):(h=typeof globalThis<"u"?globalThis:h||self,o(h.UniverFindReplace={},h.UniverCore,h["@wendellhu/redi"],h.UniverUi,h.rxjs,h.UniverEngineRender,h.React,h.UniverDesign,h["@wendellhu/redi/react-bindings"]))})(this,function(h,o,m,f,C,he,l,p,M){"use strict";var pt=Object.defineProperty;var _t=(h,o,m)=>o in h?pt(h,o,{enumerable:!0,configurable:!0,writable:!0,value:m}):h[o]=m;var d=(h,o,m)=>(_t(h,typeof o!="symbol"?o+"":o,m),m);var H;var y=function(){return y=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++){e=arguments[i];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},y.apply(this,arguments)},ue=function(t,e){var i={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(i[n[s]]=t[n[s]]);return i},$=l.forwardRef(function(t,e){var i=t.icon,n=t.id,s=t.className,a=t.extend,r=ue(t,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(s||"").trim(),_=l.useRef("_".concat(_e()));return z(i,"".concat(n),{defIds:i.defIds,idSuffix:_.current},y({ref:e,className:c},r),a)});function z(t,e,i,n,s){return l.createElement(t.tag,y(y({key:e},fe(t,i,s)),n),(pe(t,i).children||[]).map(function(a,r){return z(a,"".concat(e,"-").concat(t.tag,"-").concat(r),i,void 0,s)}))}function fe(t,e,i){var n=y({},t.attrs);i!=null&&i.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=i.colorChannel1);var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(a){var r=a[0],c=a[1];typeof c=="string"&&(n[r]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function pe(t,e){var i,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((i=t.children)===null||i===void 0)&&i.length)?y(y({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&n&&n.indexOf(s.attrs.id)>-1?y(y({},s),{attrs:y(y({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function _e(){return Math.random().toString(36).substring(2,8)}$.displayName="UniverIcon";var ge={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_217_40",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.9 0.09H16.9V16.09H0.9z"}}]},{tag:"g",attrs:{mask:"url(#mask0_217_40)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},Y=l.forwardRef(function(t,e){return l.createElement($,Object.assign({},t,{id:"search-single-16",ref:e,icon:ge}))});Y.displayName="SearchSingle16";const Z="FIND_REPLACE_INPUT_FOCUS",J="FIND_REPLACE_DIALOG_FOCUS",Q="FIND_REPLACE_REPLACE_REVEALED";var X=(t,e,i,n)=>{for(var s=e,a=t.length-1,r;a>=0;a--)(r=t[a])&&(s=r(s)||s);return s},D=(t,e)=>(i,n)=>e(i,n,t);class me extends o.Disposable{}const b=m.createIdentifier("find-replace.service");function ve(t){return typeof t.findString<"u"||typeof t.inputtingFindString<"u"||typeof t.findDirection<"u"||typeof t.matchesTheWholeCell<"u"||typeof t.caseSensitive<"u"||typeof t.findScope<"u"||typeof t.findBy<"u"}let U=class extends o.Disposable{constructor(e,i,n,s){super();d(this,"currentMatch$",new C.BehaviorSubject(null));d(this,"replaceables$",new C.BehaviorSubject([]));d(this,"_findModels",[]);d(this,"_matchingModel",null);d(this,"_matches",[]);d(this,"_currentSearchingDisposables",null);this._state=e,this._providers=i,this._univerInstanceService=n,this._logService=s,this.disposeWithMe(this._state.stateUpdates$.pipe(C.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async a=>{const r=this._state.state;ve(a)&&(r.findString!==""&&!r.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):a.replaceRevealed!==!0&&this._stopSearching())}))}get searched(){return this._findModels.length>0}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...k(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const e=await this._startSearching();return this._state.changeState({findCompleted:!0}),e}async _startSearching(){if(!this._state.findString)return{results:[]};const e=Array.from(this._providers),i=this._findModels=(await Promise.all(e.map(a=>a.find({findString:this._state.findString,findDirection:this._state.findDirection,findScope:this._state.findScope,findBy:this._state.findBy,replaceRevealed:this._state.replaceRevealed,caseSensitive:this._state.caseSensitive,matchesTheWholeCell:this._state.matchesTheWholeCell})))).flat();this._subscribeToModelsChanges(i);const n=this._matches=i.map(a=>a.getMatches()).flat();if(this.replaceables$.next(n.filter(a=>a.replaceable)),!n.length)return this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]};const s=this._moveToInitialMatch(i,n);return this._state.changeState({matchesCount:n.length,matchesPosition:s+1}),{results:n}}_stopSearching(){var e;this._providers.forEach(i=>i.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(e=this._currentSearchingDisposables)==null||e.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(e){const i=this._currentSearchingDisposables=new o.DisposableCollection,n=C.combineLatest(e.map(s=>s.matchesUpdate$)).pipe(C.debounceTime(220)).subscribe(([...s])=>{const a=this._matches=s.flat();if(a.length){const r=this._moveToInitialMatch(this._findModels,a,!0);this._state.changeState({matchesCount:a.length,matchesPosition:r+1}),this.replaceables$.next(a.filter(c=>c.replaceable))}else this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([])});e.forEach(s=>i.add(o.toDisposable(s.activelyChangingMatch$.subscribe(a=>{const r=this._matches.findIndex(c=>c===a);this._state.changeState({matchesPosition:r+1})})))),i.add(o.toDisposable(n))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const e=await Promise.all(this._findModels.map(i=>i.replaceAll(this._state.replaceString))).then(i=>i.reduce((n,s)=>(n.success+=s.success,n.failure+=s.failure,n),{success:0,failure:0}));return e.failure===0&&this._stopSearching(),e}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}moveToNextMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToNextMatch({loop:e});if(i){const n=this._matches.findIndex(s=>s===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:n+1})}else{const n=this._findModels.findIndex(c=>c===this._matchingModel),s=this._findModels[(n+1)%this._findModels.length],a=s.moveToNextMatch(),r=this._matches.findIndex(c=>c===a);this.currentMatch$.next(a),this._matchingModel=s,this._state.changeState({matchesPosition:r+1})}}moveToPreviousMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToPreviousMatch({loop:e});if(i){const n=this._matches.findIndex(s=>s===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:n+1})}else{const n=this._findModels.findIndex(c=>c===this._matchingModel),s=this._findModels[(n-1+this._findModels.length)%this._findModels.length],a=s.moveToPreviousMatch(),r=this._matches.findIndex(c=>c===a);this.currentMatch$.next(a),this._matchingModel=s,this._state.changeState({matchesPosition:r+1})}}_moveToInitialMatch(e,i,n=!1){var _;const s=(_=this._univerInstanceService.getFocusedUnit())==null?void 0:_.getUnitId();if(!s)return-1;const a=e.find(v=>v.unitId===s);if(a){this._matchingModel=a;const v=a.moveToNextMatch({stayIfOnMatch:!0,noFocus:n}),R=i.findIndex(S=>S===v);return this.currentMatch$.next(v),R}this._matchingModel=e[0];const r=this._matchingModel.moveToNextMatch({noFocus:n}),c=this._matches.findIndex(v=>v===r);return this.currentMatch$.next(r),c}};U=X([D(2,o.IUniverInstanceService),D(3,o.ILogService)],U);var T=(t=>(t.ROW="row",t.COLUMN="column",t))(T||{}),E=(t=>(t.VALUE="value",t.FORMULA="formula",t))(E||{}),O=(t=>(t.SUBUNIT="subunit",t.UNIT="unit",t))(O||{});function k(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class Se{constructor(){d(this,"_stateUpdates$",new C.Subject);d(this,"stateUpdates$",this._stateUpdates$.asObservable());d(this,"_state$",new C.BehaviorSubject(k()));d(this,"state$",this._state$.asObservable());d(this,"_findString","");d(this,"_inputtingFindString","");d(this,"_replaceString","");d(this,"_revealed",!1);d(this,"_replaceRevealed",!1);d(this,"_matchesPosition",0);d(this,"_matchesCount",0);d(this,"_caseSensitive",!0);d(this,"_matchesTheWholeCell",!1);d(this,"_findDirection","row");d(this,"_findScope","subunit");d(this,"_findBy","value");d(this,"_findCompleted",!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let i=!1;const n={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,n.findString=this._findString,i=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,n.revealed=e.revealed,i=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,n.replaceRevealed=e.replaceRevealed,i=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,n.replaceString=e.replaceString,i=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,n.matchesCount=e.matchesCount,i=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,n.matchesPosition=e.matchesPosition,i=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,n.findBy=e.findBy,i=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,n.findScope=e.findScope,i=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,n.findDirection=e.findDirection,i=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,n.caseSensitive=e.caseSensitive,i=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,n.matchesTheWholeCell=e.matchesTheWholeCell,i=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,n.inputtingFindString=e.inputtingFindString,i=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,n.findCompleted=e.findCompleted,i=!0),i&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(n))}}let B=class extends o.Disposable{constructor(e,i){super();d(this,"_providers",new Set);d(this,"_state",new Se);d(this,"_model");d(this,"_currentMatch$",new C.BehaviorSubject(null));d(this,"currentMatch$",this._currentMatch$.asObservable());d(this,"_replaceables$",new C.BehaviorSubject([]));d(this,"replaceables$",this._replaceables$.asObservable());d(this,"_focusSignal$",new C.Subject);d(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e==="formula")}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(U,this._state,this._providers),this._model.currentMatch$.subscribe(n=>this._currentMatch$.next(n)),this._model.replaceables$.subscribe(n=>this._replaceables$.next(n));const i=k();return e&&(i.replaceRevealed=!0),this._state.changeState(i),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),o.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(Q,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(he.RENDER_RAW_FORMULA_KEY,e)}};B=X([D(0,m.Inject(m.Injector)),D(1,o.IContextService)],B);const P={id:"ui.operation.open-find-dialog",type:o.CommandType.OPERATION,handler:t=>{const e=t.get(b);return e.revealed?e.focusFindInput():e.start(),!0}},W={id:"ui.operation.open-replace-dialog",type:o.CommandType.OPERATION,handler:t=>{const e=t.get(b);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},q={type:o.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(b).moveToNextMatch(),!0)},ee={type:o.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(b).moveToPreviousMatch(),!0)};var te={exports:{}},N={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var ye=d,Me=Symbol.for("react.element"),Fe=Symbol.for("react.fragment"),Ie=Object.prototype.hasOwnProperty,De=ye.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,xe={key:!0,ref:!0,__self:!0,__source:!0};function ne(n,e,i){var t,a={},s=null,o=null;i!==void 0&&(s=""+i),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(t in e)Ie.call(e,t)&&!xe.hasOwnProperty(t)&&(a[t]=e[t]);if(n&&n.defaultProps)for(t in e=n.defaultProps,e)a[t]===void 0&&(a[t]=e[t]);return{$$typeof:Me,type:n,key:s,ref:o,props:a,_owner:De.current}}N.Fragment=Fe,N.jsx=ne,N.jsxs=ne,te.exports=N;var u=te.exports;const ie={id:"ui.command.replace-current-match",type:r.CommandType.COMMAND,handler:n=>n.get(y).replace()},Oe="CONFIRM_REPLACE_ALL",ae={id:"ui.command.replace-all-matches",type:r.CommandType.COMMAND,handler:async n=>{const e=n.get(f.IConfirmService),i=n.get(r.LocaleService),t=n.get(f.IMessageService);if(!await e.confirm({id:Oe,title:{title:i.t("find-replace.replace.confirm.title")},cancelText:i.t("button.cancel"),confirmText:i.t("button.confirm")}))return!1;const s=await n.get(y).replaceAll(),{success:o,failure:c}=s;return c>0?(o===0?t.show({type:p.MessageType.Error,content:i.t("find-replace.replace.all-failure")}):t.show({type:p.MessageType.Warning,content:i.t("find-replace.replace.partial-success",`${o}`,`${c}`)}),!1):(t.show({type:p.MessageType.Success,content:i.t("find-replace.replace.all-success",`${o}`)}),!0)}};function se(n){const{findCompleted:e,localeService:i,matchesCount:t,matchesPosition:a,findString:s,findReplaceService:o,onChange:c,..._}=n,R=e&&t===0?i.t("find-replace.dialog.no-result"):t===0?" ":void 0;return u.jsx(p.InputWithSlot,{autoFocus:!0,placeholder:i.t("find-replace.dialog.find-placeholder"),slot:u.jsx(p.Pager,{loop:!0,text:R,value:a,total:t,onChange:S=>{a===t&&S===1?o.moveToNextMatch():a===1&&S===t||S<a?o.moveToPreviousMatch():o.moveToNextMatch()}}),value:s,onChange:S=>c==null?void 0:c(S),..._})}const w={findReplaceDialogContainer:"univer-find-replace-dialog-container",findReplaceExpandContainer:"univer-find-replace-expand-container",buttonText:"univer-button-text",findReplaceButtonsGroup:"univer-find-replace-buttons-group",findReplaceButtonsGroupRight:"univer-find-replace-buttons-group-right"};function oe(n,e){const i=d.useCallback(()=>{var a;(a=document.querySelector(".univer-find-input input"))==null||a.focus()},[]),t=d.useCallback(()=>{const a=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(a).some(s=>s===document.activeElement)},[]);return d.useImperativeHandle(e,()=>({focus:i,selectHasFocus:t})),d.useEffect(()=>{const a=n.focusSignal$.subscribe(()=>i());return()=>a.unsubscribe()},[n,i]),{focus:i,selectHasFocus:t}}const Pe=d.forwardRef(function(e,i){const t=M.useDependency(r.LocaleService),a=M.useDependency(y),s=M.useDependency(r.ICommandService),o=f.useObservable(a.state$,void 0,!0),{findCompleted:c,findString:_,matchesCount:v,matchesPosition:R}=o,S=d.useCallback(()=>{s.executeCommand(W.id)},[s]),L=d.useCallback(I=>a.changeFindString(I),[a]);return oe(a,i),u.jsxs(d.Fragment,{children:[u.jsx(se,{findCompleted:c,className:"univer-find-input",matchesCount:v,matchesPosition:R,findReplaceService:a,localeService:t,findString:_,onChange:L}),u.jsx("div",{className:w.findReplaceExpandContainer,children:u.jsx(p.Button,{type:"text",size:"small",onClick:S,children:t.t("find-replace.dialog.advanced-finding")})})]})}),Te=d.forwardRef(function(e,i){const t=M.useDependency(y),a=M.useDependency(r.LocaleService),s=M.useDependency(r.ICommandService),o=M.useDependency(f.IMessageService),c=f.useObservable(t.currentMatch$,void 0,!0),_=f.useObservable(t.replaceables$,void 0,!0),v=f.useObservable(t.state$,void 0,!0),{matchesCount:R,matchesPosition:S,findString:L,inputtingFindString:I,replaceString:nt,caseSensitive:it,matchesTheWholeCell:at,findDirection:st,findScope:ot,findBy:rt,findCompleted:$}=v,ct=I.length===0,lt=R===0||!(c!=null&&c.replaceable),dt=_.length===0,ht=d.useCallback(g=>t.changeInputtingFindString(g),[t]),ut=d.useCallback(g=>t.changeReplaceString(g),[t]),{focus:ft}=oe(t,i),pt=d.useCallback(()=>{L===I?t.moveToNextMatch():(t.changeFindString(I),t.find())},[L,I,t]),_t=d.useCallback(()=>s.executeCommand(ie.id),[s]),gt=d.useCallback(async()=>{await s.executeCommand(ae.id),ft()},[s]),mt=d.useCallback(g=>{t.changeFindDirection(g)},[t]),vt=d.useCallback(g=>{t.changeFindScope(g)},[t]),St=d.useCallback(g=>{t.changeFindBy(g)},[t]),Ct=Ne(a),Rt=we(a),bt=je(a);return d.useEffect(()=>{const g=$&&R===0;let A=null;return g&&(A=o.show({content:a.t("find-replace.dialog.no-match"),type:p.MessageType.Warning,delay:5e3})),()=>A==null?void 0:A.dispose()},[$,R,o,a]),u.jsxs(d.Fragment,{children:[u.jsx(p.FormLayout,{label:a.t("find-replace.dialog.find"),children:u.jsx(se,{findCompleted:$,className:"univer-find-input",matchesCount:R,matchesPosition:S,findReplaceService:t,localeService:a,findString:I,onChange:ht})}),u.jsx(p.FormLayout,{label:a.t("find-replace.dialog.replace"),children:u.jsx(p.Input,{placeholder:a.t("find-replace.dialog.replace-placeholder"),value:nt,onChange:g=>ut(g)})}),u.jsx(p.FormLayout,{label:a.t("find-replace.dialog.find-direction.title"),children:u.jsx(p.Select,{value:st,options:Rt,onChange:mt})}),u.jsx(p.FormDualColumnLayout,{children:u.jsxs(d.Fragment,{children:[u.jsx(p.FormLayout,{label:a.t("find-replace.dialog.find-scope.title"),children:u.jsx(p.Select,{value:ot,options:Ct,onChange:vt})}),u.jsx(p.FormLayout,{label:a.t("find-replace.dialog.find-by.title"),children:u.jsx(p.Select,{value:rt,options:bt,onChange:St})})]})}),u.jsx(p.FormDualColumnLayout,{children:u.jsxs(d.Fragment,{children:[u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:it,onChange:g=>{t.changeCaseSensitive(g)},children:a.t("find-replace.dialog.case-sensitive")})}),u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:at,onChange:g=>{t.changeMatchesTheWholeCell(g)},children:a.t("find-replace.dialog.match-the-whole-cell")})})]})}),u.jsxs("div",{className:w.findReplaceButtonsGroup,children:[u.jsx(p.Button,{type:"primary",onClick:pt,disabled:ct,children:a.t("find-replace.dialog.find")}),u.jsxs("span",{className:w.findReplaceButtonsGroupRight,children:[u.jsx(p.Button,{disabled:lt,onClick:_t,children:a.t("find-replace.dialog.replace")}),u.jsx(p.Button,{disabled:dt,onClick:gt,children:a.t("find-replace.dialog.replace-all")})]})]})]})});function Ee(){const n=M.useDependency(y),e=M.useDependency(f.ILayoutService),i=M.useDependency(r.IContextService),t=f.useObservable(n.state$,void 0,!0),a=d.useRef(null);d.useEffect(()=>{let _;return a.current&&(_=e.registerContainerElement(a.current)),()=>_==null?void 0:_.dispose()},[e]);const s=d.useRef(null),o=d.useCallback(_=>i.setContextValue(J,_),[i]),c=d.useCallback(_=>i.setContextValue(Z,_),[i]);return d.useEffect(()=>{var v;const _=C.fromEvent(document,"focusin").subscribe(R=>{var S;R.target&&((S=a.current)!=null&&S.contains(R.target))?o(!0):o(!1),!s.current||!s.current.selectHasFocus()?c(!0):c(!1)});return(v=s.current)==null||v.focus(),o(!0),c(!0),()=>{_.unsubscribe(),o(!1)}},[o,c]),u.jsx("div",{className:w.findReplaceDialogContainer,ref:a,children:t.replaceRevealed?u.jsx(Te,{ref:s}):u.jsx(Pe,{ref:s})})}function Ne(n){const e=n.getCurrentLocale();return d.useMemo(()=>[{label:n.t("find-replace.dialog.find-scope.current-sheet"),value:T.SUBUNIT},{label:n.t("find-replace.dialog.find-scope.workbook"),value:T.UNIT}],[e])}function we(n){const e=n.getCurrentLocale();return d.useMemo(()=>[{label:n.t("find-replace.dialog.find-direction.row"),value:O.ROW},{label:n.t("find-replace.dialog.find-direction.column"),value:O.COLUMN}],[e])}function je(n){const e=n.getCurrentLocale();return d.useMemo(()=>[{label:n.t("find-replace.dialog.find-by.value"),value:P.VALUE},{label:n.t("find-replace.dialog.find-by.formula"),value:P.FORMULA}],[e])}function D(n){return n.getContextValue(J)}function Le(n){return n.getContextValue(Q)}function re(n){return n.getContextValue(Z)}const j="7_find-replace-shortcuts";function G(n){return n.getContextValue(r.FOCUSING_SHEET)}function V(n){return!n.getContextValue(r.EDITOR_ACTIVATED)}const Ae={id:E.id,description:"find-replace.shortcut.open-find-dialog",binding:f.KeyCode.F|f.MetaKeys.CTRL_COMMAND,group:j,preconditions(n){return!D(n)&&G(n)&&V(n)}},Ue={id:E.id,description:"find-replace.shortcut.open-find-dialog",binding:f.KeyCode.F|f.MetaKeys.CTRL_COMMAND,mac:f.KeyCode.F|f.MetaKeys.MAC_CTRL,preconditions(n){return!D(n)&&G(n)&&V(n)}},Be={id:W.id,description:"find-replace.shortcut.open-replace-dialog",binding:f.KeyCode.H|f.MetaKeys.CTRL_COMMAND,mac:f.KeyCode.H|f.MetaKeys.MAC_CTRL,group:j,preconditions(n){return G(n)&&V(n)&&(!D(n)||!Le(n))}},ke={id:q.id,description:"find-replace.shortcut.go-to-next-match",binding:f.KeyCode.ENTER,group:j,priority:1e3,preconditions(n){return re(n)&&D(n)}},We={id:ee.id,description:"find-replace.shortcut.go-to-previous-match",binding:f.KeyCode.ENTER|f.MetaKeys.SHIFT,group:j,priority:1e3,preconditions(n){return re(n)&&D(n)}};function Ge(n){const e=n.get(r.IContextService);return{id:E.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",group:f.MenuGroup.TOOLBAR_OTHERS,type:f.MenuItemType.BUTTON,positions:[f.MenuPosition.TOOLBAR_START],hidden$:f.getMenuHiddenObservable(n,r.UniverInstanceType.UNIVER_SHEET),disabled$:C.combineLatest([e.subscribeContextValue$(r.EDITOR_ACTIVATED),e.subscribeContextValue$(r.FOCUSING_SHEET)]).pipe(C.map(([i,t])=>i||!t))}}var Ve=Object.defineProperty,He=Object.getOwnPropertyDescriptor,$e=(n,e,i,t)=>{for(var a=t>1?void 0:t?He(e,i):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(a=(t?o(e,i,a):o(a))||a);return t&&a&&Ve(e,i,a),a},F=(n,e)=>(i,t)=>e(i,t,n);const Ke={},ce="DESKTOP_FIND_REPLACE_DIALOG",le=350,ze=20,Ye=-90;l.FindReplaceController=class extends r.RxDisposable{constructor(e,i,t,a,s,o,c,_,v,R,S){super(),this._config=e,this._univerInstanceService=i,this._menuService=t,this._shortcutService=a,this._commandService=s,this._findReplaceService=o,this._dialogService=c,this._layoutService=_,this._localeService=v,this._componentManager=R,this._injector=S,this._initCommands(),this._initUI(),this._initShortcuts()}_initCommands(){[E,W,q,ee,ae,ie].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initShortcuts(){[Be,Ae,Ue,We,ke].forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}_initUI(){const{menu:e={}}=this._config;this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(Ge),e)),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",Ee)),this.disposeWithMe(this._componentManager.register("SearchIcon",Y)),this._findReplaceService.stateUpdates$.pipe(C.takeUntil(this.dispose$)).subscribe(i=>{i.revealed===!0&&this._openPanel()}),this.disposeWithMe(this._univerInstanceService.focused$.pipe(C.takeUntil(this.dispose$)).subscribe(i=>{(!i||!this._univerInstanceService.getUniverSheetInstance(i))&&this.closePanel()}))}_openPanel(){this._dialogService.open({id:ce,draggable:!0,width:le,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:Ze(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()})}closePanel(){this._dialogService.close(ce),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus())}},l.FindReplaceController=$e([r.OnLifecycle(r.LifecycleStages.Rendered,l.FindReplaceController),F(1,r.IUniverInstanceService),F(2,f.IMenuService),F(3,f.IShortcutService),F(4,r.ICommandService),F(5,y),F(6,f.IDialogService),F(7,f.ILayoutService),F(8,m.Inject(r.LocaleService)),F(9,m.Inject(f.ComponentManager)),F(10,m.Inject(m.Injector))],l.FindReplaceController);function Ze(){const{innerWidth:n}=window;return{x:(n-le)/2-ze,y:Ye}}const Je={"find-replace":{toolbar:"Find & Replace",shortcut:{"open-find-dialog":"Open Find Dialog","open-replace-dialog":"Open Replace Dialog","close-dialog":"Close Find & Replace Dialog","go-to-next-match":"Go to Next Match","go-to-previous-match":"Go to Previous Match"},dialog:{title:"Find",find:"Find",replace:"Replace","replace-all":"Replace All","case-sensitive":"Case Sensitive","find-placeholder":"Find in this Sheet","advanced-finding":"Advanced Searching & Replace","replace-placeholder":"Input Replace String","match-the-whole-cell":"Match the Whole Cell","find-direction":{title:"Find Direction",row:"Search by Row",column:"Search by Column"},"find-scope":{title:"Find Range","current-sheet":"Current Sheet",workbook:"Workbook"},"find-by":{title:"Find By",value:"Find by Value",formula:"Find Formula"},"no-match":"Finding completed but no match found.","no-result":"No Result"},replace:{"all-success":"Replaced all {0} matches","all-failure":"Replace failed",confirm:{title:"Are you sure to replace all matches?"}}},"find-replace-shortcuts":"Find & Replace"},de={"find-replace":{toolbar:"查找替换",shortcut:{"open-find-dialog":"打开查找对话框","open-replace-dialog":"打开替换对话框","close-dialog":"关闭查找替换对话框","go-to-next-match":"下一个匹配项","go-to-previous-match":"下一个匹配项"},dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容","case-sensitive":"匹配大小写","match-the-whole-cell":"匹配整个单元格","find-scope":{title:"查找范围","current-sheet":"当前子表",workbook:"整个工作簿"},"find-direction":{title:"查找顺序",column:"按列查找",row:"按行查找"},"find-by":{title:"查找方式",formula:"查找公式",value:"查找值"},"no-match":"已完成搜索,但是未找到任何匹配项","no-result":"无结果"},replace:{"all-success":"已全部替换 {0} 个匹配项","all-failure":"替换失败",confirm:{title:"确定要替换所有的匹配项吗?"}}},"find-replace-shortcuts":"查找替换"},Qe={"find-replace":{toolbar:"Найти и заменить",shortcut:{"open-find-dialog":"Открыть диалог поиска","open-replace-dialog":"Открыть диалог замены","close-dialog":"Закрыть диалог поиска и замены","go-to-next-match":"Перейти к следующему совпадению","go-to-previous-match":"Перейти к предыдущему совпадению"},dialog:{title:"Найти",find:"Найти",replace:"Заменить","replace-all":"Заменить все","case-sensitive":"С учетом регистра","find-placeholder":"Найти в этом листе","advanced-finding":"Расширенный поиск и замена","replace-placeholder":"Введите строку для замены","match-the-whole-cell":"Точное совпадение","find-direction":{title:"Направление поиска",row:"Поиск по строкам",column:"Поиск по столбцам"},"find-scope":{title:"Область поиска","current-sheet":"Текущий лист",workbook:"Книга"},"find-by":{title:"Поиск по",value:"Поиск по значению",formula:"Поиск по формуле"},"no-match":"Поиск завершен, совпадений не найдено.","no-result":"Нет результатов"},replace:{"all-success":"Заменены все {0} совпадений","all-failure":"Не удалось заменить",confirm:{title:"Вы уверены, что хотите заменить все совпадения?"}}},"find-replace-shortcuts":"Найти и заменить"};var Xe=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,et=(n,e,i,t)=>{for(var a=t>1?void 0:t?qe(e,i):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(a=(t?o(e,i,a):o(a))||a);return t&&a&&Xe(e,i,a),a},he=(n,e)=>(i,t)=>e(i,t,n);const tt="FIND_REPLACE_PLUGIN";l.UniverFindReplacePlugin=(H=class extends r.Plugin{constructor(e={},i,t){super(),this._config=e,this._injector=i,this._localeService=t,this._localeService.load({zhCN:de}),this._config=r.Tools.deepMerge({},Ke,this._config)}onStarting(e){[[l.FindReplaceController,{useFactory:()=>this._injector.createInstance(l.FindReplaceController,this._config)}],[y,{useClass:k}]].forEach(i=>{e.add(i)})}},h(H,"pluginName",tt),H),l.UniverFindReplacePlugin=et([he(1,m.Inject(m.Injector)),he(2,m.Inject(r.LocaleService))],l.UniverFindReplacePlugin),l.FindBy=P,l.FindDirection=O,l.FindModel=Ce,l.FindScope=T,l.IFindReplaceService=y,l.enUS=Je,l.ruRU=Qe,l.zhCN=de,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
9
|
+
*/var Ce=l,Re=Symbol.for("react.element"),ye=Symbol.for("react.fragment"),be=Object.prototype.hasOwnProperty,Me=Ce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ie={key:!0,ref:!0,__self:!0,__source:!0};function ne(t,e,i){var n,s={},a=null,r=null;i!==void 0&&(a=""+i),e.key!==void 0&&(a=""+e.key),e.ref!==void 0&&(r=e.ref);for(n in e)be.call(e,n)&&!Ie.hasOwnProperty(n)&&(s[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps,e)s[n]===void 0&&(s[n]=e[n]);return{$$typeof:Re,type:t,key:a,ref:r,props:s,_owner:Me.current}}N.Fragment=ye,N.jsx=ne,N.jsxs=ne,te.exports=N;var u=te.exports;const ie={id:"ui.command.replace-current-match",type:o.CommandType.COMMAND,handler:t=>t.get(b).replace()},Fe="CONFIRM_REPLACE_ALL",se={id:"ui.command.replace-all-matches",type:o.CommandType.COMMAND,handler:async t=>{const e=t.get(f.IConfirmService),i=t.get(o.LocaleService),n=t.get(f.IMessageService);if(!await e.confirm({id:Fe,title:{title:i.t("find-replace.replace.confirm.title")},cancelText:i.t("button.cancel"),confirmText:i.t("button.confirm")}))return!1;const a=await t.get(b).replaceAll(),{success:r,failure:c}=a;return c>0?(r===0?n.show({type:p.MessageType.Error,content:i.t("find-replace.replace.all-failure")}):n.show({type:p.MessageType.Warning,content:i.t("find-replace.replace.partial-success",`${r}`,`${c}`)}),!1):(n.show({type:p.MessageType.Success,content:i.t("find-replace.replace.all-success",`${r}`)}),!0)}};function ae(t){const{findCompleted:e,localeService:i,matchesCount:n,matchesPosition:s,findString:a,findReplaceService:r,onChange:c,..._}=t,R=e&&n===0?i.t("find-replace.dialog.no-result"):n===0?" ":void 0;return u.jsx(p.InputWithSlot,{autoFocus:!0,placeholder:i.t("find-replace.dialog.find-placeholder"),slot:u.jsx(p.Pager,{loop:!0,text:R,value:s,total:n,onChange:S=>{s===n&&S===1?r.moveToNextMatch():s===1&&S===n||S<s?r.moveToPreviousMatch():r.moveToNextMatch()}}),value:a,onChange:S=>c==null?void 0:c(S),..._})}const L={findReplaceDialogContainer:"univer-find-replace-dialog-container",findReplaceExpandContainer:"univer-find-replace-expand-container",buttonText:"univer-button-text",findReplaceButtonsGroup:"univer-find-replace-buttons-group",findReplaceButtonsGroupRight:"univer-find-replace-buttons-group-right"};function re(t,e){const i=l.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),n=l.useCallback(()=>{const s=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(s).some(a=>a===document.activeElement)},[]);return l.useImperativeHandle(e,()=>({focus:i,selectHasFocus:n})),l.useEffect(()=>{const s=t.focusSignal$.subscribe(()=>i());return()=>s.unsubscribe()},[t,i]),{focus:i,selectHasFocus:n}}const xe=l.forwardRef(function(e,i){const n=M.useDependency(o.LocaleService),s=M.useDependency(b),a=M.useDependency(o.ICommandService),r=f.useObservable(s.state$,void 0,!0),{findCompleted:c,findString:_,matchesCount:v,matchesPosition:R}=r,S=l.useCallback(()=>{a.executeCommand(W.id)},[a]),j=l.useCallback(F=>s.changeFindString(F),[s]);return re(s,i),u.jsxs(l.Fragment,{children:[u.jsx(ae,{findCompleted:c,className:"univer-find-input",matchesCount:v,matchesPosition:R,findReplaceService:s,localeService:n,findString:_,onChange:j}),u.jsx("div",{className:L.findReplaceExpandContainer,children:u.jsx(p.Button,{type:"text",size:"small",onClick:S,children:n.t("find-replace.dialog.advanced-finding")})})]})}),De=l.forwardRef(function(e,i){const n=M.useDependency(b),s=M.useDependency(o.LocaleService),a=M.useDependency(o.ICommandService),r=M.useDependency(f.IMessageService),c=f.useObservable(n.currentMatch$,void 0,!0),_=f.useObservable(n.replaceables$,void 0,!0),v=f.useObservable(n.state$,void 0,!0),{matchesCount:R,matchesPosition:S,findString:j,inputtingFindString:F,replaceString:ze,caseSensitive:Ye,matchesTheWholeCell:Ze,findDirection:Je,findScope:Qe,findBy:Xe,findCompleted:K}=v,qe=F.length===0,et=R===0||!(c!=null&&c.replaceable),tt=_.length===0,nt=l.useCallback(g=>n.changeInputtingFindString(g),[n]),it=l.useCallback(g=>n.changeReplaceString(g),[n]),{focus:st}=re(n,i),at=l.useCallback(()=>{j===F?n.moveToNextMatch():(n.changeFindString(F),n.find())},[j,F,n]),rt=l.useCallback(()=>a.executeCommand(ie.id),[a]),ot=l.useCallback(async()=>{await a.executeCommand(se.id),st()},[a]),ct=l.useCallback(g=>{n.changeFindDirection(g)},[n]),lt=l.useCallback(g=>{n.changeFindScope(g)},[n]),dt=l.useCallback(g=>{n.changeFindBy(g)},[n]),ht=Ee(s),ut=Oe(s),ft=Pe(s);return l.useEffect(()=>{const g=K&&R===0;let w=null;return g&&(w=r.show({content:s.t("find-replace.dialog.no-match"),type:p.MessageType.Warning,duration:5e3})),()=>w==null?void 0:w.dispose()},[K,R,r,s]),u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find"),children:u.jsx(ae,{findCompleted:K,className:"univer-find-input",matchesCount:R,matchesPosition:S,findReplaceService:n,localeService:s,findString:F,onChange:nt})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.replace"),children:u.jsx(p.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:ze,onChange:g=>it(g)})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:u.jsx(p.Select,{value:Je,options:ut,onChange:ct})}),u.jsx(p.FormDualColumnLayout,{children:u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:u.jsx(p.Select,{value:Qe,options:ht,onChange:lt})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:u.jsx(p.Select,{value:Xe,options:ft,onChange:dt})})]})}),u.jsx(p.FormDualColumnLayout,{children:u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:Ye,onChange:g=>{n.changeCaseSensitive(g)},children:s.t("find-replace.dialog.case-sensitive")})}),u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:Ze,onChange:g=>{n.changeMatchesTheWholeCell(g)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),u.jsxs("div",{className:L.findReplaceButtonsGroup,children:[u.jsx(p.Button,{type:"primary",onClick:at,disabled:qe,children:s.t("find-replace.dialog.find")}),u.jsxs("span",{className:L.findReplaceButtonsGroupRight,children:[u.jsx(p.Button,{disabled:et,onClick:rt,children:s.t("find-replace.dialog.replace")}),u.jsx(p.Button,{disabled:tt,onClick:ot,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function Te(){const t=M.useDependency(b),e=M.useDependency(f.ILayoutService),i=M.useDependency(o.IContextService),n=f.useObservable(t.state$,void 0,!0),s=l.useRef(null);l.useEffect(()=>{let _;return s.current&&(_=e.registerContainerElement(s.current)),()=>_==null?void 0:_.dispose()},[e]);const a=l.useRef(null),r=l.useCallback(_=>i.setContextValue(J,_),[i]),c=l.useCallback(_=>i.setContextValue(Z,_),[i]);return l.useEffect(()=>{var v;const _=C.fromEvent(document,"focusin").subscribe(R=>{var S;R.target&&((S=s.current)!=null&&S.contains(R.target))?r(!0):r(!1),!a.current||!a.current.selectHasFocus()?c(!0):c(!1)});return(v=a.current)==null||v.focus(),r(!0),c(!0),()=>{_.unsubscribe(),r(!1)}},[r,c]),u.jsx("div",{className:L.findReplaceDialogContainer,ref:s,children:n.replaceRevealed?u.jsx(De,{ref:a}):u.jsx(xe,{ref:a})})}function Ee(t){const e=t.getCurrentLocale();return l.useMemo(()=>[{label:t.t("find-replace.dialog.find-scope.current-sheet"),value:O.SUBUNIT},{label:t.t("find-replace.dialog.find-scope.workbook"),value:O.UNIT}],[e])}function Oe(t){const e=t.getCurrentLocale();return l.useMemo(()=>[{label:t.t("find-replace.dialog.find-direction.row"),value:T.ROW},{label:t.t("find-replace.dialog.find-direction.column"),value:T.COLUMN}],[e])}function Pe(t){const e=t.getCurrentLocale();return l.useMemo(()=>[{label:t.t("find-replace.dialog.find-by.value"),value:E.VALUE},{label:t.t("find-replace.dialog.find-by.formula"),value:E.FORMULA}],[e])}function x(t){return t.getContextValue(J)}function Ne(t){return t.getContextValue(Q)}function oe(t){return t.getContextValue(Z)}const A="7_find-replace-shortcuts";function G(t){return t.getContextValue(o.FOCUSING_SHEET)}function V(t){return!t.getContextValue(o.EDITOR_ACTIVATED)}const Le={id:P.id,description:"find-replace.shortcut.open-find-dialog",binding:f.KeyCode.F|f.MetaKeys.CTRL_COMMAND,group:A,preconditions(t){return!x(t)&&G(t)&&V(t)}},Ae={id:P.id,description:"find-replace.shortcut.open-find-dialog",binding:f.KeyCode.F|f.MetaKeys.CTRL_COMMAND,mac:f.KeyCode.F|f.MetaKeys.MAC_CTRL,preconditions(t){return!x(t)&&G(t)&&V(t)}},je={id:W.id,description:"find-replace.shortcut.open-replace-dialog",binding:f.KeyCode.H|f.MetaKeys.CTRL_COMMAND,mac:f.KeyCode.H|f.MetaKeys.MAC_CTRL,group:A,preconditions(t){return G(t)&&V(t)&&(!x(t)||!Ne(t))}},we={id:q.id,description:"find-replace.shortcut.go-to-next-match",binding:f.KeyCode.ENTER,group:A,priority:1e3,preconditions(t){return oe(t)&&x(t)}},Ue={id:ee.id,description:"find-replace.shortcut.go-to-previous-match",binding:f.KeyCode.ENTER|f.MetaKeys.SHIFT,group:A,priority:1e3,preconditions(t){return oe(t)&&x(t)}};function ke(t){const e=t.get(o.IContextService);return{id:P.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",group:f.MenuGroup.TOOLBAR_OTHERS,type:f.MenuItemType.BUTTON,positions:[f.MenuPosition.TOOLBAR_START],hidden$:f.getMenuHiddenObservable(t,o.UniverInstanceType.UNIVER_SHEET),disabled$:C.combineLatest([e.subscribeContextValue$(o.EDITOR_ACTIVATED),e.subscribeContextValue$(o.FOCUSING_SHEET)]).pipe(C.map(([i,n])=>i||!n))}}var Be=(t,e,i,n)=>{for(var s=e,a=t.length-1,r;a>=0;a--)(r=t[a])&&(s=r(s)||s);return s},I=(t,e)=>(i,n)=>e(i,n,t);const We={},ce="DESKTOP_FIND_REPLACE_DIALOG",le=350,Ge=20,Ve=-90;h.FindReplaceController=class extends o.RxDisposable{constructor(e,i,n,s,a,r,c,_,v,R,S){super(),this._config=e,this._univerInstanceService=i,this._menuService=n,this._shortcutService=s,this._commandService=a,this._findReplaceService=r,this._dialogService=c,this._layoutService=_,this._localeService=v,this._componentManager=R,this._injector=S,this._initCommands(),this._initUI(),this._initShortcuts()}_initCommands(){[P,W,q,ee,se,ie].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initShortcuts(){[je,Le,Ae,Ue,we].forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}_initUI(){const{menu:e={}}=this._config;this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(ke),e)),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",Te)),this.disposeWithMe(this._componentManager.register("SearchIcon",Y)),this._findReplaceService.stateUpdates$.pipe(C.takeUntil(this.dispose$)).subscribe(i=>{i.revealed===!0&&this._openPanel()}),this.disposeWithMe(this._univerInstanceService.focused$.pipe(C.takeUntil(this.dispose$)).subscribe(i=>{(!i||!this._univerInstanceService.getUniverSheetInstance(i))&&this.closePanel()}))}_openPanel(){this._dialogService.open({id:ce,draggable:!0,width:le,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:He(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()})}closePanel(){this._dialogService.close(ce),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus())}},h.FindReplaceController=Be([o.OnLifecycle(o.LifecycleStages.Rendered,h.FindReplaceController),I(1,o.IUniverInstanceService),I(2,f.IMenuService),I(3,f.IShortcutService),I(4,o.ICommandService),I(5,b),I(6,f.IDialogService),I(7,f.ILayoutService),I(8,m.Inject(o.LocaleService)),I(9,m.Inject(f.ComponentManager)),I(10,m.Inject(m.Injector))],h.FindReplaceController);function He(){const{innerWidth:t}=window;return{x:(t-le)/2-Ge,y:Ve}}var Ke=(t,e,i,n)=>{for(var s=e,a=t.length-1,r;a>=0;a--)(r=t[a])&&(s=r(s)||s);return s},de=(t,e)=>(i,n)=>e(i,n,t);const $e="FIND_REPLACE_PLUGIN";h.UniverFindReplacePlugin=(H=class extends o.Plugin{constructor(e={},i,n){super(),this._config=e,this._injector=i,this._localeService=n,this._config=o.Tools.deepMerge({},We,this._config)}onStarting(e){[[h.FindReplaceController,{useFactory:()=>this._injector.createInstance(h.FindReplaceController,this._config)}],[b,{useClass:B}]].forEach(i=>{e.add(i)})}},d(H,"pluginName",$e),H),h.UniverFindReplacePlugin=Ke([de(1,m.Inject(m.Injector)),de(2,m.Inject(o.LocaleService))],h.UniverFindReplacePlugin),h.FindBy=E,h.FindDirection=T,h.FindModel=me,h.FindScope=O,h.IFindReplaceService=b,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/find-replace",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13-nightly.202406041140",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"require": "./lib/cjs/*",
|
|
35
35
|
"types": "./lib/types/index.d.ts"
|
|
36
36
|
},
|
|
37
|
+
"./locale/*": "./lib/locale/*.json",
|
|
37
38
|
"./lib/*": "./lib/*"
|
|
38
39
|
},
|
|
39
40
|
"main": "./lib/cjs/index.js",
|
|
@@ -56,29 +57,29 @@
|
|
|
56
57
|
"@wendellhu/redi": "0.15.2",
|
|
57
58
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
58
59
|
"rxjs": ">=7.0.0",
|
|
59
|
-
"@univerjs/core": "0.1.
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/
|
|
60
|
+
"@univerjs/core": "0.1.13-nightly.202406041140",
|
|
61
|
+
"@univerjs/design": "0.1.13-nightly.202406041140",
|
|
62
|
+
"@univerjs/ui": "0.1.13-nightly.202406041140",
|
|
63
|
+
"@univerjs/engine-render": "0.1.13-nightly.202406041140"
|
|
63
64
|
},
|
|
64
65
|
"dependencies": {
|
|
65
|
-
"@univerjs/icons": "^0.1.
|
|
66
|
+
"@univerjs/icons": "^0.1.56"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
|
-
"@types/react": "^18.
|
|
69
|
+
"@types/react": "^18.3.3",
|
|
69
70
|
"@wendellhu/redi": "0.15.2",
|
|
70
71
|
"less": "^4.2.0",
|
|
71
|
-
"react": "18.
|
|
72
|
+
"react": "18.3.1",
|
|
72
73
|
"rxjs": "^7.8.1",
|
|
73
74
|
"typescript": "^5.4.5",
|
|
74
|
-
"vite": "^5.2.
|
|
75
|
+
"vite": "^5.2.12",
|
|
75
76
|
"vitest": "^1.6.0",
|
|
76
|
-
"@univerjs/
|
|
77
|
-
"@univerjs/
|
|
78
|
-
"@univerjs/engine-formula": "0.1.
|
|
79
|
-
"@univerjs/engine-render": "0.1.
|
|
80
|
-
"@univerjs/
|
|
81
|
-
"@univerjs/
|
|
77
|
+
"@univerjs/design": "0.1.13-nightly.202406041140",
|
|
78
|
+
"@univerjs/core": "0.1.13-nightly.202406041140",
|
|
79
|
+
"@univerjs/engine-formula": "0.1.13-nightly.202406041140",
|
|
80
|
+
"@univerjs/engine-render": "0.1.13-nightly.202406041140",
|
|
81
|
+
"@univerjs/ui": "0.1.13-nightly.202406041140",
|
|
82
|
+
"@univerjs/shared": "0.1.13"
|
|
82
83
|
},
|
|
83
84
|
"scripts": {
|
|
84
85
|
"test": "vitest run",
|
package/LICENSE
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|