@univerjs/sheets-hyper-link 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/facade.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@univerjs/sheets-hyper-link"),o=require("@univerjs/sheets/facade"),a=require("@univerjs/core");class u extends o.FWorkbook{createSheetHyperlink(e,t){return this._injector.get(i.SheetsHyperLinkParserService).buildHyperLink(this.getId(),e,t)}parseSheetHyperlink(e){return this._injector.get(i.SheetsHyperLinkParserService).parseHyperLink(e)}}o.FWorkbook.extend(u);class k extends o.FRange{setHyperLink(e,t){const n={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),link:{row:this._range.startRow,column:this._range.startColumn,payload:e,display:t,id:a.generateRandomId()}};return this._commandService.executeCommand(i.AddHyperLinkCommand.id,n)}getHyperLinks(){var t,n,s;const e=this._worksheet.getCellRaw(this._range.startRow,this._range.startColumn);return e!=null&&e.p?(s=(n=(t=e.p.body)==null?void 0:t.customRanges)==null?void 0:n.filter(r=>r.rangeType===a.CustomRangeType.HYPERLINK).map(r=>{var d,p,c,l,m;return{id:`${r.rangeId}`,startIndex:r.startIndex,endIndex:r.endIndex,url:(p=(d=r.properties)==null?void 0:d.url)!=null?p:"",label:(m=(l=(c=e.p)==null?void 0:c.body)==null?void 0:l.dataStream.slice(r.startIndex,r.endIndex+1).replaceAll(a.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(a.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))!=null?m:""}}))!=null?s:[]:[]}updateHyperLink(e,t,n){const s={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e,payload:{payload:t,display:n}};return this._commandService.executeCommand(i.UpdateHyperLinkCommand.id,s)}cancelHyperLink(e){const t={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e};return this._commandService.syncExecuteCommand(i.CancelHyperLinkCommand.id,t)}}o.FRange.extend(k);exports.FWorkbookHyperLinkMixin=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),a=require("@univerjs/sheets-hyper-link"),d=require("@univerjs/sheets/facade");var g=Object.defineProperty,y=Object.getOwnPropertyDescriptor,m=(n,e,r,t)=>{for(var i=t>1?void 0:t?y(e,r):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(e,r,i):o(i))||i);return t&&i&&g(e,r,i),i},_=(n,e)=>(r,t)=>e(r,t,n);let u=class{constructor(n,e){this._workbook=n,this._parserService=e}getRangeUrl(n){return this._parserService.buildHyperLink(this._workbook.getId(),n.getSheetId(),n.getRange()),this}};u=m([_(1,c.Inject(a.SheetsHyperLinkParserService))],u);class S extends d.FWorkbook{createSheetHyperlink(e,r){return this._injector.get(a.SheetsHyperLinkParserService).buildHyperLink(this.getId(),e,r)}parseSheetHyperlink(e){return this._injector.get(a.SheetsHyperLinkParserService).parseHyperLink(e)}}d.FWorkbook.extend(S);class I extends d.FWorksheet{getUrl(){return this._injector.get(a.SheetsHyperLinkParserService).buildHyperLink(this._workbook.getUnitId(),this._worksheet.getSheetId())}}d.FWorksheet.extend(I);class v extends d.FRange{setHyperLink(e,r){const t={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),link:{row:this._range.startRow,column:this._range.startColumn,payload:e,display:r,id:c.generateRandomId()}};return this._commandService.executeCommand(a.AddHyperLinkCommand.id,t)}getHyperLinks(){var r,t,i;const e=this._worksheet.getCellRaw(this._range.startRow,this._range.startColumn);return e!=null&&e.p?(i=(t=(r=e.p.body)==null?void 0:r.customRanges)==null?void 0:t.filter(s=>s.rangeType===c.CustomRangeType.HYPERLINK).map(s=>{var o,p,h,l,k;return{id:`${s.rangeId}`,startIndex:s.startIndex,endIndex:s.endIndex,url:(p=(o=s.properties)==null?void 0:o.url)!=null?p:"",label:(k=(l=(h=e.p)==null?void 0:h.body)==null?void 0:l.dataStream.slice(s.startIndex,s.endIndex+1).replaceAll(c.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(c.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))!=null?k:""}}))!=null?i:[]:[]}updateHyperLink(e,r,t){const i={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e,payload:{payload:r,display:t}};return this._commandService.executeCommand(a.UpdateHyperLinkCommand.id,i)}cancelHyperLink(e){const r={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e};return this._commandService.syncExecuteCommand(a.CancelHyperLinkCommand.id,r)}getUrl(){return this._injector.get(a.SheetsHyperLinkParserService).buildHyperLink(this.getUnitId(),this.getSheetId(),this.getRange())}}d.FRange.extend(v);exports.FWorkbookHyperLinkMixin=S;
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Ie=Object.defineProperty;var Re=(i,t,e)=>t in i?Ie(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var C=(i,t,e)=>Re(i,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),Me=require("rxjs"),g=require("@univerjs/sheets"),U=require("@univerjs/engine-formula"),Z=require("@univerjs/docs");var Ce=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Le=(i,t,e,n)=>{for(var r=n>1?void 0:n?Ue(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&Ce(t,e,r),r},we=(i,t)=>(e,n)=>t(e,n,i);exports.HyperLinkModel=class extends o.Disposable{constructor(e){super();C(this,"_linkUpdate$",new Me.Subject);C(this,"linkUpdate$",this._linkUpdate$.asObservable());C(this,"_linkMap",new Map);C(this,"_linkPositionMap",new Map);this._univerInstanceService=e,this.disposeWithMe({dispose:()=>{this._linkUpdate$.complete()}})}_ensureMap(e,n){let r=this._linkMap.get(e);r||(r=new Map,this._linkMap.set(e,r));let s=r.get(n);s||(s=new o.ObjectMatrix,r.set(n,s));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let d=a.get(n);return d||(d=new Map,a.set(n,d)),{matrix:s,positionMap:d}}addHyperLink(e,n,r){const{matrix:s,positionMap:a}=this._ensureMap(e,n);return s.setValue(r.row,r.column,r),a.set(r.id,{row:r.row,column:r.column,link:r}),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:r,type:"add"}),!0}updateHyperLink(e,n,r,s,a=!1){const{matrix:d,positionMap:c}=this._ensureMap(e,n),l=c.get(r);if(!l)return!0;const p=d.getValue(l.row,l.column);return p&&(Object.assign(p,s),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:{display:p.display,payload:p.payload},id:r,type:"update",silent:a})),!0}updateHyperLinkRef(e,n,r,s,a=!1){const{matrix:d,positionMap:c}=this._ensureMap(e,n),l=c.get(r);if(!l)return!0;let p=d.getValue(l.row,l.column);return!p||p.id!==r?p=l.link:d.realDeleteValue(l.row,l.column),Object.assign(p,s),c.set(r,{...s,link:p}),d.setValue(s.row,s.column,p),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:s,id:r,type:"updateRef",silent:a}),!0}removeHyperLink(e,n,r){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(r);if(!d)return!1;a.delete(r);const c=s.getValue(d.row,d.column);return c&&c.id===r&&s.realDeleteValue(d.row,d.column),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:d.link,type:"remove"}),!0}getHyperLink(e,n,r){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(r);if(d)return s.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,r,s){const{matrix:a}=this._ensureMap(e,n);return a.getValue(r,s)}getHyperLinkByLocationSync(e,n,r,s){var u,m,f,h,_;const{matrix:a}=this._ensureMap(e,n),d=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET),c=(u=d==null?void 0:d.getSheetBySheetId(n))==null?void 0:u.getCellRaw(r,s),l=((_=(h=c==null?void 0:c.v)!=null?h:(f=(m=c==null?void 0:c.p)==null?void 0:m.body)==null?void 0:f.dataStream.slice(0,-2))!=null?_:"").toString(),p=a.getValue(r,s);if(p)return{...p,display:l}}getSubUnit(e,n){const{matrix:r}=this._ensureMap(e,n),s=[];return r.forValue((a,d,c)=>{c&&s.push(c)}),s}getUnit(e){const n=this._linkMap.get(e);return n?Array.from(n.keys()).map(r=>{const s=this.getSubUnit(e,r);return{unitId:e,subUnitId:r,links:s}}):[]}deleteUnit(e){const n=this.getUnit(e);this._linkMap.delete(e),this._linkPositionMap.delete(e),this._linkUpdate$.next({type:"unload",unitId:e,unitLinks:n})}getAll(){return Array.from(this._linkMap.keys()).map(n=>this.getUnit(n))}};exports.HyperLinkModel=Le([we(0,o.IUniverInstanceService)],exports.HyperLinkModel);var L=(i=>(i.SHEET="gid",i.RANGE="range",i.DEFINE_NAME="rangeid",i.INVALID="invalid",i.URL="url",i))(L||{});const Ee="sheets-hyper-link.config",oe={},w={type:o.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(i,t){if(!t)return!1;const e=i.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,link:s}=t;return e.addHyperLink(n,r,s)}},E={type:o.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(i,t){if(!t)return!1;const e=i.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,id:s}=t;return e.removeHyperLink(n,r,s)}},F={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(i,t){if(!t)return!1;const e=i.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,payload:s,id:a}=t;return e.updateHyperLink(n,r,a,s,!1)}},K={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(i,t){if(!t)return!1;const e=i.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,id:s,row:a,column:d,silent:c}=t;return e.updateHyperLinkRef(n,r,s,{row:a,column:d},c)}},B={type:o.CommandType.MUTATION,id:"sheets.mutation.update-rich-hyper-link",handler(i,t){var f,h,_;if(!t)return!1;const{unitId:e,subUnitId:n,row:r,col:s,id:a,url:d}=t,c=i.get(o.IUniverInstanceService),l=g.getSheetCommandTarget(c,{unitId:e,subUnitId:n});if(!l)return!1;const{worksheet:p}=l,u=p.getCellRaw(r,s),m=(_=(h=(f=u==null?void 0:u.p)==null?void 0:f.body)==null?void 0:h.customRanges)==null?void 0:_.find(y=>y.rangeType===o.CustomRangeType.HYPERLINK&&y.rangeId===a);return m&&(m.properties.url=d),!0}},le="SHEET_HYPER_LINK_PLUGIN",x="err";var ke=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Pe=(i,t,e,n)=>{for(var r=n>1?void 0:n?be(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&ke(t,e,r),r},A=(i,t)=>(e,n)=>t(e,n,i);let z=class extends o.Disposable{constructor(t,e,n,r){super();C(this,"_disposableMap",new Map);C(this,"_watchDisposableMap",new Map);C(this,"_rangeDisableMap",new Map);C(this,"_rangeWatcherMap",new Map);C(this,"_handlePositionChange",(t,e,n,r,s)=>{const a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};return r?{redos:[{id:K.id,params:{unitId:t,subUnitId:e,id:n.id,row:r.startRow,column:r.startColumn,silent:s}}],undos:[{id:K.id,params:{unitId:t,subUnitId:e,id:n.id,row:a.startRow,column:a.startColumn,silent:s}}]}:{redos:[{id:E.id,params:{unitId:t,subUnitId:e,id:n.id}}],undos:[{id:w.id,params:{unitId:t,subUnitId:e,link:n}}]}});this._refRangeService=t,this._hyperLinkModel=e,this._selectionManagerService=n,this._commandService=r,this._initData(),this._initRefRange()}_registerPosition(t,e,n){const r=n.id,s={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row},a=d=>{const c=g.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,d,{selectionManagerService:this._selectionManagerService}),l=Array.isArray(c)?c[0]:c;return l&&l.startColumn===s.startColumn&&l.startRow===s.startRow?{undos:[],redos:[]}:this._handlePositionChange(t,e,n,l,!1)};this._disposableMap.set(r,this._refRangeService.registerRefRange(s,a,t,e))}_watchPosition(t,e,n){const r=n.id,s={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._watchDisposableMap.set(r,this._refRangeService.watchRange(t,e,s,(a,d)=>{const{redos:c}=this._handlePositionChange(t,e,n,d,!0);o.sequenceExecuteAsync(c,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(t){const e=this._disposableMap.get(t);e==null||e.dispose(),this._disposableMap.delete(t)}_unwatchPosition(t){const e=this._watchDisposableMap.get(t);e==null||e.dispose(),this._watchDisposableMap.delete(t)}_registerRange(t,e,n,r=!1){var s,a,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(s=c.get("gid"))!=null?s:"",range:(a=c.get("range"))!=null?a:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const p=l.gid,u=U.deserializeRangeWithSheet(l.range).range;if(o.isValidRange(u)&&l.range!==x){const m=f=>{const h=g.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(u,f,{selectionManagerService:this._selectionManagerService});return h&&U.serializeRange(h)===U.serializeRange(u)?{redos:[],undos:[]}:{redos:[{id:F.id,params:{unitId:t,subUnitId:p,id:e,payload:{payload:`#gid=${p}&range=${h?U.serializeRange(h):"err"}`}}}],undos:[{id:F.id,params:{unitId:t,subUnitId:p,id:e,payload:{payload:n}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(u,m,t,p)),r||this._rangeWatcherMap.set(e,this._refRangeService.watchRange(t,p,u,(f,h)=>{this._hyperLinkModel.updateHyperLink(t,p,e,{payload:`#gid=${p}&range=${h?U.serializeRange(h):"err"}`},!0)},!0))}}}}_unregisterRange(t){const e=this._rangeDisableMap.get(t);e==null||e.dispose(),this._rangeDisableMap.delete(t)}_unwatchRange(t){const e=this._rangeWatcherMap.get(t);e==null||e.dispose(),this._rangeWatcherMap.delete(t)}_initData(){this._hyperLinkModel.getAll().forEach(e=>{e.forEach(n=>{const{unitId:r,subUnitId:s,links:a}=n;a.forEach(d=>{this._registerPosition(r,s,d),this._watchPosition(r,s,d),this._registerRange(r,d.id,d.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(t=>{switch(t.type){case"add":{this._registerPosition(t.unitId,t.subUnitId,t.payload),this._watchPosition(t.unitId,t.subUnitId,t.payload),this._registerRange(t.unitId,t.payload.id,t.payload.payload);break}case"remove":{this._unregisterPosition(t.payload.id),this._unwatchPosition(t.payload.id),this._unregisterRange(t.payload.id),this._unwatchRange(t.payload.id);break}case"updateRef":{const{unitId:e,subUnitId:n,id:r,silent:s}=t,a=this._hyperLinkModel.getHyperLink(e,n,r);if(!a)return;this._unregisterPosition(r),this._registerPosition(e,n,a),s||(this._unwatchPosition(r),this._watchPosition(e,n,a));break}case"unload":{const{unitLinks:e}=t;e.forEach(n=>{const{links:r}=n;r.forEach(s=>{this._unregisterPosition(s.id),this._unwatchPosition(s.id),this._unregisterRange(s.id),this._unwatchRange(s.id)})});break}case"update":{t.silent||this._unwatchRange(t.id),this._unregisterRange(t.id),this._registerRange(t.unitId,t.id,t.payload.payload,t.silent);break}}})),this.disposeWithMe(o.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};z=Pe([A(0,o.Inject(g.RefRangeService)),A(1,o.Inject(exports.HyperLinkModel)),A(2,o.Inject(g.SheetsSelectionsService)),A(3,o.ICommandService)],z);var Te=Object.defineProperty,He=Object.getOwnPropertyDescriptor,Ne=(i,t,e,n)=>{for(var r=n>1?void 0:n?He(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&Te(t,e,r),r},te=(i,t)=>(e,n)=>t(e,n,i);let G=class extends o.Disposable{constructor(i,t,e){super(),this._sheetInterceptorService=i,this._univerInstanceService=t,this._hyperLinkModel=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===g.RemoveSheetCommand.id){const e=i.params,n=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!n)return{redos:[],undos:[]};const r=n.getUnitId(),s=e.subUnitId||((t=n.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const a=this._hyperLinkModel.getSubUnit(r,s),d=a.map(l=>({id:E.id,params:{unitId:r,subUnitId:s,id:l.id}})),c=a.map(l=>({id:w.id,params:{unitId:r,subUnitId:s,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};G=Ne([te(0,o.Inject(g.SheetInterceptorService)),te(1,o.IUniverInstanceService),te(2,o.Inject(exports.HyperLinkModel))],G);var Oe=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Ve=(i,t,e,n)=>{for(var r=n>1?void 0:n?De(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&Oe(t,e,r),r},ne=(i,t)=>(e,n)=>t(e,n,i);let Y=class extends o.Disposable{constructor(t,e,n){super();C(this,"_refRangeMap",new Map);this._commandService=t,this._univerInstanceService=e,this._refRangeService=n,this._initWorkbookLoad(),this._initWorkbookUnload(),this._initSetRangesListener()}_enusreMap(t,e){let n=this._refRangeMap.get(t);n||(n=new Map,this._refRangeMap.set(t,n));let r=n.get(e);return r||(r=new o.ObjectMatrix,n.set(e,r)),r}_isLegalRangeUrl(t,e){var r,s,a;const n=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!n)return null;if(e&&e.startsWith("#")){const d=new URLSearchParams(e.slice(1)),c={gid:(r=d.get("gid"))!=null?r:"",range:(s=d.get("range"))!=null?s:"",rangeid:(a=d.get("rangeid"))!=null?a:""};if(c.range&&c.gid){const l=c.gid,p=n.getSheetBySheetId(l);if(!p)return null;const u=U.deserializeRangeWithSheet(c.range).range;if(o.isValidRange(u,p)&&c.range!==x)return{range:u,worksheet:p}}}return null}_registerRange(t,e,n,r,s){var d,c,l,p;const a=this._enusreMap(t,e);if((c=(d=s.body)==null?void 0:d.customRanges)!=null&&c.some(u=>{var m;return u.rangeType===o.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(t,(m=u.properties)==null?void 0:m.url)})){const u=new o.DisposableCollection;let m=!1;(p=(l=s.body)==null?void 0:l.customRanges)==null||p.forEach(f=>{var h;if(f.rangeType===o.CustomRangeType.HYPERLINK){const _=(h=f.properties)==null?void 0:h.url,y=this._isLegalRangeUrl(t,_);if(y){const{range:v,worksheet:M}=y;m=!0,u.add(this._refRangeService.registerRefRange(v,S=>{const I=g.handleDefaultRangeChangeWithEffectRefCommands(v,S);return I&&o.Rectangle.equals(I,v)?{preRedos:[],preUndos:[],redos:[],undos:[]}:{preRedos:[{id:B.id,params:{unitId:t,subUnitId:e,row:n,col:r,id:f.rangeId,url:`#gid=${e}&range=${I?U.serializeRange(I):x}`}}],undos:[{id:B.id,params:{unitId:t,subUnitId:e,row:n,col:r,id:f.rangeId,url:_}}],redos:[]}},M.getUnitId(),M.getSheetId()))}}}),m&&a.setValue(n,r,u)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(r=>{const s=r.getSheetId(),a=this._enusreMap(n,s);r.getCellMatrix().forValue((d,c,l)=>{const p=a.getValue(d,c);p&&p.dispose(),l&&l.p&&this._registerRange(n,s,d,c,l.p)})})};this._univerInstanceService.getAllUnitsForType(o.UniverInstanceType.UNIVER_SHEET).forEach(e=>{t(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===o.UniverInstanceType.UNIVER_SHEET&&t(e)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===o.UniverInstanceType.UNIVER_SHEET){const e=t,n=e.getUnitId();e.getSheets().forEach(r=>{const s=r.getSheetId();this._enusreMap(n,s).forValue((d,c,l)=>{l&&l.dispose()})}),this._refRangeMap.delete(n)}})}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===g.SetRangeValuesMutation.id){const e=t.params,{unitId:n,subUnitId:r,cellValue:s}=e,a=this._enusreMap(n,r);s&&new o.ObjectMatrix(s).forValue((d,c,l)=>{const p=a.getValue(d,c);p&&p.dispose(),l&&l.p&&this._registerRange(n,r,d,c,l.p)})}})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===B.id){const e=t.params,{unitId:n,subUnitId:r,row:s,col:a}=e,d=g.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:r}),l=this._enusreMap(n,r).getValue(s,a);if(l&&l.dispose(),d){const{worksheet:p}=d,u=p.getCellRaw(s,a);u&&u.p&&this._registerRange(n,r,s,a,u.p)}}}))}};Y=Ve([ne(0,o.ICommandService),ne(1,o.IUniverInstanceService),ne(2,o.Inject(g.RefRangeService))],Y);var xe=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,je=(i,t,e,n)=>{for(var r=n>1?void 0:n?$e(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&xe(t,e,r),r},W=(i,t)=>(e,n)=>t(e,n,i);let q=class extends o.Disposable{constructor(i,t,e,n){super(),this._sheetInterceptorService=i,this._hyperLinkModel=t,this._selectionManagerService=e,this._univerInstanceService=n,this._initCommandInterceptor(),this._initAfterEditor()}_initCommandInterceptor(){this._initSetRangeValuesCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(i.id===g.SetRangeValuesCommand.id){const t=i.params,{unitId:e,subUnitId:n}=t,r=[],s=[];return t.cellValue&&new o.ObjectMatrix(t.cellValue).forValue((a,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,d);c&&(r.push({id:E.id,params:{unitId:e,subUnitId:n,id:c.id}}),s.push({id:w.id,params:{unitId:e,subUnitId:n,link:c}}))}),{undos:s,redos:r}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(i.id===g.ClearSelectionContentCommand.id||i.id===g.ClearSelectionAllCommand.id||i.id===g.ClearSelectionFormatCommand.id){const t=[],e=[],n=this._selectionManagerService.getCurrentLastSelection(),r=g.getSheetCommandTarget(this._univerInstanceService);if(n&&r){const{unitId:s,subUnitId:a}=r;o.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(s,a,d,c);l&&(t.push({id:E.id,params:{unitId:s,subUnitId:a,id:l.id}}),e.push({id:w.id,params:{unitId:s,subUnitId:a,link:l}}))})}return{redos:t,undos:e}}return{redos:[],undos:[]}}}))}_initAfterEditor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(g.AFTER_CELL_EDIT,{handler:(i,t,e)=>{if(!i||i.p)return e(i);if(typeof i.v=="string"&&o.Tools.isLegalUrl(i.v)&&i.v[i.v.length-1]!==" "){const{unitId:n,subUnitId:r}=t,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),a=s==null?void 0:s.getSheetBySheetId(r);if(!a)return e(i);const d=a.getBlankCellDocumentModel(i);if(!d.documentModel)return e(i);const c=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:i.v.length,collapsed:!1},body:{dataStream:`${i.v}`,customRanges:[{startIndex:0,endIndex:i.v.length-1,rangeId:o.generateRandomId(),rangeType:o.CustomRangeType.HYPERLINK,properties:{url:i.v}}]},doc:d.documentModel});if(!c)return e(i);const l=d.documentModel.getBody();return o.TextX.apply(l,c.serialize()),e({...i,p:{id:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:l,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(i)}}))}};q=je([W(0,o.Inject(g.SheetInterceptorService)),W(1,o.Inject(exports.HyperLinkModel)),W(2,o.Inject(g.SheetsSelectionsService)),W(3,o.IUniverInstanceService)],q);var pe=(i=>(i[i.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",i[i.UNIVER_DOC=1]="UNIVER_DOC",i[i.UNIVER_SHEET=2]="UNIVER_SHEET",i[i.UNIVER_SLIDE=3]="UNIVER_SLIDE",i[i.UNIVER_PROJECT=4]="UNIVER_PROJECT",i[i.UNRECOGNIZED=-1]="UNRECOGNIZED",i))(pe||{}),Ae=Object.defineProperty,We=Object.getOwnPropertyDescriptor,Be=(i,t,e,n)=>{for(var r=n>1?void 0:n?We(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&Ae(t,e,r),r},de=(i,t)=>(e,n)=>t(e,n,i);let J=class extends o.Disposable{constructor(i,t){super(),this._resourceManagerService=i,this._hyperLinkModel=t,this._initSnapshot()}_initSnapshot(){const i=e=>{const n=this._hyperLinkModel.getUnit(e),r={};return n?(n.forEach(s=>{r[s.subUnitId]=s.links.map(({display:a,...d})=>d)}),JSON.stringify(r)):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:le,businesses:[pe.UNIVER_SHEET],toJson:e=>i(e),parseJson:e=>t(e),onUnLoad:e=>{this._hyperLinkModel.deleteUnit(e)},onLoad:async(e,n)=>{Object.keys(n).forEach(r=>{n[r].forEach(a=>{this._hyperLinkModel.addHyperLink(e,r,a)})})}}))}};J=Be([de(0,o.IResourceManagerService),de(1,o.Inject(exports.HyperLinkModel))],J);const ue={type:o.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(i,t){if(!t)return!1;const e=i.get(o.ICommandService),n=i.get(o.IUndoRedoService),r=i.get(o.IUniverInstanceService),s=i.get(exports.HyperLinkModel),a=i.get(g.SheetInterceptorService),d=g.getSheetCommandTarget(r,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:p,worksheet:u}=d,{link:m}=t,{payload:f,display:h,row:_,column:y,id:v}=m,M=u.getCell(_,y),S=u.getBlankCellDocumentModel(M),I=S.documentModel.getSnapshot(),R=o.Tools.deepClone(I.body);if(!R)return!1;let k;if(h?k=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:R.dataStream.length-2,collapsed:R.dataStream.length-2===0},body:{dataStream:`${h}`,customRanges:[{startIndex:0,endIndex:h.length-1,rangeType:o.CustomRangeType.HYPERLINK,rangeId:v,properties:{url:f}}]},doc:S.documentModel}):k=o.BuildTextUtils.customRange.add({body:R,ranges:[{startOffset:0,endOffset:R.dataStream.length-2,collapsed:!1}],rangeId:v,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:f,refId:v}}),!k)return!1;const D=o.TextX.apply(R,k.serialize()),b={p:{...I,body:D},t:o.CellValueType.STRING},T=await a.onWriteCell(p,u,_,y,b),H={unitId:c,subUnitId:l,cellValue:{[m.row]:{[m.column]:T}}},Q={id:g.SetRangeValuesMutation.id,params:H},$=g.SetRangeValuesUndoMutationFactory(i,H),ee={id:g.SetRangeValuesMutation.id,params:$},V=[Q],N=[ee],O=s.getHyperLinkByLocation(c,l,_,y);return O&&(V.push({id:E.id,params:{unitId:c,subUnitId:l,id:O.id}}),N.push({id:w.id,params:{unitId:c,subUnitId:l,link:O}})),await o.sequenceExecuteAsync(V,e)?(n.pushUndoRedo({redoMutations:V,undoMutations:N,unitID:c}),!0):!1}},he={id:"sheets.command.add-rich-hyper-link",type:o.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,r=i.get(o.ICommandService),s=o.generateRandomId(),{payload:a}=n,d=Z.addCustomRangeBySelectionFactory(i,{unitId:e,rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:a,refId:s}});return d?r.syncExecuteCommand(d.id,d.params):!1}},ge={type:o.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(i,t){var b,T;if(!t)return!1;const e=i.get(o.ICommandService),n=i.get(o.IUndoRedoService),r=i.get(o.IUniverInstanceService),s=i.get(exports.HyperLinkModel),a=g.getSheetCommandTarget(r,t);if(!a)return!1;const{row:d,column:c,id:l}=t,{unitId:p,subUnitId:u,worksheet:m}=a,f=m.getCell(d,c);if(!f)return!1;const h=m.getCellDocumentModelWithFormula(f);if(!(h!=null&&h.documentModel))return!1;const _=o.Tools.deepClone(h.documentModel.getSnapshot()),y=(T=(b=_.body)==null?void 0:b.customRanges)==null?void 0:T.find(H=>`${H.rangeId}`===l);if(!y)return!1;const v=o.BuildTextUtils.customRange.delete(i,{documentDataModel:h.documentModel,rangeId:y.rangeId});if(!v)return!1;const M=o.TextX.apply(_.body,v.serialize()),S=[],I=[],R={unitId:p,subUnitId:u,cellValue:{[d]:{[c]:{p:{..._,body:M},t:o.CellValueType.STRING}}}};S.push({id:g.SetRangeValuesMutation.id,params:R});const k=g.SetRangeValuesUndoMutationFactory(i,R);I.push({id:g.SetRangeValuesMutation.id,params:k});const D=s.getHyperLinkByLocation(p,u,d,c);return D&&(S.push({id:E.id,params:{unitId:p,subUnitId:u,id:l}}),I.push({id:w.id,params:{unitId:p,subUnitId:u,link:{...D}}})),o.sequenceExecute(S,e).result?(n.pushUndoRedo({redoMutations:S,undoMutations:I,unitID:p}),!0):!1}},me={type:o.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(i,t){var p,u;if(!t)return!1;const{id:e,documentId:n}=t,r=i.get(o.ICommandService),a=i.get(o.IUniverInstanceService).getUnit(n,o.UniverInstanceType.UNIVER_DOC),d=(u=(p=a==null?void 0:a.getBody())==null?void 0:p.customRanges)==null?void 0:u.find(m=>m.rangeId===e);let c=null;d&&d.endIndex===a.getBody().dataStream.length-3&&(c={dataStream:" "});const l=Z.deleteCustomRangeFactory(i,{unitId:n,rangeId:e,insert:c});return l?r.syncExecuteCommand(l.id,l.params):!1}},fe={type:o.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(i,t){var ie,se,ae;if(!t)return!1;const e=i.get(o.ICommandService),n=i.get(o.IUndoRedoService),r=i.get(o.IUniverInstanceService),s=i.get(exports.HyperLinkModel),a=i.get(g.SheetInterceptorService),d=g.getSheetCommandTarget(r,{unitId:t.unitId,subUnitId:t.subUnitId});if(!d)return!1;const{payload:c,row:l,column:p,id:u}=t,{workbook:m,worksheet:f,unitId:h,subUnitId:_}=d,{payload:y,display:v=""}=c,M=f.getCell(l,p);if(!M)return!1;const S=f.getCellDocumentModelWithFormula(M);if(!(S!=null&&S.documentModel))return!1;const I=S.documentModel.getSnapshot(),R=(se=(ie=I.body)==null?void 0:ie.customRanges)==null?void 0:se.find(Se=>`${Se.rangeId}`===u);if(!R)return!1;const k=o.generateRandomId(),P=(ae=o.getBodySlice(S.documentModel.getBody(),R.startIndex,R.endIndex+1).textRuns)==null?void 0:ae[0];P&&(P.ed=v.length+1);const b=Z.replaceSelectionFactory(i,{unitId:h,body:{dataStream:`${v}`,customRanges:[{rangeId:k,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:v.length-1,properties:{url:y}}],textRuns:P?[P]:void 0},selection:{startOffset:R.startIndex,endOffset:R.endIndex+1,collapsed:!1},doc:S.documentModel});if(!b)return!1;const T=o.TextX.apply(o.Tools.deepClone(I.body),b.textX.serialize()),H={p:{...I,body:T},t:o.CellValueType.STRING},Q=await a.onWriteCell(m,f,l,p,H),$={id:g.SetRangeValuesMutation.id,params:{unitId:h,subUnitId:_,cellValue:{[l]:{[p]:Q}}}},ee=g.SetRangeValuesUndoMutationFactory(i,$.params),V={id:g.SetRangeValuesMutation.id,params:ee},N=[$],O=[V],j=s.getHyperLinkByLocation(h,_,l,p);return j&&(N.push({id:E.id,params:{unitId:h,subUnitId:_,id:j.id}}),O.push({id:w.id,params:{unitId:h,subUnitId:_,link:j}})),await o.sequenceExecuteAsync(N,e)?(n.pushUndoRedo({redoMutations:N,undoMutations:O,unitID:h}),!0):!1}},_e={type:o.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(i,t)=>{var h,_,y,v;if(!t)return!1;const{documentId:e,payload:n,id:r}=t,s=i.get(o.IUniverInstanceService),a=i.get(o.ICommandService),d=s.getUnit(e,o.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(_=(h=d.getBody())==null?void 0:h.customRanges)==null?void 0:_.find(M=>M.rangeId===r);if(!c)return!1;const l=(y=t.payload.display)!=null?y:"",p=o.generateRandomId(),m=(v=o.getBodySlice(d.getBody(),c.startIndex,c.endIndex+1).textRuns)==null?void 0:v[0];m&&(m.ed=l.length+1);const f=Z.replaceSelectionFactory(i,{unitId:e,body:{dataStream:`${l}`,customRanges:[{rangeId:p,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:l.length-1,properties:{url:n.payload}}],textRuns:m?[m]:void 0},selection:{startOffset:c.startIndex,endOffset:c.endIndex+1,collapsed:!1},doc:d});return f?a.syncExecuteCommand(f.id,f.params):!1}};var Fe=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,ze=(i,t,e,n)=>{for(var r=n>1?void 0:n?Ke(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&Fe(t,e,r),r},Ge=(i,t)=>(e,n)=>t(e,n,i);let X=class extends o.Disposable{constructor(i){super(),this._commandService=i,this._registerCommands()}_registerCommands(){[ue,fe,ge,_e,me,he,w,F,E,K,B].forEach(i=>{this._commandService.registerCommand(i)})}};X=ze([Ge(0,o.ICommandService)],X);var Ye=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,Je=(i,t,e,n)=>{for(var r=n>1?void 0:n?qe(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&Ye(t,e,r),r},re=(i,t)=>(e,n)=>t(e,n,i);exports.SheetsHyperLinkParserService=class{constructor(t,e,n){this._univerInstanceService=t,this._localeService=e,this._definedNamesService=n}buildHyperLink(t,e,n){return`#${L.SHEET}=${e}${n?`&${typeof n=="string"?L.DEFINE_NAME:L.RANGE}=${typeof n=="string"?n:U.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,r,s;if(t.startsWith("#")){const a=new URLSearchParams(t.slice(1)),d={gid:(e=a.get("gid"))!=null?e:"",range:(n=a.get("range"))!=null?n:"",rangeid:(r=a.get("rangeid"))!=null?r:"",unitid:(s=a.get("unitid"))!=null?s:""},c=this._getURLName(d);return{type:c.type,name:c.name,url:t,searchObj:d}}else return{type:L.URL,name:t,url:t,searchObj:null}}_getURLName(t){var p;const{gid:e,range:n,rangeid:r,unitid:s}=t,a=s?this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),d={type:L.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!a)return d;const c=e?a.getSheetBySheetId(e):a.getActiveSheet(),l=(p=c==null?void 0:c.getName())!=null?p:"";if(n){if(!c)return d;const u=U.deserializeRangeWithSheet(n).range;return o.isValidRange(u,c)&&n!==x?{type:L.RANGE,name:U.serializeRangeWithSheet(l,u)}:d}if(r){const u=this._definedNamesService.getValueById(a.getUnitId(),r);return u?{type:L.DEFINE_NAME,name:u.formulaOrRefString}:d}if(e){const u=a.getSheetBySheetId(e);return u?{type:L.SHEET,name:u.getName()}:d}return d}};exports.SheetsHyperLinkParserService=Je([re(0,o.IUniverInstanceService),re(1,o.Inject(o.LocaleService)),re(2,U.IDefinedNamesService)],exports.SheetsHyperLinkParserService);var ye=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,Ze=(i,t,e)=>t in i?ye(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Qe=(i,t,e,n)=>{for(var r=n>1?void 0:n?Xe(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&ye(t,e,r),r},ce=(i,t)=>(e,n)=>t(e,n,i),ve=(i,t,e)=>Ze(i,typeof t!="symbol"?t+"":t,e);exports.UniverSheetsHyperLinkPlugin=class extends o.Plugin{constructor(t=oe,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...r}=o.merge({},oe,this._config);this._configService.setConfig(Ee,r)}onStarting(){o.registerDependencies(this._injector,[[exports.HyperLinkModel],[exports.SheetsHyperLinkParserService],[J],[X],[z],[q],[G],[Y]]),o.touchDependencies(this._injector,[[z],[J],[X],[q],[G],[Y]])}};ve(exports.UniverSheetsHyperLinkPlugin,"pluginName",le);ve(exports.UniverSheetsHyperLinkPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsHyperLinkPlugin=Qe([o.DependentOn(g.UniverSheetsPlugin),ce(1,o.Inject(o.Injector)),ce(2,o.IConfigService)],exports.UniverSheetsHyperLinkPlugin);exports.AddHyperLinkCommand=ue;exports.AddHyperLinkMutation=w;exports.AddRichHyperLinkCommand=he;exports.CancelHyperLinkCommand=ge;exports.CancelRichHyperLinkCommand=me;exports.ERROR_RANGE=x;exports.RemoveHyperLinkMutation=E;exports.SheetHyperLinkType=L;exports.UpdateHyperLinkCommand=fe;exports.UpdateHyperLinkMutation=F;exports.UpdateHyperLinkRefMutation=K;exports.UpdateRichHyperLinkCommand=_e;
1
+ "use strict";var ve=Object.defineProperty;var Re=(i,t,e)=>t in i?ve(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var C=(i,t,e)=>Re(i,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),Me=require("rxjs"),g=require("@univerjs/sheets"),U=require("@univerjs/engine-formula"),Z=require("@univerjs/docs");var Ce=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Le=(i,t,e,n)=>{for(var r=n>1?void 0:n?Ue(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&Ce(t,e,r),r},we=(i,t)=>(e,n)=>t(e,n,i);exports.HyperLinkModel=class extends o.Disposable{constructor(e){super();C(this,"_linkUpdate$",new Me.Subject);C(this,"linkUpdate$",this._linkUpdate$.asObservable());C(this,"_linkMap",new Map);C(this,"_linkPositionMap",new Map);this._univerInstanceService=e,this.disposeWithMe({dispose:()=>{this._linkUpdate$.complete()}})}_ensureMap(e,n){let r=this._linkMap.get(e);r||(r=new Map,this._linkMap.set(e,r));let s=r.get(n);s||(s=new o.ObjectMatrix,r.set(n,s));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let d=a.get(n);return d||(d=new Map,a.set(n,d)),{matrix:s,positionMap:d}}addHyperLink(e,n,r){const{matrix:s,positionMap:a}=this._ensureMap(e,n);return s.setValue(r.row,r.column,r),a.set(r.id,{row:r.row,column:r.column,link:r}),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:r,type:"add"}),!0}updateHyperLink(e,n,r,s,a=!1){const{matrix:d,positionMap:c}=this._ensureMap(e,n),l=c.get(r);if(!l)return!0;const u=d.getValue(l.row,l.column);return u&&(Object.assign(u,s),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:{display:u.display,payload:u.payload},id:r,type:"update",silent:a})),!0}updateHyperLinkRef(e,n,r,s,a=!1){const{matrix:d,positionMap:c}=this._ensureMap(e,n),l=c.get(r);if(!l)return!0;let u=d.getValue(l.row,l.column);return!u||u.id!==r?u=l.link:d.realDeleteValue(l.row,l.column),Object.assign(u,s),c.set(r,{...s,link:u}),d.setValue(s.row,s.column,u),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:s,id:r,type:"updateRef",silent:a}),!0}removeHyperLink(e,n,r){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(r);if(!d)return!1;a.delete(r);const c=s.getValue(d.row,d.column);return c&&c.id===r&&s.realDeleteValue(d.row,d.column),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:d.link,type:"remove"}),!0}getHyperLink(e,n,r){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(r);if(d)return s.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,r,s){const{matrix:a}=this._ensureMap(e,n);return a.getValue(r,s)}getHyperLinkByLocationSync(e,n,r,s){var p,m,f,h,_;const{matrix:a}=this._ensureMap(e,n),d=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET),c=(p=d==null?void 0:d.getSheetBySheetId(n))==null?void 0:p.getCellRaw(r,s),l=((_=(h=c==null?void 0:c.v)!=null?h:(f=(m=c==null?void 0:c.p)==null?void 0:m.body)==null?void 0:f.dataStream.slice(0,-2))!=null?_:"").toString(),u=a.getValue(r,s);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:r}=this._ensureMap(e,n),s=[];return r.forValue((a,d,c)=>{c&&s.push(c)}),s}getUnit(e){const n=this._linkMap.get(e);return n?Array.from(n.keys()).map(r=>{const s=this.getSubUnit(e,r);return{unitId:e,subUnitId:r,links:s}}):[]}deleteUnit(e){const n=this.getUnit(e);this._linkMap.delete(e),this._linkPositionMap.delete(e),this._linkUpdate$.next({type:"unload",unitId:e,unitLinks:n})}getAll(){return Array.from(this._linkMap.keys()).map(n=>this.getUnit(n))}};exports.HyperLinkModel=Le([we(0,o.IUniverInstanceService)],exports.HyperLinkModel);var L=(i=>(i.SHEET="gid",i.RANGE="range",i.DEFINE_NAME="rangeid",i.INVALID="invalid",i.URL="url",i))(L||{});const Ee="sheets-hyper-link.config",oe={},w={type:o.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(i,t){if(!t)return!1;const e=i.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,link:s}=t;return e.addHyperLink(n,r,s)}},E={type:o.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(i,t){if(!t)return!1;const e=i.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,id:s}=t;return e.removeHyperLink(n,r,s)}},F={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(i,t){if(!t)return!1;const e=i.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,payload:s,id:a}=t;return e.updateHyperLink(n,r,a,s,!1)}},K={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(i,t){if(!t)return!1;const e=i.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,id:s,row:a,column:d,silent:c}=t;return e.updateHyperLinkRef(n,r,s,{row:a,column:d},c)}},B={type:o.CommandType.MUTATION,id:"sheets.mutation.update-rich-hyper-link",handler(i,t){var f,h,_;if(!t)return!1;const{unitId:e,subUnitId:n,row:r,col:s,id:a,url:d}=t,c=i.get(o.IUniverInstanceService),l=g.getSheetCommandTarget(c,{unitId:e,subUnitId:n});if(!l)return!1;const{worksheet:u}=l,p=u.getCellRaw(r,s),m=(_=(h=(f=p==null?void 0:p.p)==null?void 0:f.body)==null?void 0:h.customRanges)==null?void 0:_.find(y=>y.rangeType===o.CustomRangeType.HYPERLINK&&y.rangeId===a);return m&&(m.properties.url=d),!0}},le="SHEET_HYPER_LINK_PLUGIN",x="err";var ke=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Pe=(i,t,e,n)=>{for(var r=n>1?void 0:n?be(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&ke(t,e,r),r},A=(i,t)=>(e,n)=>t(e,n,i);let z=class extends o.Disposable{constructor(t,e,n,r){super();C(this,"_disposableMap",new Map);C(this,"_watchDisposableMap",new Map);C(this,"_rangeDisableMap",new Map);C(this,"_rangeWatcherMap",new Map);C(this,"_handlePositionChange",(t,e,n,r,s)=>{const a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};return r?{redos:[{id:K.id,params:{unitId:t,subUnitId:e,id:n.id,row:r.startRow,column:r.startColumn,silent:s}}],undos:[{id:K.id,params:{unitId:t,subUnitId:e,id:n.id,row:a.startRow,column:a.startColumn,silent:s}}]}:{redos:[{id:E.id,params:{unitId:t,subUnitId:e,id:n.id}}],undos:[{id:w.id,params:{unitId:t,subUnitId:e,link:n}}]}});this._refRangeService=t,this._hyperLinkModel=e,this._selectionManagerService=n,this._commandService=r,this._initData(),this._initRefRange()}_registerPosition(t,e,n){const r=n.id,s={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row},a=d=>{const c=g.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,d,{selectionManagerService:this._selectionManagerService}),l=Array.isArray(c)?c[0]:c;return l&&l.startColumn===s.startColumn&&l.startRow===s.startRow?{undos:[],redos:[]}:this._handlePositionChange(t,e,n,l,!1)};this._disposableMap.set(r,this._refRangeService.registerRefRange(s,a,t,e))}_watchPosition(t,e,n){const r=n.id,s={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._watchDisposableMap.set(r,this._refRangeService.watchRange(t,e,s,(a,d)=>{const{redos:c}=this._handlePositionChange(t,e,n,d,!0);o.sequenceExecuteAsync(c,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(t){const e=this._disposableMap.get(t);e==null||e.dispose(),this._disposableMap.delete(t)}_unwatchPosition(t){const e=this._watchDisposableMap.get(t);e==null||e.dispose(),this._watchDisposableMap.delete(t)}_registerRange(t,e,n,r=!1){var s,a,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(s=c.get("gid"))!=null?s:"",range:(a=c.get("range"))!=null?a:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,p=U.deserializeRangeWithSheet(l.range).range;if(o.isValidRange(p)&&l.range!==x){const m=f=>{const h=g.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(p,f,{selectionManagerService:this._selectionManagerService});return h&&U.serializeRange(h)===U.serializeRange(p)?{redos:[],undos:[]}:{redos:[{id:F.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${h?U.serializeRange(h):"err"}`}}}],undos:[{id:F.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:n}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(p,m,t,u)),r||this._rangeWatcherMap.set(e,this._refRangeService.watchRange(t,u,p,(f,h)=>{this._hyperLinkModel.updateHyperLink(t,u,e,{payload:`#gid=${u}&range=${h?U.serializeRange(h):"err"}`},!0)},!0))}}}}_unregisterRange(t){const e=this._rangeDisableMap.get(t);e==null||e.dispose(),this._rangeDisableMap.delete(t)}_unwatchRange(t){const e=this._rangeWatcherMap.get(t);e==null||e.dispose(),this._rangeWatcherMap.delete(t)}_initData(){this._hyperLinkModel.getAll().forEach(e=>{e.forEach(n=>{const{unitId:r,subUnitId:s,links:a}=n;a.forEach(d=>{this._registerPosition(r,s,d),this._watchPosition(r,s,d),this._registerRange(r,d.id,d.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(t=>{switch(t.type){case"add":{this._registerPosition(t.unitId,t.subUnitId,t.payload),this._watchPosition(t.unitId,t.subUnitId,t.payload),this._registerRange(t.unitId,t.payload.id,t.payload.payload);break}case"remove":{this._unregisterPosition(t.payload.id),this._unwatchPosition(t.payload.id),this._unregisterRange(t.payload.id),this._unwatchRange(t.payload.id);break}case"updateRef":{const{unitId:e,subUnitId:n,id:r,silent:s}=t,a=this._hyperLinkModel.getHyperLink(e,n,r);if(!a)return;this._unregisterPosition(r),this._registerPosition(e,n,a),s||(this._unwatchPosition(r),this._watchPosition(e,n,a));break}case"unload":{const{unitLinks:e}=t;e.forEach(n=>{const{links:r}=n;r.forEach(s=>{this._unregisterPosition(s.id),this._unwatchPosition(s.id),this._unregisterRange(s.id),this._unwatchRange(s.id)})});break}case"update":{t.silent||this._unwatchRange(t.id),this._unregisterRange(t.id),this._registerRange(t.unitId,t.id,t.payload.payload,t.silent);break}}})),this.disposeWithMe(o.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};z=Pe([A(0,o.Inject(g.RefRangeService)),A(1,o.Inject(exports.HyperLinkModel)),A(2,o.Inject(g.SheetsSelectionsService)),A(3,o.ICommandService)],z);var Te=Object.defineProperty,He=Object.getOwnPropertyDescriptor,Ne=(i,t,e,n)=>{for(var r=n>1?void 0:n?He(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&Te(t,e,r),r},te=(i,t)=>(e,n)=>t(e,n,i);let G=class extends o.Disposable{constructor(i,t,e){super(),this._sheetInterceptorService=i,this._univerInstanceService=t,this._hyperLinkModel=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===g.RemoveSheetCommand.id){const e=i.params,n=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!n)return{redos:[],undos:[]};const r=n.getUnitId(),s=e.subUnitId||((t=n.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const a=this._hyperLinkModel.getSubUnit(r,s),d=a.map(l=>({id:E.id,params:{unitId:r,subUnitId:s,id:l.id}})),c=a.map(l=>({id:w.id,params:{unitId:r,subUnitId:s,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};G=Ne([te(0,o.Inject(g.SheetInterceptorService)),te(1,o.IUniverInstanceService),te(2,o.Inject(exports.HyperLinkModel))],G);var Oe=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Ve=(i,t,e,n)=>{for(var r=n>1?void 0:n?De(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&Oe(t,e,r),r},ne=(i,t)=>(e,n)=>t(e,n,i);let Y=class extends o.Disposable{constructor(t,e,n){super();C(this,"_refRangeMap",new Map);this._commandService=t,this._univerInstanceService=e,this._refRangeService=n,this._initWorkbookLoad(),this._initWorkbookUnload(),this._initSetRangesListener()}_enusreMap(t,e){let n=this._refRangeMap.get(t);n||(n=new Map,this._refRangeMap.set(t,n));let r=n.get(e);return r||(r=new o.ObjectMatrix,n.set(e,r)),r}_isLegalRangeUrl(t,e){var r,s,a;const n=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!n)return null;if(e&&e.startsWith("#")){const d=new URLSearchParams(e.slice(1)),c={gid:(r=d.get("gid"))!=null?r:"",range:(s=d.get("range"))!=null?s:"",rangeid:(a=d.get("rangeid"))!=null?a:""};if(c.range&&c.gid){const l=c.gid,u=n.getSheetBySheetId(l);if(!u)return null;const p=U.deserializeRangeWithSheet(c.range).range;if(o.isValidRange(p,u)&&c.range!==x)return{range:p,worksheet:u}}}return null}_registerRange(t,e,n,r,s){var d,c,l,u;const a=this._enusreMap(t,e);if((c=(d=s.body)==null?void 0:d.customRanges)!=null&&c.some(p=>{var m;return p.rangeType===o.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(t,(m=p.properties)==null?void 0:m.url)})){const p=new o.DisposableCollection;let m=!1;(u=(l=s.body)==null?void 0:l.customRanges)==null||u.forEach(f=>{var h;if(f.rangeType===o.CustomRangeType.HYPERLINK){const _=(h=f.properties)==null?void 0:h.url,y=this._isLegalRangeUrl(t,_);if(y){const{range:S,worksheet:M}=y;m=!0,p.add(this._refRangeService.registerRefRange(S,I=>{const v=g.handleDefaultRangeChangeWithEffectRefCommands(S,I);return v&&o.Rectangle.equals(v,S)?{preRedos:[],preUndos:[],redos:[],undos:[]}:{preRedos:[{id:B.id,params:{unitId:t,subUnitId:e,row:n,col:r,id:f.rangeId,url:`#gid=${e}&range=${v?U.serializeRange(v):x}`}}],undos:[{id:B.id,params:{unitId:t,subUnitId:e,row:n,col:r,id:f.rangeId,url:_}}],redos:[]}},M.getUnitId(),M.getSheetId()))}}}),m&&a.setValue(n,r,p)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(r=>{const s=r.getSheetId(),a=this._enusreMap(n,s);r.getCellMatrix().forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,s,d,c,l.p)})})};this._univerInstanceService.getAllUnitsForType(o.UniverInstanceType.UNIVER_SHEET).forEach(e=>{t(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===o.UniverInstanceType.UNIVER_SHEET&&t(e)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===o.UniverInstanceType.UNIVER_SHEET){const e=t,n=e.getUnitId();e.getSheets().forEach(r=>{const s=r.getSheetId();this._enusreMap(n,s).forValue((d,c,l)=>{l&&l.dispose()})}),this._refRangeMap.delete(n)}})}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===g.SetRangeValuesMutation.id){const e=t.params,{unitId:n,subUnitId:r,cellValue:s}=e,a=this._enusreMap(n,r);s&&new o.ObjectMatrix(s).forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,r,d,c,l.p)})}})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===B.id){const e=t.params,{unitId:n,subUnitId:r,row:s,col:a}=e,d=g.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:r}),l=this._enusreMap(n,r).getValue(s,a);if(l&&l.dispose(),d){const{worksheet:u}=d,p=u.getCellRaw(s,a);p&&p.p&&this._registerRange(n,r,s,a,p.p)}}}))}};Y=Ve([ne(0,o.ICommandService),ne(1,o.IUniverInstanceService),ne(2,o.Inject(g.RefRangeService))],Y);var xe=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,je=(i,t,e,n)=>{for(var r=n>1?void 0:n?$e(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&xe(t,e,r),r},W=(i,t)=>(e,n)=>t(e,n,i);let q=class extends o.Disposable{constructor(i,t,e,n){super(),this._sheetInterceptorService=i,this._hyperLinkModel=t,this._selectionManagerService=e,this._univerInstanceService=n,this._initCommandInterceptor(),this._initAfterEditor()}_initCommandInterceptor(){this._initSetRangeValuesCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(i.id===g.SetRangeValuesCommand.id){const t=i.params,{unitId:e,subUnitId:n}=t,r=[],s=[];return t.cellValue&&new o.ObjectMatrix(t.cellValue).forValue((a,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,d);c&&(r.push({id:E.id,params:{unitId:e,subUnitId:n,id:c.id}}),s.push({id:w.id,params:{unitId:e,subUnitId:n,link:c}}))}),{undos:s,redos:r}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(i.id===g.ClearSelectionContentCommand.id||i.id===g.ClearSelectionAllCommand.id||i.id===g.ClearSelectionFormatCommand.id){const t=[],e=[],n=this._selectionManagerService.getCurrentLastSelection(),r=g.getSheetCommandTarget(this._univerInstanceService);if(n&&r){const{unitId:s,subUnitId:a}=r;o.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(s,a,d,c);l&&(t.push({id:E.id,params:{unitId:s,subUnitId:a,id:l.id}}),e.push({id:w.id,params:{unitId:s,subUnitId:a,link:l}}))})}return{redos:t,undos:e}}return{redos:[],undos:[]}}}))}_initAfterEditor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(g.AFTER_CELL_EDIT,{handler:(i,t,e)=>{if(!i||i.p)return e(i);if(typeof i.v=="string"&&o.Tools.isLegalUrl(i.v)&&i.v[i.v.length-1]!==" "){const{unitId:n,subUnitId:r}=t,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),a=s==null?void 0:s.getSheetBySheetId(r);if(!a)return e(i);const d=a.getBlankCellDocumentModel(i);if(!d.documentModel)return e(i);const c=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:i.v.length,collapsed:!1},body:{dataStream:`${i.v}`,customRanges:[{startIndex:0,endIndex:i.v.length-1,rangeId:o.generateRandomId(),rangeType:o.CustomRangeType.HYPERLINK,properties:{url:i.v}}]},doc:d.documentModel});if(!c)return e(i);const l=d.documentModel.getBody();return o.TextX.apply(l,c.serialize()),e({...i,p:{id:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:l,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(i)}}))}};q=je([W(0,o.Inject(g.SheetInterceptorService)),W(1,o.Inject(exports.HyperLinkModel)),W(2,o.Inject(g.SheetsSelectionsService)),W(3,o.IUniverInstanceService)],q);var ue=(i=>(i[i.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",i[i.UNIVER_DOC=1]="UNIVER_DOC",i[i.UNIVER_SHEET=2]="UNIVER_SHEET",i[i.UNIVER_SLIDE=3]="UNIVER_SLIDE",i[i.UNIVER_PROJECT=4]="UNIVER_PROJECT",i[i.UNRECOGNIZED=-1]="UNRECOGNIZED",i))(ue||{}),Ae=Object.defineProperty,We=Object.getOwnPropertyDescriptor,Be=(i,t,e,n)=>{for(var r=n>1?void 0:n?We(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&Ae(t,e,r),r},de=(i,t)=>(e,n)=>t(e,n,i);let J=class extends o.Disposable{constructor(i,t){super(),this._resourceManagerService=i,this._hyperLinkModel=t,this._initSnapshot()}_initSnapshot(){const i=e=>{const n=this._hyperLinkModel.getUnit(e),r={};return n?(n.forEach(s=>{r[s.subUnitId]=s.links.map(({display:a,...d})=>d)}),JSON.stringify(r)):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:le,businesses:[ue.UNIVER_SHEET],toJson:e=>i(e),parseJson:e=>t(e),onUnLoad:e=>{this._hyperLinkModel.deleteUnit(e)},onLoad:async(e,n)=>{Object.keys(n).forEach(r=>{n[r].forEach(a=>{this._hyperLinkModel.addHyperLink(e,r,a)})})}}))}};J=Be([de(0,o.IResourceManagerService),de(1,o.Inject(exports.HyperLinkModel))],J);const pe={type:o.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(i,t){if(!t)return!1;const e=i.get(o.ICommandService),n=i.get(o.IUndoRedoService),r=i.get(o.IUniverInstanceService),s=i.get(exports.HyperLinkModel),a=i.get(g.SheetInterceptorService),d=g.getSheetCommandTarget(r,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:p}=d,{link:m}=t,{payload:f,display:h,row:_,column:y,id:S}=m,M=p.getCell(_,y),I=p.getBlankCellDocumentModel(M),v=I.documentModel.getSnapshot(),R=o.Tools.deepClone(v.body);if(!R)return!1;let k;if(h?k=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:R.dataStream.length-2,collapsed:R.dataStream.length-2===0},body:{dataStream:`${h}`,customRanges:[{startIndex:0,endIndex:h.length-1,rangeType:o.CustomRangeType.HYPERLINK,rangeId:S,properties:{url:f}}]},doc:I.documentModel}):k=o.BuildTextUtils.customRange.add({body:R,ranges:[{startOffset:0,endOffset:R.dataStream.length-2,collapsed:!1}],rangeId:S,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:f,refId:S}}),!k)return!1;const D=o.TextX.apply(R,k.serialize()),b={p:{...v,body:D},t:o.CellValueType.STRING},T=await a.onWriteCell(u,p,_,y,b),H={unitId:c,subUnitId:l,cellValue:{[m.row]:{[m.column]:T}}},Q={id:g.SetRangeValuesMutation.id,params:H},$=g.SetRangeValuesUndoMutationFactory(i,H),ee={id:g.SetRangeValuesMutation.id,params:$},V=[Q],N=[ee],O=s.getHyperLinkByLocation(c,l,_,y);return O&&(V.push({id:E.id,params:{unitId:c,subUnitId:l,id:O.id}}),N.push({id:w.id,params:{unitId:c,subUnitId:l,link:O}})),await o.sequenceExecuteAsync(V,e)?(n.pushUndoRedo({redoMutations:V,undoMutations:N,unitID:c}),!0):!1}},he={id:"sheets.command.add-rich-hyper-link",type:o.CommandType.COMMAND,handler:async(i,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,r=i.get(o.ICommandService),s=o.generateRandomId(),{payload:a}=n,d=Z.addCustomRangeBySelectionFactory(i,{unitId:e,rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:a,refId:s}});return d?r.syncExecuteCommand(d.id,d.params):!1}},ge={type:o.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(i,t){var b,T;if(!t)return!1;const e=i.get(o.ICommandService),n=i.get(o.IUndoRedoService),r=i.get(o.IUniverInstanceService),s=i.get(exports.HyperLinkModel),a=g.getSheetCommandTarget(r,t);if(!a)return!1;const{row:d,column:c,id:l}=t,{unitId:u,subUnitId:p,worksheet:m}=a,f=m.getCell(d,c);if(!f)return!1;const h=m.getCellDocumentModelWithFormula(f);if(!(h!=null&&h.documentModel))return!1;const _=o.Tools.deepClone(h.documentModel.getSnapshot()),y=(T=(b=_.body)==null?void 0:b.customRanges)==null?void 0:T.find(H=>`${H.rangeId}`===l);if(!y)return!1;const S=o.BuildTextUtils.customRange.delete({documentDataModel:h.documentModel,rangeId:y.rangeId});if(!S)return!1;const M=o.TextX.apply(_.body,S.serialize()),I=[],v=[],R={unitId:u,subUnitId:p,cellValue:{[d]:{[c]:{p:{..._,body:M},t:o.CellValueType.STRING}}}};I.push({id:g.SetRangeValuesMutation.id,params:R});const k=g.SetRangeValuesUndoMutationFactory(i,R);v.push({id:g.SetRangeValuesMutation.id,params:k});const D=s.getHyperLinkByLocation(u,p,d,c);return D&&(I.push({id:E.id,params:{unitId:u,subUnitId:p,id:l}}),v.push({id:w.id,params:{unitId:u,subUnitId:p,link:{...D}}})),o.sequenceExecute(I,e).result?(n.pushUndoRedo({redoMutations:I,undoMutations:v,unitID:u}),!0):!1}},me={type:o.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(i,t){var u,p;if(!t)return!1;const{id:e,documentId:n}=t,r=i.get(o.ICommandService),a=i.get(o.IUniverInstanceService).getUnit(n,o.UniverInstanceType.UNIVER_DOC),d=(p=(u=a==null?void 0:a.getBody())==null?void 0:u.customRanges)==null?void 0:p.find(m=>m.rangeId===e);let c=null;d&&d.endIndex===a.getBody().dataStream.length-3&&(c={dataStream:" "});const l=Z.deleteCustomRangeFactory(i,{unitId:n,rangeId:e,insert:c});return l?r.syncExecuteCommand(l.id,l.params):!1}},fe={type:o.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(i,t){var ie,se,ae;if(!t)return!1;const e=i.get(o.ICommandService),n=i.get(o.IUndoRedoService),r=i.get(o.IUniverInstanceService),s=i.get(exports.HyperLinkModel),a=i.get(g.SheetInterceptorService),d=g.getSheetCommandTarget(r,{unitId:t.unitId,subUnitId:t.subUnitId});if(!d)return!1;const{payload:c,row:l,column:u,id:p}=t,{workbook:m,worksheet:f,unitId:h,subUnitId:_}=d,{payload:y,display:S=""}=c,M=f.getCell(l,u);if(!M)return!1;const I=f.getCellDocumentModelWithFormula(M);if(!(I!=null&&I.documentModel))return!1;const v=I.documentModel.getSnapshot(),R=(se=(ie=v.body)==null?void 0:ie.customRanges)==null?void 0:se.find(Ie=>`${Ie.rangeId}`===p);if(!R)return!1;const k=o.generateRandomId(),P=(ae=o.getBodySlice(I.documentModel.getBody(),R.startIndex,R.endIndex+1).textRuns)==null?void 0:ae[0];P&&(P.ed=S.length+1);const b=Z.replaceSelectionFactory(i,{unitId:h,body:{dataStream:`${S}`,customRanges:[{rangeId:k,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:S.length-1,properties:{url:y}}],textRuns:P?[P]:void 0},selection:{startOffset:R.startIndex,endOffset:R.endIndex+1,collapsed:!1},doc:I.documentModel});if(!b)return!1;const T=o.TextX.apply(o.Tools.deepClone(v.body),b.textX.serialize()),H={p:{...v,body:T},t:o.CellValueType.STRING},Q=await a.onWriteCell(m,f,l,u,H),$={id:g.SetRangeValuesMutation.id,params:{unitId:h,subUnitId:_,cellValue:{[l]:{[u]:Q}}}},ee=g.SetRangeValuesUndoMutationFactory(i,$.params),V={id:g.SetRangeValuesMutation.id,params:ee},N=[$],O=[V],j=s.getHyperLinkByLocation(h,_,l,u);return j&&(N.push({id:E.id,params:{unitId:h,subUnitId:_,id:j.id}}),O.push({id:w.id,params:{unitId:h,subUnitId:_,link:j}})),await o.sequenceExecuteAsync(N,e)?(n.pushUndoRedo({redoMutations:N,undoMutations:O,unitID:h}),!0):!1}},_e={type:o.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(i,t)=>{var h,_,y,S;if(!t)return!1;const{documentId:e,payload:n,id:r}=t,s=i.get(o.IUniverInstanceService),a=i.get(o.ICommandService),d=s.getUnit(e,o.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(_=(h=d.getBody())==null?void 0:h.customRanges)==null?void 0:_.find(M=>M.rangeId===r);if(!c)return!1;const l=(y=t.payload.display)!=null?y:"",u=o.generateRandomId(),m=(S=o.getBodySlice(d.getBody(),c.startIndex,c.endIndex+1).textRuns)==null?void 0:S[0];m&&(m.ed=l.length+1);const f=Z.replaceSelectionFactory(i,{unitId:e,body:{dataStream:`${l}`,customRanges:[{rangeId:u,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:l.length-1,properties:{url:n.payload}}],textRuns:m?[m]:void 0},selection:{startOffset:c.startIndex,endOffset:c.endIndex+1,collapsed:!1},doc:d});return f?a.syncExecuteCommand(f.id,f.params):!1}};var Fe=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,ze=(i,t,e,n)=>{for(var r=n>1?void 0:n?Ke(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&Fe(t,e,r),r},Ge=(i,t)=>(e,n)=>t(e,n,i);let X=class extends o.Disposable{constructor(i){super(),this._commandService=i,this._registerCommands()}_registerCommands(){[pe,fe,ge,_e,me,he,w,F,E,K,B].forEach(i=>{this._commandService.registerCommand(i)})}};X=ze([Ge(0,o.ICommandService)],X);var Ye=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,Je=(i,t,e,n)=>{for(var r=n>1?void 0:n?qe(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&Ye(t,e,r),r},re=(i,t)=>(e,n)=>t(e,n,i);exports.SheetsHyperLinkParserService=class{constructor(t,e,n){this._univerInstanceService=t,this._localeService=e,this._definedNamesService=n}buildHyperLink(t,e,n){return`#${L.SHEET}=${e}${n?`&${typeof n=="string"?L.DEFINE_NAME:L.RANGE}=${typeof n=="string"?n:U.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,r,s;if(t.startsWith("#")){const a=new URLSearchParams(t.slice(1)),d={gid:(e=a.get("gid"))!=null?e:"",range:(n=a.get("range"))!=null?n:"",rangeid:(r=a.get("rangeid"))!=null?r:"",unitid:(s=a.get("unitid"))!=null?s:""},c=this._getURLName(d);return{type:c.type,name:c.name,url:t,searchObj:d}}else return{type:L.URL,name:t,url:t,searchObj:null}}_getURLName(t){var u;const{gid:e,range:n,rangeid:r,unitid:s}=t,a=s?this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),d={type:L.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!a)return d;const c=e?a.getSheetBySheetId(e):a.getActiveSheet(),l=(u=c==null?void 0:c.getName())!=null?u:"";if(n){if(!c)return d;const p=U.deserializeRangeWithSheet(n).range;return o.isValidRange(p,c)&&n!==x?{type:L.RANGE,name:U.serializeRangeWithSheet(l,p)}:d}if(r){const p=this._definedNamesService.getValueById(a.getUnitId(),r);return p?{type:L.DEFINE_NAME,name:p.formulaOrRefString}:d}if(e){const p=a.getSheetBySheetId(e);return p?{type:L.SHEET,name:p.getName()}:d}return d}};exports.SheetsHyperLinkParserService=Je([re(0,o.IUniverInstanceService),re(1,o.Inject(o.LocaleService)),re(2,U.IDefinedNamesService)],exports.SheetsHyperLinkParserService);var ye=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,Ze=(i,t,e)=>t in i?ye(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Qe=(i,t,e,n)=>{for(var r=n>1?void 0:n?Xe(t,e):t,s=i.length-1,a;s>=0;s--)(a=i[s])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&ye(t,e,r),r},ce=(i,t)=>(e,n)=>t(e,n,i),Se=(i,t,e)=>Ze(i,typeof t!="symbol"?t+"":t,e);exports.UniverSheetsHyperLinkPlugin=class extends o.Plugin{constructor(t=oe,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...r}=o.merge({},oe,this._config);this._configService.setConfig(Ee,r)}onStarting(){o.registerDependencies(this._injector,[[exports.HyperLinkModel],[exports.SheetsHyperLinkParserService],[J],[X],[z],[q],[G],[Y]]),o.touchDependencies(this._injector,[[z],[J],[X],[q],[G],[Y]])}};Se(exports.UniverSheetsHyperLinkPlugin,"pluginName",le);Se(exports.UniverSheetsHyperLinkPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsHyperLinkPlugin=Qe([o.DependentOn(g.UniverSheetsPlugin),ce(1,o.Inject(o.Injector)),ce(2,o.IConfigService)],exports.UniverSheetsHyperLinkPlugin);exports.AddHyperLinkCommand=pe;exports.AddHyperLinkMutation=w;exports.AddRichHyperLinkCommand=he;exports.CancelHyperLinkCommand=ge;exports.CancelRichHyperLinkCommand=me;exports.ERROR_RANGE=x;exports.RemoveHyperLinkMutation=E;exports.SheetHyperLinkType=L;exports.UpdateHyperLinkCommand=fe;exports.UpdateHyperLinkMutation=F;exports.UpdateHyperLinkRefMutation=K;exports.UpdateRichHyperLinkCommand=_e;
package/lib/es/facade.js CHANGED
@@ -1,24 +1,49 @@
1
- import { SheetsHyperLinkParserService as m, AddHyperLinkCommand as y, UpdateHyperLinkCommand as k, CancelHyperLinkCommand as I } from "@univerjs/sheets-hyper-link";
2
- import { FWorkbook as l, FRange as h } from "@univerjs/sheets/facade";
3
- import { generateRandomId as g, CustomRangeType as _, DataStreamTreeTokenType as c } from "@univerjs/core";
4
- class S extends l {
1
+ import { Inject as k, generateRandomId as y, CustomRangeType as I, DataStreamTreeTokenType as l } from "@univerjs/core";
2
+ import { SheetsHyperLinkParserService as o, AddHyperLinkCommand as S, UpdateHyperLinkCommand as v, CancelHyperLinkCommand as H } from "@univerjs/sheets-hyper-link";
3
+ import { FWorkbook as u, FWorksheet as _, FRange as g } from "@univerjs/sheets/facade";
4
+ var x = Object.defineProperty, w = Object.getOwnPropertyDescriptor, b = (n, e, t, r) => {
5
+ for (var i = r > 1 ? void 0 : r ? w(e, t) : e, s = n.length - 1, a; s >= 0; s--)
6
+ (a = n[s]) && (i = (r ? a(e, t, i) : a(i)) || i);
7
+ return r && i && x(e, t, i), i;
8
+ }, R = (n, e) => (t, r) => e(t, r, n);
9
+ let m = class {
10
+ constructor(n, e) {
11
+ this._workbook = n, this._parserService = e;
12
+ }
13
+ getRangeUrl(n) {
14
+ return this._parserService.buildHyperLink(this._workbook.getId(), n.getSheetId(), n.getRange()), this;
15
+ }
16
+ };
17
+ m = b([
18
+ R(1, k(o))
19
+ ], m);
20
+ class C extends u {
5
21
  createSheetHyperlink(e, t) {
6
- return this._injector.get(m).buildHyperLink(this.getId(), e, t);
22
+ return this._injector.get(o).buildHyperLink(this.getId(), e, t);
7
23
  }
8
24
  /**
9
- * parse the hyperlink string to get the hyperlink info
10
- * @param hyperlink the hyperlink string
11
- * @returns the hyperlink info
25
+ * Parse the hyperlink string to get the hyperlink info.
26
+ * @param {string} hyperlink the hyperlink string
27
+ * @returns {ISheetHyperLinkInfo} the hyperlink info
12
28
  */
13
29
  parseSheetHyperlink(e) {
14
- return this._injector.get(m).parseHyperLink(e);
30
+ return this._injector.get(o).parseHyperLink(e);
31
+ }
32
+ }
33
+ u.extend(C);
34
+ class L extends _ {
35
+ getUrl() {
36
+ return this._injector.get(o).buildHyperLink(this._workbook.getUnitId(), this._worksheet.getSheetId());
15
37
  }
16
38
  }
17
- l.extend(S);
18
- class x extends h {
39
+ _.extend(L);
40
+ class U extends g {
19
41
  // #region hyperlink
42
+ /**
43
+ * @deprecated
44
+ */
20
45
  setHyperLink(e, t) {
21
- const n = {
46
+ const r = {
22
47
  unitId: this.getUnitId(),
23
48
  subUnitId: this._worksheet.getSheetId(),
24
49
  link: {
@@ -26,38 +51,32 @@ class x extends h {
26
51
  column: this._range.startColumn,
27
52
  payload: e,
28
53
  display: t,
29
- id: g()
54
+ id: y()
30
55
  }
31
56
  };
32
- return this._commandService.executeCommand(y.id, n);
57
+ return this._commandService.executeCommand(S.id, r);
33
58
  }
34
59
  /**
35
- * Get all hyperlinks in the cell in the range.
36
- * @returns hyperlinks
60
+ * @deprecated
37
61
  */
38
62
  getHyperLinks() {
39
- var t, n, i;
63
+ var t, r, i;
40
64
  const e = this._worksheet.getCellRaw(this._range.startRow, this._range.startColumn);
41
- return e != null && e.p ? (i = (n = (t = e.p.body) == null ? void 0 : t.customRanges) == null ? void 0 : n.filter((r) => r.rangeType === _.HYPERLINK).map((r) => {
42
- var s, a, o, d, p;
65
+ return e != null && e.p ? (i = (r = (t = e.p.body) == null ? void 0 : t.customRanges) == null ? void 0 : r.filter((s) => s.rangeType === I.HYPERLINK).map((s) => {
66
+ var a, d, p, c, h;
43
67
  return {
44
- id: `${r.rangeId}`,
45
- startIndex: r.startIndex,
46
- endIndex: r.endIndex,
47
- url: (a = (s = r.properties) == null ? void 0 : s.url) != null ? a : "",
48
- label: (p = (d = (o = e.p) == null ? void 0 : o.body) == null ? void 0 : d.dataStream.slice(r.startIndex, r.endIndex + 1).replaceAll(c.CUSTOM_RANGE_START, "").replaceAll(c.CUSTOM_RANGE_END, "")) != null ? p : ""
68
+ id: `${s.rangeId}`,
69
+ startIndex: s.startIndex,
70
+ endIndex: s.endIndex,
71
+ url: (d = (a = s.properties) == null ? void 0 : a.url) != null ? d : "",
72
+ label: (h = (c = (p = e.p) == null ? void 0 : p.body) == null ? void 0 : c.dataStream.slice(s.startIndex, s.endIndex + 1).replaceAll(l.CUSTOM_RANGE_START, "").replaceAll(l.CUSTOM_RANGE_END, "")) != null ? h : ""
49
73
  };
50
74
  })) != null ? i : [] : [];
51
75
  }
52
76
  /**
53
- * Update hyperlink in the cell in the range.
54
- * [!important] This method is async.
55
- * @param id id of the hyperlink
56
- * @param url url
57
- * @param label optional, label of the url
58
- * @returns success or not
77
+ * @deprecated
59
78
  */
60
- updateHyperLink(e, t, n) {
79
+ updateHyperLink(e, t, r) {
61
80
  const i = {
62
81
  unitId: this.getUnitId(),
63
82
  subUnitId: this._worksheet.getSheetId(),
@@ -66,15 +85,13 @@ class x extends h {
66
85
  id: e,
67
86
  payload: {
68
87
  payload: t,
69
- display: n
88
+ display: r
70
89
  }
71
90
  };
72
- return this._commandService.executeCommand(k.id, i);
91
+ return this._commandService.executeCommand(v.id, i);
73
92
  }
74
93
  /**
75
- * Cancel hyperlink in the cell in the range.
76
- * @param id id of the hyperlink
77
- * @returns success or not
94
+ * @deprecated
78
95
  */
79
96
  cancelHyperLink(e) {
80
97
  const t = {
@@ -84,11 +101,14 @@ class x extends h {
84
101
  column: this._range.startColumn,
85
102
  id: e
86
103
  };
87
- return this._commandService.syncExecuteCommand(I.id, t);
104
+ return this._commandService.syncExecuteCommand(H.id, t);
105
+ }
106
+ getUrl() {
107
+ return this._injector.get(o).buildHyperLink(this.getUnitId(), this.getSheetId(), this.getRange());
88
108
  }
89
109
  // #endregion
90
110
  }
91
- h.extend(x);
111
+ g.extend(U);
92
112
  export {
93
- S as FWorkbookHyperLinkMixin
113
+ C as FWorkbookHyperLinkMixin
94
114
  };
package/lib/es/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  var Ae = Object.defineProperty;
2
2
  var We = (s, e, t) => e in s ? Ae(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
3
  var w = (s, e, t) => We(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { Disposable as V, ObjectMatrix as q, UniverInstanceType as I, IUniverInstanceService as E, CommandType as L, CustomRangeType as b, Inject as M, ICommandService as P, sequenceExecuteAsync as ve, isValidRange as Re, toDisposable as Be, DisposableCollection as je, Rectangle as Fe, Range as Ke, Tools as oe, BuildTextUtils as Z, generateRandomId as de, TextX as ce, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Ye, IResourceManagerService as Ge, IUndoRedoService as Se, CellValueType as Ie, sequenceExecute as ze, getBodySlice as Ne, LocaleService as Je, DependentOn as Xe, Injector as qe, Plugin as Ze, merge as Qe, registerDependencies as et, touchDependencies as tt, IConfigService as nt } from "@univerjs/core";
4
+ import { Disposable as V, ObjectMatrix as q, UniverInstanceType as v, IUniverInstanceService as E, CommandType as L, CustomRangeType as b, Inject as M, ICommandService as P, sequenceExecuteAsync as Re, isValidRange as Se, toDisposable as Be, DisposableCollection as je, Rectangle as Fe, Range as Ke, Tools as oe, BuildTextUtils as Z, generateRandomId as de, TextX as ce, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Ye, IResourceManagerService as Ge, IUndoRedoService as Ie, CellValueType as ve, sequenceExecute as ze, getBodySlice as Ne, LocaleService as Je, DependentOn as Xe, Injector as qe, Plugin as Ze, merge as Qe, registerDependencies as et, touchDependencies as tt, IConfigService as nt } from "@univerjs/core";
5
5
  import { Subject as rt } from "rxjs";
6
6
  import { getSheetCommandTarget as j, RefRangeService as Oe, SheetsSelectionsService as ke, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as st, handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests as it, SheetInterceptorService as le, RemoveSheetCommand as at, handleDefaultRangeChangeWithEffectRefCommands as ot, SetRangeValuesMutation as H, SetRangeValuesCommand as dt, ClearSelectionContentCommand as ct, ClearSelectionAllCommand as lt, ClearSelectionFormatCommand as ut, AFTER_CELL_EDIT as pt, SetRangeValuesUndoMutationFactory as Me, UniverSheetsPlugin as ht } from "@univerjs/sheets";
7
7
  import { deserializeRangeWithSheet as Ce, serializeRange as B, serializeRangeWithSheet as gt, IDefinedNamesService as ft } from "@univerjs/engine-formula";
8
8
  import { addCustomRangeBySelectionFactory as _t, deleteCustomRangeFactory as mt, replaceSelectionFactory as De } from "@univerjs/docs";
9
- var yt = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, Rt = (s, e, t, n) => {
10
- for (var r = n > 1 ? void 0 : n ? vt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
9
+ var yt = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, St = (s, e, t, n) => {
10
+ for (var r = n > 1 ? void 0 : n ? Rt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
11
11
  (a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
12
12
  return n && r && yt(e, t, r), r;
13
- }, St = (s, e) => (t, n) => e(t, n, s);
14
- let S = class extends V {
13
+ }, It = (s, e) => (t, n) => e(t, n, s);
14
+ let I = class extends V {
15
15
  constructor(e) {
16
16
  super();
17
17
  w(this, "_linkUpdate$", new rt());
@@ -101,7 +101,7 @@ let S = class extends V {
101
101
  }
102
102
  getHyperLinkByLocationSync(e, t, n, r) {
103
103
  var l, u, h, g, p;
104
- const { matrix: i } = this._ensureMap(e, t), a = this._univerInstanceService.getUnit(e, I.UNIVER_SHEET), o = (l = a == null ? void 0 : a.getSheetBySheetId(t)) == null ? void 0 : l.getCellRaw(n, r), c = ((p = (g = o == null ? void 0 : o.v) != null ? g : (h = (u = o == null ? void 0 : o.p) == null ? void 0 : u.body) == null ? void 0 : h.dataStream.slice(0, -2)) != null ? p : "").toString(), d = i.getValue(n, r);
104
+ const { matrix: i } = this._ensureMap(e, t), a = this._univerInstanceService.getUnit(e, v.UNIVER_SHEET), o = (l = a == null ? void 0 : a.getSheetBySheetId(t)) == null ? void 0 : l.getCellRaw(n, r), c = ((p = (g = o == null ? void 0 : o.v) != null ? g : (h = (u = o == null ? void 0 : o.p) == null ? void 0 : u.body) == null ? void 0 : h.dataStream.slice(0, -2)) != null ? p : "").toString(), d = i.getValue(n, r);
105
105
  if (d)
106
106
  return {
107
107
  ...d,
@@ -137,17 +137,17 @@ let S = class extends V {
137
137
  return Array.from(this._linkMap.keys()).map((t) => this.getUnit(t));
138
138
  }
139
139
  };
140
- S = Rt([
141
- St(0, E)
142
- ], S);
140
+ I = St([
141
+ It(0, E)
142
+ ], I);
143
143
  var U = /* @__PURE__ */ ((s) => (s.SHEET = "gid", s.RANGE = "range", s.DEFINE_NAME = "rangeid", s.INVALID = "invalid", s.URL = "url", s))(U || {});
144
- const It = "sheets-hyper-link.config", Ue = {}, O = {
144
+ const vt = "sheets-hyper-link.config", Ue = {}, O = {
145
145
  type: L.MUTATION,
146
146
  id: "sheets.mutation.add-hyper-link",
147
147
  handler(s, e) {
148
148
  if (!e)
149
149
  return !1;
150
- const t = s.get(S), { unitId: n, subUnitId: r, link: i } = e;
150
+ const t = s.get(I), { unitId: n, subUnitId: r, link: i } = e;
151
151
  return t.addHyperLink(n, r, i);
152
152
  }
153
153
  }, k = {
@@ -156,7 +156,7 @@ const It = "sheets-hyper-link.config", Ue = {}, O = {
156
156
  handler(s, e) {
157
157
  if (!e)
158
158
  return !1;
159
- const t = s.get(S), { unitId: n, subUnitId: r, id: i } = e;
159
+ const t = s.get(I), { unitId: n, subUnitId: r, id: i } = e;
160
160
  return t.removeHyperLink(n, r, i);
161
161
  }
162
162
  }, _e = {
@@ -165,7 +165,7 @@ const It = "sheets-hyper-link.config", Ue = {}, O = {
165
165
  handler(s, e) {
166
166
  if (!e)
167
167
  return !1;
168
- const t = s.get(S), { unitId: n, subUnitId: r, payload: i, id: a } = e;
168
+ const t = s.get(I), { unitId: n, subUnitId: r, payload: i, id: a } = e;
169
169
  return t.updateHyperLink(n, r, a, i, !1);
170
170
  }
171
171
  }, me = {
@@ -174,7 +174,7 @@ const It = "sheets-hyper-link.config", Ue = {}, O = {
174
174
  handler(s, e) {
175
175
  if (!e)
176
176
  return !1;
177
- const t = s.get(S), { unitId: n, subUnitId: r, id: i, row: a, column: o, silent: c } = e;
177
+ const t = s.get(I), { unitId: n, subUnitId: r, id: i, row: a, column: o, silent: c } = e;
178
178
  return t.updateHyperLinkRef(n, r, i, { row: a, column: o }, c);
179
179
  }
180
180
  }, X = {
@@ -280,7 +280,7 @@ let ee = class extends V {
280
280
  r,
281
281
  this._refRangeService.watchRange(e, t, i, (a, o) => {
282
282
  const { redos: c } = this._handlePositionChange(e, t, n, o, !0);
283
- ve(c, this._commandService, { onlyLocal: !0 });
283
+ Re(c, this._commandService, { onlyLocal: !0 });
284
284
  }, !0)
285
285
  );
286
286
  }
@@ -302,7 +302,7 @@ let ee = class extends V {
302
302
  };
303
303
  if (d.range && d.gid) {
304
304
  const l = d.gid, u = Ce(d.range).range;
305
- if (Re(u) && d.range !== Q) {
305
+ if (Se(u) && d.range !== Q) {
306
306
  const h = (g) => {
307
307
  const p = it(u, g, { selectionManagerService: this._selectionManagerService });
308
308
  return p && B(p) === B(u) ? {
@@ -404,7 +404,7 @@ let ee = class extends V {
404
404
  };
405
405
  ee = wt([
406
406
  z(0, M(Oe)),
407
- z(1, M(S)),
407
+ z(1, M(I)),
408
408
  z(2, M(ke)),
409
409
  z(3, P)
410
410
  ], ee);
@@ -423,7 +423,7 @@ let te = class extends V {
423
423
  getMutations: (s) => {
424
424
  var e;
425
425
  if (s.id === at.id) {
426
- const t = s.params, n = t.unitId ? this._univerInstanceService.getUnit(t.unitId) : this._univerInstanceService.getCurrentUnitForType(I.UNIVER_SHEET);
426
+ const t = s.params, n = t.unitId ? this._univerInstanceService.getUnit(t.unitId) : this._univerInstanceService.getCurrentUnitForType(v.UNIVER_SHEET);
427
427
  if (!n)
428
428
  return { redos: [], undos: [] };
429
429
  const r = n.getUnitId(), i = t.subUnitId || ((e = n.getActiveSheet()) == null ? void 0 : e.getSheetId());
@@ -455,7 +455,7 @@ let te = class extends V {
455
455
  te = Ut([
456
456
  he(0, M(le)),
457
457
  he(1, E),
458
- he(2, M(S))
458
+ he(2, M(I))
459
459
  ], te);
460
460
  var bt = Object.defineProperty, Pt = Object.getOwnPropertyDescriptor, Nt = (s, e, t, n) => {
461
461
  for (var r = n > 1 ? void 0 : n ? Pt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
@@ -476,7 +476,7 @@ let ne = class extends V {
476
476
  }
477
477
  _isLegalRangeUrl(e, t) {
478
478
  var r, i, a;
479
- const n = this._univerInstanceService.getUnit(e, I.UNIVER_SHEET);
479
+ const n = this._univerInstanceService.getUnit(e, v.UNIVER_SHEET);
480
480
  if (!n)
481
481
  return null;
482
482
  if (t && t.startsWith("#")) {
@@ -490,7 +490,7 @@ let ne = class extends V {
490
490
  if (!l)
491
491
  return null;
492
492
  const u = Ce(c.range).range;
493
- if (Re(u, l) && c.range !== Q)
493
+ if (Se(u, l) && c.range !== Q)
494
494
  return {
495
495
  range: u,
496
496
  worksheet: l
@@ -518,8 +518,8 @@ let ne = class extends V {
518
518
  this._refRangeService.registerRefRange(
519
519
  m,
520
520
  (y) => {
521
- const v = ot(m, y);
522
- return v && Fe.equals(v, m) ? {
521
+ const R = ot(m, y);
522
+ return R && Fe.equals(R, m) ? {
523
523
  preRedos: [],
524
524
  preUndos: [],
525
525
  redos: [],
@@ -533,7 +533,7 @@ let ne = class extends V {
533
533
  row: n,
534
534
  col: r,
535
535
  id: g.rangeId,
536
- url: `#gid=${t}&range=${v ? B(v) : Q}`
536
+ url: `#gid=${t}&range=${R ? B(R) : Q}`
537
537
  }
538
538
  }],
539
539
  undos: [{
@@ -570,17 +570,17 @@ let ne = class extends V {
570
570
  });
571
571
  });
572
572
  };
573
- this._univerInstanceService.getAllUnitsForType(I.UNIVER_SHEET).forEach((t) => {
573
+ this._univerInstanceService.getAllUnitsForType(v.UNIVER_SHEET).forEach((t) => {
574
574
  e(t);
575
575
  }), this.disposeWithMe(
576
576
  this._univerInstanceService.unitAdded$.subscribe((t) => {
577
- t.type === I.UNIVER_SHEET && e(t);
577
+ t.type === v.UNIVER_SHEET && e(t);
578
578
  })
579
579
  );
580
580
  }
581
581
  _initWorkbookUnload() {
582
582
  this._univerInstanceService.unitDisposed$.subscribe((e) => {
583
- if (e.type === I.UNIVER_SHEET) {
583
+ if (e.type === v.UNIVER_SHEET) {
584
584
  const t = e, n = t.getUnitId();
585
585
  t.getSheets().forEach((r) => {
586
586
  const i = r.getSheetId();
@@ -710,7 +710,7 @@ let re = class extends V {
710
710
  if (!s || s.p)
711
711
  return t(s);
712
712
  if (typeof s.v == "string" && oe.isLegalUrl(s.v) && s.v[s.v.length - 1] !== " ") {
713
- const { unitId: n, subUnitId: r } = e, i = this._univerInstanceService.getUnit(n, I.UNIVER_SHEET), a = i == null ? void 0 : i.getSheetBySheetId(r);
713
+ const { unitId: n, subUnitId: r } = e, i = this._univerInstanceService.getUnit(n, v.UNIVER_SHEET), a = i == null ? void 0 : i.getSheetBySheetId(r);
714
714
  if (!a)
715
715
  return t(s);
716
716
  const o = a.getBlankCellDocumentModel(s);
@@ -760,7 +760,7 @@ let re = class extends V {
760
760
  };
761
761
  re = Dt([
762
762
  J(0, M(le)),
763
- J(1, M(S)),
763
+ J(1, M(I)),
764
764
  J(2, M(ke)),
765
765
  J(3, E)
766
766
  ], re);
@@ -810,7 +810,7 @@ let se = class extends V {
810
810
  };
811
811
  se = $t([
812
812
  be(0, Ge),
813
- be(1, M(S))
813
+ be(1, M(I))
814
814
  ], se);
815
815
  const xt = {
816
816
  type: L.COMMAND,
@@ -818,16 +818,16 @@ const xt = {
818
818
  // eslint-disable-next-line max-lines-per-function
819
819
  async handler(s, e) {
820
820
  if (!e) return !1;
821
- const t = s.get(P), n = s.get(Se), r = s.get(E), i = s.get(S), a = s.get(le), o = j(r, e);
821
+ const t = s.get(P), n = s.get(Ie), r = s.get(E), i = s.get(I), a = s.get(le), o = j(r, e);
822
822
  if (!o) return !1;
823
- const { unitId: c, subUnitId: d, workbook: l, worksheet: u } = o, { link: h } = e, { payload: g, display: p, row: f, column: _, id: m } = h, C = u.getCell(f, _), y = u.getBlankCellDocumentModel(C), v = y.documentModel.getSnapshot(), R = oe.deepClone(v.body);
824
- if (!R) return !1;
823
+ const { unitId: c, subUnitId: d, workbook: l, worksheet: u } = o, { link: h } = e, { payload: g, display: p, row: f, column: _, id: m } = h, C = u.getCell(f, _), y = u.getBlankCellDocumentModel(C), R = y.documentModel.getSnapshot(), S = oe.deepClone(R.body);
824
+ if (!S) return !1;
825
825
  let N;
826
826
  if (p ? N = Z.selection.replace({
827
827
  selection: {
828
828
  startOffset: 0,
829
- endOffset: R.dataStream.length - 2,
830
- collapsed: R.dataStream.length - 2 === 0
829
+ endOffset: S.dataStream.length - 2,
830
+ collapsed: S.dataStream.length - 2 === 0
831
831
  },
832
832
  body: {
833
833
  dataStream: `${p}`,
@@ -844,8 +844,8 @@ const xt = {
844
844
  },
845
845
  doc: y.documentModel
846
846
  }) : N = Z.customRange.add({
847
- body: R,
848
- ranges: [{ startOffset: 0, endOffset: R.dataStream.length - 2, collapsed: !1 }],
847
+ body: S,
848
+ ranges: [{ startOffset: 0, endOffset: S.dataStream.length - 2, collapsed: !1 }],
849
849
  rangeId: m,
850
850
  rangeType: b.HYPERLINK,
851
851
  properties: {
@@ -853,12 +853,12 @@ const xt = {
853
853
  refId: m
854
854
  }
855
855
  }), !N) return !1;
856
- const F = ce.apply(R, N.serialize()), D = {
856
+ const F = ce.apply(S, N.serialize()), D = {
857
857
  p: {
858
- ...v,
858
+ ...R,
859
859
  body: F
860
860
  },
861
- t: Ie.STRING
861
+ t: ve.STRING
862
862
  }, x = await a.onWriteCell(l, u, f, _, D), T = {
863
863
  unitId: c,
864
864
  subUnitId: d,
@@ -888,7 +888,7 @@ const xt = {
888
888
  subUnitId: d,
889
889
  link: W
890
890
  }
891
- })), await ve(K, t) ? (n.pushUndoRedo({
891
+ })), await Re(K, t) ? (n.pushUndoRedo({
892
892
  redoMutations: K,
893
893
  undoMutations: A,
894
894
  unitID: c
@@ -918,7 +918,7 @@ const xt = {
918
918
  handler(s, e) {
919
919
  var D, x;
920
920
  if (!e) return !1;
921
- const t = s.get(P), n = s.get(Se), r = s.get(E), i = s.get(S), a = j(r, e);
921
+ const t = s.get(P), n = s.get(Ie), r = s.get(E), i = s.get(I), a = j(r, e);
922
922
  if (!a) return !1;
923
923
  const { row: o, column: c, id: d } = e, { unitId: l, subUnitId: u, worksheet: h } = a, g = h.getCell(o, c);
924
924
  if (!g) return !1;
@@ -926,9 +926,9 @@ const xt = {
926
926
  if (!(p != null && p.documentModel)) return !1;
927
927
  const f = oe.deepClone(p.documentModel.getSnapshot()), _ = (x = (D = f.body) == null ? void 0 : D.customRanges) == null ? void 0 : x.find((T) => `${T.rangeId}` === d);
928
928
  if (!_) return !1;
929
- const m = Z.customRange.delete(s, { documentDataModel: p.documentModel, rangeId: _.rangeId });
929
+ const m = Z.customRange.delete({ documentDataModel: p.documentModel, rangeId: _.rangeId });
930
930
  if (!m) return !1;
931
- const C = ce.apply(f.body, m.serialize()), y = [], v = [], R = {
931
+ const C = ce.apply(f.body, m.serialize()), y = [], R = [], S = {
932
932
  unitId: l,
933
933
  subUnitId: u,
934
934
  cellValue: {
@@ -938,17 +938,17 @@ const xt = {
938
938
  ...f,
939
939
  body: C
940
940
  },
941
- t: Ie.STRING
941
+ t: ve.STRING
942
942
  }
943
943
  }
944
944
  }
945
945
  };
946
946
  y.push({
947
947
  id: H.id,
948
- params: R
948
+ params: S
949
949
  });
950
- const N = Me(s, R);
951
- v.push({
950
+ const N = Me(s, S);
951
+ R.push({
952
952
  id: H.id,
953
953
  params: N
954
954
  });
@@ -960,7 +960,7 @@ const xt = {
960
960
  subUnitId: u,
961
961
  id: d
962
962
  }
963
- }), v.push({
963
+ }), R.push({
964
964
  id: O.id,
965
965
  params: {
966
966
  unitId: l,
@@ -971,7 +971,7 @@ const xt = {
971
971
  }
972
972
  })), ze(y, t).result ? (n.pushUndoRedo({
973
973
  redoMutations: y,
974
- undoMutations: v,
974
+ undoMutations: R,
975
975
  unitID: l
976
976
  }), !0) : !1;
977
977
  }
@@ -982,7 +982,7 @@ const xt = {
982
982
  var l, u;
983
983
  if (!e)
984
984
  return !1;
985
- const { id: t, documentId: n } = e, r = s.get(P), a = s.get(E).getUnit(n, I.UNIVER_DOC), o = (u = (l = a == null ? void 0 : a.getBody()) == null ? void 0 : l.customRanges) == null ? void 0 : u.find((h) => h.rangeId === t);
985
+ const { id: t, documentId: n } = e, r = s.get(P), a = s.get(E).getUnit(n, v.UNIVER_DOC), o = (u = (l = a == null ? void 0 : a.getBody()) == null ? void 0 : l.customRanges) == null ? void 0 : u.find((h) => h.rangeId === t);
986
986
  let c = null;
987
987
  o && o.endIndex === a.getBody().dataStream.length - 3 && (c = {
988
988
  dataStream: " "
@@ -997,7 +997,7 @@ const xt = {
997
997
  async handler(s, e) {
998
998
  var we, Ee, Le;
999
999
  if (!e) return !1;
1000
- const t = s.get(P), n = s.get(Se), r = s.get(E), i = s.get(S), a = s.get(le), o = j(r, {
1000
+ const t = s.get(P), n = s.get(Ie), r = s.get(E), i = s.get(I), a = s.get(le), o = j(r, {
1001
1001
  unitId: e.unitId,
1002
1002
  subUnitId: e.subUnitId
1003
1003
  });
@@ -1006,9 +1006,9 @@ const xt = {
1006
1006
  if (!C) return !1;
1007
1007
  const y = g.getCellDocumentModelWithFormula(C);
1008
1008
  if (!(y != null && y.documentModel)) return !1;
1009
- const v = y.documentModel.getSnapshot(), R = (Ee = (we = v.body) == null ? void 0 : we.customRanges) == null ? void 0 : Ee.find((Te) => `${Te.rangeId}` === u);
1010
- if (!R) return !1;
1011
- const N = de(), $ = (Le = Ne(y.documentModel.getBody(), R.startIndex, R.endIndex + 1).textRuns) == null ? void 0 : Le[0];
1009
+ const R = y.documentModel.getSnapshot(), S = (Ee = (we = R.body) == null ? void 0 : we.customRanges) == null ? void 0 : Ee.find((Te) => `${Te.rangeId}` === u);
1010
+ if (!S) return !1;
1011
+ const N = de(), $ = (Le = Ne(y.documentModel.getBody(), S.startIndex, S.endIndex + 1).textRuns) == null ? void 0 : Le[0];
1012
1012
  $ && ($.ed = m.length + 1);
1013
1013
  const D = De(s, {
1014
1014
  unitId: p,
@@ -1026,20 +1026,20 @@ const xt = {
1026
1026
  textRuns: $ ? [$] : void 0
1027
1027
  },
1028
1028
  selection: {
1029
- startOffset: R.startIndex,
1030
- endOffset: R.endIndex + 1,
1029
+ startOffset: S.startIndex,
1030
+ endOffset: S.endIndex + 1,
1031
1031
  collapsed: !1
1032
1032
  },
1033
1033
  doc: y.documentModel
1034
1034
  });
1035
1035
  if (!D)
1036
1036
  return !1;
1037
- const x = ce.apply(oe.deepClone(v.body), D.textX.serialize()), T = {
1037
+ const x = ce.apply(oe.deepClone(R.body), D.textX.serialize()), T = {
1038
1038
  p: {
1039
- ...v,
1039
+ ...R,
1040
1040
  body: x
1041
1041
  },
1042
- t: Ie.STRING
1042
+ t: ve.STRING
1043
1043
  }, ue = await a.onWriteCell(h, g, d, l, T), Y = {
1044
1044
  id: H.id,
1045
1045
  params: {
@@ -1069,7 +1069,7 @@ const xt = {
1069
1069
  subUnitId: f,
1070
1070
  link: G
1071
1071
  }
1072
- })), await ve(A, t) ? (n.pushUndoRedo({
1072
+ })), await Re(A, t) ? (n.pushUndoRedo({
1073
1073
  redoMutations: A,
1074
1074
  undoMutations: W,
1075
1075
  unitID: p
@@ -1082,7 +1082,7 @@ const xt = {
1082
1082
  var p, f, _, m;
1083
1083
  if (!e)
1084
1084
  return !1;
1085
- const { documentId: t, payload: n, id: r } = e, i = s.get(E), a = s.get(P), o = i.getUnit(t, I.UNIVER_DOC);
1085
+ const { documentId: t, payload: n, id: r } = e, i = s.get(E), a = s.get(P), o = i.getUnit(t, v.UNIVER_DOC);
1086
1086
  if (!o)
1087
1087
  return !1;
1088
1088
  const c = (f = (p = o.getBody()) == null ? void 0 : p.customRanges) == null ? void 0 : f.find((C) => C.rangeId === r);
@@ -1182,7 +1182,7 @@ let ye = class {
1182
1182
  }
1183
1183
  _getURLName(s) {
1184
1184
  var d;
1185
- const { gid: e, range: t, rangeid: n, unitid: r } = s, i = r ? this._univerInstanceService.getUnit(r, I.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitForType(I.UNIVER_SHEET), a = {
1185
+ const { gid: e, range: t, rangeid: n, unitid: r } = s, i = r ? this._univerInstanceService.getUnit(r, v.UNIVER_SHEET) : this._univerInstanceService.getCurrentUnitForType(v.UNIVER_SHEET), a = {
1186
1186
  type: U.INVALID,
1187
1187
  name: this._localeService.t("hyperLink.message.refError")
1188
1188
  };
@@ -1192,7 +1192,7 @@ let ye = class {
1192
1192
  if (t) {
1193
1193
  if (!o) return a;
1194
1194
  const l = Ce(t).range;
1195
- return Re(l, o) && t !== Q ? {
1195
+ return Se(l, o) && t !== Q ? {
1196
1196
  type: U.RANGE,
1197
1197
  name: gt(c, l)
1198
1198
  } : a;
@@ -1232,11 +1232,11 @@ let ae = class extends Ze {
1232
1232
  Ue,
1233
1233
  this._config
1234
1234
  );
1235
- this._configService.setConfig(It, n);
1235
+ this._configService.setConfig(vt, n);
1236
1236
  }
1237
1237
  onStarting() {
1238
1238
  et(this._injector, [
1239
- [S],
1239
+ [I],
1240
1240
  [ye],
1241
1241
  [se],
1242
1242
  [ie],
@@ -1255,7 +1255,7 @@ let ae = class extends Ze {
1255
1255
  }
1256
1256
  };
1257
1257
  xe(ae, "pluginName", He);
1258
- xe(ae, "type", I.UNIVER_SHEET);
1258
+ xe(ae, "type", v.UNIVER_SHEET);
1259
1259
  ae = Qt([
1260
1260
  Xe(ht),
1261
1261
  Pe(1, M(qe)),
@@ -1268,7 +1268,7 @@ export {
1268
1268
  At as CancelHyperLinkCommand,
1269
1269
  Wt as CancelRichHyperLinkCommand,
1270
1270
  Q as ERROR_RANGE,
1271
- S as HyperLinkModel,
1271
+ I as HyperLinkModel,
1272
1272
  k as RemoveHyperLinkMutation,
1273
1273
  U as SheetHyperLinkType,
1274
1274
  ye as SheetsHyperLinkParserService,
@@ -1,9 +1,9 @@
1
1
  import { ICommand } from '@univerjs/core';
2
- import { ICellHyperLink } from '../../types/interfaces/i-hyper-link';
2
+ import { ISheetHyperLink } from '../../types/interfaces/i-hyper-link';
3
3
  export interface IAddHyperLinkCommandParams {
4
4
  unitId: string;
5
5
  subUnitId: string;
6
- link: ICellHyperLink;
6
+ link: ISheetHyperLink;
7
7
  }
8
8
  /**
9
9
  * Command for add hyperlink
@@ -14,6 +14,6 @@ export interface IAddRichHyperLinkCommandParams {
14
14
  * url of link
15
15
  */
16
16
  documentId: string;
17
- link: ICellHyperLink;
17
+ link: ISheetHyperLink;
18
18
  }
19
19
  export declare const AddRichHyperLinkCommand: ICommand<IAddRichHyperLinkCommandParams>;
@@ -1,8 +1,8 @@
1
1
  import { ICommand } from '@univerjs/core';
2
- import { ICellHyperLink } from '../../types/interfaces/i-hyper-link';
2
+ import { ISheetHyperLink } from '../../types/interfaces/i-hyper-link';
3
3
  export interface IAddHyperLinkMutationParams {
4
4
  unitId: string;
5
5
  subUnitId: string;
6
- link: ICellHyperLink;
6
+ link: ISheetHyperLink;
7
7
  }
8
8
  export declare const AddHyperLinkMutation: ICommand<IAddHyperLinkMutationParams>;
@@ -8,57 +8,44 @@ export interface ICellHyperLink {
8
8
  }
9
9
  export interface IFRangeHyperlinkMixin {
10
10
  /**
11
- * Set hyperlink in the cell in the range.
12
- * [!important] This method is async.
13
- * @param url url
14
- * @param label optional, label of the url
15
- * @returns success or not
11
+ * @deprecated use `range.setRichTextValueForCell(univerAPI.newRichText().insertLink(label, url))` instead
16
12
  */
17
13
  setHyperLink(url: string, label?: string): Promise<boolean>;
18
14
  /**
19
- * Get all hyperlinks in the cell in the range.
20
- * @returns hyperlinks
15
+ * @deprecated use `range.setRichTextValueForCell(range.getRichTextValue().getLinks())` instead
21
16
  */
22
17
  getHyperLinks(): ICellHyperLink[];
23
18
  /**
24
- * Update hyperlink in the cell in the range.
25
- * [!important] This method is async.
26
- * @param id id of the hyperlink
27
- * @param url url
28
- * @param label optional, label of the url
29
- * @returns success or not
19
+ * @deprecated use `range.setRichTextValueForCell(range.getRichTextValue().copy().updateLink(id, url))` instead
30
20
  */
31
21
  updateHyperLink(id: string, url: string, label?: string): Promise<boolean>;
32
22
  /**
33
- * Cancel hyperlink in the cell in the range.
34
- * [!important] This method is async.
35
- * @param id id of the hyperlink
36
- * @returns success or not
23
+ * @deprecated use `range.setRichTextValueForCell(range.getRichTextValue().copy().cancelLink(id))` instead
37
24
  */
38
25
  cancelHyperLink(id: string): boolean;
26
+ /**
27
+ * Get the url of this range.
28
+ */
29
+ getUrl(): string;
39
30
  }
40
31
  export declare class FRangeHyperlinkMixin extends FRange implements IFRangeHyperlinkMixin {
32
+ /**
33
+ * @deprecated
34
+ */
41
35
  setHyperLink(url: string, label?: string): Promise<boolean>;
42
36
  /**
43
- * Get all hyperlinks in the cell in the range.
44
- * @returns hyperlinks
37
+ * @deprecated
45
38
  */
46
39
  getHyperLinks(): ICellHyperLink[];
47
40
  /**
48
- * Update hyperlink in the cell in the range.
49
- * [!important] This method is async.
50
- * @param id id of the hyperlink
51
- * @param url url
52
- * @param label optional, label of the url
53
- * @returns success or not
41
+ * @deprecated
54
42
  */
55
43
  updateHyperLink(id: string, url: string, label?: string): Promise<boolean>;
56
44
  /**
57
- * Cancel hyperlink in the cell in the range.
58
- * @param id id of the hyperlink
59
- * @returns success or not
45
+ * @deprecated
60
46
  */
61
47
  cancelHyperLink(id: string): boolean;
48
+ getUrl(): string;
62
49
  }
63
50
  declare module '@univerjs/sheets/facade' {
64
51
  interface FRange extends IFRangeHyperlinkMixin {
@@ -1,27 +1,34 @@
1
+ import { ISheetHyperLinkInfo, SheetsHyperLinkParserService } from '@univerjs/sheets-hyper-link';
2
+ import { FRange, FWorkbook } from '@univerjs/sheets/facade';
1
3
  import { IRange } from '@univerjs/core';
2
- import { ISheetHyperLinkInfo } from '@univerjs/sheets-hyper-link';
3
- import { FWorkbook } from '@univerjs/sheets/facade';
4
+ export declare class SheetHyperLinkBuilder {
5
+ private _workbook;
6
+ private readonly _parserService;
7
+ constructor(_workbook: FWorkbook, _parserService: SheetsHyperLinkParserService);
8
+ getRangeUrl(range: FRange): this;
9
+ }
4
10
  export interface IFWorkbookHyperlinkMixin {
5
11
  /**
6
- * create a hyperlink for the sheet
7
- * @param sheetId the sheet id to link
8
- * @param range the range to link, or define-name id
9
- * @returns the hyperlink string
12
+ * @deprecated use `getUrl` method in `FRange` or `FWorksheet` instead.
10
13
  */
11
14
  createSheetHyperlink(this: FWorkbook, sheetId: string, range?: string | IRange): string;
12
15
  /**
13
- * parse the hyperlink string to get the hyperlink info
16
+ * Parse the hyperlink string to get the hyperlink info.
14
17
  * @param hyperlink the hyperlink string
15
18
  * @returns the hyperlink info
19
+ * @example
20
+ * ``` ts
21
+ * univerAPI.getActiveWorkbook().parseSheetHyperlink('#gid=sheet_Id&range=F6')
22
+ * ```
16
23
  */
17
24
  parseSheetHyperlink(this: FWorkbook, hyperlink: string): ISheetHyperLinkInfo;
18
25
  }
19
26
  export declare class FWorkbookHyperLinkMixin extends FWorkbook implements IFWorkbookHyperlinkMixin {
20
27
  createSheetHyperlink(sheetId: string, range?: string | IRange): string;
21
28
  /**
22
- * parse the hyperlink string to get the hyperlink info
23
- * @param hyperlink the hyperlink string
24
- * @returns the hyperlink info
29
+ * Parse the hyperlink string to get the hyperlink info.
30
+ * @param {string} hyperlink the hyperlink string
31
+ * @returns {ISheetHyperLinkInfo} the hyperlink info
25
32
  */
26
33
  parseSheetHyperlink(hyperlink: string): ISheetHyperLinkInfo;
27
34
  }
@@ -0,0 +1,14 @@
1
+ import { FWorksheet } from '@univerjs/sheets/facade';
2
+ export interface IFWorksheetHyperlinkMixin {
3
+ /**
4
+ * Get the url of this sheet
5
+ */
6
+ getUrl(): string;
7
+ }
8
+ export declare class FWorksheetHyperlinkMixin extends FWorksheet implements IFWorksheetHyperlinkMixin {
9
+ getUrl(): string;
10
+ }
11
+ declare module '@univerjs/sheets/facade' {
12
+ interface FWorksheet extends IFWorksheetHyperlinkMixin {
13
+ }
14
+ }
@@ -14,7 +14,9 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import './f-workbook';
17
+ import './f-worksheet';
17
18
  import './f-range';
18
19
  export { FWorkbookHyperLinkMixin } from './f-workbook';
19
20
  export type * from './f-range';
20
21
  export type * from './f-workbook';
22
+ export type * from './f-worksheet';
@@ -16,7 +16,7 @@
16
16
  export { HyperLinkModel } from './models/hyper-link.model';
17
17
  export { SheetHyperLinkType } from './types/enums/hyper-link-type';
18
18
  export { UniverSheetsHyperLinkPlugin } from './plugin';
19
- export type { ICellHyperLink, ICellLinkContent } from './types/interfaces/i-hyper-link';
19
+ export type { ICellLinkContent, ISheetHyperLink } from './types/interfaces/i-hyper-link';
20
20
  export { type ISheetHyperLinkInfo, type ISheetUrlParams, SheetsHyperLinkParserService } from './services/parser.service';
21
21
  export { ERROR_RANGE } from './types/const';
22
22
  export { AddHyperLinkCommand, AddRichHyperLinkCommand, type IAddHyperLinkCommandParams, type IAddRichHyperLinkCommandParams } from './commands/commands/add-hyper-link.command';
@@ -1,14 +1,14 @@
1
+ import { ICellLinkContent, ISheetHyperLink } from '../types/interfaces/i-hyper-link';
1
2
  import { Disposable, IUniverInstanceService } from '@univerjs/core';
2
- import { ICellHyperLink, ICellLinkContent } from '../types/interfaces/i-hyper-link';
3
3
  type LinkUpdate = {
4
4
  type: 'add';
5
- payload: ICellHyperLink;
5
+ payload: ISheetHyperLink;
6
6
  unitId: string;
7
7
  subUnitId: string;
8
8
  silent?: boolean;
9
9
  } | {
10
10
  type: 'remove';
11
- payload: ICellHyperLink;
11
+ payload: ISheetHyperLink;
12
12
  unitId: string;
13
13
  subUnitId: string;
14
14
  silent?: boolean;
@@ -35,7 +35,7 @@ type LinkUpdate = {
35
35
  unitLinks: {
36
36
  unitId: string;
37
37
  subUnitId: string;
38
- links: ICellHyperLink[];
38
+ links: ISheetHyperLink[];
39
39
  }[];
40
40
  silent?: boolean;
41
41
  };
@@ -47,15 +47,15 @@ export declare class HyperLinkModel extends Disposable {
47
47
  private _linkPositionMap;
48
48
  constructor(_univerInstanceService: IUniverInstanceService);
49
49
  private _ensureMap;
50
- addHyperLink(unitId: string, subUnitId: string, link: ICellHyperLink): boolean;
50
+ addHyperLink(unitId: string, subUnitId: string, link: ISheetHyperLink): boolean;
51
51
  updateHyperLink(unitId: string, subUnitId: string, id: string, payload: Partial<ICellLinkContent>, silent?: boolean): boolean;
52
52
  updateHyperLinkRef(unitId: string, subUnitId: string, id: string, payload: {
53
53
  row: number;
54
54
  column: number;
55
55
  }, silent?: boolean): boolean;
56
56
  removeHyperLink(unitId: string, subUnitId: string, id: string): boolean;
57
- getHyperLink(unitId: string, subUnitId: string, id: string): import('@univerjs/core').Nullable<ICellHyperLink>;
58
- getHyperLinkByLocation(unitId: string, subUnitId: string, row: number, column: number): ICellHyperLink | undefined;
57
+ getHyperLink(unitId: string, subUnitId: string, id: string): import('@univerjs/core').Nullable<ISheetHyperLink>;
58
+ getHyperLinkByLocation(unitId: string, subUnitId: string, row: number, column: number): ISheetHyperLink | undefined;
59
59
  getHyperLinkByLocationSync(unitId: string, subUnitId: string, row: number, column: number): {
60
60
  display: string;
61
61
  id: string;
@@ -63,17 +63,17 @@ export declare class HyperLinkModel extends Disposable {
63
63
  column: number;
64
64
  payload: string;
65
65
  } | undefined;
66
- getSubUnit(unitId: string, subUnitId: string): ICellHyperLink[];
66
+ getSubUnit(unitId: string, subUnitId: string): ISheetHyperLink[];
67
67
  getUnit(unitId: string): {
68
68
  unitId: string;
69
69
  subUnitId: string;
70
- links: ICellHyperLink[];
70
+ links: ISheetHyperLink[];
71
71
  }[];
72
72
  deleteUnit(unitId: string): void;
73
73
  getAll(): {
74
74
  unitId: string;
75
75
  subUnitId: string;
76
- links: ICellHyperLink[];
76
+ links: ISheetHyperLink[];
77
77
  }[][];
78
78
  }
79
79
  export {};
@@ -27,7 +27,7 @@ export interface ICellLinkContent {
27
27
  */
28
28
  display?: string;
29
29
  }
30
- export interface ICellHyperLink extends ICellLinkContent {
30
+ export interface ISheetHyperLink extends ICellLinkContent {
31
31
  /**
32
32
  * unique id
33
33
  */
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(r,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets/facade"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets-hyper-link","@univerjs/sheets/facade","@univerjs/core"],n):(r=typeof globalThis<"u"?globalThis:r||self,n(r.UniverSheetsHyperLinkFacade={},r.UniverSheetsHyperLink,r.UniverSheetsFacade,r.UniverCore))})(this,function(r,n,a,o){"use strict";class p extends a.FWorkbook{createSheetHyperlink(e,t){return this._injector.get(n.SheetsHyperLinkParserService).buildHyperLink(this.getId(),e,t)}parseSheetHyperlink(e){return this._injector.get(n.SheetsHyperLinkParserService).parseHyperLink(e)}}a.FWorkbook.extend(p);class y extends a.FRange{setHyperLink(e,t){const s={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),link:{row:this._range.startRow,column:this._range.startColumn,payload:e,display:t,id:o.generateRandomId()}};return this._commandService.executeCommand(n.AddHyperLinkCommand.id,s)}getHyperLinks(){var t,s,d;const e=this._worksheet.getCellRaw(this._range.startRow,this._range.startColumn);return e!=null&&e.p?(d=(s=(t=e.p.body)==null?void 0:t.customRanges)==null?void 0:s.filter(i=>i.rangeType===o.CustomRangeType.HYPERLINK).map(i=>{var u,c,h,m,l;return{id:`${i.rangeId}`,startIndex:i.startIndex,endIndex:i.endIndex,url:(c=(u=i.properties)==null?void 0:u.url)!=null?c:"",label:(l=(m=(h=e.p)==null?void 0:h.body)==null?void 0:m.dataStream.slice(i.startIndex,i.endIndex+1).replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))!=null?l:""}}))!=null?d:[]:[]}updateHyperLink(e,t,s){const d={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e,payload:{payload:t,display:s}};return this._commandService.executeCommand(n.UpdateHyperLinkCommand.id,d)}cancelHyperLink(e){const t={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e};return this._commandService.syncExecuteCommand(n.CancelHyperLinkCommand.id,t)}}a.FRange.extend(y),r.FWorkbookHyperLinkMixin=p,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
1
+ (function(o,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-hyper-link","@univerjs/sheets/facade"],a):(o=typeof globalThis<"u"?globalThis:o||self,a(o.UniverSheetsHyperLinkFacade={},o.UniverCore,o.UniverSheetsHyperLink,o.UniverSheetsFacade))})(this,function(o,a,d,p){"use strict";var v=Object.defineProperty,y=Object.getOwnPropertyDescriptor,_=(n,e,r,t)=>{for(var i=t>1?void 0:t?y(e,r):e,s=n.length-1,h;s>=0;s--)(h=n[s])&&(i=(t?h(e,r,i):h(i))||i);return t&&i&&v(e,r,i),i},g=(n,e)=>(r,t)=>e(r,t,n);let c=class{constructor(n,e){this._workbook=n,this._parserService=e}getRangeUrl(n){return this._parserService.buildHyperLink(this._workbook.getId(),n.getSheetId(),n.getRange()),this}};c=_([g(1,a.Inject(d.SheetsHyperLinkParserService))],c);class u extends p.FWorkbook{createSheetHyperlink(e,r){return this._injector.get(d.SheetsHyperLinkParserService).buildHyperLink(this.getId(),e,r)}parseSheetHyperlink(e){return this._injector.get(d.SheetsHyperLinkParserService).parseHyperLink(e)}}p.FWorkbook.extend(u);class I extends p.FWorksheet{getUrl(){return this._injector.get(d.SheetsHyperLinkParserService).buildHyperLink(this._workbook.getUnitId(),this._worksheet.getSheetId())}}p.FWorksheet.extend(I);class x extends p.FRange{setHyperLink(e,r){const t={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),link:{row:this._range.startRow,column:this._range.startColumn,payload:e,display:r,id:a.generateRandomId()}};return this._commandService.executeCommand(d.AddHyperLinkCommand.id,t)}getHyperLinks(){var r,t,i;const e=this._worksheet.getCellRaw(this._range.startRow,this._range.startColumn);return e!=null&&e.p?(i=(t=(r=e.p.body)==null?void 0:r.customRanges)==null?void 0:t.filter(s=>s.rangeType===a.CustomRangeType.HYPERLINK).map(s=>{var h,l,S,k,m;return{id:`${s.rangeId}`,startIndex:s.startIndex,endIndex:s.endIndex,url:(l=(h=s.properties)==null?void 0:h.url)!=null?l:"",label:(m=(k=(S=e.p)==null?void 0:S.body)==null?void 0:k.dataStream.slice(s.startIndex,s.endIndex+1).replaceAll(a.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(a.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))!=null?m:""}}))!=null?i:[]:[]}updateHyperLink(e,r,t){const i={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e,payload:{payload:r,display:t}};return this._commandService.executeCommand(d.UpdateHyperLinkCommand.id,i)}cancelHyperLink(e){const r={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e};return this._commandService.syncExecuteCommand(d.CancelHyperLinkCommand.id,r)}getUrl(){return this._injector.get(d.SheetsHyperLinkParserService).buildHyperLink(this.getUnitId(),this.getSheetId(),this.getRange())}}p.FRange.extend(x),o.FWorkbookHyperLinkMixin=u,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(p,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("rxjs"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs","@univerjs/sheets","@univerjs/engine-formula","@univerjs/docs"],o):(p=typeof globalThis<"u"?globalThis:p||self,o(p.UniverSheetsHyperLink={},p.UniverCore,p.rxjs,p.UniverSheets,p.UniverEngineFormula,p.UniverDocs))})(this,function(p,o,T,m,C,x){"use strict";var Qe=Object.defineProperty;var et=(p,o,T)=>o in p?Qe(p,o,{enumerable:!0,configurable:!0,writable:!0,value:T}):p[o]=T;var L=(p,o,T)=>et(p,typeof o!="symbol"?o+"":o,T);var Re=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Ce=(r,t,e,n)=>{for(var i=n>1?void 0:n?Me(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Re(t,e,i),i},Ue=(r,t)=>(e,n)=>t(e,n,r);p.HyperLinkModel=class extends o.Disposable{constructor(e){super();L(this,"_linkUpdate$",new T.Subject);L(this,"linkUpdate$",this._linkUpdate$.asObservable());L(this,"_linkMap",new Map);L(this,"_linkPositionMap",new Map);this._univerInstanceService=e,this.disposeWithMe({dispose:()=>{this._linkUpdate$.complete()}})}_ensureMap(e,n){let i=this._linkMap.get(e);i||(i=new Map,this._linkMap.set(e,i));let s=i.get(n);s||(s=new o.ObjectMatrix,i.set(n,s));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let d=a.get(n);return d||(d=new Map,a.set(n,d)),{matrix:s,positionMap:d}}addHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n);return s.setValue(i.row,i.column,i),a.set(i.id,{row:i.row,column:i.column,link:i}),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:i,type:"add"}),!0}updateHyperLink(e,n,i,s,a=!1){const{matrix:d,positionMap:c}=this._ensureMap(e,n),l=c.get(i);if(!l)return!0;const u=d.getValue(l.row,l.column);return u&&(Object.assign(u,s),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:{display:u.display,payload:u.payload},id:i,type:"update",silent:a})),!0}updateHyperLinkRef(e,n,i,s,a=!1){const{matrix:d,positionMap:c}=this._ensureMap(e,n),l=c.get(i);if(!l)return!0;let u=d.getValue(l.row,l.column);return!u||u.id!==i?u=l.link:d.realDeleteValue(l.row,l.column),Object.assign(u,s),c.set(i,{...s,link:u}),d.setValue(s.row,s.column,u),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:s,id:i,type:"updateRef",silent:a}),!0}removeHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(i);if(!d)return!1;a.delete(i);const c=s.getValue(d.row,d.column);return c&&c.id===i&&s.realDeleteValue(d.row,d.column),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:d.link,type:"remove"}),!0}getHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(i);if(d)return s.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,i,s){const{matrix:a}=this._ensureMap(e,n);return a.getValue(i,s)}getHyperLinkByLocationSync(e,n,i,s){var g,f,_,h,y;const{matrix:a}=this._ensureMap(e,n),d=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET),c=(g=d==null?void 0:d.getSheetBySheetId(n))==null?void 0:g.getCellRaw(i,s),l=((y=(h=c==null?void 0:c.v)!=null?h:(_=(f=c==null?void 0:c.p)==null?void 0:f.body)==null?void 0:_.dataStream.slice(0,-2))!=null?y:"").toString(),u=a.getValue(i,s);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:i}=this._ensureMap(e,n),s=[];return i.forValue((a,d,c)=>{c&&s.push(c)}),s}getUnit(e){const n=this._linkMap.get(e);return n?Array.from(n.keys()).map(i=>{const s=this.getSubUnit(e,i);return{unitId:e,subUnitId:i,links:s}}):[]}deleteUnit(e){const n=this.getUnit(e);this._linkMap.delete(e),this._linkPositionMap.delete(e),this._linkUpdate$.next({type:"unload",unitId:e,unitLinks:n})}getAll(){return Array.from(this._linkMap.keys()).map(n=>this.getUnit(n))}},p.HyperLinkModel=Ce([Ue(0,o.IUniverInstanceService)],p.HyperLinkModel);var w=(r=>(r.SHEET="gid",r.RANGE="range",r.DEFINE_NAME="rangeid",r.INVALID="invalid",r.URL="url",r))(w||{});const Le="sheets-hyper-link.config",ae={},E={type:o.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,link:s}=t;return e.addHyperLink(n,i,s)}},k={type:o.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s}=t;return e.removeHyperLink(n,i,s)}},W={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,payload:s,id:a}=t;return e.updateHyperLink(n,i,a,s,!1)}},B={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s,row:a,column:d,silent:c}=t;return e.updateHyperLinkRef(n,i,s,{row:a,column:d},c)}},K={type:o.CommandType.MUTATION,id:"sheets.mutation.update-rich-hyper-link",handler(r,t){var _,h,y;if(!t)return!1;const{unitId:e,subUnitId:n,row:i,col:s,id:a,url:d}=t,c=r.get(o.IUniverInstanceService),l=m.getSheetCommandTarget(c,{unitId:e,subUnitId:n});if(!l)return!1;const{worksheet:u}=l,g=u.getCellRaw(i,s),f=(y=(h=(_=g==null?void 0:g.p)==null?void 0:_.body)==null?void 0:h.customRanges)==null?void 0:y.find(v=>v.rangeType===o.CustomRangeType.HYPERLINK&&v.rangeId===a);return f&&(f.properties.url=d),!0}},oe="SHEET_HYPER_LINK_PLUGIN",$="err";var we=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,ke=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ee(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&we(t,e,i),i},z=(r,t)=>(e,n)=>t(e,n,r);let G=class extends o.Disposable{constructor(t,e,n,i){super();L(this,"_disposableMap",new Map);L(this,"_watchDisposableMap",new Map);L(this,"_rangeDisableMap",new Map);L(this,"_rangeWatcherMap",new Map);L(this,"_handlePositionChange",(t,e,n,i,s)=>{const a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};return i?{redos:[{id:B.id,params:{unitId:t,subUnitId:e,id:n.id,row:i.startRow,column:i.startColumn,silent:s}}],undos:[{id:B.id,params:{unitId:t,subUnitId:e,id:n.id,row:a.startRow,column:a.startColumn,silent:s}}]}:{redos:[{id:k.id,params:{unitId:t,subUnitId:e,id:n.id}}],undos:[{id:E.id,params:{unitId:t,subUnitId:e,link:n}}]}});this._refRangeService=t,this._hyperLinkModel=e,this._selectionManagerService=n,this._commandService=i,this._initData(),this._initRefRange()}_registerPosition(t,e,n){const i=n.id,s={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row},a=d=>{const c=m.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,d,{selectionManagerService:this._selectionManagerService}),l=Array.isArray(c)?c[0]:c;return l&&l.startColumn===s.startColumn&&l.startRow===s.startRow?{undos:[],redos:[]}:this._handlePositionChange(t,e,n,l,!1)};this._disposableMap.set(i,this._refRangeService.registerRefRange(s,a,t,e))}_watchPosition(t,e,n){const i=n.id,s={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._watchDisposableMap.set(i,this._refRangeService.watchRange(t,e,s,(a,d)=>{const{redos:c}=this._handlePositionChange(t,e,n,d,!0);o.sequenceExecuteAsync(c,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(t){const e=this._disposableMap.get(t);e==null||e.dispose(),this._disposableMap.delete(t)}_unwatchPosition(t){const e=this._watchDisposableMap.get(t);e==null||e.dispose(),this._watchDisposableMap.delete(t)}_registerRange(t,e,n,i=!1){var s,a,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(s=c.get("gid"))!=null?s:"",range:(a=c.get("range"))!=null?a:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,g=C.deserializeRangeWithSheet(l.range).range;if(o.isValidRange(g)&&l.range!==$){const f=_=>{const h=m.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(g,_,{selectionManagerService:this._selectionManagerService});return h&&C.serializeRange(h)===C.serializeRange(g)?{redos:[],undos:[]}:{redos:[{id:W.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${h?C.serializeRange(h):"err"}`}}}],undos:[{id:W.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:n}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(g,f,t,u)),i||this._rangeWatcherMap.set(e,this._refRangeService.watchRange(t,u,g,(_,h)=>{this._hyperLinkModel.updateHyperLink(t,u,e,{payload:`#gid=${u}&range=${h?C.serializeRange(h):"err"}`},!0)},!0))}}}}_unregisterRange(t){const e=this._rangeDisableMap.get(t);e==null||e.dispose(),this._rangeDisableMap.delete(t)}_unwatchRange(t){const e=this._rangeWatcherMap.get(t);e==null||e.dispose(),this._rangeWatcherMap.delete(t)}_initData(){this._hyperLinkModel.getAll().forEach(e=>{e.forEach(n=>{const{unitId:i,subUnitId:s,links:a}=n;a.forEach(d=>{this._registerPosition(i,s,d),this._watchPosition(i,s,d),this._registerRange(i,d.id,d.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(t=>{switch(t.type){case"add":{this._registerPosition(t.unitId,t.subUnitId,t.payload),this._watchPosition(t.unitId,t.subUnitId,t.payload),this._registerRange(t.unitId,t.payload.id,t.payload.payload);break}case"remove":{this._unregisterPosition(t.payload.id),this._unwatchPosition(t.payload.id),this._unregisterRange(t.payload.id),this._unwatchRange(t.payload.id);break}case"updateRef":{const{unitId:e,subUnitId:n,id:i,silent:s}=t,a=this._hyperLinkModel.getHyperLink(e,n,i);if(!a)return;this._unregisterPosition(i),this._registerPosition(e,n,a),s||(this._unwatchPosition(i),this._watchPosition(e,n,a));break}case"unload":{const{unitLinks:e}=t;e.forEach(n=>{const{links:i}=n;i.forEach(s=>{this._unregisterPosition(s.id),this._unwatchPosition(s.id),this._unregisterRange(s.id),this._unwatchRange(s.id)})});break}case"update":{t.silent||this._unwatchRange(t.id),this._unregisterRange(t.id),this._registerRange(t.unitId,t.id,t.payload.payload,t.silent);break}}})),this.disposeWithMe(o.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};G=ke([z(0,o.Inject(m.RefRangeService)),z(1,o.Inject(p.HyperLinkModel)),z(2,o.Inject(m.SheetsSelectionsService)),z(3,o.ICommandService)],G);var Pe=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Te=(r,t,e,n)=>{for(var i=n>1?void 0:n?be(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Pe(t,e,i),i},te=(r,t)=>(e,n)=>t(e,n,r);let Y=class extends o.Disposable{constructor(r,t,e){super(),this._sheetInterceptorService=r,this._univerInstanceService=t,this._hyperLinkModel=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var t;if(r.id===m.RemoveSheetCommand.id){const e=r.params,n=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!n)return{redos:[],undos:[]};const i=n.getUnitId(),s=e.subUnitId||((t=n.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const a=this._hyperLinkModel.getSubUnit(i,s),d=a.map(l=>({id:k.id,params:{unitId:i,subUnitId:s,id:l.id}})),c=a.map(l=>({id:E.id,params:{unitId:i,subUnitId:s,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};Y=Te([te(0,o.Inject(m.SheetInterceptorService)),te(1,o.IUniverInstanceService),te(2,o.Inject(p.HyperLinkModel))],Y);var He=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Oe=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ne(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&He(t,e,i),i},ne=(r,t)=>(e,n)=>t(e,n,r);let q=class extends o.Disposable{constructor(t,e,n){super();L(this,"_refRangeMap",new Map);this._commandService=t,this._univerInstanceService=e,this._refRangeService=n,this._initWorkbookLoad(),this._initWorkbookUnload(),this._initSetRangesListener()}_enusreMap(t,e){let n=this._refRangeMap.get(t);n||(n=new Map,this._refRangeMap.set(t,n));let i=n.get(e);return i||(i=new o.ObjectMatrix,n.set(e,i)),i}_isLegalRangeUrl(t,e){var i,s,a;const n=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!n)return null;if(e&&e.startsWith("#")){const d=new URLSearchParams(e.slice(1)),c={gid:(i=d.get("gid"))!=null?i:"",range:(s=d.get("range"))!=null?s:"",rangeid:(a=d.get("rangeid"))!=null?a:""};if(c.range&&c.gid){const l=c.gid,u=n.getSheetBySheetId(l);if(!u)return null;const g=C.deserializeRangeWithSheet(c.range).range;if(o.isValidRange(g,u)&&c.range!==$)return{range:g,worksheet:u}}}return null}_registerRange(t,e,n,i,s){var d,c,l,u;const a=this._enusreMap(t,e);if((c=(d=s.body)==null?void 0:d.customRanges)!=null&&c.some(g=>{var f;return g.rangeType===o.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(t,(f=g.properties)==null?void 0:f.url)})){const g=new o.DisposableCollection;let f=!1;(u=(l=s.body)==null?void 0:l.customRanges)==null||u.forEach(_=>{var h;if(_.rangeType===o.CustomRangeType.HYPERLINK){const y=(h=_.properties)==null?void 0:h.url,v=this._isLegalRangeUrl(t,y);if(v){const{range:S,worksheet:U}=v;f=!0,g.add(this._refRangeService.registerRefRange(S,I=>{const R=m.handleDefaultRangeChangeWithEffectRefCommands(S,I);return R&&o.Rectangle.equals(R,S)?{preRedos:[],preUndos:[],redos:[],undos:[]}:{preRedos:[{id:K.id,params:{unitId:t,subUnitId:e,row:n,col:i,id:_.rangeId,url:`#gid=${e}&range=${R?C.serializeRange(R):$}`}}],undos:[{id:K.id,params:{unitId:t,subUnitId:e,row:n,col:i,id:_.rangeId,url:y}}],redos:[]}},U.getUnitId(),U.getSheetId()))}}}),f&&a.setValue(n,i,g)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId(),a=this._enusreMap(n,s);i.getCellMatrix().forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,s,d,c,l.p)})})};this._univerInstanceService.getAllUnitsForType(o.UniverInstanceType.UNIVER_SHEET).forEach(e=>{t(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===o.UniverInstanceType.UNIVER_SHEET&&t(e)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===o.UniverInstanceType.UNIVER_SHEET){const e=t,n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId();this._enusreMap(n,s).forValue((d,c,l)=>{l&&l.dispose()})}),this._refRangeMap.delete(n)}})}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===m.SetRangeValuesMutation.id){const e=t.params,{unitId:n,subUnitId:i,cellValue:s}=e,a=this._enusreMap(n,i);s&&new o.ObjectMatrix(s).forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,i,d,c,l.p)})}})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===K.id){const e=t.params,{unitId:n,subUnitId:i,row:s,col:a}=e,d=m.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:i}),l=this._enusreMap(n,i).getValue(s,a);if(l&&l.dispose(),d){const{worksheet:u}=d,g=u.getCellRaw(s,a);g&&g.p&&this._registerRange(n,i,s,a,g.p)}}}))}};q=Oe([ne(0,o.ICommandService),ne(1,o.IUniverInstanceService),ne(2,o.Inject(m.RefRangeService))],q);var De=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,$e=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ve(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&De(t,e,i),i},F=(r,t)=>(e,n)=>t(e,n,r);let J=class extends o.Disposable{constructor(r,t,e,n){super(),this._sheetInterceptorService=r,this._hyperLinkModel=t,this._selectionManagerService=e,this._univerInstanceService=n,this._initCommandInterceptor(),this._initAfterEditor()}_initCommandInterceptor(){this._initSetRangeValuesCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{if(r.id===m.SetRangeValuesCommand.id){const t=r.params,{unitId:e,subUnitId:n}=t,i=[],s=[];return t.cellValue&&new o.ObjectMatrix(t.cellValue).forValue((a,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,d);c&&(i.push({id:k.id,params:{unitId:e,subUnitId:n,id:c.id}}),s.push({id:E.id,params:{unitId:e,subUnitId:n,link:c}}))}),{undos:s,redos:i}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{if(r.id===m.ClearSelectionContentCommand.id||r.id===m.ClearSelectionAllCommand.id||r.id===m.ClearSelectionFormatCommand.id){const t=[],e=[],n=this._selectionManagerService.getCurrentLastSelection(),i=m.getSheetCommandTarget(this._univerInstanceService);if(n&&i){const{unitId:s,subUnitId:a}=i;o.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(s,a,d,c);l&&(t.push({id:k.id,params:{unitId:s,subUnitId:a,id:l.id}}),e.push({id:E.id,params:{unitId:s,subUnitId:a,link:l}}))})}return{redos:t,undos:e}}return{redos:[],undos:[]}}}))}_initAfterEditor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(m.AFTER_CELL_EDIT,{handler:(r,t,e)=>{if(!r||r.p)return e(r);if(typeof r.v=="string"&&o.Tools.isLegalUrl(r.v)&&r.v[r.v.length-1]!==" "){const{unitId:n,subUnitId:i}=t,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),a=s==null?void 0:s.getSheetBySheetId(i);if(!a)return e(r);const d=a.getBlankCellDocumentModel(r);if(!d.documentModel)return e(r);const c=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:r.v.length,collapsed:!1},body:{dataStream:`${r.v}`,customRanges:[{startIndex:0,endIndex:r.v.length-1,rangeId:o.generateRandomId(),rangeType:o.CustomRangeType.HYPERLINK,properties:{url:r.v}}]},doc:d.documentModel});if(!c)return e(r);const l=d.documentModel.getBody();return o.TextX.apply(l,c.serialize()),e({...r,p:{id:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:l,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(r)}}))}};J=$e([F(0,o.Inject(m.SheetInterceptorService)),F(1,o.Inject(p.HyperLinkModel)),F(2,o.Inject(m.SheetsSelectionsService)),F(3,o.IUniverInstanceService)],J);var de=(r=>(r[r.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",r[r.UNIVER_DOC=1]="UNIVER_DOC",r[r.UNIVER_SHEET=2]="UNIVER_SHEET",r[r.UNIVER_SLIDE=3]="UNIVER_SLIDE",r[r.UNIVER_PROJECT=4]="UNIVER_PROJECT",r[r.UNRECOGNIZED=-1]="UNRECOGNIZED",r))(de||{}),je=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,xe=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ae(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&je(t,e,i),i},ce=(r,t)=>(e,n)=>t(e,n,r);let X=class extends o.Disposable{constructor(r,t){super(),this._resourceManagerService=r,this._hyperLinkModel=t,this._initSnapshot()}_initSnapshot(){const r=e=>{const n=this._hyperLinkModel.getUnit(e),i={};return n?(n.forEach(s=>{i[s.subUnitId]=s.links.map(({display:a,...d})=>d)}),JSON.stringify(i)):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:oe,businesses:[de.UNIVER_SHEET],toJson:e=>r(e),parseJson:e=>t(e),onUnLoad:e=>{this._hyperLinkModel.deleteUnit(e)},onLoad:async(e,n)=>{Object.keys(n).forEach(i=>{n[i].forEach(a=>{this._hyperLinkModel.addHyperLink(e,i,a)})})}}))}};X=xe([ce(0,o.IResourceManagerService),ce(1,o.Inject(p.HyperLinkModel))],X);const le={type:o.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(r,t){if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:g}=d,{link:f}=t,{payload:_,display:h,row:y,column:v,id:S}=f,U=g.getCell(y,v),I=g.getBlankCellDocumentModel(U),R=I.documentModel.getSnapshot(),M=o.Tools.deepClone(R.body);if(!M)return!1;let P;if(h?P=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:M.dataStream.length-2,collapsed:M.dataStream.length-2===0},body:{dataStream:`${h}`,customRanges:[{startIndex:0,endIndex:h.length-1,rangeType:o.CustomRangeType.HYPERLINK,rangeId:S,properties:{url:_}}]},doc:I.documentModel}):P=o.BuildTextUtils.customRange.add({body:M,ranges:[{startOffset:0,endOffset:M.dataStream.length-2,collapsed:!1}],rangeId:S,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:_,refId:S}}),!P)return!1;const j=o.TextX.apply(M,P.serialize()),b={p:{...R,body:j},t:o.CellValueType.STRING},N=await a.onWriteCell(u,g,y,v,b),O={unitId:c,subUnitId:l,cellValue:{[f.row]:{[f.column]:N}}},re={id:m.SetRangeValuesMutation.id,params:O},Q=m.SetRangeValuesUndoMutationFactory(r,O),se={id:m.SetRangeValuesMutation.id,params:Q},A=[re],D=[se],V=s.getHyperLinkByLocation(c,l,y,v);return V&&(A.push({id:k.id,params:{unitId:c,subUnitId:l,id:V.id}}),D.push({id:E.id,params:{unitId:c,subUnitId:l,link:V}})),await o.sequenceExecuteAsync(A,e)?(n.pushUndoRedo({redoMutations:A,undoMutations:D,unitID:c}),!0):!1}},ue={id:"sheets.command.add-rich-hyper-link",type:o.CommandType.COMMAND,handler:async(r,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,i=r.get(o.ICommandService),s=o.generateRandomId(),{payload:a}=n,d=x.addCustomRangeBySelectionFactory(r,{unitId:e,rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:a,refId:s}});return d?i.syncExecuteCommand(d.id,d.params):!1}},pe={type:o.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(r,t){var b,N;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=m.getSheetCommandTarget(i,t);if(!a)return!1;const{row:d,column:c,id:l}=t,{unitId:u,subUnitId:g,worksheet:f}=a,_=f.getCell(d,c);if(!_)return!1;const h=f.getCellDocumentModelWithFormula(_);if(!(h!=null&&h.documentModel))return!1;const y=o.Tools.deepClone(h.documentModel.getSnapshot()),v=(N=(b=y.body)==null?void 0:b.customRanges)==null?void 0:N.find(O=>`${O.rangeId}`===l);if(!v)return!1;const S=o.BuildTextUtils.customRange.delete(r,{documentDataModel:h.documentModel,rangeId:v.rangeId});if(!S)return!1;const U=o.TextX.apply(y.body,S.serialize()),I=[],R=[],M={unitId:u,subUnitId:g,cellValue:{[d]:{[c]:{p:{...y,body:U},t:o.CellValueType.STRING}}}};I.push({id:m.SetRangeValuesMutation.id,params:M});const P=m.SetRangeValuesUndoMutationFactory(r,M);R.push({id:m.SetRangeValuesMutation.id,params:P});const j=s.getHyperLinkByLocation(u,g,d,c);return j&&(I.push({id:k.id,params:{unitId:u,subUnitId:g,id:l}}),R.push({id:E.id,params:{unitId:u,subUnitId:g,link:{...j}}})),o.sequenceExecute(I,e).result?(n.pushUndoRedo({redoMutations:I,undoMutations:R,unitID:u}),!0):!1}},ge={type:o.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(r,t){var u,g;if(!t)return!1;const{id:e,documentId:n}=t,i=r.get(o.ICommandService),a=r.get(o.IUniverInstanceService).getUnit(n,o.UniverInstanceType.UNIVER_DOC),d=(g=(u=a==null?void 0:a.getBody())==null?void 0:u.customRanges)==null?void 0:g.find(f=>f.rangeId===e);let c=null;d&&d.endIndex===a.getBody().dataStream.length-3&&(c={dataStream:" "});const l=x.deleteCustomRangeFactory(r,{unitId:n,rangeId:e,insert:c});return l?i.syncExecuteCommand(l.id,l.params):!1}},he={type:o.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(r,t){var ve,Se,Ie;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,{unitId:t.unitId,subUnitId:t.subUnitId});if(!d)return!1;const{payload:c,row:l,column:u,id:g}=t,{workbook:f,worksheet:_,unitId:h,subUnitId:y}=d,{payload:v,display:S=""}=c,U=_.getCell(l,u);if(!U)return!1;const I=_.getCellDocumentModelWithFormula(U);if(!(I!=null&&I.documentModel))return!1;const R=I.documentModel.getSnapshot(),M=(Se=(ve=R.body)==null?void 0:ve.customRanges)==null?void 0:Se.find(Ze=>`${Ze.rangeId}`===g);if(!M)return!1;const P=o.generateRandomId(),H=(Ie=o.getBodySlice(I.documentModel.getBody(),M.startIndex,M.endIndex+1).textRuns)==null?void 0:Ie[0];H&&(H.ed=S.length+1);const b=x.replaceSelectionFactory(r,{unitId:h,body:{dataStream:`${S}`,customRanges:[{rangeId:P,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:S.length-1,properties:{url:v}}],textRuns:H?[H]:void 0},selection:{startOffset:M.startIndex,endOffset:M.endIndex+1,collapsed:!1},doc:I.documentModel});if(!b)return!1;const N=o.TextX.apply(o.Tools.deepClone(R.body),b.textX.serialize()),O={p:{...R,body:N},t:o.CellValueType.STRING},re=await a.onWriteCell(f,_,l,u,O),Q={id:m.SetRangeValuesMutation.id,params:{unitId:h,subUnitId:y,cellValue:{[l]:{[u]:re}}}},se=m.SetRangeValuesUndoMutationFactory(r,Q.params),A={id:m.SetRangeValuesMutation.id,params:se},D=[Q],V=[A],ee=s.getHyperLinkByLocation(h,y,l,u);return ee&&(D.push({id:k.id,params:{unitId:h,subUnitId:y,id:ee.id}}),V.push({id:E.id,params:{unitId:h,subUnitId:y,link:ee}})),await o.sequenceExecuteAsync(D,e)?(n.pushUndoRedo({redoMutations:D,undoMutations:V,unitID:h}),!0):!1}},me={type:o.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(r,t)=>{var h,y,v,S;if(!t)return!1;const{documentId:e,payload:n,id:i}=t,s=r.get(o.IUniverInstanceService),a=r.get(o.ICommandService),d=s.getUnit(e,o.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(y=(h=d.getBody())==null?void 0:h.customRanges)==null?void 0:y.find(U=>U.rangeId===i);if(!c)return!1;const l=(v=t.payload.display)!=null?v:"",u=o.generateRandomId(),f=(S=o.getBodySlice(d.getBody(),c.startIndex,c.endIndex+1).textRuns)==null?void 0:S[0];f&&(f.ed=l.length+1);const _=x.replaceSelectionFactory(r,{unitId:e,body:{dataStream:`${l}`,customRanges:[{rangeId:u,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:l.length-1,properties:{url:n.payload}}],textRuns:f?[f]:void 0},selection:{startOffset:c.startIndex,endOffset:c.endIndex+1,collapsed:!1},doc:d});return _?a.syncExecuteCommand(_.id,_.params):!1}};var We=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,Ke=(r,t,e,n)=>{for(var i=n>1?void 0:n?Be(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&We(t,e,i),i},ze=(r,t)=>(e,n)=>t(e,n,r);let Z=class extends o.Disposable{constructor(r){super(),this._commandService=r,this._registerCommands()}_registerCommands(){[le,he,pe,me,ge,ue,E,W,k,B,K].forEach(r=>{this._commandService.registerCommand(r)})}};Z=Ke([ze(0,o.ICommandService)],Z);var Ge=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,qe=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ye(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Ge(t,e,i),i},ie=(r,t)=>(e,n)=>t(e,n,r);p.SheetsHyperLinkParserService=class{constructor(t,e,n){this._univerInstanceService=t,this._localeService=e,this._definedNamesService=n}buildHyperLink(t,e,n){return`#${w.SHEET}=${e}${n?`&${typeof n=="string"?w.DEFINE_NAME:w.RANGE}=${typeof n=="string"?n:C.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,i,s;if(t.startsWith("#")){const a=new URLSearchParams(t.slice(1)),d={gid:(e=a.get("gid"))!=null?e:"",range:(n=a.get("range"))!=null?n:"",rangeid:(i=a.get("rangeid"))!=null?i:"",unitid:(s=a.get("unitid"))!=null?s:""},c=this._getURLName(d);return{type:c.type,name:c.name,url:t,searchObj:d}}else return{type:w.URL,name:t,url:t,searchObj:null}}_getURLName(t){var u;const{gid:e,range:n,rangeid:i,unitid:s}=t,a=s?this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),d={type:w.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!a)return d;const c=e?a.getSheetBySheetId(e):a.getActiveSheet(),l=(u=c==null?void 0:c.getName())!=null?u:"";if(n){if(!c)return d;const g=C.deserializeRangeWithSheet(n).range;return o.isValidRange(g,c)&&n!==$?{type:w.RANGE,name:C.serializeRangeWithSheet(l,g)}:d}if(i){const g=this._definedNamesService.getValueById(a.getUnitId(),i);return g?{type:w.DEFINE_NAME,name:g.formulaOrRefString}:d}if(e){const g=a.getSheetBySheetId(e);return g?{type:w.SHEET,name:g.getName()}:d}return d}},p.SheetsHyperLinkParserService=qe([ie(0,o.IUniverInstanceService),ie(1,o.Inject(o.LocaleService)),ie(2,C.IDefinedNamesService)],p.SheetsHyperLinkParserService);var fe=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,Je=(r,t,e)=>t in r?fe(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xe=(r,t,e,n)=>{for(var i=n>1?void 0:n?Fe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&fe(t,e,i),i},_e=(r,t)=>(e,n)=>t(e,n,r),ye=(r,t,e)=>Je(r,typeof t!="symbol"?t+"":t,e);p.UniverSheetsHyperLinkPlugin=class extends o.Plugin{constructor(t=ae,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...i}=o.merge({},ae,this._config);this._configService.setConfig(Le,i)}onStarting(){o.registerDependencies(this._injector,[[p.HyperLinkModel],[p.SheetsHyperLinkParserService],[X],[Z],[G],[J],[Y],[q]]),o.touchDependencies(this._injector,[[G],[X],[Z],[J],[Y],[q]])}},ye(p.UniverSheetsHyperLinkPlugin,"pluginName",oe),ye(p.UniverSheetsHyperLinkPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),p.UniverSheetsHyperLinkPlugin=Xe([o.DependentOn(m.UniverSheetsPlugin),_e(1,o.Inject(o.Injector)),_e(2,o.IConfigService)],p.UniverSheetsHyperLinkPlugin),p.AddHyperLinkCommand=le,p.AddHyperLinkMutation=E,p.AddRichHyperLinkCommand=ue,p.CancelHyperLinkCommand=pe,p.CancelRichHyperLinkCommand=ge,p.ERROR_RANGE=$,p.RemoveHyperLinkMutation=k,p.SheetHyperLinkType=w,p.UpdateHyperLinkCommand=he,p.UpdateHyperLinkMutation=W,p.UpdateHyperLinkRefMutation=B,p.UpdateRichHyperLinkCommand=me,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
1
+ (function(p,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("rxjs"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs","@univerjs/sheets","@univerjs/engine-formula","@univerjs/docs"],o):(p=typeof globalThis<"u"?globalThis:p||self,o(p.UniverSheetsHyperLink={},p.UniverCore,p.rxjs,p.UniverSheets,p.UniverEngineFormula,p.UniverDocs))})(this,function(p,o,T,m,C,x){"use strict";var Qe=Object.defineProperty;var et=(p,o,T)=>o in p?Qe(p,o,{enumerable:!0,configurable:!0,writable:!0,value:T}):p[o]=T;var L=(p,o,T)=>et(p,typeof o!="symbol"?o+"":o,T);var Re=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Ce=(r,t,e,n)=>{for(var i=n>1?void 0:n?Me(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Re(t,e,i),i},Ue=(r,t)=>(e,n)=>t(e,n,r);p.HyperLinkModel=class extends o.Disposable{constructor(e){super();L(this,"_linkUpdate$",new T.Subject);L(this,"linkUpdate$",this._linkUpdate$.asObservable());L(this,"_linkMap",new Map);L(this,"_linkPositionMap",new Map);this._univerInstanceService=e,this.disposeWithMe({dispose:()=>{this._linkUpdate$.complete()}})}_ensureMap(e,n){let i=this._linkMap.get(e);i||(i=new Map,this._linkMap.set(e,i));let s=i.get(n);s||(s=new o.ObjectMatrix,i.set(n,s));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let d=a.get(n);return d||(d=new Map,a.set(n,d)),{matrix:s,positionMap:d}}addHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n);return s.setValue(i.row,i.column,i),a.set(i.id,{row:i.row,column:i.column,link:i}),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:i,type:"add"}),!0}updateHyperLink(e,n,i,s,a=!1){const{matrix:d,positionMap:c}=this._ensureMap(e,n),l=c.get(i);if(!l)return!0;const u=d.getValue(l.row,l.column);return u&&(Object.assign(u,s),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:{display:u.display,payload:u.payload},id:i,type:"update",silent:a})),!0}updateHyperLinkRef(e,n,i,s,a=!1){const{matrix:d,positionMap:c}=this._ensureMap(e,n),l=c.get(i);if(!l)return!0;let u=d.getValue(l.row,l.column);return!u||u.id!==i?u=l.link:d.realDeleteValue(l.row,l.column),Object.assign(u,s),c.set(i,{...s,link:u}),d.setValue(s.row,s.column,u),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:s,id:i,type:"updateRef",silent:a}),!0}removeHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(i);if(!d)return!1;a.delete(i);const c=s.getValue(d.row,d.column);return c&&c.id===i&&s.realDeleteValue(d.row,d.column),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:d.link,type:"remove"}),!0}getHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(i);if(d)return s.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,i,s){const{matrix:a}=this._ensureMap(e,n);return a.getValue(i,s)}getHyperLinkByLocationSync(e,n,i,s){var g,f,_,h,y;const{matrix:a}=this._ensureMap(e,n),d=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET),c=(g=d==null?void 0:d.getSheetBySheetId(n))==null?void 0:g.getCellRaw(i,s),l=((y=(h=c==null?void 0:c.v)!=null?h:(_=(f=c==null?void 0:c.p)==null?void 0:f.body)==null?void 0:_.dataStream.slice(0,-2))!=null?y:"").toString(),u=a.getValue(i,s);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:i}=this._ensureMap(e,n),s=[];return i.forValue((a,d,c)=>{c&&s.push(c)}),s}getUnit(e){const n=this._linkMap.get(e);return n?Array.from(n.keys()).map(i=>{const s=this.getSubUnit(e,i);return{unitId:e,subUnitId:i,links:s}}):[]}deleteUnit(e){const n=this.getUnit(e);this._linkMap.delete(e),this._linkPositionMap.delete(e),this._linkUpdate$.next({type:"unload",unitId:e,unitLinks:n})}getAll(){return Array.from(this._linkMap.keys()).map(n=>this.getUnit(n))}},p.HyperLinkModel=Ce([Ue(0,o.IUniverInstanceService)],p.HyperLinkModel);var w=(r=>(r.SHEET="gid",r.RANGE="range",r.DEFINE_NAME="rangeid",r.INVALID="invalid",r.URL="url",r))(w||{});const Le="sheets-hyper-link.config",ae={},E={type:o.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,link:s}=t;return e.addHyperLink(n,i,s)}},k={type:o.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s}=t;return e.removeHyperLink(n,i,s)}},W={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,payload:s,id:a}=t;return e.updateHyperLink(n,i,a,s,!1)}},B={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s,row:a,column:d,silent:c}=t;return e.updateHyperLinkRef(n,i,s,{row:a,column:d},c)}},K={type:o.CommandType.MUTATION,id:"sheets.mutation.update-rich-hyper-link",handler(r,t){var _,h,y;if(!t)return!1;const{unitId:e,subUnitId:n,row:i,col:s,id:a,url:d}=t,c=r.get(o.IUniverInstanceService),l=m.getSheetCommandTarget(c,{unitId:e,subUnitId:n});if(!l)return!1;const{worksheet:u}=l,g=u.getCellRaw(i,s),f=(y=(h=(_=g==null?void 0:g.p)==null?void 0:_.body)==null?void 0:h.customRanges)==null?void 0:y.find(S=>S.rangeType===o.CustomRangeType.HYPERLINK&&S.rangeId===a);return f&&(f.properties.url=d),!0}},oe="SHEET_HYPER_LINK_PLUGIN",$="err";var we=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,ke=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ee(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&we(t,e,i),i},z=(r,t)=>(e,n)=>t(e,n,r);let G=class extends o.Disposable{constructor(t,e,n,i){super();L(this,"_disposableMap",new Map);L(this,"_watchDisposableMap",new Map);L(this,"_rangeDisableMap",new Map);L(this,"_rangeWatcherMap",new Map);L(this,"_handlePositionChange",(t,e,n,i,s)=>{const a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};return i?{redos:[{id:B.id,params:{unitId:t,subUnitId:e,id:n.id,row:i.startRow,column:i.startColumn,silent:s}}],undos:[{id:B.id,params:{unitId:t,subUnitId:e,id:n.id,row:a.startRow,column:a.startColumn,silent:s}}]}:{redos:[{id:k.id,params:{unitId:t,subUnitId:e,id:n.id}}],undos:[{id:E.id,params:{unitId:t,subUnitId:e,link:n}}]}});this._refRangeService=t,this._hyperLinkModel=e,this._selectionManagerService=n,this._commandService=i,this._initData(),this._initRefRange()}_registerPosition(t,e,n){const i=n.id,s={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row},a=d=>{const c=m.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,d,{selectionManagerService:this._selectionManagerService}),l=Array.isArray(c)?c[0]:c;return l&&l.startColumn===s.startColumn&&l.startRow===s.startRow?{undos:[],redos:[]}:this._handlePositionChange(t,e,n,l,!1)};this._disposableMap.set(i,this._refRangeService.registerRefRange(s,a,t,e))}_watchPosition(t,e,n){const i=n.id,s={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._watchDisposableMap.set(i,this._refRangeService.watchRange(t,e,s,(a,d)=>{const{redos:c}=this._handlePositionChange(t,e,n,d,!0);o.sequenceExecuteAsync(c,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(t){const e=this._disposableMap.get(t);e==null||e.dispose(),this._disposableMap.delete(t)}_unwatchPosition(t){const e=this._watchDisposableMap.get(t);e==null||e.dispose(),this._watchDisposableMap.delete(t)}_registerRange(t,e,n,i=!1){var s,a,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(s=c.get("gid"))!=null?s:"",range:(a=c.get("range"))!=null?a:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,g=C.deserializeRangeWithSheet(l.range).range;if(o.isValidRange(g)&&l.range!==$){const f=_=>{const h=m.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(g,_,{selectionManagerService:this._selectionManagerService});return h&&C.serializeRange(h)===C.serializeRange(g)?{redos:[],undos:[]}:{redos:[{id:W.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${h?C.serializeRange(h):"err"}`}}}],undos:[{id:W.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:n}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(g,f,t,u)),i||this._rangeWatcherMap.set(e,this._refRangeService.watchRange(t,u,g,(_,h)=>{this._hyperLinkModel.updateHyperLink(t,u,e,{payload:`#gid=${u}&range=${h?C.serializeRange(h):"err"}`},!0)},!0))}}}}_unregisterRange(t){const e=this._rangeDisableMap.get(t);e==null||e.dispose(),this._rangeDisableMap.delete(t)}_unwatchRange(t){const e=this._rangeWatcherMap.get(t);e==null||e.dispose(),this._rangeWatcherMap.delete(t)}_initData(){this._hyperLinkModel.getAll().forEach(e=>{e.forEach(n=>{const{unitId:i,subUnitId:s,links:a}=n;a.forEach(d=>{this._registerPosition(i,s,d),this._watchPosition(i,s,d),this._registerRange(i,d.id,d.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(t=>{switch(t.type){case"add":{this._registerPosition(t.unitId,t.subUnitId,t.payload),this._watchPosition(t.unitId,t.subUnitId,t.payload),this._registerRange(t.unitId,t.payload.id,t.payload.payload);break}case"remove":{this._unregisterPosition(t.payload.id),this._unwatchPosition(t.payload.id),this._unregisterRange(t.payload.id),this._unwatchRange(t.payload.id);break}case"updateRef":{const{unitId:e,subUnitId:n,id:i,silent:s}=t,a=this._hyperLinkModel.getHyperLink(e,n,i);if(!a)return;this._unregisterPosition(i),this._registerPosition(e,n,a),s||(this._unwatchPosition(i),this._watchPosition(e,n,a));break}case"unload":{const{unitLinks:e}=t;e.forEach(n=>{const{links:i}=n;i.forEach(s=>{this._unregisterPosition(s.id),this._unwatchPosition(s.id),this._unregisterRange(s.id),this._unwatchRange(s.id)})});break}case"update":{t.silent||this._unwatchRange(t.id),this._unregisterRange(t.id),this._registerRange(t.unitId,t.id,t.payload.payload,t.silent);break}}})),this.disposeWithMe(o.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};G=ke([z(0,o.Inject(m.RefRangeService)),z(1,o.Inject(p.HyperLinkModel)),z(2,o.Inject(m.SheetsSelectionsService)),z(3,o.ICommandService)],G);var Pe=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Te=(r,t,e,n)=>{for(var i=n>1?void 0:n?be(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Pe(t,e,i),i},te=(r,t)=>(e,n)=>t(e,n,r);let Y=class extends o.Disposable{constructor(r,t,e){super(),this._sheetInterceptorService=r,this._univerInstanceService=t,this._hyperLinkModel=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var t;if(r.id===m.RemoveSheetCommand.id){const e=r.params,n=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!n)return{redos:[],undos:[]};const i=n.getUnitId(),s=e.subUnitId||((t=n.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const a=this._hyperLinkModel.getSubUnit(i,s),d=a.map(l=>({id:k.id,params:{unitId:i,subUnitId:s,id:l.id}})),c=a.map(l=>({id:E.id,params:{unitId:i,subUnitId:s,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};Y=Te([te(0,o.Inject(m.SheetInterceptorService)),te(1,o.IUniverInstanceService),te(2,o.Inject(p.HyperLinkModel))],Y);var He=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Oe=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ne(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&He(t,e,i),i},ne=(r,t)=>(e,n)=>t(e,n,r);let q=class extends o.Disposable{constructor(t,e,n){super();L(this,"_refRangeMap",new Map);this._commandService=t,this._univerInstanceService=e,this._refRangeService=n,this._initWorkbookLoad(),this._initWorkbookUnload(),this._initSetRangesListener()}_enusreMap(t,e){let n=this._refRangeMap.get(t);n||(n=new Map,this._refRangeMap.set(t,n));let i=n.get(e);return i||(i=new o.ObjectMatrix,n.set(e,i)),i}_isLegalRangeUrl(t,e){var i,s,a;const n=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!n)return null;if(e&&e.startsWith("#")){const d=new URLSearchParams(e.slice(1)),c={gid:(i=d.get("gid"))!=null?i:"",range:(s=d.get("range"))!=null?s:"",rangeid:(a=d.get("rangeid"))!=null?a:""};if(c.range&&c.gid){const l=c.gid,u=n.getSheetBySheetId(l);if(!u)return null;const g=C.deserializeRangeWithSheet(c.range).range;if(o.isValidRange(g,u)&&c.range!==$)return{range:g,worksheet:u}}}return null}_registerRange(t,e,n,i,s){var d,c,l,u;const a=this._enusreMap(t,e);if((c=(d=s.body)==null?void 0:d.customRanges)!=null&&c.some(g=>{var f;return g.rangeType===o.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(t,(f=g.properties)==null?void 0:f.url)})){const g=new o.DisposableCollection;let f=!1;(u=(l=s.body)==null?void 0:l.customRanges)==null||u.forEach(_=>{var h;if(_.rangeType===o.CustomRangeType.HYPERLINK){const y=(h=_.properties)==null?void 0:h.url,S=this._isLegalRangeUrl(t,y);if(S){const{range:v,worksheet:U}=S;f=!0,g.add(this._refRangeService.registerRefRange(v,I=>{const R=m.handleDefaultRangeChangeWithEffectRefCommands(v,I);return R&&o.Rectangle.equals(R,v)?{preRedos:[],preUndos:[],redos:[],undos:[]}:{preRedos:[{id:K.id,params:{unitId:t,subUnitId:e,row:n,col:i,id:_.rangeId,url:`#gid=${e}&range=${R?C.serializeRange(R):$}`}}],undos:[{id:K.id,params:{unitId:t,subUnitId:e,row:n,col:i,id:_.rangeId,url:y}}],redos:[]}},U.getUnitId(),U.getSheetId()))}}}),f&&a.setValue(n,i,g)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId(),a=this._enusreMap(n,s);i.getCellMatrix().forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,s,d,c,l.p)})})};this._univerInstanceService.getAllUnitsForType(o.UniverInstanceType.UNIVER_SHEET).forEach(e=>{t(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===o.UniverInstanceType.UNIVER_SHEET&&t(e)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===o.UniverInstanceType.UNIVER_SHEET){const e=t,n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId();this._enusreMap(n,s).forValue((d,c,l)=>{l&&l.dispose()})}),this._refRangeMap.delete(n)}})}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===m.SetRangeValuesMutation.id){const e=t.params,{unitId:n,subUnitId:i,cellValue:s}=e,a=this._enusreMap(n,i);s&&new o.ObjectMatrix(s).forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,i,d,c,l.p)})}})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===K.id){const e=t.params,{unitId:n,subUnitId:i,row:s,col:a}=e,d=m.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:i}),l=this._enusreMap(n,i).getValue(s,a);if(l&&l.dispose(),d){const{worksheet:u}=d,g=u.getCellRaw(s,a);g&&g.p&&this._registerRange(n,i,s,a,g.p)}}}))}};q=Oe([ne(0,o.ICommandService),ne(1,o.IUniverInstanceService),ne(2,o.Inject(m.RefRangeService))],q);var De=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,$e=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ve(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&De(t,e,i),i},F=(r,t)=>(e,n)=>t(e,n,r);let J=class extends o.Disposable{constructor(r,t,e,n){super(),this._sheetInterceptorService=r,this._hyperLinkModel=t,this._selectionManagerService=e,this._univerInstanceService=n,this._initCommandInterceptor(),this._initAfterEditor()}_initCommandInterceptor(){this._initSetRangeValuesCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{if(r.id===m.SetRangeValuesCommand.id){const t=r.params,{unitId:e,subUnitId:n}=t,i=[],s=[];return t.cellValue&&new o.ObjectMatrix(t.cellValue).forValue((a,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,d);c&&(i.push({id:k.id,params:{unitId:e,subUnitId:n,id:c.id}}),s.push({id:E.id,params:{unitId:e,subUnitId:n,link:c}}))}),{undos:s,redos:i}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{if(r.id===m.ClearSelectionContentCommand.id||r.id===m.ClearSelectionAllCommand.id||r.id===m.ClearSelectionFormatCommand.id){const t=[],e=[],n=this._selectionManagerService.getCurrentLastSelection(),i=m.getSheetCommandTarget(this._univerInstanceService);if(n&&i){const{unitId:s,subUnitId:a}=i;o.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(s,a,d,c);l&&(t.push({id:k.id,params:{unitId:s,subUnitId:a,id:l.id}}),e.push({id:E.id,params:{unitId:s,subUnitId:a,link:l}}))})}return{redos:t,undos:e}}return{redos:[],undos:[]}}}))}_initAfterEditor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(m.AFTER_CELL_EDIT,{handler:(r,t,e)=>{if(!r||r.p)return e(r);if(typeof r.v=="string"&&o.Tools.isLegalUrl(r.v)&&r.v[r.v.length-1]!==" "){const{unitId:n,subUnitId:i}=t,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),a=s==null?void 0:s.getSheetBySheetId(i);if(!a)return e(r);const d=a.getBlankCellDocumentModel(r);if(!d.documentModel)return e(r);const c=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:r.v.length,collapsed:!1},body:{dataStream:`${r.v}`,customRanges:[{startIndex:0,endIndex:r.v.length-1,rangeId:o.generateRandomId(),rangeType:o.CustomRangeType.HYPERLINK,properties:{url:r.v}}]},doc:d.documentModel});if(!c)return e(r);const l=d.documentModel.getBody();return o.TextX.apply(l,c.serialize()),e({...r,p:{id:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:l,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(r)}}))}};J=$e([F(0,o.Inject(m.SheetInterceptorService)),F(1,o.Inject(p.HyperLinkModel)),F(2,o.Inject(m.SheetsSelectionsService)),F(3,o.IUniverInstanceService)],J);var de=(r=>(r[r.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",r[r.UNIVER_DOC=1]="UNIVER_DOC",r[r.UNIVER_SHEET=2]="UNIVER_SHEET",r[r.UNIVER_SLIDE=3]="UNIVER_SLIDE",r[r.UNIVER_PROJECT=4]="UNIVER_PROJECT",r[r.UNRECOGNIZED=-1]="UNRECOGNIZED",r))(de||{}),je=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,xe=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ae(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&je(t,e,i),i},ce=(r,t)=>(e,n)=>t(e,n,r);let X=class extends o.Disposable{constructor(r,t){super(),this._resourceManagerService=r,this._hyperLinkModel=t,this._initSnapshot()}_initSnapshot(){const r=e=>{const n=this._hyperLinkModel.getUnit(e),i={};return n?(n.forEach(s=>{i[s.subUnitId]=s.links.map(({display:a,...d})=>d)}),JSON.stringify(i)):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:oe,businesses:[de.UNIVER_SHEET],toJson:e=>r(e),parseJson:e=>t(e),onUnLoad:e=>{this._hyperLinkModel.deleteUnit(e)},onLoad:async(e,n)=>{Object.keys(n).forEach(i=>{n[i].forEach(a=>{this._hyperLinkModel.addHyperLink(e,i,a)})})}}))}};X=xe([ce(0,o.IResourceManagerService),ce(1,o.Inject(p.HyperLinkModel))],X);const le={type:o.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(r,t){if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:g}=d,{link:f}=t,{payload:_,display:h,row:y,column:S,id:v}=f,U=g.getCell(y,S),I=g.getBlankCellDocumentModel(U),R=I.documentModel.getSnapshot(),M=o.Tools.deepClone(R.body);if(!M)return!1;let P;if(h?P=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:M.dataStream.length-2,collapsed:M.dataStream.length-2===0},body:{dataStream:`${h}`,customRanges:[{startIndex:0,endIndex:h.length-1,rangeType:o.CustomRangeType.HYPERLINK,rangeId:v,properties:{url:_}}]},doc:I.documentModel}):P=o.BuildTextUtils.customRange.add({body:M,ranges:[{startOffset:0,endOffset:M.dataStream.length-2,collapsed:!1}],rangeId:v,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:_,refId:v}}),!P)return!1;const j=o.TextX.apply(M,P.serialize()),b={p:{...R,body:j},t:o.CellValueType.STRING},N=await a.onWriteCell(u,g,y,S,b),O={unitId:c,subUnitId:l,cellValue:{[f.row]:{[f.column]:N}}},re={id:m.SetRangeValuesMutation.id,params:O},Q=m.SetRangeValuesUndoMutationFactory(r,O),se={id:m.SetRangeValuesMutation.id,params:Q},A=[re],D=[se],V=s.getHyperLinkByLocation(c,l,y,S);return V&&(A.push({id:k.id,params:{unitId:c,subUnitId:l,id:V.id}}),D.push({id:E.id,params:{unitId:c,subUnitId:l,link:V}})),await o.sequenceExecuteAsync(A,e)?(n.pushUndoRedo({redoMutations:A,undoMutations:D,unitID:c}),!0):!1}},ue={id:"sheets.command.add-rich-hyper-link",type:o.CommandType.COMMAND,handler:async(r,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,i=r.get(o.ICommandService),s=o.generateRandomId(),{payload:a}=n,d=x.addCustomRangeBySelectionFactory(r,{unitId:e,rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:a,refId:s}});return d?i.syncExecuteCommand(d.id,d.params):!1}},pe={type:o.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(r,t){var b,N;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=m.getSheetCommandTarget(i,t);if(!a)return!1;const{row:d,column:c,id:l}=t,{unitId:u,subUnitId:g,worksheet:f}=a,_=f.getCell(d,c);if(!_)return!1;const h=f.getCellDocumentModelWithFormula(_);if(!(h!=null&&h.documentModel))return!1;const y=o.Tools.deepClone(h.documentModel.getSnapshot()),S=(N=(b=y.body)==null?void 0:b.customRanges)==null?void 0:N.find(O=>`${O.rangeId}`===l);if(!S)return!1;const v=o.BuildTextUtils.customRange.delete({documentDataModel:h.documentModel,rangeId:S.rangeId});if(!v)return!1;const U=o.TextX.apply(y.body,v.serialize()),I=[],R=[],M={unitId:u,subUnitId:g,cellValue:{[d]:{[c]:{p:{...y,body:U},t:o.CellValueType.STRING}}}};I.push({id:m.SetRangeValuesMutation.id,params:M});const P=m.SetRangeValuesUndoMutationFactory(r,M);R.push({id:m.SetRangeValuesMutation.id,params:P});const j=s.getHyperLinkByLocation(u,g,d,c);return j&&(I.push({id:k.id,params:{unitId:u,subUnitId:g,id:l}}),R.push({id:E.id,params:{unitId:u,subUnitId:g,link:{...j}}})),o.sequenceExecute(I,e).result?(n.pushUndoRedo({redoMutations:I,undoMutations:R,unitID:u}),!0):!1}},ge={type:o.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(r,t){var u,g;if(!t)return!1;const{id:e,documentId:n}=t,i=r.get(o.ICommandService),a=r.get(o.IUniverInstanceService).getUnit(n,o.UniverInstanceType.UNIVER_DOC),d=(g=(u=a==null?void 0:a.getBody())==null?void 0:u.customRanges)==null?void 0:g.find(f=>f.rangeId===e);let c=null;d&&d.endIndex===a.getBody().dataStream.length-3&&(c={dataStream:" "});const l=x.deleteCustomRangeFactory(r,{unitId:n,rangeId:e,insert:c});return l?i.syncExecuteCommand(l.id,l.params):!1}},he={type:o.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(r,t){var Se,ve,Ie;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,{unitId:t.unitId,subUnitId:t.subUnitId});if(!d)return!1;const{payload:c,row:l,column:u,id:g}=t,{workbook:f,worksheet:_,unitId:h,subUnitId:y}=d,{payload:S,display:v=""}=c,U=_.getCell(l,u);if(!U)return!1;const I=_.getCellDocumentModelWithFormula(U);if(!(I!=null&&I.documentModel))return!1;const R=I.documentModel.getSnapshot(),M=(ve=(Se=R.body)==null?void 0:Se.customRanges)==null?void 0:ve.find(Ze=>`${Ze.rangeId}`===g);if(!M)return!1;const P=o.generateRandomId(),H=(Ie=o.getBodySlice(I.documentModel.getBody(),M.startIndex,M.endIndex+1).textRuns)==null?void 0:Ie[0];H&&(H.ed=v.length+1);const b=x.replaceSelectionFactory(r,{unitId:h,body:{dataStream:`${v}`,customRanges:[{rangeId:P,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:v.length-1,properties:{url:S}}],textRuns:H?[H]:void 0},selection:{startOffset:M.startIndex,endOffset:M.endIndex+1,collapsed:!1},doc:I.documentModel});if(!b)return!1;const N=o.TextX.apply(o.Tools.deepClone(R.body),b.textX.serialize()),O={p:{...R,body:N},t:o.CellValueType.STRING},re=await a.onWriteCell(f,_,l,u,O),Q={id:m.SetRangeValuesMutation.id,params:{unitId:h,subUnitId:y,cellValue:{[l]:{[u]:re}}}},se=m.SetRangeValuesUndoMutationFactory(r,Q.params),A={id:m.SetRangeValuesMutation.id,params:se},D=[Q],V=[A],ee=s.getHyperLinkByLocation(h,y,l,u);return ee&&(D.push({id:k.id,params:{unitId:h,subUnitId:y,id:ee.id}}),V.push({id:E.id,params:{unitId:h,subUnitId:y,link:ee}})),await o.sequenceExecuteAsync(D,e)?(n.pushUndoRedo({redoMutations:D,undoMutations:V,unitID:h}),!0):!1}},me={type:o.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(r,t)=>{var h,y,S,v;if(!t)return!1;const{documentId:e,payload:n,id:i}=t,s=r.get(o.IUniverInstanceService),a=r.get(o.ICommandService),d=s.getUnit(e,o.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(y=(h=d.getBody())==null?void 0:h.customRanges)==null?void 0:y.find(U=>U.rangeId===i);if(!c)return!1;const l=(S=t.payload.display)!=null?S:"",u=o.generateRandomId(),f=(v=o.getBodySlice(d.getBody(),c.startIndex,c.endIndex+1).textRuns)==null?void 0:v[0];f&&(f.ed=l.length+1);const _=x.replaceSelectionFactory(r,{unitId:e,body:{dataStream:`${l}`,customRanges:[{rangeId:u,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:l.length-1,properties:{url:n.payload}}],textRuns:f?[f]:void 0},selection:{startOffset:c.startIndex,endOffset:c.endIndex+1,collapsed:!1},doc:d});return _?a.syncExecuteCommand(_.id,_.params):!1}};var We=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,Ke=(r,t,e,n)=>{for(var i=n>1?void 0:n?Be(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&We(t,e,i),i},ze=(r,t)=>(e,n)=>t(e,n,r);let Z=class extends o.Disposable{constructor(r){super(),this._commandService=r,this._registerCommands()}_registerCommands(){[le,he,pe,me,ge,ue,E,W,k,B,K].forEach(r=>{this._commandService.registerCommand(r)})}};Z=Ke([ze(0,o.ICommandService)],Z);var Ge=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,qe=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ye(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Ge(t,e,i),i},ie=(r,t)=>(e,n)=>t(e,n,r);p.SheetsHyperLinkParserService=class{constructor(t,e,n){this._univerInstanceService=t,this._localeService=e,this._definedNamesService=n}buildHyperLink(t,e,n){return`#${w.SHEET}=${e}${n?`&${typeof n=="string"?w.DEFINE_NAME:w.RANGE}=${typeof n=="string"?n:C.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,i,s;if(t.startsWith("#")){const a=new URLSearchParams(t.slice(1)),d={gid:(e=a.get("gid"))!=null?e:"",range:(n=a.get("range"))!=null?n:"",rangeid:(i=a.get("rangeid"))!=null?i:"",unitid:(s=a.get("unitid"))!=null?s:""},c=this._getURLName(d);return{type:c.type,name:c.name,url:t,searchObj:d}}else return{type:w.URL,name:t,url:t,searchObj:null}}_getURLName(t){var u;const{gid:e,range:n,rangeid:i,unitid:s}=t,a=s?this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),d={type:w.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!a)return d;const c=e?a.getSheetBySheetId(e):a.getActiveSheet(),l=(u=c==null?void 0:c.getName())!=null?u:"";if(n){if(!c)return d;const g=C.deserializeRangeWithSheet(n).range;return o.isValidRange(g,c)&&n!==$?{type:w.RANGE,name:C.serializeRangeWithSheet(l,g)}:d}if(i){const g=this._definedNamesService.getValueById(a.getUnitId(),i);return g?{type:w.DEFINE_NAME,name:g.formulaOrRefString}:d}if(e){const g=a.getSheetBySheetId(e);return g?{type:w.SHEET,name:g.getName()}:d}return d}},p.SheetsHyperLinkParserService=qe([ie(0,o.IUniverInstanceService),ie(1,o.Inject(o.LocaleService)),ie(2,C.IDefinedNamesService)],p.SheetsHyperLinkParserService);var fe=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,Je=(r,t,e)=>t in r?fe(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xe=(r,t,e,n)=>{for(var i=n>1?void 0:n?Fe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&fe(t,e,i),i},_e=(r,t)=>(e,n)=>t(e,n,r),ye=(r,t,e)=>Je(r,typeof t!="symbol"?t+"":t,e);p.UniverSheetsHyperLinkPlugin=class extends o.Plugin{constructor(t=ae,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...i}=o.merge({},ae,this._config);this._configService.setConfig(Le,i)}onStarting(){o.registerDependencies(this._injector,[[p.HyperLinkModel],[p.SheetsHyperLinkParserService],[X],[Z],[G],[J],[Y],[q]]),o.touchDependencies(this._injector,[[G],[X],[Z],[J],[Y],[q]])}},ye(p.UniverSheetsHyperLinkPlugin,"pluginName",oe),ye(p.UniverSheetsHyperLinkPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),p.UniverSheetsHyperLinkPlugin=Xe([o.DependentOn(m.UniverSheetsPlugin),_e(1,o.Inject(o.Injector)),_e(2,o.IConfigService)],p.UniverSheetsHyperLinkPlugin),p.AddHyperLinkCommand=le,p.AddHyperLinkMutation=E,p.AddRichHyperLinkCommand=ue,p.CancelHyperLinkCommand=pe,p.CancelRichHyperLinkCommand=ge,p.ERROR_RANGE=$,p.RemoveHyperLinkMutation=k,p.SheetHyperLinkType=w,p.UpdateHyperLinkCommand=he,p.UpdateHyperLinkMutation=W,p.UpdateHyperLinkRefMutation=B,p.UpdateRichHyperLinkCommand=me,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-hyper-link",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -52,17 +52,17 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@univerjs/protocol": "0.1.40",
55
- "@univerjs/core": "0.5.3",
56
- "@univerjs/docs": "0.5.3",
57
- "@univerjs/sheets": "0.5.3",
58
- "@univerjs/engine-formula": "0.5.3"
55
+ "@univerjs/core": "0.5.4",
56
+ "@univerjs/docs": "0.5.4",
57
+ "@univerjs/engine-formula": "0.5.4",
58
+ "@univerjs/sheets": "0.5.4"
59
59
  },
60
60
  "devDependencies": {
61
61
  "rxjs": "^7.8.1",
62
62
  "typescript": "^5.7.2",
63
- "vite": "^6.0.6",
63
+ "vite": "^6.0.7",
64
64
  "vitest": "^2.1.8",
65
- "@univerjs-infra/shared": "0.5.3"
65
+ "@univerjs-infra/shared": "0.5.4"
66
66
  },
67
67
  "scripts": {
68
68
  "test": "vitest run",