@univerjs/find-replace 0.1.7 → 0.1.8
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 +233 -232
- package/lib/types/plugin.d.ts +1 -0
- package/lib/umd/index.js +2 -2
- package/package.json +16 -16
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Pe=Object.defineProperty;var Te=(t,e,n)=>e in t?Pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var d=(t,e,n)=>(Te(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),M=require("@wendellhu/redi"),h=require("@univerjs/ui"),S=require("rxjs"),Ee=require("@univerjs/engine-render"),l=require("react"),p=require("@univerjs/design"),y=require("@wendellhu/redi/react-bindings");var R=function(){return R=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},R.apply(this,arguments)},$e=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(n[i[s]]=t[i[s]]);return n},H=l.forwardRef(function(t,e){var n=t.icon,i=t.id,s=t.className,r=t.extend,a=$e(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(s||"").trim(),f=l.useRef("_".concat(Le()));return K(n,"".concat(i),{defIds:n.defIds,idSuffix:f.current},R({ref:e,className:o},a),r)});function K(t,e,n,i,s){return l.createElement(t.tag,R(R({key:e},Ne(t,n,s)),i),(je(t,n).children||[]).map(function(r,a){return K(r,"".concat(e,"-").concat(t.tag,"-").concat(a),n,void 0,s)}))}function Ne(t,e,n){var i=R({},t.attrs);n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1);var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(r){var a=r[0],o=r[1];typeof o=="string"&&(i[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function je(t,e){var n,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((n=t.children)===null||n===void 0)&&n.length)?R(R({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&i&&i.indexOf(s.attrs.id)>-1?R(R({},s),{attrs:R(R({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function Le(){return Math.random().toString(36).substring(2,8)}H.displayName="UniverIcon";var Ae={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"}}]}]},q=l.forwardRef(function(t,e){return l.createElement(H,Object.assign({},t,{id:"search-single-16",ref:e,icon:Ae}))});q.displayName="SearchSingle16";const z="FIND_REPLACE_INPUT_FOCUS",Y="FIND_REPLACE_DIALOG_FOCUS",Z="FIND_REPLACE_REPLACE_REVEALED";var we=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,J=(t,e,n,i)=>{for(var s=i>1?void 0:i?Ue(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=(i?a(e,n,s):a(s))||s);return i&&s&&we(e,n,s),s},O=(t,e)=>(n,i)=>e(n,i,t);class Be extends c.Disposable{}const b=M.createIdentifier("find-replace.service");function ke(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 w=class extends c.Disposable{constructor(e,n,i,s){super();d(this,"currentMatch$",new S.BehaviorSubject(null));d(this,"replaceables$",new S.BehaviorSubject([]));d(this,"_findModels",[]);d(this,"_matchingModel",null);d(this,"_matches",[]);d(this,"_currentSearchingDisposables",null);this._state=e,this._providers=n,this._univerInstanceService=i,this._logService=s,this.disposeWithMe(this._state.stateUpdates$.pipe(S.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async r=>{const a=this._state.state;ke(r)&&(a.findString!==""&&!a.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):r.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),n=this._findModels=(await Promise.all(e.map(r=>r.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(n);const i=this._matches=n.map(r=>r.getMatches()).flat();if(this.replaceables$.next(i.filter(r=>r.replaceable)),!i.length)return this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]};const s=this._moveToInitialMatch(n,i);return this._state.changeState({matchesCount:i.length,matchesPosition:s+1}),{results:i}}_stopSearching(){var e;this._providers.forEach(n=>n.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 n=this._currentSearchingDisposables=new c.DisposableCollection,i=S.combineLatest(e.map(s=>s.matchesUpdate$)).pipe(S.debounceTime(220)).subscribe(([...s])=>{const r=this._matches=s.flat();if(r.length){const a=this._moveToInitialMatch(this._findModels,r,!0);this._state.changeState({matchesCount:r.length,matchesPosition:a+1}),this.replaceables$.next(r.filter(o=>o.replaceable))}else this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([])});e.forEach(s=>n.add(c.toDisposable(s.activelyChangingMatch$.subscribe(r=>{const a=this._matches.findIndex(o=>o===r);this._state.changeState({matchesPosition:a+1})})))),n.add(c.toDisposable(i))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const e=await Promise.all(this._findModels.map(n=>n.replaceAll(this._state.replaceString))).then(n=>n.reduce((i,s)=>(i.success+=s.success,i.failure+=s.failure,i),{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,n=this._matchingModel.moveToNextMatch({loop:e});if(n){const i=this._matches.findIndex(s=>s===n);this.currentMatch$.next(n),this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(o=>o===this._matchingModel),s=this._findModels[(i+1)%this._findModels.length],r=s.moveToNextMatch(),a=this._matches.findIndex(o=>o===r);this.currentMatch$.next(r),this._matchingModel=s,this._state.changeState({matchesPosition:a+1})}}moveToPreviousMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,n=this._matchingModel.moveToPreviousMatch({loop:e});if(n){const i=this._matches.findIndex(s=>s===n);this.currentMatch$.next(n),this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(o=>o===this._matchingModel),s=this._findModels[(i-1+this._findModels.length)%this._findModels.length],r=s.moveToPreviousMatch(),a=this._matches.findIndex(o=>o===r);this.currentMatch$.next(r),this._matchingModel=s,this._state.changeState({matchesPosition:a+1})}}_moveToInitialMatch(e,n,i=!1){var f;const s=(f=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:f.getUnitId();if(!s)return-1;const r=e.find(_=>_.unitId===s);if(r){this._matchingModel=r;const _=r.moveToNextMatch({stayIfOnMatch:!0,noFocus:i}),v=n.findIndex(m=>m===_);return this.currentMatch$.next(_),v}this._matchingModel=e[0];const a=this._matchingModel.moveToNextMatch({noFocus:i}),o=this._matches.findIndex(_=>_===a);return this.currentMatch$.next(a),o}};w=J([O(2,c.IUniverInstanceService),O(3,c.ILogService)],w);var P=(t=>(t.ROW="row",t.COLUMN="column",t))(P||{}),T=(t=>(t.VALUE="value",t.FORMULA="formula",t))(T||{}),E=(t=>(t.SUBUNIT="subunit",t.UNIT="unit",t))(E||{});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 We{constructor(){d(this,"_stateUpdates$",new S.Subject);d(this,"stateUpdates$",this._stateUpdates$.asObservable());d(this,"_state$",new S.BehaviorSubject(B()));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 n=!1;const i={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,i.findString=this._findString,n=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,i.revealed=e.revealed,n=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,i.replaceRevealed=e.replaceRevealed,n=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,i.replaceString=e.replaceString,n=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,i.matchesCount=e.matchesCount,n=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,i.matchesPosition=e.matchesPosition,n=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,i.findBy=e.findBy,n=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,i.findScope=e.findScope,n=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,i.findDirection=e.findDirection,n=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,i.caseSensitive=e.caseSensitive,n=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,i.matchesTheWholeCell=e.matchesTheWholeCell,n=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,i.inputtingFindString=e.inputtingFindString,n=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,i.findCompleted=e.findCompleted,n=!0),n&&(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(i))}}let U=class extends c.Disposable{constructor(e,n){super();d(this,"_providers",new Set);d(this,"_state",new We);d(this,"_model");d(this,"_currentMatch$",new S.BehaviorSubject(null));d(this,"currentMatch$",this._currentMatch$.asObservable());d(this,"_replaceables$",new S.BehaviorSubject([]));d(this,"replaceables$",this._replaceables$.asObservable());d(this,"_focusSignal$",new S.Subject);d(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=n}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(w,this._state,this._providers),this._model.currentMatch$.subscribe(i=>this._currentMatch$.next(i)),this._model.replaceables$.subscribe(i=>this._replaceables$.next(i));const n=B();return e&&(n.replaceRevealed=!0),this._state.changeState(n),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),c.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(Z,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(Ee.RENDER_RAW_FORMULA_KEY,e)}};U=J([O(0,M.Inject(M.Injector)),O(1,c.IContextService)],U);const N={id:"ui.operation.open-find-dialog",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(b);return e.revealed?e.focusFindInput():e.start(),!0}},k={id:"ui.operation.open-replace-dialog",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(b);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},Q={type:c.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(b).moveToNextMatch(),!0)},X={type:c.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(b).moveToPreviousMatch(),!0)};var ee={exports:{}},j={};/**
|
|
1
|
+
"use strict";var Te=Object.defineProperty;var Ee=(t,e,n)=>e in t?Te(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var d=(t,e,n)=>(Ee(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),M=require("@wendellhu/redi"),h=require("@univerjs/ui"),S=require("rxjs"),$e=require("@univerjs/engine-render"),l=require("react"),p=require("@univerjs/design"),y=require("@wendellhu/redi/react-bindings");var R=function(){return R=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},R.apply(this,arguments)},Ne=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(n[i[s]]=t[i[s]]);return n},K=l.forwardRef(function(t,e){var n=t.icon,i=t.id,s=t.className,r=t.extend,a=Ne(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(s||"").trim(),f=l.useRef("_".concat(Ae()));return q(n,"".concat(i),{defIds:n.defIds,idSuffix:f.current},R({ref:e,className:o},a),r)});function q(t,e,n,i,s){return l.createElement(t.tag,R(R({key:e},je(t,n,s)),i),(Le(t,n).children||[]).map(function(r,a){return q(r,"".concat(e,"-").concat(t.tag,"-").concat(a),n,void 0,s)}))}function je(t,e,n){var i=R({},t.attrs);n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1);var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(r){var a=r[0],o=r[1];typeof o=="string"&&(i[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function Le(t,e){var n,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((n=t.children)===null||n===void 0)&&n.length)?R(R({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&i&&i.indexOf(s.attrs.id)>-1?R(R({},s),{attrs:R(R({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function Ae(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var we={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"}}]}]},z=l.forwardRef(function(t,e){return l.createElement(K,Object.assign({},t,{id:"search-single-16",ref:e,icon:we}))});z.displayName="SearchSingle16";const Y="FIND_REPLACE_INPUT_FOCUS",Z="FIND_REPLACE_DIALOG_FOCUS",J="FIND_REPLACE_REPLACE_REVEALED";var Ue=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,Q=(t,e,n,i)=>{for(var s=i>1?void 0:i?Be(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=(i?a(e,n,s):a(s))||s);return i&&s&&Ue(e,n,s),s},O=(t,e)=>(n,i)=>e(n,i,t);class ke extends c.Disposable{}const b=M.createIdentifier("find-replace.service");function We(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 c.Disposable{constructor(e,n,i,s){super();d(this,"currentMatch$",new S.BehaviorSubject(null));d(this,"replaceables$",new S.BehaviorSubject([]));d(this,"_findModels",[]);d(this,"_matchingModel",null);d(this,"_matches",[]);d(this,"_currentSearchingDisposables",null);this._state=e,this._providers=n,this._univerInstanceService=i,this._logService=s,this.disposeWithMe(this._state.stateUpdates$.pipe(S.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async r=>{const a=this._state.state;We(r)&&(a.findString!==""&&!a.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):r.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),n=this._findModels=(await Promise.all(e.map(r=>r.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(n);const i=this._matches=n.map(r=>r.getMatches()).flat();if(this.replaceables$.next(i.filter(r=>r.replaceable)),!i.length)return this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]};const s=this._moveToInitialMatch(n,i);return this._state.changeState({matchesCount:i.length,matchesPosition:s+1}),{results:i}}_stopSearching(){var e;this._providers.forEach(n=>n.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 n=this._currentSearchingDisposables=new c.DisposableCollection,i=S.combineLatest(e.map(s=>s.matchesUpdate$)).pipe(S.debounceTime(220)).subscribe(([...s])=>{const r=this._matches=s.flat();if(r.length){const a=this._moveToInitialMatch(this._findModels,r,!0);this._state.changeState({matchesCount:r.length,matchesPosition:a+1}),this.replaceables$.next(r.filter(o=>o.replaceable))}else this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([])});e.forEach(s=>n.add(c.toDisposable(s.activelyChangingMatch$.subscribe(r=>{const a=this._matches.findIndex(o=>o===r);this._state.changeState({matchesPosition:a+1})})))),n.add(c.toDisposable(i))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const e=await Promise.all(this._findModels.map(n=>n.replaceAll(this._state.replaceString))).then(n=>n.reduce((i,s)=>(i.success+=s.success,i.failure+=s.failure,i),{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,n=this._matchingModel.moveToNextMatch({loop:e});if(n){const i=this._matches.findIndex(s=>s===n);this.currentMatch$.next(n),this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(o=>o===this._matchingModel),s=this._findModels[(i+1)%this._findModels.length],r=s.moveToNextMatch(),a=this._matches.findIndex(o=>o===r);this.currentMatch$.next(r),this._matchingModel=s,this._state.changeState({matchesPosition:a+1})}}moveToPreviousMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,n=this._matchingModel.moveToPreviousMatch({loop:e});if(n){const i=this._matches.findIndex(s=>s===n);this.currentMatch$.next(n),this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(o=>o===this._matchingModel),s=this._findModels[(i-1+this._findModels.length)%this._findModels.length],r=s.moveToPreviousMatch(),a=this._matches.findIndex(o=>o===r);this.currentMatch$.next(r),this._matchingModel=s,this._state.changeState({matchesPosition:a+1})}}_moveToInitialMatch(e,n,i=!1){var f;const s=(f=this._univerInstanceService.getFocusedUnit())==null?void 0:f.getUnitId();if(!s)return-1;const r=e.find(_=>_.unitId===s);if(r){this._matchingModel=r;const _=r.moveToNextMatch({stayIfOnMatch:!0,noFocus:i}),v=n.findIndex(m=>m===_);return this.currentMatch$.next(_),v}this._matchingModel=e[0];const a=this._matchingModel.moveToNextMatch({noFocus:i}),o=this._matches.findIndex(_=>_===a);return this.currentMatch$.next(a),o}};U=Q([O(2,c.IUniverInstanceService),O(3,c.ILogService)],U);var P=(t=>(t.ROW="row",t.COLUMN="column",t))(P||{}),T=(t=>(t.VALUE="value",t.FORMULA="formula",t))(T||{}),E=(t=>(t.SUBUNIT="subunit",t.UNIT="unit",t))(E||{});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 Ge{constructor(){d(this,"_stateUpdates$",new S.Subject);d(this,"stateUpdates$",this._stateUpdates$.asObservable());d(this,"_state$",new S.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 n=!1;const i={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,i.findString=this._findString,n=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,i.revealed=e.revealed,n=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,i.replaceRevealed=e.replaceRevealed,n=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,i.replaceString=e.replaceString,n=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,i.matchesCount=e.matchesCount,n=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,i.matchesPosition=e.matchesPosition,n=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,i.findBy=e.findBy,n=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,i.findScope=e.findScope,n=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,i.findDirection=e.findDirection,n=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,i.caseSensitive=e.caseSensitive,n=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,i.matchesTheWholeCell=e.matchesTheWholeCell,n=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,i.inputtingFindString=e.inputtingFindString,n=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,i.findCompleted=e.findCompleted,n=!0),n&&(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(i))}}let B=class extends c.Disposable{constructor(e,n){super();d(this,"_providers",new Set);d(this,"_state",new Ge);d(this,"_model");d(this,"_currentMatch$",new S.BehaviorSubject(null));d(this,"currentMatch$",this._currentMatch$.asObservable());d(this,"_replaceables$",new S.BehaviorSubject([]));d(this,"replaceables$",this._replaceables$.asObservable());d(this,"_focusSignal$",new S.Subject);d(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=n}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(i=>this._currentMatch$.next(i)),this._model.replaceables$.subscribe(i=>this._replaceables$.next(i));const n=k();return e&&(n.replaceRevealed=!0),this._state.changeState(n),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),c.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(J,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue($e.RENDER_RAW_FORMULA_KEY,e)}};B=Q([O(0,M.Inject(M.Injector)),O(1,c.IContextService)],B);const N={id:"ui.operation.open-find-dialog",type:c.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:c.CommandType.OPERATION,handler:t=>{const e=t.get(b);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},X={type:c.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(b).moveToNextMatch(),!0)},ee={type:c.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(b).moveToPreviousMatch(),!0)};var te={exports:{}},j={};/**
|
|
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 Ge=l,Ve=Symbol.for("react.element"),He=Symbol.for("react.fragment"),Ke=Object.prototype.hasOwnProperty,qe=Ge.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ze={key:!0,ref:!0,__self:!0,__source:!0};function te(t,e,n){var i,s={},r=null,a=null;n!==void 0&&(r=""+n),e.key!==void 0&&(r=""+e.key),e.ref!==void 0&&(a=e.ref);for(i in e)Ke.call(e,i)&&!ze.hasOwnProperty(i)&&(s[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)s[i]===void 0&&(s[i]=e[i]);return{$$typeof:Ve,type:t,key:r,ref:a,props:s,_owner:qe.current}}j.Fragment=He;j.jsx=te;j.jsxs=te;ee.exports=j;var u=ee.exports;const ie={id:"ui.command.replace-current-match",type:c.CommandType.COMMAND,handler:t=>t.get(b).replace()},Ye="CONFIRM_REPLACE_ALL",ne={id:"ui.command.replace-all-matches",type:c.CommandType.COMMAND,handler:async t=>{const e=t.get(h.IConfirmService),n=t.get(c.LocaleService),i=t.get(h.IMessageService);if(!await e.confirm({id:Ye,title:{title:n.t("find-replace.replace.confirm.title")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")}))return!1;const r=await t.get(b).replaceAll(),{success:a,failure:o}=r;return o>0?(a===0?i.show({type:p.MessageType.Error,content:n.t("find-replace.replace.all-failure")}):i.show({type:p.MessageType.Warning,content:n.t("find-replace.replace.partial-success",`${a}`,`${o}`)}),!1):(i.show({type:p.MessageType.Success,content:n.t("find-replace.replace.all-success",`${a}`)}),!0)}};function se(t){const{findCompleted:e,localeService:n,matchesCount:i,matchesPosition:s,findString:r,findReplaceService:a,onChange:o,...f}=t,v=e&&i===0?n.t("find-replace.dialog.no-result"):i===0?" ":void 0;return u.jsx(p.InputWithSlot,{autoFocus:!0,placeholder:n.t("find-replace.dialog.find-placeholder"),slot:u.jsx(p.Pager,{loop:!0,text:v,value:s,total:i,onChange:m=>{s===i&&m===1?a.moveToNextMatch():s===1&&m===i||m<s?a.moveToPreviousMatch():a.moveToNextMatch()}}),value:r,onChange:m=>o==null?void 0:o(m),...f})}const Ze="univer-find-replace-dialog-container",Je="univer-find-replace-expand-container",Qe="univer-button-text",Xe="univer-find-replace-buttons-group",et="univer-find-replace-buttons-group-right",$={findReplaceDialogContainer:Ze,findReplaceExpandContainer:Je,buttonText:Qe,findReplaceButtonsGroup:Xe,findReplaceButtonsGroupRight:et};function re(t,e){const n=l.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),i=l.useCallback(()=>{const s=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(s).some(r=>r===document.activeElement)},[]);return l.useImperativeHandle(e,()=>({focus:n,selectHasFocus:i})),l.useEffect(()=>{const s=t.focusSignal$.subscribe(()=>n());return()=>s.unsubscribe()},[t,n]),{focus:n,selectHasFocus:i}}const tt=l.forwardRef(function(e,n){const i=y.useDependency(c.LocaleService),s=y.useDependency(b),r=y.useDependency(c.ICommandService),a=h.useObservable(s.state$,void 0,!0),{findCompleted:o,findString:f,matchesCount:_,matchesPosition:v}=a,m=l.useCallback(()=>{r.executeCommand(k.id)},[r]),F=l.useCallback(x=>s.changeFindString(x),[s]);return re(s,n),u.jsxs(l.Fragment,{children:[u.jsx(se,{findCompleted:o,className:"univer-find-input",matchesCount:_,matchesPosition:v,findReplaceService:s,localeService:i,findString:f,onChange:F}),u.jsx("div",{className:$.findReplaceExpandContainer,children:u.jsx(p.Button,{type:"text",size:"small",onClick:m,children:i.t("find-replace.dialog.advanced-finding")})})]})}),it=l.forwardRef(function(e,n){const i=y.useDependency(b),s=y.useDependency(c.LocaleService),r=y.useDependency(c.ICommandService),a=y.useDependency(h.IMessageService),o=h.useObservable(i.currentMatch$,void 0,!0),f=h.useObservable(i.replaceables$,void 0,!0),_=h.useObservable(i.state$,void 0,!0),{matchesCount:v,matchesPosition:m,findString:F,inputtingFindString:x,replaceString:le,caseSensitive:de,matchesTheWholeCell:ue,findDirection:he,findScope:pe,findBy:fe,findCompleted:A}=_,ge=x.length===0,_e=v===0||!(o!=null&&o.replaceable),me=f.length===0,ve=l.useCallback(g=>i.changeInputtingFindString(g),[i]),Se=l.useCallback(g=>i.changeReplaceString(g),[i]),{focus:Ce}=re(i,n),Re=l.useCallback(()=>{F===x?i.moveToNextMatch():(i.changeFindString(x),i.find())},[F,x,i]),be=l.useCallback(()=>r.executeCommand(ie.id),[r]),ye=l.useCallback(async()=>{await r.executeCommand(ne.id),Ce()},[r]),Me=l.useCallback(g=>{i.changeFindDirection(g)},[i]),xe=l.useCallback(g=>{i.changeFindScope(g)},[i]),Fe=l.useCallback(g=>{i.changeFindBy(g)},[i]),Ie=st(s),De=rt(s),Oe=at(s);return l.useEffect(()=>{const g=A&&v===0;let D=null;return g&&(D=a.show({content:s.t("find-replace.dialog.no-match"),type:p.MessageType.Warning,delay:5e3})),()=>D==null?void 0:D.dispose()},[A,v,a,s]),u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find"),children:u.jsx(se,{findCompleted:A,className:"univer-find-input",matchesCount:v,matchesPosition:m,findReplaceService:i,localeService:s,findString:x,onChange:ve})}),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:le,onChange:g=>Se(g)})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:u.jsx(p.Select,{value:he,options:De,onChange:Me})}),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:pe,options:Ie,onChange:xe})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:u.jsx(p.Select,{value:fe,options:Oe,onChange:Fe})})]})}),u.jsx(p.FormDualColumnLayout,{children:u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:de,onChange:g=>{i.changeCaseSensitive(g)},children:s.t("find-replace.dialog.case-sensitive")})}),u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:ue,onChange:g=>{i.changeMatchesTheWholeCell(g)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),u.jsxs("div",{className:$.findReplaceButtonsGroup,children:[u.jsx(p.Button,{type:"primary",onClick:Re,disabled:ge,children:s.t("find-replace.dialog.find")}),u.jsxs("span",{className:$.findReplaceButtonsGroupRight,children:[u.jsx(p.Button,{disabled:_e,onClick:be,children:s.t("find-replace.dialog.replace")}),u.jsx(p.Button,{disabled:me,onClick:ye,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function nt(){const t=y.useDependency(b),e=y.useDependency(h.ILayoutService),n=y.useDependency(c.IContextService),i=h.useObservable(t.state$,void 0,!0),s=l.useRef(null);l.useEffect(()=>{let f;return s.current&&(f=e.registerContainerElement(s.current)),()=>f==null?void 0:f.dispose()},[e]);const r=l.useRef(null),a=l.useCallback(f=>n.setContextValue(Y,f),[n]),o=l.useCallback(f=>n.setContextValue(z,f),[n]);return l.useEffect(()=>{var _;const f=S.fromEvent(document,"focusin").subscribe(v=>{var m;v.target&&((m=s.current)!=null&&m.contains(v.target))?a(!0):a(!1),!r.current||!r.current.selectHasFocus()?o(!0):o(!1)});return(_=r.current)==null||_.focus(),a(!0),o(!0),()=>{f.unsubscribe(),a(!1)}},[a,o]),u.jsx("div",{className:$.findReplaceDialogContainer,ref:s,children:i.replaceRevealed?u.jsx(it,{ref:r}):u.jsx(tt,{ref:r})})}function st(t){const e=t.getCurrentLocale();return l.useMemo(()=>[{label:t.t("find-replace.dialog.find-scope.current-sheet"),value:E.SUBUNIT},{label:t.t("find-replace.dialog.find-scope.workbook"),value:E.UNIT}],[e])}function rt(t){const e=t.getCurrentLocale();return l.useMemo(()=>[{label:t.t("find-replace.dialog.find-direction.row"),value:P.ROW},{label:t.t("find-replace.dialog.find-direction.column"),value:P.COLUMN}],[e])}function at(t){const e=t.getCurrentLocale();return l.useMemo(()=>[{label:t.t("find-replace.dialog.find-by.value"),value:T.VALUE},{label:t.t("find-replace.dialog.find-by.formula"),value:T.FORMULA}],[e])}function I(t){return t.getContextValue(Y)}function ot(t){return t.getContextValue(Z)}function ae(t){return t.getContextValue(z)}const L="7_find-replace-shortcuts";function W(t){return t.getContextValue(c.FOCUSING_SHEET)}function G(t){return!t.getContextValue(c.EDITOR_ACTIVATED)}const ct={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:h.KeyCode.F|h.MetaKeys.CTRL_COMMAND,group:L,preconditions(t){return!I(t)&&W(t)&&G(t)}},lt={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:h.KeyCode.F|h.MetaKeys.CTRL_COMMAND,mac:h.KeyCode.F|h.MetaKeys.MAC_CTRL,preconditions(t){return!I(t)&&W(t)&&G(t)}},dt={id:k.id,description:"find-replace.shortcut.open-replace-dialog",binding:h.KeyCode.H|h.MetaKeys.CTRL_COMMAND,mac:h.KeyCode.H|h.MetaKeys.MAC_CTRL,group:L,preconditions(t){return W(t)&&G(t)&&(!I(t)||!ot(t))}},ut={id:Q.id,description:"find-replace.shortcut.go-to-next-match",binding:h.KeyCode.ENTER,group:L,priority:1e3,preconditions(t){return ae(t)&&I(t)}},ht={id:X.id,description:"find-replace.shortcut.go-to-previous-match",binding:h.KeyCode.ENTER|h.MetaKeys.SHIFT,group:L,priority:1e3,preconditions(t){return ae(t)&&I(t)}};function pt(t){const e=t.get(c.IContextService);return{id:N.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",group:h.MenuGroup.TOOLBAR_OTHERS,type:h.MenuItemType.BUTTON,positions:[h.MenuPosition.TOOLBAR_START],hidden$:h.getMenuHiddenObservable(t,c.UniverInstanceType.SHEET),disabled$:S.combineLatest([e.subscribeContextValue$(c.EDITOR_ACTIVATED),e.subscribeContextValue$(c.FOCUSING_SHEET)]).pipe(S.map(([n,i])=>n||!i))}}var ft=Object.defineProperty,gt=Object.getOwnPropertyDescriptor,_t=(t,e,n,i)=>{for(var s=i>1?void 0:i?gt(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=(i?a(e,n,s):a(s))||s);return i&&s&&ft(e,n,s),s},C=(t,e)=>(n,i)=>e(n,i,t);const V="DESKTOP_FIND_REPLACE_DIALOG",oe=350,mt=20,vt=-90;exports.FindReplaceController=class extends c.RxDisposable{constructor(e,n,i,s,r,a,o,f,_,v,m,F){super(),this._univerInstanceService=e,this._menuService=n,this._shortcutService=i,this._commandService=s,this._findReplaceService=r,this._logService=a,this._dialogService=o,this._contextService=f,this._layoutService=_,this._localeService=v,this._componentManager=m,this._injector=F,this._initCommands(),this._initUI(),this._initShortcuts()}_initCommands(){[N,k,Q,X,ne,ie].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initShortcuts(){[dt,ct,lt,ht,ut].forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}_initUI(){this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(pt))),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",nt)),this.disposeWithMe(this._componentManager.register("SearchIcon",q)),this._findReplaceService.stateUpdates$.pipe(S.takeUntil(this.dispose$)).subscribe(e=>{e.revealed===!0&&this._openPanel()}),this.disposeWithMe(this._univerInstanceService.focused$.pipe(S.takeUntil(this.dispose$)).subscribe(e=>{(!e||!this._univerInstanceService.getUniverSheetInstance(e))&&this.closePanel()}))}_openPanel(){this._dialogService.open({id:V,draggable:!0,width:oe,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:St(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()})}closePanel(){this._dialogService.close(V),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus())}};exports.FindReplaceController=_t([c.OnLifecycle(c.LifecycleStages.Rendered,exports.FindReplaceController),C(0,c.IUniverInstanceService),C(1,h.IMenuService),C(2,h.IShortcutService),C(3,c.ICommandService),C(4,b),C(5,c.ILogService),C(6,h.IDialogService),C(7,c.IContextService),C(8,h.ILayoutService),C(9,M.Inject(c.LocaleService)),C(10,M.Inject(h.ComponentManager)),C(11,M.Inject(M.Injector))],exports.FindReplaceController);function St(){const{innerWidth:t}=window;return{x:(t-oe)/2-mt,y:vt}}const Ct={"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"},Rt=Ct,bt={"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":"查找替换"},ce=bt;var yt=Object.defineProperty,Mt=Object.getOwnPropertyDescriptor,xt=(t,e,n,i)=>{for(var s=i>1?void 0:i?Mt(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=(i?a(e,n,s):a(s))||s);return i&&s&&yt(e,n,s),s},Ft=(t,e)=>(n,i)=>e(n,i,t);const It="FIND_REPLACE";exports.UniverFindReplacePlugin=class extends c.Plugin{constructor(e,n){super(It),this._injector=e,this._localeService=n,this._localeService.load({zhCN:ce})}onStarting(e){[[exports.FindReplaceController],[b,{useClass:U}]].forEach(n=>{e.add(n)})}};exports.UniverFindReplacePlugin=xt([Ft(1,M.Inject(c.LocaleService))],exports.UniverFindReplacePlugin);exports.FindBy=T;exports.FindDirection=P;exports.FindModel=Be;exports.FindScope=E;exports.IFindReplaceService=b;exports.enUS=Rt;exports.zhCN=ce;
|
|
9
|
+
*/var Ve=l,He=Symbol.for("react.element"),Ke=Symbol.for("react.fragment"),qe=Object.prototype.hasOwnProperty,ze=Ve.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ye={key:!0,ref:!0,__self:!0,__source:!0};function ie(t,e,n){var i,s={},r=null,a=null;n!==void 0&&(r=""+n),e.key!==void 0&&(r=""+e.key),e.ref!==void 0&&(a=e.ref);for(i in e)qe.call(e,i)&&!Ye.hasOwnProperty(i)&&(s[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)s[i]===void 0&&(s[i]=e[i]);return{$$typeof:He,type:t,key:r,ref:a,props:s,_owner:ze.current}}j.Fragment=Ke;j.jsx=ie;j.jsxs=ie;te.exports=j;var u=te.exports;const ne={id:"ui.command.replace-current-match",type:c.CommandType.COMMAND,handler:t=>t.get(b).replace()},Ze="CONFIRM_REPLACE_ALL",se={id:"ui.command.replace-all-matches",type:c.CommandType.COMMAND,handler:async t=>{const e=t.get(h.IConfirmService),n=t.get(c.LocaleService),i=t.get(h.IMessageService);if(!await e.confirm({id:Ze,title:{title:n.t("find-replace.replace.confirm.title")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")}))return!1;const r=await t.get(b).replaceAll(),{success:a,failure:o}=r;return o>0?(a===0?i.show({type:p.MessageType.Error,content:n.t("find-replace.replace.all-failure")}):i.show({type:p.MessageType.Warning,content:n.t("find-replace.replace.partial-success",`${a}`,`${o}`)}),!1):(i.show({type:p.MessageType.Success,content:n.t("find-replace.replace.all-success",`${a}`)}),!0)}};function re(t){const{findCompleted:e,localeService:n,matchesCount:i,matchesPosition:s,findString:r,findReplaceService:a,onChange:o,...f}=t,v=e&&i===0?n.t("find-replace.dialog.no-result"):i===0?" ":void 0;return u.jsx(p.InputWithSlot,{autoFocus:!0,placeholder:n.t("find-replace.dialog.find-placeholder"),slot:u.jsx(p.Pager,{loop:!0,text:v,value:s,total:i,onChange:m=>{s===i&&m===1?a.moveToNextMatch():s===1&&m===i||m<s?a.moveToPreviousMatch():a.moveToNextMatch()}}),value:r,onChange:m=>o==null?void 0:o(m),...f})}const Je="univer-find-replace-dialog-container",Qe="univer-find-replace-expand-container",Xe="univer-button-text",et="univer-find-replace-buttons-group",tt="univer-find-replace-buttons-group-right",$={findReplaceDialogContainer:Je,findReplaceExpandContainer:Qe,buttonText:Xe,findReplaceButtonsGroup:et,findReplaceButtonsGroupRight:tt};function ae(t,e){const n=l.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),i=l.useCallback(()=>{const s=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(s).some(r=>r===document.activeElement)},[]);return l.useImperativeHandle(e,()=>({focus:n,selectHasFocus:i})),l.useEffect(()=>{const s=t.focusSignal$.subscribe(()=>n());return()=>s.unsubscribe()},[t,n]),{focus:n,selectHasFocus:i}}const it=l.forwardRef(function(e,n){const i=y.useDependency(c.LocaleService),s=y.useDependency(b),r=y.useDependency(c.ICommandService),a=h.useObservable(s.state$,void 0,!0),{findCompleted:o,findString:f,matchesCount:_,matchesPosition:v}=a,m=l.useCallback(()=>{r.executeCommand(W.id)},[r]),F=l.useCallback(x=>s.changeFindString(x),[s]);return ae(s,n),u.jsxs(l.Fragment,{children:[u.jsx(re,{findCompleted:o,className:"univer-find-input",matchesCount:_,matchesPosition:v,findReplaceService:s,localeService:i,findString:f,onChange:F}),u.jsx("div",{className:$.findReplaceExpandContainer,children:u.jsx(p.Button,{type:"text",size:"small",onClick:m,children:i.t("find-replace.dialog.advanced-finding")})})]})}),nt=l.forwardRef(function(e,n){const i=y.useDependency(b),s=y.useDependency(c.LocaleService),r=y.useDependency(c.ICommandService),a=y.useDependency(h.IMessageService),o=h.useObservable(i.currentMatch$,void 0,!0),f=h.useObservable(i.replaceables$,void 0,!0),_=h.useObservable(i.state$,void 0,!0),{matchesCount:v,matchesPosition:m,findString:F,inputtingFindString:x,replaceString:de,caseSensitive:ue,matchesTheWholeCell:he,findDirection:pe,findScope:fe,findBy:ge,findCompleted:A}=_,_e=x.length===0,me=v===0||!(o!=null&&o.replaceable),ve=f.length===0,Se=l.useCallback(g=>i.changeInputtingFindString(g),[i]),Ce=l.useCallback(g=>i.changeReplaceString(g),[i]),{focus:Re}=ae(i,n),be=l.useCallback(()=>{F===x?i.moveToNextMatch():(i.changeFindString(x),i.find())},[F,x,i]),ye=l.useCallback(()=>r.executeCommand(ne.id),[r]),Me=l.useCallback(async()=>{await r.executeCommand(se.id),Re()},[r]),xe=l.useCallback(g=>{i.changeFindDirection(g)},[i]),Fe=l.useCallback(g=>{i.changeFindScope(g)},[i]),Ie=l.useCallback(g=>{i.changeFindBy(g)},[i]),De=rt(s),Oe=at(s),Pe=ot(s);return l.useEffect(()=>{const g=A&&v===0;let D=null;return g&&(D=a.show({content:s.t("find-replace.dialog.no-match"),type:p.MessageType.Warning,delay:5e3})),()=>D==null?void 0:D.dispose()},[A,v,a,s]),u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find"),children:u.jsx(re,{findCompleted:A,className:"univer-find-input",matchesCount:v,matchesPosition:m,findReplaceService:i,localeService:s,findString:x,onChange:Se})}),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:de,onChange:g=>Ce(g)})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:u.jsx(p.Select,{value:pe,options:Oe,onChange:xe})}),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:fe,options:De,onChange:Fe})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:u.jsx(p.Select,{value:ge,options:Pe,onChange:Ie})})]})}),u.jsx(p.FormDualColumnLayout,{children:u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:ue,onChange:g=>{i.changeCaseSensitive(g)},children:s.t("find-replace.dialog.case-sensitive")})}),u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:he,onChange:g=>{i.changeMatchesTheWholeCell(g)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),u.jsxs("div",{className:$.findReplaceButtonsGroup,children:[u.jsx(p.Button,{type:"primary",onClick:be,disabled:_e,children:s.t("find-replace.dialog.find")}),u.jsxs("span",{className:$.findReplaceButtonsGroupRight,children:[u.jsx(p.Button,{disabled:me,onClick:ye,children:s.t("find-replace.dialog.replace")}),u.jsx(p.Button,{disabled:ve,onClick:Me,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function st(){const t=y.useDependency(b),e=y.useDependency(h.ILayoutService),n=y.useDependency(c.IContextService),i=h.useObservable(t.state$,void 0,!0),s=l.useRef(null);l.useEffect(()=>{let f;return s.current&&(f=e.registerContainerElement(s.current)),()=>f==null?void 0:f.dispose()},[e]);const r=l.useRef(null),a=l.useCallback(f=>n.setContextValue(Z,f),[n]),o=l.useCallback(f=>n.setContextValue(Y,f),[n]);return l.useEffect(()=>{var _;const f=S.fromEvent(document,"focusin").subscribe(v=>{var m;v.target&&((m=s.current)!=null&&m.contains(v.target))?a(!0):a(!1),!r.current||!r.current.selectHasFocus()?o(!0):o(!1)});return(_=r.current)==null||_.focus(),a(!0),o(!0),()=>{f.unsubscribe(),a(!1)}},[a,o]),u.jsx("div",{className:$.findReplaceDialogContainer,ref:s,children:i.replaceRevealed?u.jsx(nt,{ref:r}):u.jsx(it,{ref:r})})}function rt(t){const e=t.getCurrentLocale();return l.useMemo(()=>[{label:t.t("find-replace.dialog.find-scope.current-sheet"),value:E.SUBUNIT},{label:t.t("find-replace.dialog.find-scope.workbook"),value:E.UNIT}],[e])}function at(t){const e=t.getCurrentLocale();return l.useMemo(()=>[{label:t.t("find-replace.dialog.find-direction.row"),value:P.ROW},{label:t.t("find-replace.dialog.find-direction.column"),value:P.COLUMN}],[e])}function ot(t){const e=t.getCurrentLocale();return l.useMemo(()=>[{label:t.t("find-replace.dialog.find-by.value"),value:T.VALUE},{label:t.t("find-replace.dialog.find-by.formula"),value:T.FORMULA}],[e])}function I(t){return t.getContextValue(Z)}function ct(t){return t.getContextValue(J)}function oe(t){return t.getContextValue(Y)}const L="7_find-replace-shortcuts";function G(t){return t.getContextValue(c.FOCUSING_SHEET)}function V(t){return!t.getContextValue(c.EDITOR_ACTIVATED)}const lt={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:h.KeyCode.F|h.MetaKeys.CTRL_COMMAND,group:L,preconditions(t){return!I(t)&&G(t)&&V(t)}},dt={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:h.KeyCode.F|h.MetaKeys.CTRL_COMMAND,mac:h.KeyCode.F|h.MetaKeys.MAC_CTRL,preconditions(t){return!I(t)&&G(t)&&V(t)}},ut={id:W.id,description:"find-replace.shortcut.open-replace-dialog",binding:h.KeyCode.H|h.MetaKeys.CTRL_COMMAND,mac:h.KeyCode.H|h.MetaKeys.MAC_CTRL,group:L,preconditions(t){return G(t)&&V(t)&&(!I(t)||!ct(t))}},ht={id:X.id,description:"find-replace.shortcut.go-to-next-match",binding:h.KeyCode.ENTER,group:L,priority:1e3,preconditions(t){return oe(t)&&I(t)}},pt={id:ee.id,description:"find-replace.shortcut.go-to-previous-match",binding:h.KeyCode.ENTER|h.MetaKeys.SHIFT,group:L,priority:1e3,preconditions(t){return oe(t)&&I(t)}};function ft(t){const e=t.get(c.IContextService);return{id:N.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",group:h.MenuGroup.TOOLBAR_OTHERS,type:h.MenuItemType.BUTTON,positions:[h.MenuPosition.TOOLBAR_START],hidden$:h.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:S.combineLatest([e.subscribeContextValue$(c.EDITOR_ACTIVATED),e.subscribeContextValue$(c.FOCUSING_SHEET)]).pipe(S.map(([n,i])=>n||!i))}}var gt=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,mt=(t,e,n,i)=>{for(var s=i>1?void 0:i?_t(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=(i?a(e,n,s):a(s))||s);return i&&s&>(e,n,s),s},C=(t,e)=>(n,i)=>e(n,i,t);const H="DESKTOP_FIND_REPLACE_DIALOG",ce=350,vt=20,St=-90;exports.FindReplaceController=class extends c.RxDisposable{constructor(e,n,i,s,r,a,o,f,_,v,m,F){super(),this._univerInstanceService=e,this._menuService=n,this._shortcutService=i,this._commandService=s,this._findReplaceService=r,this._logService=a,this._dialogService=o,this._contextService=f,this._layoutService=_,this._localeService=v,this._componentManager=m,this._injector=F,this._initCommands(),this._initUI(),this._initShortcuts()}_initCommands(){[N,W,X,ee,se,ne].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initShortcuts(){[ut,lt,dt,pt,ht].forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}_initUI(){this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(ft))),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",st)),this.disposeWithMe(this._componentManager.register("SearchIcon",z)),this._findReplaceService.stateUpdates$.pipe(S.takeUntil(this.dispose$)).subscribe(e=>{e.revealed===!0&&this._openPanel()}),this.disposeWithMe(this._univerInstanceService.focused$.pipe(S.takeUntil(this.dispose$)).subscribe(e=>{(!e||!this._univerInstanceService.getUniverSheetInstance(e))&&this.closePanel()}))}_openPanel(){this._dialogService.open({id:H,draggable:!0,width:ce,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:Ct(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()})}closePanel(){this._dialogService.close(H),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus())}};exports.FindReplaceController=mt([c.OnLifecycle(c.LifecycleStages.Rendered,exports.FindReplaceController),C(0,c.IUniverInstanceService),C(1,h.IMenuService),C(2,h.IShortcutService),C(3,c.ICommandService),C(4,b),C(5,c.ILogService),C(6,h.IDialogService),C(7,c.IContextService),C(8,h.ILayoutService),C(9,M.Inject(c.LocaleService)),C(10,M.Inject(h.ComponentManager)),C(11,M.Inject(M.Injector))],exports.FindReplaceController);function Ct(){const{innerWidth:t}=window;return{x:(t-ce)/2-vt,y:St}}const Rt={"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"},bt=Rt,yt={"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":"查找替换"},le=yt;var Mt=Object.defineProperty,xt=Object.getOwnPropertyDescriptor,Ft=(t,e,n,i)=>{for(var s=i>1?void 0:i?xt(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=(i?a(e,n,s):a(s))||s);return i&&s&&Mt(e,n,s),s},It=(t,e)=>(n,i)=>e(n,i,t);const Dt="FIND_REPLACE";var w;exports.UniverFindReplacePlugin=(w=class extends c.Plugin{constructor(e,n){super(),this._injector=e,this._localeService=n,this._localeService.load({zhCN:le})}onStarting(e){[[exports.FindReplaceController],[b,{useClass:B}]].forEach(n=>{e.add(n)})}},d(w,"pluginName",Dt),w);exports.UniverFindReplacePlugin=Ft([It(1,M.Inject(c.LocaleService))],exports.UniverFindReplacePlugin);exports.FindBy=T;exports.FindDirection=P;exports.FindModel=ke;exports.FindScope=E;exports.IFindReplaceService=b;exports.enUS=bt;exports.zhCN=le;
|