@univerjs/sheets-find-replace 0.1.13 → 0.1.15
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 +1 -1
- package/lib/es/index.js +327 -336
- package/lib/types/controllers/sheet-find-replace.controller.d.ts +2 -4
- package/lib/types/plugin.d.ts +2 -3
- package/lib/umd/index.js +1 -1
- package/package.json +35 -24
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var te=Object.defineProperty;var ie=(t,e,i)=>e in t?te(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var _=(t,e,i)=>(ie(t,typeof e!="symbol"?e+"":e,i),i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@univerjs/core"),I=require("@wendellhu/redi"),f=require("@univerjs/find-replace"),F=require("@univerjs/engine-render"),k=require("@univerjs/sheets"),y=require("@univerjs/sheets-ui"),v=require("rxjs");var G=(t=>(t[t.View=0]="View",t[t.Edit=1]="Edit",t[t.ManageCollaborator=2]="ManageCollaborator",t[t.Print=3]="Print",t[t.Duplicate=4]="Duplicate",t[t.Comment=5]="Comment",t[t.Copy=6]="Copy",t[t.Share=7]="Share",t[t.Export=8]="Export",t[t.MoveWorksheet=9]="MoveWorksheet",t[t.DeleteWorksheet=10]="DeleteWorksheet",t[t.HideWorksheet=11]="HideWorksheet",t[t.RenameWorksheet=12]="RenameWorksheet",t[t.CreateWorksheet=13]="CreateWorksheet",t[t.SetWorksheetStyle=14]="SetWorksheetStyle",t[t.EditWorksheetCell=15]="EditWorksheetCell",t[t.InsertHyperlink=16]="InsertHyperlink",t[t.Sort=17]="Sort",t[t.Filter=18]="Filter",t[t.PivotTable=19]="PivotTable",t[t.FloatImg=20]="FloatImg",t[t.History=21]="History",t[t.RwHgtClWdt=22]="RwHgtClWdt",t[t.ViemRwHgtClWdt=23]="ViemRwHgtClWdt",t[t.ViewFilter=24]="ViewFilter",t[t.MoveSheet=25]="MoveSheet",t[t.DeleteSheet=26]="DeleteSheet",t[t.HideSheet=27]="HideSheet",t[t.CopySheet=28]="CopySheet",t[t.RenameSheet=29]="RenameSheet",t[t.CreateSheet=30]="CreateSheet",t[t.SelectProtectedCells=31]="SelectProtectedCells",t[t.SelectUnProtectedCells=32]="SelectUnProtectedCells",t[t.SetCellStyle=33]="SetCellStyle",t[t.SetCellValue=34]="SetCellValue",t[t.SetRowStyle=35]="SetRowStyle",t[t.SetColumnStyle=36]="SetColumnStyle",t[t.InsertRow=37]="InsertRow",t[t.InsertColumn=38]="InsertColumn",t[t.DeleteRow=39]="DeleteRow",t[t.DeleteColumn=40]="DeleteColumn",t[t.EditExtraObject=41]="EditExtraObject",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(G||{});class ne extends F.Shape{constructor(i,n){super(i,n);_(this,"_activated",!1);_(this,"_inHiddenRange",!1);_(this,"_color");n&&this.setShapeProps(n)}setShapeProps(i){this._activated=!!i.activated,typeof i.inHiddenRange<"u"&&(this._inHiddenRange=i.inHiddenRange),typeof i.color<"u"&&(this._color=i.color),this.transformByState({width:i.width,height:i.height})}_draw(i){const n=this._activated,r=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, 0.35)`,o=`rgb(${this._color.r}, ${this._color.g}, ${this._color.b})`;F.Rect.drawWith(i,{width:this.width,height:this.height,fill:r,stroke:n?o:void 0,strokeWidth:n?2:0,evented:!1})}}const q={id:"sheet.command.replace",type:d.CommandType.COMMAND,handler:async(t,e)=>{const i=t.get(d.IUndoRedoService),n=t.get(d.ICommandService),{unitId:r,replacements:o}=e,s=i.__tempBatchingUndoRedo(r),c=await Promise.all(o.map(h=>n.executeCommand(k.SetRangeValuesCommand.id,{unitId:r,subUnitId:h.subUnitId,value:h.value})));return s.dispose(),se(c,o)}};function se(t,e){let i=0,n=0;return t.forEach((r,o)=>{const s=e[o].count;r?i+=s:n+=s}),{success:i,failure:n}}function N(t,e){return t.startRow===e.startRow&&t.startColumn===e.startColumn}function j(t,e){return t.startRow<e.startRow||t.startRow===e.startRow&&t.startColumn<=e.startColumn}function $(t,e){return t.startColumn<e.startColumn||t.startColumn===e.startColumn&&t.startRow<=e.startRow}function re(t,e){return t.startRow>e.startRow||t.startRow===e.startRow&&t.startColumn>=e.startColumn}function oe(t,e){return t.startColumn>e.startColumn||t.startColumn===e.startColumn&&t.startRow>=e.startRow}function ce(t,e){const{range:i}=t,{startRow:n,startColumn:r}=i,o=e.getMergedCell(n,r);return o?d.Rectangle.equals(i,o):i.endRow===i.startRow&&i.endColumn===i.startColumn}var he=Object.defineProperty,ae=Object.getOwnPropertyDescriptor,B=(t,e,i,n)=>{for(var r=n>1?void 0:n?ae(e,i):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(r=(n?s(e,i,r):s(r))||r);return n&&r&&he(e,i,r),r},m=(t,e)=>(i,n)=>e(i,n,t);exports.SheetsFindReplaceController=class extends d.Disposable{constructor(i,n,r,o,s){super();_(this,"_provider");this._injector=i,this._findReplaceController=n,this._contextService=r,this._findReplaceService=o,this._commandService=s,this._init(),this._initCommands()}dispose(){super.dispose(),this._provider.dispose()}_init(){const i=this._injector.createInstance(H);this._provider=i,this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(i)),this.disposeWithMe(this._contextService.subscribeContextValue$(d.EDITOR_ACTIVATED).pipe(v.filter(n=>!!n)).subscribe(()=>this._findReplaceController.closePanel()))}_initCommands(){[q].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}};exports.SheetsFindReplaceController=B([d.OnLifecycle(d.LifecycleStages.Steady,exports.SheetsFindReplaceController),m(0,I.Inject(I.Injector)),m(1,I.Inject(f.FindReplaceController)),m(2,d.IContextService),m(3,f.IFindReplaceService),m(4,d.ICommandService)],exports.SheetsFindReplaceController);const le="sheets-find-replace-provider",de=1e4;let W=class extends f.FindModel{constructor(e,i,n,r,o,s,c,h,a){super();_(this,"_matchesUpdate$",new v.Subject);_(this,"matchesUpdate$",this._matchesUpdate$.asObservable());_(this,"_activelyChangingMatch$",new v.Subject);_(this,"activelyChangingMatch$",this._activelyChangingMatch$.asObservable());_(this,"_matchesByWorksheet",new Map);_(this,"_matches",[]);_(this,"_matchesPosition",0);_(this,"_activeHighlightIndex",-1);_(this,"_highlightShapes",[]);_(this,"_currentHighlightShape",null);_(this,"_query",null);this._workbook=e,this._univerInstanceService=i,this._renderManagerService=n,this._commandService=r,this._contextService=o,this._themeService=s,this._sheetSkeletonManagerService=c,this._selectionManagerService=h,this._findReplaceController=a}get _matchesCount(){return this._matches.length}get unitId(){return this._workbook.getUnitId()}get matchesCount(){return this._matchesCount}get matchesPosition(){return this._matchesPosition}get currentMatch(){return this._matchesPosition>0?this._matches[this._matchesPosition-1]:null}dispose(){super.dispose(),this._disposeHighlights(),this._toggleDisplayRawFormula(!1)}getMatches(){return this._matches}start(e){switch(this._query=e,e.findBy===f.FindBy.FORMULA?this._toggleDisplayRawFormula(!0):this._toggleDisplayRawFormula(!1),e.findScope){case f.FindScope.UNIT:this.findInWorkbook(e);break;case f.FindScope.SUBUNIT:default:this.findInActiveWorksheet(e);break}}_toggleDisplayRawFormula(e){this._contextService.setContextValue(F.RENDER_RAW_FORMULA_KEY,e)}findInWorkbook(e){const i=this._workbook.getUnitId();let n,r=!0;const o=()=>{const s=this._workbook.getSheets().filter(c=>!c.isSheetHidden()).map(c=>{const h=this._findInWorksheet(c,e,i),a=c.getSheetId(),{results:l}=h;return l.length?this._matchesByWorksheet.set(a,h.results):this._matchesByWorksheet.delete(a),h});this._matches=s.map(c=>c.results).flat(),this._updateFindHighlight(),r?(n={results:this._matches},r=!1):this._matchesUpdate$.next(this._matches)};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._updateFindHighlight(),this._updateCurrentHighlightShape(this._activeHighlightIndex)})),this.disposeWithMe(d.fromCallback(this._commandService.onCommandExecuted).pipe(v.filter(([s,c])=>s.id===k.SetWorksheetActiveOperation.id&&!(c!=null&&c.fromFindReplace))).subscribe(()=>{const s=this._workbook.getActiveSheet(),c=s.getSheetId();this._matchesByWorksheet.has(c)&&this._findNextMatchOnActiveSheetChange(s)})),this.disposeWithMe(d.fromCallback(this._commandService.onCommandExecuted).pipe(v.filter(([s])=>s.type===d.CommandType.MUTATION&&s.params.unitId===this._workbook.getUnitId()),v.throttleTime(600,void 0,{leading:!1,trailing:!0})).subscribe(()=>o())),o(),n}_findNextMatchOnActiveSheetChange(e){let i,n,r=0;const o=this._matchesByWorksheet.get(e.getSheetId()),s=this._selectionManagerService.getSelections();s!=null&&s.length?([i,r]=this._findNextMatchByRange(o,s[0].range),n=o.findIndex(c=>c===i)):(i=o[0],n=0,r=this._matches.findIndex(c=>c===i)),this._matchesPosition=r+1,this._activelyChangingMatch$.next(i),this._activeHighlightIndex=n,this._updateFindHighlight(),this._updateCurrentHighlightShape(n)}findInActiveWorksheet(e){const i=this._workbook.getUnitId(),n=()=>{var u;const h=this._workbook.getActiveSheet(),a=this._selectionManagerService.getSelections();return(u=a==null?void 0:a.some(S=>!ce(S,h)))!=null?u:!1};let r,o=!0,s=!1;const c=()=>{const h=this._workbook.getActiveSheet(),a=this.currentMatch;s=n();const l=this._selectionManagerService.getSelections(),u=s?this._findInSelections(h,l,e,i):this._findInWorksheet(h,e,i);return this._matches=u.results,this._matchesPosition=this._tryRestoreLastMatchesPosition(a,this._matches),o?(r=u,o=!1):this._matchesUpdate$.next(this._matches),this._updateFindHighlight(),u};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>this._updateFindHighlight())),this.disposeWithMe(v.merge(d.fromCallback(this._commandService.onCommandExecuted).pipe(v.filter(([h])=>{if(h.type===d.CommandType.MUTATION&&h.params.unitId===this._workbook.getUnitId())return!0;if(h.id===k.SetSelectionsOperation.id&&h.params.unitId===i){const a=n();return a===!1&&s===!1?!1:(s=a,!0)}return!1})),this._workbook.activeSheet$.pipe(v.skip(1))).pipe(v.debounceTime(200)).subscribe(()=>c())),c(),r}_findInRange(e,i,n,r,o){const s=[],c=e.getSheetId(),h=(i.findDirection===f.FindDirection.COLUMN?e.iterateByColumn:e.iterateByRow).bind(e)(n);for(const a of h){const{row:l,col:u,colSpan:S,rowSpan:C,value:p}=a;if(!this._getFindReplacePermissionCheck({row:l,col:u,unitId:r,subUnitId:c})||o!=null&&o(l,u)||!p||e.getRowFiltered(l))continue;const{hit:b,replaceable:R,isFormula:M}=ue(e,l,u,i,p);if(b){const P={provider:le,unitId:r,replaceable:R,isFormula:M,range:{subUnitId:c,range:{startRow:l,startColumn:u,endColumn:u+(S!=null?S:1)-1,endRow:l+(C!=null?C:1)-1}}};s.push(P)}}return{results:s}}_findInSelections(e,i,n,r){const{findDirection:o}=n,s=o===f.FindDirection.ROW?j:$,c=new Set;return{results:i.map(a=>this._findInRange(e,n,a.range,r,(l,u)=>{const S=`${l}-${u}`;return c.has(S)?!0:(c.add(S),!1)}).results).flat().sort((a,l)=>s(a.range.range,l.range.range)?-1:1)}}_findInWorksheet(e,i,n){const r=e.getRowCount(),o=e.getColumnCount(),s={startRow:0,startColumn:0,endRow:r-1,endColumn:o-1};return this._findInRange(e,i,s,n)}_disposeHighlights(){var e;this._highlightShapes.forEach(i=>{i.getScene().makeDirty(),i.dispose()}),this._highlightShapes=[],(e=this._currentHighlightShape)==null||e.dispose(),this._currentHighlightShape=null}_updateFindHighlight(){var C,p;this._disposeHighlights();const e=(C=this._sheetSkeletonManagerService.getCurrent())==null?void 0:C.skeleton;if(!e||!this._getSheetObject()||((p=this._univerInstanceService.getFocusedUnit())==null?void 0:p.getUnitId())!==this._workbook.getUnitId())return;const r=this._workbook.getUnitId(),o=this._renderManagerService.getRenderById(r);if(o==null)return;const{scene:s}=o,c=this._matches,h=this._themeService.getCurrentTheme().gold400,a=new d.ColorKit(h).toRgb(),l=this._workbook.getActiveSheet(),u=l.getSheetId(),S=c.filter(w=>w.range.subUnitId===u).map((w,b)=>{const{startColumn:R,startRow:M,endColumn:P,endRow:Q}=w.range.range,X=y.getCoordByCell(M,R,s,e),Y=y.getCoordByCell(Q,P,s,e),{startX:T,startY:O}=X,{endX:Z,endY:K}=Y,D=!l.getRowRawVisible(M),A=!l.getColVisible(R),z=D||A,J=A?2:Z-T,E=D?2:K-O,ee={left:T,top:O,color:a,width:J,height:E,evented:!1,inHiddenRange:z,zIndex:de};return new ne(`find-highlight-${b}`,ee)});s.addObjects(S),this._highlightShapes=S,s.makeDirty()}_updateCurrentHighlightShape(e){var i;if((i=this._currentHighlightShape)==null||i.setShapeProps({activated:!1}),this._currentHighlightShape=null,e!==void 0){const n=this._highlightShapes[e];if(!n)return;this._currentHighlightShape=n,n.setShapeProps({activated:!0})}}_getSheetObject(){return y.getSheetObject(this._univerInstanceService,this._renderManagerService)}_focusMatch(e){const i=e.range.subUnitId;i!==this._workbook.getActiveSheet().getSheetId()&&this._commandService.syncExecuteCommand(k.SetWorksheetActivateCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:i},{fromFindReplace:!0}),this._commandService.syncExecuteCommand(y.ScrollToCellCommand.id,{range:e.range.range},{fromFindReplace:!0})}_tryRestoreLastMatchesPosition(e,i){if(!e)return 0;const{subUnitId:n}=e.range,{startColumn:r,startRow:o}=e.range.range,s=i.findIndex(c=>{if(n!==c.range.subUnitId)return!1;const{startColumn:h,startRow:a}=c.range.range;return h===r&&a===o});return s>-1?s+1:0}moveToNextMatch(e){var s,c,h;if(!this._matches.length)return null;const i=(s=e==null?void 0:e.loop)!=null?s:!1,n=(c=e==null?void 0:e.stayIfOnMatch)!=null?c:!1,r=(h=e==null?void 0:e.noFocus)!=null?h:!1,o=this._findNextMatch(i,n);if(o){const[a,l]=o;return this._matchesPosition=l+1,this._query.findScope===f.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(a.range.subUnitId).findIndex(u=>u===a):this._activeHighlightIndex=l,r||this._focusMatch(a),this._workbook.getActiveSheet().getSheetId()===a.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),a}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}moveToPreviousMatch(e){var s,c,h;if(!this._matches.length)return null;const i=(s=e==null?void 0:e.loop)!=null?s:!1,n=(c=e==null?void 0:e.stayIfOnMatch)!=null?c:!1,r=(h=e==null?void 0:e.noFocus)!=null?h:!1,o=this._findPreviousMatch(i,n);if(o){const[a,l]=o;return this._matchesPosition=l+1,this._query.findScope===f.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(a.range.subUnitId).findIndex(u=>u===a):this._activeHighlightIndex=l,r||this._focusMatch(a),this._workbook.getActiveSheet().getSheetId()===a.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),a}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}_findPreviousMatch(e=!1,i=!1){if(this.currentMatch){const s=this._matches.findIndex(l=>l===this.currentMatch);if(i)return[this.currentMatch,s];const c=s-1;if(!e&&c<0)return null;const h=this._matches.length,a=(c+h)%h;return[this._matches[a],a]}const n=this._selectionManagerService.getSelections();if(!(n!=null&&n.length))return[this._matches[0],0];if(this._query.findScope!==f.FindScope.UNIT)return this._findPreviousMatchByRange(this._matches,n[0].range);const r=this._workbook.getActiveSheet().getSheetId(),o=this._findPreviousWorksheetThatHasAMatch(r,e);return o?this._findPreviousMatchByRange(this._matchesByWorksheet.get(o),n[0].range):null}_findNextMatch(e=!1,i=!1){if(this.currentMatch){const s=this._matches.findIndex(l=>l===this.currentMatch);if(i)return[this.currentMatch,s];const c=s+1,h=this._matches.length;if(!e&&c>=h)return null;const a=c%h;return[this._matches[a],a]}const n=this._selectionManagerService.getSelections();if(!(n!=null&&n.length))return[this._matches[0],0];if(this._query.findScope!==f.FindScope.UNIT)return this._findNextMatchByRange(this._matches,n[0].range,i);const r=this._workbook.getActiveSheet().getSheetId(),o=this._findNextWorksheetThatHasAMatch(r,e);return o?this._findNextMatchByRange(this._matchesByWorksheet.get(o),n[0].range):null}_findPreviousWorksheetThatHasAMatch(e,i=!1){const n=this._workbook.getSheetOrders(),r=n.findIndex(c=>c===e),s=(i?d.rotate(n,r+1):n.slice(0,r+1)).findLast(c=>this._matchesByWorksheet.has(c));return s!=null?s:null}_findNextWorksheetThatHasAMatch(e,i=!1){const n=this._workbook.getSheetOrders(),r=n.findIndex(c=>c===e),s=(i?d.rotate(n,r):n.slice(r)).find(c=>this._matchesByWorksheet.has(c));return s!=null?s:null}_findNextMatchByRange(e,i,n=!1){const r=this._query.findDirection===f.FindDirection.ROW;let o=e.findIndex(c=>{const h=c.range.range;if(!(r?j(i,h):$(i,h)))return!1;const l=N(i,h);return n?l:!l});o===-1&&(o=e.length-1);const s=e[o];return[s,this._matches.findIndex(c=>c===s)]}_findPreviousMatchByRange(e,i,n=!1){const r=this._query.findDirection===f.FindDirection.ROW;let o=this._matches.findLastIndex(c=>{const h=c.range.range;if(!(r?re(i,h):oe(i,h)))return!1;const l=N(i,h);return n?l:!l});o===-1&&(o=0);const s=e[o];return[s,this._matches.findIndex(c=>c===s)]}async replace(e){if(this._matchesCount===0||!this.currentMatch||!this._query||!this.currentMatch.replaceable)return!1;const i=this.currentMatch.range,n=this._workbook.getSheetBySheetId(this.currentMatch.range.subUnitId),r=this._getReplacedCellData(this.currentMatch,n,this._query.findBy===f.FindBy.FORMULA,this._query.findString,e,this._query.caseSensitive?"g":"ig"),o={unitId:this.currentMatch.unitId,subUnitId:i.subUnitId,value:{[i.range.startRow]:{[i.range.startColumn]:r}}};return this._commandService.executeCommand(k.SetRangeValuesCommand.id,o)}async replaceAll(e){if(this._matchesCount===0||!this._query)return{success:0,failure:0};const i=this._workbook.getUnitId(),{findString:n,caseSensitive:r,findBy:o}=this._query,s=o===f.FindBy.FORMULA,c=r?"g":"ig",h=[];return d.groupBy(this._matches.filter(l=>l.replaceable),l=>l.range.subUnitId).forEach((l,u)=>{const S=new d.ObjectMatrix,C=this._workbook.getSheetBySheetId(u);l.forEach(p=>{const{startColumn:w,startRow:b}=p.range.range,R=this._getReplacedCellData(p,C,s,n,e,c);R&&S.setValue(b,w,R)}),h.push({count:l.length,subUnitId:u,value:S.getMatrix()})}),h?this._commandService.executeCommand(q.id,{unitId:i,replacements:h}):{success:0,failure:0}}_getReplacedCellData(e,i,n,r,o,s){var C;const c=e.range.range,{startRow:h,startColumn:a}=c,l=i.getCellRaw(h,a);if(e.isFormula)return n?{f:l.f.replace(new RegExp(V(r),s),o),v:null}:null;if(!!((C=l.p)!=null&&C.body)){const p=d.Tools.deepClone(l.p);return d.replaceInDocumentBody(p.body,r,o),{p}}return{v:l.v.toString().replace(new RegExp(V(r),s),o)}}_getFindReplacePermissionCheck(e){var a,l;const{row:i,col:n,subUnitId:r}=e,s=this._univerInstanceService.getCurrentUnitForType(d.UniverInstanceType.UNIVER_SHEET).getSheetBySheetId(r);if(!s)return!1;const c=(l=(a=s.getCell(i,n))==null?void 0:a.selectionProtection)==null?void 0:l[0];return(c==null?void 0:c[G.View])!==!1}};W=B([m(1,d.IUniverInstanceService),m(2,F.IRenderManagerService),m(3,d.ICommandService),m(4,d.IContextService),m(5,I.Inject(d.ThemeService)),m(6,I.Inject(y.SheetSkeletonManagerService)),m(7,I.Inject(k.SelectionManagerService)),m(8,I.Inject(exports.SheetsFindReplaceController))],W);function V(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}let H=class extends d.Disposable{constructor(e,i){super();_(this,"_findModelsByUnitId",new Map);this._univerInstanceService=e,this._injector=i}async find(e){this._terminate();const i=this._univerInstanceService.getCurrentUnitForType(d.UniverInstanceType.UNIVER_SHEET);if(i){const n=this._injector.createInstance(W,i);this._findModelsByUnitId.set(i.getUnitId(),n);const r=this._preprocessQuery(e);return n.start(r),[n]}return[]}terminate(){this._terminate()}_terminate(){this._findModelsByUnitId.forEach(e=>e.dispose()),this._findModelsByUnitId.clear()}_preprocessQuery(e){let i=e.caseSensitive?e.findString:e.findString.toLowerCase();return i=i.trim(),{...e,findString:i}}};H=B([m(0,d.IUniverInstanceService),m(1,I.Inject(I.Injector))],H);const g={hit:!1,replaceable:!1,isFormula:!1,rawData:null};function ue(t,e,i,n,r){const{findBy:o}=n,s=o===f.FindBy.FORMULA,c=t.getCellRaw(e,i);return g.rawData=c,!(c!=null&&c.f)?(g.isFormula=!1,U(r,n)?c?(g.hit=!0,g.replaceable=!0):(g.hit=!0,g.replaceable=!1):(g.hit=!1,g.replaceable=!1),g):(g.isFormula=!0,s?U({v:c.f},n)?(g.hit=!0,g.replaceable=!0,g):(g.hit=!1,g.replaceable=!1,g):(g.replaceable=!1,U(r,n)?g.hit=!0:g.hit=!1,g))}function U(t,e){let i=ge(t);return i?e.matchesTheWholeCell?(i=_e(i),e.caseSensitive?i===e.findString:i.toLowerCase()===e.findString):e.caseSensitive?i.indexOf(e.findString)>-1:i.toLowerCase().indexOf(e.findString)>-1:!1}function ge(t){var i,n,r;const e=(r=(n=(i=t==null?void 0:t.p)==null?void 0:i.body)==null?void 0:n.dataStream)!=null?r:t==null?void 0:t.v;return typeof e=="number"?`${e}`:typeof e=="boolean"?e?"1":"0":e}function _e(t){return t.replace(/^ +/g,"").replace(/ +$/g,"")}var fe=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,me=(t,e,i,n)=>{for(var r=n>1?void 0:n?Se(e,i):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(r=(n?s(e,i,r):s(r))||r);return n&&r&&fe(e,i,r),r},L=(t,e)=>(i,n)=>e(i,n,t);const pe="SHEET_FIND_REPLACE_PLUGIN";var x;exports.UniverSheetsFindReplacePlugin=(x=class extends d.Plugin{constructor(e,i,n){super(),this._injector=i,this._pluginService=n,this._pluginService.registerPlugin(f.UniverFindReplacePlugin)}onStarting(e){[[exports.SheetsFindReplaceController]].forEach(i=>e.add(i))}},_(x,"pluginName",pe),_(x,"type",d.UniverInstanceType.UNIVER_SHEET),x);exports.UniverSheetsFindReplacePlugin=me([L(1,I.Inject(I.Injector)),L(2,I.Inject(d.PluginService))],exports.UniverSheetsFindReplacePlugin);
|
|
1
|
+
"use strict";var ee=Object.defineProperty;var te=(c,e,t)=>e in c?ee(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t;var f=(c,e,t)=>(te(c,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@univerjs/core"),C=require("@wendellhu/redi"),_=require("@univerjs/find-replace"),R=require("@univerjs/sheets"),y=require("@univerjs/engine-render"),k=require("@univerjs/sheets-ui"),I=require("rxjs");class ne extends y.Shape{constructor(t,n){super(t,n);f(this,"_activated",!1);f(this,"_inHiddenRange",!1);f(this,"_color");n&&this.setShapeProps(n)}setShapeProps(t){this._activated=!!t.activated,typeof t.inHiddenRange<"u"&&(this._inHiddenRange=t.inHiddenRange),typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){const n=this._activated,i=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, 0.35)`,r=`rgb(${this._color.r}, ${this._color.g}, ${this._color.b})`;y.Rect.drawWith(t,{width:this.width,height:this.height,fill:i,stroke:n?r:void 0,strokeWidth:n?2:0,evented:!1})}}const $={id:"sheet.command.replace",type:d.CommandType.COMMAND,handler:async(c,e)=>{const t=c.get(d.IUndoRedoService),n=c.get(d.ICommandService),{unitId:i,replacements:r}=e,s=t.__tempBatchingUndoRedo(i),o=await Promise.all(r.map(h=>n.executeCommand(R.SetRangeValuesCommand.id,{unitId:i,subUnitId:h.subUnitId,value:h.value})));return s.dispose(),ie(o,r)}};function ie(c,e){let t=0,n=0;return c.forEach((i,r)=>{const s=e[r].count;i?t+=s:n+=s}),{success:t,failure:n}}function E(c,e){return c.startRow===e.startRow&&c.startColumn===e.startColumn}function A(c,e){return c.startRow<e.startRow||c.startRow===e.startRow&&c.startColumn<=e.startColumn}function D(c,e){return c.startColumn<e.startColumn||c.startColumn===e.startColumn&&c.startRow<=e.startRow}function se(c,e){return c.startRow>e.startRow||c.startRow===e.startRow&&c.startColumn>=e.startColumn}function re(c,e){return c.startColumn>e.startColumn||c.startColumn===e.startColumn&&c.startRow>=e.startRow}function oe(c,e){const{range:t}=c,{startRow:n,startColumn:i}=t,r=e.getMergedCell(n,i);return r?d.Rectangle.equals(t,r):t.endRow===t.startRow&&t.endColumn===t.startColumn}var ce=Object.defineProperty,he=Object.getOwnPropertyDescriptor,B=(c,e,t,n)=>{for(var i=n>1?void 0:n?he(e,t):e,r=c.length-1,s;r>=0;r--)(s=c[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&ce(e,t,i),i},m=(c,e)=>(t,n)=>e(t,n,c);exports.SheetsFindReplaceController=class extends d.Disposable{constructor(t,n,i,r,s){super();f(this,"_provider");this._injector=t,this._findReplaceController=n,this._contextService=i,this._findReplaceService=r,this._commandService=s,this._init(),this._initCommands()}dispose(){super.dispose(),this._findReplaceController.closePanel(),this._provider.dispose()}_init(){const t=this._injector.createInstance(P);this._provider=t,this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(t)),this.disposeWithMe(this._contextService.subscribeContextValue$(d.EDITOR_ACTIVATED).pipe(I.filter(n=>!!n)).subscribe(()=>this._findReplaceController.closePanel()))}_initCommands(){[$].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t)))}};exports.SheetsFindReplaceController=B([d.OnLifecycle(d.LifecycleStages.Steady,exports.SheetsFindReplaceController),m(0,C.Inject(C.Injector)),m(1,C.Inject(_.FindReplaceController)),m(2,d.IContextService),m(3,_.IFindReplaceService),m(4,d.ICommandService)],exports.SheetsFindReplaceController);const ae="sheets-find-replace-provider",le=1e4;let F=class extends _.FindModel{constructor(e,t,n,i,r,s,o,h){super();f(this,"_matchesUpdate$",new I.Subject);f(this,"matchesUpdate$",this._matchesUpdate$.asObservable());f(this,"_activelyChangingMatch$",new I.Subject);f(this,"activelyChangingMatch$",this._activelyChangingMatch$.asObservable());f(this,"_matchesByWorksheet",new Map);f(this,"_matches",[]);f(this,"_matchesPosition",0);f(this,"_activeHighlightIndex",-1);f(this,"_highlightShapes",[]);f(this,"_currentHighlightShape",null);f(this,"_query",null);this._workbook=e,this._sheetSkeletonManagerService=t,this._univerInstanceService=n,this._renderManagerService=i,this._commandService=r,this._contextService=s,this._themeService=o,this._selectionManagerService=h}get _matchesCount(){return this._matches.length}get unitId(){return this._workbook.getUnitId()}get matchesCount(){return this._matchesCount}get matchesPosition(){return this._matchesPosition}get currentMatch(){return this._matchesPosition>0?this._matches[this._matchesPosition-1]:null}dispose(){super.dispose(),this._disposeHighlights(),this._toggleDisplayRawFormula(!1)}getMatches(){return this._matches}start(e){switch(this._query=e,e.findBy===_.FindBy.FORMULA?this._toggleDisplayRawFormula(!0):this._toggleDisplayRawFormula(!1),e.findScope){case _.FindScope.UNIT:this.findInWorkbook(e);break;case _.FindScope.SUBUNIT:default:this.findInActiveWorksheet(e);break}}_toggleDisplayRawFormula(e){this._contextService.setContextValue(y.RENDER_RAW_FORMULA_KEY,e)}findInWorkbook(e){const t=this._workbook.getUnitId();let n,i=!0;const r=()=>{const s=this._workbook.getSheets().filter(o=>!o.isSheetHidden()).map(o=>{const h=this._findInWorksheet(o,e,t),l=o.getSheetId(),{results:a}=h;return a.length?this._matchesByWorksheet.set(l,h.results):this._matchesByWorksheet.delete(l),h});this._matches=s.map(o=>o.results).flat(),this._updateFindHighlight(),i?(n={results:this._matches},i=!1):this._matchesUpdate$.next(this._matches)};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._updateFindHighlight(),this._updateCurrentHighlightShape(this._activeHighlightIndex)})),this.disposeWithMe(d.fromCallback(this._commandService.onCommandExecuted).pipe(I.filter(([s,o])=>s.id===R.SetWorksheetActiveOperation.id&&!(o!=null&&o.fromFindReplace))).subscribe(()=>{const s=this._workbook.getActiveSheet(),o=s.getSheetId();this._matchesByWorksheet.has(o)&&this._findNextMatchOnActiveSheetChange(s)})),this.disposeWithMe(d.fromCallback(this._commandService.onCommandExecuted).pipe(I.filter(([s])=>s.type===d.CommandType.MUTATION&&s.params.unitId===this._workbook.getUnitId()),I.throttleTime(600,void 0,{leading:!1,trailing:!0})).subscribe(()=>r())),r(),n}_findNextMatchOnActiveSheetChange(e){let t,n,i=0;const r=this._matchesByWorksheet.get(e.getSheetId()),s=this._selectionManagerService.getSelections();s!=null&&s.length?([t,i]=this._findNextMatchByRange(r,s[0].range),n=r.findIndex(o=>o===t)):(t=r[0],n=0,i=this._matches.findIndex(o=>o===t)),this._matchesPosition=i+1,this._activelyChangingMatch$.next(t),this._activeHighlightIndex=n,this._updateFindHighlight(),this._updateCurrentHighlightShape(n)}findInActiveWorksheet(e){const t=this._workbook.getUnitId(),n=()=>{var u;const h=this._workbook.getActiveSheet(),l=this._selectionManagerService.getSelections();return(u=l==null?void 0:l.some(S=>!oe(S,h)))!=null?u:!1};let i,r=!0,s=!1;const o=()=>{const h=this._workbook.getActiveSheet(),l=this.currentMatch;s=n();const a=this._selectionManagerService.getSelections(),u=s?this._findInSelections(h,a,e,t):this._findInWorksheet(h,e,t);return this._matches=u.results,this._matchesPosition=this._tryRestoreLastMatchesPosition(l,this._matches),r?(i=u,r=!1):this._matchesUpdate$.next(this._matches),this._updateFindHighlight(),u};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>this._updateFindHighlight())),this.disposeWithMe(I.merge(d.fromCallback(this._commandService.onCommandExecuted).pipe(I.filter(([h])=>{if(h.type===d.CommandType.MUTATION&&h.params.unitId===this._workbook.getUnitId())return!0;if(h.id===R.SetSelectionsOperation.id&&h.params.unitId===t){const l=n();return l===!1&&s===!1?!1:(s=l,!0)}return!1})),this._workbook.activeSheet$.pipe(I.skip(1))).pipe(I.debounceTime(200)).subscribe(()=>o())),o(),i}_findInRange(e,t,n,i,r){const s=[],o=e.getSheetId(),h=(t.findDirection===_.FindDirection.COLUMN?e.iterateByColumn:e.iterateByRow).bind(e)(n);for(const l of h){const{row:a,col:u,colSpan:S,rowSpan:v,value:p}=l;if(r!=null&&r(a,u)||!p||e.getRowFiltered(a))continue;const{hit:b,replaceable:M,isFormula:w}=de(e,a,u,t,p);if(b){const x={provider:ae,unitId:i,replaceable:M,isFormula:w,range:{subUnitId:o,range:{startRow:a,startColumn:u,endColumn:u+(S!=null?S:1)-1,endRow:a+(v!=null?v:1)-1}}};s.push(x)}}return{results:s}}_findInSelections(e,t,n,i){const{findDirection:r}=n,s=r===_.FindDirection.ROW?A:D,o=new Set;return{results:t.map(l=>this._findInRange(e,n,l.range,i,(a,u)=>{const S=`${a}-${u}`;return o.has(S)?!0:(o.add(S),!1)}).results).flat().sort((l,a)=>s(l.range.range,a.range.range)?-1:1)}}_findInWorksheet(e,t,n){const i=e.getRowCount(),r=e.getColumnCount(),s={startRow:0,startColumn:0,endRow:i-1,endColumn:r-1};return this._findInRange(e,t,s,n)}_disposeHighlights(){var e;this._highlightShapes.forEach(t=>{t.getScene().makeDirty(),t.dispose()}),this._highlightShapes=[],(e=this._currentHighlightShape)==null||e.dispose(),this._currentHighlightShape=null}_updateFindHighlight(){var v,p;this._disposeHighlights();const e=(v=this._sheetSkeletonManagerService.getCurrent())==null?void 0:v.skeleton;if(!e||!this._getSheetObject()||((p=this._univerInstanceService.getFocusedUnit())==null?void 0:p.getUnitId())!==this._workbook.getUnitId())return;const i=this._workbook.getUnitId(),r=this._renderManagerService.getRenderById(i);if(r==null)return;const{scene:s}=r,o=this._matches,h=this._themeService.getCurrentTheme().gold400,l=new d.ColorKit(h).toRgb(),a=this._workbook.getActiveSheet(),u=a.getSheetId(),S=o.filter(b=>b.range.subUnitId===u).map((b,M)=>{const{startColumn:w,startRow:x,endColumn:V,endRow:q}=b.range.range,Q=k.getCoordByCell(x,w,s,e),X=k.getCoordByCell(q,V,s,e),{startX:W,startY:H}=Q,{endX:Y,endY:G}=X,T=!a.getRowRawVisible(x),O=!a.getColVisible(w),K=T||O,z=O?2:Y-W,J=T?2:G-H,Z={left:W,top:H,color:l,width:z,height:J,evented:!1,inHiddenRange:K,zIndex:le};return new ne(`find-highlight-${M}`,Z)});s.addObjects(S),this._highlightShapes=S,s.makeDirty()}_updateCurrentHighlightShape(e){var t;if((t=this._currentHighlightShape)==null||t.setShapeProps({activated:!1}),this._currentHighlightShape=null,e!==void 0){const n=this._highlightShapes[e];if(!n)return;this._currentHighlightShape=n,n.setShapeProps({activated:!0})}}_getSheetObject(){return k.getSheetObject(this._univerInstanceService,this._renderManagerService)}_focusMatch(e){const t=e.range.subUnitId;t!==this._workbook.getActiveSheet().getSheetId()&&this._commandService.syncExecuteCommand(R.SetWorksheetActivateCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:t},{fromFindReplace:!0}),this._commandService.syncExecuteCommand(k.ScrollToCellCommand.id,{range:e.range.range},{fromFindReplace:!0})}_tryRestoreLastMatchesPosition(e,t){if(!e)return 0;const{subUnitId:n}=e.range,{startColumn:i,startRow:r}=e.range.range,s=t.findIndex(o=>{if(n!==o.range.subUnitId)return!1;const{startColumn:h,startRow:l}=o.range.range;return h===i&&l===r});return s>-1?s+1:0}moveToNextMatch(e){var s,o,h;if(!this._matches.length)return null;const t=(s=e==null?void 0:e.loop)!=null?s:!1,n=(o=e==null?void 0:e.stayIfOnMatch)!=null?o:!1,i=(h=e==null?void 0:e.noFocus)!=null?h:!1,r=this._findNextMatch(t,n);if(r){const[l,a]=r;return this._matchesPosition=a+1,this._query.findScope===_.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(l.range.subUnitId).findIndex(u=>u===l):this._activeHighlightIndex=a,i||this._focusMatch(l),this._workbook.getActiveSheet().getSheetId()===l.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),l}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}moveToPreviousMatch(e){var s,o,h;if(!this._matches.length)return null;const t=(s=e==null?void 0:e.loop)!=null?s:!1,n=(o=e==null?void 0:e.stayIfOnMatch)!=null?o:!1,i=(h=e==null?void 0:e.noFocus)!=null?h:!1,r=this._findPreviousMatch(t,n);if(r){const[l,a]=r;return this._matchesPosition=a+1,this._query.findScope===_.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(l.range.subUnitId).findIndex(u=>u===l):this._activeHighlightIndex=a,i||this._focusMatch(l),this._workbook.getActiveSheet().getSheetId()===l.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),l}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}_findPreviousMatch(e=!1,t=!1){if(this.currentMatch){const s=this._matches.findIndex(a=>a===this.currentMatch);if(t)return[this.currentMatch,s];const o=s-1;if(!e&&o<0)return null;const h=this._matches.length,l=(o+h)%h;return[this._matches[l],l]}const n=this._selectionManagerService.getSelections();if(!(n!=null&&n.length))return[this._matches[0],0];if(this._query.findScope!==_.FindScope.UNIT)return this._findPreviousMatchByRange(this._matches,n[0].range);const i=this._workbook.getActiveSheet().getSheetId(),r=this._findPreviousWorksheetThatHasAMatch(i,e);return r?this._findPreviousMatchByRange(this._matchesByWorksheet.get(r),n[0].range):null}_findNextMatch(e=!1,t=!1){if(this.currentMatch){const s=this._matches.findIndex(a=>a===this.currentMatch);if(t)return[this.currentMatch,s];const o=s+1,h=this._matches.length;if(!e&&o>=h)return null;const l=o%h;return[this._matches[l],l]}const n=this._selectionManagerService.getSelections();if(!(n!=null&&n.length))return[this._matches[0],0];if(this._query.findScope!==_.FindScope.UNIT)return this._findNextMatchByRange(this._matches,n[0].range,t);const i=this._workbook.getActiveSheet().getSheetId(),r=this._findNextWorksheetThatHasAMatch(i,e);return r?this._findNextMatchByRange(this._matchesByWorksheet.get(r),n[0].range):null}_findPreviousWorksheetThatHasAMatch(e,t=!1){const n=this._workbook.getSheetOrders(),i=n.findIndex(o=>o===e),s=(t?d.rotate(n,i+1):n.slice(0,i+1)).findLast(o=>this._matchesByWorksheet.has(o));return s!=null?s:null}_findNextWorksheetThatHasAMatch(e,t=!1){const n=this._workbook.getSheetOrders(),i=n.findIndex(o=>o===e),s=(t?d.rotate(n,i):n.slice(i)).find(o=>this._matchesByWorksheet.has(o));return s!=null?s:null}_findNextMatchByRange(e,t,n=!1){const i=this._query.findDirection===_.FindDirection.ROW;let r=e.findIndex(o=>{const h=o.range.range;if(!(i?A(t,h):D(t,h)))return!1;const a=E(t,h);return n?a:!a});r===-1&&(r=e.length-1);const s=e[r];return[s,this._matches.findIndex(o=>o===s)]}_findPreviousMatchByRange(e,t,n=!1){const i=this._query.findDirection===_.FindDirection.ROW;let r=this._matches.findLastIndex(o=>{const h=o.range.range;if(!(i?se(t,h):re(t,h)))return!1;const a=E(t,h);return n?a:!a});r===-1&&(r=0);const s=e[r];return[s,this._matches.findIndex(o=>o===s)]}async replace(e){if(this._matchesCount===0||!this.currentMatch||!this._query||!this.currentMatch.replaceable)return!1;const t=this.currentMatch.range,n=this._workbook.getSheetBySheetId(this.currentMatch.range.subUnitId),i=this._getReplacedCellData(this.currentMatch,n,this._query.findBy===_.FindBy.FORMULA,this._query.findString,e,this._query.caseSensitive?"g":"ig"),r={unitId:this.currentMatch.unitId,subUnitId:t.subUnitId,value:{[t.range.startRow]:{[t.range.startColumn]:i}}};return this._commandService.executeCommand(R.SetRangeValuesCommand.id,r)}async replaceAll(e){if(this._matchesCount===0||!this._query)return{success:0,failure:0};const t=this._workbook.getUnitId(),{findString:n,caseSensitive:i,findBy:r}=this._query,s=r===_.FindBy.FORMULA,o=i?"g":"ig",h=[];return d.groupBy(this._matches.filter(a=>a.replaceable),a=>a.range.subUnitId).forEach((a,u)=>{const S=new d.ObjectMatrix,v=this._workbook.getSheetBySheetId(u);a.forEach(p=>{const{startColumn:b,startRow:M}=p.range.range,w=this._getReplacedCellData(p,v,s,n,e,o);w&&S.setValue(M,b,w)}),h.push({count:a.length,subUnitId:u,value:S.getMatrix()})}),h?this._commandService.executeCommand($.id,{unitId:t,replacements:h}):{success:0,failure:0}}_getReplacedCellData(e,t,n,i,r,s){var v;const o=e.range.range,{startRow:h,startColumn:l}=o,a=t.getCellRaw(h,l);if(e.isFormula)return n?{f:a.f.replace(new RegExp(N(i),s),r),v:null}:null;if(!!((v=a.p)!=null&&v.body)){const p=d.Tools.deepClone(a.p);return d.replaceInDocumentBody(p.body,i,r),{p}}return{v:a.v.toString().replace(new RegExp(N(i),s),r)}}};F=B([m(2,d.IUniverInstanceService),m(3,y.IRenderManagerService),m(4,d.ICommandService),m(5,d.IContextService),m(6,C.Inject(d.ThemeService)),m(7,C.Inject(R.SelectionManagerService))],F);function N(c){return c.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}let P=class extends d.Disposable{constructor(e,t,n){super();f(this,"_findModelsByUnitId",new Map);this._univerInstanceService=e,this._renderManagerService=t,this._injector=n}async find(e){this._terminate();const t=this._univerInstanceService.getCurrentUnitForType(d.UniverInstanceType.UNIVER_SHEET),n=this._renderManagerService.getRenderById(t.getUnitId()).with(k.SheetSkeletonManagerService);if(t){const i=this._injector.createInstance(F,t,n);this._findModelsByUnitId.set(t.getUnitId(),i);const r=this._preprocessQuery(e);return i.start(r),[i]}return[]}terminate(){this._terminate()}_terminate(){this._findModelsByUnitId.forEach(e=>e.dispose()),this._findModelsByUnitId.clear()}_preprocessQuery(e){let t=e.caseSensitive?e.findString:e.findString.toLowerCase();return t=t.trim(),{...e,findString:t}}};P=B([m(0,d.IUniverInstanceService),m(1,y.IRenderManagerService),m(2,C.Inject(C.Injector))],P);const g={hit:!1,replaceable:!1,isFormula:!1,rawData:null};function de(c,e,t,n,i){const{findBy:r}=n,s=r===_.FindBy.FORMULA,o=c.getCellRaw(e,t);return g.rawData=o,!(o!=null&&o.f)?(g.isFormula=!1,U(i,n)?o?(g.hit=!0,g.replaceable=!0):(g.hit=!0,g.replaceable=!1):(g.hit=!1,g.replaceable=!1),g):(g.isFormula=!0,s?U({v:o.f},n)?(g.hit=!0,g.replaceable=!0,g):(g.hit=!1,g.replaceable=!1,g):(g.replaceable=!1,U(i,n)?g.hit=!0:g.hit=!1,g))}function U(c,e){let t=ue(c);return t?e.matchesTheWholeCell?(t=ge(t),e.caseSensitive?t===e.findString:t.toLowerCase()===e.findString):e.caseSensitive?t.indexOf(e.findString)>-1:t.toLowerCase().indexOf(e.findString)>-1:!1}function ue(c){var t,n,i;const e=(i=(n=(t=c==null?void 0:c.p)==null?void 0:t.body)==null?void 0:n.dataStream)!=null?i:c==null?void 0:c.v;return typeof e=="number"?`${e}`:typeof e=="boolean"?e?"1":"0":e}function ge(c){return c.replace(/^ +/g,"").replace(/ +$/g,"")}var j=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,fe=(c,e,t)=>e in c?j(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,Se=(c,e,t,n)=>{for(var i=n>1?void 0:n?_e(e,t):e,r=c.length-1,s;r>=0;r--)(s=c[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&j(e,t,i),i},me=(c,e)=>(t,n)=>e(t,n,c),L=(c,e,t)=>(fe(c,typeof e!="symbol"?e+"":e,t),t);const pe="SHEET_FIND_REPLACE_PLUGIN";exports.UniverSheetsFindReplacePlugin=class extends d.Plugin{constructor(e,t){super(),this._injector=t}onStarting(e){[[exports.SheetsFindReplaceController]].forEach(t=>e.add(t))}};L(exports.UniverSheetsFindReplacePlugin,"pluginName",pe);L(exports.UniverSheetsFindReplacePlugin,"type",d.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsFindReplacePlugin=Se([d.DependentOn(R.UniverSheetsPlugin,R.UniverSheetsPlugin,_.UniverFindReplacePlugin),me(1,C.Inject(C.Injector))],exports.UniverSheetsFindReplacePlugin);
|