@univerjs/preset-sheets-find-replace 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/locales/en-US.js +1 -1
- package/lib/cjs/locales/fa-IR.js +1 -1
- package/lib/cjs/locales/fr-FR.js +1 -1
- package/lib/cjs/locales/ru-RU.js +1 -1
- package/lib/cjs/locales/vi-VN.js +1 -1
- package/lib/cjs/locales/zh-CN.js +1 -1
- package/lib/cjs/locales/zh-TW.js +1 -1
- package/lib/es/locales/en-US.js +3 -3
- package/lib/es/locales/fa-IR.js +3 -3
- package/lib/es/locales/fr-FR.js +5 -5
- package/lib/es/locales/ru-RU.js +5 -5
- package/lib/es/locales/vi-VN.js +5 -5
- package/lib/es/locales/zh-CN.js +3 -3
- package/lib/es/locales/zh-TW.js +3 -3
- package/lib/types/index.d.ts +1 -5
- package/lib/types/umd.d.ts +5 -0
- package/lib/umd/index.js +4 -4
- package/lib/umd/locales/en-US.js +1 -1
- package/lib/umd/locales/fa-IR.js +1 -1
- package/lib/umd/locales/fr-FR.js +1 -1
- package/lib/umd/locales/ru-RU.js +1 -1
- package/lib/umd/locales/vi-VN.js +1 -1
- package/lib/umd/locales/zh-CN.js +1 -1
- package/lib/umd/locales/zh-TW.js +1 -1
- package/package.json +8 -6
package/lib/cjs/locales/en-US.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("@univerjs/core"),r=require("@univerjs/find-replace/locale/en-US"),s=require("@univerjs/sheets-find-replace/locale/en-US"),n=e.
|
|
1
|
+
"use strict";const e=require("@univerjs/core"),r=require("@univerjs/find-replace/locale/en-US"),s=require("@univerjs/sheets-find-replace/locale/en-US"),n=e.merge({},r,s);module.exports=n;
|
package/lib/cjs/locales/fa-IR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("@univerjs/core"),r=require("@univerjs/find-replace/locale/fa-IR"),s=require("@univerjs/sheets-find-replace/locale/fa-IR"),c=e.
|
|
1
|
+
"use strict";const e=require("@univerjs/core"),r=require("@univerjs/find-replace/locale/fa-IR"),s=require("@univerjs/sheets-find-replace/locale/fa-IR"),c=e.merge({},r,s);module.exports=c;
|
package/lib/cjs/locales/fr-FR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("@univerjs/core"),r=require("@univerjs/find-replace/locale/fr-FR"),s=require("@univerjs/sheets-find-replace/locale/fr-FR"),c=e.
|
|
1
|
+
"use strict";const e=require("@univerjs/core"),r=require("@univerjs/find-replace/locale/fr-FR"),s=require("@univerjs/sheets-find-replace/locale/fr-FR"),c=e.merge({},r,s);module.exports=c;
|
package/lib/cjs/locales/ru-RU.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("@univerjs/core"),r=require("@univerjs/find-replace/locale/ru-RU"),s=require("@univerjs/sheets-find-replace/locale/ru-RU"),c=e.
|
|
1
|
+
"use strict";const e=require("@univerjs/core"),r=require("@univerjs/find-replace/locale/ru-RU"),s=require("@univerjs/sheets-find-replace/locale/ru-RU"),c=e.merge({},r,s);module.exports=c;
|
package/lib/cjs/locales/vi-VN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("@univerjs/core"),r=require("@univerjs/find-replace/locale/vi-VN"),s=require("@univerjs/sheets-find-replace/locale/vi-VN"),i=e.
|
|
1
|
+
"use strict";const e=require("@univerjs/core"),r=require("@univerjs/find-replace/locale/vi-VN"),s=require("@univerjs/sheets-find-replace/locale/vi-VN"),i=e.merge({},r,s);module.exports=i;
|
package/lib/cjs/locales/zh-CN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("@univerjs/core"),r=require("@univerjs/find-replace/locale/zh-CN"),s=require("@univerjs/sheets-find-replace/locale/zh-CN"),c=e.
|
|
1
|
+
"use strict";const e=require("@univerjs/core"),r=require("@univerjs/find-replace/locale/zh-CN"),s=require("@univerjs/sheets-find-replace/locale/zh-CN"),c=e.merge({},r,s);module.exports=c;
|
package/lib/cjs/locales/zh-TW.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("@univerjs/core"),r=require("@univerjs/find-replace/locale/zh-TW"),s=require("@univerjs/sheets-find-replace/locale/zh-TW"),c=e.
|
|
1
|
+
"use strict";const e=require("@univerjs/core"),r=require("@univerjs/find-replace/locale/zh-TW"),s=require("@univerjs/sheets-find-replace/locale/zh-TW"),c=e.merge({},r,s);module.exports=c;
|
package/lib/es/locales/en-US.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { merge as e } from "@univerjs/core";
|
|
2
2
|
import r from "@univerjs/find-replace/locale/en-US";
|
|
3
3
|
import o from "@univerjs/sheets-find-replace/locale/en-US";
|
|
4
|
-
const
|
|
4
|
+
const f = e(
|
|
5
5
|
{},
|
|
6
6
|
r,
|
|
7
7
|
o
|
|
8
8
|
);
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
f as default
|
|
11
11
|
};
|
package/lib/es/locales/fa-IR.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { merge as e } from "@univerjs/core";
|
|
2
2
|
import r from "@univerjs/find-replace/locale/fa-IR";
|
|
3
3
|
import o from "@univerjs/sheets-find-replace/locale/fa-IR";
|
|
4
|
-
const
|
|
4
|
+
const t = e(
|
|
5
5
|
{},
|
|
6
6
|
r,
|
|
7
7
|
o
|
|
8
8
|
);
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
t as default
|
|
11
11
|
};
|
package/lib/es/locales/fr-FR.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { merge as r } from "@univerjs/core";
|
|
2
|
+
import e from "@univerjs/find-replace/locale/fr-FR";
|
|
3
3
|
import o from "@univerjs/sheets-find-replace/locale/fr-FR";
|
|
4
|
-
const
|
|
4
|
+
const t = r(
|
|
5
5
|
{},
|
|
6
|
-
|
|
6
|
+
e,
|
|
7
7
|
o
|
|
8
8
|
);
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
t as default
|
|
11
11
|
};
|
package/lib/es/locales/ru-RU.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { merge as r } from "@univerjs/core";
|
|
2
|
+
import e from "@univerjs/find-replace/locale/ru-RU";
|
|
3
3
|
import o from "@univerjs/sheets-find-replace/locale/ru-RU";
|
|
4
|
-
const
|
|
4
|
+
const f = r(
|
|
5
5
|
{},
|
|
6
|
-
|
|
6
|
+
e,
|
|
7
7
|
o
|
|
8
8
|
);
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
f as default
|
|
11
11
|
};
|
package/lib/es/locales/vi-VN.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { merge as e } from "@univerjs/core";
|
|
2
2
|
import r from "@univerjs/find-replace/locale/vi-VN";
|
|
3
|
-
import
|
|
4
|
-
const
|
|
3
|
+
import i from "@univerjs/sheets-find-replace/locale/vi-VN";
|
|
4
|
+
const f = e(
|
|
5
5
|
{},
|
|
6
6
|
r,
|
|
7
|
-
|
|
7
|
+
i
|
|
8
8
|
);
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
f as default
|
|
11
11
|
};
|
package/lib/es/locales/zh-CN.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { merge as e } from "@univerjs/core";
|
|
2
2
|
import r from "@univerjs/find-replace/locale/zh-CN";
|
|
3
3
|
import o from "@univerjs/sheets-find-replace/locale/zh-CN";
|
|
4
|
-
const
|
|
4
|
+
const f = e(
|
|
5
5
|
{},
|
|
6
6
|
r,
|
|
7
7
|
o
|
|
8
8
|
);
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
f as default
|
|
11
11
|
};
|
package/lib/es/locales/zh-TW.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { merge as e } from "@univerjs/core";
|
|
2
2
|
import r from "@univerjs/find-replace/locale/zh-TW";
|
|
3
3
|
import o from "@univerjs/sheets-find-replace/locale/zh-TW";
|
|
4
|
-
const
|
|
4
|
+
const f = e(
|
|
5
5
|
{},
|
|
6
6
|
r,
|
|
7
7
|
o
|
|
8
8
|
);
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
f as default
|
|
11
11
|
};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import '@univerjs/find-replace/lib/index.css';
|
|
1
|
+
export * from './umd';
|
|
3
2
|
export * from '@univerjs/find-replace';
|
|
4
3
|
export * from '@univerjs/sheets-find-replace';
|
|
5
|
-
export interface IUniverSheetsFindReplacePresetConfig {
|
|
6
|
-
}
|
|
7
|
-
export declare function UniverSheetsFindReplacePreset(_config?: Partial<IUniverSheetsFindReplacePresetConfig>): IPreset;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @univerjs/find-replace/index
|
|
2
|
-
(function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("@univerjs/engine-render"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","rxjs","@univerjs/design","@univerjs/engine-render","react"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverFindReplace={},c.UniverCore,c.UniverUi,c.rxjs,c.UniverDesign,c.UniverEngineRender,c.React))})(this,function(c,a,d,S,_,de,l){"use strict";var mt=Object.defineProperty;var vt=(c,a,d)=>a in c?mt(c,a,{enumerable:!0,configurable:!0,writable:!0,value:d}):c[a]=d;var u=(c,a,d)=>vt(c,typeof a!="symbol"?a+"":a,d);var J;const ue="find-replace.config",he={};var C=function(){return C=Object.assign||function(n){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s])}return n},C.apply(this,arguments)},fe=function(n,e){var i={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.indexOf(t)<0&&(i[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,t=Object.getOwnPropertySymbols(n);s<t.length;s++)e.indexOf(t[s])<0&&Object.prototype.propertyIsEnumerable.call(n,t[s])&&(i[t[s]]=n[t[s]]);return i},Y=l.forwardRef(function(n,e){var i=n.icon,t=n.id,s=n.className,r=n.extend,o=fe(n,["icon","id","className","extend"]),h="univerjs-icon univerjs-icon-".concat(t," ").concat(s||"").trim(),f=l.useRef("_".concat(ge()));return Z(i,"".concat(t),{defIds:i.defIds,idSuffix:f.current},C({ref:e,className:h},o),r)});function Z(n,e,i,t,s){return l.createElement(n.tag,C(C({key:e},pe(n,i,s)),t),(_e(n,i).children||[]).map(function(r,o){return Z(r,"".concat(e,"-").concat(n.tag,"-").concat(o),i,void 0,s)}))}function pe(n,e,i){var t=C({},n.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1);var s=e.defIds;return!s||s.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(r){var o=r[0],h=r[1];typeof h=="string"&&(t[o]=h.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function _e(n,e){var i,t=e.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?C(C({},n),{children:n.children.map(function(s){return typeof s.attrs.id=="string"&&t&&t.indexOf(s.attrs.id)>-1?C(C({},s),{attrs:C(C({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):n}function ge(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";var me={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"}}]}]},Q=l.forwardRef(function(n,e){return l.createElement(Y,Object.assign({},n,{id:"search-single-16",ref:e,icon:me}))});Q.displayName="SearchSingle16";const X="FIND_REPLACE_INPUT_FOCUS",q="FIND_REPLACE_DIALOG_FOCUS",ee="FIND_REPLACE_REPLACE_REVEALED";var ve=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,te=(n,e,i,t)=>{for(var s=t>1?void 0:t?Se(e,i):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(t?o(e,i,s):o(s))||s);return t&&s&&ve(e,i,s),s},A=(n,e)=>(i,t)=>e(i,t,n);class Ce extends a.Disposable{}const R=a.createIdentifier("find-replace.service");function Re(n){return typeof n.findString<"u"||typeof n.inputtingFindString<"u"||typeof n.findDirection<"u"||typeof n.matchesTheWholeCell<"u"||typeof n.caseSensitive<"u"||typeof n.findScope<"u"||typeof n.findBy<"u"}let U=class extends a.Disposable{constructor(e,i,t){super();u(this,"currentMatch$",new S.BehaviorSubject(null));u(this,"replaceables$",new S.BehaviorSubject([]));u(this,"_findModels",[]);u(this,"_matchingModel",null);u(this,"_matches",[]);u(this,"_currentSearchingDisposables",null);this._state=e,this._providers=i,this._univerInstanceService=t,this.disposeWithMe(this._state.stateUpdates$.pipe(S.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async s=>{const r=this._state.state;Re(s)&&(r.findString!==""&&!r.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):s.replaceRevealed!==!0&&this._stopSearching())}))}get searched(){return this._findModels.length>0}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...w(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const e=await this._startSearching();return this._state.changeState({findCompleted:!0}),e}async _startSearching(){if(!this._state.findString)return{results:[]};const e=Array.from(this._providers),i=this._findModels=(await Promise.all(e.map(s=>s.find({findString:this._state.findString,findDirection:this._state.findDirection,findScope:this._state.findScope,findBy:this._state.findBy,replaceRevealed:this._state.replaceRevealed,caseSensitive:this._state.caseSensitive,matchesTheWholeCell:this._state.matchesTheWholeCell})))).flat();this._subscribeToModelsChanges(i);const t=this._matches=i.map(s=>s.getMatches()).flat();return this.replaceables$.next(t.filter(s=>s.replaceable)),t.length?(this._moveToInitialMatch(i),this._state.changeState({matchesCount:t.length}),{results:t}):(this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]})}_stopSearching(){var e;this._providers.forEach(i=>i.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(e=this._currentSearchingDisposables)==null||e.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(e){const i=this._currentSearchingDisposables=new a.DisposableCollection,t=S.combineLatest(e.map(s=>s.matchesUpdate$)).pipe(S.debounceTime(220)).subscribe(([...s])=>{const r=this._matches=s.flat();r.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:r.length}),this.replaceables$.next(r.filter(o=>o.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});e.forEach(s=>i.add(a.toDisposable(s.activelyChangingMatch$.subscribe(r=>{const o=this._matches.findIndex(h=>h===r);this._state.changeState({matchesPosition:o+1})})))),i.add(a.toDisposable(t))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const e=await Promise.all(this._findModels.map(i=>i.replaceAll(this._state.replaceString))).then(i=>i.reduce((t,s)=>(t.success+=s.success,t.failure+=s.failure,t),{success:0,failure:0}));return e.failure===0&&this._stopSearching(),e}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}_markMatch(e){const i=this._matches.findIndex(t=>t===e);this.currentMatch$.next(e),this._state.changeState({matchesPosition:i+1})}moveToNextMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToNextMatch({loop:e});if(i)this._markMatch(i);else{const t=this._findModels.findIndex(s=>s===this._matchingModel);this._moveToNextUnitMatch(t)}}_moveToNextUnitMatch(e){const i=this._findModels.length;for(let t=(e+1)%i;t!==e;){const s=this._findModels[t],r=s.moveToNextMatch({ignoreSelection:!0});if(r){this._matchingModel=s,this._markMatch(r);return}t=(t+1)%i}if(this._matchingModel){const t=this._matchingModel.moveToNextMatch({ignoreSelection:!0});t&&this._markMatch(t)}}moveToPreviousMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToPreviousMatch({loop:e});if(i){const t=this._matches.findIndex(s=>s===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:t+1})}else{const t=this._findModels.length,s=this._findModels.findIndex(o=>o===this._matchingModel);for(let o=(s-1+t)%t;o!==s;){const h=this._findModels[o],f=h.moveToPreviousMatch({ignoreSelection:!0});if(f){this._matchingModel=h,this._markMatch(f);return}o=(o-1)%t}const r=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});r&&this._markMatch(r)}}_moveToInitialMatch(e,i=!1){var r;const t=(r=this._univerInstanceService.getFocusedUnit())==null?void 0:r.getUnitId();if(!t)return-1;const s=e.findIndex(o=>o.unitId===t);if(s!==-1){this._matchingModel=e[s];const o=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus:i});if(o)return this._markMatch(o),s}return this._moveToNextUnitMatch(s),0}};U=te([A(2,a.IUniverInstanceService)],U);var T=(n=>(n.ROW="row",n.COLUMN="column",n))(T||{}),O=(n=>(n.VALUE="value",n.FORMULA="formula",n))(O||{}),P=(n=>(n.SUBUNIT="subunit",n.UNIT="unit",n))(P||{});function w(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class be{constructor(){u(this,"_stateUpdates$",new S.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new S.BehaviorSubject(w()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_inputtingFindString","");u(this,"_replaceString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0);u(this,"_caseSensitive",!0);u(this,"_matchesTheWholeCell",!1);u(this,"_findDirection","row");u(this,"_findScope","subunit");u(this,"_findBy","value");u(this,"_findCompleted",!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let i=!1;const t={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,t.findString=this._findString,i=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,t.revealed=e.revealed,i=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,t.replaceRevealed=e.replaceRevealed,i=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,t.replaceString=e.replaceString,i=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,t.matchesCount=e.matchesCount,i=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,t.matchesPosition=e.matchesPosition,i=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,t.findBy=e.findBy,i=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,t.findScope=e.findScope,i=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,t.findDirection=e.findDirection,i=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,t.caseSensitive=e.caseSensitive,i=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,t.matchesTheWholeCell=e.matchesTheWholeCell,i=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,t.inputtingFindString=e.inputtingFindString,i=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,t.findCompleted=e.findCompleted,i=!0),i&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(t))}}let B=class extends a.Disposable{constructor(e,i){super();u(this,"_providers",new Set);u(this,"_state",new be);u(this,"_model");u(this,"_currentMatch$",new S.BehaviorSubject(null));u(this,"currentMatch$",this._currentMatch$.asObservable());u(this,"_replaceables$",new S.BehaviorSubject([]));u(this,"replaceables$",this._replaceables$.asObservable());u(this,"_focusSignal$",new S.Subject);u(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e==="formula")}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(U,this._state,this._providers),this._model.currentMatch$.subscribe(t=>this._currentMatch$.next(t)),this._model.replaceables$.subscribe(t=>this._replaceables$.next(t));const i=w();return e&&(i.replaceRevealed=!0),this._state.changeState(i),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),a.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(ee,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(de.RENDER_RAW_FORMULA_KEY,e)}};B=te([A(0,a.Inject(a.Injector)),A(1,a.IContextService)],B);const k={id:"ui.command.replace-current-match",type:a.CommandType.COMMAND,handler:n=>n.get(R).replace()},Me="CONFIRM_REPLACE_ALL",W={id:"ui.command.replace-all-matches",type:a.CommandType.COMMAND,handler:async n=>{const e=n.get(d.IConfirmService),i=n.get(a.LocaleService),t=n.get(d.IMessageService);if(!await e.confirm({id:Me,title:{title:i.t("find-replace.replace.confirm.title")},cancelText:i.t("button.cancel"),confirmText:i.t("button.confirm")}))return!1;const r=await n.get(R).replaceAll(),{success:o,failure:h}=r;return h>0?(o===0?t.show({type:_.MessageType.Error,content:i.t("find-replace.replace.all-failure")}):t.show({type:_.MessageType.Warning,content:i.t("find-replace.replace.partial-success",`${o}`,`${h}`)}),!1):(t.show({type:_.MessageType.Success,content:i.t("find-replace.replace.all-success",`${o}`)}),!0)}},F={id:"ui.operation.open-find-dialog",type:a.CommandType.OPERATION,handler:n=>{const e=n.get(R);return e.revealed?e.focusFindInput():e.start(),!0}},E={id:"ui.operation.open-replace-dialog",type:a.CommandType.OPERATION,handler:n=>{const e=n.get(R);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},G={type:a.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:n=>(n.get(R).moveToNextMatch(),!0)},V={type:a.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:n=>(n.get(R).moveToPreviousMatch(),!0)};var H={exports:{}},D={};/**
|
|
2
|
+
(function(l,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("@univerjs/engine-render"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","rxjs","@univerjs/design","@univerjs/engine-render","react"],a):(l=typeof globalThis<"u"?globalThis:l||self,a(l.UniverFindReplace={},l.UniverCore,l.UniverUi,l.rxjs,l.UniverDesign,l.UniverEngineRender,l.React))})(this,function(l,a,d,S,_,de,p){"use strict";var gt=Object.defineProperty;var mt=(l,a,d)=>a in l?gt(l,a,{enumerable:!0,configurable:!0,writable:!0,value:d}):l[a]=d;var u=(l,a,d)=>mt(l,typeof a!="symbol"?a+"":a,d);var $;const ue="find-replace.config",z={};var C=function(){return C=Object.assign||function(n){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s])}return n},C.apply(this,arguments)},he=function(n,e){var i={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.indexOf(t)<0&&(i[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,t=Object.getOwnPropertySymbols(n);s<t.length;s++)e.indexOf(t[s])<0&&Object.prototype.propertyIsEnumerable.call(n,t[s])&&(i[t[s]]=n[t[s]]);return i},Y=p.forwardRef(function(n,e){var i=n.icon,t=n.id,s=n.className,r=n.extend,o=he(n,["icon","id","className","extend"]),h="univerjs-icon univerjs-icon-".concat(t," ").concat(s||"").trim(),f=p.useRef("_".concat(_e()));return Z(i,"".concat(t),{defIds:i.defIds,idSuffix:f.current},C({ref:e,className:h},o),r)});function Z(n,e,i,t,s){return p.createElement(n.tag,C(C({key:e},fe(n,i,s)),t),(pe(n,i).children||[]).map(function(r,o){return Z(r,"".concat(e,"-").concat(n.tag,"-").concat(o),i,void 0,s)}))}function fe(n,e,i){var t=C({},n.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1);var s=e.defIds;return!s||s.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(r){var o=r[0],h=r[1];typeof h=="string"&&(t[o]=h.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function pe(n,e){var i,t=e.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?C(C({},n),{children:n.children.map(function(s){return typeof s.attrs.id=="string"&&t&&t.indexOf(s.attrs.id)>-1?C(C({},s),{attrs:C(C({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):n}function _e(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";var ge={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"}}]}]},Q=p.forwardRef(function(n,e){return p.createElement(Y,Object.assign({},n,{id:"search-single-16",ref:e,icon:ge}))});Q.displayName="SearchSingle16";const X="FIND_REPLACE_INPUT_FOCUS",q="FIND_REPLACE_DIALOG_FOCUS",ee="FIND_REPLACE_REPLACE_REVEALED";var me=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,te=(n,e,i,t)=>{for(var s=t>1?void 0:t?ve(e,i):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(t?o(e,i,s):o(s))||s);return t&&s&&me(e,i,s),s},j=(n,e)=>(i,t)=>e(i,t,n);class Se extends a.Disposable{}const R=a.createIdentifier("find-replace.service");function Ce(n){return typeof n.findString<"u"||typeof n.inputtingFindString<"u"||typeof n.findDirection<"u"||typeof n.matchesTheWholeCell<"u"||typeof n.caseSensitive<"u"||typeof n.findScope<"u"||typeof n.findBy<"u"}let A=class extends a.Disposable{constructor(e,i,t){super();u(this,"currentMatch$",new S.BehaviorSubject(null));u(this,"replaceables$",new S.BehaviorSubject([]));u(this,"_findModels",[]);u(this,"_matchingModel",null);u(this,"_matches",[]);u(this,"_currentSearchingDisposables",null);this._state=e,this._providers=i,this._univerInstanceService=t,this.disposeWithMe(this._state.stateUpdates$.pipe(S.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async s=>{const r=this._state.state;Ce(s)&&(r.findString!==""&&!r.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):s.replaceRevealed!==!0&&this._stopSearching())}))}get searched(){return this._findModels.length>0}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...U(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const e=await this._startSearching();return this._state.changeState({findCompleted:!0}),e}async _startSearching(){if(!this._state.findString)return{results:[]};const e=Array.from(this._providers),i=this._findModels=(await Promise.all(e.map(s=>s.find({findString:this._state.findString,findDirection:this._state.findDirection,findScope:this._state.findScope,findBy:this._state.findBy,replaceRevealed:this._state.replaceRevealed,caseSensitive:this._state.caseSensitive,matchesTheWholeCell:this._state.matchesTheWholeCell})))).flat();this._subscribeToModelsChanges(i);const t=this._matches=i.map(s=>s.getMatches()).flat();return this.replaceables$.next(t.filter(s=>s.replaceable)),t.length?(this._moveToInitialMatch(i),this._state.changeState({matchesCount:t.length}),{results:t}):(this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]})}_stopSearching(){var e;this._providers.forEach(i=>i.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(e=this._currentSearchingDisposables)==null||e.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(e){const i=this._currentSearchingDisposables=new a.DisposableCollection,t=S.combineLatest(e.map(s=>s.matchesUpdate$)).pipe(S.debounceTime(220)).subscribe(([...s])=>{const r=this._matches=s.flat();r.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:r.length}),this.replaceables$.next(r.filter(o=>o.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});e.forEach(s=>i.add(a.toDisposable(s.activelyChangingMatch$.subscribe(r=>{const o=this._matches.findIndex(h=>h===r);this._state.changeState({matchesPosition:o+1})})))),i.add(a.toDisposable(t))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const e=await Promise.all(this._findModels.map(i=>i.replaceAll(this._state.replaceString))).then(i=>i.reduce((t,s)=>(t.success+=s.success,t.failure+=s.failure,t),{success:0,failure:0}));return e.failure===0&&this._stopSearching(),e}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}_markMatch(e){const i=this._matches.findIndex(t=>t===e);this.currentMatch$.next(e),this._state.changeState({matchesPosition:i+1})}moveToNextMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToNextMatch({loop:e});if(i)this._markMatch(i);else{const t=this._findModels.findIndex(s=>s===this._matchingModel);this._moveToNextUnitMatch(t)}}_moveToNextUnitMatch(e){const i=this._findModels.length;for(let t=(e+1)%i;t!==e;){const s=this._findModels[t],r=s.moveToNextMatch({ignoreSelection:!0});if(r){this._matchingModel=s,this._markMatch(r);return}t=(t+1)%i}if(this._matchingModel){const t=this._matchingModel.moveToNextMatch({ignoreSelection:!0});t&&this._markMatch(t)}}moveToPreviousMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToPreviousMatch({loop:e});if(i){const t=this._matches.findIndex(s=>s===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:t+1})}else{const t=this._findModels.length,s=this._findModels.findIndex(o=>o===this._matchingModel);for(let o=(s-1+t)%t;o!==s;){const h=this._findModels[o],f=h.moveToPreviousMatch({ignoreSelection:!0});if(f){this._matchingModel=h,this._markMatch(f);return}o=(o-1)%t}const r=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});r&&this._markMatch(r)}}_moveToInitialMatch(e,i=!1){var r;const t=(r=this._univerInstanceService.getFocusedUnit())==null?void 0:r.getUnitId();if(!t)return-1;const s=e.findIndex(o=>o.unitId===t);if(s!==-1){this._matchingModel=e[s];const o=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus:i});if(o)return this._markMatch(o),s}return this._moveToNextUnitMatch(s),0}};A=te([j(2,a.IUniverInstanceService)],A);var T=(n=>(n.ROW="row",n.COLUMN="column",n))(T||{}),O=(n=>(n.VALUE="value",n.FORMULA="formula",n))(O||{}),P=(n=>(n.SUBUNIT="subunit",n.UNIT="unit",n))(P||{});function U(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class Re{constructor(){u(this,"_stateUpdates$",new S.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new S.BehaviorSubject(U()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_inputtingFindString","");u(this,"_replaceString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0);u(this,"_caseSensitive",!0);u(this,"_matchesTheWholeCell",!1);u(this,"_findDirection","row");u(this,"_findScope","subunit");u(this,"_findBy","value");u(this,"_findCompleted",!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let i=!1;const t={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,t.findString=this._findString,i=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,t.revealed=e.revealed,i=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,t.replaceRevealed=e.replaceRevealed,i=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,t.replaceString=e.replaceString,i=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,t.matchesCount=e.matchesCount,i=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,t.matchesPosition=e.matchesPosition,i=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,t.findBy=e.findBy,i=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,t.findScope=e.findScope,i=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,t.findDirection=e.findDirection,i=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,t.caseSensitive=e.caseSensitive,i=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,t.matchesTheWholeCell=e.matchesTheWholeCell,i=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,t.inputtingFindString=e.inputtingFindString,i=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,t.findCompleted=e.findCompleted,i=!0),i&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(t))}}let w=class extends a.Disposable{constructor(e,i){super();u(this,"_providers",new Set);u(this,"_state",new Re);u(this,"_model");u(this,"_currentMatch$",new S.BehaviorSubject(null));u(this,"currentMatch$",this._currentMatch$.asObservable());u(this,"_replaceables$",new S.BehaviorSubject([]));u(this,"replaceables$",this._replaceables$.asObservable());u(this,"_focusSignal$",new S.Subject);u(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e==="formula")}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(A,this._state,this._providers),this._model.currentMatch$.subscribe(t=>this._currentMatch$.next(t)),this._model.replaceables$.subscribe(t=>this._replaceables$.next(t));const i=U();return e&&(i.replaceRevealed=!0),this._state.changeState(i),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),a.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(ee,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(de.RENDER_RAW_FORMULA_KEY,e)}};w=te([j(0,a.Inject(a.Injector)),j(1,a.IContextService)],w);const B={id:"ui.command.replace-current-match",type:a.CommandType.COMMAND,handler:n=>n.get(R).replace()},be="CONFIRM_REPLACE_ALL",k={id:"ui.command.replace-all-matches",type:a.CommandType.COMMAND,handler:async n=>{const e=n.get(d.IConfirmService),i=n.get(a.LocaleService),t=n.get(d.IMessageService);if(!await e.confirm({id:be,title:{title:i.t("find-replace.replace.confirm.title")},cancelText:i.t("button.cancel"),confirmText:i.t("button.confirm")}))return!1;const r=await n.get(R).replaceAll(),{success:o,failure:h}=r;return h>0?(o===0?t.show({type:_.MessageType.Error,content:i.t("find-replace.replace.all-failure")}):t.show({type:_.MessageType.Warning,content:i.t("find-replace.replace.partial-success",`${o}`,`${h}`)}),!1):(t.show({type:_.MessageType.Success,content:i.t("find-replace.replace.all-success",`${o}`)}),!0)}},F={id:"ui.operation.open-find-dialog",type:a.CommandType.OPERATION,handler:n=>{const e=n.get(R);return e.revealed?e.focusFindInput():e.start(),!0}},E={id:"ui.operation.open-replace-dialog",type:a.CommandType.OPERATION,handler:n=>{const e=n.get(R);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},W={type:a.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:n=>(n.get(R).moveToNextMatch(),!0)},G={type:a.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:n=>(n.get(R).moveToPreviousMatch(),!0)};var V={exports:{}},D={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.min.js
|
|
5
5
|
*
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/var ne;function ye(){if(ne)return D;ne=1;var n=l,e=Symbol.for("react.element"),i=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function o(h,f,b){var g,m={},I=null,y=null;b!==void 0&&(I=""+b),f.key!==void 0&&(I=""+f.key),f.ref!==void 0&&(y=f.ref);for(g in f)t.call(f,g)&&!r.hasOwnProperty(g)&&(m[g]=f[g]);if(h&&h.defaultProps)for(g in f=h.defaultProps,f)m[g]===void 0&&(m[g]=f[g]);return{$$typeof:e,type:h,key:I,ref:y,props:m,_owner:s.current}}return D.Fragment=i,D.jsx=o,D.jsxs=o,D}var ie;function Ie(){return ie||(ie=1,H.exports=ye()),H.exports}var p=Ie();function se(n){const{findCompleted:e,localeService:i,matchesCount:t,matchesPosition:s,findString:r,findReplaceService:o,onChange:h,...f}=n,g=e&&t===0?i.t("find-replace.dialog.no-result"):t===0?" ":void 0;return p.jsx(_.InputWithSlot,{autoFocus:!0,placeholder:i.t("find-replace.dialog.find-placeholder"),slot:p.jsx(_.Pager,{loop:!0,text:g,value:s,total:t,onChange:m=>{s===t&&m===1?o.moveToNextMatch():s===1&&m===t||m<s?o.moveToPreviousMatch():o.moveToNextMatch()}}),value:r,onChange:m=>h==null?void 0:h(m),...f})}const N={findReplaceDialogContainer:"univer-find-replace-dialog-container",findReplaceExpandContainer:"univer-find-replace-expand-container",buttonText:"univer-button-text",findReplaceButtonsGroup:"univer-find-replace-buttons-group",findReplaceButtonsGroupRight:"univer-find-replace-buttons-group-right"};function ae(n,e){const i=l.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),t=l.useCallback(()=>{const s=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(s).some(r=>r===document.activeElement)},[]);return l.useImperativeHandle(e,()=>({focus:i,selectHasFocus:t})),l.useEffect(()=>{const s=n.focusSignal$.subscribe(()=>i());return()=>s.unsubscribe()},[n,i]),{focus:i,selectHasFocus:t}}const Fe=l.forwardRef(function(e,i){const t=a.useDependency(a.LocaleService),s=a.useDependency(R),r=a.useDependency(a.ICommandService),o=d.useObservable(s.state$,void 0,!0),{findCompleted:h,findString:f,matchesCount:b,matchesPosition:g}=o,m=l.useCallback(()=>{r.executeCommand(E.id)},[r]),I=l.useCallback(y=>s.changeFindString(y),[s]);return ae(s,i),p.jsxs(l.Fragment,{children:[p.jsx(se,{findCompleted:h,className:"univer-find-input",matchesCount:b,matchesPosition:g,findReplaceService:s,localeService:t,findString:f,onChange:I}),p.jsx("div",{className:N.findReplaceExpandContainer,children:p.jsx(_.Button,{type:"text",size:"small",onClick:m,children:t.t("find-replace.dialog.advanced-finding")})})]})}),De=l.forwardRef(function(e,i){const t=a.useDependency(R),s=a.useDependency(a.LocaleService),r=a.useDependency(a.ICommandService),o=a.useDependency(d.IMessageService),h=d.useObservable(t.currentMatch$,void 0,!0),f=d.useObservable(t.replaceables$,void 0,!0),b=d.useObservable(t.state$,void 0,!0),{matchesCount:g,matchesPosition:m,findString:I,inputtingFindString:y,replaceString:Ze,caseSensitive:Qe,matchesTheWholeCell:Xe,findDirection:qe,findScope:et,findBy:tt,findCompleted:z}=b,nt=y.length===0,it=g===0||!(h!=null&&h.replaceable),st=f.length===0,at=l.useCallback(v=>t.changeInputtingFindString(v),[t]),rt=l.useCallback(v=>t.changeReplaceString(v),[t]),{focus:ot}=ae(t,i),ct=l.useCallback(()=>{I===y?t.moveToNextMatch():(t.changeFindString(y),t.find())},[I,y,t]),lt=l.useCallback(()=>r.executeCommand(k.id),[r]),dt=l.useCallback(async()=>{await r.executeCommand(W.id),ot()},[r]),ut=l.useCallback(v=>{t.changeFindDirection(v)},[t]),ht=l.useCallback(v=>{t.changeFindScope(v)},[t]),ft=l.useCallback(v=>{t.changeFindBy(v)},[t]),pt=Te(s),_t=Oe(s),gt=Pe(s);return l.useEffect(()=>{const v=z&&g===0;let j=null;return v&&(j=o.show({content:s.t("find-replace.dialog.no-match"),type:_.MessageType.Warning,duration:5e3})),()=>j==null?void 0:j.dispose()},[z,g,o,s]),p.jsxs(l.Fragment,{children:[p.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find"),children:p.jsx(se,{findCompleted:z,className:"univer-find-input",matchesCount:g,matchesPosition:m,findReplaceService:t,localeService:s,findString:y,onChange:at})}),p.jsx(_.FormLayout,{label:s.t("find-replace.dialog.replace"),children:p.jsx(_.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:Ze,onChange:v=>rt(v)})}),p.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:p.jsx(_.Select,{value:qe,options:_t,onChange:ut})}),p.jsx(_.FormDualColumnLayout,{children:p.jsxs(l.Fragment,{children:[p.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:p.jsx(_.Select,{value:et,options:pt,onChange:ht})}),p.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:p.jsx(_.Select,{value:tt,options:gt,onChange:ft})})]})}),p.jsx(_.FormDualColumnLayout,{children:p.jsxs(l.Fragment,{children:[p.jsx(_.FormLayout,{children:p.jsx(_.Checkbox,{checked:Qe,onChange:v=>{t.changeCaseSensitive(v)},children:s.t("find-replace.dialog.case-sensitive")})}),p.jsx(_.FormLayout,{children:p.jsx(_.Checkbox,{checked:Xe,onChange:v=>{t.changeMatchesTheWholeCell(v)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),p.jsxs("div",{className:N.findReplaceButtonsGroup,children:[p.jsx(_.Button,{type:"primary",onClick:ct,disabled:nt,children:s.t("find-replace.dialog.find")}),p.jsxs("span",{className:N.findReplaceButtonsGroupRight,children:[p.jsx(_.Button,{disabled:it,onClick:lt,children:s.t("find-replace.dialog.replace")}),p.jsx(_.Button,{disabled:st,onClick:dt,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function xe(){const n=a.useDependency(R),e=a.useDependency(d.ILayoutService),i=a.useDependency(a.IContextService),t=d.useObservable(n.state$,void 0,!0),s=l.useRef(null);l.useEffect(()=>{let f;return s.current&&(f=e.registerContainerElement(s.current)),()=>f==null?void 0:f.dispose()},[e]);const r=l.useRef(null),o=l.useCallback(f=>i.setContextValue(q,f),[i]),h=l.useCallback(f=>i.setContextValue(X,f),[i]);return l.useEffect(()=>{var b;const f=S.fromEvent(document,"focusin").subscribe(g=>{var m;g.target&&((m=s.current)!=null&&m.contains(g.target))?o(!0):o(!1),!r.current||!r.current.selectHasFocus()?h(!0):h(!1)});return(b=r.current)==null||b.focus(),o(!0),h(!0),()=>{f.unsubscribe(),o(!1)}},[o,h]),p.jsx("div",{className:N.findReplaceDialogContainer,ref:s,children:t.replaceRevealed?p.jsx(De,{ref:r}):p.jsx(Fe,{ref:r})})}function Te(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-scope.current-sheet"),value:P.SUBUNIT},{label:n.t("find-replace.dialog.find-scope.workbook"),value:P.UNIT}],[e])}function Oe(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-direction.row"),value:T.ROW},{label:n.t("find-replace.dialog.find-direction.column"),value:T.COLUMN}],[e])}function Pe(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-by.value"),value:O.VALUE},{label:n.t("find-replace.dialog.find-by.formula"),value:O.FORMULA}],[e])}function x(n){return n.getContextValue(q)}function Ee(n){return n.getContextValue(ee)}function re(n){return n.getContextValue(X)}const L="7_find-replace-shortcuts";function K(n){return n.getContextValue(a.FOCUSING_SHEET)}function $(n){return!n.getContextValue(a.EDITOR_ACTIVATED)}const Ne={id:F.id,description:"find-replace.shortcut.open-find-dialog",binding:d.KeyCode.F|d.MetaKeys.CTRL_COMMAND,group:L,preconditions(n){return!x(n)&&K(n)&&$(n)}},Le={id:F.id,description:"find-replace.shortcut.open-find-dialog",binding:d.KeyCode.F|d.MetaKeys.CTRL_COMMAND,mac:d.KeyCode.F|d.MetaKeys.MAC_CTRL,preconditions(n){return!x(n)&&K(n)&&$(n)}},je={id:E.id,description:"find-replace.shortcut.open-replace-dialog",binding:d.KeyCode.H|d.MetaKeys.CTRL_COMMAND,mac:d.KeyCode.H|d.MetaKeys.MAC_CTRL,group:L,preconditions(n){return K(n)&&$(n)&&(!x(n)||!Ee(n))}},Ae={id:G.id,description:"find-replace.shortcut.go-to-next-match",binding:d.KeyCode.ENTER,group:L,priority:1e3,preconditions(n){return re(n)&&x(n)}},Ue={id:V.id,description:"find-replace.shortcut.go-to-previous-match",binding:d.KeyCode.ENTER|d.MetaKeys.SHIFT,group:L,priority:1e3,preconditions(n){return re(n)&&x(n)}};function we(n){const e=n.get(a.IContextService);return{id:F.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",type:d.MenuItemType.BUTTON,hidden$:d.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:S.combineLatest([e.subscribeContextValue$(a.EDITOR_ACTIVATED),e.subscribeContextValue$(a.FOCUSING_SHEET)]).pipe(S.map(([i,t])=>i||!t))}}const Be={[d.RibbonStartGroup.OTHERS]:{[F.id]:{order:2,menuItemFactory:we}}};var ke=Object.defineProperty,We=Object.getOwnPropertyDescriptor,Ge=(n,e,i,t)=>{for(var s=t>1?void 0:t?We(e,i):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(t?o(e,i,s):o(s))||s);return t&&s&&ke(e,i,s),s},M=(n,e)=>(i,t)=>e(i,t,n);const oe="DESKTOP_FIND_REPLACE_DIALOG",ce=350,Ve=20,He=-90;c.FindReplaceController=class extends a.RxDisposable{constructor(i,t,s,r,o,h,f,b,g,m){super();u(this,"_closingListenerDisposable");this._univerInstanceService=i,this._menuManagerService=t,this._shortcutService=s,this._commandService=r,this._findReplaceService=o,this._dialogService=h,this._layoutService=f,this._localeService=b,this._componentManager=g,this._injector=m,this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var i;super.dispose(),(i=this._closingListenerDisposable)==null||i.dispose(),this._closingListenerDisposable=null}_initCommands(){[F,E,G,V,W,k].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initShortcuts(){[je,Ne,Le,Ue,Ae].forEach(i=>this.disposeWithMe(this._shortcutService.registerShortcut(i)))}_initUI(){this.disposeWithMe(this._componentManager.register("FindReplaceDialog",xe)),this.disposeWithMe(this._componentManager.register("SearchIcon",Q)),this._menuManagerService.mergeMenu(Be),this._findReplaceService.stateUpdates$.pipe(S.takeUntil(this.dispose$)).subscribe(i=>{i.revealed===!0&&this._openPanel()})}_openPanel(){this._dialogService.open({id:oe,draggable:!0,width:ce,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:Ke(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()}),this._closingListenerDisposable=a.toDisposable(this._univerInstanceService.focused$.pipe(S.takeUntil(this.dispose$)).subscribe(i=>{(!i||!this._univerInstanceService.getUniverSheetInstance(i))&&this.closePanel()}))}closePanel(){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(oe),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}},c.FindReplaceController=Ge([M(0,a.IUniverInstanceService),M(1,d.IMenuManagerService),M(2,d.IShortcutService),M(3,a.ICommandService),M(4,R),M(5,d.IDialogService),M(6,d.ILayoutService),M(7,a.Inject(a.LocaleService)),M(8,a.Inject(d.ComponentManager)),M(9,a.Inject(a.Injector))],c.FindReplaceController);function Ke(){const{innerWidth:n}=window;return{x:(n-ce)/2-Ve,y:He}}var $e=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,ze=(n,e,i,t)=>{for(var s=t>1?void 0:t?Je(e,i):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(t?o(e,i,s):o(s))||s);return t&&s&&$e(e,i,s),s},le=(n,e)=>(i,t)=>e(i,t,n);const Ye="UNIVER_FIND_REPLACE_PLUGIN";c.UniverFindReplacePlugin=(J=class extends a.Plugin{constructor(e=he,i,t){super(),this._config=e,this._injector=i,this._configService=t;const{...s}=this._config;this._configService.setConfig(ue,s)}onStarting(){[[c.FindReplaceController],[R,{useClass:B}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(c.FindReplaceController)}},u(J,"pluginName",Ye),J),c.UniverFindReplacePlugin=ze([le(1,a.Inject(a.Injector)),le(2,a.IConfigService)],c.UniverFindReplacePlugin),c.FindBy=O,c.FindDirection=T,c.FindModel=Ce,c.FindScope=P,c.GoToNextMatchOperation=G,c.GoToPreviousMatchOperation=V,c.IFindReplaceService=R,c.OpenFindDialogOperation=F,c.OpenReplaceDialogOperation=E,c.ReplaceAllMatchesCommand=W,c.ReplaceCurrentMatchCommand=k,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
10
|
+
*/var ne;function Me(){if(ne)return D;ne=1;var n=p,e=Symbol.for("react.element"),i=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function o(h,f,b){var g,m={},I=null,y=null;b!==void 0&&(I=""+b),f.key!==void 0&&(I=""+f.key),f.ref!==void 0&&(y=f.ref);for(g in f)t.call(f,g)&&!r.hasOwnProperty(g)&&(m[g]=f[g]);if(h&&h.defaultProps)for(g in f=h.defaultProps,f)m[g]===void 0&&(m[g]=f[g]);return{$$typeof:e,type:h,key:I,ref:y,props:m,_owner:s.current}}return D.Fragment=i,D.jsx=o,D.jsxs=o,D}var ie;function ye(){return ie||(ie=1,V.exports=Me()),V.exports}var c=ye();const N={findReplaceDialogContainer:"univer-find-replace-dialog-container",findReplaceExpandContainer:"univer-find-replace-expand-container",buttonText:"univer-button-text",findReplaceButtonsGroup:"univer-find-replace-buttons-group",findReplaceButtonsGroupRight:"univer-find-replace-buttons-group-right"};function se(n){const{findCompleted:e,localeService:i,matchesCount:t,matchesPosition:s,findString:r,findReplaceService:o,onChange:h,...f}=n,g=e&&t===0?i.t("find-replace.dialog.no-result"):t===0?" ":void 0;return c.jsx(_.InputWithSlot,{autoFocus:!0,placeholder:i.t("find-replace.dialog.find-placeholder"),slot:c.jsx(_.Pager,{loop:!0,text:g,value:s,total:t,onChange:m=>{s===t&&m===1?o.moveToNextMatch():s===1&&m===t||m<s?o.moveToPreviousMatch():o.moveToNextMatch()}}),value:r,onChange:m=>h==null?void 0:h(m),...f})}function ae(n,e){const i=p.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),t=p.useCallback(()=>{const s=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(s).some(r=>r===document.activeElement)},[]);return p.useImperativeHandle(e,()=>({focus:i,selectHasFocus:t})),p.useEffect(()=>{const s=n.focusSignal$.subscribe(()=>i());return()=>s.unsubscribe()},[n,i]),{focus:i,selectHasFocus:t}}const Ie=p.forwardRef(function(e,i){const t=a.useDependency(a.LocaleService),s=a.useDependency(R),r=a.useDependency(a.ICommandService),o=d.useObservable(s.state$,void 0,!0),{findCompleted:h,findString:f,matchesCount:b,matchesPosition:g}=o,m=p.useCallback(()=>{r.executeCommand(E.id)},[r]),I=p.useCallback(y=>s.changeFindString(y),[s]);return ae(s,i),c.jsxs(c.Fragment,{children:[c.jsx(se,{findCompleted:h,className:"univer-find-input",matchesCount:b,matchesPosition:g,findReplaceService:s,localeService:t,findString:f,onChange:I}),c.jsx("div",{className:N.findReplaceExpandContainer,children:c.jsx(_.Button,{type:"text",size:"small",onClick:m,children:t.t("find-replace.dialog.advanced-finding")})})]})}),Fe=p.forwardRef(function(e,i){const t=a.useDependency(R),s=a.useDependency(a.LocaleService),r=a.useDependency(a.ICommandService),o=a.useDependency(d.IMessageService),h=d.useObservable(t.currentMatch$,void 0,!0),f=d.useObservable(t.replaceables$,void 0,!0),b=d.useObservable(t.state$,void 0,!0),{matchesCount:g,matchesPosition:m,findString:I,inputtingFindString:y,replaceString:Ye,caseSensitive:Ze,matchesTheWholeCell:Qe,findDirection:Xe,findScope:qe,findBy:et,findCompleted:J}=b,tt=y.length===0,nt=g===0||!(h!=null&&h.replaceable),it=f.length===0,st=p.useCallback(v=>t.changeInputtingFindString(v),[t]),at=p.useCallback(v=>t.changeReplaceString(v),[t]),{focus:rt}=ae(t,i),ot=p.useCallback(()=>{I===y?t.moveToNextMatch():(t.changeFindString(y),t.find())},[I,y,t]),ct=p.useCallback(()=>r.executeCommand(B.id),[r]),lt=p.useCallback(async()=>{await r.executeCommand(k.id),rt()},[r]),dt=p.useCallback(v=>{t.changeFindDirection(v)},[t]),ut=p.useCallback(v=>{t.changeFindScope(v)},[t]),ht=p.useCallback(v=>{t.changeFindBy(v)},[t]),ft=xe(s),pt=Te(s),_t=Oe(s);return p.useEffect(()=>{J&&g===0&&o.show({content:s.t("find-replace.dialog.no-match"),type:_.MessageType.Warning,duration:5e3})},[J,g,o,s]),c.jsxs(c.Fragment,{children:[c.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find"),children:c.jsx(se,{findCompleted:J,className:"univer-find-input",matchesCount:g,matchesPosition:m,findReplaceService:t,localeService:s,findString:y,onChange:st})}),c.jsx(_.FormLayout,{label:s.t("find-replace.dialog.replace"),children:c.jsx(_.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:Ye,onChange:v=>at(v)})}),c.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:c.jsx(_.Select,{value:Xe,options:pt,onChange:dt})}),c.jsx(_.FormDualColumnLayout,{children:c.jsxs(c.Fragment,{children:[c.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:c.jsx(_.Select,{value:qe,options:ft,onChange:ut})}),c.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:c.jsx(_.Select,{value:et,options:_t,onChange:ht})})]})}),c.jsx(_.FormDualColumnLayout,{children:c.jsxs(c.Fragment,{children:[c.jsx(_.FormLayout,{children:c.jsx(_.Checkbox,{checked:Ze,onChange:v=>{t.changeCaseSensitive(v)},children:s.t("find-replace.dialog.case-sensitive")})}),c.jsx(_.FormLayout,{children:c.jsx(_.Checkbox,{checked:Qe,onChange:v=>{t.changeMatchesTheWholeCell(v)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),c.jsxs("div",{className:N.findReplaceButtonsGroup,children:[c.jsx(_.Button,{type:"primary",onClick:ot,disabled:tt,children:s.t("find-replace.dialog.find")}),c.jsxs("span",{className:N.findReplaceButtonsGroupRight,children:[c.jsx(_.Button,{disabled:nt,onClick:ct,children:s.t("find-replace.dialog.replace")}),c.jsx(_.Button,{disabled:it,onClick:lt,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function De(){const n=a.useDependency(R),e=a.useDependency(d.ILayoutService),i=a.useDependency(a.IContextService),t=d.useObservable(n.state$,void 0,!0),s=p.useRef(null);p.useEffect(()=>{let f;return s.current&&(f=e.registerContainerElement(s.current)),()=>f==null?void 0:f.dispose()},[e]);const r=p.useRef(null),o=p.useCallback(f=>i.setContextValue(q,f),[i]),h=p.useCallback(f=>i.setContextValue(X,f),[i]);return p.useEffect(()=>{var b;const f=S.fromEvent(document,"focusin").subscribe(g=>{var m;g.target&&((m=s.current)!=null&&m.contains(g.target))?o(!0):o(!1),!r.current||!r.current.selectHasFocus()?h(!0):h(!1)});return(b=r.current)==null||b.focus(),o(!0),h(!0),()=>{f.unsubscribe(),o(!1)}},[o,h]),c.jsx("div",{className:N.findReplaceDialogContainer,ref:s,children:t.replaceRevealed?c.jsx(Fe,{ref:r}):c.jsx(Ie,{ref:r})})}function xe(n){const e=n.getCurrentLocale();return p.useMemo(()=>[{label:n.t("find-replace.dialog.find-scope.current-sheet"),value:P.SUBUNIT},{label:n.t("find-replace.dialog.find-scope.workbook"),value:P.UNIT}],[e])}function Te(n){const e=n.getCurrentLocale();return p.useMemo(()=>[{label:n.t("find-replace.dialog.find-direction.row"),value:T.ROW},{label:n.t("find-replace.dialog.find-direction.column"),value:T.COLUMN}],[e])}function Oe(n){const e=n.getCurrentLocale();return p.useMemo(()=>[{label:n.t("find-replace.dialog.find-by.value"),value:O.VALUE},{label:n.t("find-replace.dialog.find-by.formula"),value:O.FORMULA}],[e])}function x(n){return n.getContextValue(q)}function Pe(n){return n.getContextValue(ee)}function re(n){return n.getContextValue(X)}const L="7_find-replace-shortcuts";function H(n){return n.getContextValue(a.FOCUSING_SHEET)}function K(n){return!n.getContextValue(a.EDITOR_ACTIVATED)}const Ee={id:F.id,description:"find-replace.shortcut.open-find-dialog",binding:d.KeyCode.F|d.MetaKeys.CTRL_COMMAND,group:L,preconditions(n){return!x(n)&&H(n)&&K(n)}},Ne={id:F.id,description:"find-replace.shortcut.open-find-dialog",binding:d.KeyCode.F|d.MetaKeys.CTRL_COMMAND,mac:d.KeyCode.F|d.MetaKeys.MAC_CTRL,preconditions(n){return!x(n)&&H(n)&&K(n)}},Le={id:E.id,description:"find-replace.shortcut.open-replace-dialog",binding:d.KeyCode.H|d.MetaKeys.CTRL_COMMAND,mac:d.KeyCode.H|d.MetaKeys.MAC_CTRL,group:L,preconditions(n){return H(n)&&K(n)&&(!x(n)||!Pe(n))}},je={id:W.id,description:"find-replace.shortcut.go-to-next-match",binding:d.KeyCode.ENTER,group:L,priority:1e3,preconditions(n){return re(n)&&x(n)}},Ae={id:G.id,description:"find-replace.shortcut.go-to-previous-match",binding:d.KeyCode.ENTER|d.MetaKeys.SHIFT,group:L,priority:1e3,preconditions(n){return re(n)&&x(n)}};function Ue(n){const e=n.get(a.IContextService);return{id:F.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",type:d.MenuItemType.BUTTON,hidden$:d.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:S.combineLatest([e.subscribeContextValue$(a.EDITOR_ACTIVATED),e.subscribeContextValue$(a.FOCUSING_SHEET)]).pipe(S.map(([i,t])=>i||!t))}}const we={[d.RibbonStartGroup.OTHERS]:{[F.id]:{order:2,menuItemFactory:Ue}}};var Be=Object.defineProperty,ke=Object.getOwnPropertyDescriptor,We=(n,e,i,t)=>{for(var s=t>1?void 0:t?ke(e,i):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(t?o(e,i,s):o(s))||s);return t&&s&&Be(e,i,s),s},M=(n,e)=>(i,t)=>e(i,t,n);const oe="DESKTOP_FIND_REPLACE_DIALOG",ce=350,Ge=20,Ve=-90;l.FindReplaceController=class extends a.RxDisposable{constructor(i,t,s,r,o,h,f,b,g,m){super();u(this,"_closingListenerDisposable");this._univerInstanceService=i,this._menuManagerService=t,this._shortcutService=s,this._commandService=r,this._findReplaceService=o,this._dialogService=h,this._layoutService=f,this._localeService=b,this._componentManager=g,this._injector=m,this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var i;super.dispose(),(i=this._closingListenerDisposable)==null||i.dispose(),this._closingListenerDisposable=null}_initCommands(){[F,E,W,G,k,B].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initShortcuts(){[Le,Ee,Ne,Ae,je].forEach(i=>this.disposeWithMe(this._shortcutService.registerShortcut(i)))}_initUI(){this.disposeWithMe(this._componentManager.register("FindReplaceDialog",De)),this.disposeWithMe(this._componentManager.register("SearchIcon",Q)),this._menuManagerService.mergeMenu(we),this._findReplaceService.stateUpdates$.pipe(S.takeUntil(this.dispose$)).subscribe(i=>{i.revealed===!0&&this._openPanel()})}_openPanel(){this._dialogService.open({id:oe,draggable:!0,width:ce,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:He(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()}),this._closingListenerDisposable=a.toDisposable(this._univerInstanceService.focused$.pipe(S.takeUntil(this.dispose$)).subscribe(i=>{(!i||!this._univerInstanceService.getUniverSheetInstance(i))&&this.closePanel()}))}closePanel(){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(oe),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}},l.FindReplaceController=We([M(0,a.IUniverInstanceService),M(1,d.IMenuManagerService),M(2,d.IShortcutService),M(3,a.ICommandService),M(4,R),M(5,d.IDialogService),M(6,d.ILayoutService),M(7,a.Inject(a.LocaleService)),M(8,a.Inject(d.ComponentManager)),M(9,a.Inject(a.Injector))],l.FindReplaceController);function He(){const{innerWidth:n}=window;return{x:(n-ce)/2-Ge,y:Ve}}var Ke=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Je=(n,e,i,t)=>{for(var s=t>1?void 0:t?$e(e,i):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(t?o(e,i,s):o(s))||s);return t&&s&&Ke(e,i,s),s},le=(n,e)=>(i,t)=>e(i,t,n);const ze="UNIVER_FIND_REPLACE_PLUGIN";l.UniverFindReplacePlugin=($=class extends a.Plugin{constructor(e=z,i,t){super(),this._config=e,this._injector=i,this._configService=t;const{...s}=a.merge({},z,this._config);this._configService.setConfig(ue,s)}onStarting(){[[l.FindReplaceController],[R,{useClass:w}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(l.FindReplaceController)}},u($,"pluginName",ze),$),l.UniverFindReplacePlugin=Je([le(1,a.Inject(a.Injector)),le(2,a.IConfigService)],l.UniverFindReplacePlugin),l.FindBy=O,l.FindDirection=T,l.FindModel=Se,l.FindScope=P,l.GoToNextMatchOperation=W,l.GoToPreviousMatchOperation=G,l.IFindReplaceService=R,l.OpenFindDialogOperation=F,l.OpenReplaceDialogOperation=E,l.ReplaceAllMatchesCommand=k,l.ReplaceCurrentMatchCommand=B,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
// @univerjs/sheets-find-replace/index
|
|
14
|
-
(function(_,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/find-replace"),require("@univerjs/sheets"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/find-replace","@univerjs/sheets","@univerjs/engine-render","@univerjs/sheets-ui","rxjs"],a):(_=typeof globalThis<"u"?globalThis:_||self,a(_.UniverSheetsFindReplace={},_.UniverCore,_.UniverFindReplace,_.UniverSheets,_.UniverEngineRender,_.UniverSheetsUi,_.rxjs))})(this,function(_,a,f,R,k,M,C){"use strict";var Se=Object.defineProperty;var me=(_,a,f)=>a in _?Se(_,a,{enumerable:!0,configurable:!0,writable:!0,value:f}):_[a]=f;var m=(_,a,f)=>me(_,typeof a!="symbol"?a+"":a,f);const G="sheets-find-replace.config",Y={},F={id:"sheet.command.replace",type:a.CommandType.COMMAND,handler:async(h,e)=>{const t=h.get(a.IUndoRedoService),i=h.get(a.ICommandService),{unitId:n,replacements:r}=e,s=t.__tempBatchingUndoRedo(n),o=await Promise.all(r.map(c=>i.executeCommand(R.SetRangeValuesCommand.id,{unitId:n,subUnitId:c.subUnitId,value:c.value})));return s.dispose(),q(o,r)}};function q(h,e){let t=0,i=0;return h.forEach((n,r)=>{const s=e[r].count;n?t+=s:i+=s}),{success:t,failure:i}}class K extends k.Shape{constructor(t,i){super(t,i);m(this,"_activated",!1);m(this,"_inHiddenRange",!1);m(this,"_color");i&&this.setShapeProps(i)}setShapeProps(t){this._activated=!!t.activated,typeof t.inHiddenRange<"u"&&(this._inHiddenRange=t.inHiddenRange),typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){const i=this._activated,n=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, 0.35)`,r=`rgb(${this._color.r}, ${this._color.g}, ${this._color.b})`;k.Rect.drawWith(t,{width:this.width,height:this.height,fill:n,stroke:i?r:void 0,strokeWidth:i?2:0,evented:!1})}}function T(h,e){return h.startRow===e.startRow&&h.startColumn===e.startColumn}function H(h,e){return h.startRow<e.startRow||h.startRow===e.startRow&&h.startColumn<=e.startColumn}function E(h,e){return h.startColumn<e.startColumn||h.startColumn===e.startColumn&&h.startRow<=e.startRow}function Q(h,e){return h.startRow>e.startRow||h.startRow===e.startRow&&h.startColumn>=e.startColumn}function X(h,e){return h.startColumn>e.startColumn||h.startColumn===e.startColumn&&h.startRow>=e.startRow}function z(h,e){const{range:t}=h,{startRow:i,startColumn:n}=t,r=e.getMergedCell(i,n);return r?a.Rectangle.equals(t,r):t.endRow===t.startRow&&t.endColumn===t.startColumn}var J=Object.defineProperty,Z=Object.getOwnPropertyDescriptor,U=(h,e,t,i)=>{for(var n=i>1?void 0:i?Z(e,t):e,r=h.length-1,s;r>=0;r--)(s=h[r])&&(n=(i?s(e,t,n):s(n))||n);return i&&n&&J(e,t,n),n},p=(h,e)=>(t,i)=>e(t,i,h);_.SheetsFindReplaceController=class extends a.Disposable{constructor(t,i,n,r,s){super();m(this,"_provider");this._injector=t,this._findReplaceController=i,this._contextService=n,this._findReplaceService=r,this._commandService=s,this._init(),this._initCommands()}dispose(){super.dispose(),this._findReplaceController.closePanel(),this._provider.dispose()}_init(){const t=this._injector.createInstance(x);this._provider=t,this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(t)),this.disposeWithMe(this._contextService.subscribeContextValue$(a.EDITOR_ACTIVATED).pipe(C.filter(i=>!!i)).subscribe(()=>this._findReplaceController.closePanel()))}_initCommands(){[F].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t)))}},_.SheetsFindReplaceController=U([p(0,a.Inject(a.Injector)),p(1,a.Inject(f.FindReplaceController)),p(2,a.IContextService),p(3,f.IFindReplaceService),p(4,a.ICommandService)],_.SheetsFindReplaceController);const ee="sheets-find-replace-provider",te=1e4;let P=class extends f.FindModel{constructor(e,t,i,n,r,s,o,c){super();m(this,"_matchesUpdate$",new C.Subject);m(this,"matchesUpdate$",this._matchesUpdate$.asObservable());m(this,"_activelyChangingMatch$",new C.Subject);m(this,"activelyChangingMatch$",this._activelyChangingMatch$.asObservable());m(this,"_matchesByWorksheet",new Map);m(this,"_matches",[]);m(this,"_matchesPosition",0);m(this,"_activeHighlightIndex",-1);m(this,"_highlightShapes",[]);m(this,"_currentHighlightShape",null);m(this,"_query",null);m(this,"_workbookSelections");this._workbook=e,this._sheetSkeletonManagerService=t,this._univerInstanceService=i,this._renderManagerService=n,this._commandService=r,this._contextService=s,this._themeService=o,this._workbookSelections=c.getWorkbookSelections(this.unitId)}get _matchesCount(){return this._matches.length}get unitId(){return this._workbook.getUnitId()}get matchesCount(){return this._matchesCount}get matchesPosition(){return this._matchesPosition}get currentMatch(){return this._matchesPosition>0?this._matches[this._matchesPosition-1]:null}dispose(){super.dispose(),this._disposeHighlights(),this._toggleDisplayRawFormula(!1)}getMatches(){return this._matches}start(e){switch(this._query=e,e.findBy===f.FindBy.FORMULA?this._toggleDisplayRawFormula(!0):this._toggleDisplayRawFormula(!1),e.findScope){case f.FindScope.UNIT:this.findInWorkbook(e);break;case f.FindScope.SUBUNIT:default:this.findInActiveWorksheet(e);break}}_toggleDisplayRawFormula(e){this._contextService.setContextValue(k.RENDER_RAW_FORMULA_KEY,e)}findInWorkbook(e){const t=this._workbook.getUnitId();let i,n=!0;const r=()=>{const s=this._workbook.getSheets().filter(o=>!o.isSheetHidden()).map(o=>{const c=this._findInWorksheet(o,e,t),d=o.getSheetId(),{results:l}=c;return l.length?this._matchesByWorksheet.set(d,c.results):this._matchesByWorksheet.delete(d),c});this._matches=s.map(o=>o.results).flat(),this._updateFindHighlight(),n?(i={results:this._matches},n=!1):this._matchesUpdate$.next(this._matches)};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._updateFindHighlight(),this._updateCurrentHighlightShape(this._activeHighlightIndex)})),this.disposeWithMe(a.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([s,o])=>s.id===R.SetWorksheetActiveOperation.id&&!(o!=null&&o.fromFindReplace))).subscribe(()=>{const s=this._workbook.getActiveSheet();if(!s)return;const o=s.getSheetId();this._matchesByWorksheet.has(o)&&this._findNextMatchOnActiveSheetChange(s)})),this.disposeWithMe(a.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([s])=>s.type===a.CommandType.MUTATION&&s.params.unitId===this._workbook.getUnitId()),C.throttleTime(600,void 0,{leading:!1,trailing:!0})).subscribe(()=>r())),r(),i}_findNextMatchOnActiveSheetChange(e){let t,i,n=0;const r=this._matchesByWorksheet.get(e.getSheetId()),s=this._workbookSelections.getCurrentSelections();s!=null&&s.length?([t,n]=this._findNextMatchByRange(r,s[0].range),i=r.findIndex(o=>o===t)):(t=r[0],i=0,n=this._matches.findIndex(o=>o===t)),this._matchesPosition=n+1,this._activelyChangingMatch$.next(t),this._activeHighlightIndex=i,this._updateFindHighlight(),this._updateCurrentHighlightShape(i)}findInActiveWorksheet(e){const t=this._workbook.getUnitId(),i=()=>{var u;const c=this._workbook.getActiveSheet();if(!c)return!1;const d=this._workbookSelections.getCurrentSelections();return(u=d==null?void 0:d.some(g=>!z(g,c)))!=null?u:!1};let n,r=!0,s=!1;const o=()=>{const c=this._workbook.getActiveSheet();if(!c)return{results:[]};const d=this.currentMatch;s=i();const l=this._workbookSelections.getCurrentSelections(),u=s?this._findInSelections(c,l,e,t):this._findInWorksheet(c,e,t);return this._matches=u.results,this._matchesPosition=this._tryRestoreLastMatchesPosition(d,this._matches),r?(n=u,r=!1):this._matchesUpdate$.next(this._matches),this._updateFindHighlight(),u};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>this._updateFindHighlight())),this.disposeWithMe(C.merge(a.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([c])=>{if(c.type===a.CommandType.MUTATION&&c.params.unitId===this._workbook.getUnitId())return!0;if(c.id===R.SetSelectionsOperation.id&&c.params.unitId===t){const d=i();return d===!1&&s===!1?!1:(s=d,!0)}return!1})),this._workbook.activeSheet$.pipe(C.skip(1))).pipe(C.debounceTime(200)).subscribe(()=>o())),o(),n}_findInRange(e,t,i,n,r){const s=[],o=e.getSheetId(),c=(t.findDirection===f.FindDirection.COLUMN?e.iterateByColumn:e.iterateByRow).bind(e)(i);for(const d of c){const{row:l,col:u,colSpan:g,rowSpan:v,value:I}=d;if(r!=null&&r(l,u)||!I||e.getRowFiltered(l))continue;const{hit:b,replaceable:y,isFormula:w}=ie(e,l,u,t,I);if(b){const W={provider:ee,unitId:n,replaceable:y,isFormula:w,range:{subUnitId:o,range:{startRow:l,startColumn:u,endColumn:u+(g!=null?g:1)-1,endRow:l+(v!=null?v:1)-1}}};s.push(W)}}return{results:s}}_findInSelections(e,t,i,n){const{findDirection:r}=i,s=r===f.FindDirection.ROW?H:E,o=new Set;return{results:t.map(d=>this._findInRange(e,i,d.range,n,(l,u)=>{const g=`${l}-${u}`;return o.has(g)?!0:(o.add(g),!1)}).results).flat().sort((d,l)=>s(d.range.range,l.range.range)?-1:1)}}_findInWorksheet(e,t,i){const n=e.getRowCount(),r=e.getColumnCount(),s={startRow:0,startColumn:0,endRow:n-1,endColumn:r-1};return this._findInRange(e,t,s,i)}_disposeHighlights(){var e;this._highlightShapes.forEach(t=>{var i;(i=t.getScene())==null||i.makeDirty(),t.dispose()}),this._highlightShapes=[],(e=this._currentHighlightShape)==null||e.dispose(),this._currentHighlightShape=null}_updateFindHighlight(){var u;this._disposeHighlights();const e=(u=this._sheetSkeletonManagerService.getCurrent())==null?void 0:u.skeleton;if(!e)return;const t=this._workbook.getUnitId(),i=this._renderManagerService.getRenderById(t);if(i==null)return;const{scene:n}=i,r=this._matches,s=this._themeService.getCurrentTheme().gold400,o=new a.ColorKit(s).toRgb(),c=this._workbook.getActiveSheet();if(!c)return;const d=c.getSheetId(),l=r.filter(g=>g.range.subUnitId===d).map((g,v)=>{const{startColumn:I,startRow:b,endColumn:y,endRow:w}=g.range.range,W=M.getCoordByCell(b,I,n,e),ae=M.getCoordByCell(w,y,n,e),{startX:j,startY:$}=W,{endX:le,endY:de}=ae,L=!c.getRowRawVisible(b),V=!c.getColVisible(I),ue=L||V,ge=V?2:le-j,_e=L?2:de-$,fe={left:j,top:$,color:o,width:ge,height:_e,evented:!1,inHiddenRange:ue,zIndex:te};return new K(`find-highlight-${v}`,fe)});n.addObjects(l),this._highlightShapes=l,n.makeDirty()}_updateCurrentHighlightShape(e){var t;if((t=this._currentHighlightShape)==null||t.setShapeProps({activated:!1}),this._currentHighlightShape=null,e!==void 0){const i=this._highlightShapes[e];if(!i)return;this._currentHighlightShape=i,i.setShapeProps({activated:!0})}}_getSheetObject(){return M.getSheetObject(this._univerInstanceService,this._renderManagerService)}_focusMatch(e){var i;const t=e.range.subUnitId;t!==((i=this._workbook.getActiveSheet())==null?void 0:i.getSheetId())&&this._commandService.executeCommand(R.SetWorksheetActivateCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:t},{fromFindReplace:!0}),this._commandService.executeCommand(M.ScrollToCellCommand.id,{range:e.range.range},{fromFindReplace:!0})}_tryRestoreLastMatchesPosition(e,t){if(!e)return 0;const{subUnitId:i}=e.range,{startColumn:n,startRow:r}=e.range.range,s=t.findIndex(o=>{if(i!==o.range.subUnitId)return!1;const{startColumn:c,startRow:d}=o.range.range;return c===n&&d===r});return s>-1?s+1:0}moveToNextMatch(e){var o,c,d,l,u;if(!this._matches.length)return null;const t=(o=e==null?void 0:e.loop)!=null?o:!1,i=(c=e==null?void 0:e.stayIfOnMatch)!=null?c:!1,n=(d=e==null?void 0:e.noFocus)!=null?d:!1,r=(l=e==null?void 0:e.ignoreSelection)!=null?l:!1,s=this._findNextMatch(t,i,r);if(s){const[g,v]=s;return this._matchesPosition=v+1,this._query.findScope===f.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(g.range.subUnitId).findIndex(I=>I===g):this._activeHighlightIndex=v,n||this._focusMatch(g),((u=this._workbook.getActiveSheet())==null?void 0:u.getSheetId())===g.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),g}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}moveToPreviousMatch(e){var o,c,d,l,u;if(!this._matches.length)return null;const t=(o=e==null?void 0:e.loop)!=null?o:!1,i=(c=e==null?void 0:e.stayIfOnMatch)!=null?c:!1,n=(d=e==null?void 0:e.noFocus)!=null?d:!1,r=(l=e==null?void 0:e.ignoreSelection)!=null?l:!1,s=this._findPreviousMatch(t,i,r);if(s){const[g,v]=s;return this._matchesPosition=v+1,this._query.findScope===f.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(g.range.subUnitId).findIndex(I=>I===g):this._activeHighlightIndex=v,n||this._focusMatch(g),((u=this._workbook.getActiveSheet())==null?void 0:u.getSheetId())===g.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),g}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}_findPreviousMatch(e=!1,t=!1,i=!1){var o;if(this.currentMatch){const c=this._matches.findIndex(g=>g===this.currentMatch);if(t)return[this.currentMatch,c];const d=c-1;if(!e&&d<0)return null;const l=this._matches.length,u=(d+l)%l;return[this._matches[u],u]}const n=this._workbookSelections.getCurrentLastSelection();if(i||!n){const c=this._matches.length-1;return[this._matches[c],c]}if(this._query.findScope!==f.FindScope.UNIT)return this._findPreviousMatchByRange(this._matches,n.range);const r=(o=this._workbook.getActiveSheet())==null?void 0:o.getSheetId();if(!r)return null;const s=this._findPreviousWorksheetThatHasAMatch(r,e);return s?this._findPreviousMatchByRange(this._matchesByWorksheet.get(s),n.range):null}_findNextMatch(e=!1,t=!1,i=!1){var o;if(this.currentMatch){const c=this._matches.findIndex(g=>g===this.currentMatch);if(t)return[this.currentMatch,c];const d=c+1,l=this._matches.length;if(!e&&d>=l)return null;const u=d%l;return[this._matches[u],u]}const n=this._workbookSelections.getCurrentLastSelection();if(i||!n)return[this._matches[0],0];if(this._query.findScope!==f.FindScope.UNIT)return this._findNextMatchByRange(this._matches,n.range,t);const r=(o=this._workbook.getActiveSheet())==null?void 0:o.getSheetId();if(!r)return null;const s=this._findNextWorksheetThatHasAMatch(r,e);return s?this._findNextMatchByRange(this._matchesByWorksheet.get(s),n.range):null}_findPreviousWorksheetThatHasAMatch(e,t=!1){const i=this._workbook.getSheetOrders(),n=i.findIndex(o=>o===e),s=(t?a.rotate(i,n+1):i.slice(0,n+1)).findLast(o=>this._matchesByWorksheet.has(o));return s!=null?s:null}_findNextWorksheetThatHasAMatch(e,t=!1){const i=this._workbook.getSheetOrders(),n=i.findIndex(o=>o===e),s=(t?a.rotate(i,n):i.slice(n)).find(o=>this._matchesByWorksheet.has(o));return s!=null?s:null}_findNextMatchByRange(e,t,i=!1){const n=this._query.findDirection===f.FindDirection.ROW;let r=e.findIndex(o=>{const c=o.range.range;if(!(n?H(t,c):E(t,c)))return!1;const l=T(t,c);return i?l:!l});r===-1&&(r=e.length-1);const s=e[r];return[s,this._matches.findIndex(o=>o===s)]}_findPreviousMatchByRange(e,t,i=!1){const n=this._query.findDirection===f.FindDirection.ROW;let r=this._matches.findLastIndex(o=>{const c=o.range.range;if(!(n?Q(t,c):X(t,c)))return!1;const l=T(t,c);return i?l:!l});r===-1&&(r=0);const s=e[r];return[s,this._matches.findIndex(o=>o===s)]}async replace(e){if(this._matchesCount===0||!this.currentMatch||!this._query||!this.currentMatch.replaceable)return!1;const t=this.currentMatch.range,i=this._workbook.getSheetBySheetId(this.currentMatch.range.subUnitId),n=this._getReplacedCellData(this.currentMatch,i,this._query.findBy===f.FindBy.FORMULA,this._query.findString,e,this._query.caseSensitive?"g":"ig"),r={unitId:this.currentMatch.unitId,subUnitId:t.subUnitId,value:{[t.range.startRow]:{[t.range.startColumn]:n}}};return this._commandService.executeCommand(R.SetRangeValuesCommand.id,r)}async replaceAll(e){if(this._matchesCount===0||!this._query)return{success:0,failure:0};const t=this._workbook.getUnitId(),{findString:i,caseSensitive:n,findBy:r}=this._query,s=r===f.FindBy.FORMULA,o=n?"g":"ig",c=[];return a.groupBy(this._matches.filter(l=>l.replaceable),l=>l.range.subUnitId).forEach((l,u)=>{const g=new a.ObjectMatrix,v=this._workbook.getSheetBySheetId(u);l.forEach(I=>{const{startColumn:b,startRow:y}=I.range.range,w=this._getReplacedCellData(I,v,s,i,e,o);w&&g.setValue(y,b,w)}),c.push({count:l.length,subUnitId:u,value:g.getMatrix()})}),c?this._commandService.executeCommand(F.id,{unitId:t,replacements:c}):{success:0,failure:0}}_getReplacedCellData(e,t,i,n,r,s){var v;const o=e.range.range,{startRow:c,startColumn:d}=o,l=t.getCellRaw(c,d);if(e.isFormula)return i?{f:l.f.replace(new RegExp(O(n),s),r),v:null}:null;if(!!((v=l.p)!=null&&v.body)){const I=a.Tools.deepClone(l.p);return a.replaceInDocumentBody(I.body,n,r,this._query.caseSensitive),{p:I}}return{v:l.v.toString().replace(new RegExp(O(n),s),r)}}};P=U([p(2,a.IUniverInstanceService),p(3,k.IRenderManagerService),p(4,a.ICommandService),p(5,a.IContextService),p(6,a.Inject(a.ThemeService)),p(7,a.Inject(R.SheetsSelectionsService))],P);function O(h){return h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}let x=class extends a.Disposable{constructor(e,t,i){super();m(this,"_findModelsByUnitId",new Map);this._univerInstanceService=e,this._renderManagerService=t,this._injector=i}async find(e){this._terminate();const t=this._univerInstanceService.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET),i=this._preprocessQuery(e);return t.map(r=>{const s=this._renderManagerService.getRenderById(r.getUnitId()).with(M.SheetSkeletonManagerService),o=this._injector.createInstance(P,r,s);return this._findModelsByUnitId.set(r.getUnitId(),o),o.start(i),o})}terminate(){this._terminate()}_terminate(){this._findModelsByUnitId.forEach(e=>e.dispose()),this._findModelsByUnitId.clear()}_preprocessQuery(e){let t=e.caseSensitive?e.findString:e.findString.toLowerCase();return t=t.trim(),{...e,findString:t}}};x=U([p(0,a.IUniverInstanceService),p(1,k.IRenderManagerService),p(2,a.Inject(a.Injector))],x);const S={hit:!1,replaceable:!1,isFormula:!1,rawData:null};function ie(h,e,t,i,n){const{findBy:r}=i,s=r===f.FindBy.FORMULA,o=h.getCellRaw(e,t);return S.rawData=o,!(o!=null&&o.f)?(S.isFormula=!1,B(n,i)?o?(S.hit=!0,S.replaceable=!0):(S.hit=!0,S.replaceable=!1):(S.hit=!1,S.replaceable=!1),S):(S.isFormula=!0,s?B({v:o.f},i)?(S.hit=!0,S.replaceable=!0,S):(S.hit=!1,S.replaceable=!1,S):(S.replaceable=!1,B(n,i)?S.hit=!0:S.hit=!1,S))}function B(h,e){let t=ne(h);return t?e.matchesTheWholeCell?(t=se(t),e.caseSensitive?t===e.findString:t.toLowerCase()===e.findString):e.caseSensitive?t.indexOf(e.findString)>-1:t.toLowerCase().indexOf(e.findString)>-1:!1}function ne(h){var t,i,n;const e=(n=(i=(t=h==null?void 0:h.p)==null?void 0:t.body)==null?void 0:i.dataStream)!=null?n:h==null?void 0:h.v;return typeof e=="number"?`${e}`:typeof e=="boolean"?e?"1":"0":e}function se(h){return h.replace(/^ +/g,"").replace(/ +$/g,"")}var A=Object.defineProperty,re=Object.getOwnPropertyDescriptor,oe=(h,e,t)=>e in h?A(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t,he=(h,e,t,i)=>{for(var n=i>1?void 0:i?re(e,t):e,r=h.length-1,s;r>=0;r--)(s=h[r])&&(n=(i?s(e,t,n):s(n))||n);return i&&n&&A(e,t,n),n},D=(h,e)=>(t,i)=>e(t,i,h),N=(h,e,t)=>oe(h,typeof e!="symbol"?e+"":e,t);const ce="SHEET_FIND_REPLACE_PLUGIN";_.UniverSheetsFindReplacePlugin=class extends a.Plugin{constructor(e=Y,t,i){super(),this._config=e,this._injector=t,this._configService=i;const{...n}=this._config;this._configService.setConfig(G,n)}onStarting(){[[_.SheetsFindReplaceController]].forEach(e=>this._injector.add(e))}onSteady(){this._injector.get(_.SheetsFindReplaceController)}},N(_.UniverSheetsFindReplacePlugin,"pluginName",ce),N(_.UniverSheetsFindReplacePlugin,"type",a.UniverInstanceType.UNIVER_SHEET),_.UniverSheetsFindReplacePlugin=he([a.DependentOn(R.UniverSheetsPlugin,R.UniverSheetsPlugin,f.UniverFindReplacePlugin),D(1,a.Inject(a.Injector)),D(2,a.IConfigService)],_.UniverSheetsFindReplacePlugin),_.SheetReplaceCommand=F,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
|
14
|
+
(function(_,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/find-replace"),require("@univerjs/sheets"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/find-replace","@univerjs/sheets","@univerjs/engine-render","@univerjs/sheets-ui","rxjs"],a):(_=typeof globalThis<"u"?globalThis:_||self,a(_.UniverSheetsFindReplace={},_.UniverCore,_.UniverFindReplace,_.UniverSheets,_.UniverEngineRender,_.UniverSheetsUi,_.rxjs))})(this,function(_,a,f,R,k,M,C){"use strict";var Se=Object.defineProperty;var me=(_,a,f)=>a in _?Se(_,a,{enumerable:!0,configurable:!0,writable:!0,value:f}):_[a]=f;var m=(_,a,f)=>me(_,typeof a!="symbol"?a+"":a,f);const Y="sheets-find-replace.config",T={},F={id:"sheet.command.replace",type:a.CommandType.COMMAND,handler:async(h,e)=>{const t=h.get(a.IUndoRedoService),i=h.get(a.ICommandService),{unitId:n,replacements:r}=e,s=t.__tempBatchingUndoRedo(n),o=await Promise.all(r.map(c=>i.executeCommand(R.SetRangeValuesCommand.id,{unitId:n,subUnitId:c.subUnitId,value:c.value})));return s.dispose(),q(o,r)}};function q(h,e){let t=0,i=0;return h.forEach((n,r)=>{const s=e[r].count;n?t+=s:i+=s}),{success:t,failure:i}}class K extends k.Shape{constructor(t,i){super(t,i);m(this,"_activated",!1);m(this,"_inHiddenRange",!1);m(this,"_color");i&&this.setShapeProps(i)}setShapeProps(t){this._activated=!!t.activated,typeof t.inHiddenRange<"u"&&(this._inHiddenRange=t.inHiddenRange),typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){const i=this._activated,n=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, 0.35)`,r=`rgb(${this._color.r}, ${this._color.g}, ${this._color.b})`;k.Rect.drawWith(t,{width:this.width,height:this.height,fill:n,stroke:i?r:void 0,strokeWidth:i?2:0,evented:!1})}}function H(h,e){return h.startRow===e.startRow&&h.startColumn===e.startColumn}function E(h,e){return h.startRow<e.startRow||h.startRow===e.startRow&&h.startColumn<=e.startColumn}function O(h,e){return h.startColumn<e.startColumn||h.startColumn===e.startColumn&&h.startRow<=e.startRow}function Q(h,e){return h.startRow>e.startRow||h.startRow===e.startRow&&h.startColumn>=e.startColumn}function X(h,e){return h.startColumn>e.startColumn||h.startColumn===e.startColumn&&h.startRow>=e.startRow}function z(h,e){const{range:t}=h,{startRow:i,startColumn:n}=t,r=e.getMergedCell(i,n);return r?a.Rectangle.equals(t,r):t.endRow===t.startRow&&t.endColumn===t.startColumn}var J=Object.defineProperty,Z=Object.getOwnPropertyDescriptor,U=(h,e,t,i)=>{for(var n=i>1?void 0:i?Z(e,t):e,r=h.length-1,s;r>=0;r--)(s=h[r])&&(n=(i?s(e,t,n):s(n))||n);return i&&n&&J(e,t,n),n},p=(h,e)=>(t,i)=>e(t,i,h);_.SheetsFindReplaceController=class extends a.Disposable{constructor(t,i,n,r,s){super();m(this,"_provider");this._injector=t,this._findReplaceController=i,this._contextService=n,this._findReplaceService=r,this._commandService=s,this._init(),this._initCommands()}dispose(){super.dispose(),this._findReplaceController.closePanel(),this._provider.dispose()}_init(){const t=this._injector.createInstance(x);this._provider=t,this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(t)),this.disposeWithMe(this._contextService.subscribeContextValue$(a.EDITOR_ACTIVATED).pipe(C.filter(i=>!!i)).subscribe(()=>this._findReplaceController.closePanel()))}_initCommands(){[F].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t)))}},_.SheetsFindReplaceController=U([p(0,a.Inject(a.Injector)),p(1,a.Inject(f.FindReplaceController)),p(2,a.IContextService),p(3,f.IFindReplaceService),p(4,a.ICommandService)],_.SheetsFindReplaceController);const ee="sheets-find-replace-provider",te=1e4;let P=class extends f.FindModel{constructor(e,t,i,n,r,s,o,c){super();m(this,"_matchesUpdate$",new C.Subject);m(this,"matchesUpdate$",this._matchesUpdate$.asObservable());m(this,"_activelyChangingMatch$",new C.Subject);m(this,"activelyChangingMatch$",this._activelyChangingMatch$.asObservable());m(this,"_matchesByWorksheet",new Map);m(this,"_matches",[]);m(this,"_matchesPosition",0);m(this,"_activeHighlightIndex",-1);m(this,"_highlightShapes",[]);m(this,"_currentHighlightShape",null);m(this,"_query",null);m(this,"_workbookSelections");this._workbook=e,this._sheetSkeletonManagerService=t,this._univerInstanceService=i,this._renderManagerService=n,this._commandService=r,this._contextService=s,this._themeService=o,this._workbookSelections=c.getWorkbookSelections(this.unitId)}get _matchesCount(){return this._matches.length}get unitId(){return this._workbook.getUnitId()}get matchesCount(){return this._matchesCount}get matchesPosition(){return this._matchesPosition}get currentMatch(){return this._matchesPosition>0?this._matches[this._matchesPosition-1]:null}dispose(){super.dispose(),this._disposeHighlights(),this._toggleDisplayRawFormula(!1)}getMatches(){return this._matches}start(e){switch(this._query=e,e.findBy===f.FindBy.FORMULA?this._toggleDisplayRawFormula(!0):this._toggleDisplayRawFormula(!1),e.findScope){case f.FindScope.UNIT:this.findInWorkbook(e);break;case f.FindScope.SUBUNIT:default:this.findInActiveWorksheet(e);break}}_toggleDisplayRawFormula(e){this._contextService.setContextValue(k.RENDER_RAW_FORMULA_KEY,e)}findInWorkbook(e){const t=this._workbook.getUnitId();let i,n=!0;const r=()=>{const s=this._workbook.getSheets().filter(o=>!o.isSheetHidden()).map(o=>{const c=this._findInWorksheet(o,e,t),d=o.getSheetId(),{results:l}=c;return l.length?this._matchesByWorksheet.set(d,c.results):this._matchesByWorksheet.delete(d),c});this._matches=s.map(o=>o.results).flat(),this._updateFindHighlight(),n?(i={results:this._matches},n=!1):this._matchesUpdate$.next(this._matches)};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._updateFindHighlight(),this._updateCurrentHighlightShape(this._activeHighlightIndex)})),this.disposeWithMe(a.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([s,o])=>s.id===R.SetWorksheetActiveOperation.id&&!(o!=null&&o.fromFindReplace))).subscribe(()=>{const s=this._workbook.getActiveSheet();if(!s)return;const o=s.getSheetId();this._matchesByWorksheet.has(o)&&this._findNextMatchOnActiveSheetChange(s)})),this.disposeWithMe(a.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([s])=>s.type===a.CommandType.MUTATION&&s.params.unitId===this._workbook.getUnitId()),C.throttleTime(600,void 0,{leading:!1,trailing:!0})).subscribe(()=>r())),r(),i}_findNextMatchOnActiveSheetChange(e){let t,i,n=0;const r=this._matchesByWorksheet.get(e.getSheetId()),s=this._workbookSelections.getCurrentSelections();s!=null&&s.length?([t,n]=this._findNextMatchByRange(r,s[0].range),i=r.findIndex(o=>o===t)):(t=r[0],i=0,n=this._matches.findIndex(o=>o===t)),this._matchesPosition=n+1,this._activelyChangingMatch$.next(t),this._activeHighlightIndex=i,this._updateFindHighlight(),this._updateCurrentHighlightShape(i)}findInActiveWorksheet(e){const t=this._workbook.getUnitId(),i=()=>{var u;const c=this._workbook.getActiveSheet();if(!c)return!1;const d=this._workbookSelections.getCurrentSelections();return(u=d==null?void 0:d.some(g=>!z(g,c)))!=null?u:!1};let n,r=!0,s=!1;const o=()=>{const c=this._workbook.getActiveSheet();if(!c)return{results:[]};const d=this.currentMatch;s=i();const l=this._workbookSelections.getCurrentSelections(),u=s?this._findInSelections(c,l,e,t):this._findInWorksheet(c,e,t);return this._matches=u.results,this._matchesPosition=this._tryRestoreLastMatchesPosition(d,this._matches),r?(n=u,r=!1):this._matchesUpdate$.next(this._matches),this._updateFindHighlight(),u};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>this._updateFindHighlight())),this.disposeWithMe(C.merge(a.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([c])=>{if(c.type===a.CommandType.MUTATION&&c.params.unitId===this._workbook.getUnitId())return!0;if(c.id===R.SetSelectionsOperation.id&&c.params.unitId===t){const d=i();return d===!1&&s===!1?!1:(s=d,!0)}return!1})),this._workbook.activeSheet$.pipe(C.skip(1))).pipe(C.debounceTime(200)).subscribe(()=>o())),o(),n}_findInRange(e,t,i,n,r){const s=[],o=e.getSheetId(),c=(t.findDirection===f.FindDirection.COLUMN?e.iterateByColumn:e.iterateByRow).bind(e)(i);for(const d of c){const{row:l,col:u,colSpan:g,rowSpan:v,value:I}=d;if(r!=null&&r(l,u)||!I||e.getRowFiltered(l))continue;const{hit:b,replaceable:y,isFormula:w}=ie(e,l,u,t,I);if(b){const W={provider:ee,unitId:n,replaceable:y,isFormula:w,range:{subUnitId:o,range:{startRow:l,startColumn:u,endColumn:u+(g!=null?g:1)-1,endRow:l+(v!=null?v:1)-1}}};s.push(W)}}return{results:s}}_findInSelections(e,t,i,n){const{findDirection:r}=i,s=r===f.FindDirection.ROW?E:O,o=new Set;return{results:t.map(d=>this._findInRange(e,i,d.range,n,(l,u)=>{const g=`${l}-${u}`;return o.has(g)?!0:(o.add(g),!1)}).results).flat().sort((d,l)=>s(d.range.range,l.range.range)?-1:1)}}_findInWorksheet(e,t,i){const n=e.getRowCount(),r=e.getColumnCount(),s={startRow:0,startColumn:0,endRow:n-1,endColumn:r-1};return this._findInRange(e,t,s,i)}_disposeHighlights(){var e;this._highlightShapes.forEach(t=>{var i;(i=t.getScene())==null||i.makeDirty(),t.dispose()}),this._highlightShapes=[],(e=this._currentHighlightShape)==null||e.dispose(),this._currentHighlightShape=null}_updateFindHighlight(){var u;this._disposeHighlights();const e=(u=this._sheetSkeletonManagerService.getCurrent())==null?void 0:u.skeleton;if(!e)return;const t=this._workbook.getUnitId(),i=this._renderManagerService.getRenderById(t);if(i==null)return;const{scene:n}=i,r=this._matches,s=this._themeService.getCurrentTheme().gold400,o=new a.ColorKit(s).toRgb(),c=this._workbook.getActiveSheet();if(!c)return;const d=c.getSheetId(),l=r.filter(g=>g.range.subUnitId===d).map((g,v)=>{const{startColumn:I,startRow:b,endColumn:y,endRow:w}=g.range.range,W=M.getCoordByCell(b,I,n,e),ae=M.getCoordByCell(w,y,n,e),{startX:$,startY:L}=W,{endX:le,endY:de}=ae,V=!c.getRowRawVisible(b),G=!c.getColVisible(I),ue=V||G,ge=G?2:le-$,_e=V?2:de-L,fe={left:$,top:L,color:o,width:ge,height:_e,evented:!1,inHiddenRange:ue,zIndex:te};return new K(`find-highlight-${v}`,fe)});n.addObjects(l),this._highlightShapes=l,n.makeDirty()}_updateCurrentHighlightShape(e){var t;if((t=this._currentHighlightShape)==null||t.setShapeProps({activated:!1}),this._currentHighlightShape=null,e!==void 0){const i=this._highlightShapes[e];if(!i)return;this._currentHighlightShape=i,i.setShapeProps({activated:!0})}}_getSheetObject(){return M.getSheetObject(this._univerInstanceService,this._renderManagerService)}_focusMatch(e){var i;const t=e.range.subUnitId;t!==((i=this._workbook.getActiveSheet())==null?void 0:i.getSheetId())&&this._commandService.executeCommand(R.SetWorksheetActivateCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:t},{fromFindReplace:!0}),this._commandService.executeCommand(M.ScrollToCellCommand.id,{range:e.range.range},{fromFindReplace:!0})}_tryRestoreLastMatchesPosition(e,t){if(!e)return 0;const{subUnitId:i}=e.range,{startColumn:n,startRow:r}=e.range.range,s=t.findIndex(o=>{if(i!==o.range.subUnitId)return!1;const{startColumn:c,startRow:d}=o.range.range;return c===n&&d===r});return s>-1?s+1:0}moveToNextMatch(e){var o,c,d,l,u;if(!this._matches.length)return null;const t=(o=e==null?void 0:e.loop)!=null?o:!1,i=(c=e==null?void 0:e.stayIfOnMatch)!=null?c:!1,n=(d=e==null?void 0:e.noFocus)!=null?d:!1,r=(l=e==null?void 0:e.ignoreSelection)!=null?l:!1,s=this._findNextMatch(t,i,r);if(s){const[g,v]=s;return this._matchesPosition=v+1,this._query.findScope===f.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(g.range.subUnitId).findIndex(I=>I===g):this._activeHighlightIndex=v,n||this._focusMatch(g),((u=this._workbook.getActiveSheet())==null?void 0:u.getSheetId())===g.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),g}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}moveToPreviousMatch(e){var o,c,d,l,u;if(!this._matches.length)return null;const t=(o=e==null?void 0:e.loop)!=null?o:!1,i=(c=e==null?void 0:e.stayIfOnMatch)!=null?c:!1,n=(d=e==null?void 0:e.noFocus)!=null?d:!1,r=(l=e==null?void 0:e.ignoreSelection)!=null?l:!1,s=this._findPreviousMatch(t,i,r);if(s){const[g,v]=s;return this._matchesPosition=v+1,this._query.findScope===f.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(g.range.subUnitId).findIndex(I=>I===g):this._activeHighlightIndex=v,n||this._focusMatch(g),((u=this._workbook.getActiveSheet())==null?void 0:u.getSheetId())===g.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),g}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}_findPreviousMatch(e=!1,t=!1,i=!1){var o;if(this.currentMatch){const c=this._matches.findIndex(g=>g===this.currentMatch);if(t)return[this.currentMatch,c];const d=c-1;if(!e&&d<0)return null;const l=this._matches.length,u=(d+l)%l;return[this._matches[u],u]}const n=this._workbookSelections.getCurrentLastSelection();if(i||!n){const c=this._matches.length-1;return[this._matches[c],c]}if(this._query.findScope!==f.FindScope.UNIT)return this._findPreviousMatchByRange(this._matches,n.range);const r=(o=this._workbook.getActiveSheet())==null?void 0:o.getSheetId();if(!r)return null;const s=this._findPreviousWorksheetThatHasAMatch(r,e);return s?this._findPreviousMatchByRange(this._matchesByWorksheet.get(s),n.range):null}_findNextMatch(e=!1,t=!1,i=!1){var o;if(this.currentMatch){const c=this._matches.findIndex(g=>g===this.currentMatch);if(t)return[this.currentMatch,c];const d=c+1,l=this._matches.length;if(!e&&d>=l)return null;const u=d%l;return[this._matches[u],u]}const n=this._workbookSelections.getCurrentLastSelection();if(i||!n)return[this._matches[0],0];if(this._query.findScope!==f.FindScope.UNIT)return this._findNextMatchByRange(this._matches,n.range,t);const r=(o=this._workbook.getActiveSheet())==null?void 0:o.getSheetId();if(!r)return null;const s=this._findNextWorksheetThatHasAMatch(r,e);return s?this._findNextMatchByRange(this._matchesByWorksheet.get(s),n.range):null}_findPreviousWorksheetThatHasAMatch(e,t=!1){const i=this._workbook.getSheetOrders(),n=i.findIndex(o=>o===e),s=(t?a.rotate(i,n+1):i.slice(0,n+1)).findLast(o=>this._matchesByWorksheet.has(o));return s!=null?s:null}_findNextWorksheetThatHasAMatch(e,t=!1){const i=this._workbook.getSheetOrders(),n=i.findIndex(o=>o===e),s=(t?a.rotate(i,n):i.slice(n)).find(o=>this._matchesByWorksheet.has(o));return s!=null?s:null}_findNextMatchByRange(e,t,i=!1){const n=this._query.findDirection===f.FindDirection.ROW;let r=e.findIndex(o=>{const c=o.range.range;if(!(n?E(t,c):O(t,c)))return!1;const l=H(t,c);return i?l:!l});r===-1&&(r=e.length-1);const s=e[r];return[s,this._matches.findIndex(o=>o===s)]}_findPreviousMatchByRange(e,t,i=!1){const n=this._query.findDirection===f.FindDirection.ROW;let r=this._matches.findLastIndex(o=>{const c=o.range.range;if(!(n?Q(t,c):X(t,c)))return!1;const l=H(t,c);return i?l:!l});r===-1&&(r=0);const s=e[r];return[s,this._matches.findIndex(o=>o===s)]}async replace(e){if(this._matchesCount===0||!this.currentMatch||!this._query||!this.currentMatch.replaceable)return!1;const t=this.currentMatch.range,i=this._workbook.getSheetBySheetId(this.currentMatch.range.subUnitId),n=this._getReplacedCellData(this.currentMatch,i,this._query.findBy===f.FindBy.FORMULA,this._query.findString,e,this._query.caseSensitive?"g":"ig"),r={unitId:this.currentMatch.unitId,subUnitId:t.subUnitId,value:{[t.range.startRow]:{[t.range.startColumn]:n}}};return this._commandService.executeCommand(R.SetRangeValuesCommand.id,r)}async replaceAll(e){if(this._matchesCount===0||!this._query)return{success:0,failure:0};const t=this._workbook.getUnitId(),{findString:i,caseSensitive:n,findBy:r}=this._query,s=r===f.FindBy.FORMULA,o=n?"g":"ig",c=[];return a.groupBy(this._matches.filter(l=>l.replaceable),l=>l.range.subUnitId).forEach((l,u)=>{const g=new a.ObjectMatrix,v=this._workbook.getSheetBySheetId(u);l.forEach(I=>{const{startColumn:b,startRow:y}=I.range.range,w=this._getReplacedCellData(I,v,s,i,e,o);w&&g.setValue(y,b,w)}),c.push({count:l.length,subUnitId:u,value:g.getMatrix()})}),c?this._commandService.executeCommand(F.id,{unitId:t,replacements:c}):{success:0,failure:0}}_getReplacedCellData(e,t,i,n,r,s){var v;const o=e.range.range,{startRow:c,startColumn:d}=o,l=t.getCellRaw(c,d);if(e.isFormula)return i?{f:l.f.replace(new RegExp(A(n),s),r),v:null}:null;if(!!((v=l.p)!=null&&v.body)){const I=a.Tools.deepClone(l.p);return a.replaceInDocumentBody(I.body,n,r,this._query.caseSensitive),{p:I}}return{v:l.v.toString().replace(new RegExp(A(n),s),r)}}};P=U([p(2,a.IUniverInstanceService),p(3,k.IRenderManagerService),p(4,a.ICommandService),p(5,a.IContextService),p(6,a.Inject(a.ThemeService)),p(7,a.Inject(R.SheetsSelectionsService))],P);function A(h){return h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}let x=class extends a.Disposable{constructor(e,t,i){super();m(this,"_findModelsByUnitId",new Map);this._univerInstanceService=e,this._renderManagerService=t,this._injector=i}async find(e){this._terminate();const t=this._univerInstanceService.getAllUnitsForType(a.UniverInstanceType.UNIVER_SHEET),i=this._preprocessQuery(e);return t.map(r=>{const s=this._renderManagerService.getRenderById(r.getUnitId()).with(M.SheetSkeletonManagerService),o=this._injector.createInstance(P,r,s);return this._findModelsByUnitId.set(r.getUnitId(),o),o.start(i),o})}terminate(){this._terminate()}_terminate(){this._findModelsByUnitId.forEach(e=>e.dispose()),this._findModelsByUnitId.clear()}_preprocessQuery(e){let t=e.caseSensitive?e.findString:e.findString.toLowerCase();return t=t.trim(),{...e,findString:t}}};x=U([p(0,a.IUniverInstanceService),p(1,k.IRenderManagerService),p(2,a.Inject(a.Injector))],x);const S={hit:!1,replaceable:!1,isFormula:!1,rawData:null};function ie(h,e,t,i,n){const{findBy:r}=i,s=r===f.FindBy.FORMULA,o=h.getCellRaw(e,t);return S.rawData=o,!(o!=null&&o.f)?(S.isFormula=!1,B(n,i)?o?(S.hit=!0,S.replaceable=!0):(S.hit=!0,S.replaceable=!1):(S.hit=!1,S.replaceable=!1),S):(S.isFormula=!0,s?B({v:o.f},i)?(S.hit=!0,S.replaceable=!0,S):(S.hit=!1,S.replaceable=!1,S):(S.replaceable=!1,B(n,i)?S.hit=!0:S.hit=!1,S))}function B(h,e){let t=ne(h);return t?e.matchesTheWholeCell?(t=se(t),e.caseSensitive?t===e.findString:t.toLowerCase()===e.findString):e.caseSensitive?t.indexOf(e.findString)>-1:t.toLowerCase().indexOf(e.findString)>-1:!1}function ne(h){var t,i,n;const e=(n=(i=(t=h==null?void 0:h.p)==null?void 0:t.body)==null?void 0:i.dataStream)!=null?n:h==null?void 0:h.v;return typeof e=="number"?`${e}`:typeof e=="boolean"?e?"1":"0":e}function se(h){return h.replace(/^ +/g,"").replace(/ +$/g,"")}var D=Object.defineProperty,re=Object.getOwnPropertyDescriptor,oe=(h,e,t)=>e in h?D(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t,he=(h,e,t,i)=>{for(var n=i>1?void 0:i?re(e,t):e,r=h.length-1,s;r>=0;r--)(s=h[r])&&(n=(i?s(e,t,n):s(n))||n);return i&&n&&D(e,t,n),n},N=(h,e)=>(t,i)=>e(t,i,h),j=(h,e,t)=>oe(h,typeof e!="symbol"?e+"":e,t);const ce="SHEET_FIND_REPLACE_PLUGIN";_.UniverSheetsFindReplacePlugin=class extends a.Plugin{constructor(e=T,t,i){super(),this._config=e,this._injector=t,this._configService=i;const{...n}=a.merge({},T,this._config);this._configService.setConfig(Y,n)}onStarting(){[[_.SheetsFindReplaceController]].forEach(e=>this._injector.add(e))}onSteady(){this._injector.get(_.SheetsFindReplaceController)}},j(_.UniverSheetsFindReplacePlugin,"pluginName",ce),j(_.UniverSheetsFindReplacePlugin,"type",a.UniverInstanceType.UNIVER_SHEET),_.UniverSheetsFindReplacePlugin=he([a.DependentOn(R.UniverSheetsPlugin,R.UniverSheetsPlugin,f.UniverFindReplacePlugin),N(1,a.Inject(a.Injector)),N(2,a.IConfigService)],_.UniverSheetsFindReplacePlugin),_.SheetReplaceCommand=F,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
// index
|
|
18
|
-
(function(e,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/find-replace"),require("@univerjs/sheets-find-replace")):typeof define=="function"&&define.amd?define(["exports","@univerjs/find-replace","@univerjs/sheets-find-replace"],i):(e=typeof globalThis<"u"?globalThis:e||self,i(e.UniverPresetSheetsFindReplace={},e.UniverFindReplace,e.UniverSheetsFindReplace))})(this,function(e,i,
|
|
18
|
+
(function(e,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/find-replace"),require("@univerjs/sheets-find-replace")):typeof define=="function"&&define.amd?define(["exports","@univerjs/find-replace","@univerjs/sheets-find-replace"],i):(e=typeof globalThis<"u"?globalThis:e||self,i(e.UniverPresetSheetsFindReplace={},e.UniverFindReplace,e.UniverSheetsFindReplace))})(this,function(e,i,n){"use strict";function r(s){return{plugins:[[i.UniverFindReplacePlugin],[n.UniverSheetsFindReplacePlugin]].filter(t=>!!t)}}e.UniverSheetsFindReplacePreset=r,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
package/lib/umd/locales/en-US.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
// locale/en-US
|
|
10
|
-
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n(require("@univerjs/core"),require("@univerjs/find-replace/locale/en-US"),require("@univerjs/sheets-find-replace/locale/en-US")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace/locale/en-US","@univerjs/sheets-find-replace/locale/en-US"],n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsFindReplaceEnUS=n(e.UniverCore,e.UniverFindReplaceEnUS,e.UniverSheetsFindReplaceEnUS))})(this,function(e,n,i){"use strict";return e.
|
|
10
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n(require("@univerjs/core"),require("@univerjs/find-replace/locale/en-US"),require("@univerjs/sheets-find-replace/locale/en-US")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace/locale/en-US","@univerjs/sheets-find-replace/locale/en-US"],n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsFindReplaceEnUS=n(e.UniverCore,e.UniverFindReplaceEnUS,e.UniverSheetsFindReplaceEnUS))})(this,function(e,n,i){"use strict";return e.merge({},n,i)});
|
package/lib/umd/locales/fa-IR.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
// locale/fa-IR
|
|
10
|
-
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("@univerjs/core"),require("@univerjs/find-replace/locale/fa-IR"),require("@univerjs/sheets-find-replace/locale/fa-IR")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace/locale/fa-IR","@univerjs/sheets-find-replace/locale/fa-IR"],i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsFindReplaceFaIR=i(e.UniverCore,e.UniverFindReplaceFaIR,e.UniverSheetsFindReplaceFaIR))})(this,function(e,i,n){"use strict";return e.
|
|
10
|
+
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("@univerjs/core"),require("@univerjs/find-replace/locale/fa-IR"),require("@univerjs/sheets-find-replace/locale/fa-IR")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace/locale/fa-IR","@univerjs/sheets-find-replace/locale/fa-IR"],i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsFindReplaceFaIR=i(e.UniverCore,e.UniverFindReplaceFaIR,e.UniverSheetsFindReplaceFaIR))})(this,function(e,i,n){"use strict";return e.merge({},i,n)});
|
package/lib/umd/locales/fr-FR.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
// locale/fr-FR
|
|
10
|
-
(function(e,r){typeof exports=="object"&&typeof module<"u"?module.exports=r(require("@univerjs/core"),require("@univerjs/find-replace/locale/fr-FR"),require("@univerjs/sheets-find-replace/locale/fr-FR")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace/locale/fr-FR","@univerjs/sheets-find-replace/locale/fr-FR"],r):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsFindReplaceFrFR=r(e.UniverCore,e.UniverFindReplaceFrFR,e.UniverSheetsFindReplaceFrFR))})(this,function(e,r,i){"use strict";return e.
|
|
10
|
+
(function(e,r){typeof exports=="object"&&typeof module<"u"?module.exports=r(require("@univerjs/core"),require("@univerjs/find-replace/locale/fr-FR"),require("@univerjs/sheets-find-replace/locale/fr-FR")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace/locale/fr-FR","@univerjs/sheets-find-replace/locale/fr-FR"],r):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsFindReplaceFrFR=r(e.UniverCore,e.UniverFindReplaceFrFR,e.UniverSheetsFindReplaceFrFR))})(this,function(e,r,i){"use strict";return e.merge({},r,i)});
|
package/lib/umd/locales/ru-RU.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
// locale/ru-RU
|
|
10
|
-
(function(e,r){typeof exports=="object"&&typeof module<"u"?module.exports=r(require("@univerjs/core"),require("@univerjs/find-replace/locale/ru-RU"),require("@univerjs/sheets-find-replace/locale/ru-RU")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace/locale/ru-RU","@univerjs/sheets-find-replace/locale/ru-RU"],r):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsFindReplaceRuRU=r(e.UniverCore,e.UniverFindReplaceRuRU,e.UniverSheetsFindReplaceRuRU))})(this,function(e,r,i){"use strict";return e.
|
|
10
|
+
(function(e,r){typeof exports=="object"&&typeof module<"u"?module.exports=r(require("@univerjs/core"),require("@univerjs/find-replace/locale/ru-RU"),require("@univerjs/sheets-find-replace/locale/ru-RU")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace/locale/ru-RU","@univerjs/sheets-find-replace/locale/ru-RU"],r):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsFindReplaceRuRU=r(e.UniverCore,e.UniverFindReplaceRuRU,e.UniverSheetsFindReplaceRuRU))})(this,function(e,r,i){"use strict";return e.merge({},r,i)});
|
package/lib/umd/locales/vi-VN.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
// locale/vi-VN
|
|
10
|
-
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("@univerjs/core"),require("@univerjs/find-replace/locale/vi-VN"),require("@univerjs/sheets-find-replace/locale/vi-VN")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace/locale/vi-VN","@univerjs/sheets-find-replace/locale/vi-VN"],i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsFindReplaceViVN=i(e.UniverCore,e.UniverFindReplaceViVN,e.UniverSheetsFindReplaceViVN))})(this,function(e,i,n){"use strict";return e.
|
|
10
|
+
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("@univerjs/core"),require("@univerjs/find-replace/locale/vi-VN"),require("@univerjs/sheets-find-replace/locale/vi-VN")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace/locale/vi-VN","@univerjs/sheets-find-replace/locale/vi-VN"],i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsFindReplaceViVN=i(e.UniverCore,e.UniverFindReplaceViVN,e.UniverSheetsFindReplaceViVN))})(this,function(e,i,n){"use strict";return e.merge({},i,n)});
|
package/lib/umd/locales/zh-CN.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
// locale/zh-CN
|
|
10
|
-
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("@univerjs/core"),require("@univerjs/find-replace/locale/zh-CN"),require("@univerjs/sheets-find-replace/locale/zh-CN")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace/locale/zh-CN","@univerjs/sheets-find-replace/locale/zh-CN"],i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsFindReplaceZhCN=i(e.UniverCore,e.UniverFindReplaceZhCN,e.UniverSheetsFindReplaceZhCN))})(this,function(e,i,n){"use strict";return e.
|
|
10
|
+
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("@univerjs/core"),require("@univerjs/find-replace/locale/zh-CN"),require("@univerjs/sheets-find-replace/locale/zh-CN")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace/locale/zh-CN","@univerjs/sheets-find-replace/locale/zh-CN"],i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsFindReplaceZhCN=i(e.UniverCore,e.UniverFindReplaceZhCN,e.UniverSheetsFindReplaceZhCN))})(this,function(e,i,n){"use strict";return e.merge({},i,n)});
|
package/lib/umd/locales/zh-TW.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
// locale/zh-TW
|
|
10
|
-
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("@univerjs/core"),require("@univerjs/find-replace/locale/zh-TW"),require("@univerjs/sheets-find-replace/locale/zh-TW")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace/locale/zh-TW","@univerjs/sheets-find-replace/locale/zh-TW"],i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsFindReplaceZhTW=i(e.UniverCore,e.UniverFindReplaceZhTW,e.UniverSheetsFindReplaceZhTW))})(this,function(e,i,n){"use strict";return e.
|
|
10
|
+
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("@univerjs/core"),require("@univerjs/find-replace/locale/zh-TW"),require("@univerjs/sheets-find-replace/locale/zh-TW")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/find-replace/locale/zh-TW","@univerjs/sheets-find-replace/locale/zh-TW"],i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsFindReplaceZhTW=i(e.UniverCore,e.UniverFindReplaceZhTW,e.UniverSheetsFindReplaceZhTW))})(this,function(e,i,n){"use strict";return e.merge({},i,n)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/preset-sheets-find-replace",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
"keywords": [
|
|
21
21
|
"univer"
|
|
22
22
|
],
|
|
23
|
-
"sideEffects":
|
|
23
|
+
"sideEffects": [
|
|
24
|
+
"*.css"
|
|
25
|
+
],
|
|
24
26
|
"exports": {
|
|
25
27
|
".": {
|
|
26
28
|
"import": "./lib/es/index.js",
|
|
@@ -55,13 +57,13 @@
|
|
|
55
57
|
"rxjs": ">=7.0.0"
|
|
56
58
|
},
|
|
57
59
|
"dependencies": {
|
|
58
|
-
"@univerjs/find-replace": "0.5.
|
|
59
|
-
"@univerjs/sheets-find-replace": "0.5.
|
|
60
|
+
"@univerjs/find-replace": "0.5.3",
|
|
61
|
+
"@univerjs/sheets-find-replace": "0.5.3"
|
|
60
62
|
},
|
|
61
63
|
"devDependencies": {
|
|
62
|
-
"@univerjs/core": "0.5.
|
|
64
|
+
"@univerjs/core": "0.5.3",
|
|
63
65
|
"typescript": "^5.7.2",
|
|
64
|
-
"@univerjs-infra/shared": "0.5.
|
|
66
|
+
"@univerjs-infra/shared": "0.5.3"
|
|
65
67
|
},
|
|
66
68
|
"scripts": {
|
|
67
69
|
"prebuild:preset": "tsx prepare.ts",
|