@univerjs/find-replace 0.1.0-beta.5 → 0.1.2

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/README.md CHANGED
@@ -5,12 +5,16 @@
5
5
 
6
6
  ## Introduction
7
7
 
8
- > TODO: Introduction
8
+ TODO: Not yet written.
9
9
 
10
10
  ## Usage
11
11
 
12
12
  ### Installation
13
13
 
14
14
  ```shell
15
- npm i @univerjs/find-replace
15
+ # Using npm
16
+ npm install @univerjs/find-replace
17
+
18
+ # Using pnpm
19
+ pnpm add @univerjs/find-replace
16
20
  ```
package/lib/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var J=Object.defineProperty;var Y=(t,e,n)=>e in t?J(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var u=(t,e,n)=>(Y(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),S=require("@wendellhu/redi"),d=require("@univerjs/ui"),O=require("rxjs"),p=require("react"),f=require("@univerjs/design"),P=require("@wendellhu/redi/react-bindings");var _=function(){return _=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},_.apply(this,arguments)},Q=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 r=0,i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]]);return n},N=p.forwardRef(function(t,e){var n=t.icon,i=t.id,r=t.className,o=t.extend,a=Q(t,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),v=p.useRef("_".concat(te()));return U(n,"".concat(i),{defIds:n.defIds,idSuffix:v.current},_({ref:e,className:c},a),o)});function U(t,e,n,i,r){return p.createElement(t.tag,_(_({key:e},X(t,n,r)),i),(ee(t,n).children||[]).map(function(o,a){return U(o,"".concat(e,"-").concat(t.tag,"-").concat(a),n,void 0,r)}))}function X(t,e,n){var i=_({},t.attrs);n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1);var r=e.defIds;return!r||r.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(i[a]=c.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)?_(_({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?_(_({},r),{attrs:_(_({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):t}function te(){return Math.random().toString(36).substring(2,8)}N.displayName="UniverIcon";var ie={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_217_40",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.9 0.09H16.9V16.09H0.9z"}}]},{tag:"g",attrs:{mask:"url(#mask0_217_40)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},$=p.forwardRef(function(t,e){return p.createElement(N,Object.assign({},t,{id:"search-single-16",ref:e,icon:ie}))});$.displayName="SearchSingle16";var ne=Object.defineProperty,re=Object.getOwnPropertyDescriptor,A=(t,e,n,i)=>{for(var r=i>1?void 0:i?re(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&ne(e,n,r),r},I=(t,e)=>(n,i)=>e(n,i,t);class oe extends s.Disposable{}const m=S.createIdentifier("univer.find-replace.service");let T=class extends s.Disposable{constructor(e,n,i,r){super();u(this,"_matchPositionFindModel",null);u(this,"_findModels",[]);u(this,"_matches",[]);u(this,"_positionModel",null);this._state=e,this._providers=n,this._logService=i,this._univerInstanceService=r,this._state.stateUpdates$.subscribe(o=>{typeof o.findString<"u"&&(o.findString?this.find():this._cancelFinding())})}async find(){this._cancelFinding();const e=Array.from(this._providers),n=this._findModels=(await Promise.all(e.map(o=>o.find({text:this._state.findString})))).flat(),i=n.map(o=>o.getMatches()).flat();if(this._matches=i,!i.length)return{results:[]};const r=this._moveToInitialMatch(n,i);return this._state.changeState({matchesCount:i.length,matchesPosition:r+1}),{results:i}}moveToNextMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,n=this._positionModel.moveToNextMatch(e);if(n){const i=this._matches.findIndex(r=>r===n);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(c=>c===this._positionModel),r=this._findModels[(i+1)%this._findModels.length],o=r.moveToNextMatch(),a=this._matches.findIndex(c=>c===o);this._positionModel=r,this._state.changeState({matchesPosition:a+1})}}moveToPreviousMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,n=this._positionModel.moveToPreviousMatch(e);if(n){const i=this._matches.findIndex(r=>r===n);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(c=>c===this._positionModel),r=this._findModels[(i-1+this._findModels.length)%this._findModels.length],o=r.moveToPreviousMatch(),a=this._matches.findIndex(c=>c===o);this._positionModel=r,this._state.changeState({matchesPosition:a+1})}}_moveToInitialMatch(e,n){var c;const i=(c=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:c.getUnitId();if(!i)return-1;const r=e.find(v=>v.unitId===i);if(r){this._positionModel=r;const v=r.moveToNextMatch();return n.findIndex(C=>C===v)}this._positionModel=e[0];const o=this._positionModel.moveToNextMatch();return this._matches.findIndex(v=>v===o)}_cancelFinding(){this._providers.forEach(e=>e.cancel()),this._state.changeState({matchesCount:0,matchesPosition:0})}};T=A([I(2,s.ILogService),I(3,s.IUniverInstanceService)],T);function L(){return{revealed:!0,findString:"",replaceRevealed:!1,matchesPosition:0,matchesCount:0}}class ae{constructor(){u(this,"_stateUpdates$",new O.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new O.BehaviorSubject(L()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0)}get state(){return this._state$.getValue()}get findString(){return this._findString}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.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),n&&(this._stateUpdates$.next(i),this._state$.next({findString:this._findString,revealed:this._revealed,replaceRevealed:this._replaceRevealed,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition}))}}let b=class extends s.Disposable{constructor(e,n,i){super();u(this,"_providers",new Set);u(this,"_state",new ae);u(this,"_model");this._injector=e,this._univerInstanceService=n,this._logService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}changeFindString(e){this._state.changeState({findString:e})}moveToNextMatch(){var e;this._model&&((e=this._model)==null||e.moveToNextMatch())}moveToPreviousMatch(){var e;this._model&&((e=this._model)==null||e.moveToPreviousMatch())}replace(){return!0}replaceAll(){return!0}revealReplace(){this._state.changeState({replaceRevealed:!0})}disposeModel(){var e;(e=this._model)==null||e.dispose(),this._model=null}start(){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(T,this._state,this._providers);const e=L();return e.revealed=!0,this._state.changeState(e),!0}end(){return this._state.changeState({revealed:!1,replaceRevealed:!1}),!0}registerFindReplaceProvider(e){return this._providers.add(e),s.toDisposable(()=>this._providers.delete(e))}};b=A([I(0,S.Inject(S.Injector)),I(1,s.IUniverInstanceService),I(2,s.ILogService)],b);const F={id:"ui.operation.open-find-dialog",type:s.CommandType.OPERATION,handler:t=>(t.get(m).start(),!0)},w={id:"ui.operation.open-replace-dialog",type:s.CommandType.OPERATION,handler:t=>(t.get(m).start(),!0)},se={id:"ui.operation.toggle-replace-dialog",type:s.CommandType.OPERATION,handler:t=>(t.get(m),!0)},B={id:"ui.operation.close-find-replace-dialog",type:s.CommandType.OPERATION,handler:t=>!0},V={type:s.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(m).moveToNextMatch(),!0)},q={type:s.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(m).moveToPreviousMatch(),!0)},x="FIND_REPLACE_ACTIVATED";var K={exports:{}},y={};/**
1
+ "use strict";var J=Object.defineProperty;var Y=(t,e,n)=>e in t?J(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var u=(t,e,n)=>(Y(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),S=require("@wendellhu/redi"),d=require("@univerjs/ui"),O=require("rxjs"),p=require("react"),f=require("@univerjs/design"),P=require("@wendellhu/redi/react-bindings");var _=function(){return _=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},_.apply(this,arguments)},Q=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 r=0,i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]]);return n},N=p.forwardRef(function(t,e){var n=t.icon,i=t.id,r=t.className,o=t.extend,a=Q(t,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),v=p.useRef("_".concat(te()));return U(n,"".concat(i),{defIds:n.defIds,idSuffix:v.current},_({ref:e,className:c},a),o)});function U(t,e,n,i,r){return p.createElement(t.tag,_(_({key:e},X(t,n,r)),i),(ee(t,n).children||[]).map(function(o,a){return U(o,"".concat(e,"-").concat(t.tag,"-").concat(a),n,void 0,r)}))}function X(t,e,n){var i=_({},t.attrs);n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1);var r=e.defIds;return!r||r.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(i[a]=c.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)?_(_({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?_(_({},r),{attrs:_(_({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):t}function te(){return Math.random().toString(36).substring(2,8)}N.displayName="UniverIcon";var ie={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_217_40",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.9 0.09H16.9V16.09H0.9z"}}]},{tag:"g",attrs:{mask:"url(#mask0_217_40)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},$=p.forwardRef(function(t,e){return p.createElement(N,Object.assign({},t,{id:"search-single-16",ref:e,icon:ie}))});$.displayName="SearchSingle16";var ne=Object.defineProperty,re=Object.getOwnPropertyDescriptor,L=(t,e,n,i)=>{for(var r=i>1?void 0:i?re(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&ne(e,n,r),r},I=(t,e)=>(n,i)=>e(n,i,t);class oe extends s.Disposable{}const m=S.createIdentifier("univer.find-replace.service");class ae{constructor(){u(this,"_stateUpdates$",new O.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new O.BehaviorSubject(A()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0)}get state(){return this._state$.getValue()}get findString(){return this._findString}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.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),n&&(this._stateUpdates$.next(i),this._state$.next({findString:this._findString,revealed:this._revealed,replaceRevealed:this._replaceRevealed,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition}))}}let T=class extends s.Disposable{constructor(e,n,i,r){super();u(this,"_matchPositionFindModel",null);u(this,"_findModels",[]);u(this,"_matches",[]);u(this,"_positionModel",null);this._state=e,this._providers=n,this._logService=i,this._univerInstanceService=r,this._state.stateUpdates$.subscribe(o=>{typeof o.findString<"u"&&(o.findString?this.find():this._cancelFinding())})}async find(){this._cancelFinding();const e=Array.from(this._providers),n=this._findModels=(await Promise.all(e.map(o=>o.find({text:this._state.findString})))).flat(),i=n.map(o=>o.getMatches()).flat();if(this._matches=i,!i.length)return{results:[]};const r=this._moveToInitialMatch(n,i);return this._state.changeState({matchesCount:i.length,matchesPosition:r+1}),{results:i}}moveToNextMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,n=this._positionModel.moveToNextMatch(e);if(n){const i=this._matches.findIndex(r=>r===n);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(c=>c===this._positionModel),r=this._findModels[(i+1)%this._findModels.length],o=r.moveToNextMatch(),a=this._matches.findIndex(c=>c===o);this._positionModel=r,this._state.changeState({matchesPosition:a+1})}}moveToPreviousMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,n=this._positionModel.moveToPreviousMatch(e);if(n){const i=this._matches.findIndex(r=>r===n);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(c=>c===this._positionModel),r=this._findModels[(i-1+this._findModels.length)%this._findModels.length],o=r.moveToPreviousMatch(),a=this._matches.findIndex(c=>c===o);this._positionModel=r,this._state.changeState({matchesPosition:a+1})}}_moveToInitialMatch(e,n){var c;const i=(c=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:c.getUnitId();if(!i)return-1;const r=e.find(v=>v.unitId===i);if(r){this._positionModel=r;const v=r.moveToNextMatch();return n.findIndex(C=>C===v)}this._positionModel=e[0];const o=this._positionModel.moveToNextMatch();return this._matches.findIndex(v=>v===o)}_cancelFinding(){this._providers.forEach(e=>e.cancel()),this._state.changeState({matchesCount:0,matchesPosition:0})}};T=L([I(2,s.ILogService),I(3,s.IUniverInstanceService)],T);function A(){return{revealed:!0,findString:"",replaceRevealed:!1,matchesPosition:0,matchesCount:0}}let b=class extends s.Disposable{constructor(e,n,i){super();u(this,"_providers",new Set);u(this,"_state",new ae);u(this,"_model");this._injector=e,this._univerInstanceService=n,this._logService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}changeFindString(e){this._state.changeState({findString:e})}moveToNextMatch(){var e;this._model&&((e=this._model)==null||e.moveToNextMatch())}moveToPreviousMatch(){var e;this._model&&((e=this._model)==null||e.moveToPreviousMatch())}replace(){return!0}replaceAll(){return!0}revealReplace(){this._state.changeState({replaceRevealed:!0})}disposeModel(){var e;(e=this._model)==null||e.dispose(),this._model=null}start(){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(T,this._state,this._providers);const e=A();return e.revealed=!0,this._state.changeState(e),!0}end(){return this._state.changeState({revealed:!1,replaceRevealed:!1}),!0}registerFindReplaceProvider(e){return this._providers.add(e),s.toDisposable(()=>this._providers.delete(e))}};b=L([I(0,S.Inject(S.Injector)),I(1,s.IUniverInstanceService),I(2,s.ILogService)],b);const j={id:"ui.operation.open-find-dialog",type:s.CommandType.OPERATION,handler:t=>(t.get(m).start(),!0)},w={id:"ui.operation.open-replace-dialog",type:s.CommandType.OPERATION,handler:t=>(t.get(m).start(),!0)},se={id:"ui.operation.toggle-replace-dialog",type:s.CommandType.OPERATION,handler:t=>(t.get(m),!0)},B={id:"ui.operation.close-find-replace-dialog",type:s.CommandType.OPERATION,handler:t=>!0},V={type:s.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(m).moveToNextMatch(),!0)},q={type:s.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(m).moveToPreviousMatch(),!0)},x="FIND_REPLACE_ACTIVATED";var K={exports:{}},y={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ce=p,le=Symbol.for("react.element"),de=Symbol.for("react.fragment"),ue=Object.prototype.hasOwnProperty,he=ce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,pe={key:!0,ref:!0,__self:!0,__source:!0};function k(t,e,n){var i,r={},o=null,a=null;n!==void 0&&(o=""+n),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(a=e.ref);for(i in e)ue.call(e,i)&&!pe.hasOwnProperty(i)&&(r[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)r[i]===void 0&&(r[i]=e[i]);return{$$typeof:le,type:t,key:o,ref:a,props:r,_owner:he.current}}y.Fragment=de;y.jsx=k;y.jsxs=k;K.exports=y;var h=K.exports;const fe="univer-find-replace-expand-container",E={findReplaceExpandContainer:fe};function ve(){const t=P.useDependency(m),e=P.useDependency(s.LocaleService),n=P.useDependency(d.LayoutService),[i,r]=p.useState(""),[o,a]=p.useState(""),c=p.useRef(null),v=f.useObservable(t.state$,!0),{matchesCount:R,matchesPosition:C}=v,G=p.useCallback(()=>t.revealReplace(),[t]),H=p.useCallback(l=>t.changeFindString(l),[t]),W=p.useCallback(l=>{r(l),H(l)},[t]),j=p.useCallback(l=>{a(l)},[t]);p.useEffect(()=>{let l;return c.current&&(l=n.registerContainer(c.current)),()=>l==null?void 0:l.dispose()},[c.current]);function z(){return h.jsxs(p.Fragment,{children:[h.jsx(f.InputWithSlot,{autoFocus:!0,placeholder:e.t("univer.find-replace.dialog.find-placeholder"),slot:h.jsx(f.Pager,{loop:!0,value:C,total:R,onChange:l=>{C===R&&l===1?t.moveToNextMatch():C===1&&l===R||l<C?t.moveToPreviousMatch():t.moveToNextMatch()}}),value:i,onChange:l=>W(l)}),h.jsx("div",{className:E.findReplaceExpandContainer,children:h.jsx(f.Button,{type:"text",size:"small",onClick:G,children:e.t("univer.find-replace.dialog.advanced-finding")})})]})}function Z(){return h.jsxs(p.Fragment,{children:[h.jsx(f.FormLayout,{label:e.t("univer.find-replace.dialog.find"),children:h.jsx(f.Input,{placeholder:e.t("univer.find-replace.dialog.find-placeholder"),autoFocus:!0,value:i,onChange:l=>j(l)})}),h.jsx(f.FormLayout,{label:e.t("univer.find-replace.dialog.replace"),children:h.jsx(f.Input,{placeholder:e.t("univer.find-replace.dialog.replace-placeholder"),value:o,onChange:l=>j(l)})}),h.jsx(f.FormLayout,{label:e.t("univer.find-replace.dialog.find-range"),children:h.jsx(f.Select,{value:"123",onChange:()=>{}})}),h.jsx(f.Button,{type:"primary",children:e.t("univer.find-replace.dialog.find")}),h.jsx(f.Button,{children:e.t("univer.find-replace.dialog.replace")}),h.jsx(f.Button,{children:e.t("univer.find-replace.dialog.replace-all")})]})}return h.jsx("div",{className:E.findReplaceDialogContainer,ref:c,children:v.replaceRevealed?Z():z()})}function _e(t){return{id:F.id,icon:"SearchIcon",tooltip:"toolbar.find-replace",group:d.MenuGroup.TOOLBAR_OTHERS,type:d.MenuItemType.BUTTON,positions:[d.MenuPosition.TOOLBAR_START],hidden$:d.getMenuHiddenObservable(t,s.UniverInstanceType.SHEET)}}const ge={id:F.id,description:"shortcut.find-replace.open-find-dialog",binding:d.KeyCode.F|d.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(x)}},me={id:w.id,description:"shortcut.find-replace.open-replace-dialog",binding:d.KeyCode.H|d.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(x)}},Se={id:B.id,description:"shortcut.find-replace.close-dialog",binding:d.KeyCode.ESC,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(x)}},xe={id:V.id,description:"shortcut.find-replace.go-to-next-find-match",binding:d.KeyCode.ENTER,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(x)}},Re={id:q.id,description:"shortcut.find-replace.go-to-previous-find-match",binding:d.KeyCode.ENTER|d.MetaKeys.SHIFT,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(x)}};var Ce=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Me=(t,e,n,i)=>{for(var r=i>1?void 0:i?Ie(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Ce(e,n,r),r},g=(t,e)=>(n,i)=>e(n,i,t);const D="DESKTOP_FIND_REPLACE_DIALOG";let M=class extends s.RxDisposable{constructor(t,e,n,i,r,o,a,c,v,R){super(),this._menuService=t,this._shortcutService=e,this._commandService=n,this._findReplaceService=i,this._dialogService=r,this._contextService=o,this._focusService=a,this._localeService=c,this._componentManager=v,this._injector=R,this._initOperations(),this._initUI(),this._initShortcuts()}_initOperations(){[B,F,w,se,V,q].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initUI(){[_e].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)))}),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",ve)),this.disposeWithMe(this._componentManager.register("SearchIcon",$)),this._findReplaceService.stateUpdates$.pipe(O.takeUntil(this.dispose$)).subscribe(t=>{t.revealed===!0?this._openPanel():t.revealed===!1&&this._closePanel()})}_initShortcuts(){[me,ge,Se,Re,xe].forEach(t=>{this.disposeWithMe(this._shortcutService.registerShortcut(t))})}_openPanel(){this._dialogService.open({id:D,draggable:!0,width:350,title:{title:this._localeService.t("univer.find-replace.dialog.title")},children:{label:"FindReplaceDialog"},onClose:()=>this._closePanel()}),this._contextService.setContextValue(x,!0)}_closePanel(){this._dialogService.close(D),this._contextService.setContextValue(x,!1),this._focusService.forceFocus(),this._findReplaceService.end()}};M=Me([s.OnLifecycle(s.LifecycleStages.Rendered,M),g(0,d.IMenuService),g(1,d.IShortcutService),g(2,s.ICommandService),g(3,m),g(4,d.IDialogService),g(5,s.IContextService),g(6,d.IFocusService),g(7,S.Inject(s.LocaleService)),g(8,S.Inject(d.ComponentManager)),g(9,S.Inject(S.Injector))],M);const ye={univer:{"find-replace":{dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-range":"查找范围","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容"}}}};var Pe=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Te=(t,e,n,i)=>{for(var r=i>1?void 0:i?Oe(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Pe(e,n,r),r},be=(t,e)=>(n,i)=>e(n,i,t);const Fe="FIND_REPLACE";exports.UniverFindReplacePlugin=class extends s.Plugin{constructor(e,n){super(Fe),this._injector=e,this._localeService=n,this._localeService.load({zhCN:ye})}onStarting(e){[[M],[m,{useClass:b}]].forEach(n=>{e.add(n)})}};exports.UniverFindReplacePlugin=Te([be(1,S.Inject(s.LocaleService))],exports.UniverFindReplacePlugin);exports.FindModel=oe;exports.IFindReplaceService=m;
9
+ */var ce=p,le=Symbol.for("react.element"),de=Symbol.for("react.fragment"),ue=Object.prototype.hasOwnProperty,he=ce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,pe={key:!0,ref:!0,__self:!0,__source:!0};function k(t,e,n){var i,r={},o=null,a=null;n!==void 0&&(o=""+n),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(a=e.ref);for(i in e)ue.call(e,i)&&!pe.hasOwnProperty(i)&&(r[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)r[i]===void 0&&(r[i]=e[i]);return{$$typeof:le,type:t,key:o,ref:a,props:r,_owner:he.current}}y.Fragment=de;y.jsx=k;y.jsxs=k;K.exports=y;var h=K.exports;const fe="univer-find-replace-expand-container",E={findReplaceExpandContainer:fe};function ve(){const t=P.useDependency(m),e=P.useDependency(s.LocaleService),n=P.useDependency(d.ILayoutService),[i,r]=p.useState(""),[o,a]=p.useState(""),c=p.useRef(null),v=f.useObservable(t.state$,!0),{matchesCount:R,matchesPosition:C}=v,G=p.useCallback(()=>t.revealReplace(),[t]),H=p.useCallback(l=>t.changeFindString(l),[t]),W=p.useCallback(l=>{r(l),H(l)},[t]),F=p.useCallback(l=>{a(l)},[t]);p.useEffect(()=>{let l;return c.current&&(l=n.registerContainerElement(c.current)),()=>l==null?void 0:l.dispose()},[c.current]);function z(){return h.jsxs(p.Fragment,{children:[h.jsx(f.InputWithSlot,{autoFocus:!0,placeholder:e.t("univer.find-replace.dialog.find-placeholder"),slot:h.jsx(f.Pager,{loop:!0,value:C,total:R,onChange:l=>{C===R&&l===1?t.moveToNextMatch():C===1&&l===R||l<C?t.moveToPreviousMatch():t.moveToNextMatch()}}),value:i,onChange:l=>W(l)}),h.jsx("div",{className:E.findReplaceExpandContainer,children:h.jsx(f.Button,{type:"text",size:"small",onClick:G,children:e.t("univer.find-replace.dialog.advanced-finding")})})]})}function Z(){return h.jsxs(p.Fragment,{children:[h.jsx(f.FormLayout,{label:e.t("univer.find-replace.dialog.find"),children:h.jsx(f.Input,{placeholder:e.t("univer.find-replace.dialog.find-placeholder"),autoFocus:!0,value:i,onChange:l=>F(l)})}),h.jsx(f.FormLayout,{label:e.t("univer.find-replace.dialog.replace"),children:h.jsx(f.Input,{placeholder:e.t("univer.find-replace.dialog.replace-placeholder"),value:o,onChange:l=>F(l)})}),h.jsx(f.FormLayout,{label:e.t("univer.find-replace.dialog.find-range"),children:h.jsx(f.Select,{value:"123",onChange:()=>{}})}),h.jsx(f.Button,{type:"primary",children:e.t("univer.find-replace.dialog.find")}),h.jsx(f.Button,{children:e.t("univer.find-replace.dialog.replace")}),h.jsx(f.Button,{children:e.t("univer.find-replace.dialog.replace-all")})]})}return h.jsx("div",{className:E.findReplaceDialogContainer,ref:c,children:v.replaceRevealed?Z():z()})}function _e(t){return{id:j.id,icon:"SearchIcon",tooltip:"toolbar.find-replace",group:d.MenuGroup.TOOLBAR_OTHERS,type:d.MenuItemType.BUTTON,positions:[d.MenuPosition.TOOLBAR_START],hidden$:d.getMenuHiddenObservable(t,s.UniverInstanceType.SHEET)}}const ge={id:j.id,description:"shortcut.find-replace.open-find-dialog",binding:d.KeyCode.F|d.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(x)}},me={id:w.id,description:"shortcut.find-replace.open-replace-dialog",binding:d.KeyCode.H|d.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(x)}},Se={id:B.id,description:"shortcut.find-replace.close-dialog",binding:d.KeyCode.ESC,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(x)}},xe={id:V.id,description:"shortcut.find-replace.go-to-next-find-match",binding:d.KeyCode.ENTER,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(x)}},Re={id:q.id,description:"shortcut.find-replace.go-to-previous-find-match",binding:d.KeyCode.ENTER|d.MetaKeys.SHIFT,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(x)}};var Ce=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Me=(t,e,n,i)=>{for(var r=i>1?void 0:i?Ie(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Ce(e,n,r),r},g=(t,e)=>(n,i)=>e(n,i,t);const D="DESKTOP_FIND_REPLACE_DIALOG";let M=class extends s.RxDisposable{constructor(t,e,n,i,r,o,a,c,v,R){super(),this._menuService=t,this._shortcutService=e,this._commandService=n,this._findReplaceService=i,this._dialogService=r,this._contextService=o,this._layoutService=a,this._localeService=c,this._componentManager=v,this._injector=R,this._initOperations(),this._initUI(),this._initShortcuts()}_initOperations(){[B,j,w,se,V,q].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initUI(){[_e].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)))}),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",ve)),this.disposeWithMe(this._componentManager.register("SearchIcon",$)),this._findReplaceService.stateUpdates$.pipe(O.takeUntil(this.dispose$)).subscribe(t=>{t.revealed===!0?this._openPanel():t.revealed===!1&&this._closePanel()})}_initShortcuts(){[me,ge,Se,Re,xe].forEach(t=>{this.disposeWithMe(this._shortcutService.registerShortcut(t))})}_openPanel(){this._dialogService.open({id:D,draggable:!0,width:350,title:{title:this._localeService.t("univer.find-replace.dialog.title")},children:{label:"FindReplaceDialog"},onClose:()=>this._closePanel()}),this._contextService.setContextValue(x,!0)}_closePanel(){this._dialogService.close(D),this._contextService.setContextValue(x,!1),this._layoutService.focus(),this._findReplaceService.end()}};M=Me([s.OnLifecycle(s.LifecycleStages.Rendered,M),g(0,d.IMenuService),g(1,d.IShortcutService),g(2,s.ICommandService),g(3,m),g(4,d.IDialogService),g(5,s.IContextService),g(6,d.ILayoutService),g(7,S.Inject(s.LocaleService)),g(8,S.Inject(d.ComponentManager)),g(9,S.Inject(S.Injector))],M);const ye={univer:{"find-replace":{dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-range":"查找范围","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容"}}}};var Pe=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Te=(t,e,n,i)=>{for(var r=i>1?void 0:i?Oe(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Pe(e,n,r),r},be=(t,e)=>(n,i)=>e(n,i,t);const je="FIND_REPLACE";exports.UniverFindReplacePlugin=class extends s.Plugin{constructor(e,n){super(je),this._injector=e,this._localeService=n,this._localeService.load({zhCN:ye})}onStarting(e){[[M],[m,{useClass:b}]].forEach(n=>{e.add(n)})}};exports.UniverFindReplacePlugin=Te([be(1,S.Inject(s.LocaleService))],exports.UniverFindReplacePlugin);exports.FindModel=oe;exports.IFindReplaceService=m;
package/lib/es/index.js CHANGED
@@ -1,12 +1,12 @@
1
- var le = Object.defineProperty;
2
- var de = (t, e, n) => e in t ? le(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var l = (t, e, n) => (de(t, typeof e != "symbol" ? e + "" : e, n), n);
4
- import { Disposable as E, ILogService as B, IUniverInstanceService as G, toDisposable as he, CommandType as m, LocaleService as F, UniverInstanceType as ue, OnLifecycle as pe, LifecycleStages as fe, RxDisposable as ve, ICommandService as _e, IContextService as ge, Plugin as me } from "@univerjs/core";
5
- import { createIdentifier as Se, Inject as S, Injector as H } from "@wendellhu/redi";
6
- import { LayoutService as xe, MenuGroup as Re, MenuItemType as Me, MenuPosition as Ie, getMenuHiddenObservable as Ce, KeyCode as R, MetaKeys as j, ComponentManager as Oe, IMenuService as Pe, IShortcutService as ye, IDialogService as Te, IFocusService as be } from "@univerjs/ui";
7
- import { Subject as Ee, BehaviorSubject as Fe, takeUntil as je } from "rxjs";
8
- import De, { forwardRef as W, useRef as k, createElement as z, useState as $, useCallback as M, useEffect as Ne, Fragment as A } from "react";
9
- import { useObservable as $e, InputWithSlot as Ae, Pager as Ue, Button as I, FormLayout as P, Input as U, Select as Le } from "@univerjs/design";
1
+ var de = Object.defineProperty;
2
+ var he = (t, e, n) => e in t ? de(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var l = (t, e, n) => (he(t, typeof e != "symbol" ? e + "" : e, n), n);
4
+ import { Disposable as E, ILogService as B, IUniverInstanceService as G, toDisposable as ue, CommandType as m, LocaleService as j, UniverInstanceType as pe, OnLifecycle as fe, LifecycleStages as _e, RxDisposable as ve, ICommandService as ge, IContextService as me, Plugin as Se } from "@univerjs/core";
5
+ import { createIdentifier as xe, Inject as S, Injector as H } from "@wendellhu/redi";
6
+ import { ILayoutService as W, MenuGroup as Re, MenuItemType as Me, MenuPosition as Ie, getMenuHiddenObservable as Ce, KeyCode as R, MetaKeys as F, ComponentManager as Oe, IMenuService as Pe, IShortcutService as ye, IDialogService as Te } from "@univerjs/ui";
7
+ import { Subject as be, BehaviorSubject as Ee, takeUntil as je } from "rxjs";
8
+ import Fe, { forwardRef as k, useRef as z, createElement as K, useState as $, useCallback as M, useEffect as De, Fragment as A } from "react";
9
+ import { useObservable as Ne, InputWithSlot as $e, Pager as Ae, Button as I, FormLayout as P, Input as U, Select as Ue } from "@univerjs/design";
10
10
  import { useDependency as y } from "@wendellhu/redi/react-bindings";
11
11
  var u = function() {
12
12
  return u = Object.assign || function(t) {
@@ -17,7 +17,7 @@ var u = function() {
17
17
  }
18
18
  return t;
19
19
  }, u.apply(this, arguments);
20
- }, we = function(t, e) {
20
+ }, Le = function(t, e) {
21
21
  var n = {};
22
22
  for (var i in t)
23
23
  Object.prototype.hasOwnProperty.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
@@ -25,16 +25,16 @@ var u = function() {
25
25
  for (var r = 0, i = Object.getOwnPropertySymbols(t); r < i.length; r++)
26
26
  e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, i[r]) && (n[i[r]] = t[i[r]]);
27
27
  return n;
28
- }, K = W(function(t, e) {
29
- var n = t.icon, i = t.id, r = t.className, o = t.extend, a = we(t, ["icon", "id", "className", "extend"]), s = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), h = k("_".concat(Ge()));
30
- return q(n, "".concat(i), { defIds: n.defIds, idSuffix: h.current }, u({ ref: e, className: s }, a), o);
28
+ }, q = k(function(t, e) {
29
+ var n = t.icon, i = t.id, r = t.className, o = t.extend, a = Le(t, ["icon", "id", "className", "extend"]), s = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), h = z("_".concat(Be()));
30
+ return Z(n, "".concat(i), { defIds: n.defIds, idSuffix: h.current }, u({ ref: e, className: s }, a), o);
31
31
  });
32
- function q(t, e, n, i, r) {
33
- return z(t.tag, u(u({ key: e }, Ve(t, n, r)), i), (Be(t, n).children || []).map(function(o, a) {
34
- return q(o, "".concat(e, "-").concat(t.tag, "-").concat(a), n, void 0, r);
32
+ function Z(t, e, n, i, r) {
33
+ return K(t.tag, u(u({ key: e }, we(t, n, r)), i), (Ve(t, n).children || []).map(function(o, a) {
34
+ return Z(o, "".concat(e, "-").concat(t.tag, "-").concat(a), n, void 0, r);
35
35
  }));
36
36
  }
37
- function Ve(t, e, n) {
37
+ function we(t, e, n) {
38
38
  var i = u({}, t.attrs);
39
39
  n != null && n.colorChannel1 && i.fill === "colorChannel1" && (i.fill = n.colorChannel1);
40
40
  var r = e.defIds;
@@ -43,17 +43,17 @@ function Ve(t, e, n) {
43
43
  typeof s == "string" && (i[a] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
44
44
  })), i;
45
45
  }
46
- function Be(t, e) {
46
+ function Ve(t, e) {
47
47
  var n, i = e.defIds;
48
48
  return !i || i.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? u(u({}, t), { children: t.children.map(function(r) {
49
49
  return typeof r.attrs.id == "string" && i && i.indexOf(r.attrs.id) > -1 ? u(u({}, r), { attrs: u(u({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
50
50
  }) }) : t;
51
51
  }
52
- function Ge() {
52
+ function Be() {
53
53
  return Math.random().toString(36).substring(2, 8);
54
54
  }
55
- K.displayName = "UniverIcon";
56
- var He = {
55
+ q.displayName = "UniverIcon";
56
+ var Ge = {
57
57
  tag: "svg",
58
58
  attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" },
59
59
  children: [
@@ -91,22 +91,53 @@ var He = {
91
91
  ]
92
92
  }
93
93
  ]
94
- }, Z = W(function(t, e) {
95
- return z(K, Object.assign({}, t, {
94
+ }, J = k(function(t, e) {
95
+ return K(q, Object.assign({}, t, {
96
96
  id: "search-single-16",
97
97
  ref: e,
98
- icon: He
98
+ icon: Ge
99
99
  }));
100
100
  });
101
- Z.displayName = "SearchSingle16";
102
- var We = Object.defineProperty, ke = Object.getOwnPropertyDescriptor, J = (t, e, n, i) => {
103
- for (var r = i > 1 ? void 0 : i ? ke(e, n) : e, o = t.length - 1, a; o >= 0; o--)
101
+ J.displayName = "SearchSingle16";
102
+ var He = Object.defineProperty, We = Object.getOwnPropertyDescriptor, Y = (t, e, n, i) => {
103
+ for (var r = i > 1 ? void 0 : i ? We(e, n) : e, o = t.length - 1, a; o >= 0; o--)
104
104
  (a = t[o]) && (r = (i ? a(e, n, r) : a(r)) || r);
105
- return i && r && We(e, n, r), r;
105
+ return i && r && He(e, n, r), r;
106
106
  }, x = (t, e) => (n, i) => e(n, i, t);
107
- class Ot extends E {
107
+ class Ct extends E {
108
+ }
109
+ const f = xe("univer.find-replace.service");
110
+ class ke {
111
+ constructor() {
112
+ l(this, "_stateUpdates$", new be());
113
+ l(this, "stateUpdates$", this._stateUpdates$.asObservable());
114
+ l(this, "_state$", new Ee(Q()));
115
+ l(this, "state$", this._state$.asObservable());
116
+ // TODO@wzhudev: put all state properties here
117
+ l(this, "_findString", "");
118
+ l(this, "_revealed", !1);
119
+ l(this, "_replaceRevealed", !1);
120
+ l(this, "_matchesPosition", 0);
121
+ l(this, "_matchesCount", 0);
122
+ }
123
+ get state() {
124
+ return this._state$.getValue();
125
+ }
126
+ get findString() {
127
+ return this._findString;
128
+ }
129
+ changeState(e) {
130
+ let n = !1;
131
+ const i = {};
132
+ 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.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), n && (this._stateUpdates$.next(i), this._state$.next({
133
+ findString: this._findString,
134
+ revealed: this._revealed,
135
+ replaceRevealed: this._replaceRevealed,
136
+ matchesCount: this._matchesCount,
137
+ matchesPosition: this._matchesPosition
138
+ }));
139
+ }
108
140
  }
109
- const f = Se("univer.find-replace.service");
110
141
  let T = class extends E {
111
142
  constructor(e, n, i, r) {
112
143
  super();
@@ -189,11 +220,11 @@ let T = class extends E {
189
220
  });
190
221
  }
191
222
  };
192
- T = J([
223
+ T = Y([
193
224
  x(2, B),
194
225
  x(3, G)
195
226
  ], T);
196
- function Y() {
227
+ function Q() {
197
228
  return {
198
229
  revealed: !0,
199
230
  findString: "",
@@ -202,42 +233,11 @@ function Y() {
202
233
  matchesCount: 0
203
234
  };
204
235
  }
205
- class ze {
206
- constructor() {
207
- l(this, "_stateUpdates$", new Ee());
208
- l(this, "stateUpdates$", this._stateUpdates$.asObservable());
209
- l(this, "_state$", new Fe(Y()));
210
- l(this, "state$", this._state$.asObservable());
211
- // TODO@wzhudev: put all state properties here
212
- l(this, "_findString", "");
213
- l(this, "_revealed", !1);
214
- l(this, "_replaceRevealed", !1);
215
- l(this, "_matchesPosition", 0);
216
- l(this, "_matchesCount", 0);
217
- }
218
- get state() {
219
- return this._state$.getValue();
220
- }
221
- get findString() {
222
- return this._findString;
223
- }
224
- changeState(e) {
225
- let n = !1;
226
- const i = {};
227
- 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.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), n && (this._stateUpdates$.next(i), this._state$.next({
228
- findString: this._findString,
229
- revealed: this._revealed,
230
- replaceRevealed: this._replaceRevealed,
231
- matchesCount: this._matchesCount,
232
- matchesPosition: this._matchesPosition
233
- }));
234
- }
235
- }
236
236
  let b = class extends E {
237
237
  constructor(e, n, i) {
238
238
  super();
239
239
  l(this, "_providers", /* @__PURE__ */ new Set());
240
- l(this, "_state", new ze());
240
+ l(this, "_state", new ke());
241
241
  l(this, "_model");
242
242
  this._injector = e, this._univerInstanceService = n, this._logService = i;
243
243
  }
@@ -277,17 +277,17 @@ let b = class extends E {
277
277
  if (this._providers.size === 0)
278
278
  return !1;
279
279
  this._model = this._injector.createInstance(T, this._state, this._providers);
280
- const e = Y();
280
+ const e = Q();
281
281
  return e.revealed = !0, this._state.changeState(e), !0;
282
282
  }
283
283
  end() {
284
284
  return this._state.changeState({ revealed: !1, replaceRevealed: !1 }), !0;
285
285
  }
286
286
  registerFindReplaceProvider(e) {
287
- return this._providers.add(e), he(() => this._providers.delete(e));
287
+ return this._providers.add(e), ue(() => this._providers.delete(e));
288
288
  }
289
289
  };
290
- b = J([
290
+ b = Y([
291
291
  x(0, S(H)),
292
292
  x(1, G),
293
293
  x(2, B)
@@ -296,28 +296,28 @@ const D = {
296
296
  id: "ui.operation.open-find-dialog",
297
297
  type: m.OPERATION,
298
298
  handler: (t) => (t.get(f).start(), !0)
299
- }, Q = {
299
+ }, X = {
300
300
  id: "ui.operation.open-replace-dialog",
301
301
  type: m.OPERATION,
302
302
  handler: (t) => (t.get(f).start(), !0)
303
- }, Ke = {
303
+ }, ze = {
304
304
  id: "ui.operation.toggle-replace-dialog",
305
305
  type: m.OPERATION,
306
306
  handler: (t) => (t.get(f), !0)
307
- }, X = {
307
+ }, ee = {
308
308
  id: "ui.operation.close-find-replace-dialog",
309
309
  type: m.OPERATION,
310
310
  handler: (t) => !0
311
- }, ee = {
311
+ }, te = {
312
312
  type: m.OPERATION,
313
313
  id: "ui.operation.go-to-next-match",
314
314
  handler: (t) => (t.get(f).moveToNextMatch(), !0)
315
- }, te = {
315
+ }, ie = {
316
316
  type: m.OPERATION,
317
317
  id: "ui.operation.go-to-previous-match",
318
318
  handler: (t) => (t.get(f).moveToPreviousMatch(), !0)
319
- }, v = "FIND_REPLACE_ACTIVATED";
320
- var ie = { exports: {} }, O = {};
319
+ }, _ = "FIND_REPLACE_ACTIVATED";
320
+ var ne = { exports: {} }, O = {};
321
321
  /**
322
322
  * @license React
323
323
  * react-jsx-runtime.production.min.js
@@ -327,34 +327,34 @@ var ie = { exports: {} }, O = {};
327
327
  * This source code is licensed under the MIT license found in the
328
328
  * LICENSE file in the root directory of this source tree.
329
329
  */
330
- var qe = De, Ze = Symbol.for("react.element"), Je = Symbol.for("react.fragment"), Ye = Object.prototype.hasOwnProperty, Qe = qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, Xe = { key: !0, ref: !0, __self: !0, __source: !0 };
331
- function ne(t, e, n) {
330
+ var Ke = Fe, qe = Symbol.for("react.element"), Ze = Symbol.for("react.fragment"), Je = Object.prototype.hasOwnProperty, Ye = Ke.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, Qe = { key: !0, ref: !0, __self: !0, __source: !0 };
331
+ function re(t, e, n) {
332
332
  var i, r = {}, o = null, a = null;
333
333
  n !== void 0 && (o = "" + n), e.key !== void 0 && (o = "" + e.key), e.ref !== void 0 && (a = e.ref);
334
334
  for (i in e)
335
- Ye.call(e, i) && !Xe.hasOwnProperty(i) && (r[i] = e[i]);
335
+ Je.call(e, i) && !Qe.hasOwnProperty(i) && (r[i] = e[i]);
336
336
  if (t && t.defaultProps)
337
337
  for (i in e = t.defaultProps, e)
338
338
  r[i] === void 0 && (r[i] = e[i]);
339
- return { $$typeof: Ze, type: t, key: o, ref: a, props: r, _owner: Qe.current };
339
+ return { $$typeof: qe, type: t, key: o, ref: a, props: r, _owner: Ye.current };
340
340
  }
341
- O.Fragment = Je;
342
- O.jsx = ne;
343
- O.jsxs = ne;
344
- ie.exports = O;
345
- var d = ie.exports;
346
- const et = "univer-find-replace-expand-container", L = {
347
- findReplaceExpandContainer: et
341
+ O.Fragment = Ze;
342
+ O.jsx = re;
343
+ O.jsxs = re;
344
+ ne.exports = O;
345
+ var d = ne.exports;
346
+ const Xe = "univer-find-replace-expand-container", L = {
347
+ findReplaceExpandContainer: Xe
348
348
  };
349
- function tt() {
350
- const t = y(f), e = y(F), n = y(xe), [i, r] = $(""), [o, a] = $(""), s = k(null), h = $e(t.state$, !0), { matchesCount: _, matchesPosition: g } = h, re = M(() => t.revealReplace(), [t]), oe = M(
349
+ function et() {
350
+ const t = y(f), e = y(j), n = y(W), [i, r] = $(""), [o, a] = $(""), s = z(null), h = Ne(t.state$, !0), { matchesCount: v, matchesPosition: g } = h, oe = M(() => t.revealReplace(), [t]), ae = M(
351
351
  (c) => t.changeFindString(c),
352
352
  // FIXME@wzhudev: this throttle function has no leading and taling config hence has some problems
353
353
  // throttle((findString: string) => findReplaceService.changeFindString(findString), FIND_THROTTLE_TIME),
354
354
  [t]
355
- ), ae = M(
355
+ ), se = M(
356
356
  (c) => {
357
- r(c), oe(c);
357
+ r(c), ae(c);
358
358
  },
359
359
  [t]
360
360
  ), N = M(
@@ -363,36 +363,36 @@ function tt() {
363
363
  },
364
364
  [t]
365
365
  );
366
- Ne(() => {
366
+ De(() => {
367
367
  let c;
368
- return s.current && (c = n.registerContainer(s.current)), () => c == null ? void 0 : c.dispose();
368
+ return s.current && (c = n.registerContainerElement(s.current)), () => c == null ? void 0 : c.dispose();
369
369
  }, [s.current]);
370
- function se() {
370
+ function ce() {
371
371
  return /* @__PURE__ */ d.jsxs(A, { children: [
372
372
  /* @__PURE__ */ d.jsx(
373
- Ae,
373
+ $e,
374
374
  {
375
375
  autoFocus: !0,
376
376
  placeholder: e.t("univer.find-replace.dialog.find-placeholder"),
377
377
  slot: /* @__PURE__ */ d.jsx(
378
- Ue,
378
+ Ae,
379
379
  {
380
380
  loop: !0,
381
381
  value: g,
382
- total: _,
382
+ total: v,
383
383
  onChange: (c) => {
384
- g === _ && c === 1 ? t.moveToNextMatch() : g === 1 && c === _ || c < g ? t.moveToPreviousMatch() : t.moveToNextMatch();
384
+ g === v && c === 1 ? t.moveToNextMatch() : g === 1 && c === v || c < g ? t.moveToPreviousMatch() : t.moveToNextMatch();
385
385
  }
386
386
  }
387
387
  ),
388
388
  value: i,
389
- onChange: (c) => ae(c)
389
+ onChange: (c) => se(c)
390
390
  }
391
391
  ),
392
- /* @__PURE__ */ d.jsx("div", { className: L.findReplaceExpandContainer, children: /* @__PURE__ */ d.jsx(I, { type: "text", size: "small", onClick: re, children: e.t("univer.find-replace.dialog.advanced-finding") }) })
392
+ /* @__PURE__ */ d.jsx("div", { className: L.findReplaceExpandContainer, children: /* @__PURE__ */ d.jsx(I, { type: "text", size: "small", onClick: oe, children: e.t("univer.find-replace.dialog.advanced-finding") }) })
393
393
  ] });
394
394
  }
395
- function ce() {
395
+ function le() {
396
396
  return /* @__PURE__ */ d.jsxs(A, { children: [
397
397
  /* @__PURE__ */ d.jsx(P, { label: e.t("univer.find-replace.dialog.find"), children: /* @__PURE__ */ d.jsx(
398
398
  U,
@@ -411,16 +411,16 @@ function tt() {
411
411
  onChange: (c) => N(c)
412
412
  }
413
413
  ) }),
414
- /* @__PURE__ */ d.jsx(P, { label: e.t("univer.find-replace.dialog.find-range"), children: /* @__PURE__ */ d.jsx(Le, { value: "123", onChange: () => {
414
+ /* @__PURE__ */ d.jsx(P, { label: e.t("univer.find-replace.dialog.find-range"), children: /* @__PURE__ */ d.jsx(Ue, { value: "123", onChange: () => {
415
415
  } }) }),
416
416
  /* @__PURE__ */ d.jsx(I, { type: "primary", children: e.t("univer.find-replace.dialog.find") }),
417
417
  /* @__PURE__ */ d.jsx(I, { children: e.t("univer.find-replace.dialog.replace") }),
418
418
  /* @__PURE__ */ d.jsx(I, { children: e.t("univer.find-replace.dialog.replace-all") })
419
419
  ] });
420
420
  }
421
- return /* @__PURE__ */ d.jsx("div", { className: L.findReplaceDialogContainer, ref: s, children: h.replaceRevealed ? ce() : se() });
421
+ return /* @__PURE__ */ d.jsx("div", { className: L.findReplaceDialogContainer, ref: s, children: h.replaceRevealed ? le() : ce() });
422
422
  }
423
- function it(t) {
423
+ function tt(t) {
424
424
  return {
425
425
  id: D.id,
426
426
  icon: "SearchIcon",
@@ -428,89 +428,89 @@ function it(t) {
428
428
  group: Re.TOOLBAR_OTHERS,
429
429
  type: Me.BUTTON,
430
430
  positions: [Ie.TOOLBAR_START],
431
- hidden$: Ce(t, ue.SHEET)
431
+ hidden$: Ce(t, pe.SHEET)
432
432
  };
433
433
  }
434
- const nt = {
434
+ const it = {
435
435
  id: D.id,
436
436
  description: "shortcut.find-replace.open-find-dialog",
437
- binding: R.F | j.CTRL_COMMAND,
437
+ binding: R.F | F.CTRL_COMMAND,
438
438
  group: "4_find-replace",
439
439
  preconditions(t) {
440
- return !t.getContextValue(v);
440
+ return !t.getContextValue(_);
441
441
  }
442
- }, rt = {
443
- id: Q.id,
442
+ }, nt = {
443
+ id: X.id,
444
444
  description: "shortcut.find-replace.open-replace-dialog",
445
- binding: R.H | j.CTRL_COMMAND,
445
+ binding: R.H | F.CTRL_COMMAND,
446
446
  group: "4_find-replace",
447
447
  preconditions(t) {
448
- return !t.getContextValue(v);
448
+ return !t.getContextValue(_);
449
449
  }
450
- }, ot = {
451
- id: X.id,
450
+ }, rt = {
451
+ id: ee.id,
452
452
  description: "shortcut.find-replace.close-dialog",
453
453
  binding: R.ESC,
454
454
  group: "4_find-replace",
455
455
  priority: 1e3,
456
456
  preconditions(t) {
457
- return !!t.getContextValue(v);
457
+ return !!t.getContextValue(_);
458
458
  }
459
- }, at = {
460
- id: ee.id,
459
+ }, ot = {
460
+ id: te.id,
461
461
  description: "shortcut.find-replace.go-to-next-find-match",
462
462
  binding: R.ENTER,
463
463
  group: "4_find-replace",
464
464
  priority: 1e3,
465
465
  preconditions(t) {
466
- return !!t.getContextValue(v);
466
+ return !!t.getContextValue(_);
467
467
  }
468
- }, st = {
469
- id: te.id,
468
+ }, at = {
469
+ id: ie.id,
470
470
  description: "shortcut.find-replace.go-to-previous-find-match",
471
- binding: R.ENTER | j.SHIFT,
471
+ binding: R.ENTER | F.SHIFT,
472
472
  group: "4_find-replace",
473
473
  priority: 1e3,
474
474
  preconditions(t) {
475
- return !!t.getContextValue(v);
475
+ return !!t.getContextValue(_);
476
476
  }
477
477
  };
478
- var ct = Object.defineProperty, lt = Object.getOwnPropertyDescriptor, dt = (t, e, n, i) => {
479
- for (var r = i > 1 ? void 0 : i ? lt(e, n) : e, o = t.length - 1, a; o >= 0; o--)
478
+ var st = Object.defineProperty, ct = Object.getOwnPropertyDescriptor, lt = (t, e, n, i) => {
479
+ for (var r = i > 1 ? void 0 : i ? ct(e, n) : e, o = t.length - 1, a; o >= 0; o--)
480
480
  (a = t[o]) && (r = (i ? a(e, n, r) : a(r)) || r);
481
- return i && r && ct(e, n, r), r;
481
+ return i && r && st(e, n, r), r;
482
482
  }, p = (t, e) => (n, i) => e(n, i, t);
483
483
  const w = "DESKTOP_FIND_REPLACE_DIALOG";
484
484
  let C = class extends ve {
485
- constructor(t, e, n, i, r, o, a, s, h, _) {
486
- super(), this._menuService = t, this._shortcutService = e, this._commandService = n, this._findReplaceService = i, this._dialogService = r, this._contextService = o, this._focusService = a, this._localeService = s, this._componentManager = h, this._injector = _, this._initOperations(), this._initUI(), this._initShortcuts();
485
+ constructor(t, e, n, i, r, o, a, s, h, v) {
486
+ super(), this._menuService = t, this._shortcutService = e, this._commandService = n, this._findReplaceService = i, this._dialogService = r, this._contextService = o, this._layoutService = a, this._localeService = s, this._componentManager = h, this._injector = v, this._initOperations(), this._initUI(), this._initShortcuts();
487
487
  }
488
488
  _initOperations() {
489
489
  [
490
- X,
491
- D,
492
- Q,
493
- Ke,
494
490
  ee,
495
- te
491
+ D,
492
+ X,
493
+ ze,
494
+ te,
495
+ ie
496
496
  ].forEach((t) => {
497
497
  this.disposeWithMe(this._commandService.registerCommand(t));
498
498
  });
499
499
  }
500
500
  _initUI() {
501
- [it].forEach((t) => {
501
+ [tt].forEach((t) => {
502
502
  this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)));
503
- }), this.disposeWithMe(this._componentManager.register("FindReplaceDialog", tt)), this.disposeWithMe(this._componentManager.register("SearchIcon", Z)), this._findReplaceService.stateUpdates$.pipe(je(this.dispose$)).subscribe((t) => {
503
+ }), this.disposeWithMe(this._componentManager.register("FindReplaceDialog", et)), this.disposeWithMe(this._componentManager.register("SearchIcon", J)), this._findReplaceService.stateUpdates$.pipe(je(this.dispose$)).subscribe((t) => {
504
504
  t.revealed === !0 ? this._openPanel() : t.revealed === !1 && this._closePanel();
505
505
  });
506
506
  }
507
507
  _initShortcuts() {
508
508
  [
509
- rt,
510
509
  nt,
511
- ot,
512
- st,
513
- at
510
+ it,
511
+ rt,
512
+ at,
513
+ ot
514
514
  ].forEach((t) => {
515
515
  this.disposeWithMe(this._shortcutService.registerShortcut(t));
516
516
  });
@@ -523,26 +523,26 @@ let C = class extends ve {
523
523
  title: { title: this._localeService.t("univer.find-replace.dialog.title") },
524
524
  children: { label: "FindReplaceDialog" },
525
525
  onClose: () => this._closePanel()
526
- }), this._contextService.setContextValue(v, !0);
526
+ }), this._contextService.setContextValue(_, !0);
527
527
  }
528
528
  _closePanel() {
529
- this._dialogService.close(w), this._contextService.setContextValue(v, !1), this._focusService.forceFocus(), this._findReplaceService.end();
529
+ this._dialogService.close(w), this._contextService.setContextValue(_, !1), this._layoutService.focus(), this._findReplaceService.end();
530
530
  }
531
531
  };
532
- C = dt([
533
- pe(fe.Rendered, C),
532
+ C = lt([
533
+ fe(_e.Rendered, C),
534
534
  p(0, Pe),
535
535
  p(1, ye),
536
- p(2, _e),
536
+ p(2, ge),
537
537
  p(3, f),
538
538
  p(4, Te),
539
- p(5, ge),
540
- p(6, be),
541
- p(7, S(F)),
539
+ p(5, me),
540
+ p(6, W),
541
+ p(7, S(j)),
542
542
  p(8, S(Oe)),
543
543
  p(9, S(H))
544
544
  ], C);
545
- const ht = {
545
+ const dt = {
546
546
  univer: {
547
547
  "find-replace": {
548
548
  dialog: {
@@ -558,16 +558,16 @@ const ht = {
558
558
  }
559
559
  }
560
560
  };
561
- var ut = Object.defineProperty, pt = Object.getOwnPropertyDescriptor, ft = (t, e, n, i) => {
562
- for (var r = i > 1 ? void 0 : i ? pt(e, n) : e, o = t.length - 1, a; o >= 0; o--)
561
+ var ht = Object.defineProperty, ut = Object.getOwnPropertyDescriptor, pt = (t, e, n, i) => {
562
+ for (var r = i > 1 ? void 0 : i ? ut(e, n) : e, o = t.length - 1, a; o >= 0; o--)
563
563
  (a = t[o]) && (r = (i ? a(e, n, r) : a(r)) || r);
564
- return i && r && ut(e, n, r), r;
565
- }, vt = (t, e) => (n, i) => e(n, i, t);
564
+ return i && r && ht(e, n, r), r;
565
+ }, ft = (t, e) => (n, i) => e(n, i, t);
566
566
  const _t = "FIND_REPLACE";
567
- let V = class extends me {
567
+ let V = class extends Se {
568
568
  constructor(t, e) {
569
569
  super(_t), this._injector = t, this._localeService = e, this._localeService.load({
570
- zhCN: ht
570
+ zhCN: dt
571
571
  });
572
572
  }
573
573
  onStarting(t) {
@@ -578,11 +578,11 @@ let V = class extends me {
578
578
  );
579
579
  }
580
580
  };
581
- V = ft([
582
- vt(1, S(F))
581
+ V = pt([
582
+ ft(1, S(j))
583
583
  ], V);
584
584
  export {
585
- Ot as FindModel,
585
+ Ct as FindModel,
586
586
  f as IFindReplaceService,
587
587
  V as UniverFindReplacePlugin
588
588
  };
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { ICommandService, IContextService, LocaleService, RxDisposable } from '@univerjs/core';
17
- import { ComponentManager, IDialogService, IFocusService, IMenuService, IShortcutService } from '@univerjs/ui';
17
+ import { ComponentManager, IDialogService, ILayoutService, IMenuService, IShortcutService } from '@univerjs/ui';
18
18
  import { Injector } from '@wendellhu/redi';
19
19
  import { IFindReplaceService } from '../services/find-replace.service';
20
20
  export declare class FindReplaceController extends RxDisposable {
@@ -24,11 +24,11 @@ export declare class FindReplaceController extends RxDisposable {
24
24
  private readonly _findReplaceService;
25
25
  private readonly _dialogService;
26
26
  private readonly _contextService;
27
- private readonly _focusService;
27
+ private readonly _layoutService;
28
28
  private readonly _localeService;
29
29
  private readonly _componentManager;
30
30
  private readonly _injector;
31
- constructor(_menuService: IMenuService, _shortcutService: IShortcutService, _commandService: ICommandService, _findReplaceService: IFindReplaceService, _dialogService: IDialogService, _contextService: IContextService, _focusService: IFocusService, _localeService: LocaleService, _componentManager: ComponentManager, _injector: Injector);
31
+ constructor(_menuService: IMenuService, _shortcutService: IShortcutService, _commandService: ICommandService, _findReplaceService: IFindReplaceService, _dialogService: IDialogService, _contextService: IContextService, _layoutService: ILayoutService, _localeService: LocaleService, _componentManager: ComponentManager, _injector: Injector);
32
32
  private _initOperations;
33
33
  private _initUI;
34
34
  private _initShortcuts;
@@ -13,20 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- declare const locale: {
17
- univer: {
18
- 'find-replace': {
19
- dialog: {
20
- title: string;
21
- find: string;
22
- replace: string;
23
- 'replace-all': string;
24
- 'find-range': string;
25
- 'find-placeholder': string;
26
- 'advanced-finding': string;
27
- 'replace-placeholder': string;
28
- };
29
- };
30
- };
31
- };
16
+ import type zhCN from './zh-CN';
17
+ declare const locale: typeof zhCN;
32
18
  export default locale;
@@ -13,6 +13,20 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type enUS from './en-US';
17
- declare const locale: typeof enUS;
16
+ declare const locale: {
17
+ univer: {
18
+ 'find-replace': {
19
+ dialog: {
20
+ title: string;
21
+ find: string;
22
+ replace: string;
23
+ 'replace-all': string;
24
+ 'find-range': string;
25
+ 'find-placeholder': string;
26
+ 'advanced-finding': string;
27
+ 'replace-placeholder': string;
28
+ };
29
+ };
30
+ };
31
+ };
18
32
  export default locale;
@@ -77,6 +77,25 @@ export interface IFindQuery {
77
77
  /** Other possible options set by business. */
78
78
  [key: string]: boolean | string | number | undefined;
79
79
  }
80
+ /**
81
+ * This class stores find replace options state. These state are stored
82
+ * here instead of the React component so we can change state from
83
+ * operations.
84
+ */
85
+ export declare class FindReplaceState {
86
+ private readonly _stateUpdates$;
87
+ readonly stateUpdates$: Observable<Partial<IFindReplaceState>>;
88
+ private readonly _state$;
89
+ readonly state$: Observable<IFindReplaceState>;
90
+ get state(): IFindReplaceState;
91
+ private _findString;
92
+ private _revealed;
93
+ private _replaceRevealed;
94
+ private _matchesPosition;
95
+ private _matchesCount;
96
+ get findString(): string;
97
+ changeState(changes: Partial<IFindReplaceState>): void;
98
+ }
80
99
  /**
81
100
  * This class stores find replace results and provides methods to perform replace or something.
82
101
  */
@@ -107,25 +126,6 @@ export interface IFindReplaceState {
107
126
  matchesPosition: number;
108
127
  matchesCount: number;
109
128
  }
110
- /**
111
- * This class stores find replace options state. These state are stored
112
- * here instead of the React component so we can change state from
113
- * operations.
114
- */
115
- export declare class FindReplaceState {
116
- private readonly _stateUpdates$;
117
- readonly stateUpdates$: Observable<Partial<IFindReplaceState>>;
118
- private readonly _state$;
119
- readonly state$: Observable<IFindReplaceState>;
120
- get state(): IFindReplaceState;
121
- private _findString;
122
- private _revealed;
123
- private _replaceRevealed;
124
- private _matchesPosition;
125
- private _matchesCount;
126
- get findString(): string;
127
- changeState(changes: Partial<IFindReplaceState>): void;
128
- }
129
129
  export declare class FindReplaceService extends Disposable implements IFindReplaceService {
130
130
  private readonly _injector;
131
131
  private readonly _univerInstanceService;
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","react","@univerjs/design","@wendellhu/redi/react-bindings"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverFindReplace={},c.UniverCore,c["@wendellhu/redi"],c.UniverUi,c.rxjs,c.React,c.UniverDesign,c["@wendellhu/redi/react-bindings"]))})(this,function(c,o,v,h,O,p,_,T){"use strict";var je=Object.defineProperty;var Fe=(c,o,v)=>o in c?je(c,o,{enumerable:!0,configurable:!0,writable:!0,value:v}):c[o]=v;var u=(c,o,v)=>(Fe(c,typeof o!="symbol"?o+"":o,v),v);var g=function(){return g=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},g.apply(this,arguments)},z=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r},E=p.forwardRef(function(t,e){var r=t.icon,i=t.id,n=t.className,a=t.extend,s=z(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(i," ").concat(n||"").trim(),m=p.useRef("_".concat(Y()));return D(r,"".concat(i),{defIds:r.defIds,idSuffix:m.current},g({ref:e,className:l},s),a)});function D(t,e,r,i,n){return p.createElement(t.tag,g(g({key:e},Z(t,r,n)),i),(J(t,r).children||[]).map(function(a,s){return D(a,"".concat(e,"-").concat(t.tag,"-").concat(s),r,void 0,n)}))}function Z(t,e,r){var i=g({},t.attrs);r!=null&&r.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=r.colorChannel1);var n=e.defIds;return!n||n.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(a){var s=a[0],l=a[1];typeof l=="string"&&(i[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function J(t,e){var r,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?g(g({},t),{children:t.children.map(function(n){return typeof n.attrs.id=="string"&&i&&i.indexOf(n.attrs.id)>-1?g(g({},n),{attrs:g(g({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):t}function Y(){return Math.random().toString(36).substring(2,8)}E.displayName="UniverIcon";var Q={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_217_40",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.9 0.09H16.9V16.09H0.9z"}}]},{tag:"g",attrs:{mask:"url(#mask0_217_40)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},N=p.forwardRef(function(t,e){return p.createElement(E,Object.assign({},t,{id:"search-single-16",ref:e,icon:Q}))});N.displayName="SearchSingle16";var X=Object.defineProperty,$=Object.getOwnPropertyDescriptor,U=(t,e,r,i)=>{for(var n=i>1?void 0:i?$(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&X(e,r,n),n},M=(t,e)=>(r,i)=>e(r,i,t);class q extends o.Disposable{}const x=v.createIdentifier("univer.find-replace.service");let j=class extends o.Disposable{constructor(e,r,i,n){super();u(this,"_matchPositionFindModel",null);u(this,"_findModels",[]);u(this,"_matches",[]);u(this,"_positionModel",null);this._state=e,this._providers=r,this._logService=i,this._univerInstanceService=n,this._state.stateUpdates$.subscribe(a=>{typeof a.findString<"u"&&(a.findString?this.find():this._cancelFinding())})}async find(){this._cancelFinding();const e=Array.from(this._providers),r=this._findModels=(await Promise.all(e.map(a=>a.find({text:this._state.findString})))).flat(),i=r.map(a=>a.getMatches()).flat();if(this._matches=i,!i.length)return{results:[]};const n=this._moveToInitialMatch(r,i);return this._state.changeState({matchesCount:i.length,matchesPosition:n+1}),{results:i}}moveToNextMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,r=this._positionModel.moveToNextMatch(e);if(r){const i=this._matches.findIndex(n=>n===r);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(l=>l===this._positionModel),n=this._findModels[(i+1)%this._findModels.length],a=n.moveToNextMatch(),s=this._matches.findIndex(l=>l===a);this._positionModel=n,this._state.changeState({matchesPosition:s+1})}}moveToPreviousMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,r=this._positionModel.moveToPreviousMatch(e);if(r){const i=this._matches.findIndex(n=>n===r);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(l=>l===this._positionModel),n=this._findModels[(i-1+this._findModels.length)%this._findModels.length],a=n.moveToPreviousMatch(),s=this._matches.findIndex(l=>l===a);this._positionModel=n,this._state.changeState({matchesPosition:s+1})}}_moveToInitialMatch(e,r){var l;const i=(l=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:l.getUnitId();if(!i)return-1;const n=e.find(m=>m.unitId===i);if(n){this._positionModel=n;const m=n.moveToNextMatch();return r.findIndex(I=>I===m)}this._positionModel=e[0];const a=this._positionModel.moveToNextMatch();return this._matches.findIndex(m=>m===a)}_cancelFinding(){this._providers.forEach(e=>e.cancel()),this._state.changeState({matchesCount:0,matchesPosition:0})}};j=U([M(2,o.ILogService),M(3,o.IUniverInstanceService)],j);function w(){return{revealed:!0,findString:"",replaceRevealed:!1,matchesPosition:0,matchesCount:0}}class ee{constructor(){u(this,"_stateUpdates$",new O.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new O.BehaviorSubject(w()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0)}get state(){return this._state$.getValue()}get findString(){return this._findString}changeState(e){let r=!1;const i={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,i.findString=this._findString,r=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,i.revealed=e.revealed,r=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,i.replaceRevealed=e.replaceRevealed,r=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,i.matchesCount=e.matchesCount,r=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,i.matchesPosition=e.matchesPosition,r=!0),r&&(this._stateUpdates$.next(i),this._state$.next({findString:this._findString,revealed:this._revealed,replaceRevealed:this._replaceRevealed,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition}))}}let F=class extends o.Disposable{constructor(e,r,i){super();u(this,"_providers",new Set);u(this,"_state",new ee);u(this,"_model");this._injector=e,this._univerInstanceService=r,this._logService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}changeFindString(e){this._state.changeState({findString:e})}moveToNextMatch(){var e;this._model&&((e=this._model)==null||e.moveToNextMatch())}moveToPreviousMatch(){var e;this._model&&((e=this._model)==null||e.moveToPreviousMatch())}replace(){return!0}replaceAll(){return!0}revealReplace(){this._state.changeState({replaceRevealed:!0})}disposeModel(){var e;(e=this._model)==null||e.dispose(),this._model=null}start(){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(j,this._state,this._providers);const e=w();return e.revealed=!0,this._state.changeState(e),!0}end(){return this._state.changeState({revealed:!1,replaceRevealed:!1}),!0}registerFindReplaceProvider(e){return this._providers.add(e),o.toDisposable(()=>this._providers.delete(e))}};F=U([M(0,v.Inject(v.Injector)),M(1,o.IUniverInstanceService),M(2,o.ILogService)],F);const b={id:"ui.operation.open-find-dialog",type:o.CommandType.OPERATION,handler:t=>(t.get(x).start(),!0)},A={id:"ui.operation.open-replace-dialog",type:o.CommandType.OPERATION,handler:t=>(t.get(x).start(),!0)},te={id:"ui.operation.toggle-replace-dialog",type:o.CommandType.OPERATION,handler:t=>(t.get(x),!0)},L={id:"ui.operation.close-find-replace-dialog",type:o.CommandType.OPERATION,handler:t=>!0},V={type:o.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(x).moveToNextMatch(),!0)},B={type:o.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(x).moveToPreviousMatch(),!0)},R="FIND_REPLACE_ACTIVATED";var K={exports:{}},y={};/**
1
+ (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","react","@univerjs/design","@wendellhu/redi/react-bindings"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverFindReplace={},c.UniverCore,c["@wendellhu/redi"],c.UniverUi,c.rxjs,c.React,c.UniverDesign,c["@wendellhu/redi/react-bindings"]))})(this,function(c,o,v,h,O,p,_,T){"use strict";var je=Object.defineProperty;var be=(c,o,v)=>o in c?je(c,o,{enumerable:!0,configurable:!0,writable:!0,value:v}):c[o]=v;var u=(c,o,v)=>(be(c,typeof o!="symbol"?o+"":o,v),v);var g=function(){return g=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},g.apply(this,arguments)},z=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r},E=p.forwardRef(function(t,e){var r=t.icon,i=t.id,n=t.className,a=t.extend,s=z(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(i," ").concat(n||"").trim(),m=p.useRef("_".concat(Y()));return D(r,"".concat(i),{defIds:r.defIds,idSuffix:m.current},g({ref:e,className:l},s),a)});function D(t,e,r,i,n){return p.createElement(t.tag,g(g({key:e},Z(t,r,n)),i),(J(t,r).children||[]).map(function(a,s){return D(a,"".concat(e,"-").concat(t.tag,"-").concat(s),r,void 0,n)}))}function Z(t,e,r){var i=g({},t.attrs);r!=null&&r.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=r.colorChannel1);var n=e.defIds;return!n||n.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(a){var s=a[0],l=a[1];typeof l=="string"&&(i[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function J(t,e){var r,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?g(g({},t),{children:t.children.map(function(n){return typeof n.attrs.id=="string"&&i&&i.indexOf(n.attrs.id)>-1?g(g({},n),{attrs:g(g({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):t}function Y(){return Math.random().toString(36).substring(2,8)}E.displayName="UniverIcon";var Q={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_217_40",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.9 0.09H16.9V16.09H0.9z"}}]},{tag:"g",attrs:{mask:"url(#mask0_217_40)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},N=p.forwardRef(function(t,e){return p.createElement(E,Object.assign({},t,{id:"search-single-16",ref:e,icon:Q}))});N.displayName="SearchSingle16";var X=Object.defineProperty,$=Object.getOwnPropertyDescriptor,U=(t,e,r,i)=>{for(var n=i>1?void 0:i?$(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&X(e,r,n),n},M=(t,e)=>(r,i)=>e(r,i,t);class q extends o.Disposable{}const x=v.createIdentifier("univer.find-replace.service");class ee{constructor(){u(this,"_stateUpdates$",new O.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new O.BehaviorSubject(L()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0)}get state(){return this._state$.getValue()}get findString(){return this._findString}changeState(e){let r=!1;const i={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,i.findString=this._findString,r=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,i.revealed=e.revealed,r=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,i.replaceRevealed=e.replaceRevealed,r=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,i.matchesCount=e.matchesCount,r=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,i.matchesPosition=e.matchesPosition,r=!0),r&&(this._stateUpdates$.next(i),this._state$.next({findString:this._findString,revealed:this._revealed,replaceRevealed:this._replaceRevealed,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition}))}}let j=class extends o.Disposable{constructor(e,r,i,n){super();u(this,"_matchPositionFindModel",null);u(this,"_findModels",[]);u(this,"_matches",[]);u(this,"_positionModel",null);this._state=e,this._providers=r,this._logService=i,this._univerInstanceService=n,this._state.stateUpdates$.subscribe(a=>{typeof a.findString<"u"&&(a.findString?this.find():this._cancelFinding())})}async find(){this._cancelFinding();const e=Array.from(this._providers),r=this._findModels=(await Promise.all(e.map(a=>a.find({text:this._state.findString})))).flat(),i=r.map(a=>a.getMatches()).flat();if(this._matches=i,!i.length)return{results:[]};const n=this._moveToInitialMatch(r,i);return this._state.changeState({matchesCount:i.length,matchesPosition:n+1}),{results:i}}moveToNextMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,r=this._positionModel.moveToNextMatch(e);if(r){const i=this._matches.findIndex(n=>n===r);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(l=>l===this._positionModel),n=this._findModels[(i+1)%this._findModels.length],a=n.moveToNextMatch(),s=this._matches.findIndex(l=>l===a);this._positionModel=n,this._state.changeState({matchesPosition:s+1})}}moveToPreviousMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,r=this._positionModel.moveToPreviousMatch(e);if(r){const i=this._matches.findIndex(n=>n===r);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(l=>l===this._positionModel),n=this._findModels[(i-1+this._findModels.length)%this._findModels.length],a=n.moveToPreviousMatch(),s=this._matches.findIndex(l=>l===a);this._positionModel=n,this._state.changeState({matchesPosition:s+1})}}_moveToInitialMatch(e,r){var l;const i=(l=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:l.getUnitId();if(!i)return-1;const n=e.find(m=>m.unitId===i);if(n){this._positionModel=n;const m=n.moveToNextMatch();return r.findIndex(I=>I===m)}this._positionModel=e[0];const a=this._positionModel.moveToNextMatch();return this._matches.findIndex(m=>m===a)}_cancelFinding(){this._providers.forEach(e=>e.cancel()),this._state.changeState({matchesCount:0,matchesPosition:0})}};j=U([M(2,o.ILogService),M(3,o.IUniverInstanceService)],j);function L(){return{revealed:!0,findString:"",replaceRevealed:!1,matchesPosition:0,matchesCount:0}}let b=class extends o.Disposable{constructor(e,r,i){super();u(this,"_providers",new Set);u(this,"_state",new ee);u(this,"_model");this._injector=e,this._univerInstanceService=r,this._logService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}changeFindString(e){this._state.changeState({findString:e})}moveToNextMatch(){var e;this._model&&((e=this._model)==null||e.moveToNextMatch())}moveToPreviousMatch(){var e;this._model&&((e=this._model)==null||e.moveToPreviousMatch())}replace(){return!0}replaceAll(){return!0}revealReplace(){this._state.changeState({replaceRevealed:!0})}disposeModel(){var e;(e=this._model)==null||e.dispose(),this._model=null}start(){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(j,this._state,this._providers);const e=L();return e.revealed=!0,this._state.changeState(e),!0}end(){return this._state.changeState({revealed:!1,replaceRevealed:!1}),!0}registerFindReplaceProvider(e){return this._providers.add(e),o.toDisposable(()=>this._providers.delete(e))}};b=U([M(0,v.Inject(v.Injector)),M(1,o.IUniverInstanceService),M(2,o.ILogService)],b);const F={id:"ui.operation.open-find-dialog",type:o.CommandType.OPERATION,handler:t=>(t.get(x).start(),!0)},w={id:"ui.operation.open-replace-dialog",type:o.CommandType.OPERATION,handler:t=>(t.get(x).start(),!0)},te={id:"ui.operation.toggle-replace-dialog",type:o.CommandType.OPERATION,handler:t=>(t.get(x),!0)},A={id:"ui.operation.close-find-replace-dialog",type:o.CommandType.OPERATION,handler:t=>!0},V={type:o.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(x).moveToNextMatch(),!0)},B={type:o.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(x).moveToPreviousMatch(),!0)},R="FIND_REPLACE_ACTIVATED";var K={exports:{}},y={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ie=p,ne=Symbol.for("react.element"),re=Symbol.for("react.fragment"),ae=Object.prototype.hasOwnProperty,oe=ie.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,se={key:!0,ref:!0,__self:!0,__source:!0};function k(t,e,r){var i,n={},a=null,s=null;r!==void 0&&(a=""+r),e.key!==void 0&&(a=""+e.key),e.ref!==void 0&&(s=e.ref);for(i in e)ae.call(e,i)&&!se.hasOwnProperty(i)&&(n[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)n[i]===void 0&&(n[i]=e[i]);return{$$typeof:ne,type:t,key:a,ref:s,props:n,_owner:oe.current}}y.Fragment=re,y.jsx=k,y.jsxs=k,K.exports=y;var f=K.exports;const G={findReplaceExpandContainer:"univer-find-replace-expand-container"};function ce(){const t=T.useDependency(x),e=T.useDependency(o.LocaleService),r=T.useDependency(h.LayoutService),[i,n]=p.useState(""),[a,s]=p.useState(""),l=p.useRef(null),m=_.useObservable(t.state$,!0),{matchesCount:C,matchesPosition:I}=m,Me=p.useCallback(()=>t.revealReplace(),[t]),ye=p.useCallback(d=>t.changeFindString(d),[t]),Pe=p.useCallback(d=>{n(d),ye(d)},[t]),W=p.useCallback(d=>{s(d)},[t]);p.useEffect(()=>{let d;return l.current&&(d=r.registerContainer(l.current)),()=>d==null?void 0:d.dispose()},[l.current]);function Oe(){return f.jsxs(p.Fragment,{children:[f.jsx(_.InputWithSlot,{autoFocus:!0,placeholder:e.t("univer.find-replace.dialog.find-placeholder"),slot:f.jsx(_.Pager,{loop:!0,value:I,total:C,onChange:d=>{I===C&&d===1?t.moveToNextMatch():I===1&&d===C||d<I?t.moveToPreviousMatch():t.moveToNextMatch()}}),value:i,onChange:d=>Pe(d)}),f.jsx("div",{className:G.findReplaceExpandContainer,children:f.jsx(_.Button,{type:"text",size:"small",onClick:Me,children:e.t("univer.find-replace.dialog.advanced-finding")})})]})}function Te(){return f.jsxs(p.Fragment,{children:[f.jsx(_.FormLayout,{label:e.t("univer.find-replace.dialog.find"),children:f.jsx(_.Input,{placeholder:e.t("univer.find-replace.dialog.find-placeholder"),autoFocus:!0,value:i,onChange:d=>W(d)})}),f.jsx(_.FormLayout,{label:e.t("univer.find-replace.dialog.replace"),children:f.jsx(_.Input,{placeholder:e.t("univer.find-replace.dialog.replace-placeholder"),value:a,onChange:d=>W(d)})}),f.jsx(_.FormLayout,{label:e.t("univer.find-replace.dialog.find-range"),children:f.jsx(_.Select,{value:"123",onChange:()=>{}})}),f.jsx(_.Button,{type:"primary",children:e.t("univer.find-replace.dialog.find")}),f.jsx(_.Button,{children:e.t("univer.find-replace.dialog.replace")}),f.jsx(_.Button,{children:e.t("univer.find-replace.dialog.replace-all")})]})}return f.jsx("div",{className:G.findReplaceDialogContainer,ref:l,children:m.replaceRevealed?Te():Oe()})}function le(t){return{id:b.id,icon:"SearchIcon",tooltip:"toolbar.find-replace",group:h.MenuGroup.TOOLBAR_OTHERS,type:h.MenuItemType.BUTTON,positions:[h.MenuPosition.TOOLBAR_START],hidden$:h.getMenuHiddenObservable(t,o.UniverInstanceType.SHEET)}}const de={id:b.id,description:"shortcut.find-replace.open-find-dialog",binding:h.KeyCode.F|h.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(R)}},he={id:A.id,description:"shortcut.find-replace.open-replace-dialog",binding:h.KeyCode.H|h.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(R)}},ue={id:L.id,description:"shortcut.find-replace.close-dialog",binding:h.KeyCode.ESC,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(R)}},pe={id:V.id,description:"shortcut.find-replace.go-to-next-find-match",binding:h.KeyCode.ENTER,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(R)}},fe={id:B.id,description:"shortcut.find-replace.go-to-previous-find-match",binding:h.KeyCode.ENTER|h.MetaKeys.SHIFT,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(R)}};var ve=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,ge=(t,e,r,i)=>{for(var n=i>1?void 0:i?_e(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&ve(e,r,n),n},S=(t,e)=>(r,i)=>e(r,i,t);const H="DESKTOP_FIND_REPLACE_DIALOG";let P=class extends o.RxDisposable{constructor(t,e,r,i,n,a,s,l,m,C){super(),this._menuService=t,this._shortcutService=e,this._commandService=r,this._findReplaceService=i,this._dialogService=n,this._contextService=a,this._focusService=s,this._localeService=l,this._componentManager=m,this._injector=C,this._initOperations(),this._initUI(),this._initShortcuts()}_initOperations(){[L,b,A,te,V,B].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initUI(){[le].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)))}),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",ce)),this.disposeWithMe(this._componentManager.register("SearchIcon",N)),this._findReplaceService.stateUpdates$.pipe(O.takeUntil(this.dispose$)).subscribe(t=>{t.revealed===!0?this._openPanel():t.revealed===!1&&this._closePanel()})}_initShortcuts(){[he,de,ue,fe,pe].forEach(t=>{this.disposeWithMe(this._shortcutService.registerShortcut(t))})}_openPanel(){this._dialogService.open({id:H,draggable:!0,width:350,title:{title:this._localeService.t("univer.find-replace.dialog.title")},children:{label:"FindReplaceDialog"},onClose:()=>this._closePanel()}),this._contextService.setContextValue(R,!0)}_closePanel(){this._dialogService.close(H),this._contextService.setContextValue(R,!1),this._focusService.forceFocus(),this._findReplaceService.end()}};P=ge([o.OnLifecycle(o.LifecycleStages.Rendered,P),S(0,h.IMenuService),S(1,h.IShortcutService),S(2,o.ICommandService),S(3,x),S(4,h.IDialogService),S(5,o.IContextService),S(6,h.IFocusService),S(7,v.Inject(o.LocaleService)),S(8,v.Inject(h.ComponentManager)),S(9,v.Inject(v.Injector))],P);const me={univer:{"find-replace":{dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-range":"查找范围","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容"}}}};var Se=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Re=(t,e,r,i)=>{for(var n=i>1?void 0:i?xe(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Se(e,r,n),n},Ce=(t,e)=>(r,i)=>e(r,i,t);const Ie="FIND_REPLACE";c.UniverFindReplacePlugin=class extends o.Plugin{constructor(e,r){super(Ie),this._injector=e,this._localeService=r,this._localeService.load({zhCN:me})}onStarting(e){[[P],[x,{useClass:F}]].forEach(r=>{e.add(r)})}},c.UniverFindReplacePlugin=Re([Ce(1,v.Inject(o.LocaleService))],c.UniverFindReplacePlugin),c.FindModel=q,c.IFindReplaceService=x,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
9
+ */var ie=p,ne=Symbol.for("react.element"),re=Symbol.for("react.fragment"),ae=Object.prototype.hasOwnProperty,oe=ie.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,se={key:!0,ref:!0,__self:!0,__source:!0};function k(t,e,r){var i,n={},a=null,s=null;r!==void 0&&(a=""+r),e.key!==void 0&&(a=""+e.key),e.ref!==void 0&&(s=e.ref);for(i in e)ae.call(e,i)&&!se.hasOwnProperty(i)&&(n[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)n[i]===void 0&&(n[i]=e[i]);return{$$typeof:ne,type:t,key:a,ref:s,props:n,_owner:oe.current}}y.Fragment=re,y.jsx=k,y.jsxs=k,K.exports=y;var f=K.exports;const G={findReplaceExpandContainer:"univer-find-replace-expand-container"};function ce(){const t=T.useDependency(x),e=T.useDependency(o.LocaleService),r=T.useDependency(h.ILayoutService),[i,n]=p.useState(""),[a,s]=p.useState(""),l=p.useRef(null),m=_.useObservable(t.state$,!0),{matchesCount:C,matchesPosition:I}=m,Me=p.useCallback(()=>t.revealReplace(),[t]),ye=p.useCallback(d=>t.changeFindString(d),[t]),Pe=p.useCallback(d=>{n(d),ye(d)},[t]),W=p.useCallback(d=>{s(d)},[t]);p.useEffect(()=>{let d;return l.current&&(d=r.registerContainerElement(l.current)),()=>d==null?void 0:d.dispose()},[l.current]);function Oe(){return f.jsxs(p.Fragment,{children:[f.jsx(_.InputWithSlot,{autoFocus:!0,placeholder:e.t("univer.find-replace.dialog.find-placeholder"),slot:f.jsx(_.Pager,{loop:!0,value:I,total:C,onChange:d=>{I===C&&d===1?t.moveToNextMatch():I===1&&d===C||d<I?t.moveToPreviousMatch():t.moveToNextMatch()}}),value:i,onChange:d=>Pe(d)}),f.jsx("div",{className:G.findReplaceExpandContainer,children:f.jsx(_.Button,{type:"text",size:"small",onClick:Me,children:e.t("univer.find-replace.dialog.advanced-finding")})})]})}function Te(){return f.jsxs(p.Fragment,{children:[f.jsx(_.FormLayout,{label:e.t("univer.find-replace.dialog.find"),children:f.jsx(_.Input,{placeholder:e.t("univer.find-replace.dialog.find-placeholder"),autoFocus:!0,value:i,onChange:d=>W(d)})}),f.jsx(_.FormLayout,{label:e.t("univer.find-replace.dialog.replace"),children:f.jsx(_.Input,{placeholder:e.t("univer.find-replace.dialog.replace-placeholder"),value:a,onChange:d=>W(d)})}),f.jsx(_.FormLayout,{label:e.t("univer.find-replace.dialog.find-range"),children:f.jsx(_.Select,{value:"123",onChange:()=>{}})}),f.jsx(_.Button,{type:"primary",children:e.t("univer.find-replace.dialog.find")}),f.jsx(_.Button,{children:e.t("univer.find-replace.dialog.replace")}),f.jsx(_.Button,{children:e.t("univer.find-replace.dialog.replace-all")})]})}return f.jsx("div",{className:G.findReplaceDialogContainer,ref:l,children:m.replaceRevealed?Te():Oe()})}function le(t){return{id:F.id,icon:"SearchIcon",tooltip:"toolbar.find-replace",group:h.MenuGroup.TOOLBAR_OTHERS,type:h.MenuItemType.BUTTON,positions:[h.MenuPosition.TOOLBAR_START],hidden$:h.getMenuHiddenObservable(t,o.UniverInstanceType.SHEET)}}const de={id:F.id,description:"shortcut.find-replace.open-find-dialog",binding:h.KeyCode.F|h.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(R)}},he={id:w.id,description:"shortcut.find-replace.open-replace-dialog",binding:h.KeyCode.H|h.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(R)}},ue={id:A.id,description:"shortcut.find-replace.close-dialog",binding:h.KeyCode.ESC,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(R)}},pe={id:V.id,description:"shortcut.find-replace.go-to-next-find-match",binding:h.KeyCode.ENTER,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(R)}},fe={id:B.id,description:"shortcut.find-replace.go-to-previous-find-match",binding:h.KeyCode.ENTER|h.MetaKeys.SHIFT,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(R)}};var ve=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,ge=(t,e,r,i)=>{for(var n=i>1?void 0:i?_e(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&ve(e,r,n),n},S=(t,e)=>(r,i)=>e(r,i,t);const H="DESKTOP_FIND_REPLACE_DIALOG";let P=class extends o.RxDisposable{constructor(t,e,r,i,n,a,s,l,m,C){super(),this._menuService=t,this._shortcutService=e,this._commandService=r,this._findReplaceService=i,this._dialogService=n,this._contextService=a,this._layoutService=s,this._localeService=l,this._componentManager=m,this._injector=C,this._initOperations(),this._initUI(),this._initShortcuts()}_initOperations(){[A,F,w,te,V,B].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initUI(){[le].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)))}),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",ce)),this.disposeWithMe(this._componentManager.register("SearchIcon",N)),this._findReplaceService.stateUpdates$.pipe(O.takeUntil(this.dispose$)).subscribe(t=>{t.revealed===!0?this._openPanel():t.revealed===!1&&this._closePanel()})}_initShortcuts(){[he,de,ue,fe,pe].forEach(t=>{this.disposeWithMe(this._shortcutService.registerShortcut(t))})}_openPanel(){this._dialogService.open({id:H,draggable:!0,width:350,title:{title:this._localeService.t("univer.find-replace.dialog.title")},children:{label:"FindReplaceDialog"},onClose:()=>this._closePanel()}),this._contextService.setContextValue(R,!0)}_closePanel(){this._dialogService.close(H),this._contextService.setContextValue(R,!1),this._layoutService.focus(),this._findReplaceService.end()}};P=ge([o.OnLifecycle(o.LifecycleStages.Rendered,P),S(0,h.IMenuService),S(1,h.IShortcutService),S(2,o.ICommandService),S(3,x),S(4,h.IDialogService),S(5,o.IContextService),S(6,h.ILayoutService),S(7,v.Inject(o.LocaleService)),S(8,v.Inject(h.ComponentManager)),S(9,v.Inject(v.Injector))],P);const me={univer:{"find-replace":{dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-range":"查找范围","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容"}}}};var Se=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Re=(t,e,r,i)=>{for(var n=i>1?void 0:i?xe(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Se(e,r,n),n},Ce=(t,e)=>(r,i)=>e(r,i,t);const Ie="FIND_REPLACE";c.UniverFindReplacePlugin=class extends o.Plugin{constructor(e,r){super(Ie),this._injector=e,this._localeService=r,this._localeService.load({zhCN:me})}onStarting(e){[[P],[x,{useClass:b}]].forEach(r=>{e.add(r)})}},c.UniverFindReplacePlugin=Re([Ce(1,v.Inject(o.LocaleService))],c.UniverFindReplacePlugin),c.FindModel=q,c.IFindReplaceService=x,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/find-replace",
3
- "version": "0.1.0-beta.5",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -48,16 +48,16 @@
48
48
  "npm": ">=8.0.0"
49
49
  },
50
50
  "peerDependencies": {
51
- "@univerjs/icons": "^0.1.28",
51
+ "@univerjs/icons": "^0.1.30",
52
52
  "@wendellhu/redi": "^0.13.0",
53
53
  "react": "^18.2.0",
54
54
  "rxjs": ">=7.0.0",
55
- "@univerjs/core": "0.1.0-beta.5",
56
- "@univerjs/design": "0.1.0-beta.5",
57
- "@univerjs/ui": "0.1.0-beta.5"
55
+ "@univerjs/core": "0.1.2",
56
+ "@univerjs/design": "0.1.2",
57
+ "@univerjs/ui": "0.1.2"
58
58
  },
59
59
  "dependencies": {
60
- "@univerjs/icons": "^0.1.28"
60
+ "@univerjs/icons": "^0.1.30"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/react": "^18.2.57",
@@ -67,10 +67,10 @@
67
67
  "typescript": "^5.3.3",
68
68
  "vite": "^5.1.4",
69
69
  "vitest": "^1.3.1",
70
- "@univerjs/core": "0.1.0-beta.5",
71
- "@univerjs/shared": "0.1.0-beta.5",
72
- "@univerjs/ui": "0.1.0-beta.5",
73
- "@univerjs/design": "0.1.0-beta.5"
70
+ "@univerjs/design": "0.1.2",
71
+ "@univerjs/ui": "0.1.2",
72
+ "@univerjs/core": "0.1.2",
73
+ "@univerjs/shared": "0.1.2"
74
74
  },
75
75
  "scripts": {
76
76
  "test": "vitest run",