@univerjs/find-replace 0.1.9 → 0.1.11
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 +168 -120
- package/lib/types/controllers/find-replace.controller.d.ts +3 -3
- package/lib/types/controllers/find-replace.menu.d.ts +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/locale/index.d.ts +1 -0
- package/lib/types/locale/ru-RU.d.ts +4 -0
- package/lib/types/locale/zh-CN.d.ts +63 -3
- package/lib/types/plugin.d.ts +1 -1
- package/lib/types/services/find-replace.service.d.ts +2 -2
- package/lib/types/views/dialog/FindReplaceDialog.stories.d.ts +1 -1
- package/lib/types/views/dialog/SearchInput.d.ts +3 -3
- 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 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={};/**
|
|
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,a=t.extend,r=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},r),a)});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(a,r){return q(a,"".concat(e,"-").concat(t.tag,"-").concat(r),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(a){var r=a[0],o=a[1];typeof o=="string"&&(i[r]=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,a=t.length-1,r;a>=0;a--)(r=t[a])&&(s=(i?r(e,n,s):r(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 a=>{const r=this._state.state;We(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),n=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(n);const i=this._matches=n.map(a=>a.getMatches()).flat();if(this.replaceables$.next(i.filter(a=>a.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 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(o=>o.replaceable))}else this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([])});e.forEach(s=>n.add(c.toDisposable(s.activelyChangingMatch$.subscribe(a=>{const r=this._matches.findIndex(o=>o===a);this._state.changeState({matchesPosition:r+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],a=s.moveToNextMatch(),r=this._matches.findIndex(o=>o===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,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],a=s.moveToPreviousMatch(),r=this._matches.findIndex(o=>o===a);this.currentMatch$.next(a),this._matchingModel=s,this._state.changeState({matchesPosition:r+1})}}_moveToInitialMatch(e,n,i=!1){var f;const s=(f=this._univerInstanceService.getFocusedUnit())==null?void 0:f.getUnitId();if(!s)return-1;const a=e.find(_=>_.unitId===s);if(a){this._matchingModel=a;const _=a.moveToNextMatch({stayIfOnMatch:!0,noFocus:i}),v=n.findIndex(m=>m===_);return this.currentMatch$.next(_),v}this._matchingModel=e[0];const r=this._matchingModel.moveToNextMatch({noFocus:i}),o=this._matches.findIndex(_=>_===r);return this.currentMatch$.next(r),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 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;
|
|
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={},a=null,r=null;n!==void 0&&(a=""+n),e.key!==void 0&&(a=""+e.key),e.ref!==void 0&&(r=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:a,ref:r,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 a=await t.get(b).replaceAll(),{success:r,failure:o}=a;return o>0?(r===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",`${r}`,`${o}`)}),!1):(i.show({type:p.MessageType.Success,content:n.t("find-replace.replace.all-success",`${r}`)}),!0)}};function ae(t){const{findCompleted:e,localeService:n,matchesCount:i,matchesPosition:s,findString:a,findReplaceService:r,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?r.moveToNextMatch():s===1&&m===i||m<s?r.moveToPreviousMatch():r.moveToNextMatch()}}),value:a,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 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(a=>a===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),a=y.useDependency(c.ICommandService),r=h.useObservable(s.state$,void 0,!0),{findCompleted:o,findString:f,matchesCount:_,matchesPosition:v}=r,m=l.useCallback(()=>{a.executeCommand(W.id)},[a]),F=l.useCallback(x=>s.changeFindString(x),[s]);return re(s,n),u.jsxs(l.Fragment,{children:[u.jsx(ae,{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),a=y.useDependency(c.ICommandService),r=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}=re(i,n),be=l.useCallback(()=>{F===x?i.moveToNextMatch():(i.changeFindString(x),i.find())},[F,x,i]),ye=l.useCallback(()=>a.executeCommand(ne.id),[a]),Me=l.useCallback(async()=>{await a.executeCommand(se.id),Re()},[a]),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=at(s),Oe=rt(s),Pe=ot(s);return l.useEffect(()=>{const g=A&&v===0;let D=null;return g&&(D=r.show({content:s.t("find-replace.dialog.no-match"),type:p.MessageType.Warning,delay:5e3})),()=>D==null?void 0:D.dispose()},[A,v,r,s]),u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find"),children:u.jsx(ae,{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 a=l.useRef(null),r=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))?r(!0):r(!1),!a.current||!a.current.selectHasFocus()?o(!0):o(!1)});return(_=a.current)==null||_.focus(),r(!0),o(!0),()=>{f.unsubscribe(),r(!1)}},[r,o]),u.jsx("div",{className:$.findReplaceDialogContainer,ref:s,children:i.replaceRevealed?u.jsx(nt,{ref:a}):u.jsx(it,{ref:a})})}function at(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 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,a=t.length-1,r;a>=0;a--)(r=t[a])&&(s=(i?r(e,n,s):r(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,a,r,o,f,_,v,m,F){super(),this._univerInstanceService=e,this._menuService=n,this._shortcutService=i,this._commandService=s,this._findReplaceService=a,this._logService=r,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,Mt={"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":"Найти и заменить"},xt=Mt;var Ft=Object.defineProperty,It=Object.getOwnPropertyDescriptor,Dt=(t,e,n,i)=>{for(var s=i>1?void 0:i?It(e,n):e,a=t.length-1,r;a>=0;a--)(r=t[a])&&(s=(i?r(e,n,s):r(s))||s);return i&&s&&Ft(e,n,s),s},Ot=(t,e)=>(n,i)=>e(n,i,t);const Pt="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",Pt),w);exports.UniverFindReplacePlugin=Dt([Ot(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.ruRU=xt;exports.zhCN=le;
|
package/lib/es/index.js
CHANGED
|
@@ -13,8 +13,8 @@ var m = function() {
|
|
|
13
13
|
return m = Object.assign || function(t) {
|
|
14
14
|
for (var e, n = 1, i = arguments.length; n < i; n++) {
|
|
15
15
|
e = arguments[n];
|
|
16
|
-
for (var
|
|
17
|
-
Object.prototype.hasOwnProperty.call(e,
|
|
16
|
+
for (var r in e)
|
|
17
|
+
Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
|
|
18
18
|
}
|
|
19
19
|
return t;
|
|
20
20
|
}, m.apply(this, arguments);
|
|
@@ -23,31 +23,31 @@ var m = function() {
|
|
|
23
23
|
for (var i in t)
|
|
24
24
|
Object.prototype.hasOwnProperty.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
|
|
25
25
|
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
26
|
-
for (var
|
|
27
|
-
e.indexOf(i[
|
|
26
|
+
for (var r = 0, i = Object.getOwnPropertySymbols(t); r < i.length; r++)
|
|
27
|
+
e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, i[r]) && (n[i[r]] = t[i[r]]);
|
|
28
28
|
return n;
|
|
29
29
|
}, be = B(function(t, e) {
|
|
30
|
-
var n = t.icon, i = t.id,
|
|
31
|
-
return xe(n, "".concat(i), { defIds: n.defIds, idSuffix: d.current }, m({ ref: e, className: o }, a),
|
|
30
|
+
var n = t.icon, i = t.id, r = t.className, s = t.extend, a = Nt(t, ["icon", "id", "className", "extend"]), o = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), d = K("_".concat(jt()));
|
|
31
|
+
return xe(n, "".concat(i), { defIds: n.defIds, idSuffix: d.current }, m({ ref: e, className: o }, a), s);
|
|
32
32
|
});
|
|
33
|
-
function xe(t, e, n, i,
|
|
34
|
-
return Re(t.tag, m(m({ key: e }, At(t, n,
|
|
35
|
-
return xe(
|
|
33
|
+
function xe(t, e, n, i, r) {
|
|
34
|
+
return Re(t.tag, m(m({ key: e }, At(t, n, r)), i), (wt(t, n).children || []).map(function(s, a) {
|
|
35
|
+
return xe(s, "".concat(e, "-").concat(t.tag, "-").concat(a), n, void 0, r);
|
|
36
36
|
}));
|
|
37
37
|
}
|
|
38
38
|
function At(t, e, n) {
|
|
39
39
|
var i = m({}, t.attrs);
|
|
40
40
|
n != null && n.colorChannel1 && i.fill === "colorChannel1" && (i.fill = n.colorChannel1);
|
|
41
|
-
var
|
|
42
|
-
return !
|
|
43
|
-
var a =
|
|
41
|
+
var r = e.defIds;
|
|
42
|
+
return !r || r.length === 0 || (t.tag === "use" && i["xlink:href"] && (i["xlink:href"] = i["xlink:href"] + e.idSuffix), Object.entries(i).forEach(function(s) {
|
|
43
|
+
var a = s[0], o = s[1];
|
|
44
44
|
typeof o == "string" && (i[a] = o.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
45
45
|
})), i;
|
|
46
46
|
}
|
|
47
47
|
function wt(t, e) {
|
|
48
48
|
var n, i = e.defIds;
|
|
49
|
-
return !i || i.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? m(m({}, t), { children: t.children.map(function(
|
|
50
|
-
return typeof
|
|
49
|
+
return !i || i.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? m(m({}, t), { children: t.children.map(function(r) {
|
|
50
|
+
return typeof r.attrs.id == "string" && i && i.indexOf(r.attrs.id) > -1 ? m(m({}, r), { attrs: m(m({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
|
|
51
51
|
}) }) : t;
|
|
52
52
|
}
|
|
53
53
|
function jt() {
|
|
@@ -64,18 +64,18 @@ var Lt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em"
|
|
|
64
64
|
Me.displayName = "SearchSingle16";
|
|
65
65
|
const ye = "FIND_REPLACE_INPUT_FOCUS", Ie = "FIND_REPLACE_DIALOG_FOCUS", Fe = "FIND_REPLACE_REPLACE_REVEALED";
|
|
66
66
|
var Ut = Object.defineProperty, Bt = Object.getOwnPropertyDescriptor, De = (t, e, n, i) => {
|
|
67
|
-
for (var
|
|
68
|
-
(a = t[
|
|
69
|
-
return i &&
|
|
67
|
+
for (var r = i > 1 ? void 0 : i ? Bt(e, n) : e, s = t.length - 1, a; s >= 0; s--)
|
|
68
|
+
(a = t[s]) && (r = (i ? a(e, n, r) : a(r)) || r);
|
|
69
|
+
return i && r && Ut(e, n, r), r;
|
|
70
70
|
}, j = (t, e) => (n, i) => e(n, i, t);
|
|
71
|
-
class
|
|
71
|
+
class Li extends ee {
|
|
72
72
|
}
|
|
73
73
|
const v = ft("find-replace.service");
|
|
74
74
|
function Wt(t) {
|
|
75
75
|
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";
|
|
76
76
|
}
|
|
77
77
|
let Y = class extends ee {
|
|
78
|
-
constructor(e, n, i,
|
|
78
|
+
constructor(e, n, i, r) {
|
|
79
79
|
super();
|
|
80
80
|
c(this, "currentMatch$", new F(null));
|
|
81
81
|
c(this, "replaceables$", new F([]));
|
|
@@ -85,10 +85,10 @@ let Y = class extends ee {
|
|
|
85
85
|
c(this, "_matchingModel", null);
|
|
86
86
|
c(this, "_matches", []);
|
|
87
87
|
c(this, "_currentSearchingDisposables", null);
|
|
88
|
-
this._state = e, this._providers = n, this._univerInstanceService = i, this._logService =
|
|
89
|
-
this._state.stateUpdates$.pipe(Mt(200, void 0, { leading: !0, trailing: !0 })).subscribe(async (
|
|
88
|
+
this._state = e, this._providers = n, this._univerInstanceService = i, this._logService = r, this.disposeWithMe(
|
|
89
|
+
this._state.stateUpdates$.pipe(Mt(200, void 0, { leading: !0, trailing: !0 })).subscribe(async (s) => {
|
|
90
90
|
const a = this._state.state;
|
|
91
|
-
Wt(
|
|
91
|
+
Wt(s) && (a.findString !== "" && !a.replaceRevealed ? (await this._startSearching(), this._state.changeState({ findCompleted: !0 })) : s.replaceRevealed !== !0 && this._stopSearching());
|
|
92
92
|
})
|
|
93
93
|
);
|
|
94
94
|
}
|
|
@@ -108,7 +108,7 @@ let Y = class extends ee {
|
|
|
108
108
|
async _startSearching() {
|
|
109
109
|
if (!this._state.findString)
|
|
110
110
|
return { results: [] };
|
|
111
|
-
const e = Array.from(this._providers), n = this._findModels = (await Promise.all(e.map((
|
|
111
|
+
const e = Array.from(this._providers), n = this._findModels = (await Promise.all(e.map((s) => s.find({
|
|
112
112
|
findString: this._state.findString,
|
|
113
113
|
findDirection: this._state.findDirection,
|
|
114
114
|
findScope: this._state.findScope,
|
|
@@ -118,13 +118,13 @@ let Y = class extends ee {
|
|
|
118
118
|
matchesTheWholeCell: this._state.matchesTheWholeCell
|
|
119
119
|
})))).flat();
|
|
120
120
|
this._subscribeToModelsChanges(n);
|
|
121
|
-
const i = this._matches = n.map((
|
|
122
|
-
if (this.replaceables$.next(i.filter((
|
|
121
|
+
const i = this._matches = n.map((s) => s.getMatches()).flat();
|
|
122
|
+
if (this.replaceables$.next(i.filter((s) => s.replaceable)), !i.length)
|
|
123
123
|
return this._state.changeState({ matchesCount: 0, matchesPosition: 0 }), { results: [] };
|
|
124
|
-
const
|
|
124
|
+
const r = this._moveToInitialMatch(n, i);
|
|
125
125
|
return this._state.changeState({
|
|
126
126
|
matchesCount: i.length,
|
|
127
|
-
matchesPosition:
|
|
127
|
+
matchesPosition: r + 1
|
|
128
128
|
// the matches position start from 1
|
|
129
129
|
}), { results: i };
|
|
130
130
|
}
|
|
@@ -139,16 +139,16 @@ let Y = class extends ee {
|
|
|
139
139
|
}
|
|
140
140
|
// When a document's content changes, we should reset all matches and try to move to the next match.
|
|
141
141
|
_subscribeToModelsChanges(e) {
|
|
142
|
-
const n = this._currentSearchingDisposables = new ct(), i = Ce(e.map((
|
|
143
|
-
const
|
|
144
|
-
if (
|
|
145
|
-
const a = this._moveToInitialMatch(this._findModels,
|
|
146
|
-
this._state.changeState({ matchesCount:
|
|
142
|
+
const n = this._currentSearchingDisposables = new ct(), i = Ce(e.map((r) => r.matchesUpdate$)).pipe(yt(220)).subscribe(([...r]) => {
|
|
143
|
+
const s = this._matches = r.flat();
|
|
144
|
+
if (s.length) {
|
|
145
|
+
const a = this._moveToInitialMatch(this._findModels, s, !0);
|
|
146
|
+
this._state.changeState({ matchesCount: s.length, matchesPosition: a + 1 }), this.replaceables$.next(s.filter((o) => o.replaceable));
|
|
147
147
|
} else
|
|
148
148
|
this._state.changeState({ matchesCount: 0, matchesPosition: 0 }), this.replaceables$.next([]);
|
|
149
149
|
});
|
|
150
|
-
e.forEach((
|
|
151
|
-
const a = this._matches.findIndex((o) => o ===
|
|
150
|
+
e.forEach((r) => n.add(z(r.activelyChangingMatch$.subscribe((s) => {
|
|
151
|
+
const a = this._matches.findIndex((o) => o === s);
|
|
152
152
|
this._state.changeState({ matchesPosition: a + 1 });
|
|
153
153
|
})))), n.add(z(i));
|
|
154
154
|
}
|
|
@@ -156,7 +156,7 @@ let Y = class extends ee {
|
|
|
156
156
|
return this._matchingModel ? this._matchingModel.replace(this._state.replaceString) : !1;
|
|
157
157
|
}
|
|
158
158
|
async replaceAll() {
|
|
159
|
-
const e = await Promise.all(this._findModels.map((n) => n.replaceAll(this._state.replaceString))).then((n) => n.reduce((i,
|
|
159
|
+
const e = await Promise.all(this._findModels.map((n) => n.replaceAll(this._state.replaceString))).then((n) => n.reduce((i, r) => (i.success += r.success, i.failure += r.failure, i), { success: 0, failure: 0 }));
|
|
160
160
|
return e.failure === 0 && this._stopSearching(), e;
|
|
161
161
|
}
|
|
162
162
|
getCurrentMatch() {
|
|
@@ -167,13 +167,13 @@ let Y = class extends ee {
|
|
|
167
167
|
return;
|
|
168
168
|
const e = this._findModels.length === 1, n = this._matchingModel.moveToNextMatch({ loop: e });
|
|
169
169
|
if (n) {
|
|
170
|
-
const i = this._matches.findIndex((
|
|
170
|
+
const i = this._matches.findIndex((r) => r === n);
|
|
171
171
|
this.currentMatch$.next(n), this._state.changeState({
|
|
172
172
|
matchesPosition: i + 1
|
|
173
173
|
});
|
|
174
174
|
} else {
|
|
175
|
-
const i = this._findModels.findIndex((o) => o === this._matchingModel),
|
|
176
|
-
this.currentMatch$.next(
|
|
175
|
+
const i = this._findModels.findIndex((o) => o === this._matchingModel), r = this._findModels[(i + 1) % this._findModels.length], s = r.moveToNextMatch(), a = this._matches.findIndex((o) => o === s);
|
|
176
|
+
this.currentMatch$.next(s), this._matchingModel = r, this._state.changeState({
|
|
177
177
|
matchesPosition: a + 1
|
|
178
178
|
});
|
|
179
179
|
}
|
|
@@ -183,26 +183,26 @@ let Y = class extends ee {
|
|
|
183
183
|
return;
|
|
184
184
|
const e = this._findModels.length === 1, n = this._matchingModel.moveToPreviousMatch({ loop: e });
|
|
185
185
|
if (n) {
|
|
186
|
-
const i = this._matches.findIndex((
|
|
186
|
+
const i = this._matches.findIndex((r) => r === n);
|
|
187
187
|
this.currentMatch$.next(n), this._state.changeState({
|
|
188
188
|
matchesPosition: i + 1
|
|
189
189
|
});
|
|
190
190
|
} else {
|
|
191
|
-
const i = this._findModels.findIndex((o) => o === this._matchingModel),
|
|
192
|
-
this.currentMatch$.next(
|
|
191
|
+
const i = this._findModels.findIndex((o) => o === this._matchingModel), r = this._findModels[(i - 1 + this._findModels.length) % this._findModels.length], s = r.moveToPreviousMatch(), a = this._matches.findIndex((o) => o === s);
|
|
192
|
+
this.currentMatch$.next(s), this._matchingModel = r, this._state.changeState({
|
|
193
193
|
matchesPosition: a + 1
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
_moveToInitialMatch(e, n, i = !1) {
|
|
198
198
|
var d;
|
|
199
|
-
const
|
|
200
|
-
if (!
|
|
199
|
+
const r = (d = this._univerInstanceService.getFocusedUnit()) == null ? void 0 : d.getUnitId();
|
|
200
|
+
if (!r)
|
|
201
201
|
return -1;
|
|
202
|
-
const
|
|
203
|
-
if (
|
|
204
|
-
this._matchingModel =
|
|
205
|
-
const u =
|
|
202
|
+
const s = e.find((u) => u.unitId === r);
|
|
203
|
+
if (s) {
|
|
204
|
+
this._matchingModel = s;
|
|
205
|
+
const u = s.moveToNextMatch({ stayIfOnMatch: !0, noFocus: i }), f = n.findIndex((p) => p === u);
|
|
206
206
|
return this.currentMatch$.next(u), f;
|
|
207
207
|
}
|
|
208
208
|
this._matchingModel = e[0];
|
|
@@ -432,7 +432,7 @@ const W = {
|
|
|
432
432
|
const e = t.get(v);
|
|
433
433
|
return e.revealed ? e.focusFindInput() : e.start(), !0;
|
|
434
434
|
}
|
|
435
|
-
},
|
|
435
|
+
}, re = {
|
|
436
436
|
id: "ui.operation.open-replace-dialog",
|
|
437
437
|
type: M.OPERATION,
|
|
438
438
|
handler: (t) => {
|
|
@@ -460,14 +460,14 @@ var Te = { exports: {} }, k = {};
|
|
|
460
460
|
*/
|
|
461
461
|
var Gt = Pt, Vt = Symbol.for("react.element"), Ht = Symbol.for("react.fragment"), qt = Object.prototype.hasOwnProperty, zt = Gt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, Kt = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
462
462
|
function Ee(t, e, n) {
|
|
463
|
-
var i,
|
|
464
|
-
n !== void 0 && (
|
|
463
|
+
var i, r = {}, s = null, a = null;
|
|
464
|
+
n !== void 0 && (s = "" + n), e.key !== void 0 && (s = "" + e.key), e.ref !== void 0 && (a = e.ref);
|
|
465
465
|
for (i in e)
|
|
466
|
-
qt.call(e, i) && !Kt.hasOwnProperty(i) && (
|
|
466
|
+
qt.call(e, i) && !Kt.hasOwnProperty(i) && (r[i] = e[i]);
|
|
467
467
|
if (t && t.defaultProps)
|
|
468
468
|
for (i in e = t.defaultProps, e)
|
|
469
|
-
|
|
470
|
-
return { $$typeof: Vt, type: t, key:
|
|
469
|
+
r[i] === void 0 && (r[i] = e[i]);
|
|
470
|
+
return { $$typeof: Vt, type: t, key: s, ref: a, props: r, _owner: zt.current };
|
|
471
471
|
}
|
|
472
472
|
k.Fragment = Ht;
|
|
473
473
|
k.jsx = Ee;
|
|
@@ -490,7 +490,7 @@ const $e = {
|
|
|
490
490
|
confirmText: n.t("button.confirm")
|
|
491
491
|
}))
|
|
492
492
|
return !1;
|
|
493
|
-
const
|
|
493
|
+
const s = await t.get(v).replaceAll(), { success: a, failure: o } = s;
|
|
494
494
|
return o > 0 ? (a === 0 ? i.show({
|
|
495
495
|
type: $.Error,
|
|
496
496
|
content: n.t("find-replace.replace.all-failure")
|
|
@@ -504,7 +504,7 @@ const $e = {
|
|
|
504
504
|
}
|
|
505
505
|
};
|
|
506
506
|
function Ae(t) {
|
|
507
|
-
const { findCompleted: e, localeService: n, matchesCount: i, matchesPosition:
|
|
507
|
+
const { findCompleted: e, localeService: n, matchesCount: i, matchesPosition: r, findString: s, findReplaceService: a, onChange: o, ...d } = t, f = e && i === 0 ? n.t("find-replace.dialog.no-result") : i === 0 ? " " : void 0;
|
|
508
508
|
return /* @__PURE__ */ l.jsx(
|
|
509
509
|
Tt,
|
|
510
510
|
{
|
|
@@ -515,14 +515,14 @@ function Ae(t) {
|
|
|
515
515
|
{
|
|
516
516
|
loop: !0,
|
|
517
517
|
text: f,
|
|
518
|
-
value:
|
|
518
|
+
value: r,
|
|
519
519
|
total: i,
|
|
520
520
|
onChange: (p) => {
|
|
521
|
-
|
|
521
|
+
r === i && p === 1 ? a.moveToNextMatch() : r === 1 && p === i || p < r ? a.moveToPreviousMatch() : a.moveToNextMatch();
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
524
|
),
|
|
525
|
-
value:
|
|
525
|
+
value: s,
|
|
526
526
|
onChange: (p) => o == null ? void 0 : o(p),
|
|
527
527
|
...d
|
|
528
528
|
}
|
|
@@ -537,22 +537,22 @@ const Zt = "univer-find-replace-dialog-container", Jt = "univer-find-replace-exp
|
|
|
537
537
|
};
|
|
538
538
|
function we(t, e) {
|
|
539
539
|
const n = _(() => {
|
|
540
|
-
var
|
|
541
|
-
(
|
|
540
|
+
var r;
|
|
541
|
+
(r = document.querySelector(".univer-find-input input")) == null || r.focus();
|
|
542
542
|
}, []), i = _(() => {
|
|
543
|
-
const
|
|
544
|
-
return Array.from(
|
|
543
|
+
const r = document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");
|
|
544
|
+
return Array.from(r).some((s) => s === document.activeElement);
|
|
545
545
|
}, []);
|
|
546
546
|
return Ot(e, () => ({ focus: n, selectHasFocus: i })), w(() => {
|
|
547
|
-
const
|
|
548
|
-
return () =>
|
|
547
|
+
const r = t.focusSignal$.subscribe(() => n());
|
|
548
|
+
return () => r.unsubscribe();
|
|
549
549
|
}, [t, n]), { focus: n, selectHasFocus: i };
|
|
550
550
|
}
|
|
551
551
|
const ti = B(function(e, n) {
|
|
552
|
-
const i = S(D),
|
|
553
|
-
|
|
554
|
-
}, [
|
|
555
|
-
return we(
|
|
552
|
+
const i = S(D), r = S(v), s = S(te), a = I(r.state$, void 0, !0), { findCompleted: o, findString: d, matchesCount: u, matchesPosition: f } = a, p = _(() => {
|
|
553
|
+
s.executeCommand(re.id);
|
|
554
|
+
}, [s]), O = _((C) => r.changeFindString(C), [r]);
|
|
555
|
+
return we(r, n), /* @__PURE__ */ l.jsxs(E, { children: [
|
|
556
556
|
/* @__PURE__ */ l.jsx(
|
|
557
557
|
Ae,
|
|
558
558
|
{
|
|
@@ -560,7 +560,7 @@ const ti = B(function(e, n) {
|
|
|
560
560
|
className: "univer-find-input",
|
|
561
561
|
matchesCount: u,
|
|
562
562
|
matchesPosition: f,
|
|
563
|
-
findReplaceService:
|
|
563
|
+
findReplaceService: r,
|
|
564
564
|
localeService: i,
|
|
565
565
|
findString: d,
|
|
566
566
|
onChange: O
|
|
@@ -569,7 +569,7 @@ const ti = B(function(e, n) {
|
|
|
569
569
|
/* @__PURE__ */ l.jsx("div", { className: L.findReplaceExpandContainer, children: /* @__PURE__ */ l.jsx(N, { type: "text", size: "small", onClick: p, children: i.t("find-replace.dialog.advanced-finding") }) })
|
|
570
570
|
] });
|
|
571
571
|
}), ii = B(function(e, n) {
|
|
572
|
-
const i = S(v),
|
|
572
|
+
const i = S(v), r = S(D), s = S(te), a = S(me), o = I(i.currentMatch$, void 0, !0), d = I(i.replaceables$, void 0, !0), u = I(i.state$, void 0, !0), {
|
|
573
573
|
matchesCount: f,
|
|
574
574
|
matchesPosition: p,
|
|
575
575
|
findString: O,
|
|
@@ -589,25 +589,25 @@ const ti = B(function(e, n) {
|
|
|
589
589
|
[i]
|
|
590
590
|
), { focus: Ze } = we(i, n), Je = _(() => {
|
|
591
591
|
O === C ? i.moveToNextMatch() : (i.changeFindString(C), i.find());
|
|
592
|
-
}, [O, C, i]), Qe = _(() =>
|
|
593
|
-
await
|
|
594
|
-
}, [
|
|
592
|
+
}, [O, C, i]), Qe = _(() => s.executeCommand($e.id), [s]), Xe = _(async () => {
|
|
593
|
+
await s.executeCommand(Ne.id), Ze();
|
|
594
|
+
}, [s]), et = _((h) => {
|
|
595
595
|
i.changeFindDirection(h);
|
|
596
596
|
}, [i]), tt = _((h) => {
|
|
597
597
|
i.changeFindScope(h);
|
|
598
598
|
}, [i]), it = _((h) => {
|
|
599
599
|
i.changeFindBy(h);
|
|
600
|
-
}, [i]), nt =
|
|
600
|
+
}, [i]), nt = ri(r), rt = si(r), st = ai(r);
|
|
601
601
|
return w(() => {
|
|
602
602
|
const h = V && f === 0;
|
|
603
603
|
let T = null;
|
|
604
604
|
return h && (T = a.show({
|
|
605
|
-
content:
|
|
605
|
+
content: r.t("find-replace.dialog.no-match"),
|
|
606
606
|
type: $.Warning,
|
|
607
607
|
delay: 5e3
|
|
608
608
|
})), () => T == null ? void 0 : T.dispose();
|
|
609
|
-
}, [V, f, a,
|
|
610
|
-
/* @__PURE__ */ l.jsx(R, { label:
|
|
609
|
+
}, [V, f, a, r]), /* @__PURE__ */ l.jsxs(E, { children: [
|
|
610
|
+
/* @__PURE__ */ l.jsx(R, { label: r.t("find-replace.dialog.find"), children: /* @__PURE__ */ l.jsx(
|
|
611
611
|
Ae,
|
|
612
612
|
{
|
|
613
613
|
findCompleted: V,
|
|
@@ -615,23 +615,23 @@ const ti = B(function(e, n) {
|
|
|
615
615
|
matchesCount: f,
|
|
616
616
|
matchesPosition: p,
|
|
617
617
|
findReplaceService: i,
|
|
618
|
-
localeService:
|
|
618
|
+
localeService: r,
|
|
619
619
|
findString: C,
|
|
620
620
|
onChange: Ke
|
|
621
621
|
}
|
|
622
622
|
) }),
|
|
623
|
-
/* @__PURE__ */ l.jsx(R, { label:
|
|
623
|
+
/* @__PURE__ */ l.jsx(R, { label: r.t("find-replace.dialog.replace"), children: /* @__PURE__ */ l.jsx(
|
|
624
624
|
$t,
|
|
625
625
|
{
|
|
626
|
-
placeholder:
|
|
626
|
+
placeholder: r.t("find-replace.dialog.replace-placeholder"),
|
|
627
627
|
value: Ue,
|
|
628
628
|
onChange: (h) => Ye(h)
|
|
629
629
|
}
|
|
630
630
|
) }),
|
|
631
|
-
/* @__PURE__ */ l.jsx(R, { label:
|
|
631
|
+
/* @__PURE__ */ l.jsx(R, { label: r.t("find-replace.dialog.find-direction.title"), children: /* @__PURE__ */ l.jsx(H, { value: ke, options: rt, onChange: et }) }),
|
|
632
632
|
/* @__PURE__ */ l.jsx(ce, { children: /* @__PURE__ */ l.jsxs(E, { children: [
|
|
633
|
-
/* @__PURE__ */ l.jsx(R, { label:
|
|
634
|
-
/* @__PURE__ */ l.jsx(R, { label:
|
|
633
|
+
/* @__PURE__ */ l.jsx(R, { label: r.t("find-replace.dialog.find-scope.title"), children: /* @__PURE__ */ l.jsx(H, { value: Ge, options: nt, onChange: tt }) }),
|
|
634
|
+
/* @__PURE__ */ l.jsx(R, { label: r.t("find-replace.dialog.find-by.title"), children: /* @__PURE__ */ l.jsx(H, { value: Ve, options: st, onChange: it }) })
|
|
635
635
|
] }) }),
|
|
636
636
|
/* @__PURE__ */ l.jsx(ce, { children: /* @__PURE__ */ l.jsxs(E, { children: [
|
|
637
637
|
/* @__PURE__ */ l.jsx(R, { children: /* @__PURE__ */ l.jsx(
|
|
@@ -641,7 +641,7 @@ const ti = B(function(e, n) {
|
|
|
641
641
|
onChange: (h) => {
|
|
642
642
|
i.changeCaseSensitive(h);
|
|
643
643
|
},
|
|
644
|
-
children:
|
|
644
|
+
children: r.t("find-replace.dialog.case-sensitive")
|
|
645
645
|
}
|
|
646
646
|
) }),
|
|
647
647
|
/* @__PURE__ */ l.jsx(R, { children: /* @__PURE__ */ l.jsx(
|
|
@@ -651,26 +651,26 @@ const ti = B(function(e, n) {
|
|
|
651
651
|
onChange: (h) => {
|
|
652
652
|
i.changeMatchesTheWholeCell(h);
|
|
653
653
|
},
|
|
654
|
-
children:
|
|
654
|
+
children: r.t("find-replace.dialog.match-the-whole-cell")
|
|
655
655
|
}
|
|
656
656
|
) })
|
|
657
657
|
] }) }),
|
|
658
658
|
/* @__PURE__ */ l.jsxs("div", { className: L.findReplaceButtonsGroup, children: [
|
|
659
|
-
/* @__PURE__ */ l.jsx(N, { type: "primary", onClick: Je, disabled: He, children:
|
|
659
|
+
/* @__PURE__ */ l.jsx(N, { type: "primary", onClick: Je, disabled: He, children: r.t("find-replace.dialog.find") }),
|
|
660
660
|
/* @__PURE__ */ l.jsxs("span", { className: L.findReplaceButtonsGroupRight, children: [
|
|
661
|
-
/* @__PURE__ */ l.jsx(N, { disabled: qe, onClick: Qe, children:
|
|
662
|
-
/* @__PURE__ */ l.jsx(N, { disabled: ze, onClick: Xe, children:
|
|
661
|
+
/* @__PURE__ */ l.jsx(N, { disabled: qe, onClick: Qe, children: r.t("find-replace.dialog.replace") }),
|
|
662
|
+
/* @__PURE__ */ l.jsx(N, { disabled: ze, onClick: Xe, children: r.t("find-replace.dialog.replace-all") })
|
|
663
663
|
] })
|
|
664
664
|
] })
|
|
665
665
|
] });
|
|
666
666
|
});
|
|
667
667
|
function ni() {
|
|
668
|
-
const t = S(v), e = S(ve), n = S(U), i = I(t.state$, void 0, !0),
|
|
668
|
+
const t = S(v), e = S(ve), n = S(U), i = I(t.state$, void 0, !0), r = K(null);
|
|
669
669
|
w(() => {
|
|
670
670
|
let d;
|
|
671
|
-
return
|
|
671
|
+
return r.current && (d = e.registerContainerElement(r.current)), () => d == null ? void 0 : d.dispose();
|
|
672
672
|
}, [e]);
|
|
673
|
-
const
|
|
673
|
+
const s = K(null), a = _(
|
|
674
674
|
(d) => n.setContextValue(Ie, d),
|
|
675
675
|
[n]
|
|
676
676
|
), o = _(
|
|
@@ -681,21 +681,21 @@ function ni() {
|
|
|
681
681
|
var u;
|
|
682
682
|
const d = It(document, "focusin").subscribe((f) => {
|
|
683
683
|
var p;
|
|
684
|
-
f.target && ((p =
|
|
684
|
+
f.target && ((p = r.current) != null && p.contains(f.target)) ? a(!0) : a(!1), !s.current || !s.current.selectHasFocus() ? o(!0) : o(!1);
|
|
685
685
|
});
|
|
686
|
-
return (u =
|
|
686
|
+
return (u = s.current) == null || u.focus(), a(!0), o(!0), () => {
|
|
687
687
|
d.unsubscribe(), a(!1);
|
|
688
688
|
};
|
|
689
|
-
}, [a, o]), /* @__PURE__ */ l.jsx("div", { className: L.findReplaceDialogContainer, ref:
|
|
689
|
+
}, [a, o]), /* @__PURE__ */ l.jsx("div", { className: L.findReplaceDialogContainer, ref: r, children: i.replaceRevealed ? /* @__PURE__ */ l.jsx(ii, { ref: s }) : /* @__PURE__ */ l.jsx(ti, { ref: s }) });
|
|
690
690
|
}
|
|
691
|
-
function
|
|
691
|
+
function ri(t) {
|
|
692
692
|
const e = t.getCurrentLocale();
|
|
693
693
|
return ie(() => [
|
|
694
694
|
{ label: t.t("find-replace.dialog.find-scope.current-sheet"), value: Q.SUBUNIT },
|
|
695
695
|
{ label: t.t("find-replace.dialog.find-scope.workbook"), value: Q.UNIT }
|
|
696
696
|
], [e]);
|
|
697
697
|
}
|
|
698
|
-
function
|
|
698
|
+
function si(t) {
|
|
699
699
|
const e = t.getCurrentLocale();
|
|
700
700
|
return ie(() => [
|
|
701
701
|
{ label: t.t("find-replace.dialog.find-direction.row"), value: Z.ROW },
|
|
@@ -719,7 +719,7 @@ function je(t) {
|
|
|
719
719
|
return t.getContextValue(ye);
|
|
720
720
|
}
|
|
721
721
|
const G = "7_find-replace-shortcuts";
|
|
722
|
-
function
|
|
722
|
+
function se(t) {
|
|
723
723
|
return t.getContextValue(fe);
|
|
724
724
|
}
|
|
725
725
|
function ae(t) {
|
|
@@ -731,7 +731,7 @@ const ci = {
|
|
|
731
731
|
binding: b.F | x.CTRL_COMMAND,
|
|
732
732
|
group: G,
|
|
733
733
|
preconditions(t) {
|
|
734
|
-
return !P(t) &&
|
|
734
|
+
return !P(t) && se(t) && ae(t);
|
|
735
735
|
}
|
|
736
736
|
}, li = {
|
|
737
737
|
id: W.id,
|
|
@@ -739,16 +739,16 @@ const ci = {
|
|
|
739
739
|
binding: b.F | x.CTRL_COMMAND,
|
|
740
740
|
mac: b.F | x.MAC_CTRL,
|
|
741
741
|
preconditions(t) {
|
|
742
|
-
return !P(t) &&
|
|
742
|
+
return !P(t) && se(t) && ae(t);
|
|
743
743
|
}
|
|
744
744
|
}, di = {
|
|
745
|
-
id:
|
|
745
|
+
id: re.id,
|
|
746
746
|
description: "find-replace.shortcut.open-replace-dialog",
|
|
747
747
|
binding: b.H | x.CTRL_COMMAND,
|
|
748
748
|
mac: b.H | x.MAC_CTRL,
|
|
749
749
|
group: G,
|
|
750
750
|
preconditions(t) {
|
|
751
|
-
return
|
|
751
|
+
return se(t) && ae(t) && (!P(t) || !oi(t));
|
|
752
752
|
}
|
|
753
753
|
}, hi = {
|
|
754
754
|
id: Pe.id,
|
|
@@ -786,19 +786,19 @@ function pi(t) {
|
|
|
786
786
|
};
|
|
787
787
|
}
|
|
788
788
|
var fi = Object.defineProperty, _i = Object.getOwnPropertyDescriptor, gi = (t, e, n, i) => {
|
|
789
|
-
for (var
|
|
790
|
-
(a = t[
|
|
791
|
-
return i &&
|
|
789
|
+
for (var r = i > 1 ? void 0 : i ? _i(e, n) : e, s = t.length - 1, a; s >= 0; s--)
|
|
790
|
+
(a = t[s]) && (r = (i ? a(e, n, r) : a(r)) || r);
|
|
791
|
+
return i && r && fi(e, n, r), r;
|
|
792
792
|
}, g = (t, e) => (n, i) => e(n, i, t);
|
|
793
793
|
const de = "DESKTOP_FIND_REPLACE_DIALOG", Le = 350, mi = 20, vi = -90;
|
|
794
794
|
let A = class extends dt {
|
|
795
|
-
constructor(t, e, n, i,
|
|
796
|
-
super(), this._univerInstanceService = t, this._menuService = e, this._shortcutService = n, this._commandService = i, this._findReplaceService =
|
|
795
|
+
constructor(t, e, n, i, r, s, a, o, d, u, f, p) {
|
|
796
|
+
super(), this._univerInstanceService = t, this._menuService = e, this._shortcutService = n, this._commandService = i, this._findReplaceService = r, this._logService = s, this._dialogService = a, this._contextService = o, this._layoutService = d, this._localeService = u, this._componentManager = f, this._injector = p, this._initCommands(), this._initUI(), this._initShortcuts();
|
|
797
797
|
}
|
|
798
798
|
_initCommands() {
|
|
799
799
|
[
|
|
800
800
|
W,
|
|
801
|
-
|
|
801
|
+
re,
|
|
802
802
|
Pe,
|
|
803
803
|
Oe,
|
|
804
804
|
Ne,
|
|
@@ -908,7 +908,7 @@ const Ci = {
|
|
|
908
908
|
}
|
|
909
909
|
},
|
|
910
910
|
"find-replace-shortcuts": "Find & Replace"
|
|
911
|
-
},
|
|
911
|
+
}, Ui = Ci, Ri = {
|
|
912
912
|
"find-replace": {
|
|
913
913
|
toolbar: "查找替换",
|
|
914
914
|
shortcut: {
|
|
@@ -955,13 +955,60 @@ const Ci = {
|
|
|
955
955
|
}
|
|
956
956
|
},
|
|
957
957
|
"find-replace-shortcuts": "查找替换"
|
|
958
|
-
}, bi = Ri
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
958
|
+
}, bi = Ri, xi = {
|
|
959
|
+
"find-replace": {
|
|
960
|
+
toolbar: "Найти и заменить",
|
|
961
|
+
shortcut: {
|
|
962
|
+
"open-find-dialog": "Открыть диалог поиска",
|
|
963
|
+
"open-replace-dialog": "Открыть диалог замены",
|
|
964
|
+
"close-dialog": "Закрыть диалог поиска и замены",
|
|
965
|
+
"go-to-next-match": "Перейти к следующему совпадению",
|
|
966
|
+
"go-to-previous-match": "Перейти к предыдущему совпадению"
|
|
967
|
+
},
|
|
968
|
+
dialog: {
|
|
969
|
+
title: "Найти",
|
|
970
|
+
find: "Найти",
|
|
971
|
+
replace: "Заменить",
|
|
972
|
+
"replace-all": "Заменить все",
|
|
973
|
+
"case-sensitive": "С учетом регистра",
|
|
974
|
+
"find-placeholder": "Найти в этом листе",
|
|
975
|
+
"advanced-finding": "Расширенный поиск и замена",
|
|
976
|
+
"replace-placeholder": "Введите строку для замены",
|
|
977
|
+
"match-the-whole-cell": "Точное совпадение",
|
|
978
|
+
"find-direction": {
|
|
979
|
+
title: "Направление поиска",
|
|
980
|
+
row: "Поиск по строкам",
|
|
981
|
+
column: "Поиск по столбцам"
|
|
982
|
+
},
|
|
983
|
+
"find-scope": {
|
|
984
|
+
title: "Область поиска",
|
|
985
|
+
"current-sheet": "Текущий лист",
|
|
986
|
+
workbook: "Книга"
|
|
987
|
+
},
|
|
988
|
+
"find-by": {
|
|
989
|
+
title: "Поиск по",
|
|
990
|
+
value: "Поиск по значению",
|
|
991
|
+
formula: "Поиск по формуле"
|
|
992
|
+
},
|
|
993
|
+
"no-match": "Поиск завершен, совпадений не найдено.",
|
|
994
|
+
"no-result": "Нет результатов"
|
|
995
|
+
},
|
|
996
|
+
replace: {
|
|
997
|
+
"all-success": "Заменены все {0} совпадений",
|
|
998
|
+
"all-failure": "Не удалось заменить",
|
|
999
|
+
confirm: {
|
|
1000
|
+
title: "Вы уверены, что хотите заменить все совпадения?"
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
},
|
|
1004
|
+
"find-replace-shortcuts": "Найти и заменить"
|
|
1005
|
+
}, Bi = xi;
|
|
1006
|
+
var Mi = Object.defineProperty, yi = Object.getOwnPropertyDescriptor, Ii = (t, e, n, i) => {
|
|
1007
|
+
for (var r = i > 1 ? void 0 : i ? yi(e, n) : e, s = t.length - 1, a; s >= 0; s--)
|
|
1008
|
+
(a = t[s]) && (r = (i ? a(e, n, r) : a(r)) || r);
|
|
1009
|
+
return i && r && Mi(e, n, r), r;
|
|
1010
|
+
}, Fi = (t, e) => (n, i) => e(n, i, t);
|
|
1011
|
+
const Di = "FIND_REPLACE";
|
|
965
1012
|
var q;
|
|
966
1013
|
let he = (q = class extends pt {
|
|
967
1014
|
constructor(t, e) {
|
|
@@ -976,18 +1023,19 @@ let he = (q = class extends pt {
|
|
|
976
1023
|
}
|
|
977
1024
|
);
|
|
978
1025
|
}
|
|
979
|
-
}, c(q, "pluginName",
|
|
980
|
-
he =
|
|
981
|
-
|
|
1026
|
+
}, c(q, "pluginName", Di), q);
|
|
1027
|
+
he = Ii([
|
|
1028
|
+
Fi(1, y(D))
|
|
982
1029
|
], he);
|
|
983
1030
|
export {
|
|
984
1031
|
J as FindBy,
|
|
985
1032
|
Z as FindDirection,
|
|
986
|
-
|
|
1033
|
+
Li as FindModel,
|
|
987
1034
|
A as FindReplaceController,
|
|
988
1035
|
Q as FindScope,
|
|
989
1036
|
v as IFindReplaceService,
|
|
990
1037
|
he as UniverFindReplacePlugin,
|
|
991
|
-
|
|
1038
|
+
Ui as enUS,
|
|
1039
|
+
Bi as ruRU,
|
|
992
1040
|
bi as zhCN
|
|
993
1041
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IFindReplaceService } from '../services/find-replace.service';
|
|
2
|
-
import { Injector } from '@wendellhu/redi';
|
|
3
|
-
import { ComponentManager, IDialogService, ILayoutService, IMenuService, IShortcutService } from '@univerjs/ui';
|
|
4
1
|
import { ICommandService, IContextService, ILogService, IUniverInstanceService, LocaleService, RxDisposable } from '@univerjs/core';
|
|
2
|
+
import { ComponentManager, IDialogService, ILayoutService, IMenuService, IShortcutService } from '@univerjs/ui';
|
|
3
|
+
import { Injector } from '@wendellhu/redi';
|
|
4
|
+
import { IFindReplaceService } from '../services/find-replace.service';
|
|
5
5
|
|
|
6
6
|
export declare class FindReplaceController extends RxDisposable {
|
|
7
7
|
private readonly _univerInstanceService;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -17,4 +17,4 @@ 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 } from './locale';
|
|
20
|
+
export { enUS, zhCN, ruRU } from './locale';
|
|
@@ -1,4 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
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
|
+
'find-placeholder': string;
|
|
32
|
+
'advanced-finding': string;
|
|
33
|
+
'replace-placeholder': string;
|
|
34
|
+
'case-sensitive': string;
|
|
35
|
+
'match-the-whole-cell': string;
|
|
36
|
+
'find-scope': {
|
|
37
|
+
title: string;
|
|
38
|
+
'current-sheet': string;
|
|
39
|
+
workbook: string;
|
|
40
|
+
};
|
|
41
|
+
'find-direction': {
|
|
42
|
+
title: string;
|
|
43
|
+
column: string;
|
|
44
|
+
row: string;
|
|
45
|
+
};
|
|
46
|
+
'find-by': {
|
|
47
|
+
title: string;
|
|
48
|
+
formula: string;
|
|
49
|
+
value: 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
|
+
};
|
|
4
64
|
export default locale;
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Observable, BehaviorSubject } from 'rxjs';
|
|
2
|
-
import { IDisposable, Injector } from '@wendellhu/redi';
|
|
3
1
|
import { Nullable, Disposable, IContextService, ILogService, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
+
import { IDisposable, Injector } from '@wendellhu/redi';
|
|
3
|
+
import { Observable, BehaviorSubject } from 'rxjs';
|
|
4
4
|
|
|
5
5
|
export type FindProgressFn = () => void;
|
|
6
6
|
export interface IFindComplete<T extends IFindMatch = IFindMatch> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IFindReplaceService } from '../../services/find-replace.service';
|
|
2
|
-
import { default as React } from 'react';
|
|
3
|
-
import { IInputWithSlotProps } from '@univerjs/design';
|
|
4
1
|
import { LocaleService } from '@univerjs/core';
|
|
2
|
+
import { IInputWithSlotProps } from '@univerjs/design';
|
|
3
|
+
import { default as React } from 'react';
|
|
4
|
+
import { IFindReplaceService } from '../../services/find-replace.service';
|
|
5
5
|
|
|
6
6
|
export interface ISearchInputProps extends Pick<IInputWithSlotProps, 'onFocus' | 'onBlur' | 'className' | 'onChange'> {
|
|
7
7
|
findCompleted: boolean;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(d,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):(d=typeof globalThis<"u"?globalThis:d||self,r(d.UniverFindReplace={},d.UniverCore,d["@wendellhu/redi"],d.UniverUi,d.rxjs,d.UniverEngineRender,d.React,d.UniverDesign,d["@wendellhu/redi/react-bindings"]))})(this,function(d,r,R,p,S,he,l,f,F){"use strict";var Rt=Object.defineProperty;var bt=(d,r,R)=>r in d?Rt(d,r,{enumerable:!0,configurable:!0,writable:!0,value:R}):d[r]=R;var h=(d,r,R)=>(bt(d,typeof r!="symbol"?r+"":r,R),R);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)},ue=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},$=l.forwardRef(function(n,e){var i=n.icon,t=n.id,a=n.className,s=n.extend,o=ue(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(a||"").trim(),_=l.useRef("_".concat(_e()));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 l.createElement(n.tag,b(b({key:e},pe(n,i,a)),t),(fe(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 fe(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 _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(n,e){return l.createElement($,Object.assign({},n,{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 me=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,X=(n,e,i,t)=>{for(var a=t>1?void 0:t?ve(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&&me(e,i,a),a},O=(n,e)=>(i,t)=>e(i,t,n);class Se extends r.Disposable{}const y=R.createIdentifier("find-replace.service");function Ce(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 S.BehaviorSubject(null));h(this,"replaceables$",new S.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(S.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async s=>{const o=this._state.state;Ce(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=S.combineLatest(e.map(a=>a.matchesUpdate$)).pipe(S.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(m=>m.unitId===a);if(s){this._matchingModel=s;const m=s.moveToNextMatch({stayIfOnMatch:!0,noFocus:t}),C=i.findIndex(v=>v===m);return this.currentMatch$.next(m),C}this._matchingModel=e[0];const o=this._matchingModel.moveToNextMatch({noFocus:t}),c=this._matches.findIndex(m=>m===o);return this.currentMatch$.next(o),c}};U=X([O(2,r.IUniverInstanceService),O(3,r.ILogService)],U);var P=(n=>(n.ROW="row",n.COLUMN="column",n))(P||{}),T=(n=>(n.VALUE="value",n.FORMULA="formula",n))(T||{}),E=(n=>(n.SUBUNIT="subunit",n.UNIT="unit",n))(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 Re{constructor(){h(this,"_stateUpdates$",new S.Subject);h(this,"stateUpdates$",this._stateUpdates$.asObservable());h(this,"_state$",new S.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 Re);h(this,"_model");h(this,"_currentMatch$",new S.BehaviorSubject(null));h(this,"currentMatch$",this._currentMatch$.asObservable());h(this,"_replaceables$",new S.BehaviorSubject([]));h(this,"replaceables$",this._replaceables$.asObservable());h(this,"_focusSignal$",new S.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(he.RENDER_RAW_FORMULA_KEY,e)}};k=X([O(0,R.Inject(R.Injector)),O(1,r.IContextService)],k);const N={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:{}},w={};/**
|
|
1
|
+
(function(d,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):(d=typeof globalThis<"u"?globalThis:d||self,r(d.UniverFindReplace={},d.UniverCore,d["@wendellhu/redi"],d.UniverUi,d.rxjs,d.UniverEngineRender,d.React,d.UniverDesign,d["@wendellhu/redi/react-bindings"]))})(this,function(d,r,R,p,S,he,c,f,F){"use strict";var bt=Object.defineProperty;var yt=(d,r,R)=>r in d?bt(d,r,{enumerable:!0,configurable:!0,writable:!0,value:R}):d[r]=R;var h=(d,r,R)=>(yt(d,typeof r!="symbol"?r+"":r,R),R);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)},ue=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=c.forwardRef(function(n,e){var i=n.icon,t=n.id,a=n.className,s=n.extend,o=ue(n,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(t," ").concat(a||"").trim(),_=c.useRef("_".concat(_e()));return z(i,"".concat(t),{defIds:i.defIds,idSuffix:_.current},b({ref:e,className:l},o),s)});function z(n,e,i,t,a){return c.createElement(n.tag,b(b({key:e},pe(n,i,a)),t),(fe(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],l=s[1];typeof l=="string"&&(t[o]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function fe(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 _e(){return Math.random().toString(36).substring(2,8)}K.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=c.forwardRef(function(n,e){return c.createElement(K,Object.assign({},n,{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 me=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,X=(n,e,i,t)=>{for(var a=t>1?void 0:t?ve(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&&me(e,i,a),a},O=(n,e)=>(i,t)=>e(i,t,n);class Se extends r.Disposable{}const y=R.createIdentifier("find-replace.service");function Ce(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 S.BehaviorSubject(null));h(this,"replaceables$",new S.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(S.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async s=>{const o=this._state.state;Ce(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=S.combineLatest(e.map(a=>a.matchesUpdate$)).pipe(S.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(l=>l.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(l=>l===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(l=>l===this._matchingModel),a=this._findModels[(t+1)%this._findModels.length],s=a.moveToNextMatch(),o=this._matches.findIndex(l=>l===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(l=>l===this._matchingModel),a=this._findModels[(t-1+this._findModels.length)%this._findModels.length],s=a.moveToPreviousMatch(),o=this._matches.findIndex(l=>l===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(m=>m.unitId===a);if(s){this._matchingModel=s;const m=s.moveToNextMatch({stayIfOnMatch:!0,noFocus:t}),C=i.findIndex(v=>v===m);return this.currentMatch$.next(m),C}this._matchingModel=e[0];const o=this._matchingModel.moveToNextMatch({noFocus:t}),l=this._matches.findIndex(m=>m===o);return this.currentMatch$.next(o),l}};U=X([O(2,r.IUniverInstanceService),O(3,r.ILogService)],U);var P=(n=>(n.ROW="row",n.COLUMN="column",n))(P||{}),T=(n=>(n.VALUE="value",n.FORMULA="formula",n))(T||{}),E=(n=>(n.SUBUNIT="subunit",n.UNIT="unit",n))(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 Re{constructor(){h(this,"_stateUpdates$",new S.Subject);h(this,"stateUpdates$",this._stateUpdates$.asObservable());h(this,"_state$",new S.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 Re);h(this,"_model");h(this,"_currentMatch$",new S.BehaviorSubject(null));h(this,"currentMatch$",this._currentMatch$.asObservable());h(this,"_replaceables$",new S.BehaviorSubject([]));h(this,"replaceables$",this._replaceables$.asObservable());h(this,"_focusSignal$",new S.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(he.RENDER_RAW_FORMULA_KEY,e)}};k=X([O(0,R.Inject(R.Injector)),O(1,r.IContextService)],k);const N={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:{}},w={};/**
|
|
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 be=l,ye=Symbol.for("react.element"),Me=Symbol.for("react.fragment"),Fe=Object.prototype.hasOwnProperty,Ie=be.__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)Fe.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:ye,type:n,key:s,ref:o,props:a,_owner:Ie.current}}w.Fragment=Me,w.jsx=ne,w.jsxs=ne,te.exports=w;var u=te.exports;const ie={id:"ui.command.replace-current-match",type:r.CommandType.COMMAND,handler:n=>n.get(y).replace()},De="CONFIRM_REPLACE_ALL",ae={id:"ui.command.replace-all-matches",type:r.CommandType.COMMAND,handler:async n=>{const e=n.get(p.IConfirmService),i=n.get(r.LocaleService),t=n.get(p.IMessageService);if(!await e.confirm({id:De,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:f.MessageType.Error,content:i.t("find-replace.replace.all-failure")}):t.show({type:f.MessageType.Warning,content:i.t("find-replace.replace.partial-success",`${o}`,`${c}`)}),!1):(t.show({type:f.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,C=e&&t===0?i.t("find-replace.dialog.no-result"):t===0?" ":void 0;return u.jsx(f.InputWithSlot,{autoFocus:!0,placeholder:i.t("find-replace.dialog.find-placeholder"),slot:u.jsx(f.Pager,{loop:!0,text:C,value:a,total:t,onChange:v=>{a===t&&v===1?o.moveToNextMatch():a===1&&v===t||v<a?o.moveToPreviousMatch():o.moveToNextMatch()}}),value:s,onChange:v=>c==null?void 0:c(v),..._})}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 oe(n,e){const i=l.useCallback(()=>{var a;(a=document.querySelector(".univer-find-input input"))==null||a.focus()},[]),t=l.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 l.useImperativeHandle(e,()=>({focus:i,selectHasFocus:t})),l.useEffect(()=>{const a=n.focusSignal$.subscribe(()=>i());return()=>a.unsubscribe()},[n,i]),{focus:i,selectHasFocus:t}}const Oe=l.forwardRef(function(e,i){const t=F.useDependency(r.LocaleService),a=F.useDependency(y),s=F.useDependency(r.ICommandService),o=p.useObservable(a.state$,void 0,!0),{findCompleted:c,findString:_,matchesCount:m,matchesPosition:C}=o,v=l.useCallback(()=>{s.executeCommand(W.id)},[s]),x=l.useCallback(I=>a.changeFindString(I),[a]);return oe(a,i),u.jsxs(l.Fragment,{children:[u.jsx(se,{findCompleted:c,className:"univer-find-input",matchesCount:m,matchesPosition:C,findReplaceService:a,localeService:t,findString:_,onChange:x}),u.jsx("div",{className:L.findReplaceExpandContainer,children:u.jsx(f.Button,{type:"text",size:"small",onClick:v,children:t.t("find-replace.dialog.advanced-finding")})})]})}),Pe=l.forwardRef(function(e,i){const t=F.useDependency(y),a=F.useDependency(r.LocaleService),s=F.useDependency(r.ICommandService),o=F.useDependency(p.IMessageService),c=p.useObservable(t.currentMatch$,void 0,!0),_=p.useObservable(t.replaceables$,void 0,!0),m=p.useObservable(t.state$,void 0,!0),{matchesCount:C,matchesPosition:v,findString:x,inputtingFindString:I,replaceString:et,caseSensitive:tt,matchesTheWholeCell:nt,findDirection:it,findScope:at,findBy:st,findCompleted:K}=m,ot=I.length===0,rt=C===0||!(c!=null&&c.replaceable),ct=_.length===0,lt=l.useCallback(g=>t.changeInputtingFindString(g),[t]),dt=l.useCallback(g=>t.changeReplaceString(g),[t]),{focus:ht}=oe(t,i),ut=l.useCallback(()=>{x===I?t.moveToNextMatch():(t.changeFindString(I),t.find())},[x,I,t]),pt=l.useCallback(()=>s.executeCommand(ie.id),[s]),ft=l.useCallback(async()=>{await s.executeCommand(ae.id),ht()},[s]),_t=l.useCallback(g=>{t.changeFindDirection(g)},[t]),gt=l.useCallback(g=>{t.changeFindScope(g)},[t]),mt=l.useCallback(g=>{t.changeFindBy(g)},[t]),vt=Ee(a),St=Ne(a),Ct=we(a);return l.useEffect(()=>{const g=K&&C===0;let j=null;return g&&(j=o.show({content:a.t("find-replace.dialog.no-match"),type:f.MessageType.Warning,delay:5e3})),()=>j==null?void 0:j.dispose()},[K,C,o,a]),u.jsxs(l.Fragment,{children:[u.jsx(f.FormLayout,{label:a.t("find-replace.dialog.find"),children:u.jsx(se,{findCompleted:K,className:"univer-find-input",matchesCount:C,matchesPosition:v,findReplaceService:t,localeService:a,findString:I,onChange:lt})}),u.jsx(f.FormLayout,{label:a.t("find-replace.dialog.replace"),children:u.jsx(f.Input,{placeholder:a.t("find-replace.dialog.replace-placeholder"),value:et,onChange:g=>dt(g)})}),u.jsx(f.FormLayout,{label:a.t("find-replace.dialog.find-direction.title"),children:u.jsx(f.Select,{value:it,options:St,onChange:_t})}),u.jsx(f.FormDualColumnLayout,{children:u.jsxs(l.Fragment,{children:[u.jsx(f.FormLayout,{label:a.t("find-replace.dialog.find-scope.title"),children:u.jsx(f.Select,{value:at,options:vt,onChange:gt})}),u.jsx(f.FormLayout,{label:a.t("find-replace.dialog.find-by.title"),children:u.jsx(f.Select,{value:st,options:Ct,onChange:mt})})]})}),u.jsx(f.FormDualColumnLayout,{children:u.jsxs(l.Fragment,{children:[u.jsx(f.FormLayout,{children:u.jsx(f.Checkbox,{checked:tt,onChange:g=>{t.changeCaseSensitive(g)},children:a.t("find-replace.dialog.case-sensitive")})}),u.jsx(f.FormLayout,{children:u.jsx(f.Checkbox,{checked:nt,onChange:g=>{t.changeMatchesTheWholeCell(g)},children:a.t("find-replace.dialog.match-the-whole-cell")})})]})}),u.jsxs("div",{className:L.findReplaceButtonsGroup,children:[u.jsx(f.Button,{type:"primary",onClick:ut,disabled:ot,children:a.t("find-replace.dialog.find")}),u.jsxs("span",{className:L.findReplaceButtonsGroupRight,children:[u.jsx(f.Button,{disabled:rt,onClick:pt,children:a.t("find-replace.dialog.replace")}),u.jsx(f.Button,{disabled:ct,onClick:ft,children:a.t("find-replace.dialog.replace-all")})]})]})]})});function Te(){const n=F.useDependency(y),e=F.useDependency(p.ILayoutService),i=F.useDependency(r.IContextService),t=p.useObservable(n.state$,void 0,!0),a=l.useRef(null);l.useEffect(()=>{let _;return a.current&&(_=e.registerContainerElement(a.current)),()=>_==null?void 0:_.dispose()},[e]);const s=l.useRef(null),o=l.useCallback(_=>i.setContextValue(J,_),[i]),c=l.useCallback(_=>i.setContextValue(Z,_),[i]);return l.useEffect(()=>{var m;const _=S.fromEvent(document,"focusin").subscribe(C=>{var v;C.target&&((v=a.current)!=null&&v.contains(C.target))?o(!0):o(!1),!s.current||!s.current.selectHasFocus()?c(!0):c(!1)});return(m=s.current)==null||m.focus(),o(!0),c(!0),()=>{_.unsubscribe(),o(!1)}},[o,c]),u.jsx("div",{className:L.findReplaceDialogContainer,ref:a,children:t.replaceRevealed?u.jsx(Pe,{ref:s}):u.jsx(Oe,{ref:s})})}function Ee(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-scope.current-sheet"),value:E.SUBUNIT},{label:n.t("find-replace.dialog.find-scope.workbook"),value:E.UNIT}],[e])}function Ne(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-direction.row"),value:P.ROW},{label:n.t("find-replace.dialog.find-direction.column"),value:P.COLUMN}],[e])}function we(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-by.value"),value:T.VALUE},{label:n.t("find-replace.dialog.find-by.formula"),value:T.FORMULA}],[e])}function D(n){return n.getContextValue(J)}function Le(n){return n.getContextValue(Q)}function re(n){return n.getContextValue(Z)}const A="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:N.id,description:"find-replace.shortcut.open-find-dialog",binding:p.KeyCode.F|p.MetaKeys.CTRL_COMMAND,group:A,preconditions(n){return!D(n)&&G(n)&&V(n)}},je={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:p.KeyCode.F|p.MetaKeys.CTRL_COMMAND,mac:p.KeyCode.F|p.MetaKeys.MAC_CTRL,preconditions(n){return!D(n)&&G(n)&&V(n)}},Ue={id:W.id,description:"find-replace.shortcut.open-replace-dialog",binding:p.KeyCode.H|p.MetaKeys.CTRL_COMMAND,mac:p.KeyCode.H|p.MetaKeys.MAC_CTRL,group:A,preconditions(n){return G(n)&&V(n)&&(!D(n)||!Le(n))}},Be={id:q.id,description:"find-replace.shortcut.go-to-next-match",binding:p.KeyCode.ENTER,group:A,priority:1e3,preconditions(n){return re(n)&&D(n)}},ke={id:ee.id,description:"find-replace.shortcut.go-to-previous-match",binding:p.KeyCode.ENTER|p.MetaKeys.SHIFT,group:A,priority:1e3,preconditions(n){return re(n)&&D(n)}};function We(n){const e=n.get(r.IContextService);return{id:N.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",group:p.MenuGroup.TOOLBAR_OTHERS,type:p.MenuItemType.BUTTON,positions:[p.MenuPosition.TOOLBAR_START],hidden$:p.getMenuHiddenObservable(n,r.UniverInstanceType.UNIVER_SHEET),disabled$:S.combineLatest([e.subscribeContextValue$(r.EDITOR_ACTIVATED),e.subscribeContextValue$(r.FOCUSING_SHEET)]).pipe(S.map(([i,t])=>i||!t))}}var Ge=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,He=(n,e,i,t)=>{for(var a=t>1?void 0:t?Ve(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&&Ge(e,i,a),a},M=(n,e)=>(i,t)=>e(i,t,n);const ce="DESKTOP_FIND_REPLACE_DIALOG",le=350,Ke=20,$e=-90;d.FindReplaceController=class extends r.RxDisposable{constructor(e,i,t,a,s,o,c,_,m,C,v,x){super(),this._univerInstanceService=e,this._menuService=i,this._shortcutService=t,this._commandService=a,this._findReplaceService=s,this._logService=o,this._dialogService=c,this._contextService=_,this._layoutService=m,this._localeService=C,this._componentManager=v,this._injector=x,this._initCommands(),this._initUI(),this._initShortcuts()}_initCommands(){[N,W,q,ee,ae,ie].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initShortcuts(){[Ue,Ae,je,ke,Be].forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}_initUI(){this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(We))),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",Te)),this.disposeWithMe(this._componentManager.register("SearchIcon",Y)),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: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())}},d.FindReplaceController=He([r.OnLifecycle(r.LifecycleStages.Rendered,d.FindReplaceController),M(0,r.IUniverInstanceService),M(1,p.IMenuService),M(2,p.IShortcutService),M(3,r.ICommandService),M(4,y),M(5,r.ILogService),M(6,p.IDialogService),M(7,r.IContextService),M(8,p.ILayoutService),M(9,R.Inject(r.LocaleService)),M(10,R.Inject(p.ComponentManager)),M(11,R.Inject(R.Injector))],d.FindReplaceController);function ze(){const{innerWidth:n}=window;return{x:(n-le)/2-Ke,y:$e}}const Ye={"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":"查找替换"};var Ze=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(n,e,i,t)=>{for(var a=t>1?void 0:t?Je(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&&Ze(e,i,a),a},Xe=(n,e)=>(i,t)=>e(i,t,n);const qe="FIND_REPLACE";d.UniverFindReplacePlugin=(H=class extends r.Plugin{constructor(e,i){super(),this._injector=e,this._localeService=i,this._localeService.load({zhCN:de})}onStarting(e){[[d.FindReplaceController],[y,{useClass:k}]].forEach(i=>{e.add(i)})}},h(H,"pluginName",qe),H),d.UniverFindReplacePlugin=Qe([Xe(1,R.Inject(r.LocaleService))],d.UniverFindReplacePlugin),d.FindBy=T,d.FindDirection=P,d.FindModel=Se,d.FindScope=E,d.IFindReplaceService=y,d.enUS=Ye,d.zhCN=de,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
9
|
+
*/var be=c,ye=Symbol.for("react.element"),Me=Symbol.for("react.fragment"),Fe=Object.prototype.hasOwnProperty,Ie=be.__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)Fe.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:ye,type:n,key:s,ref:o,props:a,_owner:Ie.current}}w.Fragment=Me,w.jsx=ne,w.jsxs=ne,te.exports=w;var u=te.exports;const ie={id:"ui.command.replace-current-match",type:r.CommandType.COMMAND,handler:n=>n.get(y).replace()},De="CONFIRM_REPLACE_ALL",ae={id:"ui.command.replace-all-matches",type:r.CommandType.COMMAND,handler:async n=>{const e=n.get(p.IConfirmService),i=n.get(r.LocaleService),t=n.get(p.IMessageService);if(!await e.confirm({id:De,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:l}=s;return l>0?(o===0?t.show({type:f.MessageType.Error,content:i.t("find-replace.replace.all-failure")}):t.show({type:f.MessageType.Warning,content:i.t("find-replace.replace.partial-success",`${o}`,`${l}`)}),!1):(t.show({type:f.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:l,..._}=n,C=e&&t===0?i.t("find-replace.dialog.no-result"):t===0?" ":void 0;return u.jsx(f.InputWithSlot,{autoFocus:!0,placeholder:i.t("find-replace.dialog.find-placeholder"),slot:u.jsx(f.Pager,{loop:!0,text:C,value:a,total:t,onChange:v=>{a===t&&v===1?o.moveToNextMatch():a===1&&v===t||v<a?o.moveToPreviousMatch():o.moveToNextMatch()}}),value:s,onChange:v=>l==null?void 0:l(v),..._})}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 oe(n,e){const i=c.useCallback(()=>{var a;(a=document.querySelector(".univer-find-input input"))==null||a.focus()},[]),t=c.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 c.useImperativeHandle(e,()=>({focus:i,selectHasFocus:t})),c.useEffect(()=>{const a=n.focusSignal$.subscribe(()=>i());return()=>a.unsubscribe()},[n,i]),{focus:i,selectHasFocus:t}}const Oe=c.forwardRef(function(e,i){const t=F.useDependency(r.LocaleService),a=F.useDependency(y),s=F.useDependency(r.ICommandService),o=p.useObservable(a.state$,void 0,!0),{findCompleted:l,findString:_,matchesCount:m,matchesPosition:C}=o,v=c.useCallback(()=>{s.executeCommand(W.id)},[s]),x=c.useCallback(I=>a.changeFindString(I),[a]);return oe(a,i),u.jsxs(c.Fragment,{children:[u.jsx(se,{findCompleted:l,className:"univer-find-input",matchesCount:m,matchesPosition:C,findReplaceService:a,localeService:t,findString:_,onChange:x}),u.jsx("div",{className:L.findReplaceExpandContainer,children:u.jsx(f.Button,{type:"text",size:"small",onClick:v,children:t.t("find-replace.dialog.advanced-finding")})})]})}),Pe=c.forwardRef(function(e,i){const t=F.useDependency(y),a=F.useDependency(r.LocaleService),s=F.useDependency(r.ICommandService),o=F.useDependency(p.IMessageService),l=p.useObservable(t.currentMatch$,void 0,!0),_=p.useObservable(t.replaceables$,void 0,!0),m=p.useObservable(t.state$,void 0,!0),{matchesCount:C,matchesPosition:v,findString:x,inputtingFindString:I,replaceString:tt,caseSensitive:nt,matchesTheWholeCell:it,findDirection:at,findScope:st,findBy:ot,findCompleted:$}=m,rt=I.length===0,lt=C===0||!(l!=null&&l.replaceable),ct=_.length===0,dt=c.useCallback(g=>t.changeInputtingFindString(g),[t]),ht=c.useCallback(g=>t.changeReplaceString(g),[t]),{focus:ut}=oe(t,i),pt=c.useCallback(()=>{x===I?t.moveToNextMatch():(t.changeFindString(I),t.find())},[x,I,t]),ft=c.useCallback(()=>s.executeCommand(ie.id),[s]),_t=c.useCallback(async()=>{await s.executeCommand(ae.id),ut()},[s]),gt=c.useCallback(g=>{t.changeFindDirection(g)},[t]),mt=c.useCallback(g=>{t.changeFindScope(g)},[t]),vt=c.useCallback(g=>{t.changeFindBy(g)},[t]),St=Ee(a),Ct=Ne(a),Rt=we(a);return c.useEffect(()=>{const g=$&&C===0;let j=null;return g&&(j=o.show({content:a.t("find-replace.dialog.no-match"),type:f.MessageType.Warning,delay:5e3})),()=>j==null?void 0:j.dispose()},[$,C,o,a]),u.jsxs(c.Fragment,{children:[u.jsx(f.FormLayout,{label:a.t("find-replace.dialog.find"),children:u.jsx(se,{findCompleted:$,className:"univer-find-input",matchesCount:C,matchesPosition:v,findReplaceService:t,localeService:a,findString:I,onChange:dt})}),u.jsx(f.FormLayout,{label:a.t("find-replace.dialog.replace"),children:u.jsx(f.Input,{placeholder:a.t("find-replace.dialog.replace-placeholder"),value:tt,onChange:g=>ht(g)})}),u.jsx(f.FormLayout,{label:a.t("find-replace.dialog.find-direction.title"),children:u.jsx(f.Select,{value:at,options:Ct,onChange:gt})}),u.jsx(f.FormDualColumnLayout,{children:u.jsxs(c.Fragment,{children:[u.jsx(f.FormLayout,{label:a.t("find-replace.dialog.find-scope.title"),children:u.jsx(f.Select,{value:st,options:St,onChange:mt})}),u.jsx(f.FormLayout,{label:a.t("find-replace.dialog.find-by.title"),children:u.jsx(f.Select,{value:ot,options:Rt,onChange:vt})})]})}),u.jsx(f.FormDualColumnLayout,{children:u.jsxs(c.Fragment,{children:[u.jsx(f.FormLayout,{children:u.jsx(f.Checkbox,{checked:nt,onChange:g=>{t.changeCaseSensitive(g)},children:a.t("find-replace.dialog.case-sensitive")})}),u.jsx(f.FormLayout,{children:u.jsx(f.Checkbox,{checked:it,onChange:g=>{t.changeMatchesTheWholeCell(g)},children:a.t("find-replace.dialog.match-the-whole-cell")})})]})}),u.jsxs("div",{className:L.findReplaceButtonsGroup,children:[u.jsx(f.Button,{type:"primary",onClick:pt,disabled:rt,children:a.t("find-replace.dialog.find")}),u.jsxs("span",{className:L.findReplaceButtonsGroupRight,children:[u.jsx(f.Button,{disabled:lt,onClick:ft,children:a.t("find-replace.dialog.replace")}),u.jsx(f.Button,{disabled:ct,onClick:_t,children:a.t("find-replace.dialog.replace-all")})]})]})]})});function Te(){const n=F.useDependency(y),e=F.useDependency(p.ILayoutService),i=F.useDependency(r.IContextService),t=p.useObservable(n.state$,void 0,!0),a=c.useRef(null);c.useEffect(()=>{let _;return a.current&&(_=e.registerContainerElement(a.current)),()=>_==null?void 0:_.dispose()},[e]);const s=c.useRef(null),o=c.useCallback(_=>i.setContextValue(J,_),[i]),l=c.useCallback(_=>i.setContextValue(Z,_),[i]);return c.useEffect(()=>{var m;const _=S.fromEvent(document,"focusin").subscribe(C=>{var v;C.target&&((v=a.current)!=null&&v.contains(C.target))?o(!0):o(!1),!s.current||!s.current.selectHasFocus()?l(!0):l(!1)});return(m=s.current)==null||m.focus(),o(!0),l(!0),()=>{_.unsubscribe(),o(!1)}},[o,l]),u.jsx("div",{className:L.findReplaceDialogContainer,ref:a,children:t.replaceRevealed?u.jsx(Pe,{ref:s}):u.jsx(Oe,{ref:s})})}function Ee(n){const e=n.getCurrentLocale();return c.useMemo(()=>[{label:n.t("find-replace.dialog.find-scope.current-sheet"),value:E.SUBUNIT},{label:n.t("find-replace.dialog.find-scope.workbook"),value:E.UNIT}],[e])}function Ne(n){const e=n.getCurrentLocale();return c.useMemo(()=>[{label:n.t("find-replace.dialog.find-direction.row"),value:P.ROW},{label:n.t("find-replace.dialog.find-direction.column"),value:P.COLUMN}],[e])}function we(n){const e=n.getCurrentLocale();return c.useMemo(()=>[{label:n.t("find-replace.dialog.find-by.value"),value:T.VALUE},{label:n.t("find-replace.dialog.find-by.formula"),value:T.FORMULA}],[e])}function D(n){return n.getContextValue(J)}function Le(n){return n.getContextValue(Q)}function re(n){return n.getContextValue(Z)}const A="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:N.id,description:"find-replace.shortcut.open-find-dialog",binding:p.KeyCode.F|p.MetaKeys.CTRL_COMMAND,group:A,preconditions(n){return!D(n)&&G(n)&&V(n)}},je={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:p.KeyCode.F|p.MetaKeys.CTRL_COMMAND,mac:p.KeyCode.F|p.MetaKeys.MAC_CTRL,preconditions(n){return!D(n)&&G(n)&&V(n)}},Ue={id:W.id,description:"find-replace.shortcut.open-replace-dialog",binding:p.KeyCode.H|p.MetaKeys.CTRL_COMMAND,mac:p.KeyCode.H|p.MetaKeys.MAC_CTRL,group:A,preconditions(n){return G(n)&&V(n)&&(!D(n)||!Le(n))}},Be={id:q.id,description:"find-replace.shortcut.go-to-next-match",binding:p.KeyCode.ENTER,group:A,priority:1e3,preconditions(n){return re(n)&&D(n)}},ke={id:ee.id,description:"find-replace.shortcut.go-to-previous-match",binding:p.KeyCode.ENTER|p.MetaKeys.SHIFT,group:A,priority:1e3,preconditions(n){return re(n)&&D(n)}};function We(n){const e=n.get(r.IContextService);return{id:N.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",group:p.MenuGroup.TOOLBAR_OTHERS,type:p.MenuItemType.BUTTON,positions:[p.MenuPosition.TOOLBAR_START],hidden$:p.getMenuHiddenObservable(n,r.UniverInstanceType.UNIVER_SHEET),disabled$:S.combineLatest([e.subscribeContextValue$(r.EDITOR_ACTIVATED),e.subscribeContextValue$(r.FOCUSING_SHEET)]).pipe(S.map(([i,t])=>i||!t))}}var Ge=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,He=(n,e,i,t)=>{for(var a=t>1?void 0:t?Ve(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&&Ge(e,i,a),a},M=(n,e)=>(i,t)=>e(i,t,n);const le="DESKTOP_FIND_REPLACE_DIALOG",ce=350,$e=20,Ke=-90;d.FindReplaceController=class extends r.RxDisposable{constructor(e,i,t,a,s,o,l,_,m,C,v,x){super(),this._univerInstanceService=e,this._menuService=i,this._shortcutService=t,this._commandService=a,this._findReplaceService=s,this._logService=o,this._dialogService=l,this._contextService=_,this._layoutService=m,this._localeService=C,this._componentManager=v,this._injector=x,this._initCommands(),this._initUI(),this._initShortcuts()}_initCommands(){[N,W,q,ee,ae,ie].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initShortcuts(){[Ue,Ae,je,ke,Be].forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}_initUI(){this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(We))),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",Te)),this.disposeWithMe(this._componentManager.register("SearchIcon",Y)),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:le,draggable:!0,width:ce,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(le),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus())}},d.FindReplaceController=He([r.OnLifecycle(r.LifecycleStages.Rendered,d.FindReplaceController),M(0,r.IUniverInstanceService),M(1,p.IMenuService),M(2,p.IShortcutService),M(3,r.ICommandService),M(4,y),M(5,r.ILogService),M(6,p.IDialogService),M(7,r.IContextService),M(8,p.ILayoutService),M(9,R.Inject(r.LocaleService)),M(10,R.Inject(p.ComponentManager)),M(11,R.Inject(R.Injector))],d.FindReplaceController);function ze(){const{innerWidth:n}=window;return{x:(n-ce)/2-$e,y:Ke}}const Ye={"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":"查找替换"},Ze={"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 Je=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,Xe=(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&&Je(e,i,a),a},qe=(n,e)=>(i,t)=>e(i,t,n);const et="FIND_REPLACE";d.UniverFindReplacePlugin=(H=class extends r.Plugin{constructor(e,i){super(),this._injector=e,this._localeService=i,this._localeService.load({zhCN:de})}onStarting(e){[[d.FindReplaceController],[y,{useClass:k}]].forEach(i=>{e.add(i)})}},h(H,"pluginName",et),H),d.UniverFindReplacePlugin=Xe([qe(1,R.Inject(r.LocaleService))],d.UniverFindReplacePlugin),d.FindBy=T,d.FindDirection=P,d.FindModel=Se,d.FindScope=E,d.IFindReplaceService=y,d.enUS=Ye,d.ruRU=Ze,d.zhCN=de,Object.defineProperty(d,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.11",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -53,32 +53,32 @@
|
|
|
53
53
|
"npm": ">=8.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@wendellhu/redi": "^0.
|
|
56
|
+
"@wendellhu/redi": "^0.15.1",
|
|
57
57
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
58
58
|
"rxjs": ">=7.0.0",
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/
|
|
59
|
+
"@univerjs/design": "0.1.11",
|
|
60
|
+
"@univerjs/core": "0.1.11",
|
|
61
|
+
"@univerjs/engine-render": "0.1.11",
|
|
62
|
+
"@univerjs/ui": "0.1.11"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@univerjs/icons": "^0.1.
|
|
65
|
+
"@univerjs/icons": "^0.1.45"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/react": "^18.2.79",
|
|
69
|
-
"@wendellhu/redi": "^0.
|
|
69
|
+
"@wendellhu/redi": "^0.15.1",
|
|
70
70
|
"less": "^4.2.0",
|
|
71
71
|
"react": "18.2.0",
|
|
72
72
|
"rxjs": "^7.8.1",
|
|
73
73
|
"typescript": "^5.4.5",
|
|
74
|
-
"vite": "^5.2.
|
|
75
|
-
"vitest": "^1.
|
|
76
|
-
"@univerjs/core": "0.1.
|
|
77
|
-
"@univerjs/design": "0.1.
|
|
78
|
-
"@univerjs/engine-formula": "0.1.
|
|
79
|
-
"@univerjs/
|
|
80
|
-
"@univerjs/
|
|
81
|
-
"@univerjs/
|
|
74
|
+
"vite": "^5.2.11",
|
|
75
|
+
"vitest": "^1.6.0",
|
|
76
|
+
"@univerjs/core": "0.1.11",
|
|
77
|
+
"@univerjs/design": "0.1.11",
|
|
78
|
+
"@univerjs/engine-formula": "0.1.11",
|
|
79
|
+
"@univerjs/shared": "0.1.11",
|
|
80
|
+
"@univerjs/ui": "0.1.11",
|
|
81
|
+
"@univerjs/engine-render": "0.1.11"
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
|
84
84
|
"test": "vitest run",
|