@univerjs/sheets-find-replace 0.17.0 → 0.18.0
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/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/locale/ca-ES.js +1 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/es-ES.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ja-JP.js +1 -1
- package/lib/cjs/locale/ko-KR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/sk-SK.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/facade.js +1 -101
- package/lib/es/index.js +1 -633
- package/lib/es/locale/ca-ES.js +1 -11
- package/lib/es/locale/en-US.js +1 -11
- package/lib/es/locale/es-ES.js +1 -11
- package/lib/es/locale/fa-IR.js +1 -11
- package/lib/es/locale/fr-FR.js +1 -11
- package/lib/es/locale/ja-JP.js +1 -11
- package/lib/es/locale/ko-KR.js +1 -11
- package/lib/es/locale/ru-RU.js +1 -11
- package/lib/es/locale/sk-SK.js +1 -11
- package/lib/es/locale/vi-VN.js +1 -11
- package/lib/es/locale/zh-CN.js +1 -11
- package/lib/es/locale/zh-TW.js +1 -11
- package/lib/facade.js +1 -101
- package/lib/index.js +1 -633
- package/lib/locale/ca-ES.js +1 -11
- package/lib/locale/en-US.js +1 -11
- package/lib/locale/es-ES.js +1 -11
- package/lib/locale/fa-IR.js +1 -11
- package/lib/locale/fr-FR.js +1 -11
- package/lib/locale/ja-JP.js +1 -11
- package/lib/locale/ko-KR.js +1 -11
- package/lib/locale/ru-RU.js +1 -11
- package/lib/locale/sk-SK.js +1 -11
- package/lib/locale/vi-VN.js +1 -11
- package/lib/locale/zh-CN.js +1 -11
- package/lib/locale/zh-TW.js +1 -11
- package/lib/types/commands/commands/sheet-replace.command.d.ts +17 -2
- package/lib/types/controllers/sheet-find-replace.controller.d.ts +21 -4
- package/lib/types/controllers/utils.d.ts +17 -2
- package/lib/types/facade/f-text-finder.d.ts +19 -2
- package/lib/types/facade/f-univer.d.ts +15 -0
- package/lib/types/locale/ca-ES.d.ts +16 -1
- package/lib/types/locale/es-ES.d.ts +16 -1
- package/lib/types/locale/fa-IR.d.ts +16 -1
- package/lib/types/locale/fr-FR.d.ts +16 -1
- package/lib/types/locale/ja-JP.d.ts +16 -1
- package/lib/types/locale/ko-KR.d.ts +16 -1
- package/lib/types/locale/ru-RU.d.ts +16 -1
- package/lib/types/locale/sk-SK.d.ts +16 -1
- package/lib/types/locale/vi-VN.d.ts +16 -1
- package/lib/types/locale/zh-TW.d.ts +16 -1
- package/lib/types/plugin.d.ts +16 -1
- package/lib/types/views/shapes/find-replace-highlight.shape.d.ts +18 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +11 -10
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"
|
|
1
|
+
let e=require(`@univerjs/core`),t=require(`@univerjs/find-replace`),n=require(`@univerjs/sheets/facade`),r=require(`@univerjs/core/facade`);function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){return function(n,r){t(n,r,e)}}function l(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let u=class extends e.Disposable{constructor(e,n,r,i){super(),this._injector=n,this._univerInstanceService=r,this._findReplaceService=i,s(this,`_state`,new t.FindReplaceState),s(this,`_model`,void 0),s(this,`_complete`,void 0);let a=this._findReplaceService.getProviders();this._model=this._injector.createInstance(t.FindReplaceModel,this._state,a);let o={...(0,t.createInitFindReplaceState)(),...e};this._state.changeState(o)}findAll(){return!this._state.findCompleted||!this._complete?[]:this._complete.results.map(e=>this._findMatchToFRange(e))}findNext(){var e;if(!this._state.findCompleted||!this._complete)return null;let t=(e=this._model)==null?void 0:e.moveToNextMatch();return t?this._findMatchToFRange(t):null}findPrevious(){var e;let t=(e=this._model)==null?void 0:e.moveToPreviousMatch();return t?this._findMatchToFRange(t):null}getCurrentMatch(){var e;if(!this._state.findCompleted||!this._complete)throw Error(`Find operation is not completed.`);let t=(e=this._model)==null?void 0:e.currentMatch$.value;return t?this._findMatchToFRange(t):null}async matchCaseAsync(e){return this._state.changeState({caseSensitive:e,findCompleted:!1}),new Promise(e=>{let t=this._state.stateUpdates$.subscribe(async n=>{n.findCompleted===!0&&(t.unsubscribe(),await this.ensureCompleteAsync(),e(this))})})}async matchEntireCellAsync(e){return this._state.changeState({matchesTheWholeCell:e,findCompleted:!1}),new Promise(e=>{let t=this._state.stateUpdates$.subscribe(async n=>{n.findCompleted===!0&&(t.unsubscribe(),await this.ensureCompleteAsync(),e(this))})})}async matchFormulaTextAsync(e){return this._state.changeState({findBy:e?t.FindBy.FORMULA:t.FindBy.VALUE,findCompleted:!1}),new Promise(e=>{let t=this._state.stateUpdates$.subscribe(async n=>{n.findCompleted===!0&&(t.unsubscribe(),await this.ensureCompleteAsync(),e(this))})})}async replaceAllWithAsync(e){var t,n,r;await this._state.changeState({replaceRevealed:!0,replaceString:e});let i=(t=(n=await((r=this._model)==null?void 0:r.replaceAll()))==null?void 0:n.success)==null?0:t;return this._state.changeState({replaceRevealed:!1}),i}async replaceWithAsync(e){var t;return await this._state.changeState({replaceRevealed:!0,replaceString:e}),await((t=this._model)==null?void 0:t.replace()),this._state.changeState({replaceRevealed:!1}),!0}async ensureCompleteAsync(){var e;this._complete=await((e=this._model)==null?void 0:e.start())}_findMatchToFRange(e){let{unitId:t}=e,{subUnitId:r,range:i}=e.range,a=this._univerInstanceService.getUnit(t),o=a.getSheetBySheetId(r);return this._injector.createInstance(n.FRange,a,o,i)}};u=l([c(1,(0,e.Inject)(e.Injector)),c(2,e.IUniverInstanceService),c(3,t.IFindReplaceService)],u);var d=class extends r.FUniver{async createTextFinderAsync(e){let t={findString:e},n=this._injector.createInstance(u,t);return await n.ensureCompleteAsync(),n}};r.FUniver.extend(d);
|
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Z=Object.defineProperty;var ee=(c,e,t)=>e in c?Z(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t;var _=(c,e,t)=>ee(c,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@univerjs/core"),C=require("@univerjs/sheets"),y=require("@univerjs/engine-render"),S=require("@univerjs/find-replace"),M=require("@univerjs/sheets-ui"),I=require("rxjs"),T={id:"sheet.command.replace",type:l.CommandType.COMMAND,handler:async(c,e)=>{const t=c.get(l.IUndoRedoService),n=c.get(l.ICommandService),{unitId:i,replacements:r}=e,s=t.__tempBatchingUndoRedo(i),o=await Promise.all(r.map(h=>n.executeCommand(C.SetRangeValuesCommand.id,{unitId:i,subUnitId:h.subUnitId,value:h.value})));return s.dispose(),te(o,r)}};function te(c,e){let t=0,n=0;return c.forEach((i,r)=>{const s=e[r].count;i?t+=s:n+=s}),{success:t,failure:n}}class ne extends y.Shape{constructor(t,n){super(t,n);_(this,"_activated",!1);_(this,"_inHiddenRange",!1);_(this,"_color");n&&this.setShapeProps(n)}setShapeProps(t){this._activated=!!t.activated,typeof t.inHiddenRange<"u"&&(this._inHiddenRange=t.inHiddenRange),typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){const n=this._activated,i=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, 0.35)`,r=`rgb(${this._color.r}, ${this._color.g}, ${this._color.b})`;y.Rect.drawWith(t,{width:this.width,height:this.height,fill:i,stroke:n?r:void 0,strokeWidth:n?2:0,evented:!1})}}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 $(c,e){return c.startColumn<e.startColumn||c.startColumn===e.startColumn&&c.startRow<=e.startRow}function ie(c,e){return c.startRow>e.startRow||c.startRow===e.startRow&&c.startColumn>=e.startColumn}function se(c,e){return c.startColumn>e.startColumn||c.startColumn===e.startColumn&&c.startRow>=e.startRow}function re(c,e){const{range:t}=c,{startRow:n,startColumn:i}=t,r=e.getMergedCell(n,i);return r?l.Rectangle.equals(t,r):t.endRow===t.startRow&&t.endColumn===t.startColumn}var oe=Object.getOwnPropertyDescriptor,O=(c,e,t,n)=>{for(var i=n>1?void 0:n?oe(e,t):e,r=c.length-1,s;r>=0;r--)(s=c[r])&&(i=s(i)||i);return i},v=(c,e)=>(t,n)=>e(t,n,c);exports.SheetsFindReplaceController=class extends l.Disposable{constructor(t,n,i,r,s){super();_(this,"_provider");this._injector=t,this._findReplaceController=n,this._contextService=i,this._findReplaceService=r,this._commandService=s,this._init(),this._initCommands()}dispose(){super.dispose(),this._findReplaceController.closePanel(),this._provider.dispose()}_init(){const t=this._injector.createInstance(H);this._provider=t,this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(t)),this.disposeWithMe(this._contextService.subscribeContextValue$(l.EDITOR_ACTIVATED).pipe(I.filter(n=>!!n)).subscribe(()=>this._findReplaceController.closePanel()))}_initCommands(){[T].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t)))}};exports.SheetsFindReplaceController=O([v(0,l.Inject(l.Injector)),v(1,l.Inject(S.FindReplaceController)),v(2,l.IContextService),v(3,S.IFindReplaceService),v(4,l.ICommandService)],exports.SheetsFindReplaceController);const ce="sheets-find-replace-provider",he=1e4;let W=class extends S.FindModel{constructor(e,t,n,i,r,s,o,h){super();_(this,"_matchesUpdate$",new I.Subject);_(this,"matchesUpdate$",this._matchesUpdate$.asObservable());_(this,"_activelyChangingMatch$",new I.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,"_workbookSelections");this._workbook=e,this._sheetSkeletonManagerService=t,this._univerInstanceService=n,this._renderManagerService=i,this._commandService=r,this._contextService=s,this._themeService=o,this._workbookSelections=h.getWorkbookSelections(this.unitId)}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}}focusSelection(){const e=this.currentMatch;e&&this._commandService.executeCommand(C.SelectRangeCommand.id,{unitId:e.unitId,subUnit:e.range.subUnitId,range:e.range.range})}_toggleDisplayRawFormula(e){this._contextService.setContextValue(y.RENDER_RAW_FORMULA_KEY,e)}findInWorkbook(e){const t=this._workbook.getUnitId();let n,i=!0;const r=()=>{const s=this._workbook.getSheets().filter(o=>!o.isSheetHidden()).map(o=>{const h=this._findInWorksheet(o,e,t),d=o.getSheetId(),{results:a}=h;return a.length?this._matchesByWorksheet.set(d,h.results):this._matchesByWorksheet.delete(d),h});this._matches=s.map(o=>o.results).flat(),this._updateFindHighlight(),i?(n={results:this._matches},i=!1):this._matchesUpdate$.next(this._matches)};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._updateFindHighlight(),this._updateCurrentHighlightShape(this._activeHighlightIndex)})),this.disposeWithMe(l.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(I.filter(([s,o])=>s.id===C.SetWorksheetActiveOperation.id&&!(o!=null&&o.fromFindReplace))).subscribe(()=>{const s=this._workbook.getActiveSheet();if(!s)return;const o=s.getSheetId();this._matchesByWorksheet.has(o)&&this._findNextMatchOnActiveSheetChange(s)})),this.disposeWithMe(l.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(I.filter(([s])=>s.type===l.CommandType.MUTATION&&s.params.unitId===this._workbook.getUnitId()),I.throttleTime(600,void 0,{leading:!1,trailing:!0})).subscribe(()=>r())),r(),n}_findNextMatchOnActiveSheetChange(e){let t,n,i=0;const r=this._matchesByWorksheet.get(e.getSheetId()),s=this._workbookSelections.getCurrentSelections();s!=null&&s.length?([t,i]=this._findNextMatchByRange(r,s[0].range),n=r.findIndex(o=>o===t)):(t=r[0],n=0,i=this._matches.findIndex(o=>o===t)),this._matchesPosition=i+1,this._activelyChangingMatch$.next(t),this._activeHighlightIndex=n,this._updateFindHighlight(),this._updateCurrentHighlightShape(n)}findInActiveWorksheet(e){const t=this._workbook.getUnitId(),n=()=>{var u;const h=this._workbook.getActiveSheet();if(!h)return!1;const d=this._workbookSelections.getCurrentSelections();return(u=d==null?void 0:d.some(g=>!re(g,h)))!=null?u:!1};let i,r=!0,s=!1;const o=()=>{const h=this._workbook.getActiveSheet();if(!h)return{results:[]};const d=this.currentMatch;s=n();const a=this._workbookSelections.getCurrentSelections(),u=s?this._findInSelections(h,a,e,t):this._findInWorksheet(h,e,t);return this._matches=u.results,this._matchesPosition=this._tryRestoreLastMatchesPosition(d,this._matches),r?(i=u,r=!1):this._matchesUpdate$.next(this._matches),this._updateFindHighlight(),u};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>this._updateFindHighlight())),this.disposeWithMe(I.merge(l.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(I.filter(([h])=>{if(h.type===l.CommandType.MUTATION&&h.params.unitId===this._workbook.getUnitId())return!0;if(h.id===C.SetSelectionsOperation.id&&h.params.unitId===t){const d=n();return d===!1&&s===!1?!1:(s=d,!0)}return!1})),this._workbook.activeSheet$.pipe(I.skip(1))).pipe(I.debounceTime(200)).subscribe(()=>o())),o(),i}_findInRange(e,t,n,i,r){const s=[],o=e.getSheetId(),h=(t.findDirection===S.FindDirection.COLUMN?e.iterateByColumn:e.iterateByRow).bind(e)(n);for(const d of h){const{row:a,col:u,colSpan:g,rowSpan:m,value:p}=d;if(r!=null&&r(a,u)||!p||e.getRowFiltered(a))continue;const{hit:k,replaceable:w,isFormula:R}=ae(e,a,u,t,p);if(k){const F={provider:ce,unitId:i,replaceable:w,isFormula:R,range:{subUnitId:o,range:{startRow:a,startColumn:u,endColumn:u+(g!=null?g:1)-1,endRow:a+(m!=null?m:1)-1}}};s.push(F)}}return{results:s}}_findInSelections(e,t,n,i){const{findDirection:r}=n,s=r===S.FindDirection.ROW?N:$,o=new Set;return{results:t.map(d=>this._findInRange(e,n,d.range,i,(a,u)=>{const g=`${a}-${u}`;return o.has(g)?!0:(o.add(g),!1)}).results).flat().sort((d,a)=>s(d.range.range,a.range.range)?-1:1)}}_findInWorksheet(e,t,n){const i=e.getRowCount(),r=e.getColumnCount(),s={startRow:0,startColumn:0,endRow:i-1,endColumn:r-1};return this._findInRange(e,t,s,n)}_disposeHighlights(){var e;this._highlightShapes.forEach(t=>{var n;(n=t.getScene())==null||n.makeDirty(),t.dispose()}),this._highlightShapes=[],(e=this._currentHighlightShape)==null||e.dispose(),this._currentHighlightShape=null}_updateFindHighlight(){var u;this._disposeHighlights();const e=(u=this._sheetSkeletonManagerService.getCurrent())==null?void 0:u.skeleton;if(!e)return;const t=this._workbook.getUnitId(),n=this._renderManagerService.getRenderById(t);if(n==null)return;const{scene:i}=n,r=this._matches,s=this._themeService.getColorFromTheme("yellow.400"),o=new l.ColorKit(s).toRgb(),h=this._workbook.getActiveSheet();if(!h)return;const d=h.getSheetId(),a=r.filter(g=>g.range.subUnitId===d).map((g,m)=>{const{startColumn:p,startRow:k,endColumn:w,endRow:R}=g.range.range,F=M.getCoordByCell(k,p,i,e),Y=M.getCoordByCell(R,w,i,e),{startX:E,startY:A}=F,{endX:q,endY:K}=Y;let U=!0;for(let b=k;b<=R;b++)if(h.getRowRawVisible(b)){U=!1;break}let P=!0;for(let b=p;b<=w;b++)if(h.getColVisible(b)){P=!1;break}const Q=U||P,X=P?2:q-E,z=U?2:K-A,J={left:E,top:A,color:o,width:X,height:z,evented:!1,inHiddenRange:Q,zIndex:he};return new ne(`find-highlight-${m}`,J)});i.addObjects(a),this._highlightShapes=a,i.makeDirty()}_updateCurrentHighlightShape(e){var t;if((t=this._currentHighlightShape)==null||t.setShapeProps({activated:!1}),this._currentHighlightShape=null,e!==void 0){const n=this._highlightShapes[e];if(!n)return;this._currentHighlightShape=n,n.setShapeProps({activated:!0})}}_getSheetObject(){return M.getSheetObject(this._univerInstanceService,this._renderManagerService)}_focusMatch(e){var n;const t=e.range.subUnitId;t!==((n=this._workbook.getActiveSheet())==null?void 0:n.getSheetId())&&this._commandService.executeCommand(C.SetWorksheetActivateCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:t},{fromFindReplace:!0}),this._commandService.executeCommand(M.ScrollToCellCommand.id,{range:e.range.range},{fromFindReplace:!0})}_tryRestoreLastMatchesPosition(e,t){if(!e)return 0;const{subUnitId:n}=e.range,{startColumn:i,startRow:r}=e.range.range,s=t.findIndex(o=>{if(n!==o.range.subUnitId)return!1;const{startColumn:h,startRow:d}=o.range.range;return h===i&&d===r});return s>-1?s+1:0}moveToNextMatch(e){var o,h,d,a,u;if(!this._matches.length)return null;const t=(o=e==null?void 0:e.loop)!=null?o:!1,n=(h=e==null?void 0:e.stayIfOnMatch)!=null?h:!1,i=(d=e==null?void 0:e.noFocus)!=null?d:!1,r=(a=e==null?void 0:e.ignoreSelection)!=null?a:!1,s=this._findNextMatch(t,n,r);if(s){const[g,m]=s;return this._matchesPosition=m+1,this._query.findScope===S.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(g.range.subUnitId).findIndex(p=>p===g):this._activeHighlightIndex=m,i||this._focusMatch(g),((u=this._workbook.getActiveSheet())==null?void 0:u.getSheetId())===g.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),g}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}moveToPreviousMatch(e){var o,h,d,a,u;if(!this._matches.length)return null;const t=(o=e==null?void 0:e.loop)!=null?o:!1,n=(h=e==null?void 0:e.stayIfOnMatch)!=null?h:!1,i=(d=e==null?void 0:e.noFocus)!=null?d:!1,r=(a=e==null?void 0:e.ignoreSelection)!=null?a:!1,s=this._findPreviousMatch(t,n,r);if(s){const[g,m]=s;return this._matchesPosition=m+1,this._query.findScope===S.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(g.range.subUnitId).findIndex(p=>p===g):this._activeHighlightIndex=m,i||this._focusMatch(g),((u=this._workbook.getActiveSheet())==null?void 0:u.getSheetId())===g.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),g}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}_findPreviousMatch(e=!1,t=!1,n=!1){var o;if(this.currentMatch){const h=this._matches.findIndex(g=>g===this.currentMatch);if(t)return[this.currentMatch,h];const d=h-1;if(!e&&d<0)return null;const a=this._matches.length,u=(d+a)%a;return[this._matches[u],u]}const i=this._workbookSelections.getCurrentLastSelection();if(n||!i){const h=this._matches.length-1;return[this._matches[h],h]}if(this._query.findScope!==S.FindScope.UNIT)return this._findPreviousMatchByRange(this._matches,i.range);const r=(o=this._workbook.getActiveSheet())==null?void 0:o.getSheetId();if(!r)return null;const s=this._findPreviousWorksheetThatHasAMatch(r,e);return s?this._findPreviousMatchByRange(this._matchesByWorksheet.get(s),i.range):null}_findNextMatch(e=!1,t=!1,n=!1){var o;if(this.currentMatch){const h=this._matches.findIndex(g=>g===this.currentMatch);if(t)return[this.currentMatch,h];const d=h+1,a=this._matches.length;if(!e&&d>=a)return null;const u=d%a;return[this._matches[u],u]}const i=this._workbookSelections.getCurrentLastSelection();if(n||!i)return[this._matches[0],0];if(this._query.findScope!==S.FindScope.UNIT)return this._findNextMatchByRange(this._matches,i.range,t);const r=(o=this._workbook.getActiveSheet())==null?void 0:o.getSheetId();if(!r)return null;const s=this._findNextWorksheetThatHasAMatch(r,e);return s?this._findNextMatchByRange(this._matchesByWorksheet.get(s),i.range):null}_findPreviousWorksheetThatHasAMatch(e,t=!1){const n=this._workbook.getSheetOrders(),i=n.findIndex(o=>o===e),s=(t?l.rotate(n,i+1):n.slice(0,i+1)).findLast(o=>this._matchesByWorksheet.has(o));return s!=null?s:null}_findNextWorksheetThatHasAMatch(e,t=!1){const n=this._workbook.getSheetOrders(),i=n.findIndex(o=>o===e),s=(t?l.rotate(n,i):n.slice(i)).find(o=>this._matchesByWorksheet.has(o));return s!=null?s:null}_findNextMatchByRange(e,t,n=!1){const i=this._query.findDirection===S.FindDirection.ROW;let r=e.findIndex(o=>{const h=o.range.range;if(!(i?N(t,h):$(t,h)))return!1;const a=D(t,h);return n?a:!a});r===-1&&(r=e.length-1);const s=e[r];return[s,this._matches.findIndex(o=>o===s)]}_findPreviousMatchByRange(e,t,n=!1){const i=this._query.findDirection===S.FindDirection.ROW;let r=this._matches.findLastIndex(o=>{const h=o.range.range;if(!(i?ie(t,h):se(t,h)))return!1;const a=D(t,h);return n?a:!a});r===-1&&(r=0);const s=e[r];return[s,this._matches.findIndex(o=>o===s)]}async replace(e){if(this._matchesCount===0||!this.currentMatch||!this._query||!this.currentMatch.replaceable)return!1;const t=this.currentMatch.range,n=this._workbook.getSheetBySheetId(this.currentMatch.range.subUnitId),i=this._getReplacedCellData(this.currentMatch,n,this._query.findBy===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]:i}}};return this._commandService.executeCommand(C.SetRangeValuesCommand.id,r)}async replaceAll(e){if(this._matchesCount===0||!this._query)return{success:0,failure:0};const t=this._workbook.getUnitId(),{findString:n,caseSensitive:i,findBy:r}=this._query,s=r===S.FindBy.FORMULA,o=i?"g":"ig",h=[];return l.groupBy(this._matches.filter(a=>a.replaceable),a=>a.range.subUnitId).forEach((a,u)=>{const g=new l.ObjectMatrix,m=this._workbook.getSheetBySheetId(u);a.forEach(p=>{const{startColumn:k,startRow:w}=p.range.range,R=this._getReplacedCellData(p,m,s,n,e,o);R&&g.setValue(w,k,R)}),h.push({count:a.length,subUnitId:u,value:g.getMatrix()})}),h?this._commandService.executeCommand(T.id,{unitId:t,replacements:h}):{success:0,failure:0}}_getReplacedCellData(e,t,n,i,r,s){var m;const o=e.range.range,{startRow:h,startColumn:d}=o,a=t.getCellRaw(h,d);if(e.isFormula)return n?{f:a.f.replace(new RegExp(j(i),s),r),v:null}:null;if(!!((m=a.p)!=null&&m.body)){const p=l.Tools.deepClone(a.p);return l.replaceInDocumentBody(p.body,i,r,this._query.caseSensitive),{p}}return{v:a.v.toString().replace(new RegExp(j(i),s),r)}}};W=O([v(2,l.IUniverInstanceService),v(3,y.IRenderManagerService),v(4,l.ICommandService),v(5,l.IContextService),v(6,l.Inject(l.ThemeService)),v(7,l.Inject(C.SheetsSelectionsService))],W);function j(c){return c.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}let H=class extends l.Disposable{constructor(e,t,n){super();_(this,"_findModelsByUnitId",new Map);this._univerInstanceService=e,this._renderManagerService=t,this._injector=n}async find(e){this._terminate();const t=this._univerInstanceService.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET);if(!t)return[];const n=this._preprocessQuery(e),i=this._renderManagerService.getRenderById(t.getUnitId()).with(M.SheetSkeletonManagerService),r=this._injector.createInstance(W,t,i);return this._findModelsByUnitId.set(t.getUnitId(),r),r.start(n),[r]}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}}};H=O([v(0,l.IUniverInstanceService),v(1,y.IRenderManagerService),v(2,l.Inject(l.Injector))],H);const f={hit:!1,replaceable:!1,isFormula:!1,rawData:null};function ae(c,e,t,n,i){const{findBy:r}=n,s=r===S.FindBy.FORMULA,o=c.getCellRaw(e,t);return f.rawData=o,!(o!=null&&o.f)?(f.isFormula=!1,B(i,n)?o?(f.hit=!0,f.replaceable=!0):(f.hit=!0,f.replaceable=!1):(f.hit=!1,f.replaceable=!1),f):(f.isFormula=!0,s?B({v:o.f},n)?(f.hit=!0,f.replaceable=!0,f):(f.hit=!1,f.replaceable=!1,f):(f.replaceable=!1,B(i,n)?f.hit=!0:f.hit=!1,f))}function B(c,e){let t=le(c);return t?e.matchesTheWholeCell?(t=de(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 le(c){var t,n,i;const e=(i=(n=(t=c==null?void 0:c.p)==null?void 0:t.body)==null?void 0:n.dataStream)!=null?i:c==null?void 0:c.v;return typeof e=="number"?`${e}`:typeof e=="boolean"?e?"1":"0":e}function de(c){return c.replace(/^ +/g,"").replace(/ +$/g,"")}const ue="@univerjs/sheets-find-replace",ge="0.17.0",G={name:ue,version:ge},fe="sheets-find-replace.config",L={};var _e=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,me=(c,e,t)=>e in c?_e(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,pe=(c,e,t,n)=>{for(var i=n>1?void 0:n?Se(e,t):e,r=c.length-1,s;r>=0;r--)(s=c[r])&&(i=s(i)||i);return i},V=(c,e)=>(t,n)=>e(t,n,c),x=(c,e,t)=>me(c,typeof e!="symbol"?e+"":e,t);exports.UniverSheetsFindReplacePlugin=class extends l.Plugin{constructor(e=L,t,n){super(),this._config=e,this._injector=t,this._configService=n;const{...i}=l.merge({},L,this._config);this._configService.setConfig(fe,i)}onStarting(){[[exports.SheetsFindReplaceController]].forEach(e=>this._injector.add(e))}onSteady(){this._injector.get(exports.SheetsFindReplaceController)}};x(exports.UniverSheetsFindReplacePlugin,"pluginName","SHEET_FIND_REPLACE_PLUGIN");x(exports.UniverSheetsFindReplacePlugin,"packageName",G.name);x(exports.UniverSheetsFindReplacePlugin,"version",G.version);x(exports.UniverSheetsFindReplacePlugin,"type",l.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsFindReplacePlugin=pe([l.DependentOn(C.UniverSheetsPlugin,C.UniverSheetsPlugin,S.UniverFindReplacePlugin),V(1,l.Inject(l.Injector)),V(2,l.IConfigService)],exports.UniverSheetsFindReplacePlugin);exports.SheetReplaceCommand=T;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@univerjs/core`),t=require(`@univerjs/sheets`),n=require(`@univerjs/engine-render`),r=require(`@univerjs/find-replace`),i=require(`@univerjs/sheets-ui`),a=require(`rxjs`);const o={id:`sheet.command.replace`,type:e.CommandType.COMMAND,handler:async(n,r)=>{let i=n.get(e.IUndoRedoService),a=n.get(e.ICommandService),{unitId:o,replacements:c}=r,l=i.__tempBatchingUndoRedo(o),u=await Promise.all(c.map(e=>a.executeCommand(t.SetRangeValuesCommand.id,{unitId:o,subUnitId:e.subUnitId,value:e.value})));return l.dispose(),s(u,c)}};function s(e,t){let n=0,r=0;return e.forEach((e,i)=>{let a=t[i].count;e?n+=a:r+=a}),{success:n,failure:r}}function c(e){"@babel/helpers - typeof";return c=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},c(e)}function l(e,t){if(c(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(c(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function u(e){var t=l(e,`string`);return c(t)==`symbol`?t:t+``}function d(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var f=class extends n.Shape{constructor(e,t){super(e,t),d(this,`_activated`,!1),d(this,`_inHiddenRange`,!1),d(this,`_color`,void 0),t&&this.setShapeProps(t)}setShapeProps(e){this._activated=!!e.activated,e.inHiddenRange!==void 0&&(this._inHiddenRange=e.inHiddenRange),e.color!==void 0&&(this._color=e.color),this.transformByState({width:e.width,height:e.height})}_draw(e){let t=this._activated,r=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, 0.35)`,i=`rgb(${this._color.r}, ${this._color.g}, ${this._color.b})`;n.Rect.drawWith(e,{width:this.width,height:this.height,fill:r,stroke:t?i:void 0,strokeWidth:t?2:0,evented:!1})}};function p(e,t){return e.startRow===t.startRow&&e.startColumn===t.startColumn}function m(e,t){return e.startRow<t.startRow||e.startRow===t.startRow&&e.startColumn<=t.startColumn}function h(e,t){return e.startColumn<t.startColumn||e.startColumn===t.startColumn&&e.startRow<=t.startRow}function g(e,t){return e.startRow>t.startRow||e.startRow===t.startRow&&e.startColumn>=t.startColumn}function _(e,t){return e.startColumn>t.startColumn||e.startColumn===t.startColumn&&e.startRow>=t.startRow}function v(t,n){let{range:r}=t,{startRow:i,startColumn:a}=r,o=n.getMergedCell(i,a);return o?e.Rectangle.equals(r,o):r.endRow===r.startRow&&r.endColumn===r.startColumn}function y(e,t){return function(n,r){t(n,r,e)}}function b(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let x=class extends e.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._findReplaceController=t,this._contextService=n,this._findReplaceService=r,this._commandService=i,d(this,`_provider`,void 0),this._init(),this._initCommands()}dispose(){super.dispose(),this._findReplaceController.closePanel(),this._provider.dispose()}_init(){let t=this._injector.createInstance(w);this._provider=t,this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(t)),this.disposeWithMe(this._contextService.subscribeContextValue$(e.EDITOR_ACTIVATED).pipe((0,a.filter)(e=>!!e)).subscribe(()=>this._findReplaceController.closePanel()))}_initCommands(){[o].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};x=b([y(0,(0,e.Inject)(e.Injector)),y(1,(0,e.Inject)(r.FindReplaceController)),y(2,e.IContextService),y(3,r.IFindReplaceService),y(4,e.ICommandService)],x);let S=class extends r.FindModel{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}constructor(e,t,n,r,i,o,s,c){super(),this._workbook=e,this._sheetSkeletonManagerService=t,this._univerInstanceService=n,this._renderManagerService=r,this._commandService=i,this._contextService=o,this._themeService=s,d(this,`_matchesUpdate$`,new a.Subject),d(this,`matchesUpdate$`,this._matchesUpdate$.asObservable()),d(this,`_activelyChangingMatch$`,new a.Subject),d(this,`activelyChangingMatch$`,this._activelyChangingMatch$.asObservable()),d(this,`_matchesByWorksheet`,new Map),d(this,`_matches`,[]),d(this,`_matchesPosition`,0),d(this,`_activeHighlightIndex`,-1),d(this,`_highlightShapes`,[]),d(this,`_currentHighlightShape`,null),d(this,`_query`,null),d(this,`_workbookSelections`,void 0),this._workbookSelections=c.getWorkbookSelections(this.unitId)}dispose(){super.dispose(),this._disposeHighlights(),this._toggleDisplayRawFormula(!1)}getMatches(){return this._matches}start(e){switch(this._query=e,e.findBy===r.FindBy.FORMULA?this._toggleDisplayRawFormula(!0):this._toggleDisplayRawFormula(!1),e.findScope){case r.FindScope.UNIT:this.findInWorkbook(e);break;case r.FindScope.SUBUNIT:default:this.findInActiveWorksheet(e);break}}focusSelection(){let e=this.currentMatch;e&&this._commandService.executeCommand(t.SelectRangeCommand.id,{unitId:e.unitId,subUnit:e.range.subUnitId,range:e.range.range})}_toggleDisplayRawFormula(e){this._contextService.setContextValue(n.RENDER_RAW_FORMULA_KEY,e)}findInWorkbook(n){let r=this._workbook.getUnitId(),i,o=!0,s=()=>{this._matches=this._workbook.getSheets().filter(e=>!e.isSheetHidden()).map(e=>{let t=this._findInWorksheet(e,n,r),i=e.getSheetId(),{results:a}=t;return a.length?this._matchesByWorksheet.set(i,t.results):this._matchesByWorksheet.delete(i),t}).map(e=>e.results).flat(),this._updateFindHighlight(),o?(i={results:this._matches},o=!1):this._matchesUpdate$.next(this._matches)};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._updateFindHighlight(),this._updateCurrentHighlightShape(this._activeHighlightIndex)})),this.disposeWithMe((0,e.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0,a.filter)(([e,n])=>e.id===t.SetWorksheetActiveOperation.id&&!(n!=null&&n.fromFindReplace))).subscribe(()=>{let e=this._workbook.getActiveSheet();if(!e)return;let t=e.getSheetId();this._matchesByWorksheet.has(t)&&this._findNextMatchOnActiveSheetChange(e)})),this.disposeWithMe((0,e.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0,a.filter)(([t])=>t.type===e.CommandType.MUTATION&&t.params.unitId===this._workbook.getUnitId()),(0,a.throttleTime)(600,void 0,{leading:!1,trailing:!0})).subscribe(()=>s())),s(),i}_findNextMatchOnActiveSheetChange(e){let t,n,r=0,i=this._matchesByWorksheet.get(e.getSheetId()),a=this._workbookSelections.getCurrentSelections();a!=null&&a.length?([t,r]=this._findNextMatchByRange(i,a[0].range),n=i.findIndex(e=>e===t)):(t=i[0],n=0,r=this._matches.findIndex(e=>e===t)),this._matchesPosition=r+1,this._activelyChangingMatch$.next(t),this._activeHighlightIndex=n,this._updateFindHighlight(),this._updateCurrentHighlightShape(n)}findInActiveWorksheet(n){let r=this._workbook.getUnitId(),i=()=>{var e;let t=this._workbook.getActiveSheet();if(!t)return!1;let n=this._workbookSelections.getCurrentSelections();return(e=n==null?void 0:n.some(e=>!v(e,t)))==null?!1:e},o,s=!0,c=!1,l=()=>{let e=this._workbook.getActiveSheet();if(!e)return{results:[]};let t=this.currentMatch;c=i();let a=this._workbookSelections.getCurrentSelections(),l=c?this._findInSelections(e,a,n,r):this._findInWorksheet(e,n,r);return this._matches=l.results,this._matchesPosition=this._tryRestoreLastMatchesPosition(t,this._matches),s?(o=l,s=!1):this._matchesUpdate$.next(this._matches),this._updateFindHighlight(),l};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>this._updateFindHighlight())),this.disposeWithMe((0,a.merge)((0,e.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0,a.filter)(([n])=>{if(n.type===e.CommandType.MUTATION&&n.params.unitId===this._workbook.getUnitId())return!0;if(n.id===t.SetSelectionsOperation.id&&n.params.unitId===r){let e=i();return e===!1&&c===!1?!1:(c=e,!0)}return!1})),this._workbook.activeSheet$.pipe((0,a.skip)(1))).pipe((0,a.debounceTime)(200)).subscribe(()=>l())),l(),o}_findInRange(e,t,n,i,a){let o=[],s=e.getSheetId(),c=(t.findDirection===r.FindDirection.COLUMN?e.iterateByColumn:e.iterateByRow).bind(e)(n);for(let n of c){let{row:r,col:c,colSpan:l,rowSpan:u,value:d}=n;if(a!=null&&a(r,c)||!d||e.getRowFiltered(r))continue;let{hit:f,replaceable:p,isFormula:m}=E(e,r,c,t,d);if(f){let e={provider:`sheets-find-replace-provider`,unitId:i,replaceable:p,isFormula:m,range:{subUnitId:s,range:{startRow:r,startColumn:c,endColumn:c+(l==null?1:l)-1,endRow:r+(u==null?1:u)-1}}};o.push(e)}}return{results:o}}_findInSelections(e,t,n,i){let{findDirection:a}=n,o=a===r.FindDirection.ROW?m:h,s=new Set;return{results:t.map(t=>this._findInRange(e,n,t.range,i,(e,t)=>{let n=`${e}-${t}`;return s.has(n)?!0:(s.add(n),!1)}).results).flat().sort((e,t)=>o(e.range.range,t.range.range)?-1:1)}}_findInWorksheet(e,t,n){let r=e.getRowCount(),i=e.getColumnCount(),a={startRow:0,startColumn:0,endRow:r-1,endColumn:i-1};return this._findInRange(e,t,a,n)}_disposeHighlights(){var e;this._highlightShapes.forEach(e=>{var t;(t=e.getScene())==null||t.makeDirty(),e.dispose()}),this._highlightShapes=[],(e=this._currentHighlightShape)==null||e.dispose(),this._currentHighlightShape=null}_updateFindHighlight(){var t;this._disposeHighlights();let n=(t=this._sheetSkeletonManagerService.getCurrent())==null?void 0:t.skeleton;if(!n)return;let r=this._workbook.getUnitId(),a=this._renderManagerService.getRenderById(r);if(a==null)return;let{scene:o}=a,s=this._matches,c=new e.ColorKit(this._themeService.getColorFromTheme(`yellow.400`)).toRgb(),l=this._workbook.getActiveSheet();if(!l)return;let u=l.getSheetId(),d=s.filter(e=>e.range.subUnitId===u).map((e,t)=>{let{startColumn:r,startRow:a,endColumn:s,endRow:u}=e.range.range,d=(0,i.getCoordByCell)(a,r,o,n),p=(0,i.getCoordByCell)(u,s,o,n),{startX:m,startY:h}=d,{endX:g,endY:_}=p,v=!0;for(let e=a;e<=u;e++)if(l.getRowRawVisible(e)){v=!1;break}let y=!0;for(let e=r;e<=s;e++)if(l.getColVisible(e)){y=!1;break}let b=v||y,x={left:m,top:h,color:c,width:y?2:g-m,height:v?2:_-h,evented:!1,inHiddenRange:b,zIndex:1e4};return new f(`find-highlight-${t}`,x)});o.addObjects(d),this._highlightShapes=d,o.makeDirty()}_updateCurrentHighlightShape(e){var t;if((t=this._currentHighlightShape)==null||t.setShapeProps({activated:!1}),this._currentHighlightShape=null,e!==void 0){let t=this._highlightShapes[e];if(!t)return;this._currentHighlightShape=t,t.setShapeProps({activated:!0})}}_getSheetObject(){return(0,i.getSheetObject)(this._univerInstanceService,this._renderManagerService)}_focusMatch(e){var n;let r=e.range.subUnitId;r!==((n=this._workbook.getActiveSheet())==null?void 0:n.getSheetId())&&this._commandService.executeCommand(t.SetWorksheetActivateCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:r},{fromFindReplace:!0}),this._commandService.executeCommand(i.ScrollToCellCommand.id,{range:e.range.range},{fromFindReplace:!0})}_tryRestoreLastMatchesPosition(e,t){if(!e)return 0;let{subUnitId:n}=e.range,{startColumn:r,startRow:i}=e.range.range,a=t.findIndex(e=>{if(n!==e.range.subUnitId)return!1;let{startColumn:t,startRow:a}=e.range.range;return t===r&&a===i});return a>-1?a+1:0}moveToNextMatch(e){var t,n,i,a;if(!this._matches.length)return null;let o=(t=e==null?void 0:e.loop)==null?!1:t,s=(n=e==null?void 0:e.stayIfOnMatch)==null?!1:n,c=(i=e==null?void 0:e.noFocus)==null?!1:i,l=(a=e==null?void 0:e.ignoreSelection)==null?!1:a,u=this._findNextMatch(o,s,l);if(u){var d;let[e,t]=u;return this._matchesPosition=t+1,this._query.findScope===r.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(e.range.subUnitId).findIndex(t=>t===e):this._activeHighlightIndex=t,c||this._focusMatch(e),((d=this._workbook.getActiveSheet())==null?void 0:d.getSheetId())===e.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),e}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}moveToPreviousMatch(e){var t,n,i,a;if(!this._matches.length)return null;let o=(t=e==null?void 0:e.loop)==null?!1:t,s=(n=e==null?void 0:e.stayIfOnMatch)==null?!1:n,c=(i=e==null?void 0:e.noFocus)==null?!1:i,l=(a=e==null?void 0:e.ignoreSelection)==null?!1:a,u=this._findPreviousMatch(o,s,l);if(u){var d;let[e,t]=u;return this._matchesPosition=t+1,this._query.findScope===r.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(e.range.subUnitId).findIndex(t=>t===e):this._activeHighlightIndex=t,c||this._focusMatch(e),((d=this._workbook.getActiveSheet())==null?void 0:d.getSheetId())===e.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),e}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}_findPreviousMatch(e=!1,t=!1,n=!1){var i;if(this.currentMatch){let n=this._matches.findIndex(e=>e===this.currentMatch);if(t)return[this.currentMatch,n];let r=n-1;if(!e&&r<0)return null;let i=this._matches.length,a=(r+i)%i;return[this._matches[a],a]}let a=this._workbookSelections.getCurrentLastSelection();if(n||!a){let e=this._matches.length-1;return[this._matches[e],e]}if(this._query.findScope!==r.FindScope.UNIT)return this._findPreviousMatchByRange(this._matches,a.range);let o=(i=this._workbook.getActiveSheet())==null?void 0:i.getSheetId();if(!o)return null;let s=this._findPreviousWorksheetThatHasAMatch(o,e);return s?this._findPreviousMatchByRange(this._matchesByWorksheet.get(s),a.range):null}_findNextMatch(e=!1,t=!1,n=!1){var i;if(this.currentMatch){let n=this._matches.findIndex(e=>e===this.currentMatch);if(t)return[this.currentMatch,n];let r=n+1,i=this._matches.length;if(!e&&r>=i)return null;let a=r%i;return[this._matches[a],a]}let a=this._workbookSelections.getCurrentLastSelection();if(n||!a)return[this._matches[0],0];if(this._query.findScope!==r.FindScope.UNIT)return this._findNextMatchByRange(this._matches,a.range,t);let o=(i=this._workbook.getActiveSheet())==null?void 0:i.getSheetId();if(!o)return null;let s=this._findNextWorksheetThatHasAMatch(o,e);return s?this._findNextMatchByRange(this._matchesByWorksheet.get(s),a.range):null}_findPreviousWorksheetThatHasAMatch(t,n=!1){let r=this._workbook.getSheetOrders(),i=r.findIndex(e=>e===t),a=(n?(0,e.rotate)(r,i+1):r.slice(0,i+1)).findLast(e=>this._matchesByWorksheet.has(e));return a==null?null:a}_findNextWorksheetThatHasAMatch(t,n=!1){let r=this._workbook.getSheetOrders(),i=r.findIndex(e=>e===t),a=(n?(0,e.rotate)(r,i):r.slice(i)).find(e=>this._matchesByWorksheet.has(e));return a==null?null:a}_findNextMatchByRange(e,t,n=!1){let i=this._query.findDirection===r.FindDirection.ROW,a=e.findIndex(e=>{let r=e.range.range;if(!(i?m(t,r):h(t,r)))return!1;let a=p(t,r);return n?a:!a});a===-1&&(a=e.length-1);let o=e[a];return[o,this._matches.findIndex(e=>e===o)]}_findPreviousMatchByRange(e,t,n=!1){let i=this._query.findDirection===r.FindDirection.ROW,a=this._matches.findLastIndex(e=>{let r=e.range.range;if(!(i?g(t,r):_(t,r)))return!1;let a=p(t,r);return n?a:!a});a===-1&&(a=0);let o=e[a];return[o,this._matches.findIndex(e=>e===o)]}async replace(e){if(this._matchesCount===0||!this.currentMatch||!this._query||!this.currentMatch.replaceable)return!1;let n=this.currentMatch.range,i=this._workbook.getSheetBySheetId(this.currentMatch.range.subUnitId),a=this._getReplacedCellData(this.currentMatch,i,this._query.findBy===r.FindBy.FORMULA,this._query.findString,e,this._query.caseSensitive?`g`:`ig`),o={unitId:this.currentMatch.unitId,subUnitId:n.subUnitId,value:{[n.range.startRow]:{[n.range.startColumn]:a}}};return this._commandService.executeCommand(t.SetRangeValuesCommand.id,o)}async replaceAll(t){if(this._matchesCount===0||!this._query)return{success:0,failure:0};let n=this._workbook.getUnitId(),{findString:i,caseSensitive:a,findBy:s}=this._query,c=s===r.FindBy.FORMULA,l=a?`g`:`ig`,u=[];return(0,e.groupBy)(this._matches.filter(e=>e.replaceable),e=>e.range.subUnitId).forEach((n,r)=>{let a=new e.ObjectMatrix,o=this._workbook.getSheetBySheetId(r);n.forEach(e=>{let{startColumn:n,startRow:r}=e.range.range,s=this._getReplacedCellData(e,o,c,i,t,l);s&&a.setValue(r,n,s)}),u.push({count:n.length,subUnitId:r,value:a.getMatrix()})}),u?this._commandService.executeCommand(o.id,{unitId:n,replacements:u}):{success:0,failure:0}}_getReplacedCellData(t,n,r,i,a,o){var s;let{startRow:c,startColumn:l}=t.range.range,u=n.getCellRaw(c,l);if(t.isFormula)return r?{f:u.f.replace(new RegExp(C(i),o),a),v:null}:null;if((s=u.p)!=null&&s.body){let t=e.Tools.deepClone(u.p);return(0,e.replaceInDocumentBody)(t.body,i,a,this._query.caseSensitive),{p:t}}return{v:u.v.toString().replace(new RegExp(C(i),o),a)}}};S=b([y(2,e.IUniverInstanceService),y(3,n.IRenderManagerService),y(4,e.ICommandService),y(5,e.IContextService),y(6,(0,e.Inject)(e.ThemeService)),y(7,(0,e.Inject)(t.SheetsSelectionsService))],S);function C(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`)}let w=class extends e.Disposable{constructor(e,t,n){super(),this._univerInstanceService=e,this._renderManagerService=t,this._injector=n,d(this,`_findModelsByUnitId`,new Map)}async find(t){this._terminate();let n=this._univerInstanceService.getCurrentUnitOfType(e.UniverInstanceType.UNIVER_SHEET);if(!n)return[];let r=this._preprocessQuery(t),a=this._renderManagerService.getRenderById(n.getUnitId()).with(i.SheetSkeletonManagerService),o=this._injector.createInstance(S,n,a);return this._findModelsByUnitId.set(n.getUnitId(),o),o.start(r),[o]}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=b([y(0,e.IUniverInstanceService),y(1,n.IRenderManagerService),y(2,(0,e.Inject)(e.Injector))],w);const T={hit:!1,replaceable:!1,isFormula:!1,rawData:null};function E(e,t,n,i,a){let{findBy:o}=i,s=o===r.FindBy.FORMULA,c=e.getCellRaw(t,n);return T.rawData=c,c!=null&&c.f?(T.isFormula=!0,s?D({v:c.f},i)?(T.hit=!0,T.replaceable=!0,T):(T.hit=!1,T.replaceable=!1,T):(T.replaceable=!1,D(a,i)?T.hit=!0:T.hit=!1,T)):(T.isFormula=!1,D(a,i)?c?(T.hit=!0,T.replaceable=!0):(T.hit=!0,T.replaceable=!1):(T.hit=!1,T.replaceable=!1),T)}function D(e,t){let n=O(e);return n?t.matchesTheWholeCell?(n=k(n),t.caseSensitive?n===t.findString:n.toLowerCase()===t.findString):t.caseSensitive?n.indexOf(t.findString)>-1:n.toLowerCase().indexOf(t.findString)>-1:!1}function O(e){var t,n;let r=(t=e==null||(n=e.p)==null||(n=n.body)==null?void 0:n.dataStream)==null?e==null?void 0:e.v:t;return typeof r==`number`?`${r}`:typeof r==`boolean`?r?`1`:`0`:r}function k(e){return e.replace(/^ +/g,``).replace(/ +$/g,``)}var A=`@univerjs/sheets-find-replace`,j=`0.18.0`;const M=`sheets-find-replace.config`;Symbol(M);const N={};let P=class extends e.Plugin{constructor(t=N,n,r){super(),this._config=t,this._injector=n,this._configService=r;let{...i}=(0,e.merge)({},N,this._config);this._configService.setConfig(M,i)}onStarting(){[[x]].forEach(e=>this._injector.add(e))}onSteady(){this._injector.get(x)}};d(P,`pluginName`,`SHEET_FIND_REPLACE_PLUGIN`),d(P,`packageName`,A),d(P,`version`,j),d(P,`type`,e.UniverInstanceType.UNIVER_SHEET),P=b([(0,e.DependentOn)(t.UniverSheetsPlugin,t.UniverSheetsPlugin,r.UniverFindReplacePlugin),y(1,(0,e.Inject)(e.Injector)),y(2,e.IConfigService)],P),exports.SheetReplaceCommand=o,Object.defineProperty(exports,`SheetsFindReplaceController`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`UniverSheetsFindReplacePlugin`,{enumerable:!0,get:function(){return P}});
|
package/lib/cjs/locale/ca-ES.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e={"sheet-find-replace":{replace:{"partial-failure":`No s’ha pogut substituir algunes cel·les`,failure:`No s’ha pogut substituir cap cel·la`}}};module.exports=e;
|
package/lib/cjs/locale/en-US.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e={"sheet-find-replace":{replace:{"partial-failure":`Failed to replace some cells`,failure:`Failed to replace all cells`}}};module.exports=e;
|
package/lib/cjs/locale/es-ES.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e={"sheet-find-replace":{replace:{"partial-failure":`No se pudo reemplazar algunas celdas`,failure:`No se pudo reemplazar ninguna celda`}}};module.exports=e;
|
package/lib/cjs/locale/fa-IR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e={"sheet-find-replace":{replace:{"partial-failure":`جایگزینی برخی سلولها ناموفق بود`,failure:`جایگزینی همه سلولها ناموفق بود`}}};module.exports=e;
|
package/lib/cjs/locale/fr-FR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e={"sheet-find-replace":{replace:{"partial-failure":`Échec du remplacement de certaines cellules`,failure:`Échec du remplacement de toutes les cellules`}}};module.exports=e;
|
package/lib/cjs/locale/ja-JP.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e={"sheet-find-replace":{replace:{"partial-failure":`一部のセルの置換に失敗しました`,failure:`すべてのセルの置換に失敗しました`}}};module.exports=e;
|
package/lib/cjs/locale/ko-KR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e={"sheet-find-replace":{replace:{"partial-failure":`일부 셀 교체에 실패했습니다`,failure:`모든 셀 교체에 실패했습니다`}}};module.exports=e;
|
package/lib/cjs/locale/ru-RU.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e={"sheet-find-replace":{replace:{"partial-failure":`Не удалось заменить некоторые ячейки`,failure:`Не удалось заменить все ячейки`}}};module.exports=e;
|
package/lib/cjs/locale/sk-SK.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e={"sheet-find-replace":{replace:{"partial-failure":`Nepodarilo sa nahradiť niektoré bunky`,failure:`Nepodarilo sa nahradiť všetky bunky`}}};module.exports=e;
|
package/lib/cjs/locale/vi-VN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e={"sheet-find-replace":{replace:{"partial-failure":`Thay thế một phần ô thất bại`,failure:`Thay thế thất bại`}}};module.exports=e;
|
package/lib/cjs/locale/zh-CN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var e={"sheet-find-replace":{replace:{"partial-failure":`部分单元格替换失败`,failure:`替换失败`}}};module.exports=e;
|
package/lib/cjs/locale/zh-TW.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e={"sheet-find-replace":{replace:{"partial-failure":`部分儲存格替換失敗`,failure:`替換失敗`}}};module.exports=e;
|
package/lib/es/facade.js
CHANGED
|
@@ -1,101 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var p = (a, e, t) => e in a ? u(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
|
-
var c = (a, e, t) => p(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { Inject as m, Injector as _, IUniverInstanceService as f, Disposable as v } from "@univerjs/core";
|
|
5
|
-
import { IFindReplaceService as g, FindReplaceModel as y, createInitFindReplaceState as S, FindReplaceState as b, FindBy as h } from "@univerjs/find-replace";
|
|
6
|
-
import { FRange as F } from "@univerjs/sheets/facade";
|
|
7
|
-
import { FUniver as d } from "@univerjs/core/facade";
|
|
8
|
-
var w = Object.getOwnPropertyDescriptor, C = (a, e, t, s) => {
|
|
9
|
-
for (var n = s > 1 ? void 0 : s ? w(e, t) : e, i = a.length - 1, r; i >= 0; i--)
|
|
10
|
-
(r = a[i]) && (n = r(n) || n);
|
|
11
|
-
return n;
|
|
12
|
-
}, o = (a, e) => (t, s) => e(t, s, a);
|
|
13
|
-
let l = class extends v {
|
|
14
|
-
constructor(e, t, s, n) {
|
|
15
|
-
super();
|
|
16
|
-
c(this, "_state", new b());
|
|
17
|
-
c(this, "_model");
|
|
18
|
-
c(this, "_complete");
|
|
19
|
-
this._injector = t, this._univerInstanceService = s, this._findReplaceService = n;
|
|
20
|
-
const i = this._findReplaceService.getProviders();
|
|
21
|
-
this._model = this._injector.createInstance(y, this._state, i);
|
|
22
|
-
const r = {
|
|
23
|
-
...S(),
|
|
24
|
-
...e
|
|
25
|
-
};
|
|
26
|
-
this._state.changeState(r);
|
|
27
|
-
}
|
|
28
|
-
findAll() {
|
|
29
|
-
return !this._state.findCompleted || !this._complete ? [] : this._complete.results.map((e) => this._findMatchToFRange(e));
|
|
30
|
-
}
|
|
31
|
-
findNext() {
|
|
32
|
-
var t;
|
|
33
|
-
if (!this._state.findCompleted || !this._complete)
|
|
34
|
-
return null;
|
|
35
|
-
const e = (t = this._model) == null ? void 0 : t.moveToNextMatch();
|
|
36
|
-
return e ? this._findMatchToFRange(e) : null;
|
|
37
|
-
}
|
|
38
|
-
findPrevious() {
|
|
39
|
-
var t;
|
|
40
|
-
const e = (t = this._model) == null ? void 0 : t.moveToPreviousMatch();
|
|
41
|
-
return e ? this._findMatchToFRange(e) : null;
|
|
42
|
-
}
|
|
43
|
-
getCurrentMatch() {
|
|
44
|
-
var t;
|
|
45
|
-
if (!this._state.findCompleted || !this._complete)
|
|
46
|
-
throw new Error("Find operation is not completed.");
|
|
47
|
-
const e = (t = this._model) == null ? void 0 : t.currentMatch$.value;
|
|
48
|
-
return e ? this._findMatchToFRange(e) : null;
|
|
49
|
-
}
|
|
50
|
-
async matchCaseAsync(e) {
|
|
51
|
-
return this._state.changeState({ caseSensitive: e, findCompleted: !1 }), new Promise((t) => {
|
|
52
|
-
const s = this._state.stateUpdates$.subscribe(async (n) => {
|
|
53
|
-
n.findCompleted === !0 && (s.unsubscribe(), await this.ensureCompleteAsync(), t(this));
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
async matchEntireCellAsync(e) {
|
|
58
|
-
return this._state.changeState({ matchesTheWholeCell: e, findCompleted: !1 }), new Promise((t) => {
|
|
59
|
-
const s = this._state.stateUpdates$.subscribe(async (n) => {
|
|
60
|
-
n.findCompleted === !0 && (s.unsubscribe(), await this.ensureCompleteAsync(), t(this));
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
async matchFormulaTextAsync(e) {
|
|
65
|
-
return this._state.changeState({ findBy: e ? h.FORMULA : h.VALUE, findCompleted: !1 }), new Promise((t) => {
|
|
66
|
-
const s = this._state.stateUpdates$.subscribe(async (n) => {
|
|
67
|
-
n.findCompleted === !0 && (s.unsubscribe(), await this.ensureCompleteAsync(), t(this));
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
async replaceAllWithAsync(e) {
|
|
72
|
-
var s, n, i;
|
|
73
|
-
await this._state.changeState({ replaceRevealed: !0, replaceString: e });
|
|
74
|
-
const t = (i = (n = await ((s = this._model) == null ? void 0 : s.replaceAll())) == null ? void 0 : n.success) != null ? i : 0;
|
|
75
|
-
return this._state.changeState({ replaceRevealed: !1 }), t;
|
|
76
|
-
}
|
|
77
|
-
async replaceWithAsync(e) {
|
|
78
|
-
var t;
|
|
79
|
-
return await this._state.changeState({ replaceRevealed: !0, replaceString: e }), await ((t = this._model) == null ? void 0 : t.replace()), this._state.changeState({ replaceRevealed: !1 }), !0;
|
|
80
|
-
}
|
|
81
|
-
async ensureCompleteAsync() {
|
|
82
|
-
var e;
|
|
83
|
-
this._complete = await ((e = this._model) == null ? void 0 : e.start());
|
|
84
|
-
}
|
|
85
|
-
_findMatchToFRange(e) {
|
|
86
|
-
const { unitId: t } = e, { subUnitId: s, range: n } = e.range, i = this._univerInstanceService.getUnit(t), r = i.getSheetBySheetId(s);
|
|
87
|
-
return this._injector.createInstance(F, i, r, n);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
l = C([
|
|
91
|
-
o(1, m(_)),
|
|
92
|
-
o(2, f),
|
|
93
|
-
o(3, g)
|
|
94
|
-
], l);
|
|
95
|
-
class R extends d {
|
|
96
|
-
async createTextFinderAsync(e) {
|
|
97
|
-
const t = { findString: e }, s = this._injector.createInstance(l, t);
|
|
98
|
-
return await s.ensureCompleteAsync(), s;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
d.extend(R);
|
|
1
|
+
import{Disposable as e,IUniverInstanceService as t,Inject as n,Injector as r}from"@univerjs/core";import{FindBy as i,FindReplaceModel as a,FindReplaceState as o,IFindReplaceService as s,createInitFindReplaceState as c}from"@univerjs/find-replace";import{FRange as l}from"@univerjs/sheets/facade";import{FUniver as u}from"@univerjs/core/facade";function d(e){"@babel/helpers - typeof";return d=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},d(e)}function f(e,t){if(d(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(d(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p(e){var t=f(e,`string`);return d(t)==`symbol`?t:t+``}function m(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e,t){return function(n,r){t(n,r,e)}}function g(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let _=class extends e{constructor(e,t,n,r){super(),this._injector=t,this._univerInstanceService=n,this._findReplaceService=r,m(this,`_state`,new o),m(this,`_model`,void 0),m(this,`_complete`,void 0);let i=this._findReplaceService.getProviders();this._model=this._injector.createInstance(a,this._state,i);let s={...c(),...e};this._state.changeState(s)}findAll(){return!this._state.findCompleted||!this._complete?[]:this._complete.results.map(e=>this._findMatchToFRange(e))}findNext(){var e;if(!this._state.findCompleted||!this._complete)return null;let t=(e=this._model)==null?void 0:e.moveToNextMatch();return t?this._findMatchToFRange(t):null}findPrevious(){var e;let t=(e=this._model)==null?void 0:e.moveToPreviousMatch();return t?this._findMatchToFRange(t):null}getCurrentMatch(){var e;if(!this._state.findCompleted||!this._complete)throw Error(`Find operation is not completed.`);let t=(e=this._model)==null?void 0:e.currentMatch$.value;return t?this._findMatchToFRange(t):null}async matchCaseAsync(e){return this._state.changeState({caseSensitive:e,findCompleted:!1}),new Promise(e=>{let t=this._state.stateUpdates$.subscribe(async n=>{n.findCompleted===!0&&(t.unsubscribe(),await this.ensureCompleteAsync(),e(this))})})}async matchEntireCellAsync(e){return this._state.changeState({matchesTheWholeCell:e,findCompleted:!1}),new Promise(e=>{let t=this._state.stateUpdates$.subscribe(async n=>{n.findCompleted===!0&&(t.unsubscribe(),await this.ensureCompleteAsync(),e(this))})})}async matchFormulaTextAsync(e){return this._state.changeState({findBy:e?i.FORMULA:i.VALUE,findCompleted:!1}),new Promise(e=>{let t=this._state.stateUpdates$.subscribe(async n=>{n.findCompleted===!0&&(t.unsubscribe(),await this.ensureCompleteAsync(),e(this))})})}async replaceAllWithAsync(e){var t,n,r;await this._state.changeState({replaceRevealed:!0,replaceString:e});let i=(t=(n=await((r=this._model)==null?void 0:r.replaceAll()))==null?void 0:n.success)==null?0:t;return this._state.changeState({replaceRevealed:!1}),i}async replaceWithAsync(e){var t;return await this._state.changeState({replaceRevealed:!0,replaceString:e}),await((t=this._model)==null?void 0:t.replace()),this._state.changeState({replaceRevealed:!1}),!0}async ensureCompleteAsync(){var e;this._complete=await((e=this._model)==null?void 0:e.start())}_findMatchToFRange(e){let{unitId:t}=e,{subUnitId:n,range:r}=e.range,i=this._univerInstanceService.getUnit(t),a=i.getSheetBySheetId(n);return this._injector.createInstance(l,i,a,r)}};_=g([h(1,n(r)),h(2,t),h(3,s)],_);var v=class extends u{async createTextFinderAsync(e){let t={findString:e},n=this._injector.createInstance(_,t);return await n.ensureCompleteAsync(),n}};u.extend(v);export{};
|