@univerjs/sheets-hyper-link 0.10.11 → 0.10.12-nightly.202510251119

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var ve=Object.defineProperty;var Ie=(s,t,e)=>t in s?ve(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var C=(s,t,e)=>Ie(s,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),Q=require("@univerjs/docs"),h=require("@univerjs/sheets"),Re=require("rxjs"),k=require("@univerjs/engine-formula");var Me=Object.getOwnPropertyDescriptor,Ce=(s,t,e,n)=>{for(var r=n>1?void 0:n?Me(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},ke=(s,t)=>(e,n)=>t(e,n,s);exports.HyperLinkModel=class extends o.Disposable{constructor(e){super();C(this,"_linkUpdate$",new Re.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 i=r.get(n);i||(i=new o.ObjectMatrix,r.set(n,i));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:i,positionMap:d}}addHyperLink(e,n,r){const{matrix:i,positionMap:a}=this._ensureMap(e,n);return i.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,i,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,i),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,i,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,i),c.set(r,{...i,link:u}),d.setValue(i.row,i.column,u),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:i,id:r,type:"updateRef",silent:a}),!0}removeHyperLink(e,n,r){const{matrix:i,positionMap:a}=this._ensureMap(e,n),d=a.get(r);if(!d)return!1;a.delete(r);const c=i.getValue(d.row,d.column);return c&&c.id===r&&i.realDeleteValue(d.row,d.column),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:d.link,type:"remove"}),!0}getHyperLink(e,n,r){const{matrix:i,positionMap:a}=this._ensureMap(e,n),d=a.get(r);if(d)return i.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,r,i){const{matrix:a}=this._ensureMap(e,n);return a.getValue(r,i)}getHyperLinkByLocationSync(e,n,r,i){var p,m,f,g,y;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,i),l=((y=(g=c==null?void 0:c.v)!=null?g:(f=(m=c==null?void 0:c.p)==null?void 0:m.body)==null?void 0:f.dataStream.slice(0,-2))!=null?y:"").toString(),u=a.getValue(r,i);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:r}=this._ensureMap(e,n),i=[];return r.forValue((a,d,c)=>{c&&i.push(c)}),i}getUnit(e){const n=this._linkMap.get(e);return n?Array.from(n.keys()).map(r=>{const i=this.getSubUnit(e,r);return{unitId:e,subUnitId:r,links:i}}):[]}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=Ce([ke(0,o.IUniverInstanceService)],exports.HyperLinkModel);const U={type:o.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(s,t){if(!t)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,link:i}=t;return e.addHyperLink(n,r,i)}},w={type:o.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(s,t){if(!t)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,id:i}=t;return e.removeHyperLink(n,r,i)}},ue={type:o.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(s,t){if(!t)return!1;const e=s.get(o.ICommandService),n=s.get(o.IUndoRedoService),r=s.get(o.IUniverInstanceService),i=s.get(exports.HyperLinkModel),a=s.get(h.SheetInterceptorService),d=h.getSheetCommandTarget(r,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:p}=d,{link:m}=t,{payload:f,display:g,row:y,column:_,id:S}=m,M=p.getCell(y,_),v=p.getBlankCellDocumentModel(M,y,_),I=v.documentModel.getSnapshot(),R=o.Tools.deepClone(I.body);if(!R)return!1;let E;if(g?E=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:R.dataStream.length-2,collapsed:R.dataStream.length-2===0},body:{dataStream:`${g}`,customRanges:[{startIndex:0,endIndex:g.length-1,rangeType:o.CustomRangeType.HYPERLINK,rangeId:S,properties:{url:f}}]},doc:v.documentModel}):E=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}}),!E)return!1;const N=o.TextX.apply(R,E.serialize()),b={p:{...I,body:N},t:o.CellValueType.STRING},D=a.onWriteCell(u,p,y,_,b),O={unitId:c,subUnitId:l,cellValue:{[m.row]:{[m.column]:D}}},Z={id:h.SetRangeValuesMutation.id,params:O},$=h.SetRangeValuesUndoMutationFactory(s,O),ee={id:h.SetRangeValuesMutation.id,params:$},x=[Z],H=[ee],T=i.getHyperLinkByLocation(c,l,y,_);return T&&(x.push({id:w.id,params:{unitId:c,subUnitId:l,id:T.id}}),H.push({id:U.id,params:{unitId:c,subUnitId:l,link:T}})),await o.sequenceExecute(x,e)?await a.onValidateCell(u,p,y,_)===!1?(o.sequenceExecute(H,e),!1):(n.pushUndoRedo({redoMutations:x,undoMutations:H,unitID:c}),!0):!1}},pe={id:"sheets.command.add-rich-hyper-link",type:o.CommandType.COMMAND,handler:async(s,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,r=s.get(o.ICommandService),i=o.generateRandomId(),{payload:a}=n,d=Q.addCustomRangeBySelectionFactory(s,{unitId:e,rangeId:i,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:a,refId:i}});return d?r.syncExecuteCommand(d.id,d.params):!1}},ge={type:o.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(s,t){var b,D;if(!t)return!1;const e=s.get(o.ICommandService),n=s.get(o.IUndoRedoService),r=s.get(o.IUniverInstanceService),i=s.get(exports.HyperLinkModel),a=h.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 g=m.getCellDocumentModelWithFormula(f,d,c);if(!(g!=null&&g.documentModel))return!1;const y=o.Tools.deepClone(g.documentModel.getSnapshot()),_=(D=(b=y.body)==null?void 0:b.customRanges)==null?void 0:D.find(O=>`${O.rangeId}`===l);if(!_)return!1;const S=o.BuildTextUtils.customRange.delete({documentDataModel:g.documentModel,rangeId:_.rangeId});if(!S)return!1;const M=o.TextX.apply(y.body,S.serialize()),v=[],I=[],R={unitId:u,subUnitId:p,cellValue:{[d]:{[c]:{p:{...y,body:M},t:o.CellValueType.STRING}}}};v.push({id:h.SetRangeValuesMutation.id,params:R});const E=h.SetRangeValuesUndoMutationFactory(s,R);I.push({id:h.SetRangeValuesMutation.id,params:E});const N=i.getHyperLinkByLocation(u,p,d,c);return N&&(v.push({id:w.id,params:{unitId:u,subUnitId:p,id:l}}),I.push({id:U.id,params:{unitId:u,subUnitId:p,link:{...N}}})),o.sequenceExecute(v,e).result?(n.pushUndoRedo({redoMutations:v,undoMutations:I,unitID:u}),!0):!1}},he={type:o.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(s,t){var u,p;if(!t)return!1;const{id:e,documentId:n}=t,r=s.get(o.ICommandService),a=s.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=Q.deleteCustomRangeFactory(s,{unitId:n,rangeId:e,insert:c});return l?r.syncExecuteCommand(l.id,l.params):!1}},me={type:o.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(s,t){var ie,se,ae;if(!t)return!1;const e=s.get(o.ICommandService),n=s.get(o.IUndoRedoService),r=s.get(o.IUniverInstanceService),i=s.get(exports.HyperLinkModel),a=s.get(h.SheetInterceptorService),d=h.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:g,subUnitId:y}=d,{payload:_,display:S=""}=c,M=f.getCell(l,u);if(!M)return!1;const v=f.getCellDocumentModelWithFormula(M,l,u);if(!(v!=null&&v.documentModel))return!1;const I=v.documentModel.getSnapshot(),R=(se=(ie=I.body)==null?void 0:ie.customRanges)==null?void 0:se.find(oe=>`${oe.rangeId}`===p);if(!R)return!1;const E=o.generateRandomId(),P=(ae=o.getBodySlice(v.documentModel.getBody(),R.startIndex,R.endIndex+1).textRuns)==null?void 0:ae[0];P&&(P.ed=S.length+1);const b=Q.replaceSelectionFactory(s,{unitId:g,body:{dataStream:`${S}`,customRanges:[{rangeId:E,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:S.length-1,properties:{url:_}}],textRuns:P?[P]:void 0},selection:{startOffset:R.startIndex,endOffset:R.endIndex+1,collapsed:!1},doc:v.documentModel});if(!b)return!1;const D=o.TextX.apply(o.Tools.deepClone(I.body),b.textX.serialize()),O={p:{...I,body:D},t:o.CellValueType.STRING},Z=a.onWriteCell(m,f,l,u,O),$={id:h.SetRangeValuesMutation.id,params:{unitId:g,subUnitId:y,cellValue:{[l]:{[u]:Z}}}},ee=h.SetRangeValuesUndoMutationFactory(s,$.params),x={id:h.SetRangeValuesMutation.id,params:ee},H=[$],T=[x],A=i.getHyperLinkByLocation(g,y,l,u);return A&&(H.push({id:w.id,params:{unitId:g,subUnitId:y,id:A.id}}),T.push({id:U.id,params:{unitId:g,subUnitId:y,link:A}})),o.sequenceExecute(H,e)?await a.onValidateCell(m,f,l,u)===!1?(o.sequenceExecute(T,e),!1):(n.pushUndoRedo({redoMutations:H,undoMutations:T,unitID:g}),!0):!1}},fe={type:o.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(s,t)=>{var g,y,_,S;if(!t)return!1;const{documentId:e,payload:n,id:r}=t,i=s.get(o.IUniverInstanceService),a=s.get(o.ICommandService),d=i.getUnit(e,o.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(y=(g=d.getBody())==null?void 0:g.customRanges)==null?void 0:y.find(M=>M.rangeId===r);if(!c)return!1;const l=(_=t.payload.display)!=null?_:"",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=Q.replaceSelectionFactory(s,{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}},F={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(s,t){if(!t)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,payload:i,id:a}=t;return e.updateHyperLink(n,r,a,i,!1)}},z={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(s,t){if(!t)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,id:i,row:a,column:d,silent:c}=t;return e.updateHyperLinkRef(n,r,i,{row:a,column:d},c)}},B={type:o.CommandType.MUTATION,id:"sheets.mutation.update-rich-hyper-link",handler(s,t){var f,g,y;if(!t)return!1;const{unitId:e,subUnitId:n,row:r,col:i,id:a,url:d}=t,c=s.get(o.IUniverInstanceService),l=h.getSheetCommandTarget(c,{unitId:e,subUnitId:n});if(!l)return!1;const{worksheet:u}=l,p=u.getCellRaw(r,i),m=(y=(g=(f=p==null?void 0:p.p)==null?void 0:f.body)==null?void 0:g.customRanges)==null?void 0:y.find(_=>_.rangeType===o.CustomRangeType.HYPERLINK&&_.rangeId===a);return m&&(m.properties.url=d),!0}},Le="sheets-hyper-link.config",de={},ye="SHEET_HYPER_LINK_PLUGIN",V="err";var Ue=Object.getOwnPropertyDescriptor,we=(s,t,e,n)=>{for(var r=n>1?void 0:n?Ue(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},j=(s,t)=>(e,n)=>t(e,n,s);let K=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,i)=>{const a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};return r?{redos:[{id:z.id,params:{unitId:t,subUnitId:e,id:n.id,row:r.startRow,column:r.startColumn,silent:i}}],undos:[{id:z.id,params:{unitId:t,subUnitId:e,id:n.id,row:a.startRow,column:a.startColumn,silent:i}}]}:{redos:[{id:w.id,params:{unitId:t,subUnitId:e,id:n.id}}],undos:[{id:U.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,i={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row},a=d=>{const c=h.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(i,d,{selectionManagerService:this._selectionManagerService}),l=Array.isArray(c)?c[0]:c;return l&&l.startColumn===i.startColumn&&l.startRow===i.startRow?{undos:[],redos:[]}:this._handlePositionChange(t,e,n,l,!1)};this._disposableMap.set(r,this._refRangeService.registerRefRange(i,a,t,e))}_watchPosition(t,e,n){const r=n.id,i={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._watchDisposableMap.set(r,this._refRangeService.watchRange(t,e,i,(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 i,a,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(i=c.get("gid"))!=null?i:"",range:(a=c.get("range"))!=null?a:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,p=k.deserializeRangeWithSheet(l.range).range;if(o.isValidRange(p)&&l.range!==V){const m=f=>{const g=h.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(p,f,{selectionManagerService:this._selectionManagerService});return g&&k.serializeRange(g)===k.serializeRange(p)?{redos:[],undos:[]}:{redos:[{id:F.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${g?k.serializeRange(g):"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,g)=>{this._hyperLinkModel.updateHyperLink(t,u,e,{payload:`#gid=${u}&range=${g?k.serializeRange(g):"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:i,links:a}=n;a.forEach(d=>{this._registerPosition(r,i,d),this._watchPosition(r,i,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:i}=t,a=this._hyperLinkModel.getHyperLink(e,n,r);if(!a)return;this._unregisterPosition(r),this._registerPosition(e,n,a),i||(this._unwatchPosition(r),this._watchPosition(e,n,a));break}case"unload":{const{unitLinks:e}=t;e.forEach(n=>{const{links:r}=n;r.forEach(i=>{this._unregisterPosition(i.id),this._unwatchPosition(i.id),this._unregisterRange(i.id),this._unwatchRange(i.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()}))}};K=we([j(0,o.Inject(h.RefRangeService)),j(1,o.Inject(exports.HyperLinkModel)),j(2,o.Inject(h.SheetsSelectionsService)),j(3,o.ICommandService)],K);var Ee=Object.getOwnPropertyDescriptor,be=(s,t,e,n)=>{for(var r=n>1?void 0:n?Ee(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},te=(s,t)=>(e,n)=>t(e,n,s);let Y=class extends o.Disposable{constructor(s,t,e){super(),this._sheetInterceptorService=s,this._univerInstanceService=t,this._hyperLinkModel=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:s=>{var t;if(s.id===h.RemoveSheetCommand.id){const e=s.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(),i=e.subUnitId||((t=n.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const a=this._hyperLinkModel.getSubUnit(r,i),d=a.map(l=>({id:w.id,params:{unitId:r,subUnitId:i,id:l.id}})),c=a.map(l=>({id:U.id,params:{unitId:r,subUnitId:i,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};Y=be([te(0,o.Inject(h.SheetInterceptorService)),te(1,o.IUniverInstanceService),te(2,o.Inject(exports.HyperLinkModel))],Y);var He=Object.getOwnPropertyDescriptor,Te=(s,t,e,n)=>{for(var r=n>1?void 0:n?He(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},ne=(s,t)=>(e,n)=>t(e,n,s);let q=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,i,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:(i=d.get("range"))!=null?i:"",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=k.deserializeRangeWithSheet(c.range).range;if(o.isValidRange(p,u)&&c.range!==V)return{range:p,worksheet:u}}}return null}_registerRange(t,e,n,r,i){var d,c,l,u;const a=this._enusreMap(t,e);if((c=(d=i.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=i.body)==null?void 0:l.customRanges)==null||u.forEach(f=>{var g;if(f.rangeType===o.CustomRangeType.HYPERLINK){const y=(g=f.properties)==null?void 0:g.url,_=this._isLegalRangeUrl(t,y);if(_){const{range:S,worksheet:M}=_;m=!0,p.add(this._refRangeService.registerRefRange(S,v=>{const I=h.handleDefaultRangeChangeWithEffectRefCommands(S,v);return I&&o.Rectangle.equals(I,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=${I?k.serializeRange(I):V}`}}],undos:[{id:B.id,params:{unitId:t,subUnitId:e,row:n,col:r,id:f.rangeId,url:y}}],redos:[]}},M.getUnitId(),M.getSheetId()))}}}),m&&a.setValue(n,r,p)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(r=>{const i=r.getSheetId(),a=this._enusreMap(n,i);r.getCellMatrix().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._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.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===o.UniverInstanceType.UNIVER_SHEET){const e=t,n=e.getUnitId();e.getSheets().forEach(r=>{const i=r.getSheetId();this._enusreMap(n,i).forValue((d,c,l)=>{l&&l.dispose()})}),this._refRangeMap.delete(n)}}))}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===h.SetRangeValuesMutation.id){const e=t.params,{unitId:n,subUnitId:r,cellValue:i}=e,a=this._enusreMap(n,r);i&&new o.ObjectMatrix(i).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:i,col:a}=e,d=h.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:r}),l=this._enusreMap(n,r).getValue(i,a);if(l&&l.dispose(),d){const{worksheet:u}=d,p=u.getCellRaw(i,a);p&&p.p&&this._registerRange(n,r,i,a,p.p)}}}))}};q=Te([ne(0,o.ICommandService),ne(1,o.IUniverInstanceService),ne(2,o.Inject(h.RefRangeService))],q);var Pe=Object.getOwnPropertyDescriptor,De=(s,t,e,n)=>{for(var r=n>1?void 0:n?Pe(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},W=(s,t)=>(e,n)=>t(e,n,s);let G=class extends o.Disposable{constructor(s,t,e,n){super(),this._sheetInterceptorService=s,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:s=>{if(s.id===h.SetRangeValuesCommand.id){const t=s.params,{unitId:e,subUnitId:n}=t,r=[],i=[];return t.cellValue&&new o.ObjectMatrix(t.cellValue).forValue((a,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,d);c&&(r.push({id:w.id,params:{unitId:e,subUnitId:n,id:c.id}}),i.push({id:U.id,params:{unitId:e,subUnitId:n,link:c}}))}),{undos:i,redos:r}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:s=>{if(s.id===h.ClearSelectionContentCommand.id||s.id===h.ClearSelectionAllCommand.id||s.id===h.ClearSelectionFormatCommand.id){const t=[],e=[],n=this._selectionManagerService.getCurrentLastSelection(),r=h.getSheetCommandTarget(this._univerInstanceService);if(n&&r){const{unitId:i,subUnitId:a}=r;o.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(i,a,d,c);l&&(t.push({id:w.id,params:{unitId:i,subUnitId:a,id:l.id}}),e.push({id:U.id,params:{unitId:i,subUnitId:a,link:l}}))})}return{redos:t,undos:e}}return{redos:[],undos:[]}}}))}_initAfterEditor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(h.AFTER_CELL_EDIT,{handler:(s,t,e)=>{if(!s||s.p)return e(s);if(typeof s.v=="string"&&o.Tools.isLegalUrl(s.v)&&s.v[s.v.length-1]!==" "){const{unitId:n,subUnitId:r,row:i,col:a}=t,d=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),c=d==null?void 0:d.getSheetBySheetId(r);if(!c)return e(s);const l=c.getBlankCellDocumentModel(s,i,a);if(!l.documentModel)return e(s);const u=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:s.v.length,collapsed:!1},body:{dataStream:`${s.v}`,customRanges:[{startIndex:0,endIndex:s.v.length-1,rangeId:o.generateRandomId(),rangeType:o.CustomRangeType.HYPERLINK,properties:{url:s.v}}]},doc:l.documentModel});if(!u)return e(s);const p=l.documentModel.getBody();return o.TextX.apply(p,u.serialize()),e({...s,p:{id:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:p,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(s)}}))}};G=De([W(0,o.Inject(h.SheetInterceptorService)),W(1,o.Inject(exports.HyperLinkModel)),W(2,o.Inject(h.SheetsSelectionsService)),W(3,o.IUniverInstanceService)],G);var Oe=Object.getOwnPropertyDescriptor,Ne=(s,t,e,n)=>{for(var r=n>1?void 0:n?Oe(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},ce=(s,t)=>(e,n)=>t(e,n,s);let X=class extends o.Disposable{constructor(s,t){super(),this._resourceManagerService=s,this._hyperLinkModel=t,this._initSnapshot()}_initSnapshot(){const s=e=>{const n=this._hyperLinkModel.getUnit(e),r={};return n?(n.forEach(i=>{r[i.subUnitId]=i.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:ye,businesses:[o.UniverInstanceType.UNIVER_SHEET],toJson:e=>s(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)})})}}))}};X=Ne([ce(0,o.IResourceManagerService),ce(1,o.Inject(exports.HyperLinkModel))],X);var xe=Object.getOwnPropertyDescriptor,Ve=(s,t,e,n)=>{for(var r=n>1?void 0:n?xe(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},$e=(s,t)=>(e,n)=>t(e,n,s);let J=class extends o.Disposable{constructor(s){super(),this._commandService=s,this._registerCommands()}_registerCommands(){[ue,me,ge,fe,he,pe,U,F,w,z,B].forEach(s=>{this._commandService.registerCommand(s)})}};J=Ve([$e(0,o.ICommandService)],J);var L=(s=>(s.SHEET="gid",s.RANGE="range",s.DEFINE_NAME="rangeid",s.INVALID="invalid",s.URL="url",s))(L||{}),Ae=Object.getOwnPropertyDescriptor,je=(s,t,e,n)=>{for(var r=n>1?void 0:n?Ae(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},re=(s,t)=>(e,n)=>t(e,n,s);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:k.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,r,i;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:(i=a.get("unitid"))!=null?i:""},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:i}=t,a=i?this._univerInstanceService.getUnit(i,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=k.deserializeRangeWithSheet(n).range;return o.isValidRange(p,c)&&n!==V?{type:L.RANGE,name:k.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,k.IDefinedNamesService)],exports.SheetsHyperLinkParserService);var We=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,Fe=(s,t,e)=>t in s?We(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,ze=(s,t,e,n)=>{for(var r=n>1?void 0:n?Be(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},le=(s,t)=>(e,n)=>t(e,n,s),_e=(s,t,e)=>Fe(s,typeof t!="symbol"?t+"":t,e);exports.UniverSheetsHyperLinkPlugin=class extends o.Plugin{constructor(t=de,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...r}=o.merge({},de,this._config);this._configService.setConfig(Le,r)}onStarting(){o.registerDependencies(this._injector,[[exports.HyperLinkModel],[exports.SheetsHyperLinkParserService],[X],[J],[K],[G],[Y],[q]]),o.touchDependencies(this._injector,[[K],[X],[J],[G],[Y],[q]])}};_e(exports.UniverSheetsHyperLinkPlugin,"pluginName",ye);_e(exports.UniverSheetsHyperLinkPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsHyperLinkPlugin=ze([o.DependentOn(h.UniverSheetsPlugin),le(1,o.Inject(o.Injector)),le(2,o.IConfigService)],exports.UniverSheetsHyperLinkPlugin);exports.AddHyperLinkCommand=ue;exports.AddHyperLinkMutation=U;exports.AddRichHyperLinkCommand=pe;exports.CancelHyperLinkCommand=ge;exports.CancelRichHyperLinkCommand=he;exports.ERROR_RANGE=V;exports.RemoveHyperLinkMutation=w;exports.SheetHyperLinkType=L;exports.UpdateHyperLinkCommand=me;exports.UpdateHyperLinkMutation=F;exports.UpdateHyperLinkRefMutation=z;exports.UpdateRichHyperLinkCommand=fe;
1
+ "use strict";var ve=Object.defineProperty;var Ie=(s,t,e)=>t in s?ve(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var C=(s,t,e)=>Ie(s,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),Q=require("@univerjs/docs"),h=require("@univerjs/sheets"),Re=require("rxjs"),k=require("@univerjs/engine-formula");var Me=Object.getOwnPropertyDescriptor,Ce=(s,t,e,n)=>{for(var r=n>1?void 0:n?Me(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},ke=(s,t)=>(e,n)=>t(e,n,s);exports.HyperLinkModel=class extends o.Disposable{constructor(e){super();C(this,"_linkUpdate$",new Re.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 i=r.get(n);i||(i=new o.ObjectMatrix,r.set(n,i));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:i,positionMap:d}}addHyperLink(e,n,r){const{matrix:i,positionMap:a}=this._ensureMap(e,n);return i.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,i,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,i),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,i,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,i),c.set(r,{...i,link:u}),d.setValue(i.row,i.column,u),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:i,id:r,type:"updateRef",silent:a}),!0}removeHyperLink(e,n,r){const{matrix:i,positionMap:a}=this._ensureMap(e,n),d=a.get(r);if(!d)return!1;a.delete(r);const c=i.getValue(d.row,d.column);return c&&c.id===r&&i.realDeleteValue(d.row,d.column),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:d.link,type:"remove"}),!0}getHyperLink(e,n,r){const{matrix:i,positionMap:a}=this._ensureMap(e,n),d=a.get(r);if(d)return i.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,r,i){const{matrix:a}=this._ensureMap(e,n);return a.getValue(r,i)}getHyperLinkByLocationSync(e,n,r,i){var p,m,f,g,y;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,i),l=((y=(g=c==null?void 0:c.v)!=null?g:(f=(m=c==null?void 0:c.p)==null?void 0:m.body)==null?void 0:f.dataStream.slice(0,-2))!=null?y:"").toString(),u=a.getValue(r,i);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:r}=this._ensureMap(e,n),i=[];return r.forValue((a,d,c)=>{c&&i.push(c)}),i}getUnit(e){const n=this._linkMap.get(e);return n?Array.from(n.keys()).map(r=>{const i=this.getSubUnit(e,r);return{unitId:e,subUnitId:r,links:i}}):[]}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=Ce([ke(0,o.IUniverInstanceService)],exports.HyperLinkModel);const U={type:o.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(s,t){if(!t)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,link:i}=t;return e.addHyperLink(n,r,i)}},w={type:o.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(s,t){if(!t)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,id:i}=t;return e.removeHyperLink(n,r,i)}},ue={type:o.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(s,t){if(!t)return!1;const e=s.get(o.ICommandService),n=s.get(o.IUndoRedoService),r=s.get(o.IUniverInstanceService),i=s.get(exports.HyperLinkModel),a=s.get(h.SheetInterceptorService),d=h.getSheetCommandTarget(r,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:p}=d,{link:m}=t,{payload:f,display:g,row:y,column:_,id:S}=m,M=p.getCell(y,_),v=p.getBlankCellDocumentModel(M,y,_),I=v.documentModel.getSnapshot(),R=o.Tools.deepClone(I.body);if(!R)return!1;let E;if(g?E=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:R.dataStream.length-2,collapsed:R.dataStream.length-2===0},body:{dataStream:`${g}`,customRanges:[{startIndex:0,endIndex:g.length-1,rangeType:o.CustomRangeType.HYPERLINK,rangeId:S,properties:{url:f}}]},doc:v.documentModel}):E=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}}),!E)return!1;const N=o.TextX.apply(R,E.serialize()),b={p:{...I,body:N},t:o.CellValueType.STRING},D=a.onWriteCell(u,p,y,_,b),O={unitId:c,subUnitId:l,cellValue:{[m.row]:{[m.column]:D}}},Z={id:h.SetRangeValuesMutation.id,params:O},$=h.SetRangeValuesUndoMutationFactory(s,O),ee={id:h.SetRangeValuesMutation.id,params:$},x=[Z],T=[ee],H=i.getHyperLinkByLocation(c,l,y,_);return H&&(x.push({id:w.id,params:{unitId:c,subUnitId:l,id:H.id}}),T.push({id:U.id,params:{unitId:c,subUnitId:l,link:H}})),await o.sequenceExecute(x,e)?await a.onValidateCell(u,p,y,_)===!1?(o.sequenceExecute(T,e),!1):(n.pushUndoRedo({redoMutations:x,undoMutations:T,unitID:c}),!0):!1}},pe={id:"sheets.command.add-rich-hyper-link",type:o.CommandType.COMMAND,handler:async(s,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,r=s.get(o.ICommandService),i=o.generateRandomId(),{payload:a}=n,d=Q.addCustomRangeBySelectionFactory(s,{unitId:e,rangeId:i,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:a,refId:i}});return d?r.syncExecuteCommand(d.id,d.params):!1}},ge={type:o.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(s,t){var b,D;if(!t)return!1;const e=s.get(o.ICommandService),n=s.get(o.IUndoRedoService),r=s.get(o.IUniverInstanceService),i=s.get(exports.HyperLinkModel),a=h.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 g=m.getCellDocumentModelWithFormula(f,d,c);if(!(g!=null&&g.documentModel))return!1;const y=o.Tools.deepClone(g.documentModel.getSnapshot()),_=(D=(b=y.body)==null?void 0:b.customRanges)==null?void 0:D.find(O=>`${O.rangeId}`===l);if(!_)return!1;const S=o.BuildTextUtils.customRange.delete({documentDataModel:g.documentModel,rangeId:_.rangeId});if(!S)return!1;const M=o.TextX.apply(y.body,S.serialize()),v=[],I=[],R={unitId:u,subUnitId:p,cellValue:{[d]:{[c]:{p:{...y,body:M},t:o.CellValueType.STRING}}}};v.push({id:h.SetRangeValuesMutation.id,params:R});const E=h.SetRangeValuesUndoMutationFactory(s,R);I.push({id:h.SetRangeValuesMutation.id,params:E});const N=i.getHyperLinkByLocation(u,p,d,c);return N&&(v.push({id:w.id,params:{unitId:u,subUnitId:p,id:l}}),I.push({id:U.id,params:{unitId:u,subUnitId:p,link:{...N}}})),o.sequenceExecute(v,e).result?(n.pushUndoRedo({redoMutations:v,undoMutations:I,unitID:u}),!0):!1}},he={type:o.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(s,t){var u,p;if(!t)return!1;const{id:e,documentId:n}=t,r=s.get(o.ICommandService),a=s.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=Q.deleteCustomRangeFactory(s,{unitId:n,rangeId:e,insert:c});return l?r.syncExecuteCommand(l.id,l.params):!1}},me={type:o.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(s,t){var ie,se,ae;if(!t)return!1;const e=s.get(o.ICommandService),n=s.get(o.IUndoRedoService),r=s.get(o.IUniverInstanceService),i=s.get(exports.HyperLinkModel),a=s.get(h.SheetInterceptorService),d=h.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:g,subUnitId:y}=d,{payload:_,display:S=""}=c,M=f.getCell(l,u);if(!M)return!1;const v=f.getCellDocumentModelWithFormula(M,l,u);if(!(v!=null&&v.documentModel))return!1;const I=v.documentModel.getSnapshot(),R=(se=(ie=I.body)==null?void 0:ie.customRanges)==null?void 0:se.find(oe=>`${oe.rangeId}`===p);if(!R)return!1;const E=o.generateRandomId(),P=(ae=o.getBodySlice(v.documentModel.getBody(),R.startIndex,R.endIndex+1).textRuns)==null?void 0:ae[0];P&&(P.ed=S.length+1);const b=Q.replaceSelectionFactory(s,{unitId:g,body:{dataStream:`${S}`,customRanges:[{rangeId:E,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:S.length-1,properties:{url:_}}],textRuns:P?[P]:void 0},selection:{startOffset:R.startIndex,endOffset:R.endIndex+1,collapsed:!1},doc:v.documentModel});if(!b)return!1;const D=o.TextX.apply(o.Tools.deepClone(I.body),b.textX.serialize()),O={p:{...I,body:D},t:o.CellValueType.STRING},Z=a.onWriteCell(m,f,l,u,O),$={id:h.SetRangeValuesMutation.id,params:{unitId:g,subUnitId:y,cellValue:{[l]:{[u]:Z}}}},ee=h.SetRangeValuesUndoMutationFactory(s,$.params),x={id:h.SetRangeValuesMutation.id,params:ee},T=[$],H=[x],A=i.getHyperLinkByLocation(g,y,l,u);return A&&(T.push({id:w.id,params:{unitId:g,subUnitId:y,id:A.id}}),H.push({id:U.id,params:{unitId:g,subUnitId:y,link:A}})),o.sequenceExecute(T,e)?await a.onValidateCell(m,f,l,u)===!1?(o.sequenceExecute(H,e),!1):(n.pushUndoRedo({redoMutations:T,undoMutations:H,unitID:g}),!0):!1}},fe={type:o.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(s,t)=>{var g,y,_,S;if(!t)return!1;const{documentId:e,payload:n,id:r}=t,i=s.get(o.IUniverInstanceService),a=s.get(o.ICommandService),d=i.getUnit(e,o.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(y=(g=d.getBody())==null?void 0:g.customRanges)==null?void 0:y.find(M=>M.rangeId===r);if(!c)return!1;const l=(_=t.payload.display)!=null?_:"",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=Q.replaceSelectionFactory(s,{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}},F={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(s,t){if(!t)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,payload:i,id:a}=t;return e.updateHyperLink(n,r,a,i,!1)}},z={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(s,t){if(!t)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:r,id:i,row:a,column:d,silent:c}=t;return e.updateHyperLinkRef(n,r,i,{row:a,column:d},c)}},B={type:o.CommandType.MUTATION,id:"sheets.mutation.update-rich-hyper-link",handler(s,t){var f,g,y;if(!t)return!1;const{unitId:e,subUnitId:n,row:r,col:i,id:a,url:d}=t,c=s.get(o.IUniverInstanceService),l=h.getSheetCommandTarget(c,{unitId:e,subUnitId:n});if(!l)return!1;const{worksheet:u}=l,p=u.getCellRaw(r,i),m=(y=(g=(f=p==null?void 0:p.p)==null?void 0:f.body)==null?void 0:g.customRanges)==null?void 0:y.find(_=>_.rangeType===o.CustomRangeType.HYPERLINK&&_.rangeId===a);return m&&(m.properties.url=d),!0}},Le="sheets-hyper-link.config",de={},ye="SHEET_HYPER_LINK_PLUGIN",V="err";var Ue=Object.getOwnPropertyDescriptor,we=(s,t,e,n)=>{for(var r=n>1?void 0:n?Ue(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},j=(s,t)=>(e,n)=>t(e,n,s);let K=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,i)=>{const a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};return r?{redos:[{id:z.id,params:{unitId:t,subUnitId:e,id:n.id,row:r.startRow,column:r.startColumn,silent:i}}],undos:[{id:z.id,params:{unitId:t,subUnitId:e,id:n.id,row:a.startRow,column:a.startColumn,silent:i}}]}:{redos:[{id:w.id,params:{unitId:t,subUnitId:e,id:n.id}}],undos:[{id:U.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,i={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row},a=d=>{const c=h.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(i,d,{selectionManagerService:this._selectionManagerService}),l=Array.isArray(c)?c[0]:c;return l&&l.startColumn===i.startColumn&&l.startRow===i.startRow?{undos:[],redos:[]}:this._handlePositionChange(t,e,n,l,!1)};this._disposableMap.set(r,this._refRangeService.registerRefRange(i,a,t,e))}_watchPosition(t,e,n){const r=n.id,i={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._watchDisposableMap.set(r,this._refRangeService.watchRange(t,e,i,(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 i,a,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(i=c.get("gid"))!=null?i:"",range:(a=c.get("range"))!=null?a:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,p=k.deserializeRangeWithSheet(l.range).range;if(o.isValidRange(p)&&l.range!==V){const m=f=>{const g=h.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(p,f,{selectionManagerService:this._selectionManagerService});return g&&k.serializeRange(g)===k.serializeRange(p)?{redos:[],undos:[]}:{redos:[{id:F.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${g?k.serializeRange(g):"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,g)=>{this._hyperLinkModel.updateHyperLink(t,u,e,{payload:`#gid=${u}&range=${g?k.serializeRange(g):"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:i,links:a}=n;a.forEach(d=>{this._registerPosition(r,i,d),this._watchPosition(r,i,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:i}=t,a=this._hyperLinkModel.getHyperLink(e,n,r);if(!a)return;this._unregisterPosition(r),this._registerPosition(e,n,a),i||(this._unwatchPosition(r),this._watchPosition(e,n,a));break}case"unload":{const{unitLinks:e}=t;e.forEach(n=>{const{links:r}=n;r.forEach(i=>{this._unregisterPosition(i.id),this._unwatchPosition(i.id),this._unregisterRange(i.id),this._unwatchRange(i.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()}))}};K=we([j(0,o.Inject(h.RefRangeService)),j(1,o.Inject(exports.HyperLinkModel)),j(2,o.Inject(h.SheetsSelectionsService)),j(3,o.ICommandService)],K);var Ee=Object.getOwnPropertyDescriptor,be=(s,t,e,n)=>{for(var r=n>1?void 0:n?Ee(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},te=(s,t)=>(e,n)=>t(e,n,s);let Y=class extends o.Disposable{constructor(s,t,e){super(),this._sheetInterceptorService=s,this._univerInstanceService=t,this._hyperLinkModel=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:s=>{var t;if(s.id===h.RemoveSheetCommand.id){const e=s.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(),i=e.subUnitId||((t=n.getActiveSheet())==null?void 0:t.getSheetId());if(!i)return{redos:[],undos:[]};const a=this._hyperLinkModel.getSubUnit(r,i),d=a.map(l=>({id:w.id,params:{unitId:r,subUnitId:i,id:l.id}})),c=a.map(l=>({id:U.id,params:{unitId:r,subUnitId:i,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};Y=be([te(0,o.Inject(h.SheetInterceptorService)),te(1,o.IUniverInstanceService),te(2,o.Inject(exports.HyperLinkModel))],Y);var Te=Object.getOwnPropertyDescriptor,He=(s,t,e,n)=>{for(var r=n>1?void 0:n?Te(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},ne=(s,t)=>(e,n)=>t(e,n,s);let q=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,i,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:(i=d.get("range"))!=null?i:"",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=k.deserializeRangeWithSheet(c.range).range;if(o.isValidRange(p,u)&&c.range!==V)return{range:p,worksheet:u}}}return null}_registerRange(t,e,n,r,i){var d,c,l,u;const a=this._enusreMap(t,e);if((c=(d=i.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=i.body)==null?void 0:l.customRanges)==null||u.forEach(f=>{var g;if(f.rangeType===o.CustomRangeType.HYPERLINK){const y=(g=f.properties)==null?void 0:g.url,_=this._isLegalRangeUrl(t,y);if(_){const{range:S,worksheet:M}=_;m=!0,p.add(this._refRangeService.registerRefRange(S,v=>{const I=h.handleDefaultRangeChangeWithEffectRefCommands(S,v);return I&&o.Rectangle.equals(I,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=${I?k.serializeRange(I):V}`}}],undos:[{id:B.id,params:{unitId:t,subUnitId:e,row:n,col:r,id:f.rangeId,url:y}}],redos:[]}},M.getUnitId(),M.getSheetId()))}}}),m&&a.setValue(n,r,p)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(r=>{const i=r.getSheetId(),a=this._enusreMap(n,i);r.getCellMatrix().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._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.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===o.UniverInstanceType.UNIVER_SHEET){const e=t,n=e.getUnitId();e.getSheets().forEach(r=>{const i=r.getSheetId();this._enusreMap(n,i).forValue((d,c,l)=>{l&&l.dispose()})}),this._refRangeMap.delete(n)}}))}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===h.SetRangeValuesMutation.id){const e=t.params,{unitId:n,subUnitId:r,cellValue:i}=e,a=this._enusreMap(n,r);i&&new o.ObjectMatrix(i).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:i,col:a}=e,d=h.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:r}),l=this._enusreMap(n,r).getValue(i,a);if(l&&l.dispose(),d){const{worksheet:u}=d,p=u.getCellRaw(i,a);p&&p.p&&this._registerRange(n,r,i,a,p.p)}}}))}};q=He([ne(0,o.ICommandService),ne(1,o.IUniverInstanceService),ne(2,o.Inject(h.RefRangeService))],q);var Pe=Object.getOwnPropertyDescriptor,De=(s,t,e,n)=>{for(var r=n>1?void 0:n?Pe(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},W=(s,t)=>(e,n)=>t(e,n,s);let G=class extends o.Disposable{constructor(s,t,e,n){super(),this._sheetInterceptorService=s,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:s=>{if(s.id===h.SetRangeValuesCommand.id){const t=s.params,{unitId:e,subUnitId:n}=t,r=[],i=[];return t.cellValue&&new o.ObjectMatrix(t.cellValue).forValue((a,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,d);c&&(r.push({id:w.id,params:{unitId:e,subUnitId:n,id:c.id}}),i.push({id:U.id,params:{unitId:e,subUnitId:n,link:c}}))}),{undos:i,redos:r}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:s=>{if(s.id===h.ClearSelectionContentCommand.id||s.id===h.ClearSelectionAllCommand.id||s.id===h.ClearSelectionFormatCommand.id){const t=[],e=[],n=this._selectionManagerService.getCurrentLastSelection(),r=h.getSheetCommandTarget(this._univerInstanceService);if(n&&r){const{unitId:i,subUnitId:a}=r;o.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(i,a,d,c);l&&(t.push({id:w.id,params:{unitId:i,subUnitId:a,id:l.id}}),e.push({id:U.id,params:{unitId:i,subUnitId:a,link:l}}))})}return{redos:t,undos:e}}return{redos:[],undos:[]}}}))}_initAfterEditor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(h.AFTER_CELL_EDIT,{handler:(s,t,e)=>{if(!s||s.p)return e(s);if(typeof s.v=="string"&&o.Tools.isLegalUrl(s.v)&&s.v[s.v.length-1]!==" "){const{unitId:n,subUnitId:r,row:i,col:a}=t,d=o.Tools.normalizeUrl(s.v),c=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),l=c==null?void 0:c.getSheetBySheetId(r);if(!l)return e(s);const u=l.getBlankCellDocumentModel(s,i,a);if(!u.documentModel)return e(s);const p=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:s.v.length,collapsed:!1},body:{dataStream:`${s.v}`,customRanges:[{startIndex:0,endIndex:s.v.length-1,rangeId:o.generateRandomId(),rangeType:o.CustomRangeType.HYPERLINK,properties:{url:d}}]},doc:u.documentModel});if(!p)return e(s);const m=u.documentModel.getBody();return o.TextX.apply(m,p.serialize()),e({...s,p:{id:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:m,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(s)}}))}};G=De([W(0,o.Inject(h.SheetInterceptorService)),W(1,o.Inject(exports.HyperLinkModel)),W(2,o.Inject(h.SheetsSelectionsService)),W(3,o.IUniverInstanceService)],G);var Oe=Object.getOwnPropertyDescriptor,Ne=(s,t,e,n)=>{for(var r=n>1?void 0:n?Oe(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},ce=(s,t)=>(e,n)=>t(e,n,s);let X=class extends o.Disposable{constructor(s,t){super(),this._resourceManagerService=s,this._hyperLinkModel=t,this._initSnapshot()}_initSnapshot(){const s=e=>{const n=this._hyperLinkModel.getUnit(e),r={};return n?(n.forEach(i=>{r[i.subUnitId]=i.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:ye,businesses:[o.UniverInstanceType.UNIVER_SHEET],toJson:e=>s(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)})})}}))}};X=Ne([ce(0,o.IResourceManagerService),ce(1,o.Inject(exports.HyperLinkModel))],X);var xe=Object.getOwnPropertyDescriptor,Ve=(s,t,e,n)=>{for(var r=n>1?void 0:n?xe(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},$e=(s,t)=>(e,n)=>t(e,n,s);let J=class extends o.Disposable{constructor(s){super(),this._commandService=s,this._registerCommands()}_registerCommands(){[ue,me,ge,fe,he,pe,U,F,w,z,B].forEach(s=>{this._commandService.registerCommand(s)})}};J=Ve([$e(0,o.ICommandService)],J);var L=(s=>(s.SHEET="gid",s.RANGE="range",s.DEFINE_NAME="rangeid",s.INVALID="invalid",s.URL="url",s))(L||{}),Ae=Object.getOwnPropertyDescriptor,je=(s,t,e,n)=>{for(var r=n>1?void 0:n?Ae(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},re=(s,t)=>(e,n)=>t(e,n,s);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:k.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,r,i;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:(i=a.get("unitid"))!=null?i:""},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:i}=t,a=i?this._univerInstanceService.getUnit(i,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=k.deserializeRangeWithSheet(n).range;return o.isValidRange(p,c)&&n!==V?{type:L.RANGE,name:k.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,k.IDefinedNamesService)],exports.SheetsHyperLinkParserService);var We=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,Fe=(s,t,e)=>t in s?We(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,ze=(s,t,e,n)=>{for(var r=n>1?void 0:n?Be(t,e):t,i=s.length-1,a;i>=0;i--)(a=s[i])&&(r=a(r)||r);return r},le=(s,t)=>(e,n)=>t(e,n,s),_e=(s,t,e)=>Fe(s,typeof t!="symbol"?t+"":t,e);exports.UniverSheetsHyperLinkPlugin=class extends o.Plugin{constructor(t=de,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...r}=o.merge({},de,this._config);this._configService.setConfig(Le,r)}onStarting(){o.registerDependencies(this._injector,[[exports.HyperLinkModel],[exports.SheetsHyperLinkParserService],[X],[J],[K],[G],[Y],[q]]),o.touchDependencies(this._injector,[[K],[X],[J],[G],[Y],[q]])}};_e(exports.UniverSheetsHyperLinkPlugin,"pluginName",ye);_e(exports.UniverSheetsHyperLinkPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsHyperLinkPlugin=ze([o.DependentOn(h.UniverSheetsPlugin),le(1,o.Inject(o.Injector)),le(2,o.IConfigService)],exports.UniverSheetsHyperLinkPlugin);exports.AddHyperLinkCommand=ue;exports.AddHyperLinkMutation=U;exports.AddRichHyperLinkCommand=pe;exports.CancelHyperLinkCommand=ge;exports.CancelRichHyperLinkCommand=he;exports.ERROR_RANGE=V;exports.RemoveHyperLinkMutation=w;exports.SheetHyperLinkType=L;exports.UpdateHyperLinkCommand=me;exports.UpdateHyperLinkMutation=F;exports.UpdateHyperLinkRefMutation=z;exports.UpdateRichHyperLinkCommand=fe;
package/lib/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var $e = Object.defineProperty;
2
2
  var Ae = (s, e, t) => e in s ? $e(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
3
  var w = (s, e, t) => Ae(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { Disposable as T, ObjectMatrix as Q, UniverInstanceType as I, IUniverInstanceService as k, CommandType as L, ICommandService as b, IUndoRedoService as Se, Tools as de, BuildTextUtils as Z, CustomRangeType as U, TextX as ce, CellValueType as Re, sequenceExecute as Y, generateRandomId as le, getBodySlice as De, Inject as M, sequenceExecuteAsync as We, isValidRange as Ie, toDisposable as Be, DisposableCollection as je, Rectangle as Fe, Range as Ke, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Ye, IResourceManagerService as Ge, LocaleService as ze, DependentOn as Je, Injector as Xe, IConfigService as qe, Plugin as Qe, merge as Ze, registerDependencies as et, touchDependencies as tt } from "@univerjs/core";
4
+ import { Disposable as T, ObjectMatrix as Z, UniverInstanceType as I, IUniverInstanceService as k, CommandType as L, ICommandService as b, IUndoRedoService as Se, Tools as Y, BuildTextUtils as ee, CustomRangeType as U, TextX as ce, CellValueType as Re, sequenceExecute as G, generateRandomId as le, getBodySlice as De, Inject as M, sequenceExecuteAsync as We, isValidRange as Ie, toDisposable as Be, DisposableCollection as je, Rectangle as Fe, Range as Ke, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Ye, IResourceManagerService as Ge, LocaleService as ze, DependentOn as Je, Injector as Xe, IConfigService as qe, Plugin as Qe, merge as Ze, registerDependencies as et, touchDependencies as tt } from "@univerjs/core";
5
5
  import { addCustomRangeBySelectionFactory as nt, deleteCustomRangeFactory as rt, replaceSelectionFactory as Ne } from "@univerjs/docs";
6
6
  import { SheetInterceptorService as ue, getSheetCommandTarget as j, SetRangeValuesMutation as V, SetRangeValuesUndoMutationFactory as Me, RefRangeService as Oe, SheetsSelectionsService as He, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as st, handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests as it, RemoveSheetCommand as at, handleDefaultRangeChangeWithEffectRefCommands as ot, SetRangeValuesCommand as dt, ClearSelectionContentCommand as ct, ClearSelectionAllCommand as lt, ClearSelectionFormatCommand as ut, AFTER_CELL_EDIT as pt, UniverSheetsPlugin as ht } from "@univerjs/sheets";
7
7
  import { Subject as gt } from "rxjs";
@@ -28,7 +28,7 @@ let R = class extends T {
28
28
  let n = this._linkMap.get(e);
29
29
  n || (n = /* @__PURE__ */ new Map(), this._linkMap.set(e, n));
30
30
  let r = n.get(t);
31
- r || (r = new Q(), n.set(t, r));
31
+ r || (r = new Z(), n.set(t, r));
32
32
  let i = this._linkPositionMap.get(e);
33
33
  i || (i = /* @__PURE__ */ new Map(), this._linkPositionMap.set(e, i));
34
34
  let a = i.get(t);
@@ -166,10 +166,10 @@ const D = {
166
166
  if (!e) return !1;
167
167
  const t = s.get(b), n = s.get(Se), r = s.get(k), i = s.get(R), a = s.get(ue), o = j(r, e);
168
168
  if (!o) return !1;
169
- const { unitId: c, subUnitId: d, workbook: l, worksheet: u } = o, { link: h } = e, { payload: g, display: p, row: f, column: m, id: _ } = h, C = u.getCell(f, m), y = u.getBlankCellDocumentModel(C, f, m), v = y.documentModel.getSnapshot(), S = de.deepClone(v.body);
169
+ const { unitId: c, subUnitId: d, workbook: l, worksheet: u } = o, { link: h } = e, { payload: g, display: p, row: f, column: m, id: _ } = h, C = u.getCell(f, m), y = u.getBlankCellDocumentModel(C, f, m), v = y.documentModel.getSnapshot(), S = Y.deepClone(v.body);
170
170
  if (!S) return !1;
171
171
  let P;
172
- if (p ? P = Z.selection.replace({
172
+ if (p ? P = ee.selection.replace({
173
173
  selection: {
174
174
  startOffset: 0,
175
175
  endOffset: S.dataStream.length - 2,
@@ -189,7 +189,7 @@ const D = {
189
189
  }]
190
190
  },
191
191
  doc: y.documentModel
192
- }) : P = Z.customRange.add({
192
+ }) : P = ee.customRange.add({
193
193
  body: S,
194
194
  ranges: [{ startOffset: 0, endOffset: S.dataStream.length - 2, collapsed: !1 }],
195
195
  rangeId: _,
@@ -216,9 +216,9 @@ const D = {
216
216
  }, pe = {
217
217
  id: V.id,
218
218
  params: W
219
- }, G = Me(s, W), he = {
219
+ }, z = Me(s, W), he = {
220
220
  id: V.id,
221
- params: G
221
+ params: z
222
222
  }, K = [pe], H = [he], x = i.getHyperLinkByLocation(c, d, f, m);
223
223
  return x && (K.push({
224
224
  id: N.id,
@@ -234,7 +234,7 @@ const D = {
234
234
  subUnitId: d,
235
235
  link: x
236
236
  }
237
- })), await Y(K, t) ? await a.onValidateCell(l, u, f, m) === !1 ? (Y(H, t), !1) : (n.pushUndoRedo({
237
+ })), await G(K, t) ? await a.onValidateCell(l, u, f, m) === !1 ? (G(H, t), !1) : (n.pushUndoRedo({
238
238
  redoMutations: K,
239
239
  undoMutations: H,
240
240
  unitID: c
@@ -270,9 +270,9 @@ const D = {
270
270
  if (!g) return !1;
271
271
  const p = h.getCellDocumentModelWithFormula(g, o, c);
272
272
  if (!(p != null && p.documentModel)) return !1;
273
- const f = de.deepClone(p.documentModel.getSnapshot()), m = (A = (O = f.body) == null ? void 0 : O.customRanges) == null ? void 0 : A.find((W) => `${W.rangeId}` === d);
273
+ const f = Y.deepClone(p.documentModel.getSnapshot()), m = (A = (O = f.body) == null ? void 0 : O.customRanges) == null ? void 0 : A.find((W) => `${W.rangeId}` === d);
274
274
  if (!m) return !1;
275
- const _ = Z.customRange.delete({ documentDataModel: p.documentModel, rangeId: m.rangeId });
275
+ const _ = ee.customRange.delete({ documentDataModel: p.documentModel, rangeId: m.rangeId });
276
276
  if (!_) return !1;
277
277
  const C = ce.apply(f.body, _.serialize()), y = [], v = [], S = {
278
278
  unitId: l,
@@ -315,7 +315,7 @@ const D = {
315
315
  ...F
316
316
  }
317
317
  }
318
- })), Y(y, t).result ? (n.pushUndoRedo({
318
+ })), G(y, t).result ? (n.pushUndoRedo({
319
319
  redoMutations: y,
320
320
  undoMutations: v,
321
321
  unitID: l
@@ -380,13 +380,13 @@ const D = {
380
380
  });
381
381
  if (!O)
382
382
  return !1;
383
- const A = ce.apply(de.deepClone(v.body), O.textX.serialize()), W = {
383
+ const A = ce.apply(Y.deepClone(v.body), O.textX.serialize()), W = {
384
384
  p: {
385
385
  ...v,
386
386
  body: A
387
387
  },
388
388
  t: Re.STRING
389
- }, pe = a.onWriteCell(h, g, d, l, W), G = {
389
+ }, pe = a.onWriteCell(h, g, d, l, W), z = {
390
390
  id: V.id,
391
391
  params: {
392
392
  unitId: p,
@@ -397,25 +397,25 @@ const D = {
397
397
  }
398
398
  }
399
399
  }
400
- }, he = Me(s, G.params), K = {
400
+ }, he = Me(s, z.params), K = {
401
401
  id: V.id,
402
402
  params: he
403
- }, H = [G], x = [K], z = i.getHyperLinkByLocation(p, f, d, l);
404
- return z && (H.push({
403
+ }, H = [z], x = [K], J = i.getHyperLinkByLocation(p, f, d, l);
404
+ return J && (H.push({
405
405
  id: N.id,
406
406
  params: {
407
407
  unitId: p,
408
408
  subUnitId: f,
409
- id: z.id
409
+ id: J.id
410
410
  }
411
411
  }), x.push({
412
412
  id: D.id,
413
413
  params: {
414
414
  unitId: p,
415
415
  subUnitId: f,
416
- link: z
416
+ link: J
417
417
  }
418
- })), Y(H, t) ? await a.onValidateCell(h, g, d, l) === !1 ? (Y(x, t), !1) : (n.pushUndoRedo({
418
+ })), G(H, t) ? await a.onValidateCell(h, g, d, l) === !1 ? (G(x, t), !1) : (n.pushUndoRedo({
419
419
  redoMutations: H,
420
420
  undoMutations: x,
421
421
  unitID: p
@@ -478,7 +478,7 @@ const D = {
478
478
  const t = s.get(R), { unitId: n, subUnitId: r, id: i, row: a, column: o, silent: c } = e;
479
479
  return t.updateHyperLinkRef(n, r, i, { row: a, column: o }, c);
480
480
  }
481
- }, q = {
481
+ }, Q = {
482
482
  type: L.MUTATION,
483
483
  id: "sheets.mutation.update-rich-hyper-link",
484
484
  handler(s, e) {
@@ -491,13 +491,13 @@ const D = {
491
491
  const { worksheet: l } = d, u = l.getCellRaw(r, i), h = (f = (p = (g = u == null ? void 0 : u.p) == null ? void 0 : g.body) == null ? void 0 : p.customRanges) == null ? void 0 : f.find((m) => m.rangeType === U.HYPERLINK && m.rangeId === a);
492
492
  return h && (h.properties.url = o), !0;
493
493
  }
494
- }, kt = "sheets-hyper-link.config", Ue = {}, xe = "SHEET_HYPER_LINK_PLUGIN", ee = "err";
494
+ }, kt = "sheets-hyper-link.config", Ue = {}, xe = "SHEET_HYPER_LINK_PLUGIN", te = "err";
495
495
  var Lt = Object.getOwnPropertyDescriptor, Et = (s, e, t, n) => {
496
496
  for (var r = n > 1 ? void 0 : n ? Lt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
497
497
  (a = s[i]) && (r = a(r) || r);
498
498
  return r;
499
- }, J = (s, e) => (t, n) => e(t, n, s);
500
- let te = class extends T {
499
+ }, X = (s, e) => (t, n) => e(t, n, s);
500
+ let ne = class extends T {
501
501
  constructor(e, t, n, r) {
502
502
  super();
503
503
  w(this, "_disposableMap", /* @__PURE__ */ new Map());
@@ -600,7 +600,7 @@ let te = class extends T {
600
600
  };
601
601
  if (d.range && d.gid) {
602
602
  const l = d.gid, u = Ce(d.range).range;
603
- if (Ie(u) && d.range !== ee) {
603
+ if (Ie(u) && d.range !== te) {
604
604
  const h = (g) => {
605
605
  const p = it(u, g, { selectionManagerService: this._selectionManagerService });
606
606
  return p && B(p) === B(u) ? {
@@ -700,18 +700,18 @@ let te = class extends T {
700
700
  }));
701
701
  }
702
702
  };
703
- te = Et([
704
- J(0, M(Oe)),
705
- J(1, M(R)),
706
- J(2, M(He)),
707
- J(3, b)
708
- ], te);
703
+ ne = Et([
704
+ X(0, M(Oe)),
705
+ X(1, M(R)),
706
+ X(2, M(He)),
707
+ X(3, b)
708
+ ], ne);
709
709
  var Ut = Object.getOwnPropertyDescriptor, bt = (s, e, t, n) => {
710
710
  for (var r = n > 1 ? void 0 : n ? Ut(e, t) : e, i = s.length - 1, a; i >= 0; i--)
711
711
  (a = s[i]) && (r = a(r) || r);
712
712
  return r;
713
713
  }, ge = (s, e) => (t, n) => e(t, n, s);
714
- let ne = class extends T {
714
+ let re = class extends T {
715
715
  constructor(s, e, t) {
716
716
  super(), this._sheetInterceptorService = s, this._univerInstanceService = e, this._hyperLinkModel = t, this._initSheetChange();
717
717
  }
@@ -750,17 +750,17 @@ let ne = class extends T {
750
750
  );
751
751
  }
752
752
  };
753
- ne = bt([
753
+ re = bt([
754
754
  ge(0, M(ue)),
755
755
  ge(1, k),
756
756
  ge(2, M(R))
757
- ], ne);
757
+ ], re);
758
758
  var Pt = Object.getOwnPropertyDescriptor, Dt = (s, e, t, n) => {
759
759
  for (var r = n > 1 ? void 0 : n ? Pt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
760
760
  (a = s[i]) && (r = a(r) || r);
761
761
  return r;
762
762
  }, fe = (s, e) => (t, n) => e(t, n, s);
763
- let re = class extends T {
763
+ let se = class extends T {
764
764
  constructor(e, t, n) {
765
765
  super();
766
766
  w(this, "_refRangeMap", /* @__PURE__ */ new Map());
@@ -770,7 +770,7 @@ let re = class extends T {
770
770
  let n = this._refRangeMap.get(e);
771
771
  n || (n = /* @__PURE__ */ new Map(), this._refRangeMap.set(e, n));
772
772
  let r = n.get(t);
773
- return r || (r = new Q(), n.set(t, r)), r;
773
+ return r || (r = new Z(), n.set(t, r)), r;
774
774
  }
775
775
  _isLegalRangeUrl(e, t) {
776
776
  var r, i, a;
@@ -788,7 +788,7 @@ let re = class extends T {
788
788
  if (!l)
789
789
  return null;
790
790
  const u = Ce(c.range).range;
791
- if (Ie(u, l) && c.range !== ee)
791
+ if (Ie(u, l) && c.range !== te)
792
792
  return {
793
793
  range: u,
794
794
  worksheet: l
@@ -824,18 +824,18 @@ let re = class extends T {
824
824
  undos: []
825
825
  } : {
826
826
  preRedos: [{
827
- id: q.id,
827
+ id: Q.id,
828
828
  params: {
829
829
  unitId: e,
830
830
  subUnitId: t,
831
831
  row: n,
832
832
  col: r,
833
833
  id: g.rangeId,
834
- url: `#gid=${t}&range=${v ? B(v) : ee}`
834
+ url: `#gid=${t}&range=${v ? B(v) : te}`
835
835
  }
836
836
  }],
837
837
  undos: [{
838
- id: q.id,
838
+ id: Q.id,
839
839
  params: {
840
840
  unitId: e,
841
841
  subUnitId: t,
@@ -896,7 +896,7 @@ let re = class extends T {
896
896
  this._commandService.onCommandExecuted((e) => {
897
897
  if (e.id === V.id) {
898
898
  const t = e.params, { unitId: n, subUnitId: r, cellValue: i } = t, a = this._enusreMap(n, r);
899
- i && new Q(i).forValue((o, c, d) => {
899
+ i && new Z(i).forValue((o, c, d) => {
900
900
  const l = a.getValue(o, c);
901
901
  l && l.dispose(), d && d.p && this._registerRange(n, r, o, c, d.p);
902
902
  });
@@ -904,7 +904,7 @@ let re = class extends T {
904
904
  })
905
905
  ), this.disposeWithMe(
906
906
  this._commandService.onCommandExecuted((e) => {
907
- if (e.id === q.id) {
907
+ if (e.id === Q.id) {
908
908
  const t = e.params, { unitId: n, subUnitId: r, row: i, col: a } = t, o = j(this._univerInstanceService, { unitId: n, subUnitId: r }), d = this._enusreMap(n, r).getValue(i, a);
909
909
  if (d && d.dispose(), o) {
910
910
  const { worksheet: l } = o, u = l.getCellRaw(i, a);
@@ -915,17 +915,17 @@ let re = class extends T {
915
915
  );
916
916
  }
917
917
  };
918
- re = Dt([
918
+ se = Dt([
919
919
  fe(0, b),
920
920
  fe(1, k),
921
921
  fe(2, M(Oe))
922
- ], re);
922
+ ], se);
923
923
  var Nt = Object.getOwnPropertyDescriptor, Ot = (s, e, t, n) => {
924
924
  for (var r = n > 1 ? void 0 : n ? Nt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
925
925
  (a = s[i]) && (r = a(r) || r);
926
926
  return r;
927
- }, X = (s, e) => (t, n) => e(t, n, s);
928
- let se = class extends T {
927
+ }, q = (s, e) => (t, n) => e(t, n, s);
928
+ let ie = class extends T {
929
929
  constructor(s, e, t, n) {
930
930
  super(), this._sheetInterceptorService = s, this._hyperLinkModel = e, this._selectionManagerService = t, this._univerInstanceService = n, this._initCommandInterceptor(), this._initAfterEditor();
931
931
  }
@@ -937,7 +937,7 @@ let se = class extends T {
937
937
  getMutations: (s) => {
938
938
  if (s.id === dt.id) {
939
939
  const e = s.params, { unitId: t, subUnitId: n } = e, r = [], i = [];
940
- return e.cellValue && new Q(e.cellValue).forValue((a, o) => {
940
+ return e.cellValue && new Z(e.cellValue).forValue((a, o) => {
941
941
  const c = this._hyperLinkModel.getHyperLinkByLocation(t, n, a, o);
942
942
  c && (r.push({
943
943
  id: N.id,
@@ -1009,14 +1009,14 @@ let se = class extends T {
1009
1009
  handler: (s, e, t) => {
1010
1010
  if (!s || s.p)
1011
1011
  return t(s);
1012
- if (typeof s.v == "string" && de.isLegalUrl(s.v) && s.v[s.v.length - 1] !== " ") {
1013
- const { unitId: n, subUnitId: r, row: i, col: a } = e, o = this._univerInstanceService.getUnit(n, I.UNIVER_SHEET), c = o == null ? void 0 : o.getSheetBySheetId(r);
1014
- if (!c)
1012
+ if (typeof s.v == "string" && Y.isLegalUrl(s.v) && s.v[s.v.length - 1] !== " ") {
1013
+ const { unitId: n, subUnitId: r, row: i, col: a } = e, o = Y.normalizeUrl(s.v), c = this._univerInstanceService.getUnit(n, I.UNIVER_SHEET), d = c == null ? void 0 : c.getSheetBySheetId(r);
1014
+ if (!d)
1015
1015
  return t(s);
1016
- const d = c.getBlankCellDocumentModel(s, i, a);
1017
- if (!d.documentModel)
1016
+ const l = d.getBlankCellDocumentModel(s, i, a);
1017
+ if (!l.documentModel)
1018
1018
  return t(s);
1019
- const l = Z.selection.replace({
1019
+ const u = ee.selection.replace({
1020
1020
  selection: {
1021
1021
  startOffset: 0,
1022
1022
  endOffset: s.v.length,
@@ -1030,20 +1030,20 @@ let se = class extends T {
1030
1030
  rangeId: le(),
1031
1031
  rangeType: U.HYPERLINK,
1032
1032
  properties: {
1033
- url: s.v
1033
+ url: o
1034
1034
  }
1035
1035
  }]
1036
1036
  },
1037
- doc: d.documentModel
1037
+ doc: l.documentModel
1038
1038
  });
1039
- if (!l)
1039
+ if (!u)
1040
1040
  return t(s);
1041
- const u = d.documentModel.getBody();
1042
- return ce.apply(u, l.serialize()), t({
1041
+ const h = l.documentModel.getBody();
1042
+ return ce.apply(h, u.serialize()), t({
1043
1043
  ...s,
1044
1044
  p: {
1045
1045
  id: Ye,
1046
- body: u,
1046
+ body: h,
1047
1047
  documentStyle: {
1048
1048
  pageSize: {
1049
1049
  width: 1 / 0,
@@ -1058,18 +1058,18 @@ let se = class extends T {
1058
1058
  }));
1059
1059
  }
1060
1060
  };
1061
- se = Ot([
1062
- X(0, M(ue)),
1063
- X(1, M(R)),
1064
- X(2, M(He)),
1065
- X(3, k)
1066
- ], se);
1061
+ ie = Ot([
1062
+ q(0, M(ue)),
1063
+ q(1, M(R)),
1064
+ q(2, M(He)),
1065
+ q(3, k)
1066
+ ], ie);
1067
1067
  var Ht = Object.getOwnPropertyDescriptor, xt = (s, e, t, n) => {
1068
1068
  for (var r = n > 1 ? void 0 : n ? Ht(e, t) : e, i = s.length - 1, a; i >= 0; i--)
1069
1069
  (a = s[i]) && (r = a(r) || r);
1070
1070
  return r;
1071
1071
  }, be = (s, e) => (t, n) => e(t, n, s);
1072
- let ie = class extends T {
1072
+ let ae = class extends T {
1073
1073
  constructor(s, e) {
1074
1074
  super(), this._resourceManagerService = s, this._hyperLinkModel = e, this._initSnapshot();
1075
1075
  }
@@ -1108,16 +1108,16 @@ let ie = class extends T {
1108
1108
  );
1109
1109
  }
1110
1110
  };
1111
- ie = xt([
1111
+ ae = xt([
1112
1112
  be(0, Ge),
1113
1113
  be(1, M(R))
1114
- ], ie);
1114
+ ], ae);
1115
1115
  var Vt = Object.getOwnPropertyDescriptor, Tt = (s, e, t, n) => {
1116
1116
  for (var r = n > 1 ? void 0 : n ? Vt(e, t) : e, i = s.length - 1, a; i >= 0; i--)
1117
1117
  (a = s[i]) && (r = a(r) || r);
1118
1118
  return r;
1119
1119
  }, $t = (s, e) => (t, n) => e(t, n, s);
1120
- let ae = class extends T {
1120
+ let oe = class extends T {
1121
1121
  constructor(s) {
1122
1122
  super(), this._commandService = s, this._registerCommands();
1123
1123
  }
@@ -1133,15 +1133,15 @@ let ae = class extends T {
1133
1133
  _e,
1134
1134
  N,
1135
1135
  ye,
1136
- q
1136
+ Q
1137
1137
  ].forEach((s) => {
1138
1138
  this._commandService.registerCommand(s);
1139
1139
  });
1140
1140
  }
1141
1141
  };
1142
- ae = Tt([
1142
+ oe = Tt([
1143
1143
  $t(0, b)
1144
- ], ae);
1144
+ ], oe);
1145
1145
  var E = /* @__PURE__ */ ((s) => (s.SHEET = "gid", s.RANGE = "range", s.DEFINE_NAME = "rangeid", s.INVALID = "invalid", s.URL = "url", s))(E || {}), At = Object.getOwnPropertyDescriptor, Wt = (s, e, t, n) => {
1146
1146
  for (var r = n > 1 ? void 0 : n ? At(e, t) : e, i = s.length - 1, a; i >= 0; i--)
1147
1147
  (a = s[i]) && (r = a(r) || r);
@@ -1189,7 +1189,7 @@ let ve = class {
1189
1189
  if (t) {
1190
1190
  if (!o) return a;
1191
1191
  const l = Ce(t).range;
1192
- return Ie(l, o) && t !== ee ? {
1192
+ return Ie(l, o) && t !== te ? {
1193
1193
  type: E.RANGE,
1194
1194
  name: mt(c, l)
1195
1195
  } : a;
@@ -1221,7 +1221,7 @@ var Bt = Object.defineProperty, jt = Object.getOwnPropertyDescriptor, Ft = (s, e
1221
1221
  (a = s[i]) && (r = a(r) || r);
1222
1222
  return r;
1223
1223
  }, Pe = (s, e) => (t, n) => e(t, n, s), Ve = (s, e, t) => Ft(s, typeof e != "symbol" ? e + "" : e, t);
1224
- let oe = class extends Qe {
1224
+ let de = class extends Qe {
1225
1225
  constructor(s = Ue, e, t) {
1226
1226
  super(), this._config = s, this._injector = e, this._configService = t;
1227
1227
  const { ...n } = Ze(
@@ -1235,41 +1235,41 @@ let oe = class extends Qe {
1235
1235
  et(this._injector, [
1236
1236
  [R],
1237
1237
  [ve],
1238
- [ie],
1239
1238
  [ae],
1240
- [te],
1241
- [se],
1239
+ [oe],
1242
1240
  [ne],
1243
- [re]
1244
- ]), tt(this._injector, [
1245
- [te],
1246
1241
  [ie],
1247
- [ae],
1248
- [se],
1242
+ [re],
1243
+ [se]
1244
+ ]), tt(this._injector, [
1249
1245
  [ne],
1250
- [re]
1246
+ [ae],
1247
+ [oe],
1248
+ [ie],
1249
+ [re],
1250
+ [se]
1251
1251
  ]);
1252
1252
  }
1253
1253
  };
1254
- Ve(oe, "pluginName", xe);
1255
- Ve(oe, "type", I.UNIVER_SHEET);
1256
- oe = Kt([
1254
+ Ve(de, "pluginName", xe);
1255
+ Ve(de, "type", I.UNIVER_SHEET);
1256
+ de = Kt([
1257
1257
  Je(ht),
1258
1258
  Pe(1, M(Xe)),
1259
1259
  Pe(2, qe)
1260
- ], oe);
1260
+ ], de);
1261
1261
  export {
1262
1262
  St as AddHyperLinkCommand,
1263
1263
  D as AddHyperLinkMutation,
1264
1264
  Rt as AddRichHyperLinkCommand,
1265
1265
  It as CancelHyperLinkCommand,
1266
1266
  Mt as CancelRichHyperLinkCommand,
1267
- ee as ERROR_RANGE,
1267
+ te as ERROR_RANGE,
1268
1268
  R as HyperLinkModel,
1269
1269
  N as RemoveHyperLinkMutation,
1270
1270
  E as SheetHyperLinkType,
1271
1271
  ve as SheetsHyperLinkParserService,
1272
- oe as UniverSheetsHyperLinkPlugin,
1272
+ de as UniverSheetsHyperLinkPlugin,
1273
1273
  Ct as UpdateHyperLinkCommand,
1274
1274
  _e as UpdateHyperLinkMutation,
1275
1275
  ye as UpdateHyperLinkRefMutation,