@univerjs/sheets-find-replace 0.1.12 → 0.1.13
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 +343 -356
- package/lib/locale/en-US.json +8 -0
- package/lib/locale/ru-RU.json +8 -0
- package/lib/locale/zh-CN.json +8 -0
- package/lib/types/controllers/sheet-find-replace.controller.d.ts +3 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +18 -14
- package/lib/types/locale/index.d.ts +0 -18
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var te=Object.defineProperty;var ie=(c,e,t)=>e in c?te(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t;var f=(c,e,t)=>(ie(c,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@univerjs/core"),I=require("@wendellhu/redi"),_=require("@univerjs/find-replace"),F=require("@univerjs/engine-render"),w=require("@univerjs/sheets"),k=require("@univerjs/sheets-ui"),C=require("rxjs"),ne={"sheet-find-replace":{replace:{"partial-failure":"Failed to replace some cells",failure:"Failed to replace all cells"}}},se={"sheet-find-replace":{replace:{"partial-failure":"部分单元格替换失败",failure:"替换失败"}}},re={"sheet-find-replace":{replace:{"partial-failure":"Не удалось заменить некоторые ячейки",failure:"Не удалось заменить все ячейки"}}};class oe extends F.Shape{constructor(t,i){super(t,i);f(this,"_activated",!1);f(this,"_inHiddenRange",!1);f(this,"_color");i&&this.setShapeProps(i)}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 i=this._activated,n=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, 0.35)`,r=`rgb(${this._color.r}, ${this._color.g}, ${this._color.b})`;F.Rect.drawWith(t,{width:this.width,height:this.height,fill:n,stroke:i?r:void 0,strokeWidth:i?2:0,evented:!1})}}const V={id:"sheet.command.replace",type:d.CommandType.COMMAND,handler:async(c,e)=>{const t=c.get(d.IUndoRedoService),i=c.get(d.ICommandService),{unitId:n,replacements:r}=e,s=t.__tempBatchingUndoRedo(n),o=await Promise.all(r.map(h=>i.executeCommand(w.SetRangeValuesCommand.id,{unitId:n,subUnitId:h.subUnitId,value:h.value})));return s.dispose(),ce(o,r)}};function ce(c,e){let t=0,i=0;return c.forEach((n,r)=>{const s=e[r].count;n?t+=s:i+=s}),{success:t,failure:i}}function D(c,e){return c.startRow===e.startRow&&c.startColumn===e.startColumn}function N(c,e){return c.startRow<e.startRow||c.startRow===e.startRow&&c.startColumn<=e.startColumn}function j(c,e){return c.startColumn<e.startColumn||c.startColumn===e.startColumn&&c.startRow<=e.startRow}function he(c,e){return c.startRow>e.startRow||c.startRow===e.startRow&&c.startColumn>=e.startColumn}function ae(c,e){return c.startColumn>e.startColumn||c.startColumn===e.startColumn&&c.startRow>=e.startRow}function le(c,e){const{range:t}=c,{startRow:i,startColumn:n}=t,r=e.getMergedCell(i,n);return r?d.Rectangle.equals(t,r):t.endRow===t.startRow&&t.endColumn===t.startColumn}var de=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,H=(c,e,t,i)=>{for(var n=i>1?void 0:i?ue(e,t):e,r=c.length-1,s;r>=0;r--)(s=c[r])&&(n=(i?s(e,t,n):s(n))||n);return i&&n&&de(e,t,n),n},m=(c,e)=>(t,i)=>e(t,i,c);let U=class extends d.Disposable{constructor(e,t,i,n,r){super();f(this,"_provider");this._injector=e,this._findReplaceController=t,this._contextService=i,this._findReplaceService=n,this._commandService=r,this._init(),this._initCommands()}dispose(){super.dispose(),this._provider.dispose()}_init(){const e=this._injector.createInstance(W);this._provider=e,this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(e)),this.disposeWithMe(this._contextService.subscribeContextValue$(d.EDITOR_ACTIVATED).pipe(C.filter(t=>!!t)).subscribe(()=>this._findReplaceController.closePanel()))}_initCommands(){[V].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};U=H([d.OnLifecycle(d.LifecycleStages.Steady,U),m(0,I.Inject(I.Injector)),m(1,I.Inject(_.FindReplaceController)),m(2,d.IContextService),m(3,_.IFindReplaceService),m(4,d.ICommandService)],U);const ge="sheets-find-replace-provider",fe=1e4;let B=class extends _.FindModel{constructor(e,t,i,n,r,s,o,h){super();f(this,"_matchesUpdate$",new C.Subject);f(this,"matchesUpdate$",this._matchesUpdate$.asObservable());f(this,"_activelyChangingMatch$",new C.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._univerInstanceService=t,this._renderManagerService=i,this._commandService=n,this._contextService=r,this._themeService=s,this._sheetSkeletonManagerService=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(F.RENDER_RAW_FORMULA_KEY,e)}findInWorkbook(e){const t=this._workbook.getUnitId();let i,n=!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(),n?(i={results:this._matches},n=!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(C.filter(([s,o])=>s.id===w.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(C.filter(([s])=>s.type===d.CommandType.MUTATION&&s.params.unitId===this._workbook.getUnitId()),C.throttleTime(600,void 0,{leading:!1,trailing:!0})).subscribe(()=>r())),r(),i}_findNextMatchOnActiveSheetChange(e){let t,i,n=0;const r=this._matchesByWorksheet.get(e.getSheetId()),s=this._selectionManagerService.getSelections();s!=null&&s.length?([t,n]=this._findNextMatchByRange(r,s[0].range),i=r.findIndex(o=>o===t)):(t=r[0],i=0,n=this._matches.findIndex(o=>o===t)),this._matchesPosition=n+1,this._activelyChangingMatch$.next(t),this._activeHighlightIndex=i,this._updateFindHighlight(),this._updateCurrentHighlightShape(i)}findInActiveWorksheet(e){const t=this._workbook.getUnitId(),i=()=>{var u;const h=this._workbook.getActiveSheet(),l=this._selectionManagerService.getSelections();return(u=l==null?void 0:l.some(S=>!le(S,h)))!=null?u:!1};let n,r=!0,s=!1;const o=()=>{const h=this._workbook.getActiveSheet(),l=this.currentMatch;s=i();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?(n=u,r=!1):this._matchesUpdate$.next(this._matches),this._updateFindHighlight(),u};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>this._updateFindHighlight())),this.disposeWithMe(C.merge(d.fromCallback(this._commandService.onCommandExecuted).pipe(C.filter(([h])=>{if(h.type===d.CommandType.MUTATION&&h.params.unitId===this._workbook.getUnitId())return!0;if(h.id===w.SetSelectionsOperation.id&&h.params.unitId===t){const l=i();return l===!1&&s===!1?!1:(s=l,!0)}return!1})),this._workbook.activeSheet$.pipe(C.skip(1))).pipe(C.debounceTime(200)).subscribe(()=>o())),o(),n}_findInRange(e,t,i,n,r){const s=[],o=e.getSheetId(),h=(t.findDirection===_.FindDirection.COLUMN?e.iterateByColumn:e.iterateByRow).bind(e)(i);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:R,replaceable:M,isFormula:b}=_e(e,a,u,t,p);if(R){const y={provider:ge,unitId:n,replaceable:M,isFormula:b,range:{subUnitId:o,range:{startRow:a,startColumn:u,endColumn:u+(S!=null?S:1)-1,endRow:a+(v!=null?v:1)-1}}};s.push(y)}}return{results:s}}_findInSelections(e,t,i,n){const{findDirection:r}=i,s=r===_.FindDirection.ROW?N:j,o=new Set;return{results:t.map(l=>this._findInRange(e,i,l.range,n,(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,i){const n=e.getRowCount(),r=e.getColumnCount(),s={startRow:0,startColumn:0,endRow:n-1,endColumn:r-1};return this._findInRange(e,t,s,i)}_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 n=this._workbook.getUnitId(),r=this._renderManagerService.getRenderById(n);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(R=>R.range.subUnitId===u).map((R,M)=>{const{startColumn:b,startRow:y,endColumn:q,endRow:Q}=R.range.range,X=k.getCoordByCell(y,b,s,e),Y=k.getCoordByCell(Q,q,s,e),{startX:T,startY:O}=X,{endX:z,endY:G}=Y,E=!a.getRowRawVisible(y),A=!a.getColVisible(b),K=E||A,J=A?2:z-T,Z=E?2:G-O,ee={left:T,top:O,color:l,width:J,height:Z,evented:!1,inHiddenRange:K};return new oe(`find-highlight-${M}`,ee)});s.addObjects(S,fe),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 i=this._highlightShapes[e];if(!i)return;this._currentHighlightShape=i,i.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(w.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:i}=e.range,{startColumn:n,startRow:r}=e.range.range,s=t.findIndex(o=>{if(i!==o.range.subUnitId)return!1;const{startColumn:h,startRow:l}=o.range.range;return h===n&&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,i=(o=e==null?void 0:e.stayIfOnMatch)!=null?o:!1,n=(h=e==null?void 0:e.noFocus)!=null?h:!1,r=this._findNextMatch(t,i);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,n||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,i=(o=e==null?void 0:e.stayIfOnMatch)!=null?o:!1,n=(h=e==null?void 0:e.noFocus)!=null?h:!1,r=this._findPreviousMatch(t,i);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,n||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 i=this._selectionManagerService.getSelections();if(!(i!=null&&i.length))return[this._matches[0],0];if(this._query.findScope!==_.FindScope.UNIT)return this._findPreviousMatchByRange(this._matches,i[0].range);const n=this._workbook.getActiveSheet().getSheetId(),r=this._findPreviousWorksheetThatHasAMatch(n,e);return r?this._findPreviousMatchByRange(this._matchesByWorksheet.get(r),i[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 i=this._selectionManagerService.getSelections();if(!(i!=null&&i.length))return[this._matches[0],0];if(this._query.findScope!==_.FindScope.UNIT)return this._findNextMatchByRange(this._matches,i[0].range,t);const n=this._workbook.getActiveSheet().getSheetId(),r=this._findNextWorksheetThatHasAMatch(n,e);return r?this._findNextMatchByRange(this._matchesByWorksheet.get(r),i[0].range):null}_findPreviousWorksheetThatHasAMatch(e,t=!1){const i=this._workbook.getSheetOrders(),n=i.findIndex(o=>o===e),s=(t?d.rotate(i,n+1):i.slice(0,n+1)).findLast(o=>this._matchesByWorksheet.has(o));return s!=null?s:null}_findNextWorksheetThatHasAMatch(e,t=!1){const i=this._workbook.getSheetOrders(),n=i.findIndex(o=>o===e),s=(t?d.rotate(i,n):i.slice(n)).find(o=>this._matchesByWorksheet.has(o));return s!=null?s:null}_findNextMatchByRange(e,t,i=!1){const n=this._query.findDirection===_.FindDirection.ROW;let r=e.findIndex(o=>{const h=o.range.range;if(!(n?N(t,h):j(t,h)))return!1;const a=D(t,h);return i?a:!a});r===-1&&(r=e.length-1);const s=e[r];return[s,this._matches.findIndex(o=>o===s)]}_findPreviousMatchByRange(e,t,i=!1){const n=this._query.findDirection===_.FindDirection.ROW;let r=this._matches.findLastIndex(o=>{const h=o.range.range;if(!(n?he(t,h):ae(t,h)))return!1;const a=D(t,h);return i?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,i=this._workbook.getSheetBySheetId(this.currentMatch.range.subUnitId),n=this._getReplacedCellData(this.currentMatch,i,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]:n}}};return this._commandService.executeCommand(w.SetRangeValuesCommand.id,r)}async replaceAll(e){if(this._matchesCount===0||!this._query)return{success:0,failure:0};const t=this._workbook.getUnitId(),{findString:i,caseSensitive:n,findBy:r}=this._query,s=r===_.FindBy.FORMULA,o=n?"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:R,startRow:M}=p.range.range,b=this._getReplacedCellData(p,v,s,i,e,o);b&&S.setValue(M,R,b)}),h.push({count:a.length,subUnitId:u,value:S.getMatrix()})}),h?this._commandService.executeCommand(V.id,{unitId:t,replacements:h}):{success:0,failure:0}}_getReplacedCellData(e,t,i,n,r,s){var v;const o=e.range.range,{startRow:h,startColumn:l}=o,a=t.getCellRaw(h,l);if(e.isFormula)return i?{f:a.f.replace(new RegExp($(n),s),r),v:null}:null;if(!!((v=a.p)!=null&&v.body)){const p=d.Tools.deepClone(a.p);return d.replaceInDocumentBody(p.body,n,r),{p}}return{v:a.v.toString().replace(new RegExp($(n),s),r)}}};B=H([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(k.SheetSkeletonManagerService)),m(7,I.Inject(w.SelectionManagerService))],B);function $(c){return c.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}let W=class extends d.Disposable{constructor(e,t){super();f(this,"_findModelsByUnitId",new Map);this._univerInstanceService=e,this._injector=t}async find(e){this._terminate();const t=this._univerInstanceService.getCurrentUnitForType(d.UniverInstanceType.UNIVER_SHEET);if(t){const i=this._injector.createInstance(B,t);this._findModelsByUnitId.set(t.getUnitId(),i);const n=this._preprocessQuery(e);return i.start(n),[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}}};W=H([m(0,d.IUniverInstanceService),m(1,I.Inject(I.Injector))],W);const g={hit:!1,replaceable:!1,isFormula:!1,rawData:null};function _e(c,e,t,i,n){const{findBy:r}=i,s=r===_.FindBy.FORMULA,o=c.getCellRaw(e,t);return g.rawData=o,!(o!=null&&o.f)?(g.isFormula=!1,P(n,i)?o?(g.hit=!0,g.replaceable=!0):(g.hit=!0,g.replaceable=!1):(g.hit=!1,g.replaceable=!1),g):(g.isFormula=!0,s?P({v:o.f},i)?(g.hit=!0,g.replaceable=!0,g):(g.hit=!1,g.replaceable=!1,g):(g.replaceable=!1,P(n,i)?g.hit=!0:g.hit=!1,g))}function P(c,e){let t=Se(c);return t?e.matchesTheWholeCell?(t=me(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 Se(c){var t,i,n;const e=(n=(i=(t=c==null?void 0:c.p)==null?void 0:t.body)==null?void 0:i.dataStream)!=null?n:c==null?void 0:c.v;return typeof e=="number"?`${e}`:typeof e=="boolean"?e?"1":"0":e}function me(c){return c.replace(/^ +/g,"").replace(/ +$/g,"")}var pe=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,Ie=(c,e,t,i)=>{for(var n=i>1?void 0:i?ve(e,t):e,r=c.length-1,s;r>=0;r--)(s=c[r])&&(n=(i?s(e,t,n):s(n))||n);return i&&n&&pe(e,t,n),n},L=(c,e)=>(t,i)=>e(t,i,c);const Ce="SHEET_FIND_REPLACE_PLUGIN";var x;exports.UniverSheetsFindReplacePlugin=(x=class extends d.Plugin{constructor(e,t,i){super(),this._injector=t,this._pluginService=i,this._pluginService.registerPlugin(_.UniverFindReplacePlugin)}onStarting(e){[[U]].forEach(t=>e.add(t))}},f(x,"pluginName",Ce),f(x,"type",d.UniverInstanceType.UNIVER_SHEET),x);exports.UniverSheetsFindReplacePlugin=Ie([L(1,I.Inject(I.Injector)),L(2,I.Inject(d.PluginService))],exports.UniverSheetsFindReplacePlugin);exports.enUS=ne;exports.ruRU=re;exports.zhCN=se;
|
|
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);
|