@univerjs/find-replace 0.7.0 → 0.8.0-beta.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/index.js +1 -1
- package/lib/es/index.js +81 -74
- package/lib/index.js +81 -74
- package/lib/types/locale/en-US.d.ts +64 -2
- package/lib/types/locale/fa-IR.d.ts +2 -2
- package/lib/types/locale/ru-RU.d.ts +2 -2
- package/lib/types/locale/vi-VN.d.ts +2 -2
- package/lib/types/locale/zh-CN.d.ts +2 -64
- package/lib/types/locale/zh-TW.d.ts +2 -2
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Fe=Object.defineProperty;var xe=(t,e,n)=>e in t?Fe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var u=(t,e,n)=>xe(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),l=require("@univerjs/ui"),m=require("rxjs"),f=require("@univerjs/design"),De=require("@univerjs/engine-render"),d=require("react/jsx-runtime"),h=require("react"),Te="find-replace.config",G={};var b=function(){return b=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},b.apply(this,arguments)},Oe=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(n[i[s]]=t[i[s]]);return n},H=h.forwardRef(function(t,e){var n=t.icon,i=t.id,s=t.className,r=t.extend,a=Oe(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(s||"").trim(),p=h.useRef("_".concat(Ne()));return q(n,"".concat(i),{defIds:n.defIds,idSuffix:p.current},b({ref:e,className:o},a),r)});function q(t,e,n,i,s){return h.createElement(t.tag,b(b({key:e},Pe(t,n,s)),i),(Ee(t,n).children||[]).map(function(r,a){return q(r,"".concat(e,"-").concat(t.tag,"-").concat(a),n,void 0,s)}))}function Pe(t,e,n){var i=b({},t.attrs);n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1),t.tag==="mask"&&i.id&&(i.id=i.id+e.idSuffix),Object.entries(i).forEach(function(r){var a=r[0],o=r[1];a==="mask"&&typeof o=="string"&&(i[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(r){var a=r[0],o=r[1];typeof o=="string"&&(i[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function Ee(t,e){var n,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((n=t.children)===null||n===void 0)&&n.length)?b(b({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&i&&i.indexOf(s.attrs.id)>-1?b(b({},s),{attrs:b(b({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function Ne(){return Math.random().toString(36).substring(2,8)}H.displayName="UniverIcon";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.71899 1.36938C4.37604 1.36938 1.66602 4.07941 1.66602 7.42236C1.66602 10.7653 4.37604 13.4753 7.71899 13.4753C9.16744 13.4753 10.4971 12.9666 11.5389 12.118L13.6598 14.4109C13.8848 14.6542 14.2644 14.669 14.5077 14.444C14.7509 14.219 14.7657 13.8393 14.5407 13.5961L12.3906 11.2716C13.2536 10.2254 13.772 8.88442 13.772 7.42236C13.772 4.07941 11.0619 1.36938 7.71899 1.36938ZM2.86602 7.42236C2.86602 4.74215 5.03878 2.56938 7.71899 2.56938C10.3992 2.56938 12.572 4.74215 12.572 7.42236C12.572 10.1026 10.3992 12.2753 7.71899 12.2753C5.03878 12.2753 2.86602 10.1026 2.86602 7.42236Z",fillRule:"evenodd",clipRule:"evenodd"}}]},z=h.forwardRef(function(t,e){return h.createElement(H,Object.assign({},t,{id:"search-single",ref:e,icon:Le}))});z.displayName="SearchSingle";const Y="FIND_REPLACE_INPUT_FOCUS",Z="FIND_REPLACE_DIALOG_FOCUS",J="FIND_REPLACE_REPLACE_REVEALED";var je=Object.getOwnPropertyDescriptor,Q=(t,e,n,i)=>{for(var s=i>1?void 0:i?je(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=a(s)||s);return s},D=(t,e)=>(n,i)=>e(n,i,t);class $e extends c.Disposable{}const C=c.createIdentifier("find-replace.service");function Ae(t){return typeof t.findString<"u"||typeof t.inputtingFindString<"u"||typeof t.findDirection<"u"||typeof t.matchesTheWholeCell<"u"||typeof t.caseSensitive<"u"||typeof t.findScope<"u"||typeof t.findBy<"u"}exports.FindReplaceModel=class extends c.Disposable{constructor(n,i,s,r){super();u(this,"currentMatch$",new m.BehaviorSubject(null));u(this,"replaceables$",new m.BehaviorSubject([]));u(this,"_findModels",[]);u(this,"_matchingModel",null);u(this,"_matches",[]);u(this,"_currentSearchingDisposables",null);this._state=n,this._providers=i,this._univerInstanceService=s,this._commandService=r,this.disposeWithMe(this._state.stateUpdates$.pipe(m.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async a=>{const o=this._state.state;Ae(a)&&(o.findString!==""&&!o.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):a.replaceRevealed!==!0&&this._stopSearching())}))}get searched(){return this._findModels.length>0}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...E(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const n=await this._startSearching();return this._state.changeState({findCompleted:!0}),n}focusSelection(){var n;(n=this._matchingModel)==null||n.focusSelection()}async _startSearching(){if(!this._state.findString)return{results:[]};const n=Array.from(this._providers),i=this._findModels=(await Promise.all(n.map(r=>r.find({findString:this._state.findString,findDirection:this._state.findDirection,findScope:this._state.findScope,findBy:this._state.findBy,replaceRevealed:this._state.replaceRevealed,caseSensitive:this._state.caseSensitive,matchesTheWholeCell:this._state.matchesTheWholeCell})))).flat();this._subscribeToModelsChanges(i);const s=this._matches=i.map(r=>r.getMatches()).flat();return this.replaceables$.next(s.filter(r=>r.replaceable)),s.length?(this._moveToInitialMatch(i),this._state.changeState({matchesCount:s.length}),{results:s}):(this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]})}_stopSearching(){var n;this._providers.forEach(i=>i.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(n=this._currentSearchingDisposables)==null||n.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(n){const i=this._currentSearchingDisposables=new c.DisposableCollection,s=m.combineLatest(n.map(r=>r.matchesUpdate$)).pipe(m.debounceTime(220)).subscribe(([...r])=>{const a=this._matches=r.flat();a.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:a.length}),this.replaceables$.next(a.filter(o=>o.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});n.forEach(r=>i.add(c.toDisposable(r.activelyChangingMatch$.subscribe(a=>{const o=this._matches.findIndex(p=>p===a);this._state.changeState({matchesPosition:o+1})})))),i.add(c.toDisposable(s))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const n=await Promise.all(this._findModels.map(i=>i.replaceAll(this._state.replaceString))).then(i=>i.reduce((s,r)=>(s.success+=r.success,s.failure+=r.failure,s),{success:0,failure:0}));return n.failure===0&&this._stopSearching(),n}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}_markMatch(n){const i=this._matches.findIndex(s=>s===n);this.currentMatch$.next(n),this._state.changeState({matchesPosition:i+1})}moveToNextMatch(){if(!this._matchingModel)return;const n=this._findModels.length===1,i=this._matchingModel.moveToNextMatch({loop:n});if(i)return this._markMatch(i),i;{const s=this._findModels.findIndex(r=>r===this._matchingModel);return this._moveToNextUnitMatch(s)}}_moveToNextUnitMatch(n){const i=this._findModels.length;for(let s=(n+1)%i;s!==n;){const r=this._findModels[s],a=r.moveToNextMatch({ignoreSelection:!0});if(a)return this._matchingModel=r,this._markMatch(a),a;s=(s+1)%i}if(this._matchingModel){const s=this._matchingModel.moveToNextMatch({ignoreSelection:!0});return s&&this._markMatch(s),s}}moveToPreviousMatch(){if(!this._matchingModel)return;const n=this._findModels.length===1,i=this._matchingModel.moveToPreviousMatch({loop:n});if(i){const s=this._matches.findIndex(r=>r===i);return this.currentMatch$.next(i),this._state.changeState({matchesPosition:s+1}),i}else{const s=this._findModels.length,r=this._findModels.findIndex(o=>o===this._matchingModel);for(let o=(r-1+s)%s;o!==r;){const p=this._findModels[o],v=p.moveToPreviousMatch({ignoreSelection:!0});if(v)return this._matchingModel=p,this._markMatch(v),v;o=(o-1)%s}const a=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});return a&&this._markMatch(a),a}}_moveToInitialMatch(n,i=!1){var a;const s=(a=this._univerInstanceService.getFocusedUnit())==null?void 0:a.getUnitId();if(!s)return-1;const r=n.findIndex(o=>o.unitId===s);if(r!==-1){this._matchingModel=n[r];const o=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus:i});if(o)return this._markMatch(o),r}return this._moveToNextUnitMatch(r),0}};exports.FindReplaceModel=Q([D(2,c.IUniverInstanceService),D(3,c.ICommandService)],exports.FindReplaceModel);var T=(t=>(t.ROW="row",t.COLUMN="column",t))(T||{}),O=(t=>(t.VALUE="value",t.FORMULA="formula",t))(O||{}),P=(t=>(t.SUBUNIT="subunit",t.UNIT="unit",t))(P||{});function E(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class X{constructor(){u(this,"_stateUpdates$",new m.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new m.BehaviorSubject(E()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_inputtingFindString","");u(this,"_replaceString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0);u(this,"_caseSensitive",!0);u(this,"_matchesTheWholeCell",!1);u(this,"_findDirection","row");u(this,"_findScope","subunit");u(this,"_findBy","value");u(this,"_findCompleted",!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let n=!1;const i={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,i.findString=this._findString,n=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,i.revealed=e.revealed,n=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,i.replaceRevealed=e.replaceRevealed,n=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,i.replaceString=e.replaceString,n=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,i.matchesCount=e.matchesCount,n=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,i.matchesPosition=e.matchesPosition,n=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,i.findBy=e.findBy,n=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,i.findScope=e.findScope,n=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,i.findDirection=e.findDirection,n=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,i.caseSensitive=e.caseSensitive,n=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,i.matchesTheWholeCell=e.matchesTheWholeCell,n=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,i.inputtingFindString=e.inputtingFindString,n=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,i.findCompleted=e.findCompleted,n=!0),n&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(i))}}let $=class extends c.Disposable{constructor(e,n){super();u(this,"_providers",new Set);u(this,"_state",new X);u(this,"_model");u(this,"_currentMatch$",new m.BehaviorSubject(null));u(this,"currentMatch$",this._currentMatch$.asObservable());u(this,"_replaceables$",new m.BehaviorSubject([]));u(this,"replaceables$",this._replaceables$.asObservable());u(this,"_focusSignal$",new m.Subject);u(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=n}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getProviders(){return this._providers}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e==="formula")}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}focusSelection(){var e;(e=this._model)==null||e.focusSelection()}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(exports.FindReplaceModel,this._state,this._providers),this._model.currentMatch$.subscribe(i=>this._currentMatch$.next(i)),this._model.replaceables$.subscribe(i=>this._replaceables$.next(i));const n=E();return e&&(n.replaceRevealed=!0),this._state.changeState(n),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),c.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(J,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(De.RENDER_RAW_FORMULA_KEY,e)}};$=Q([D(0,c.Inject(c.Injector)),D(1,c.IContextService)],$);const A={id:"ui.command.replace-current-match",type:c.CommandType.COMMAND,handler:t=>t.get(C).replace()},we="CONFIRM_REPLACE_ALL",w={id:"ui.command.replace-all-matches",type:c.CommandType.COMMAND,handler:async t=>{const e=t.get(l.IConfirmService),n=t.get(c.LocaleService),i=t.get(l.IMessageService);if(!await e.confirm({id:we,title:{title:n.t("find-replace.replace.confirm.title")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")}))return!1;const r=await t.get(C).replaceAll(),{success:a,failure:o}=r;return o>0?(a===0?i.show({type:f.MessageType.Error,content:n.t("find-replace.replace.all-failure")}):i.show({type:f.MessageType.Warning,content:n.t("find-replace.replace.partial-success",`${a}`,`${o}`)}),!1):(i.show({type:f.MessageType.Success,content:n.t("find-replace.replace.all-success",`${a}`)}),!0)}},y={id:"ui.operation.open-find-dialog",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(C);return e.revealed?e.focusFindInput():e.start(),!0}},N={id:"ui.operation.open-replace-dialog",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(C);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},U={type:c.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(C).moveToNextMatch(),!0)},k={type:c.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(C).moveToPreviousMatch(),!0)},ee={type:c.CommandType.OPERATION,id:"ui.operation.focus-selection",handler:t=>(t.get(C).focusSelection(),!0)};function te(t){const{findCompleted:e,localeService:n,matchesCount:i,matchesPosition:s,findString:r,findReplaceService:a,onChange:o,...p}=t,S=e&&i===0?n.t("find-replace.dialog.no-result"):i===0?" ":void 0;return d.jsx("div",{className:"univer-relative univer-flex univer-items-center univer-gap-2",onDrag:g=>g.stopPropagation(),children:d.jsx(f.Input,{"data-u-comp":"search-input",autoFocus:!0,placeholder:n.t("find-replace.dialog.find-placeholder"),value:r,onChange:g=>o==null?void 0:o(g),slot:d.jsx(f.Pager,{loop:!0,text:S,value:s,total:i,onChange:g=>{s===i&&g===1?a.moveToNextMatch():s===1&&g===i||g<s?a.moveToPreviousMatch():a.moveToNextMatch()}}),...p})})}function ie(t,e){const n=h.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),i=h.useCallback(()=>{const s=document.querySelectorAll("[data-u-comp=find-replace-dialog] [data-u-comp=search-input]");return Array.from(s).some(r=>r===document.activeElement)},[]);return h.useImperativeHandle(e,()=>({focus:n,selectHasFocus:i})),h.useEffect(()=>{const s=t.focusSignal$.subscribe(()=>n());return()=>s.unsubscribe()},[t,n]),{focus:n,selectHasFocus:i}}const Ue=h.forwardRef(function(e,n){const i=l.useDependency(c.LocaleService),s=l.useDependency(C),r=l.useDependency(c.ICommandService),a=l.useObservable(s.state$,void 0,!0),{findCompleted:o,findString:p,matchesCount:v,matchesPosition:S}=a,g=h.useCallback(()=>{r.executeCommand(N.id)},[r]),x=h.useCallback(R=>s.changeFindString(R),[s]);return ie(s,n),d.jsxs(d.Fragment,{children:[d.jsx(te,{findCompleted:o,className:"univer-find-input",matchesCount:v,matchesPosition:S,findReplaceService:s,localeService:i,findString:p,onChange:x}),d.jsx("div",{className:"univer-mt-4 univer-text-center",children:d.jsx("a",{className:"univer-cursor-pointer univer-text-sm univer-text-primary-500 univer-transition-colors hover:univer-text-primary-500/80",onClick:g,children:i.t("find-replace.dialog.advanced-finding")})})]})}),ke=h.forwardRef(function(e,n){const i=l.useDependency(C),s=l.useDependency(c.LocaleService),r=l.useDependency(c.ICommandService),a=l.useDependency(l.IMessageService),o=l.useObservable(i.currentMatch$,void 0,!0),p=l.useObservable(i.replaceables$,void 0,!0),v=l.useObservable(i.state$,void 0,!0),{matchesCount:S,matchesPosition:g,findString:x,inputtingFindString:R,replaceString:re,caseSensitive:ae,matchesTheWholeCell:oe,findDirection:ce,findScope:le,findBy:de,findCompleted:L}=v,ue=R.length===0,he=S===0||!(o!=null&&o.replaceable),pe=p.length===0,fe=h.useCallback(_=>i.changeInputtingFindString(_),[i]),ge=h.useCallback(_=>i.changeReplaceString(_),[i]),{focus:_e}=ie(i,n),me=h.useCallback(()=>{x===R?i.moveToNextMatch():(i.changeFindString(R),i.find())},[x,R,i]),ve=h.useCallback(()=>r.executeCommand(A.id),[r]),Se=h.useCallback(async()=>{await r.executeCommand(w.id),_e()},[r]),Ce=h.useCallback(_=>{i.changeFindDirection(_)},[i]),be=h.useCallback(_=>{i.changeFindScope(_)},[i]),Me=h.useCallback(_=>{i.changeFindBy(_)},[i]),Re=We(s),ye=Ge(s),Ie=Ve(s);return h.useEffect(()=>{L&&S===0&&a.show({content:s.t("find-replace.dialog.no-match"),type:f.MessageType.Warning,duration:5e3})},[L,S,a,s]),d.jsxs("div",{children:[d.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find"),children:d.jsx(te,{findCompleted:L,className:"univer-find-input",matchesCount:S,matchesPosition:g,findReplaceService:i,localeService:s,findString:R,onChange:fe})}),d.jsx(f.FormLayout,{label:s.t("find-replace.dialog.replace"),children:d.jsx(f.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:re,onChange:_=>ge(_)})}),d.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:d.jsx(f.Select,{value:ce,options:ye,onChange:Ce})}),d.jsx(f.FormDualColumnLayout,{children:d.jsxs(d.Fragment,{children:[d.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:d.jsx(f.Select,{value:le,options:Re,onChange:be})}),d.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:d.jsx(f.Select,{value:de,options:Ie,onChange:Me})})]})}),d.jsx(f.FormDualColumnLayout,{children:d.jsxs(d.Fragment,{children:[d.jsx(f.FormLayout,{children:d.jsx(f.Checkbox,{checked:ae,onChange:_=>{i.changeCaseSensitive(_)},children:s.t("find-replace.dialog.case-sensitive")})}),d.jsx(f.FormLayout,{children:d.jsx(f.Checkbox,{checked:oe,onChange:_=>{i.changeMatchesTheWholeCell(_)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),d.jsxs("div",{className:"univer-mt-6 univer-flex univer-justify-between",children:[d.jsx(f.Button,{variant:"primary",onClick:me,disabled:ue,children:s.t("find-replace.dialog.find")}),d.jsxs("span",{className:"univer-inline-flex univer-gap-2",children:[d.jsx(f.Button,{disabled:he,onClick:ve,children:s.t("find-replace.dialog.replace")}),d.jsx(f.Button,{disabled:pe,onClick:Se,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function Be(){const t=l.useDependency(C),e=l.useDependency(l.ILayoutService),n=l.useDependency(c.IContextService),i=l.useObservable(t.state$,void 0,!0),s=h.useRef(null);h.useEffect(()=>{let p;return s.current&&(p=e.registerContainerElement(s.current)),()=>p==null?void 0:p.dispose()},[e]);const r=h.useRef(null),a=h.useCallback(p=>n.setContextValue(Z,p),[n]),o=h.useCallback(p=>n.setContextValue(Y,p),[n]);return h.useEffect(()=>{var v;const p=m.fromEvent(document,"focusin").subscribe(S=>{var g;S.target&&((g=s.current)!=null&&g.contains(S.target))?a(!0):a(!1),!r.current||!r.current.selectHasFocus()?o(!0):o(!1)});return(v=r.current)==null||v.focus(),a(!0),o(!0),()=>{p.unsubscribe(),a(!1)}},[a,o]),d.jsx("div",{ref:s,"data-u-comp":"find-replace-dialog",children:i.replaceRevealed?d.jsx(ke,{ref:r}):d.jsx(Ue,{ref:r})})}function We(t){const e=t.getCurrentLocale();return h.useMemo(()=>[{label:t.t("find-replace.dialog.find-scope.current-sheet"),value:P.SUBUNIT},{label:t.t("find-replace.dialog.find-scope.workbook"),value:P.UNIT}],[e])}function Ge(t){const e=t.getCurrentLocale();return h.useMemo(()=>[{label:t.t("find-replace.dialog.find-direction.row"),value:T.ROW},{label:t.t("find-replace.dialog.find-direction.column"),value:T.COLUMN}],[e])}function Ve(t){const e=t.getCurrentLocale();return h.useMemo(()=>[{label:t.t("find-replace.dialog.find-by.value"),value:O.VALUE},{label:t.t("find-replace.dialog.find-by.formula"),value:O.FORMULA}],[e])}function I(t){return t.getContextValue(Z)}function Ke(t){return t.getContextValue(J)}function ne(t){return t.getContextValue(Y)}const F="7_find-replace-shortcuts";function B(t){return t.getContextValue(c.FOCUSING_SHEET)}function W(t){return!t.getContextValue(c.EDITOR_ACTIVATED)}const He={id:y.id,description:"find-replace.shortcut.open-find-dialog",binding:l.KeyCode.F|l.MetaKeys.CTRL_COMMAND,group:F,preconditions(t){return!I(t)&&B(t)&&W(t)}},qe={id:y.id,description:"find-replace.shortcut.open-find-dialog",binding:l.KeyCode.F|l.MetaKeys.CTRL_COMMAND,mac:l.KeyCode.F|l.MetaKeys.MAC_CTRL,preconditions(t){return!I(t)&&B(t)&&W(t)}},ze={id:N.id,description:"find-replace.shortcut.open-replace-dialog",binding:l.KeyCode.H|l.MetaKeys.CTRL_COMMAND,mac:l.KeyCode.H|l.MetaKeys.MAC_CTRL,group:F,preconditions(t){return B(t)&&W(t)&&(!I(t)||!Ke(t))}},Ye={id:U.id,description:"find-replace.shortcut.go-to-next-match",binding:l.KeyCode.ENTER,group:F,priority:1e3,preconditions(t){return ne(t)&&I(t)}},Ze={id:k.id,description:"find-replace.shortcut.go-to-previous-match",binding:l.KeyCode.ENTER|l.MetaKeys.SHIFT,group:F,priority:1e3,preconditions(t){return ne(t)&&I(t)}},Je={id:ee.id,description:"find-replace.shortcut.focus-selection",binding:l.KeyCode.ESC,group:F,priority:1e3,preconditions(t){return I(t)}};function Qe(t){const e=t.get(c.IContextService);return{id:y.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",type:l.MenuItemType.BUTTON,hidden$:l.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:m.combineLatest([e.subscribeContextValue$(c.EDITOR_ACTIVATED),e.subscribeContextValue$(c.FOCUSING_SHEET)]).pipe(m.map(([n,i])=>n||!i))}}const Xe={[l.RibbonStartGroup.OTHERS]:{[y.id]:{order:2,menuItemFactory:Qe}}};var et=Object.getOwnPropertyDescriptor,tt=(t,e,n,i)=>{for(var s=i>1?void 0:i?et(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=a(s)||s);return s},M=(t,e)=>(n,i)=>e(n,i,t);const V="DESKTOP_FIND_REPLACE_DIALOG",se=350,it=20,nt=64;exports.FindReplaceController=class extends c.RxDisposable{constructor(n,i,s,r,a,o,p,v,S,g){super();u(this,"_closingListenerDisposable");this._univerInstanceService=n,this._menuManagerService=i,this._shortcutService=s,this._commandService=r,this._findReplaceService=a,this._dialogService=o,this._layoutService=p,this._localeService=v,this._componentManager=S,this._injector=g,this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var n;super.dispose(),(n=this._closingListenerDisposable)==null||n.dispose(),this._closingListenerDisposable=null}_initCommands(){[y,N,U,k,w,A,ee].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initShortcuts(){[ze,He,qe,Ze,Ye,Je].forEach(n=>this.disposeWithMe(this._shortcutService.registerShortcut(n)))}_initUI(){this.disposeWithMe(this._componentManager.register("FindReplaceDialog",Be)),this.disposeWithMe(this._componentManager.register("SearchIcon",z)),this._menuManagerService.mergeMenu(Xe),this._findReplaceService.stateUpdates$.pipe(m.takeUntil(this.dispose$)).subscribe(n=>{n.revealed===!0&&this._openPanel()})}_openPanel(){this._dialogService.open({id:V,draggable:!0,width:se,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,mask:!1,maskClosable:!1,defaultPosition:st(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()}),this._closingListenerDisposable=c.toDisposable(this._univerInstanceService.focused$.pipe(m.takeUntil(this.dispose$)).subscribe(n=>{(!n||!this._univerInstanceService.getUniverSheetInstance(n))&&this.closePanel()}))}closePanel(){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(V),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}};exports.FindReplaceController=tt([M(0,c.IUniverInstanceService),M(1,l.IMenuManagerService),M(2,l.IShortcutService),M(3,c.ICommandService),M(4,C),M(5,l.IDialogService),M(6,l.ILayoutService),M(7,c.Inject(c.LocaleService)),M(8,c.Inject(l.ComponentManager)),M(9,c.Inject(c.Injector))],exports.FindReplaceController);function st(){const{innerWidth:t}=window;return{x:t-se-it,y:nt}}var rt=Object.getOwnPropertyDescriptor,at=(t,e,n,i)=>{for(var s=i>1?void 0:i?rt(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=a(s)||s);return s},K=(t,e)=>(n,i)=>e(n,i,t);const ot="UNIVER_FIND_REPLACE_PLUGIN";var j;exports.UniverFindReplacePlugin=(j=class extends c.Plugin{constructor(e=G,n,i){super(),this._config=e,this._injector=n,this._configService=i;const{...s}=c.merge({},G,this._config);this._configService.setConfig(Te,s)}onStarting(){[[exports.FindReplaceController],[C,{useClass:$}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(exports.FindReplaceController)}},u(j,"pluginName",ot),j);exports.UniverFindReplacePlugin=at([K(1,c.Inject(c.Injector)),K(2,c.IConfigService)],exports.UniverFindReplacePlugin);exports.FindBy=O;exports.FindDirection=T;exports.FindModel=$e;exports.FindReplaceState=X;exports.FindScope=P;exports.GoToNextMatchOperation=U;exports.GoToPreviousMatchOperation=k;exports.IFindReplaceService=C;exports.OpenFindDialogOperation=y;exports.OpenReplaceDialogOperation=N;exports.ReplaceAllMatchesCommand=w;exports.ReplaceCurrentMatchCommand=A;exports.createInitFindReplaceState=E;
|
|
1
|
+
"use strict";var Fe=Object.defineProperty;var xe=(t,e,n)=>e in t?Fe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var u=(t,e,n)=>xe(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),l=require("@univerjs/ui"),m=require("rxjs"),f=require("@univerjs/design"),De=require("@univerjs/engine-render"),d=require("react/jsx-runtime"),h=require("react"),Te="find-replace.config",G={};var b=function(){return b=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},b.apply(this,arguments)},Oe=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(n[i[s]]=t[i[s]]);return n},H=h.forwardRef(function(t,e){var n=t.icon,i=t.id,s=t.className,r=t.extend,a=Oe(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(s||"").trim(),p=h.useRef("_".concat(Ne()));return q(n,"".concat(i),{defIds:n.defIds,idSuffix:p.current},b({ref:e,className:o},a),r)});function q(t,e,n,i,s){return h.createElement(t.tag,b(b({key:e},Pe(t,n,s)),i),(Ee(t,n).children||[]).map(function(r,a){return q(r,"".concat(e,"-").concat(t.tag,"-").concat(a),n,void 0,s)}))}function Pe(t,e,n){var i=b({},t.attrs);n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1),t.tag==="mask"&&i.id&&(i.id=i.id+e.idSuffix),Object.entries(i).forEach(function(r){var a=r[0],o=r[1];a==="mask"&&typeof o=="string"&&(i[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(r){var a=r[0],o=r[1];typeof o=="string"&&(i[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function Ee(t,e){var n,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((n=t.children)===null||n===void 0)&&n.length)?b(b({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&i&&i.indexOf(s.attrs.id)>-1?b(b({},s),{attrs:b(b({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function Ne(){return Math.random().toString(36).substring(2,8)}H.displayName="UniverIcon";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.71899 1.36938C4.37604 1.36938 1.66602 4.07941 1.66602 7.42236C1.66602 10.7653 4.37604 13.4753 7.71899 13.4753C9.16744 13.4753 10.4971 12.9666 11.5389 12.118L13.6598 14.4109C13.8848 14.6542 14.2644 14.669 14.5077 14.444C14.7509 14.219 14.7657 13.8393 14.5407 13.5961L12.3906 11.2716C13.2536 10.2254 13.772 8.88442 13.772 7.42236C13.772 4.07941 11.0619 1.36938 7.71899 1.36938ZM2.86602 7.42236C2.86602 4.74215 5.03878 2.56938 7.71899 2.56938C10.3992 2.56938 12.572 4.74215 12.572 7.42236C12.572 10.1026 10.3992 12.2753 7.71899 12.2753C5.03878 12.2753 2.86602 10.1026 2.86602 7.42236Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Z=h.forwardRef(function(t,e){return h.createElement(H,Object.assign({},t,{id:"search-single",ref:e,icon:Le}))});Z.displayName="SearchSingle";const z="FIND_REPLACE_INPUT_FOCUS",Y="FIND_REPLACE_DIALOG_FOCUS",J="FIND_REPLACE_REPLACE_REVEALED";var je=Object.getOwnPropertyDescriptor,Q=(t,e,n,i)=>{for(var s=i>1?void 0:i?je(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=a(s)||s);return s},D=(t,e)=>(n,i)=>e(n,i,t);class $e extends c.Disposable{}const C=c.createIdentifier("find-replace.service");function Ae(t){return typeof t.findString<"u"||typeof t.inputtingFindString<"u"||typeof t.findDirection<"u"||typeof t.matchesTheWholeCell<"u"||typeof t.caseSensitive<"u"||typeof t.findScope<"u"||typeof t.findBy<"u"}exports.FindReplaceModel=class extends c.Disposable{constructor(n,i,s,r){super();u(this,"currentMatch$",new m.BehaviorSubject(null));u(this,"replaceables$",new m.BehaviorSubject([]));u(this,"_findModels",[]);u(this,"_matchingModel",null);u(this,"_matches",[]);u(this,"_currentSearchingDisposables",null);this._state=n,this._providers=i,this._univerInstanceService=s,this._commandService=r,this.disposeWithMe(this._state.stateUpdates$.pipe(m.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async a=>{const o=this._state.state;Ae(a)&&(o.findString!==""&&!o.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):a.replaceRevealed!==!0&&this._stopSearching())}))}get searched(){return this._findModels.length>0}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...E(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const n=await this._startSearching();return this._state.changeState({findCompleted:!0}),n}focusSelection(){var n;(n=this._matchingModel)==null||n.focusSelection()}async _startSearching(){if(!this._state.findString)return{results:[]};const n=Array.from(this._providers),i=this._findModels=(await Promise.all(n.map(r=>r.find({findString:this._state.findString,findDirection:this._state.findDirection,findScope:this._state.findScope,findBy:this._state.findBy,replaceRevealed:this._state.replaceRevealed,caseSensitive:this._state.caseSensitive,matchesTheWholeCell:this._state.matchesTheWholeCell})))).flat();this._subscribeToModelsChanges(i);const s=this._matches=i.map(r=>r.getMatches()).flat();return this.replaceables$.next(s.filter(r=>r.replaceable)),s.length?(this._moveToInitialMatch(i),this._state.changeState({matchesCount:s.length}),{results:s}):(this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]})}_stopSearching(){var n;this._providers.forEach(i=>i.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(n=this._currentSearchingDisposables)==null||n.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(n){const i=this._currentSearchingDisposables=new c.DisposableCollection,s=m.combineLatest(n.map(r=>r.matchesUpdate$)).pipe(m.debounceTime(220)).subscribe(([...r])=>{const a=this._matches=r.flat();a.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:a.length}),this.replaceables$.next(a.filter(o=>o.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});n.forEach(r=>i.add(c.toDisposable(r.activelyChangingMatch$.subscribe(a=>{const o=this._matches.findIndex(p=>p===a);this._state.changeState({matchesPosition:o+1})})))),i.add(c.toDisposable(s))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const n=await Promise.all(this._findModels.map(i=>i.replaceAll(this._state.replaceString))).then(i=>i.reduce((s,r)=>(s.success+=r.success,s.failure+=r.failure,s),{success:0,failure:0}));return n.failure===0&&this._stopSearching(),n}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}_markMatch(n){const i=this._matches.findIndex(s=>s===n);this.currentMatch$.next(n),this._state.changeState({matchesPosition:i+1})}moveToNextMatch(){if(!this._matchingModel)return;const n=this._findModels.length===1,i=this._matchingModel.moveToNextMatch({loop:n});if(i)return this._markMatch(i),i;{const s=this._findModels.findIndex(r=>r===this._matchingModel);return this._moveToNextUnitMatch(s)}}_moveToNextUnitMatch(n){const i=this._findModels.length;for(let s=(n+1)%i;s!==n;){const r=this._findModels[s],a=r.moveToNextMatch({ignoreSelection:!0});if(a)return this._matchingModel=r,this._markMatch(a),a;s=(s+1)%i}if(this._matchingModel){const s=this._matchingModel.moveToNextMatch({ignoreSelection:!0});return s&&this._markMatch(s),s}}moveToPreviousMatch(){if(!this._matchingModel)return;const n=this._findModels.length===1,i=this._matchingModel.moveToPreviousMatch({loop:n});if(i){const s=this._matches.findIndex(r=>r===i);return this.currentMatch$.next(i),this._state.changeState({matchesPosition:s+1}),i}else{const s=this._findModels.length,r=this._findModels.findIndex(o=>o===this._matchingModel);for(let o=(r-1+s)%s;o!==r;){const p=this._findModels[o],v=p.moveToPreviousMatch({ignoreSelection:!0});if(v)return this._matchingModel=p,this._markMatch(v),v;o=(o-1)%s}const a=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});return a&&this._markMatch(a),a}}_moveToInitialMatch(n,i=!1){var a;const s=(a=this._univerInstanceService.getFocusedUnit())==null?void 0:a.getUnitId();if(!s)return-1;const r=n.findIndex(o=>o.unitId===s);if(r!==-1){this._matchingModel=n[r];const o=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus:i});if(o)return this._markMatch(o),r}return this._moveToNextUnitMatch(r),0}};exports.FindReplaceModel=Q([D(2,c.IUniverInstanceService),D(3,c.ICommandService)],exports.FindReplaceModel);var T=(t=>(t.ROW="row",t.COLUMN="column",t))(T||{}),O=(t=>(t.VALUE="value",t.FORMULA="formula",t))(O||{}),P=(t=>(t.SUBUNIT="subunit",t.UNIT="unit",t))(P||{});function E(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class X{constructor(){u(this,"_stateUpdates$",new m.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new m.BehaviorSubject(E()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_inputtingFindString","");u(this,"_replaceString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0);u(this,"_caseSensitive",!0);u(this,"_matchesTheWholeCell",!1);u(this,"_findDirection","row");u(this,"_findScope","subunit");u(this,"_findBy","value");u(this,"_findCompleted",!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let n=!1;const i={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,i.findString=this._findString,n=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,i.revealed=e.revealed,n=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,i.replaceRevealed=e.replaceRevealed,n=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,i.replaceString=e.replaceString,n=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,i.matchesCount=e.matchesCount,n=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,i.matchesPosition=e.matchesPosition,n=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,i.findBy=e.findBy,n=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,i.findScope=e.findScope,n=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,i.findDirection=e.findDirection,n=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,i.caseSensitive=e.caseSensitive,n=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,i.matchesTheWholeCell=e.matchesTheWholeCell,n=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,i.inputtingFindString=e.inputtingFindString,n=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,i.findCompleted=e.findCompleted,n=!0),n&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(i))}}let $=class extends c.Disposable{constructor(e,n){super();u(this,"_providers",new Set);u(this,"_state",new X);u(this,"_model");u(this,"_currentMatch$",new m.BehaviorSubject(null));u(this,"currentMatch$",this._currentMatch$.asObservable());u(this,"_replaceables$",new m.BehaviorSubject([]));u(this,"replaceables$",this._replaceables$.asObservable());u(this,"_focusSignal$",new m.Subject);u(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=n}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getProviders(){return this._providers}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e==="formula")}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}focusSelection(){var e;(e=this._model)==null||e.focusSelection()}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(exports.FindReplaceModel,this._state,this._providers),this._model.currentMatch$.subscribe(i=>this._currentMatch$.next(i)),this._model.replaceables$.subscribe(i=>this._replaceables$.next(i));const n=E();return e&&(n.replaceRevealed=!0),this._state.changeState(n),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),c.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(J,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(De.RENDER_RAW_FORMULA_KEY,e)}};$=Q([D(0,c.Inject(c.Injector)),D(1,c.IContextService)],$);const A={id:"ui.command.replace-current-match",type:c.CommandType.COMMAND,handler:t=>t.get(C).replace()},we="CONFIRM_REPLACE_ALL",w={id:"ui.command.replace-all-matches",type:c.CommandType.COMMAND,handler:async t=>{const e=t.get(l.IConfirmService),n=t.get(c.LocaleService),i=t.get(l.IMessageService);if(!await e.confirm({id:we,title:{title:n.t("find-replace.replace.confirm.title")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")}))return!1;const r=await t.get(C).replaceAll(),{success:a,failure:o}=r;return o>0?(a===0?i.show({type:f.MessageType.Error,content:n.t("find-replace.replace.all-failure")}):i.show({type:f.MessageType.Warning,content:n.t("find-replace.replace.partial-success",`${a}`,`${o}`)}),!1):(i.show({type:f.MessageType.Success,content:n.t("find-replace.replace.all-success",`${a}`)}),!0)}},y={id:"ui.operation.open-find-dialog",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(C);return e.revealed?e.focusFindInput():e.start(),!0}},N={id:"ui.operation.open-replace-dialog",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(C);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},U={type:c.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(C).moveToNextMatch(),!0)},k={type:c.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(C).moveToPreviousMatch(),!0)},ee={type:c.CommandType.OPERATION,id:"ui.operation.focus-selection",handler:t=>(t.get(C).focusSelection(),!0)};function te(t){const{findCompleted:e,localeService:n,matchesCount:i,matchesPosition:s,findString:r,findReplaceService:a,onChange:o,...p}=t,S=e&&i===0?n.t("find-replace.dialog.no-result"):i===0?" ":void 0;return d.jsx("div",{className:"univer-relative univer-flex univer-items-center univer-gap-2",onDrag:g=>g.stopPropagation(),children:d.jsx(f.Input,{"data-u-comp":"search-input",autoFocus:!0,placeholder:n.t("find-replace.dialog.find-placeholder"),value:r,onChange:g=>o==null?void 0:o(g),slot:d.jsx(f.Pager,{loop:!0,text:S,value:s,total:i,onChange:g=>{s===i&&g===1?a.moveToNextMatch():s===1&&g===i||g<s?a.moveToPreviousMatch():a.moveToNextMatch()}}),...p})})}function ie(t,e){const n=h.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),i=h.useCallback(()=>{const s=document.querySelectorAll("[data-u-comp=find-replace-dialog] [data-u-comp=search-input]");return Array.from(s).some(r=>r===document.activeElement)},[]);return h.useImperativeHandle(e,()=>({focus:n,selectHasFocus:i})),h.useEffect(()=>{const s=t.focusSignal$.subscribe(()=>n());return()=>s.unsubscribe()},[t,n]),{focus:n,selectHasFocus:i}}const Ue=h.forwardRef(function(e,n){const i=l.useDependency(c.LocaleService),s=l.useDependency(C),r=l.useDependency(c.ICommandService),a=l.useObservable(s.state$,void 0,!0),{findCompleted:o,findString:p,matchesCount:v,matchesPosition:S}=a,g=h.useCallback(()=>{r.executeCommand(N.id)},[r]),x=h.useCallback(R=>s.changeFindString(R),[s]);return ie(s,n),d.jsxs(d.Fragment,{children:[d.jsx(te,{findCompleted:o,className:"univer-find-input",matchesCount:v,matchesPosition:S,findReplaceService:s,localeService:i,findString:p,onChange:x}),d.jsx("div",{className:"univer-mt-4 univer-text-center",children:d.jsx("a",{className:"univer-cursor-pointer univer-text-sm univer-text-primary-500 univer-transition-colors hover:univer-text-primary-500/80",onClick:g,children:i.t("find-replace.dialog.advanced-finding")})})]})}),ke=h.forwardRef(function(e,n){const i=l.useDependency(C),s=l.useDependency(c.LocaleService),r=l.useDependency(c.ICommandService),a=l.useDependency(l.IMessageService),o=l.useObservable(i.currentMatch$,void 0,!0),p=l.useObservable(i.replaceables$,void 0,!0),v=l.useObservable(i.state$,void 0,!0),{matchesCount:S,matchesPosition:g,findString:x,inputtingFindString:R,replaceString:re,caseSensitive:ae,matchesTheWholeCell:oe,findDirection:ce,findScope:le,findBy:de,findCompleted:L}=v,ue=R.length===0,he=S===0||!(o!=null&&o.replaceable),pe=p.length===0,fe=h.useCallback(_=>i.changeInputtingFindString(_),[i]),ge=h.useCallback(_=>i.changeReplaceString(_),[i]),{focus:_e}=ie(i,n),me=h.useCallback(()=>{x===R?i.moveToNextMatch():(i.changeFindString(R),i.find())},[x,R,i]),ve=h.useCallback(()=>r.executeCommand(A.id),[r]),Se=h.useCallback(async()=>{await r.executeCommand(w.id),_e()},[r]),Ce=h.useCallback(_=>{i.changeFindDirection(_)},[i]),be=h.useCallback(_=>{i.changeFindScope(_)},[i]),Me=h.useCallback(_=>{i.changeFindBy(_)},[i]),Re=We(s),ye=Ge(s),Ie=Ve(s);return h.useEffect(()=>{L&&S===0&&a.show({content:s.t("find-replace.dialog.no-match"),type:f.MessageType.Warning,duration:5e3})},[L,S,a,s]),d.jsxs("div",{children:[d.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find"),children:d.jsx(te,{findCompleted:L,className:"univer-find-input",matchesCount:S,matchesPosition:g,findReplaceService:i,localeService:s,findString:R,onChange:fe})}),d.jsx(f.FormLayout,{label:s.t("find-replace.dialog.replace"),children:d.jsx(f.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:re,onChange:_=>ge(_)})}),d.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:d.jsx(f.Select,{value:ce,options:ye,onChange:Ce})}),d.jsx(f.FormDualColumnLayout,{children:d.jsxs(d.Fragment,{children:[d.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:d.jsx(f.Select,{value:le,options:Re,onChange:be})}),d.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:d.jsx(f.Select,{value:de,options:Ie,onChange:Me})})]})}),d.jsx(f.FormDualColumnLayout,{children:d.jsxs(d.Fragment,{children:[d.jsx(f.FormLayout,{children:d.jsx(f.Checkbox,{checked:ae,onChange:_=>{i.changeCaseSensitive(_)},children:s.t("find-replace.dialog.case-sensitive")})}),d.jsx(f.FormLayout,{children:d.jsx(f.Checkbox,{checked:oe,onChange:_=>{i.changeMatchesTheWholeCell(_)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),d.jsxs("div",{className:"univer-mt-6 univer-flex univer-justify-between",children:[d.jsx(f.Button,{variant:"primary",onClick:me,disabled:ue,children:s.t("find-replace.dialog.find")}),d.jsxs("span",{className:"univer-inline-flex univer-gap-2",children:[d.jsx(f.Button,{disabled:he,onClick:ve,children:s.t("find-replace.dialog.replace")}),d.jsx(f.Button,{disabled:pe,onClick:Se,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function Be(){const t=l.useDependency(C),e=l.useDependency(l.ILayoutService),n=l.useDependency(c.IContextService),i=l.useObservable(t.state$,void 0,!0),s=h.useRef(null);h.useEffect(()=>{let p;return s.current&&(p=e.registerContainerElement(s.current)),()=>p==null?void 0:p.dispose()},[e]);const r=h.useRef(null),a=h.useCallback(p=>n.setContextValue(Y,p),[n]),o=h.useCallback(p=>n.setContextValue(z,p),[n]);return h.useEffect(()=>{var v;const p=m.fromEvent(document,"focusin").subscribe(S=>{var g;S.target&&((g=s.current)!=null&&g.contains(S.target))?a(!0):a(!1),!r.current||!r.current.selectHasFocus()?o(!0):o(!1)});return(v=r.current)==null||v.focus(),a(!0),o(!0),()=>{p.unsubscribe(),a(!1)}},[a,o]),d.jsx("div",{ref:s,"data-u-comp":"find-replace-dialog",children:i.replaceRevealed?d.jsx(ke,{ref:r}):d.jsx(Ue,{ref:r})})}function We(t){const e=t.getCurrentLocale();return h.useMemo(()=>[{label:t.t("find-replace.dialog.find-scope.current-sheet"),value:P.SUBUNIT},{label:t.t("find-replace.dialog.find-scope.workbook"),value:P.UNIT}],[e])}function Ge(t){const e=t.getCurrentLocale();return h.useMemo(()=>[{label:t.t("find-replace.dialog.find-direction.row"),value:T.ROW},{label:t.t("find-replace.dialog.find-direction.column"),value:T.COLUMN}],[e])}function Ve(t){const e=t.getCurrentLocale();return h.useMemo(()=>[{label:t.t("find-replace.dialog.find-by.value"),value:O.VALUE},{label:t.t("find-replace.dialog.find-by.formula"),value:O.FORMULA}],[e])}function I(t){return t.getContextValue(Y)}function Ke(t){return t.getContextValue(J)}function ne(t){return t.getContextValue(z)}const F="7_find-replace-shortcuts";function B(t){return t.getContextValue(c.FOCUSING_SHEET)}function W(t){return!t.getContextValue(c.EDITOR_ACTIVATED)}const He={id:y.id,description:"find-replace.shortcut.open-find-dialog",binding:l.KeyCode.F|l.MetaKeys.CTRL_COMMAND,group:F,preconditions(t){return!I(t)&&B(t)&&W(t)}},qe={id:y.id,description:"find-replace.shortcut.open-find-dialog",binding:l.KeyCode.F|l.MetaKeys.CTRL_COMMAND,mac:l.KeyCode.F|l.MetaKeys.MAC_CTRL,preconditions(t){return!I(t)&&B(t)&&W(t)}},Ze={id:N.id,description:"find-replace.shortcut.open-replace-dialog",binding:l.KeyCode.H|l.MetaKeys.CTRL_COMMAND,mac:l.KeyCode.H|l.MetaKeys.MAC_CTRL,group:F,preconditions(t){return B(t)&&W(t)&&(!I(t)||!Ke(t))}},ze={id:U.id,description:"find-replace.shortcut.go-to-next-match",binding:l.KeyCode.ENTER,group:F,priority:1e3,preconditions(t){return ne(t)&&I(t)}},Ye={id:k.id,description:"find-replace.shortcut.go-to-previous-match",binding:l.KeyCode.ENTER|l.MetaKeys.SHIFT,group:F,priority:1e3,preconditions(t){return ne(t)&&I(t)}},Je={id:ee.id,description:"find-replace.shortcut.focus-selection",binding:l.KeyCode.ESC,group:F,priority:1e3,preconditions(t){return I(t)}};function Qe(t){const e=t.get(c.IContextService);return{id:y.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",type:l.MenuItemType.BUTTON,hidden$:l.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:m.combineLatest([e.subscribeContextValue$(c.EDITOR_ACTIVATED),e.subscribeContextValue$(c.FOCUSING_SHEET)]).pipe(m.map(([n,i])=>n||!i))}}const Xe={[l.RibbonDataGroup.ORGANIZATION]:{[y.id]:{order:2,menuItemFactory:Qe}}};var et=Object.getOwnPropertyDescriptor,tt=(t,e,n,i)=>{for(var s=i>1?void 0:i?et(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=a(s)||s);return s},M=(t,e)=>(n,i)=>e(n,i,t);const V="DESKTOP_FIND_REPLACE_DIALOG",se=350,it=20,nt=64;exports.FindReplaceController=class extends c.RxDisposable{constructor(n,i,s,r,a,o,p,v,S,g){super();u(this,"_closingListenerDisposable");this._univerInstanceService=n,this._menuManagerService=i,this._shortcutService=s,this._commandService=r,this._findReplaceService=a,this._dialogService=o,this._layoutService=p,this._localeService=v,this._componentManager=S,this._injector=g,this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var n;super.dispose(),(n=this._closingListenerDisposable)==null||n.dispose(),this._closingListenerDisposable=null}_initCommands(){[y,N,U,k,w,A,ee].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initShortcuts(){[Ze,He,qe,Ye,ze,Je].forEach(n=>this.disposeWithMe(this._shortcutService.registerShortcut(n)))}_initUI(){[["FindReplaceDialog",Be],["SearchIcon",Z]].forEach(([n,i])=>{this.disposeWithMe(this._componentManager.register(n,i))}),this._menuManagerService.mergeMenu(Xe),this._findReplaceService.stateUpdates$.pipe(m.takeUntil(this.dispose$)).subscribe(n=>{n.revealed===!0&&this._openPanel()})}_openPanel(){this._dialogService.open({id:V,draggable:!0,width:se,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,mask:!1,maskClosable:!1,defaultPosition:st(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()}),this._closingListenerDisposable=c.toDisposable(this._univerInstanceService.focused$.pipe(m.takeUntil(this.dispose$)).subscribe(n=>{(!n||!this._univerInstanceService.getUniverSheetInstance(n))&&this.closePanel()}))}closePanel(){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(V),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}};exports.FindReplaceController=tt([M(0,c.IUniverInstanceService),M(1,l.IMenuManagerService),M(2,l.IShortcutService),M(3,c.ICommandService),M(4,C),M(5,l.IDialogService),M(6,l.ILayoutService),M(7,c.Inject(c.LocaleService)),M(8,c.Inject(l.ComponentManager)),M(9,c.Inject(c.Injector))],exports.FindReplaceController);function st(){const{innerWidth:t}=window;return{x:t-se-it,y:nt}}var rt=Object.getOwnPropertyDescriptor,at=(t,e,n,i)=>{for(var s=i>1?void 0:i?rt(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=a(s)||s);return s},K=(t,e)=>(n,i)=>e(n,i,t);const ot="UNIVER_FIND_REPLACE_PLUGIN";var j;exports.UniverFindReplacePlugin=(j=class extends c.Plugin{constructor(e=G,n,i){super(),this._config=e,this._injector=n,this._configService=i;const{...s}=c.merge({},G,this._config);this._configService.setConfig(Te,s)}onStarting(){[[exports.FindReplaceController],[C,{useClass:$}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(exports.FindReplaceController)}},u(j,"pluginName",ot),j);exports.UniverFindReplacePlugin=at([K(1,c.Inject(c.Injector)),K(2,c.IConfigService)],exports.UniverFindReplacePlugin);exports.FindBy=O;exports.FindDirection=T;exports.FindModel=$e;exports.FindReplaceState=X;exports.FindScope=P;exports.GoToNextMatchOperation=U;exports.GoToPreviousMatchOperation=k;exports.IFindReplaceService=C;exports.OpenFindDialogOperation=y;exports.OpenReplaceDialogOperation=N;exports.ReplaceAllMatchesCommand=w;exports.ReplaceCurrentMatchCommand=A;exports.createInitFindReplaceState=E;
|
package/lib/es/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var st = Object.defineProperty;
|
|
2
2
|
var at = (t, e, n) => e in t ? st(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
3
|
var o = (t, e, n) => at(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
-
import { createIdentifier as ot, Inject as D, Injector as Q, IContextService as X, Disposable as ee, DisposableCollection as ct, toDisposable as $, IUniverInstanceService as fe, ICommandService as U, CommandType as b, LocaleService as
|
|
5
|
-
import { IConfirmService as pt, IMessageService as ge, useDependency as v, useObservable as x, ILayoutService as me, KeyCode as C, MetaKeys as y, getMenuHiddenObservable as _t, MenuItemType as gt,
|
|
4
|
+
import { createIdentifier as ot, Inject as D, Injector as Q, IContextService as X, Disposable as ee, DisposableCollection as ct, toDisposable as $, IUniverInstanceService as fe, ICommandService as U, CommandType as b, LocaleService as B, FOCUSING_SHEET as pe, EDITOR_ACTIVATED as _e, UniverInstanceType as lt, RxDisposable as dt, IConfigService as ht, Plugin as ut, merge as ft } from "@univerjs/core";
|
|
5
|
+
import { IConfirmService as pt, IMessageService as ge, useDependency as v, useObservable as x, ILayoutService as me, KeyCode as C, MetaKeys as y, getMenuHiddenObservable as _t, MenuItemType as gt, RibbonDataGroup as mt, IMenuManagerService as vt, IShortcutService as St, IDialogService as Ct, ComponentManager as Mt } from "@univerjs/ui";
|
|
6
6
|
import { throttleTime as Rt, BehaviorSubject as P, combineLatest as ve, debounceTime as bt, Subject as Se, fromEvent as It, map as yt, takeUntil as ae } from "rxjs";
|
|
7
|
-
import { MessageType as N, Input as Ce, Pager as Ft, FormLayout as R, Select as j, FormDualColumnLayout as oe, Checkbox as ce, Button as
|
|
7
|
+
import { MessageType as N, Input as Ce, Pager as Ft, FormLayout as R, Select as j, FormDualColumnLayout as oe, Checkbox as ce, Button as G } from "@univerjs/design";
|
|
8
8
|
import { RENDER_RAW_FORMULA_KEY as Dt } from "@univerjs/engine-render";
|
|
9
9
|
import { jsx as l, jsxs as I, Fragment as H } from "react/jsx-runtime";
|
|
10
|
-
import { forwardRef as
|
|
10
|
+
import { forwardRef as W, useRef as K, createElement as Me, useCallback as f, useEffect as A, useMemo as te, useImperativeHandle as xt } from "react";
|
|
11
11
|
const Pt = "find-replace.config", le = {};
|
|
12
12
|
var _ = function() {
|
|
13
13
|
return _ = Object.assign || function(t) {
|
|
@@ -17,23 +17,23 @@ var _ = function() {
|
|
|
17
17
|
}
|
|
18
18
|
return t;
|
|
19
19
|
}, _.apply(this, arguments);
|
|
20
|
-
},
|
|
20
|
+
}, Ot = function(t, e) {
|
|
21
21
|
var n = {};
|
|
22
22
|
for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
|
|
23
23
|
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
24
24
|
for (var r = 0, i = Object.getOwnPropertySymbols(t); r < i.length; r++)
|
|
25
25
|
e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, i[r]) && (n[i[r]] = t[i[r]]);
|
|
26
26
|
return n;
|
|
27
|
-
}, Re =
|
|
28
|
-
var n = t.icon, i = t.id, r = t.className, s = t.extend, a =
|
|
27
|
+
}, Re = W(function(t, e) {
|
|
28
|
+
var n = t.icon, i = t.id, r = t.className, s = t.extend, a = Ot(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), d = K("_".concat(Nt()));
|
|
29
29
|
return be(n, "".concat(i), { defIds: n.defIds, idSuffix: d.current }, _({ ref: e, className: c }, a), s);
|
|
30
30
|
});
|
|
31
31
|
function be(t, e, n, i, r) {
|
|
32
|
-
return Me(t.tag, _(_({ key: e },
|
|
32
|
+
return Me(t.tag, _(_({ key: e }, Tt(t, n, r)), i), (Et(t, n).children || []).map(function(s, a) {
|
|
33
33
|
return be(s, "".concat(e, "-").concat(t.tag, "-").concat(a), n, void 0, r);
|
|
34
34
|
}));
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function Tt(t, e, n) {
|
|
37
37
|
var i = _({}, t.attrs);
|
|
38
38
|
n != null && n.colorChannel1 && i.fill === "colorChannel1" && (i.fill = n.colorChannel1), t.tag === "mask" && i.id && (i.id = i.id + e.idSuffix), Object.entries(i).forEach(function(s) {
|
|
39
39
|
var a = s[0], c = s[1];
|
|
@@ -55,7 +55,7 @@ function Nt() {
|
|
|
55
55
|
return Math.random().toString(36).substring(2, 8);
|
|
56
56
|
}
|
|
57
57
|
Re.displayName = "UniverIcon";
|
|
58
|
-
var $t = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.71899 1.36938C4.37604 1.36938 1.66602 4.07941 1.66602 7.42236C1.66602 10.7653 4.37604 13.4753 7.71899 13.4753C9.16744 13.4753 10.4971 12.9666 11.5389 12.118L13.6598 14.4109C13.8848 14.6542 14.2644 14.669 14.5077 14.444C14.7509 14.219 14.7657 13.8393 14.5407 13.5961L12.3906 11.2716C13.2536 10.2254 13.772 8.88442 13.772 7.42236C13.772 4.07941 11.0619 1.36938 7.71899 1.36938ZM2.86602 7.42236C2.86602 4.74215 5.03878 2.56938 7.71899 2.56938C10.3992 2.56938 12.572 4.74215 12.572 7.42236C12.572 10.1026 10.3992 12.2753 7.71899 12.2753C5.03878 12.2753 2.86602 10.1026 2.86602 7.42236Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Ie =
|
|
58
|
+
var $t = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.71899 1.36938C4.37604 1.36938 1.66602 4.07941 1.66602 7.42236C1.66602 10.7653 4.37604 13.4753 7.71899 13.4753C9.16744 13.4753 10.4971 12.9666 11.5389 12.118L13.6598 14.4109C13.8848 14.6542 14.2644 14.669 14.5077 14.444C14.7509 14.219 14.7657 13.8393 14.5407 13.5961L12.3906 11.2716C13.2536 10.2254 13.772 8.88442 13.772 7.42236C13.772 4.07941 11.0619 1.36938 7.71899 1.36938ZM2.86602 7.42236C2.86602 4.74215 5.03878 2.56938 7.71899 2.56938C10.3992 2.56938 12.572 4.74215 12.572 7.42236C12.572 10.1026 10.3992 12.2753 7.71899 12.2753C5.03878 12.2753 2.86602 10.1026 2.86602 7.42236Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Ie = W(function(t, e) {
|
|
59
59
|
return Me(Re, Object.assign({}, t, {
|
|
60
60
|
id: "search-single",
|
|
61
61
|
ref: e,
|
|
@@ -222,7 +222,7 @@ q = xe([
|
|
|
222
222
|
L(2, fe),
|
|
223
223
|
L(3, U)
|
|
224
224
|
], q);
|
|
225
|
-
var
|
|
225
|
+
var Z = /* @__PURE__ */ ((t) => (t.ROW = "row", t.COLUMN = "column", t))(Z || {}), z = /* @__PURE__ */ ((t) => (t.VALUE = "value", t.FORMULA = "formula", t))(z || {}), Y = /* @__PURE__ */ ((t) => (t.SUBUNIT = "subunit", t.UNIT = "unit", t))(Y || {});
|
|
226
226
|
function ie() {
|
|
227
227
|
return {
|
|
228
228
|
caseSensitive: !1,
|
|
@@ -445,11 +445,11 @@ const Pe = {
|
|
|
445
445
|
id: "ui.command.replace-current-match",
|
|
446
446
|
type: b.COMMAND,
|
|
447
447
|
handler: (t) => t.get(g).replace()
|
|
448
|
-
}, Ut = "CONFIRM_REPLACE_ALL",
|
|
448
|
+
}, Ut = "CONFIRM_REPLACE_ALL", Oe = {
|
|
449
449
|
id: "ui.command.replace-all-matches",
|
|
450
450
|
type: b.COMMAND,
|
|
451
451
|
handler: async (t) => {
|
|
452
|
-
const e = t.get(pt), n = t.get(
|
|
452
|
+
const e = t.get(pt), n = t.get(B), i = t.get(ge);
|
|
453
453
|
if (!await e.confirm({
|
|
454
454
|
id: Ut,
|
|
455
455
|
title: { title: n.t("find-replace.replace.confirm.title") },
|
|
@@ -469,7 +469,7 @@ const Pe = {
|
|
|
469
469
|
content: n.t("find-replace.replace.all-success", `${a}`)
|
|
470
470
|
}), !0);
|
|
471
471
|
}
|
|
472
|
-
},
|
|
472
|
+
}, O = {
|
|
473
473
|
id: "ui.operation.open-find-dialog",
|
|
474
474
|
type: b.OPERATION,
|
|
475
475
|
handler: (t) => {
|
|
@@ -483,7 +483,7 @@ const Pe = {
|
|
|
483
483
|
const e = t.get(g);
|
|
484
484
|
return e.revealed ? e.replaceRevealed ? e.focusFindInput() : e.revealReplace() : e.start(!0), !0;
|
|
485
485
|
}
|
|
486
|
-
},
|
|
486
|
+
}, Te = {
|
|
487
487
|
type: b.OPERATION,
|
|
488
488
|
id: "ui.operation.go-to-next-match",
|
|
489
489
|
handler: (t) => (t.get(g).moveToNextMatch(), !0)
|
|
@@ -535,8 +535,8 @@ function Ae(t, e) {
|
|
|
535
535
|
return () => r.unsubscribe();
|
|
536
536
|
}, [t, n]), { focus: n, selectHasFocus: i };
|
|
537
537
|
}
|
|
538
|
-
const
|
|
539
|
-
const i = v(
|
|
538
|
+
const Bt = W(function(e, n) {
|
|
539
|
+
const i = v(B), r = v(g), s = v(U), a = x(r.state$, void 0, !0), { findCompleted: c, findString: d, matchesCount: S, matchesPosition: p } = a, u = f(() => {
|
|
540
540
|
s.executeCommand(ne.id);
|
|
541
541
|
}, [s]), E = f((M) => r.changeFindString(M), [r]);
|
|
542
542
|
return Ae(r, n), /* @__PURE__ */ I(H, { children: [
|
|
@@ -562,36 +562,36 @@ const Wt = B(function(e, n) {
|
|
|
562
562
|
}
|
|
563
563
|
) })
|
|
564
564
|
] });
|
|
565
|
-
}),
|
|
566
|
-
const i = v(g), r = v(
|
|
565
|
+
}), Wt = W(function(e, n) {
|
|
566
|
+
const i = v(g), r = v(B), s = v(U), a = v(ge), c = x(i.currentMatch$, void 0, !0), d = x(i.replaceables$, void 0, !0), S = x(i.state$, void 0, !0), {
|
|
567
567
|
matchesCount: p,
|
|
568
568
|
matchesPosition: u,
|
|
569
569
|
findString: E,
|
|
570
570
|
inputtingFindString: M,
|
|
571
571
|
replaceString: Ue,
|
|
572
|
-
caseSensitive:
|
|
573
|
-
matchesTheWholeCell:
|
|
572
|
+
caseSensitive: Be,
|
|
573
|
+
matchesTheWholeCell: We,
|
|
574
574
|
findDirection: ke,
|
|
575
575
|
findScope: je,
|
|
576
|
-
findBy:
|
|
576
|
+
findBy: Ge,
|
|
577
577
|
findCompleted: k
|
|
578
|
-
} = S,
|
|
578
|
+
} = S, Ve = M.length === 0, He = p === 0 || !(c != null && c.replaceable), Ke = d.length === 0, qe = f(
|
|
579
579
|
(h) => i.changeInputtingFindString(h),
|
|
580
580
|
[i]
|
|
581
|
-
),
|
|
581
|
+
), Ze = f(
|
|
582
582
|
(h) => i.changeReplaceString(h),
|
|
583
583
|
[i]
|
|
584
|
-
), { focus:
|
|
584
|
+
), { focus: ze } = Ae(i, n), Ye = f(() => {
|
|
585
585
|
E === M ? i.moveToNextMatch() : (i.changeFindString(M), i.find());
|
|
586
586
|
}, [E, M, i]), Je = f(() => s.executeCommand(Pe.id), [s]), Qe = f(async () => {
|
|
587
|
-
await s.executeCommand(
|
|
587
|
+
await s.executeCommand(Oe.id), ze();
|
|
588
588
|
}, [s]), Xe = f((h) => {
|
|
589
589
|
i.changeFindDirection(h);
|
|
590
590
|
}, [i]), et = f((h) => {
|
|
591
591
|
i.changeFindScope(h);
|
|
592
592
|
}, [i]), tt = f((h) => {
|
|
593
593
|
i.changeFindBy(h);
|
|
594
|
-
}, [i]), it = jt(r), nt =
|
|
594
|
+
}, [i]), it = jt(r), nt = Gt(r), rt = Vt(r);
|
|
595
595
|
return A(() => {
|
|
596
596
|
k && p === 0 && a.show({
|
|
597
597
|
content: r.t("find-replace.dialog.no-match"),
|
|
@@ -617,19 +617,19 @@ const Wt = B(function(e, n) {
|
|
|
617
617
|
{
|
|
618
618
|
placeholder: r.t("find-replace.dialog.replace-placeholder"),
|
|
619
619
|
value: Ue,
|
|
620
|
-
onChange: (h) =>
|
|
620
|
+
onChange: (h) => Ze(h)
|
|
621
621
|
}
|
|
622
622
|
) }),
|
|
623
623
|
/* @__PURE__ */ l(R, { label: r.t("find-replace.dialog.find-direction.title"), children: /* @__PURE__ */ l(j, { value: ke, options: nt, onChange: Xe }) }),
|
|
624
624
|
/* @__PURE__ */ l(oe, { children: /* @__PURE__ */ I(H, { children: [
|
|
625
625
|
/* @__PURE__ */ l(R, { label: r.t("find-replace.dialog.find-scope.title"), children: /* @__PURE__ */ l(j, { value: je, options: it, onChange: et }) }),
|
|
626
|
-
/* @__PURE__ */ l(R, { label: r.t("find-replace.dialog.find-by.title"), children: /* @__PURE__ */ l(j, { value:
|
|
626
|
+
/* @__PURE__ */ l(R, { label: r.t("find-replace.dialog.find-by.title"), children: /* @__PURE__ */ l(j, { value: Ge, options: rt, onChange: tt }) })
|
|
627
627
|
] }) }),
|
|
628
628
|
/* @__PURE__ */ l(oe, { children: /* @__PURE__ */ I(H, { children: [
|
|
629
629
|
/* @__PURE__ */ l(R, { children: /* @__PURE__ */ l(
|
|
630
630
|
ce,
|
|
631
631
|
{
|
|
632
|
-
checked:
|
|
632
|
+
checked: Be,
|
|
633
633
|
onChange: (h) => {
|
|
634
634
|
i.changeCaseSensitive(h);
|
|
635
635
|
},
|
|
@@ -639,7 +639,7 @@ const Wt = B(function(e, n) {
|
|
|
639
639
|
/* @__PURE__ */ l(R, { children: /* @__PURE__ */ l(
|
|
640
640
|
ce,
|
|
641
641
|
{
|
|
642
|
-
checked:
|
|
642
|
+
checked: We,
|
|
643
643
|
onChange: (h) => {
|
|
644
644
|
i.changeMatchesTheWholeCell(h);
|
|
645
645
|
},
|
|
@@ -648,10 +648,10 @@ const Wt = B(function(e, n) {
|
|
|
648
648
|
) })
|
|
649
649
|
] }) }),
|
|
650
650
|
/* @__PURE__ */ I("div", { className: "univer-mt-6 univer-flex univer-justify-between", children: [
|
|
651
|
-
/* @__PURE__ */ l(
|
|
651
|
+
/* @__PURE__ */ l(G, { variant: "primary", onClick: Ye, disabled: Ve, children: r.t("find-replace.dialog.find") }),
|
|
652
652
|
/* @__PURE__ */ I("span", { className: "univer-inline-flex univer-gap-2", children: [
|
|
653
|
-
/* @__PURE__ */ l(
|
|
654
|
-
/* @__PURE__ */ l(
|
|
653
|
+
/* @__PURE__ */ l(G, { disabled: He, onClick: Je, children: r.t("find-replace.dialog.replace") }),
|
|
654
|
+
/* @__PURE__ */ l(G, { disabled: Ke, onClick: Qe, children: r.t("find-replace.dialog.replace-all") })
|
|
655
655
|
] })
|
|
656
656
|
] })
|
|
657
657
|
] });
|
|
@@ -678,27 +678,27 @@ function kt() {
|
|
|
678
678
|
return (S = s.current) == null || S.focus(), a(!0), c(!0), () => {
|
|
679
679
|
d.unsubscribe(), a(!1);
|
|
680
680
|
};
|
|
681
|
-
}, [a, c]), /* @__PURE__ */ l("div", { ref: r, "data-u-comp": "find-replace-dialog", children: i.replaceRevealed ? /* @__PURE__ */ l(
|
|
681
|
+
}, [a, c]), /* @__PURE__ */ l("div", { ref: r, "data-u-comp": "find-replace-dialog", children: i.replaceRevealed ? /* @__PURE__ */ l(Wt, { ref: s }) : /* @__PURE__ */ l(Bt, { ref: s }) });
|
|
682
682
|
}
|
|
683
683
|
function jt(t) {
|
|
684
684
|
const e = t.getCurrentLocale();
|
|
685
685
|
return te(() => [
|
|
686
|
-
{ label: t.t("find-replace.dialog.find-scope.current-sheet"), value:
|
|
687
|
-
{ label: t.t("find-replace.dialog.find-scope.workbook"), value:
|
|
686
|
+
{ label: t.t("find-replace.dialog.find-scope.current-sheet"), value: Y.SUBUNIT },
|
|
687
|
+
{ label: t.t("find-replace.dialog.find-scope.workbook"), value: Y.UNIT }
|
|
688
688
|
], [e]);
|
|
689
689
|
}
|
|
690
|
-
function
|
|
690
|
+
function Gt(t) {
|
|
691
691
|
const e = t.getCurrentLocale();
|
|
692
692
|
return te(() => [
|
|
693
|
-
{ label: t.t("find-replace.dialog.find-direction.row"), value:
|
|
694
|
-
{ label: t.t("find-replace.dialog.find-direction.column"), value:
|
|
693
|
+
{ label: t.t("find-replace.dialog.find-direction.row"), value: Z.ROW },
|
|
694
|
+
{ label: t.t("find-replace.dialog.find-direction.column"), value: Z.COLUMN }
|
|
695
695
|
], [e]);
|
|
696
696
|
}
|
|
697
|
-
function
|
|
697
|
+
function Vt(t) {
|
|
698
698
|
const e = t.getCurrentLocale();
|
|
699
699
|
return te(() => [
|
|
700
|
-
{ label: t.t("find-replace.dialog.find-by.value"), value:
|
|
701
|
-
{ label: t.t("find-replace.dialog.find-by.formula"), value:
|
|
700
|
+
{ label: t.t("find-replace.dialog.find-by.value"), value: z.VALUE },
|
|
701
|
+
{ label: t.t("find-replace.dialog.find-by.formula"), value: z.FORMULA }
|
|
702
702
|
], [e]);
|
|
703
703
|
}
|
|
704
704
|
function F(t) {
|
|
@@ -710,7 +710,7 @@ function Ht(t) {
|
|
|
710
710
|
function Le(t) {
|
|
711
711
|
return t.getContextValue(ye);
|
|
712
712
|
}
|
|
713
|
-
const
|
|
713
|
+
const T = "7_find-replace-shortcuts";
|
|
714
714
|
function re(t) {
|
|
715
715
|
return t.getContextValue(pe);
|
|
716
716
|
}
|
|
@@ -718,44 +718,44 @@ function se(t) {
|
|
|
718
718
|
return !t.getContextValue(_e);
|
|
719
719
|
}
|
|
720
720
|
const Kt = {
|
|
721
|
-
id:
|
|
721
|
+
id: O.id,
|
|
722
722
|
description: "find-replace.shortcut.open-find-dialog",
|
|
723
723
|
binding: C.F | y.CTRL_COMMAND,
|
|
724
|
-
group:
|
|
724
|
+
group: T,
|
|
725
725
|
preconditions(t) {
|
|
726
726
|
return !F(t) && re(t) && se(t);
|
|
727
727
|
}
|
|
728
728
|
}, qt = {
|
|
729
|
-
id:
|
|
729
|
+
id: O.id,
|
|
730
730
|
description: "find-replace.shortcut.open-find-dialog",
|
|
731
731
|
binding: C.F | y.CTRL_COMMAND,
|
|
732
732
|
mac: C.F | y.MAC_CTRL,
|
|
733
733
|
preconditions(t) {
|
|
734
734
|
return !F(t) && re(t) && se(t);
|
|
735
735
|
}
|
|
736
|
-
},
|
|
736
|
+
}, Zt = {
|
|
737
737
|
id: ne.id,
|
|
738
738
|
description: "find-replace.shortcut.open-replace-dialog",
|
|
739
739
|
binding: C.H | y.CTRL_COMMAND,
|
|
740
740
|
mac: C.H | y.MAC_CTRL,
|
|
741
|
-
group:
|
|
741
|
+
group: T,
|
|
742
742
|
preconditions(t) {
|
|
743
743
|
return re(t) && se(t) && (!F(t) || !Ht(t));
|
|
744
744
|
}
|
|
745
|
-
},
|
|
746
|
-
id:
|
|
745
|
+
}, zt = {
|
|
746
|
+
id: Te.id,
|
|
747
747
|
description: "find-replace.shortcut.go-to-next-match",
|
|
748
748
|
binding: C.ENTER,
|
|
749
|
-
group:
|
|
749
|
+
group: T,
|
|
750
750
|
priority: 1e3,
|
|
751
751
|
preconditions(t) {
|
|
752
752
|
return Le(t) && F(t);
|
|
753
753
|
}
|
|
754
|
-
},
|
|
754
|
+
}, Yt = {
|
|
755
755
|
id: Ee.id,
|
|
756
756
|
description: "find-replace.shortcut.go-to-previous-match",
|
|
757
757
|
binding: C.ENTER | y.SHIFT,
|
|
758
|
-
group:
|
|
758
|
+
group: T,
|
|
759
759
|
priority: 1e3,
|
|
760
760
|
preconditions(t) {
|
|
761
761
|
return Le(t) && F(t);
|
|
@@ -764,7 +764,7 @@ const Kt = {
|
|
|
764
764
|
id: Ne.id,
|
|
765
765
|
description: "find-replace.shortcut.focus-selection",
|
|
766
766
|
binding: C.ESC,
|
|
767
|
-
group:
|
|
767
|
+
group: T,
|
|
768
768
|
priority: 1e3,
|
|
769
769
|
preconditions(t) {
|
|
770
770
|
return F(t);
|
|
@@ -773,7 +773,7 @@ const Kt = {
|
|
|
773
773
|
function Qt(t) {
|
|
774
774
|
const e = t.get(X);
|
|
775
775
|
return {
|
|
776
|
-
id:
|
|
776
|
+
id: O.id,
|
|
777
777
|
icon: "SearchIcon",
|
|
778
778
|
tooltip: "find-replace.toolbar",
|
|
779
779
|
type: gt.BUTTON,
|
|
@@ -785,8 +785,8 @@ function Qt(t) {
|
|
|
785
785
|
};
|
|
786
786
|
}
|
|
787
787
|
const Xt = {
|
|
788
|
-
[mt.
|
|
789
|
-
[
|
|
788
|
+
[mt.ORGANIZATION]: {
|
|
789
|
+
[O.id]: {
|
|
790
790
|
order: 2,
|
|
791
791
|
menuItemFactory: Qt
|
|
792
792
|
}
|
|
@@ -810,11 +810,11 @@ let w = class extends dt {
|
|
|
810
810
|
}
|
|
811
811
|
_initCommands() {
|
|
812
812
|
[
|
|
813
|
-
|
|
813
|
+
O,
|
|
814
814
|
ne,
|
|
815
|
-
Oe,
|
|
816
|
-
Ee,
|
|
817
815
|
Te,
|
|
816
|
+
Ee,
|
|
817
|
+
Oe,
|
|
818
818
|
Pe,
|
|
819
819
|
Ne
|
|
820
820
|
].forEach((e) => {
|
|
@@ -823,16 +823,23 @@ let w = class extends dt {
|
|
|
823
823
|
}
|
|
824
824
|
_initShortcuts() {
|
|
825
825
|
[
|
|
826
|
-
|
|
826
|
+
Zt,
|
|
827
827
|
Kt,
|
|
828
828
|
qt,
|
|
829
|
-
Zt,
|
|
830
829
|
Yt,
|
|
830
|
+
zt,
|
|
831
831
|
Jt
|
|
832
832
|
].forEach((e) => this.disposeWithMe(this._shortcutService.registerShortcut(e)));
|
|
833
833
|
}
|
|
834
834
|
_initUI() {
|
|
835
|
-
|
|
835
|
+
[
|
|
836
|
+
["FindReplaceDialog", kt],
|
|
837
|
+
["SearchIcon", Ie]
|
|
838
|
+
].forEach(([e, n]) => {
|
|
839
|
+
this.disposeWithMe(
|
|
840
|
+
this._componentManager.register(e, n)
|
|
841
|
+
);
|
|
842
|
+
}), this._menuManagerService.mergeMenu(Xt), this._findReplaceService.stateUpdates$.pipe(ae(this.dispose$)).subscribe((e) => {
|
|
836
843
|
e.revealed === !0 && this._openPanel();
|
|
837
844
|
});
|
|
838
845
|
}
|
|
@@ -865,7 +872,7 @@ w = ti([
|
|
|
865
872
|
m(4, g),
|
|
866
873
|
m(5, Ct),
|
|
867
874
|
m(6, me),
|
|
868
|
-
m(7, D(
|
|
875
|
+
m(7, D(B)),
|
|
869
876
|
m(8, D(Mt)),
|
|
870
877
|
m(9, D(Q))
|
|
871
878
|
], w);
|
|
@@ -879,8 +886,8 @@ var si = Object.getOwnPropertyDescriptor, ai = (t, e, n, i) => {
|
|
|
879
886
|
return r;
|
|
880
887
|
}, he = (t, e) => (n, i) => e(n, i, t);
|
|
881
888
|
const oi = "UNIVER_FIND_REPLACE_PLUGIN";
|
|
882
|
-
var
|
|
883
|
-
let ue = (
|
|
889
|
+
var V;
|
|
890
|
+
let ue = (V = class extends ut {
|
|
884
891
|
constructor(t = le, e, n) {
|
|
885
892
|
super(), this._config = t, this._injector = e, this._configService = n;
|
|
886
893
|
const { ...i } = ft(
|
|
@@ -899,25 +906,25 @@ let ue = (G = class extends ut {
|
|
|
899
906
|
onRendered() {
|
|
900
907
|
this._injector.get(w);
|
|
901
908
|
}
|
|
902
|
-
}, o(
|
|
909
|
+
}, o(V, "pluginName", oi), V);
|
|
903
910
|
ue = ai([
|
|
904
911
|
he(1, D(Q)),
|
|
905
912
|
he(2, ht)
|
|
906
913
|
], ue);
|
|
907
914
|
export {
|
|
908
|
-
|
|
909
|
-
|
|
915
|
+
z as FindBy,
|
|
916
|
+
Z as FindDirection,
|
|
910
917
|
gi as FindModel,
|
|
911
918
|
w as FindReplaceController,
|
|
912
919
|
q as FindReplaceModel,
|
|
913
920
|
wt as FindReplaceState,
|
|
914
|
-
|
|
915
|
-
|
|
921
|
+
Y as FindScope,
|
|
922
|
+
Te as GoToNextMatchOperation,
|
|
916
923
|
Ee as GoToPreviousMatchOperation,
|
|
917
924
|
g as IFindReplaceService,
|
|
918
|
-
|
|
925
|
+
O as OpenFindDialogOperation,
|
|
919
926
|
ne as OpenReplaceDialogOperation,
|
|
920
|
-
|
|
927
|
+
Oe as ReplaceAllMatchesCommand,
|
|
921
928
|
Pe as ReplaceCurrentMatchCommand,
|
|
922
929
|
ue as UniverFindReplacePlugin,
|
|
923
930
|
ie as createInitFindReplaceState
|