@univerjs/sheets-find-replace 0.1.11 → 0.1.12
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 +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +15 -15
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="UNIVER_SHEETS_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=(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;
|
package/lib/es/index.js
CHANGED
|
@@ -594,7 +594,7 @@ var st = Object.defineProperty, rt = Object.getOwnPropertyDescriptor, ot = (h, e
|
|
|
594
594
|
(s = h[r]) && (n = (i ? s(e, t, n) : s(n)) || n);
|
|
595
595
|
return i && n && st(e, t, n), n;
|
|
596
596
|
}, G = (h, e) => (t, i) => e(t, i, h);
|
|
597
|
-
const ht = "
|
|
597
|
+
const ht = "SHEET_FIND_REPLACE_PLUGIN";
|
|
598
598
|
var M;
|
|
599
599
|
let K = (M = class extends Me {
|
|
600
600
|
constructor(h, e, t) {
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(d,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/find-replace"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/find-replace","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-ui","rxjs"],u):(d=typeof globalThis<"u"?globalThis:d||self,u(d.UniverSheetsFindReplace={},d.UniverCore,d["@wendellhu/redi"],d.UniverFindReplace,d.UniverEngineRender,d.UniverSheets,d.UniverSheetsUi,d.rxjs))})(this,function(d,u,m,S,U,M,k,w){"use strict";var Ce=Object.defineProperty;var we=(d,u,m)=>u in d?Ce(d,u,{enumerable:!0,configurable:!0,writable:!0,value:m}):d[u]=m;var _=(d,u,m)=>(we(d,typeof u!="symbol"?u+"":u,m),m);var F;const Q={"sheet-find-replace":{replace:{"partial-failure":"Failed to replace some cells",failure:"Failed to replace all cells"}}},X={"sheet-find-replace":{replace:{"partial-failure":"部分单元格替换失败",failure:"替换失败"}}},Y={"sheet-find-replace":{replace:{"partial-failure":"Не удалось заменить некоторые ячейки",failure:"Не удалось заменить все ячейки"}}};class z extends U.Shape{constructor(t,i){super(t,i);_(this,"_activated",!1);_(this,"_inHiddenRange",!1);_(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})`;U.Rect.drawWith(t,{width:this.width,height:this.height,fill:n,stroke:i?r:void 0,strokeWidth:i?2:0,evented:!1})}}const O={id:"sheet.command.replace",type:u.CommandType.COMMAND,handler:async(h,e)=>{const t=h.get(u.IUndoRedoService),i=h.get(u.ICommandService),{unitId:n,replacements:r}=e,s=t.__tempBatchingUndoRedo(n),o=await Promise.all(r.map(c=>i.executeCommand(M.SetRangeValuesCommand.id,{unitId:n,subUnitId:c.subUnitId,value:c.value})));return s.dispose(),G(o,r)}};function G(h,e){let t=0,i=0;return h.forEach((n,r)=>{const s=e[r].count;n?t+=s:i+=s}),{success:t,failure:i}}function E(h,e){return h.startRow===e.startRow&&h.startColumn===e.startColumn}function A(h,e){return h.startRow<e.startRow||h.startRow===e.startRow&&h.startColumn<=e.startColumn}function D(h,e){return h.startColumn<e.startColumn||h.startColumn===e.startColumn&&h.startRow<=e.startRow}function K(h,e){return h.startRow>e.startRow||h.startRow===e.startRow&&h.startColumn>=e.startColumn}function J(h,e){return h.startColumn>e.startColumn||h.startColumn===e.startColumn&&h.startRow>=e.startRow}function Z(h,e){const{range:t}=h,{startRow:i,startColumn:n}=t,r=e.getMergedCell(i,n);return r?u.Rectangle.equals(t,r):t.endRow===t.startRow&&t.endColumn===t.startColumn}var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,B=(h,e,t,i)=>{for(var n=i>1?void 0:i?te(e,t):e,r=h.length-1,s;r>=0;r--)(s=h[r])&&(n=(i?s(e,t,n):s(n))||n);return i&&n&&ee(e,t,n),n},p=(h,e)=>(t,i)=>e(t,i,h);let x=class extends u.Disposable{constructor(e,t,i,n,r){super();_(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(T);this._provider=e,this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(e)),this.disposeWithMe(this._contextService.subscribeContextValue$(u.EDITOR_ACTIVATED).pipe(w.filter(t=>!!t)).subscribe(()=>this._findReplaceController.closePanel()))}_initCommands(){[O].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};x=B([u.OnLifecycle(u.LifecycleStages.Steady,x),p(0,m.Inject(m.Injector)),p(1,m.Inject(S.FindReplaceController)),p(2,u.IContextService),p(3,S.IFindReplaceService),p(4,u.ICommandService)],x);const ie="sheets-find-replace-provider",ne=1e4;let W=class extends S.FindModel{constructor(e,t,i,n,r,s,o,c){super();_(this,"_matchesUpdate$",new w.Subject);_(this,"matchesUpdate$",this._matchesUpdate$.asObservable());_(this,"_activelyChangingMatch$",new w.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=t,this._renderManagerService=i,this._commandService=n,this._contextService=r,this._themeService=s,this._sheetSkeletonManagerService=o,this._selectionManagerService=c}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===S.FindBy.FORMULA?this._toggleDisplayRawFormula(!0):this._toggleDisplayRawFormula(!1),e.findScope){case S.FindScope.UNIT:this.findInWorkbook(e);break;case S.FindScope.SUBUNIT:default:this.findInActiveWorksheet(e);break}}_toggleDisplayRawFormula(e){this._contextService.setContextValue(U.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 c=this._findInWorksheet(o,e,t),l=o.getSheetId(),{results:a}=c;return a.length?this._matchesByWorksheet.set(l,c.results):this._matchesByWorksheet.delete(l),c});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(u.fromCallback(this._commandService.onCommandExecuted).pipe(w.filter(([s,o])=>s.id===M.SetWorksheetActiveOperation.id&&!(o!=null&&o.fromFindReplace))).subscribe(()=>{const s=this._workbook.getActiveSheet(),o=s.getSheetId();this._matchesByWorksheet.has(o)&&this._findNextMatchOnActiveSheetChange(s)})),this.disposeWithMe(u.fromCallback(this._commandService.onCommandExecuted).pipe(w.filter(([s])=>s.type===u.CommandType.MUTATION&&s.params.unitId===this._workbook.getUnitId()),w.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 g;const c=this._workbook.getActiveSheet(),l=this._selectionManagerService.getSelections();return(g=l==null?void 0:l.some(v=>!Z(v,c)))!=null?g:!1};let n,r=!0,s=!1;const o=()=>{const c=this._workbook.getActiveSheet(),l=this.currentMatch;s=i();const a=this._selectionManagerService.getSelections(),g=s?this._findInSelections(c,a,e,t):this._findInWorksheet(c,e,t);return this._matches=g.results,this._matchesPosition=this._tryRestoreLastMatchesPosition(l,this._matches),r?(n=g,r=!1):this._matchesUpdate$.next(this._matches),this._updateFindHighlight(),g};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>this._updateFindHighlight())),this.disposeWithMe(w.merge(u.fromCallback(this._commandService.onCommandExecuted).pipe(w.filter(([c])=>{if(c.type===u.CommandType.MUTATION&&c.params.unitId===this._workbook.getUnitId())return!0;if(c.id===M.SetSelectionsOperation.id&&c.params.unitId===t){const l=i();return l===!1&&s===!1?!1:(s=l,!0)}return!1})),this._workbook.activeSheet$.pipe(w.skip(1))).pipe(w.debounceTime(200)).subscribe(()=>o())),o(),n}_findInRange(e,t,i,n,r){const s=[],o=e.getSheetId(),c=(t.findDirection===S.FindDirection.COLUMN?e.iterateByColumn:e.iterateByRow).bind(e)(i);for(const l of c){const{row:a,col:g,colSpan:v,rowSpan:C,value:I}=l;if(r!=null&&r(a,g)||!I||e.getRowFiltered(a))continue;const{hit:R,replaceable:y,isFormula:b}=se(e,a,g,t,I);if(R){const P={provider:ie,unitId:n,replaceable:y,isFormula:b,range:{subUnitId:o,range:{startRow:a,startColumn:g,endColumn:g+(v!=null?v:1)-1,endRow:a+(C!=null?C:1)-1}}};s.push(P)}}return{results:s}}_findInSelections(e,t,i,n){const{findDirection:r}=i,s=r===S.FindDirection.ROW?A:D,o=new Set;return{results:t.map(l=>this._findInRange(e,i,l.range,n,(a,g)=>{const v=`${a}-${g}`;return o.has(v)?!0:(o.add(v),!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 C,I;this._disposeHighlights();const e=(C=this._sheetSkeletonManagerService.getCurrent())==null?void 0:C.skeleton;if(!e||!this._getSheetObject()||((I=this._univerInstanceService.getFocusedUnit())==null?void 0:I.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,c=this._themeService.getCurrentTheme().gold400,l=new u.ColorKit(c).toRgb(),a=this._workbook.getActiveSheet(),g=a.getSheetId(),v=o.filter(R=>R.range.subUnitId===g).map((R,y)=>{const{startColumn:b,startRow:P,endColumn:ue,endRow:de}=R.range.range,ge=k.getCoordByCell(P,b,s,e),fe=k.getCoordByCell(de,ue,s,e),{startX:$,startY:L}=ge,{endX:_e,endY:Se}=fe,V=!a.getRowRawVisible(P),q=!a.getColVisible(b),me=V||q,ve=q?2:_e-$,pe=V?2:Se-L,Ie={left:$,top:L,color:l,width:ve,height:pe,evented:!1,inHiddenRange:me};return new z(`find-highlight-${y}`,Ie)});s.addObjects(v,ne),this._highlightShapes=v,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(M.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:c,startRow:l}=o.range.range;return c===n&&l===r});return s>-1?s+1:0}moveToNextMatch(e){var s,o,c;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=(c=e==null?void 0:e.noFocus)!=null?c:!1,r=this._findNextMatch(t,i);if(r){const[l,a]=r;return this._matchesPosition=a+1,this._query.findScope===S.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(l.range.subUnitId).findIndex(g=>g===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,c;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=(c=e==null?void 0:e.noFocus)!=null?c:!1,r=this._findPreviousMatch(t,i);if(r){const[l,a]=r;return this._matchesPosition=a+1,this._query.findScope===S.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(l.range.subUnitId).findIndex(g=>g===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 c=this._matches.length,l=(o+c)%c;return[this._matches[l],l]}const i=this._selectionManagerService.getSelections();if(!(i!=null&&i.length))return[this._matches[0],0];if(this._query.findScope!==S.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,c=this._matches.length;if(!e&&o>=c)return null;const l=o%c;return[this._matches[l],l]}const i=this._selectionManagerService.getSelections();if(!(i!=null&&i.length))return[this._matches[0],0];if(this._query.findScope!==S.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?u.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?u.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===S.FindDirection.ROW;let r=e.findIndex(o=>{const c=o.range.range;if(!(n?A(t,c):D(t,c)))return!1;const a=E(t,c);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===S.FindDirection.ROW;let r=this._matches.findLastIndex(o=>{const c=o.range.range;if(!(n?K(t,c):J(t,c)))return!1;const a=E(t,c);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===S.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(M.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===S.FindBy.FORMULA,o=n?"g":"ig",c=[];return u.groupBy(this._matches.filter(a=>a.replaceable),a=>a.range.subUnitId).forEach((a,g)=>{const v=new u.ObjectMatrix,C=this._workbook.getSheetBySheetId(g);a.forEach(I=>{const{startColumn:R,startRow:y}=I.range.range,b=this._getReplacedCellData(I,C,s,i,e,o);b&&v.setValue(y,R,b)}),c.push({count:a.length,subUnitId:g,value:v.getMatrix()})}),c?this._commandService.executeCommand(O.id,{unitId:t,replacements:c}):{success:0,failure:0}}_getReplacedCellData(e,t,i,n,r,s){var C;const o=e.range.range,{startRow:c,startColumn:l}=o,a=t.getCellRaw(c,l);if(e.isFormula)return i?{f:a.f.replace(new RegExp(N(n),s),r),v:null}:null;if(!!((C=a.p)!=null&&C.body)){const I=u.Tools.deepClone(a.p);return u.replaceInDocumentBody(I.body,n,r),{p:I}}return{v:a.v.toString().replace(new RegExp(N(n),s),r)}}};W=B([p(1,u.IUniverInstanceService),p(2,U.IRenderManagerService),p(3,u.ICommandService),p(4,u.IContextService),p(5,m.Inject(u.ThemeService)),p(6,m.Inject(k.SheetSkeletonManagerService)),p(7,m.Inject(M.SelectionManagerService))],W);function N(h){return h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}let T=class extends u.Disposable{constructor(e,t){super();_(this,"_findModelsByUnitId",new Map);this._univerInstanceService=e,this._injector=t}async find(e){this._terminate();const t=this._univerInstanceService.getCurrentUnitForType(u.UniverInstanceType.UNIVER_SHEET);if(t){const i=this._injector.createInstance(W,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}}};T=B([p(0,u.IUniverInstanceService),p(1,m.Inject(m.Injector))],T);const f={hit:!1,replaceable:!1,isFormula:!1,rawData:null};function se(h,e,t,i,n){const{findBy:r}=i,s=r===S.FindBy.FORMULA,o=h.getCellRaw(e,t);return f.rawData=o,!(o!=null&&o.f)?(f.isFormula=!1,H(n,i)?o?(f.hit=!0,f.replaceable=!0):(f.hit=!0,f.replaceable=!1):(f.hit=!1,f.replaceable=!1),f):(f.isFormula=!0,s?H({v:o.f},i)?(f.hit=!0,f.replaceable=!0,f):(f.hit=!1,f.replaceable=!1,f):(f.replaceable=!1,H(n,i)?f.hit=!0:f.hit=!1,f))}function H(h,e){let t=re(h);return t?e.matchesTheWholeCell?(t=oe(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 re(h){var t,i,n;const e=(n=(i=(t=h==null?void 0:h.p)==null?void 0:t.body)==null?void 0:i.dataStream)!=null?n:h==null?void 0:h.v;return typeof e=="number"?`${e}`:typeof e=="boolean"?e?"1":"0":e}function oe(h){return h.replace(/^ +/g,"").replace(/ +$/g,"")}var he=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,ae=(h,e,t,i)=>{for(var n=i>1?void 0:i?ce(e,t):e,r=h.length-1,s;r>=0;r--)(s=h[r])&&(n=(i?s(e,t,n):s(n))||n);return i&&n&&he(e,t,n),n},j=(h,e)=>(t,i)=>e(t,i,h);const le="UNIVER_SHEETS_FIND_REPLACE_PLUGIN";d.UniverSheetsFindReplacePlugin=(F=class extends u.Plugin{constructor(e,t,i){super(),this._injector=t,this._pluginService=i,this._pluginService.registerPlugin(S.UniverFindReplacePlugin)}onStarting(e){[[x]].forEach(t=>e.add(t))}},_(F,"pluginName",le),_(F,"type",u.UniverInstanceType.UNIVER_SHEET),F),d.UniverSheetsFindReplacePlugin=ae([j(1,m.Inject(m.Injector)),j(2,m.Inject(u.PluginService))],d.UniverSheetsFindReplacePlugin),d.enUS=Q,d.ruRU=Y,d.zhCN=X,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(d,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/find-replace"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/find-replace","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-ui","rxjs"],u):(d=typeof globalThis<"u"?globalThis:d||self,u(d.UniverSheetsFindReplace={},d.UniverCore,d["@wendellhu/redi"],d.UniverFindReplace,d.UniverEngineRender,d.UniverSheets,d.UniverSheetsUi,d.rxjs))})(this,function(d,u,m,S,U,M,k,w){"use strict";var Ce=Object.defineProperty;var we=(d,u,m)=>u in d?Ce(d,u,{enumerable:!0,configurable:!0,writable:!0,value:m}):d[u]=m;var _=(d,u,m)=>(we(d,typeof u!="symbol"?u+"":u,m),m);var F;const Q={"sheet-find-replace":{replace:{"partial-failure":"Failed to replace some cells",failure:"Failed to replace all cells"}}},X={"sheet-find-replace":{replace:{"partial-failure":"部分单元格替换失败",failure:"替换失败"}}},Y={"sheet-find-replace":{replace:{"partial-failure":"Не удалось заменить некоторые ячейки",failure:"Не удалось заменить все ячейки"}}};class z extends U.Shape{constructor(t,i){super(t,i);_(this,"_activated",!1);_(this,"_inHiddenRange",!1);_(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})`;U.Rect.drawWith(t,{width:this.width,height:this.height,fill:n,stroke:i?r:void 0,strokeWidth:i?2:0,evented:!1})}}const O={id:"sheet.command.replace",type:u.CommandType.COMMAND,handler:async(h,e)=>{const t=h.get(u.IUndoRedoService),i=h.get(u.ICommandService),{unitId:n,replacements:r}=e,s=t.__tempBatchingUndoRedo(n),o=await Promise.all(r.map(c=>i.executeCommand(M.SetRangeValuesCommand.id,{unitId:n,subUnitId:c.subUnitId,value:c.value})));return s.dispose(),G(o,r)}};function G(h,e){let t=0,i=0;return h.forEach((n,r)=>{const s=e[r].count;n?t+=s:i+=s}),{success:t,failure:i}}function E(h,e){return h.startRow===e.startRow&&h.startColumn===e.startColumn}function A(h,e){return h.startRow<e.startRow||h.startRow===e.startRow&&h.startColumn<=e.startColumn}function D(h,e){return h.startColumn<e.startColumn||h.startColumn===e.startColumn&&h.startRow<=e.startRow}function K(h,e){return h.startRow>e.startRow||h.startRow===e.startRow&&h.startColumn>=e.startColumn}function J(h,e){return h.startColumn>e.startColumn||h.startColumn===e.startColumn&&h.startRow>=e.startRow}function Z(h,e){const{range:t}=h,{startRow:i,startColumn:n}=t,r=e.getMergedCell(i,n);return r?u.Rectangle.equals(t,r):t.endRow===t.startRow&&t.endColumn===t.startColumn}var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,B=(h,e,t,i)=>{for(var n=i>1?void 0:i?te(e,t):e,r=h.length-1,s;r>=0;r--)(s=h[r])&&(n=(i?s(e,t,n):s(n))||n);return i&&n&&ee(e,t,n),n},p=(h,e)=>(t,i)=>e(t,i,h);let x=class extends u.Disposable{constructor(e,t,i,n,r){super();_(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(T);this._provider=e,this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(e)),this.disposeWithMe(this._contextService.subscribeContextValue$(u.EDITOR_ACTIVATED).pipe(w.filter(t=>!!t)).subscribe(()=>this._findReplaceController.closePanel()))}_initCommands(){[O].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};x=B([u.OnLifecycle(u.LifecycleStages.Steady,x),p(0,m.Inject(m.Injector)),p(1,m.Inject(S.FindReplaceController)),p(2,u.IContextService),p(3,S.IFindReplaceService),p(4,u.ICommandService)],x);const ie="sheets-find-replace-provider",ne=1e4;let W=class extends S.FindModel{constructor(e,t,i,n,r,s,o,c){super();_(this,"_matchesUpdate$",new w.Subject);_(this,"matchesUpdate$",this._matchesUpdate$.asObservable());_(this,"_activelyChangingMatch$",new w.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=t,this._renderManagerService=i,this._commandService=n,this._contextService=r,this._themeService=s,this._sheetSkeletonManagerService=o,this._selectionManagerService=c}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===S.FindBy.FORMULA?this._toggleDisplayRawFormula(!0):this._toggleDisplayRawFormula(!1),e.findScope){case S.FindScope.UNIT:this.findInWorkbook(e);break;case S.FindScope.SUBUNIT:default:this.findInActiveWorksheet(e);break}}_toggleDisplayRawFormula(e){this._contextService.setContextValue(U.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 c=this._findInWorksheet(o,e,t),l=o.getSheetId(),{results:a}=c;return a.length?this._matchesByWorksheet.set(l,c.results):this._matchesByWorksheet.delete(l),c});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(u.fromCallback(this._commandService.onCommandExecuted).pipe(w.filter(([s,o])=>s.id===M.SetWorksheetActiveOperation.id&&!(o!=null&&o.fromFindReplace))).subscribe(()=>{const s=this._workbook.getActiveSheet(),o=s.getSheetId();this._matchesByWorksheet.has(o)&&this._findNextMatchOnActiveSheetChange(s)})),this.disposeWithMe(u.fromCallback(this._commandService.onCommandExecuted).pipe(w.filter(([s])=>s.type===u.CommandType.MUTATION&&s.params.unitId===this._workbook.getUnitId()),w.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 g;const c=this._workbook.getActiveSheet(),l=this._selectionManagerService.getSelections();return(g=l==null?void 0:l.some(v=>!Z(v,c)))!=null?g:!1};let n,r=!0,s=!1;const o=()=>{const c=this._workbook.getActiveSheet(),l=this.currentMatch;s=i();const a=this._selectionManagerService.getSelections(),g=s?this._findInSelections(c,a,e,t):this._findInWorksheet(c,e,t);return this._matches=g.results,this._matchesPosition=this._tryRestoreLastMatchesPosition(l,this._matches),r?(n=g,r=!1):this._matchesUpdate$.next(this._matches),this._updateFindHighlight(),g};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>this._updateFindHighlight())),this.disposeWithMe(w.merge(u.fromCallback(this._commandService.onCommandExecuted).pipe(w.filter(([c])=>{if(c.type===u.CommandType.MUTATION&&c.params.unitId===this._workbook.getUnitId())return!0;if(c.id===M.SetSelectionsOperation.id&&c.params.unitId===t){const l=i();return l===!1&&s===!1?!1:(s=l,!0)}return!1})),this._workbook.activeSheet$.pipe(w.skip(1))).pipe(w.debounceTime(200)).subscribe(()=>o())),o(),n}_findInRange(e,t,i,n,r){const s=[],o=e.getSheetId(),c=(t.findDirection===S.FindDirection.COLUMN?e.iterateByColumn:e.iterateByRow).bind(e)(i);for(const l of c){const{row:a,col:g,colSpan:v,rowSpan:C,value:I}=l;if(r!=null&&r(a,g)||!I||e.getRowFiltered(a))continue;const{hit:R,replaceable:y,isFormula:b}=se(e,a,g,t,I);if(R){const P={provider:ie,unitId:n,replaceable:y,isFormula:b,range:{subUnitId:o,range:{startRow:a,startColumn:g,endColumn:g+(v!=null?v:1)-1,endRow:a+(C!=null?C:1)-1}}};s.push(P)}}return{results:s}}_findInSelections(e,t,i,n){const{findDirection:r}=i,s=r===S.FindDirection.ROW?A:D,o=new Set;return{results:t.map(l=>this._findInRange(e,i,l.range,n,(a,g)=>{const v=`${a}-${g}`;return o.has(v)?!0:(o.add(v),!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 C,I;this._disposeHighlights();const e=(C=this._sheetSkeletonManagerService.getCurrent())==null?void 0:C.skeleton;if(!e||!this._getSheetObject()||((I=this._univerInstanceService.getFocusedUnit())==null?void 0:I.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,c=this._themeService.getCurrentTheme().gold400,l=new u.ColorKit(c).toRgb(),a=this._workbook.getActiveSheet(),g=a.getSheetId(),v=o.filter(R=>R.range.subUnitId===g).map((R,y)=>{const{startColumn:b,startRow:P,endColumn:ue,endRow:de}=R.range.range,ge=k.getCoordByCell(P,b,s,e),fe=k.getCoordByCell(de,ue,s,e),{startX:$,startY:L}=ge,{endX:_e,endY:Se}=fe,V=!a.getRowRawVisible(P),q=!a.getColVisible(b),me=V||q,ve=q?2:_e-$,pe=V?2:Se-L,Ie={left:$,top:L,color:l,width:ve,height:pe,evented:!1,inHiddenRange:me};return new z(`find-highlight-${y}`,Ie)});s.addObjects(v,ne),this._highlightShapes=v,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(M.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:c,startRow:l}=o.range.range;return c===n&&l===r});return s>-1?s+1:0}moveToNextMatch(e){var s,o,c;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=(c=e==null?void 0:e.noFocus)!=null?c:!1,r=this._findNextMatch(t,i);if(r){const[l,a]=r;return this._matchesPosition=a+1,this._query.findScope===S.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(l.range.subUnitId).findIndex(g=>g===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,c;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=(c=e==null?void 0:e.noFocus)!=null?c:!1,r=this._findPreviousMatch(t,i);if(r){const[l,a]=r;return this._matchesPosition=a+1,this._query.findScope===S.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(l.range.subUnitId).findIndex(g=>g===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 c=this._matches.length,l=(o+c)%c;return[this._matches[l],l]}const i=this._selectionManagerService.getSelections();if(!(i!=null&&i.length))return[this._matches[0],0];if(this._query.findScope!==S.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,c=this._matches.length;if(!e&&o>=c)return null;const l=o%c;return[this._matches[l],l]}const i=this._selectionManagerService.getSelections();if(!(i!=null&&i.length))return[this._matches[0],0];if(this._query.findScope!==S.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?u.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?u.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===S.FindDirection.ROW;let r=e.findIndex(o=>{const c=o.range.range;if(!(n?A(t,c):D(t,c)))return!1;const a=E(t,c);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===S.FindDirection.ROW;let r=this._matches.findLastIndex(o=>{const c=o.range.range;if(!(n?K(t,c):J(t,c)))return!1;const a=E(t,c);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===S.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(M.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===S.FindBy.FORMULA,o=n?"g":"ig",c=[];return u.groupBy(this._matches.filter(a=>a.replaceable),a=>a.range.subUnitId).forEach((a,g)=>{const v=new u.ObjectMatrix,C=this._workbook.getSheetBySheetId(g);a.forEach(I=>{const{startColumn:R,startRow:y}=I.range.range,b=this._getReplacedCellData(I,C,s,i,e,o);b&&v.setValue(y,R,b)}),c.push({count:a.length,subUnitId:g,value:v.getMatrix()})}),c?this._commandService.executeCommand(O.id,{unitId:t,replacements:c}):{success:0,failure:0}}_getReplacedCellData(e,t,i,n,r,s){var C;const o=e.range.range,{startRow:c,startColumn:l}=o,a=t.getCellRaw(c,l);if(e.isFormula)return i?{f:a.f.replace(new RegExp(j(n),s),r),v:null}:null;if(!!((C=a.p)!=null&&C.body)){const I=u.Tools.deepClone(a.p);return u.replaceInDocumentBody(I.body,n,r),{p:I}}return{v:a.v.toString().replace(new RegExp(j(n),s),r)}}};W=B([p(1,u.IUniverInstanceService),p(2,U.IRenderManagerService),p(3,u.ICommandService),p(4,u.IContextService),p(5,m.Inject(u.ThemeService)),p(6,m.Inject(k.SheetSkeletonManagerService)),p(7,m.Inject(M.SelectionManagerService))],W);function j(h){return h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}let T=class extends u.Disposable{constructor(e,t){super();_(this,"_findModelsByUnitId",new Map);this._univerInstanceService=e,this._injector=t}async find(e){this._terminate();const t=this._univerInstanceService.getCurrentUnitForType(u.UniverInstanceType.UNIVER_SHEET);if(t){const i=this._injector.createInstance(W,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}}};T=B([p(0,u.IUniverInstanceService),p(1,m.Inject(m.Injector))],T);const f={hit:!1,replaceable:!1,isFormula:!1,rawData:null};function se(h,e,t,i,n){const{findBy:r}=i,s=r===S.FindBy.FORMULA,o=h.getCellRaw(e,t);return f.rawData=o,!(o!=null&&o.f)?(f.isFormula=!1,H(n,i)?o?(f.hit=!0,f.replaceable=!0):(f.hit=!0,f.replaceable=!1):(f.hit=!1,f.replaceable=!1),f):(f.isFormula=!0,s?H({v:o.f},i)?(f.hit=!0,f.replaceable=!0,f):(f.hit=!1,f.replaceable=!1,f):(f.replaceable=!1,H(n,i)?f.hit=!0:f.hit=!1,f))}function H(h,e){let t=re(h);return t?e.matchesTheWholeCell?(t=oe(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 re(h){var t,i,n;const e=(n=(i=(t=h==null?void 0:h.p)==null?void 0:t.body)==null?void 0:i.dataStream)!=null?n:h==null?void 0:h.v;return typeof e=="number"?`${e}`:typeof e=="boolean"?e?"1":"0":e}function oe(h){return h.replace(/^ +/g,"").replace(/ +$/g,"")}var he=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,ae=(h,e,t,i)=>{for(var n=i>1?void 0:i?ce(e,t):e,r=h.length-1,s;r>=0;r--)(s=h[r])&&(n=(i?s(e,t,n):s(n))||n);return i&&n&&he(e,t,n),n},N=(h,e)=>(t,i)=>e(t,i,h);const le="SHEET_FIND_REPLACE_PLUGIN";d.UniverSheetsFindReplacePlugin=(F=class extends u.Plugin{constructor(e,t,i){super(),this._injector=t,this._pluginService=i,this._pluginService.registerPlugin(S.UniverFindReplacePlugin)}onStarting(e){[[x]].forEach(t=>e.add(t))}},_(F,"pluginName",le),_(F,"type",u.UniverInstanceType.UNIVER_SHEET),F),d.UniverSheetsFindReplacePlugin=ae([N(1,m.Inject(m.Injector)),N(2,m.Inject(u.PluginService))],d.UniverSheetsFindReplacePlugin),d.enUS=Q,d.ruRU=Y,d.zhCN=X,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-find-replace",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "UniverSheet find replace plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -50,27 +50,27 @@
|
|
|
50
50
|
"npm": ">=8.0.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@wendellhu/redi": "
|
|
53
|
+
"@wendellhu/redi": "0.15.2",
|
|
54
54
|
"rxjs": ">=7.0.0",
|
|
55
|
-
"@univerjs/core": "0.1.
|
|
56
|
-
"@univerjs/engine-render": "0.1.
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/sheets
|
|
55
|
+
"@univerjs/core": "0.1.12",
|
|
56
|
+
"@univerjs/engine-render": "0.1.12",
|
|
57
|
+
"@univerjs/sheets-ui": "0.1.12",
|
|
58
|
+
"@univerjs/find-replace": "0.1.12",
|
|
59
|
+
"@univerjs/sheets": "0.1.12"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@wendellhu/redi": "
|
|
62
|
+
"@wendellhu/redi": "0.15.2",
|
|
63
63
|
"rxjs": "^7.8.1",
|
|
64
64
|
"typescript": "^5.4.5",
|
|
65
65
|
"vite": "^5.2.11",
|
|
66
66
|
"vitest": "^1.6.0",
|
|
67
|
-
"@univerjs/
|
|
68
|
-
"@univerjs/
|
|
69
|
-
"@univerjs/
|
|
70
|
-
"@univerjs/
|
|
71
|
-
"@univerjs/sheets": "0.1.
|
|
72
|
-
"@univerjs/
|
|
73
|
-
"@univerjs/
|
|
67
|
+
"@univerjs/core": "0.1.12",
|
|
68
|
+
"@univerjs/engine-formula": "0.1.12",
|
|
69
|
+
"@univerjs/engine-render": "0.1.12",
|
|
70
|
+
"@univerjs/shared": "0.1.12",
|
|
71
|
+
"@univerjs/sheets": "0.1.12",
|
|
72
|
+
"@univerjs/sheets-ui": "0.1.12",
|
|
73
|
+
"@univerjs/find-replace": "0.1.12"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"test": "vitest run",
|