@univerjs/sheets-hyper-link 0.1.16 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +85 -85
- package/lib/types/index.d.ts +6 -7
- package/lib/umd/index.js +1 -1
- package/package.json +14 -14
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var j=Object.defineProperty;var A=(s,i,e)=>i in s?j(s,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[i]=e;var g=(s,i,e)=>A(s,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@univerjs/core"),M=require("@univerjs/sheets"),T=require("rxjs"),R=require("@wendellhu/redi"),f=require("@univerjs/sheets-hyper-link"),v=require("@univerjs/engine-formula");var V=Object.defineProperty,W=Object.getOwnPropertyDescriptor,q=(s,i,e,n)=>{for(var t=n>1?void 0:n?W(i,e):i,r=s.length-1,o;r>=0;r--)(o=s[r])&&(t=(n?o(i,e,t):o(t))||t);return n&&t&&V(i,e,t),t},G=(s,i)=>(e,n)=>i(e,n,s);exports.HyperLinkModel=class extends d.Disposable{constructor(e){super();g(this,"_linkUpdate$",new T.Subject);g(this,"linkUpdate$",this._linkUpdate$.asObservable());g(this,"_linkMap",new Map);g(this,"_linkPositionMap",new Map);this._univerInstanceService=e,this.disposeWithMe({dispose:()=>{this._linkUpdate$.complete()}})}_ensureMap(e,n){let t=this._linkMap.get(e);t||(t=new Map,this._linkMap.set(e,t));let r=t.get(n);r||(r=new d.ObjectMatrix,t.set(n,r));let o=this._linkPositionMap.get(e);o||(o=new Map,this._linkPositionMap.set(e,o));let a=o.get(n);return a||(a=new Map,o.set(n,a)),{matrix:r,positionMap:a}}addHyperLink(e,n,t){const{matrix:r,positionMap:o}=this._ensureMap(e,n);return r.setValue(t.row,t.column,t),o.set(t.id,{row:t.row,column:t.column,link:t}),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:t,type:"add"}),!0}updateHyperLink(e,n,t,r,o=!1){const{matrix:a,positionMap:c}=this._ensureMap(e,n),l=c.get(t);if(!l)return!0;const p=a.getValue(l.row,l.column);return p&&(Object.assign(p,r),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:{display:p.display,payload:p.payload},id:t,type:"update",silent:o})),!0}updateHyperLinkRef(e,n,t,r,o=!1){const{matrix:a,positionMap:c}=this._ensureMap(e,n),l=c.get(t);if(!l)return!0;let p=a.getValue(l.row,l.column);return!p||p.id!==t?p=l.link:a.realDeleteValue(l.row,l.column),Object.assign(p,r),c.set(t,{...r,link:p}),a.setValue(r.row,r.column,p),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:r,id:t,type:"updateRef",silent:o}),!0}removeHyperLink(e,n,t){const{matrix:r,positionMap:o}=this._ensureMap(e,n),a=o.get(t);if(!a)return!1;o.delete(t);const c=r.getValue(a.row,a.column);return c&&c.id===t&&r.realDeleteValue(a.row,a.column),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:a.link,type:"remove"}),!0}getHyperLink(e,n,t){const{matrix:r,positionMap:o}=this._ensureMap(e,n),a=o.get(t);if(a)return r.getValue(a.row,a.column)}getHyperLinkByLocation(e,n,t,r){const{matrix:o}=this._ensureMap(e,n);return o.getValue(t,r)}getHyperLinkByLocationSync(e,n,t,r){var u,h,y,m,_;const{matrix:o}=this._ensureMap(e,n),a=this._univerInstanceService.getUnit(e,d.UniverInstanceType.UNIVER_SHEET),c=(u=a==null?void 0:a.getSheetBySheetId(n))==null?void 0:u.getCellRaw(t,r),l=((_=(m=c==null?void 0:c.v)!=null?m:(y=(h=c==null?void 0:c.p)==null?void 0:h.body)==null?void 0:y.dataStream.slice(0,-2))!=null?_:"").toString(),p=o.getValue(t,r);if(p)return{...p,display:l}}getSubUnit(e,n){const{matrix:t}=this._ensureMap(e,n),r=[];return t.forValue((o,a,c)=>{c&&r.push(c)}),r}getUnit(e){const n=this._linkMap.get(e);return n?Array.from(n.keys()).map(t=>{const r=this.getSubUnit(e,t);return{unitId:e,subUnitId:t,links:r}}):[]}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=q([G(0,d.IUniverInstanceService)],exports.HyperLinkModel);const S={type:d.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(s,i){if(!i)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:t,link:r}=i;return e.addHyperLink(n,t,r)}},L={type:d.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(s,i){if(!i)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:t,id:r}=i;return e.removeHyperLink(n,t,r)}},U={type:d.CommandType.COMMAND,id:"sheets.command.remove-hyper-link",async handler(s,i){if(!i)return!1;const e=s.get(M.SheetInterceptorService),n=s.get(d.ICommandService),t=s.get(d.IUndoRedoService),r=s.get(exports.HyperLinkModel),{unitId:o,subUnitId:a,id:c}=i,l=r.getHyperLink(o,a,c),{redos:p,undos:u}=e.onCommandExecute({id:U.id,params:i}),h={id:L.id,params:i},y={id:S.id,params:{unitId:o,subUnitId:a,link:l}};return(await d.sequenceExecuteAsync([h,...p],n)).result?(t.pushUndoRedo({redoMutations:[h,...p],undoMutations:[y,...u],unitID:o}),!0):!1}},O={type:d.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",async handler(s,i){if(!i)return!1;const e=s.get(d.ICommandService),n=s.get(d.IUndoRedoService),t=s.get(exports.HyperLinkModel),{unitId:r,subUnitId:o,id:a}=i,c=t.getHyperLink(r,o,a),l={id:L.id,params:i},p={id:S.id,params:{unitId:r,subUnitId:o,link:c}};return(await d.sequenceExecuteAsync([l],e)).result?(n.pushUndoRedo({redoMutations:[l],undoMutations:[p],unitID:r}),!0):!1}},w={type:d.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(s,i){if(!i)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:t,payload:r,id:o}=i;return e.updateHyperLink(n,t,o,r,!1)}},b={type:d.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(s,i){if(!i)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:t,id:r,row:o,column:a,silent:c}=i;return e.updateHyperLinkRef(n,t,r,{row:o,column:a},c)}},P={type:d.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(s,i){if(!i)return!1;const e=s.get(M.SheetInterceptorService),n=s.get(d.ICommandService),t=s.get(d.IUndoRedoService),{unitId:r,subUnitId:o,link:a}=i,{redos:c,undos:l}=e.onCommandExecute({id:P.id,params:i}),p={id:S.id,params:i},u={id:L.id,params:{unitId:r,subUnitId:o,id:a.id}};return(await d.sequenceExecuteAsync([p,...c],n)).result?(t.pushUndoRedo({redoMutations:[p,...c],undoMutations:[u,...l],unitID:r}),!0):!1}};function J(s){const{row:i,column:e,id:n,...t}=s;return t}const I={type:d.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(s,i){if(!i)return!1;const e=s.get(M.SheetInterceptorService),n=s.get(d.ICommandService),t=s.get(d.IUndoRedoService),r=s.get(exports.HyperLinkModel),{unitId:o,subUnitId:a,id:c}=i,l=r.getHyperLink(o,a,c);if(!l)return!1;const{redos:p,undos:u}=e.onCommandExecute({id:I.id,params:i}),h={id:w.id,params:i},y={id:w.id,params:{unitId:o,subUnitId:a,id:c,payload:J(l)}};return(await d.sequenceExecuteAsync([h,...p],n)).result?(t.pushUndoRedo({redoMutations:[h,...p],undoMutations:[y,...u],unitID:o}),!0):!1}};var z=Object.defineProperty,K=Object.getOwnPropertyDescriptor,B=(s,i,e,n)=>{for(var t=n>1?void 0:n?K(i,e):i,r=s.length-1,o;r>=0;r--)(o=s[r])&&(t=(n?o(i,e,t):o(t))||t);return n&&t&&z(i,e,t),t},Y=(s,i)=>(e,n)=>i(e,n,s);exports.SheetsHyperLinkController=class extends d.Disposable{constructor(i){super(),this._commandService=i,this._registerCommands()}_registerCommands(){[S,w,L,b,P,I,U,O].forEach(i=>{this._commandService.registerCommand(i)})}};exports.SheetsHyperLinkController=B([d.OnLifecycle(d.LifecycleStages.Starting,exports.SheetsHyperLinkController),Y(0,d.ICommandService)],exports.SheetsHyperLinkController);var D=(s=>(s[s.range=0]="range",s[s.link=1]="link",s))(D||{});const N="SHEET_HYPER_LINK_PLUGIN",$="err";var x=(s=>(s[s.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",s[s.UNIVER_DOC=1]="UNIVER_DOC",s[s.UNIVER_SHEET=2]="UNIVER_SHEET",s[s.UNIVER_SLIDE=3]="UNIVER_SLIDE",s[s.UNRECOGNIZED=-1]="UNRECOGNIZED",s))(x||{}),Z=Object.defineProperty,F=Object.getOwnPropertyDescriptor,Q=(s,i,e,n)=>{for(var t=n>1?void 0:n?F(i,e):i,r=s.length-1,o;r>=0;r--)(o=s[r])&&(t=(n?o(i,e,t):o(t))||t);return n&&t&&Z(i,e,t),t},E=(s,i)=>(e,n)=>i(e,n,s);let C=class extends d.Disposable{constructor(s,i){super(),this._resourceManagerService=s,this._hyperLinkModel=i,this._initSnapshot()}_initSnapshot(){const s=e=>{const n=this._hyperLinkModel.getUnit(e),t={};return n?(n.forEach(r=>{t[r.subUnitId]=r.links.map(({display:o,...a})=>a)}),JSON.stringify(t)):""},i=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:N,businesses:[x.UNIVER_SHEET],toJson:e=>s(e),parseJson:e=>i(e),onUnLoad:e=>{this._hyperLinkModel.deleteUnit(e)},onLoad:async(e,n)=>{Object.keys(n).forEach(t=>{n[t].forEach(o=>{this._hyperLinkModel.addHyperLink(e,t,o)})})}}))}};C=Q([d.OnLifecycle(d.LifecycleStages.Starting,C),E(0,d.IResourceManagerService),E(1,R.Inject(exports.HyperLinkModel))],C);var X=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,te=(s,i,e,n)=>{for(var t=n>1?void 0:n?ee(i,e):i,r=s.length-1,o;r>=0;r--)(o=s[r])&&(t=(n?o(i,e,t):o(t))||t);return n&&t&&X(i,e,t),t},k=(s,i)=>(e,n)=>i(e,n,s);exports.SheetsHyperLinkRefRangeController=class extends d.Disposable{constructor(e,n,t,r){super();g(this,"_disposableMap",new Map);g(this,"_watchDisposableMap",new Map);g(this,"_rangeDisableMap",new Map);g(this,"_rangeWatcherMap",new Map);g(this,"_handlePositionChange",(e,n,t,r,o)=>{const a={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};return r?{redos:[{id:f.UpdateHyperLinkRefMutation.id,params:{unitId:e,subUnitId:n,id:t.id,row:r.startRow,column:r.startColumn,silent:o}}],undos:[{id:f.UpdateHyperLinkRefMutation.id,params:{unitId:e,subUnitId:n,id:t.id,row:a.startRow,column:a.startColumn,silent:o}}]}:{redos:[{id:f.RemoveHyperLinkMutation.id,params:{unitId:e,subUnitId:n,id:t.id}}],undos:[{id:f.AddHyperLinkMutation.id,params:{unitId:e,subUnitId:n,link:t}}]}});this._refRangeService=e,this._hyperLinkModel=n,this._selectionManagerService=t,this._commandService=r,this._initData(),this._initRefRange()}_registerPosition(e,n,t){const r=t.id,o={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row},a=c=>{const l=M.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(o,c,{selectionManagerService:this._selectionManagerService});return l&&l.startColumn===o.startColumn&&l.startRow===o.startRow?{undos:[],redos:[]}:this._handlePositionChange(e,n,t,l,!1)};this._disposableMap.set(r,this._refRangeService.registerRefRange(o,a,e,n))}_watchPosition(e,n,t){const r=t.id,o={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._watchDisposableMap.set(r,this._refRangeService.watchRange(e,n,o,(a,c)=>{const{redos:l}=this._handlePositionChange(e,n,t,c,!0);d.sequenceExecuteAsync(l,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(e){const n=this._disposableMap.get(e);n==null||n.dispose(),this._disposableMap.delete(e)}_unwatchPosition(e){const n=this._watchDisposableMap.get(e);n==null||n.dispose(),this._watchDisposableMap.delete(e)}_registerRange(e,n,t,r=!1){var o,a,c;if(t.startsWith("#")){const l=new URLSearchParams(t.slice(1)),p={gid:(o=l.get("gid"))!=null?o:"",range:(a=l.get("range"))!=null?a:"",rangeid:(c=l.get("rangeid"))!=null?c:""};if(p.range&&p.gid){const u=p.gid,h=v.deserializeRangeWithSheet(p.range).range;if(d.isValidRange(h)&&p.range!==$){const y=m=>{const _=M.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(h,m,{selectionManagerService:this._selectionManagerService});return _&&v.serializeRange(_)===v.serializeRange(h)?{redos:[],undos:[]}:{redos:[{id:f.UpdateHyperLinkMutation.id,params:{unitId:e,subUnitId:u,id:n,payload:{payload:`#gid=${u}&range=${_?v.serializeRange(_):"err"}`}}}],undos:[{id:f.UpdateHyperLinkMutation.id,params:{unitId:e,subUnitId:u,id:n,payload:{payload:t}}}]}};this._rangeDisableMap.set(n,this._refRangeService.registerRefRange(h,y,e,u)),r||this._rangeWatcherMap.set(n,this._refRangeService.watchRange(e,u,h,(m,_)=>{this._hyperLinkModel.updateHyperLink(e,u,n,{payload:`#gid=${u}&range=${_?v.serializeRange(_):"err"}`},!0)},!0))}}}}_unregisterRange(e){const n=this._rangeDisableMap.get(e);n==null||n.dispose(),this._rangeDisableMap.delete(e)}_unwatchRange(e){const n=this._rangeWatcherMap.get(e);n==null||n.dispose(),this._rangeWatcherMap.delete(e)}_initData(){this._hyperLinkModel.getAll().forEach(n=>{n.forEach(t=>{const{unitId:r,subUnitId:o,links:a}=t;a.forEach(c=>{this._registerPosition(r,o,c),this._watchPosition(r,o,c),this._registerRange(r,c.id,c.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(e=>{switch(e.type){case"add":{this._registerPosition(e.unitId,e.subUnitId,e.payload),this._watchPosition(e.unitId,e.subUnitId,e.payload),this._registerRange(e.unitId,e.payload.id,e.payload.payload);break}case"remove":{this._unregisterPosition(e.payload.id),this._unwatchPosition(e.payload.id),this._unregisterRange(e.payload.id),this._unwatchRange(e.payload.id);break}case"updateRef":{const{unitId:n,subUnitId:t,id:r,silent:o}=e,a=this._hyperLinkModel.getHyperLink(n,t,r);if(!a)return;this._unregisterPosition(r),this._registerPosition(n,t,a),o||(this._unwatchPosition(r),this._watchPosition(n,t,a));break}case"unload":{const{unitLinks:n}=e;n.forEach(t=>{const{links:r}=t;r.forEach(o=>{this._unregisterPosition(o.id),this._unwatchPosition(o.id),this._unregisterRange(o.id),this._unwatchRange(o.id)})});break}case"update":{e.silent||this._unwatchRange(e.id),this._unregisterRange(e.id),this._registerRange(e.unitId,e.id,e.payload.payload,e.silent);break}}})),this.disposeWithMe(d.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};exports.SheetsHyperLinkRefRangeController=te([d.OnLifecycle(d.LifecycleStages.Starting,exports.SheetsHyperLinkRefRangeController),k(0,R.Inject(M.RefRangeService)),k(1,R.Inject(f.HyperLinkModel)),k(2,R.Inject(M.SelectionManagerService)),k(3,d.ICommandService)],exports.SheetsHyperLinkRefRangeController);var ne=Object.defineProperty,re=Object.getOwnPropertyDescriptor,ie=(s,i,e,n)=>{for(var t=n>1?void 0:n?re(i,e):i,r=s.length-1,o;r>=0;r--)(o=s[r])&&(t=(n?o(i,e,t):o(t))||t);return n&&t&&ne(i,e,t),t},se=(s,i)=>(e,n)=>i(e,n,s),H;exports.UniverSheetsHyperLinkPlugin=(H=class extends d.Plugin{constructor(i,e){super(),this._injector=e}onStarting(i){[[C],[exports.SheetsHyperLinkController],[exports.SheetsHyperLinkRefRangeController],[exports.HyperLinkModel]].forEach(e=>{i.add(e)})}},g(H,"pluginName",N),g(H,"type",d.UniverInstanceType.UNIVER_SHEET),H);exports.UniverSheetsHyperLinkPlugin=ie([se(1,R.Inject(R.Injector))],exports.UniverSheetsHyperLinkPlugin);exports.AddHyperLinkCommand=P;exports.AddHyperLinkMutation=S;exports.CancelHyperLinkCommand=O;exports.ERROR_RANGE=$;exports.HyperLinkType=D;exports.RemoveHyperLinkCommand=U;exports.RemoveHyperLinkMutation=L;exports.UpdateHyperLinkCommand=I;exports.UpdateHyperLinkMutation=w;exports.UpdateHyperLinkRefMutation=b;
|
|
1
|
+
"use strict";var j=Object.defineProperty;var A=(s,i,e)=>i in s?j(s,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[i]=e;var g=(s,i,e)=>A(s,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("rxjs"),d=require("@univerjs/core"),M=require("@univerjs/sheets"),R=require("@wendellhu/redi"),f=require("@univerjs/sheets-hyper-link"),v=require("@univerjs/engine-formula");var V=Object.defineProperty,W=Object.getOwnPropertyDescriptor,q=(s,i,e,n)=>{for(var t=n>1?void 0:n?W(i,e):i,r=s.length-1,o;r>=0;r--)(o=s[r])&&(t=(n?o(i,e,t):o(t))||t);return n&&t&&V(i,e,t),t},G=(s,i)=>(e,n)=>i(e,n,s);exports.HyperLinkModel=class extends d.Disposable{constructor(e){super();g(this,"_linkUpdate$",new T.Subject);g(this,"linkUpdate$",this._linkUpdate$.asObservable());g(this,"_linkMap",new Map);g(this,"_linkPositionMap",new Map);this._univerInstanceService=e,this.disposeWithMe({dispose:()=>{this._linkUpdate$.complete()}})}_ensureMap(e,n){let t=this._linkMap.get(e);t||(t=new Map,this._linkMap.set(e,t));let r=t.get(n);r||(r=new d.ObjectMatrix,t.set(n,r));let o=this._linkPositionMap.get(e);o||(o=new Map,this._linkPositionMap.set(e,o));let a=o.get(n);return a||(a=new Map,o.set(n,a)),{matrix:r,positionMap:a}}addHyperLink(e,n,t){const{matrix:r,positionMap:o}=this._ensureMap(e,n);return r.setValue(t.row,t.column,t),o.set(t.id,{row:t.row,column:t.column,link:t}),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:t,type:"add"}),!0}updateHyperLink(e,n,t,r,o=!1){const{matrix:a,positionMap:c}=this._ensureMap(e,n),l=c.get(t);if(!l)return!0;const p=a.getValue(l.row,l.column);return p&&(Object.assign(p,r),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:{display:p.display,payload:p.payload},id:t,type:"update",silent:o})),!0}updateHyperLinkRef(e,n,t,r,o=!1){const{matrix:a,positionMap:c}=this._ensureMap(e,n),l=c.get(t);if(!l)return!0;let p=a.getValue(l.row,l.column);return!p||p.id!==t?p=l.link:a.realDeleteValue(l.row,l.column),Object.assign(p,r),c.set(t,{...r,link:p}),a.setValue(r.row,r.column,p),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:r,id:t,type:"updateRef",silent:o}),!0}removeHyperLink(e,n,t){const{matrix:r,positionMap:o}=this._ensureMap(e,n),a=o.get(t);if(!a)return!1;o.delete(t);const c=r.getValue(a.row,a.column);return c&&c.id===t&&r.realDeleteValue(a.row,a.column),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:a.link,type:"remove"}),!0}getHyperLink(e,n,t){const{matrix:r,positionMap:o}=this._ensureMap(e,n),a=o.get(t);if(a)return r.getValue(a.row,a.column)}getHyperLinkByLocation(e,n,t,r){const{matrix:o}=this._ensureMap(e,n);return o.getValue(t,r)}getHyperLinkByLocationSync(e,n,t,r){var u,h,y,m,_;const{matrix:o}=this._ensureMap(e,n),a=this._univerInstanceService.getUnit(e,d.UniverInstanceType.UNIVER_SHEET),c=(u=a==null?void 0:a.getSheetBySheetId(n))==null?void 0:u.getCellRaw(t,r),l=((_=(m=c==null?void 0:c.v)!=null?m:(y=(h=c==null?void 0:c.p)==null?void 0:h.body)==null?void 0:y.dataStream.slice(0,-2))!=null?_:"").toString(),p=o.getValue(t,r);if(p)return{...p,display:l}}getSubUnit(e,n){const{matrix:t}=this._ensureMap(e,n),r=[];return t.forValue((o,a,c)=>{c&&r.push(c)}),r}getUnit(e){const n=this._linkMap.get(e);return n?Array.from(n.keys()).map(t=>{const r=this.getSubUnit(e,t);return{unitId:e,subUnitId:t,links:r}}):[]}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=q([G(0,d.IUniverInstanceService)],exports.HyperLinkModel);const S={type:d.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(s,i){if(!i)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:t,link:r}=i;return e.addHyperLink(n,t,r)}},w={type:d.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(s,i){if(!i)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:t,payload:r,id:o}=i;return e.updateHyperLink(n,t,o,r,!1)}},O={type:d.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(s,i){if(!i)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:t,id:r,row:o,column:a,silent:c}=i;return e.updateHyperLinkRef(n,t,r,{row:o,column:a},c)}},L={type:d.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(s,i){if(!i)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:t,id:r}=i;return e.removeHyperLink(n,t,r)}},U={type:d.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(s,i){if(!i)return!1;const e=s.get(M.SheetInterceptorService),n=s.get(d.ICommandService),t=s.get(d.IUndoRedoService),{unitId:r,subUnitId:o,link:a}=i,{redos:c,undos:l}=e.onCommandExecute({id:U.id,params:i}),p={id:S.id,params:i},u={id:L.id,params:{unitId:r,subUnitId:o,id:a.id}};return(await d.sequenceExecuteAsync([p,...c],n)).result?(t.pushUndoRedo({redoMutations:[p,...c],undoMutations:[u,...l],unitID:r}),!0):!1}};function J(s){const{row:i,column:e,id:n,...t}=s;return t}const P={type:d.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(s,i){if(!i)return!1;const e=s.get(M.SheetInterceptorService),n=s.get(d.ICommandService),t=s.get(d.IUndoRedoService),r=s.get(exports.HyperLinkModel),{unitId:o,subUnitId:a,id:c}=i,l=r.getHyperLink(o,a,c);if(!l)return!1;const{redos:p,undos:u}=e.onCommandExecute({id:P.id,params:i}),h={id:w.id,params:i},y={id:w.id,params:{unitId:o,subUnitId:a,id:c,payload:J(l)}};return(await d.sequenceExecuteAsync([h,...p],n)).result?(t.pushUndoRedo({redoMutations:[h,...p],undoMutations:[y,...u],unitID:o}),!0):!1}},I={type:d.CommandType.COMMAND,id:"sheets.command.remove-hyper-link",async handler(s,i){if(!i)return!1;const e=s.get(M.SheetInterceptorService),n=s.get(d.ICommandService),t=s.get(d.IUndoRedoService),r=s.get(exports.HyperLinkModel),{unitId:o,subUnitId:a,id:c}=i,l=r.getHyperLink(o,a,c),{redos:p,undos:u}=e.onCommandExecute({id:I.id,params:i}),h={id:L.id,params:i},y={id:S.id,params:{unitId:o,subUnitId:a,link:l}};return(await d.sequenceExecuteAsync([h,...p],n)).result?(t.pushUndoRedo({redoMutations:[h,...p],undoMutations:[y,...u],unitID:o}),!0):!1}},b={type:d.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",async handler(s,i){if(!i)return!1;const e=s.get(d.ICommandService),n=s.get(d.IUndoRedoService),t=s.get(exports.HyperLinkModel),{unitId:r,subUnitId:o,id:a}=i,c=t.getHyperLink(r,o,a),l={id:L.id,params:i},p={id:S.id,params:{unitId:r,subUnitId:o,link:c}};return(await d.sequenceExecuteAsync([l],e)).result?(n.pushUndoRedo({redoMutations:[l],undoMutations:[p],unitID:r}),!0):!1}};var z=Object.defineProperty,K=Object.getOwnPropertyDescriptor,B=(s,i,e,n)=>{for(var t=n>1?void 0:n?K(i,e):i,r=s.length-1,o;r>=0;r--)(o=s[r])&&(t=(n?o(i,e,t):o(t))||t);return n&&t&&z(i,e,t),t},Y=(s,i)=>(e,n)=>i(e,n,s);exports.SheetsHyperLinkController=class extends d.Disposable{constructor(i){super(),this._commandService=i,this._registerCommands()}_registerCommands(){[S,w,L,O,U,P,I,b].forEach(i=>{this._commandService.registerCommand(i)})}};exports.SheetsHyperLinkController=B([d.OnLifecycle(d.LifecycleStages.Starting,exports.SheetsHyperLinkController),Y(0,d.ICommandService)],exports.SheetsHyperLinkController);var D=(s=>(s[s.range=0]="range",s[s.link=1]="link",s))(D||{});const N="SHEET_HYPER_LINK_PLUGIN",$="err";var x=(s=>(s[s.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",s[s.UNIVER_DOC=1]="UNIVER_DOC",s[s.UNIVER_SHEET=2]="UNIVER_SHEET",s[s.UNIVER_SLIDE=3]="UNIVER_SLIDE",s[s.UNRECOGNIZED=-1]="UNRECOGNIZED",s))(x||{}),Z=Object.defineProperty,F=Object.getOwnPropertyDescriptor,Q=(s,i,e,n)=>{for(var t=n>1?void 0:n?F(i,e):i,r=s.length-1,o;r>=0;r--)(o=s[r])&&(t=(n?o(i,e,t):o(t))||t);return n&&t&&Z(i,e,t),t},E=(s,i)=>(e,n)=>i(e,n,s);let C=class extends d.Disposable{constructor(s,i){super(),this._resourceManagerService=s,this._hyperLinkModel=i,this._initSnapshot()}_initSnapshot(){const s=e=>{const n=this._hyperLinkModel.getUnit(e),t={};return n?(n.forEach(r=>{t[r.subUnitId]=r.links.map(({display:o,...a})=>a)}),JSON.stringify(t)):""},i=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:N,businesses:[x.UNIVER_SHEET],toJson:e=>s(e),parseJson:e=>i(e),onUnLoad:e=>{this._hyperLinkModel.deleteUnit(e)},onLoad:async(e,n)=>{Object.keys(n).forEach(t=>{n[t].forEach(o=>{this._hyperLinkModel.addHyperLink(e,t,o)})})}}))}};C=Q([d.OnLifecycle(d.LifecycleStages.Starting,C),E(0,d.IResourceManagerService),E(1,R.Inject(exports.HyperLinkModel))],C);var X=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,te=(s,i,e,n)=>{for(var t=n>1?void 0:n?ee(i,e):i,r=s.length-1,o;r>=0;r--)(o=s[r])&&(t=(n?o(i,e,t):o(t))||t);return n&&t&&X(i,e,t),t},k=(s,i)=>(e,n)=>i(e,n,s);exports.SheetsHyperLinkRefRangeController=class extends d.Disposable{constructor(e,n,t,r){super();g(this,"_disposableMap",new Map);g(this,"_watchDisposableMap",new Map);g(this,"_rangeDisableMap",new Map);g(this,"_rangeWatcherMap",new Map);g(this,"_handlePositionChange",(e,n,t,r,o)=>{const a={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};return r?{redos:[{id:f.UpdateHyperLinkRefMutation.id,params:{unitId:e,subUnitId:n,id:t.id,row:r.startRow,column:r.startColumn,silent:o}}],undos:[{id:f.UpdateHyperLinkRefMutation.id,params:{unitId:e,subUnitId:n,id:t.id,row:a.startRow,column:a.startColumn,silent:o}}]}:{redos:[{id:f.RemoveHyperLinkMutation.id,params:{unitId:e,subUnitId:n,id:t.id}}],undos:[{id:f.AddHyperLinkMutation.id,params:{unitId:e,subUnitId:n,link:t}}]}});this._refRangeService=e,this._hyperLinkModel=n,this._selectionManagerService=t,this._commandService=r,this._initData(),this._initRefRange()}_registerPosition(e,n,t){const r=t.id,o={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row},a=c=>{const l=M.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(o,c,{selectionManagerService:this._selectionManagerService});return l&&l.startColumn===o.startColumn&&l.startRow===o.startRow?{undos:[],redos:[]}:this._handlePositionChange(e,n,t,l,!1)};this._disposableMap.set(r,this._refRangeService.registerRefRange(o,a,e,n))}_watchPosition(e,n,t){const r=t.id,o={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._watchDisposableMap.set(r,this._refRangeService.watchRange(e,n,o,(a,c)=>{const{redos:l}=this._handlePositionChange(e,n,t,c,!0);d.sequenceExecuteAsync(l,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(e){const n=this._disposableMap.get(e);n==null||n.dispose(),this._disposableMap.delete(e)}_unwatchPosition(e){const n=this._watchDisposableMap.get(e);n==null||n.dispose(),this._watchDisposableMap.delete(e)}_registerRange(e,n,t,r=!1){var o,a,c;if(t.startsWith("#")){const l=new URLSearchParams(t.slice(1)),p={gid:(o=l.get("gid"))!=null?o:"",range:(a=l.get("range"))!=null?a:"",rangeid:(c=l.get("rangeid"))!=null?c:""};if(p.range&&p.gid){const u=p.gid,h=v.deserializeRangeWithSheet(p.range).range;if(d.isValidRange(h)&&p.range!==$){const y=m=>{const _=M.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(h,m,{selectionManagerService:this._selectionManagerService});return _&&v.serializeRange(_)===v.serializeRange(h)?{redos:[],undos:[]}:{redos:[{id:f.UpdateHyperLinkMutation.id,params:{unitId:e,subUnitId:u,id:n,payload:{payload:`#gid=${u}&range=${_?v.serializeRange(_):"err"}`}}}],undos:[{id:f.UpdateHyperLinkMutation.id,params:{unitId:e,subUnitId:u,id:n,payload:{payload:t}}}]}};this._rangeDisableMap.set(n,this._refRangeService.registerRefRange(h,y,e,u)),r||this._rangeWatcherMap.set(n,this._refRangeService.watchRange(e,u,h,(m,_)=>{this._hyperLinkModel.updateHyperLink(e,u,n,{payload:`#gid=${u}&range=${_?v.serializeRange(_):"err"}`},!0)},!0))}}}}_unregisterRange(e){const n=this._rangeDisableMap.get(e);n==null||n.dispose(),this._rangeDisableMap.delete(e)}_unwatchRange(e){const n=this._rangeWatcherMap.get(e);n==null||n.dispose(),this._rangeWatcherMap.delete(e)}_initData(){this._hyperLinkModel.getAll().forEach(n=>{n.forEach(t=>{const{unitId:r,subUnitId:o,links:a}=t;a.forEach(c=>{this._registerPosition(r,o,c),this._watchPosition(r,o,c),this._registerRange(r,c.id,c.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(e=>{switch(e.type){case"add":{this._registerPosition(e.unitId,e.subUnitId,e.payload),this._watchPosition(e.unitId,e.subUnitId,e.payload),this._registerRange(e.unitId,e.payload.id,e.payload.payload);break}case"remove":{this._unregisterPosition(e.payload.id),this._unwatchPosition(e.payload.id),this._unregisterRange(e.payload.id),this._unwatchRange(e.payload.id);break}case"updateRef":{const{unitId:n,subUnitId:t,id:r,silent:o}=e,a=this._hyperLinkModel.getHyperLink(n,t,r);if(!a)return;this._unregisterPosition(r),this._registerPosition(n,t,a),o||(this._unwatchPosition(r),this._watchPosition(n,t,a));break}case"unload":{const{unitLinks:n}=e;n.forEach(t=>{const{links:r}=t;r.forEach(o=>{this._unregisterPosition(o.id),this._unwatchPosition(o.id),this._unregisterRange(o.id),this._unwatchRange(o.id)})});break}case"update":{e.silent||this._unwatchRange(e.id),this._unregisterRange(e.id),this._registerRange(e.unitId,e.id,e.payload.payload,e.silent);break}}})),this.disposeWithMe(d.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};exports.SheetsHyperLinkRefRangeController=te([d.OnLifecycle(d.LifecycleStages.Starting,exports.SheetsHyperLinkRefRangeController),k(0,R.Inject(M.RefRangeService)),k(1,R.Inject(f.HyperLinkModel)),k(2,R.Inject(M.SelectionManagerService)),k(3,d.ICommandService)],exports.SheetsHyperLinkRefRangeController);var ne=Object.defineProperty,re=Object.getOwnPropertyDescriptor,ie=(s,i,e,n)=>{for(var t=n>1?void 0:n?re(i,e):i,r=s.length-1,o;r>=0;r--)(o=s[r])&&(t=(n?o(i,e,t):o(t))||t);return n&&t&&ne(i,e,t),t},se=(s,i)=>(e,n)=>i(e,n,s),H;exports.UniverSheetsHyperLinkPlugin=(H=class extends d.Plugin{constructor(i,e){super(),this._injector=e}onStarting(i){[[C],[exports.SheetsHyperLinkController],[exports.SheetsHyperLinkRefRangeController],[exports.HyperLinkModel]].forEach(e=>{i.add(e)})}},g(H,"pluginName",N),g(H,"type",d.UniverInstanceType.UNIVER_SHEET),H);exports.UniverSheetsHyperLinkPlugin=ie([se(1,R.Inject(R.Injector))],exports.UniverSheetsHyperLinkPlugin);exports.AddHyperLinkCommand=U;exports.AddHyperLinkMutation=S;exports.CancelHyperLinkCommand=b;exports.ERROR_RANGE=$;exports.HyperLinkType=D;exports.RemoveHyperLinkCommand=I;exports.RemoveHyperLinkMutation=L;exports.UpdateHyperLinkCommand=P;exports.UpdateHyperLinkMutation=w;exports.UpdateHyperLinkRefMutation=O;
|
package/lib/es/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var B = Object.defineProperty;
|
|
2
2
|
var z = (s, e, t) => e in s ? B(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
3
|
var h = (s, e, t) => z(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { Subject as Y } from "rxjs";
|
|
5
|
+
import { Disposable as k, ObjectMatrix as Z, UniverInstanceType as A, IUniverInstanceService as q, CommandType as m, ICommandService as M, IUndoRedoService as C, sequenceExecuteAsync as R, OnLifecycle as E, LifecycleStages as D, IResourceManagerService as F, isValidRange as Q, toDisposable as X, Plugin as ee } from "@univerjs/core";
|
|
6
|
+
import { SheetInterceptorService as N, RefRangeService as te, SelectionManagerService as ne, handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests as I } from "@univerjs/sheets";
|
|
7
7
|
import { Inject as y, Injector as re } from "@wendellhu/redi";
|
|
8
8
|
import { HyperLinkModel as se, RemoveHyperLinkMutation as ie, AddHyperLinkMutation as ae, UpdateHyperLinkRefMutation as $, UpdateHyperLinkMutation as x } from "@univerjs/sheets-hyper-link";
|
|
9
9
|
import { deserializeRangeWithSheet as oe, serializeRange as v } from "@univerjs/engine-formula";
|
|
@@ -15,7 +15,7 @@ var de = Object.defineProperty, ce = Object.getOwnPropertyDescriptor, ue = (s, e
|
|
|
15
15
|
let _ = class extends k {
|
|
16
16
|
constructor(e) {
|
|
17
17
|
super();
|
|
18
|
-
h(this, "_linkUpdate$", new
|
|
18
|
+
h(this, "_linkUpdate$", new Y());
|
|
19
19
|
h(this, "linkUpdate$", this._linkUpdate$.asObservable());
|
|
20
20
|
h(this, "_linkMap", /* @__PURE__ */ new Map());
|
|
21
21
|
h(this, "_linkPositionMap", /* @__PURE__ */ new Map());
|
|
@@ -29,7 +29,7 @@ let _ = class extends k {
|
|
|
29
29
|
let n = this._linkMap.get(e);
|
|
30
30
|
n || (n = /* @__PURE__ */ new Map(), this._linkMap.set(e, n));
|
|
31
31
|
let r = n.get(t);
|
|
32
|
-
r || (r = new
|
|
32
|
+
r || (r = new Z(), n.set(t, r));
|
|
33
33
|
let i = this._linkPositionMap.get(e);
|
|
34
34
|
i || (i = /* @__PURE__ */ new Map(), this._linkPositionMap.set(e, i));
|
|
35
35
|
let a = i.get(t);
|
|
@@ -139,7 +139,7 @@ let _ = class extends k {
|
|
|
139
139
|
}
|
|
140
140
|
};
|
|
141
141
|
_ = ue([
|
|
142
|
-
pe(0,
|
|
142
|
+
pe(0, q)
|
|
143
143
|
], _);
|
|
144
144
|
const H = {
|
|
145
145
|
type: m.MUTATION,
|
|
@@ -150,64 +150,6 @@ const H = {
|
|
|
150
150
|
const t = s.get(_), { unitId: n, subUnitId: r, link: i } = e;
|
|
151
151
|
return t.addHyperLink(n, r, i);
|
|
152
152
|
}
|
|
153
|
-
}, O = {
|
|
154
|
-
type: m.MUTATION,
|
|
155
|
-
id: "sheets.mutation.remove-hyper-link",
|
|
156
|
-
handler(s, e) {
|
|
157
|
-
if (!e)
|
|
158
|
-
return !1;
|
|
159
|
-
const t = s.get(_), { unitId: n, subUnitId: r, id: i } = e;
|
|
160
|
-
return t.removeHyperLink(n, r, i);
|
|
161
|
-
}
|
|
162
|
-
}, T = {
|
|
163
|
-
type: m.COMMAND,
|
|
164
|
-
id: "sheets.command.remove-hyper-link",
|
|
165
|
-
async handler(s, e) {
|
|
166
|
-
if (!e)
|
|
167
|
-
return !1;
|
|
168
|
-
const t = s.get(N), n = s.get(M), r = s.get(C), i = s.get(_), { unitId: a, subUnitId: o, id: d } = e, c = i.getHyperLink(a, o, d), { redos: u, undos: p } = t.onCommandExecute({
|
|
169
|
-
id: T.id,
|
|
170
|
-
params: e
|
|
171
|
-
}), g = {
|
|
172
|
-
id: O.id,
|
|
173
|
-
params: e
|
|
174
|
-
}, f = {
|
|
175
|
-
id: H.id,
|
|
176
|
-
params: {
|
|
177
|
-
unitId: a,
|
|
178
|
-
subUnitId: o,
|
|
179
|
-
link: c
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
return (await R([g, ...u], n)).result ? (r.pushUndoRedo({
|
|
183
|
-
redoMutations: [g, ...u],
|
|
184
|
-
undoMutations: [f, ...p],
|
|
185
|
-
unitID: a
|
|
186
|
-
}), !0) : !1;
|
|
187
|
-
}
|
|
188
|
-
}, le = {
|
|
189
|
-
type: m.COMMAND,
|
|
190
|
-
id: "sheets.command.cancel-hyper-link",
|
|
191
|
-
async handler(s, e) {
|
|
192
|
-
if (!e)
|
|
193
|
-
return !1;
|
|
194
|
-
const t = s.get(M), n = s.get(C), r = s.get(_), { unitId: i, subUnitId: a, id: o } = e, d = r.getHyperLink(i, a, o), c = {
|
|
195
|
-
id: O.id,
|
|
196
|
-
params: e
|
|
197
|
-
}, u = {
|
|
198
|
-
id: H.id,
|
|
199
|
-
params: {
|
|
200
|
-
unitId: i,
|
|
201
|
-
subUnitId: a,
|
|
202
|
-
link: d
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
return (await R([c], t)).result ? (n.pushUndoRedo({
|
|
206
|
-
redoMutations: [c],
|
|
207
|
-
undoMutations: [u],
|
|
208
|
-
unitID: i
|
|
209
|
-
}), !0) : !1;
|
|
210
|
-
}
|
|
211
153
|
}, b = {
|
|
212
154
|
type: m.MUTATION,
|
|
213
155
|
id: "sheets.mutation.update-hyper-link",
|
|
@@ -217,7 +159,7 @@ const H = {
|
|
|
217
159
|
const t = s.get(_), { unitId: n, subUnitId: r, payload: i, id: a } = e;
|
|
218
160
|
return t.updateHyperLink(n, r, a, i, !1);
|
|
219
161
|
}
|
|
220
|
-
},
|
|
162
|
+
}, le = {
|
|
221
163
|
type: m.MUTATION,
|
|
222
164
|
id: "sheets.mutation.update-hyper-link-ref",
|
|
223
165
|
handler(s, e) {
|
|
@@ -226,14 +168,23 @@ const H = {
|
|
|
226
168
|
const t = s.get(_), { unitId: n, subUnitId: r, id: i, row: a, column: o, silent: d } = e;
|
|
227
169
|
return t.updateHyperLinkRef(n, r, i, { row: a, column: o }, d);
|
|
228
170
|
}
|
|
229
|
-
},
|
|
171
|
+
}, O = {
|
|
172
|
+
type: m.MUTATION,
|
|
173
|
+
id: "sheets.mutation.remove-hyper-link",
|
|
174
|
+
handler(s, e) {
|
|
175
|
+
if (!e)
|
|
176
|
+
return !1;
|
|
177
|
+
const t = s.get(_), { unitId: n, subUnitId: r, id: i } = e;
|
|
178
|
+
return t.removeHyperLink(n, r, i);
|
|
179
|
+
}
|
|
180
|
+
}, T = {
|
|
230
181
|
type: m.COMMAND,
|
|
231
182
|
id: "sheets.command.add-hyper-link",
|
|
232
183
|
async handler(s, e) {
|
|
233
184
|
if (!e)
|
|
234
185
|
return !1;
|
|
235
186
|
const t = s.get(N), n = s.get(M), r = s.get(C), { unitId: i, subUnitId: a, link: o } = e, { redos: d, undos: c } = t.onCommandExecute({
|
|
236
|
-
id:
|
|
187
|
+
id: T.id,
|
|
237
188
|
params: e
|
|
238
189
|
}), u = {
|
|
239
190
|
id: H.id,
|
|
@@ -253,11 +204,11 @@ const H = {
|
|
|
253
204
|
}), !0) : !1;
|
|
254
205
|
}
|
|
255
206
|
};
|
|
256
|
-
function
|
|
207
|
+
function he(s) {
|
|
257
208
|
const { row: e, column: t, id: n, ...r } = s;
|
|
258
209
|
return r;
|
|
259
210
|
}
|
|
260
|
-
const
|
|
211
|
+
const W = {
|
|
261
212
|
type: m.COMMAND,
|
|
262
213
|
id: "sheets.command.update-hyper-link",
|
|
263
214
|
async handler(s, e) {
|
|
@@ -267,7 +218,7 @@ const J = {
|
|
|
267
218
|
if (!c)
|
|
268
219
|
return !1;
|
|
269
220
|
const { redos: u, undos: p } = t.onCommandExecute({
|
|
270
|
-
id:
|
|
221
|
+
id: W.id,
|
|
271
222
|
params: e
|
|
272
223
|
}), g = {
|
|
273
224
|
id: b.id,
|
|
@@ -278,7 +229,7 @@ const J = {
|
|
|
278
229
|
unitId: a,
|
|
279
230
|
subUnitId: o,
|
|
280
231
|
id: d,
|
|
281
|
-
payload:
|
|
232
|
+
payload: he(c)
|
|
282
233
|
}
|
|
283
234
|
};
|
|
284
235
|
return (await R([g, ...u], n)).result ? (r.pushUndoRedo({
|
|
@@ -287,6 +238,55 @@ const J = {
|
|
|
287
238
|
unitID: a
|
|
288
239
|
}), !0) : !1;
|
|
289
240
|
}
|
|
241
|
+
}, J = {
|
|
242
|
+
type: m.COMMAND,
|
|
243
|
+
id: "sheets.command.remove-hyper-link",
|
|
244
|
+
async handler(s, e) {
|
|
245
|
+
if (!e)
|
|
246
|
+
return !1;
|
|
247
|
+
const t = s.get(N), n = s.get(M), r = s.get(C), i = s.get(_), { unitId: a, subUnitId: o, id: d } = e, c = i.getHyperLink(a, o, d), { redos: u, undos: p } = t.onCommandExecute({
|
|
248
|
+
id: J.id,
|
|
249
|
+
params: e
|
|
250
|
+
}), g = {
|
|
251
|
+
id: O.id,
|
|
252
|
+
params: e
|
|
253
|
+
}, f = {
|
|
254
|
+
id: H.id,
|
|
255
|
+
params: {
|
|
256
|
+
unitId: a,
|
|
257
|
+
subUnitId: o,
|
|
258
|
+
link: c
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
return (await R([g, ...u], n)).result ? (r.pushUndoRedo({
|
|
262
|
+
redoMutations: [g, ...u],
|
|
263
|
+
undoMutations: [f, ...p],
|
|
264
|
+
unitID: a
|
|
265
|
+
}), !0) : !1;
|
|
266
|
+
}
|
|
267
|
+
}, ge = {
|
|
268
|
+
type: m.COMMAND,
|
|
269
|
+
id: "sheets.command.cancel-hyper-link",
|
|
270
|
+
async handler(s, e) {
|
|
271
|
+
if (!e)
|
|
272
|
+
return !1;
|
|
273
|
+
const t = s.get(M), n = s.get(C), r = s.get(_), { unitId: i, subUnitId: a, id: o } = e, d = r.getHyperLink(i, a, o), c = {
|
|
274
|
+
id: O.id,
|
|
275
|
+
params: e
|
|
276
|
+
}, u = {
|
|
277
|
+
id: H.id,
|
|
278
|
+
params: {
|
|
279
|
+
unitId: i,
|
|
280
|
+
subUnitId: a,
|
|
281
|
+
link: d
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
return (await R([c], t)).result ? (n.pushUndoRedo({
|
|
285
|
+
redoMutations: [c],
|
|
286
|
+
undoMutations: [u],
|
|
287
|
+
unitID: i
|
|
288
|
+
}), !0) : !1;
|
|
289
|
+
}
|
|
290
290
|
};
|
|
291
291
|
var _e = Object.defineProperty, fe = Object.getOwnPropertyDescriptor, me = (s, e, t, n) => {
|
|
292
292
|
for (var r = n > 1 ? void 0 : n ? fe(e, t) : e, i = s.length - 1, a; i >= 0; i--)
|
|
@@ -302,11 +302,11 @@ let L = class extends k {
|
|
|
302
302
|
H,
|
|
303
303
|
b,
|
|
304
304
|
O,
|
|
305
|
-
|
|
305
|
+
le,
|
|
306
|
+
T,
|
|
306
307
|
W,
|
|
307
308
|
J,
|
|
308
|
-
|
|
309
|
-
le
|
|
309
|
+
ge
|
|
310
310
|
].forEach((s) => {
|
|
311
311
|
this._commandService.registerCommand(s);
|
|
312
312
|
});
|
|
@@ -364,7 +364,7 @@ let U = class extends k {
|
|
|
364
364
|
};
|
|
365
365
|
U = Se([
|
|
366
366
|
E(D.Starting, U),
|
|
367
|
-
V(0,
|
|
367
|
+
V(0, F),
|
|
368
368
|
V(1, y(_))
|
|
369
369
|
], U);
|
|
370
370
|
var Le = Object.defineProperty, Ue = Object.getOwnPropertyDescriptor, Pe = (s, e, t, n) => {
|
|
@@ -478,7 +478,7 @@ let P = class extends k {
|
|
|
478
478
|
};
|
|
479
479
|
if (c.range && c.gid) {
|
|
480
480
|
const u = c.gid, p = oe(c.range).range;
|
|
481
|
-
if (
|
|
481
|
+
if (Q(p) && c.range !== Re) {
|
|
482
482
|
const g = (f) => {
|
|
483
483
|
const l = I(p, f, { selectionManagerService: this._selectionManagerService });
|
|
484
484
|
return l && v(l) === v(p) ? {
|
|
@@ -571,7 +571,7 @@ let P = class extends k {
|
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
573
|
})
|
|
574
|
-
), this.disposeWithMe(
|
|
574
|
+
), this.disposeWithMe(X(() => {
|
|
575
575
|
this._disposableMap.forEach((e) => {
|
|
576
576
|
e.dispose();
|
|
577
577
|
}), this._disposableMap.clear();
|
|
@@ -580,9 +580,9 @@ let P = class extends k {
|
|
|
580
580
|
};
|
|
581
581
|
P = Pe([
|
|
582
582
|
E(D.Starting, P),
|
|
583
|
-
w(0, y(
|
|
583
|
+
w(0, y(te)),
|
|
584
584
|
w(1, y(se)),
|
|
585
|
-
w(2, y(
|
|
585
|
+
w(2, y(ne)),
|
|
586
586
|
w(3, M)
|
|
587
587
|
], P);
|
|
588
588
|
var ke = Object.defineProperty, Ce = Object.getOwnPropertyDescriptor, He = (s, e, t, n) => {
|
|
@@ -590,7 +590,7 @@ var ke = Object.defineProperty, Ce = Object.getOwnPropertyDescriptor, He = (s, e
|
|
|
590
590
|
(a = s[i]) && (r = (n ? a(e, t, r) : a(r)) || r);
|
|
591
591
|
return n && r && ke(e, t, r), r;
|
|
592
592
|
}, Oe = (s, e) => (t, n) => e(t, n, s), S;
|
|
593
|
-
let j = (S = class extends
|
|
593
|
+
let j = (S = class extends ee {
|
|
594
594
|
constructor(s, e) {
|
|
595
595
|
super(), this._injector = e;
|
|
596
596
|
}
|
|
@@ -609,18 +609,18 @@ j = He([
|
|
|
609
609
|
Oe(1, y(re))
|
|
610
610
|
], j);
|
|
611
611
|
export {
|
|
612
|
-
|
|
612
|
+
T as AddHyperLinkCommand,
|
|
613
613
|
H as AddHyperLinkMutation,
|
|
614
|
-
|
|
614
|
+
ge as CancelHyperLinkCommand,
|
|
615
615
|
Re as ERROR_RANGE,
|
|
616
616
|
_ as HyperLinkModel,
|
|
617
617
|
ye as HyperLinkType,
|
|
618
|
-
|
|
618
|
+
J as RemoveHyperLinkCommand,
|
|
619
619
|
O as RemoveHyperLinkMutation,
|
|
620
620
|
L as SheetsHyperLinkController,
|
|
621
621
|
P as SheetsHyperLinkRefRangeController,
|
|
622
622
|
j as UniverSheetsHyperLinkPlugin,
|
|
623
|
-
|
|
623
|
+
W as UpdateHyperLinkCommand,
|
|
624
624
|
b as UpdateHyperLinkMutation,
|
|
625
|
-
|
|
625
|
+
le as UpdateHyperLinkRefMutation
|
|
626
626
|
};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,13 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export { CancelHyperLinkCommand } from './commands/commands/remove-hyper-link.command';
|
|
17
|
-
export { AddHyperLinkMutation, type IAddHyperLinkMutationParams } from './commands/mutations/add-hyper-link.mutation';
|
|
18
|
-
export { UpdateHyperLinkMutation, UpdateHyperLinkRefMutation, type IUpdateHyperLinkMutationParams, type IUpdateHyperLinkRefMutationParams } from './commands/mutations/update-hyper-link.mutation';
|
|
19
|
-
export { RemoveHyperLinkMutation, type IRemoveHyperLinkMutationParams } from './commands/mutations/remove-hyper-link.mutation';
|
|
20
|
-
export { AddHyperLinkCommand, type IAddHyperLinkCommandParams } from './commands/commands/add-hyper-link.command';
|
|
21
|
-
export { UpdateHyperLinkCommand, type IUpdateHyperLinkCommandParams } from './commands/commands/update-hyper-link.command';
|
|
22
|
-
export { RemoveHyperLinkCommand, type IRemoveHyperLinkCommandParams } from './commands/commands/remove-hyper-link.command';
|
|
23
16
|
export { HyperLinkModel } from './models/hyper-link.model';
|
|
24
17
|
export { SheetsHyperLinkController } from './controllers/sheet-hyper-link.controller';
|
|
25
18
|
export { HyperLinkType } from './types/enums/hyper-link-type';
|
|
@@ -27,3 +20,9 @@ export { UniverSheetsHyperLinkPlugin } from './plugin';
|
|
|
27
20
|
export { SheetsHyperLinkRefRangeController } from './controllers/ref-range.controller';
|
|
28
21
|
export type { ICellHyperLink, ICellLinkContent } from './types/interfaces/i-hyper-link';
|
|
29
22
|
export { ERROR_RANGE } from './types/const';
|
|
23
|
+
export { AddHyperLinkCommand, type IAddHyperLinkCommandParams } from './commands/commands/add-hyper-link.command';
|
|
24
|
+
export { RemoveHyperLinkCommand, CancelHyperLinkCommand, type IRemoveHyperLinkCommandParams } from './commands/commands/remove-hyper-link.command';
|
|
25
|
+
export { UpdateHyperLinkCommand, type IUpdateHyperLinkCommandParams } from './commands/commands/update-hyper-link.command';
|
|
26
|
+
export { AddHyperLinkMutation, type IAddHyperLinkMutationParams } from './commands/mutations/add-hyper-link.mutation';
|
|
27
|
+
export { RemoveHyperLinkMutation, type IRemoveHyperLinkMutationParams } from './commands/mutations/remove-hyper-link.mutation';
|
|
28
|
+
export { UpdateHyperLinkMutation, UpdateHyperLinkRefMutation, type IUpdateHyperLinkMutationParams, type IUpdateHyperLinkRefMutationParams } from './commands/mutations/update-hyper-link.mutation';
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs"),require("@wendellhu/redi"),require("@univerjs/sheets-hyper-link"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","rxjs","@wendellhu/redi","@univerjs/sheets-hyper-link","@univerjs/engine-formula"],d):(c=typeof globalThis<"u"?globalThis:c||self,d(c.UniverSheetsHyperLink={},c.UniverCore,c.UniverSheets,c.rxjs,c["@wendellhu/redi"],c.UniverSheetsHyperLink,c.UniverEngineFormula))})(this,function(c,d,_,A,v,M,S){"use strict";var se=Object.defineProperty;var ae=(c,d,_)=>d in c?se(c,d,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[d]=_;var y=(c,d,_)=>ae(c,typeof d!="symbol"?d+"":d,_);var U;var V=Object.defineProperty,W=Object.getOwnPropertyDescriptor,q=(a,s,e,n)=>{for(var t=n>1?void 0:n?W(s,e):s,i=a.length-1,r;i>=0;i--)(r=a[i])&&(t=(n?r(s,e,t):r(t))||t);return n&&t&&V(s,e,t),t},G=(a,s)=>(e,n)=>s(e,n,a);c.HyperLinkModel=class extends d.Disposable{constructor(e){super();y(this,"_linkUpdate$",new A.Subject);y(this,"linkUpdate$",this._linkUpdate$.asObservable());y(this,"_linkMap",new Map);y(this,"_linkPositionMap",new Map);this._univerInstanceService=e,this.disposeWithMe({dispose:()=>{this._linkUpdate$.complete()}})}_ensureMap(e,n){let t=this._linkMap.get(e);t||(t=new Map,this._linkMap.set(e,t));let i=t.get(n);i||(i=new d.ObjectMatrix,t.set(n,i));let r=this._linkPositionMap.get(e);r||(r=new Map,this._linkPositionMap.set(e,r));let o=r.get(n);return o||(o=new Map,r.set(n,o)),{matrix:i,positionMap:o}}addHyperLink(e,n,t){const{matrix:i,positionMap:r}=this._ensureMap(e,n);return i.setValue(t.row,t.column,t),r.set(t.id,{row:t.row,column:t.column,link:t}),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:t,type:"add"}),!0}updateHyperLink(e,n,t,i,r=!1){const{matrix:o,positionMap:u}=this._ensureMap(e,n),l=u.get(t);if(!l)return!0;const p=o.getValue(l.row,l.column);return p&&(Object.assign(p,i),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:{display:p.display,payload:p.payload},id:t,type:"update",silent:r})),!0}updateHyperLinkRef(e,n,t,i,r=!1){const{matrix:o,positionMap:u}=this._ensureMap(e,n),l=u.get(t);if(!l)return!0;let p=o.getValue(l.row,l.column);return!p||p.id!==t?p=l.link:o.realDeleteValue(l.row,l.column),Object.assign(p,i),u.set(t,{...i,link:p}),o.setValue(i.row,i.column,p),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:i,id:t,type:"updateRef",silent:r}),!0}removeHyperLink(e,n,t){const{matrix:i,positionMap:r}=this._ensureMap(e,n),o=r.get(t);if(!o)return!1;r.delete(t);const u=i.getValue(o.row,o.column);return u&&u.id===t&&i.realDeleteValue(o.row,o.column),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:o.link,type:"remove"}),!0}getHyperLink(e,n,t){const{matrix:i,positionMap:r}=this._ensureMap(e,n),o=r.get(t);if(o)return i.getValue(o.row,o.column)}getHyperLinkByLocation(e,n,t,i){const{matrix:r}=this._ensureMap(e,n);return r.getValue(t,i)}getHyperLinkByLocationSync(e,n,t,i){var h,g,f,R,m;const{matrix:r}=this._ensureMap(e,n),o=this._univerInstanceService.getUnit(e,d.UniverInstanceType.UNIVER_SHEET),u=(h=o==null?void 0:o.getSheetBySheetId(n))==null?void 0:h.getCellRaw(t,i),l=((m=(R=u==null?void 0:u.v)!=null?R:(f=(g=u==null?void 0:u.p)==null?void 0:g.body)==null?void 0:f.dataStream.slice(0,-2))!=null?m:"").toString(),p=r.getValue(t,i);if(p)return{...p,display:l}}getSubUnit(e,n){const{matrix:t}=this._ensureMap(e,n),i=[];return t.forValue((r,o,u)=>{u&&i.push(u)}),i}getUnit(e){const n=this._linkMap.get(e);return n?Array.from(n.keys()).map(t=>{const i=this.getSubUnit(e,t);return{unitId:e,subUnitId:t,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))}},c.HyperLinkModel=q([G(0,d.IUniverInstanceService)],c.HyperLinkModel);const L={type:d.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(a,s){if(!s)return!1;const e=a.get(c.HyperLinkModel),{unitId:n,subUnitId:t,link:i}=s;return e.addHyperLink(n,t,i)}},k={type:d.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(a,s){if(!s)return!1;const e=a.get(c.HyperLinkModel),{unitId:n,subUnitId:t,id:i}=s;return e.removeHyperLink(n,t,i)}},P={type:d.CommandType.COMMAND,id:"sheets.command.remove-hyper-link",async handler(a,s){if(!s)return!1;const e=a.get(_.SheetInterceptorService),n=a.get(d.ICommandService),t=a.get(d.IUndoRedoService),i=a.get(c.HyperLinkModel),{unitId:r,subUnitId:o,id:u}=s,l=i.getHyperLink(r,o,u),{redos:p,undos:h}=e.onCommandExecute({id:P.id,params:s}),g={id:k.id,params:s},f={id:L.id,params:{unitId:r,subUnitId:o,link:l}};return(await d.sequenceExecuteAsync([g,...p],n)).result?(t.pushUndoRedo({redoMutations:[g,...p],undoMutations:[f,...h],unitID:r}),!0):!1}},O={type:d.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",async handler(a,s){if(!s)return!1;const e=a.get(d.ICommandService),n=a.get(d.IUndoRedoService),t=a.get(c.HyperLinkModel),{unitId:i,subUnitId:r,id:o}=s,u=t.getHyperLink(i,r,o),l={id:k.id,params:s},p={id:L.id,params:{unitId:i,subUnitId:r,link:u}};return(await d.sequenceExecuteAsync([l],e)).result?(n.pushUndoRedo({redoMutations:[l],undoMutations:[p],unitID:i}),!0):!1}},w={type:d.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(a,s){if(!s)return!1;const e=a.get(c.HyperLinkModel),{unitId:n,subUnitId:t,payload:i,id:r}=s;return e.updateHyperLink(n,t,r,i,!1)}},D={type:d.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(a,s){if(!s)return!1;const e=a.get(c.HyperLinkModel),{unitId:n,subUnitId:t,id:i,row:r,column:o,silent:u}=s;return e.updateHyperLinkRef(n,t,i,{row:r,column:o},u)}},I={type:d.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(a,s){if(!s)return!1;const e=a.get(_.SheetInterceptorService),n=a.get(d.ICommandService),t=a.get(d.IUndoRedoService),{unitId:i,subUnitId:r,link:o}=s,{redos:u,undos:l}=e.onCommandExecute({id:I.id,params:s}),p={id:L.id,params:s},h={id:k.id,params:{unitId:i,subUnitId:r,id:o.id}};return(await d.sequenceExecuteAsync([p,...u],n)).result?(t.pushUndoRedo({redoMutations:[p,...u],undoMutations:[h,...l],unitID:i}),!0):!1}};function J(a){const{row:s,column:e,id:n,...t}=a;return t}const E={type:d.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(a,s){if(!s)return!1;const e=a.get(_.SheetInterceptorService),n=a.get(d.ICommandService),t=a.get(d.IUndoRedoService),i=a.get(c.HyperLinkModel),{unitId:r,subUnitId:o,id:u}=s,l=i.getHyperLink(r,o,u);if(!l)return!1;const{redos:p,undos:h}=e.onCommandExecute({id:E.id,params:s}),g={id:w.id,params:s},f={id:w.id,params:{unitId:r,subUnitId:o,id:u,payload:J(l)}};return(await d.sequenceExecuteAsync([g,...p],n)).result?(t.pushUndoRedo({redoMutations:[g,...p],undoMutations:[f,...h],unitID:r}),!0):!1}};var z=Object.defineProperty,K=Object.getOwnPropertyDescriptor,B=(a,s,e,n)=>{for(var t=n>1?void 0:n?K(s,e):s,i=a.length-1,r;i>=0;i--)(r=a[i])&&(t=(n?r(s,e,t):r(t))||t);return n&&t&&z(s,e,t),t},Y=(a,s)=>(e,n)=>s(e,n,a);c.SheetsHyperLinkController=class extends d.Disposable{constructor(s){super(),this._commandService=s,this._registerCommands()}_registerCommands(){[L,w,k,D,I,E,P,O].forEach(s=>{this._commandService.registerCommand(s)})}},c.SheetsHyperLinkController=B([d.OnLifecycle(d.LifecycleStages.Starting,c.SheetsHyperLinkController),Y(0,d.ICommandService)],c.SheetsHyperLinkController);var b=(a=>(a[a.range=0]="range",a[a.link=1]="link",a))(b||{});const N="SHEET_HYPER_LINK_PLUGIN",j="err";var $=(a=>(a[a.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",a[a.UNIVER_DOC=1]="UNIVER_DOC",a[a.UNIVER_SHEET=2]="UNIVER_SHEET",a[a.UNIVER_SLIDE=3]="UNIVER_SLIDE",a[a.UNRECOGNIZED=-1]="UNRECOGNIZED",a))($||{}),Z=Object.defineProperty,Q=Object.getOwnPropertyDescriptor,X=(a,s,e,n)=>{for(var t=n>1?void 0:n?Q(s,e):s,i=a.length-1,r;i>=0;i--)(r=a[i])&&(t=(n?r(s,e,t):r(t))||t);return n&&t&&Z(s,e,t),t},T=(a,s)=>(e,n)=>s(e,n,a);let C=class extends d.Disposable{constructor(a,s){super(),this._resourceManagerService=a,this._hyperLinkModel=s,this._initSnapshot()}_initSnapshot(){const a=e=>{const n=this._hyperLinkModel.getUnit(e),t={};return n?(n.forEach(i=>{t[i.subUnitId]=i.links.map(({display:r,...o})=>o)}),JSON.stringify(t)):""},s=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:N,businesses:[$.UNIVER_SHEET],toJson:e=>a(e),parseJson:e=>s(e),onUnLoad:e=>{this._hyperLinkModel.deleteUnit(e)},onLoad:async(e,n)=>{Object.keys(n).forEach(t=>{n[t].forEach(r=>{this._hyperLinkModel.addHyperLink(e,t,r)})})}}))}};C=X([d.OnLifecycle(d.LifecycleStages.Starting,C),T(0,d.IResourceManagerService),T(1,v.Inject(c.HyperLinkModel))],C);var x=Object.defineProperty,F=Object.getOwnPropertyDescriptor,ee=(a,s,e,n)=>{for(var t=n>1?void 0:n?F(s,e):s,i=a.length-1,r;i>=0;i--)(r=a[i])&&(t=(n?r(s,e,t):r(t))||t);return n&&t&&x(s,e,t),t},H=(a,s)=>(e,n)=>s(e,n,a);c.SheetsHyperLinkRefRangeController=class extends d.Disposable{constructor(e,n,t,i){super();y(this,"_disposableMap",new Map);y(this,"_watchDisposableMap",new Map);y(this,"_rangeDisableMap",new Map);y(this,"_rangeWatcherMap",new Map);y(this,"_handlePositionChange",(e,n,t,i,r)=>{const o={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};return i?{redos:[{id:M.UpdateHyperLinkRefMutation.id,params:{unitId:e,subUnitId:n,id:t.id,row:i.startRow,column:i.startColumn,silent:r}}],undos:[{id:M.UpdateHyperLinkRefMutation.id,params:{unitId:e,subUnitId:n,id:t.id,row:o.startRow,column:o.startColumn,silent:r}}]}:{redos:[{id:M.RemoveHyperLinkMutation.id,params:{unitId:e,subUnitId:n,id:t.id}}],undos:[{id:M.AddHyperLinkMutation.id,params:{unitId:e,subUnitId:n,link:t}}]}});this._refRangeService=e,this._hyperLinkModel=n,this._selectionManagerService=t,this._commandService=i,this._initData(),this._initRefRange()}_registerPosition(e,n,t){const i=t.id,r={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row},o=u=>{const l=_.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(r,u,{selectionManagerService:this._selectionManagerService});return l&&l.startColumn===r.startColumn&&l.startRow===r.startRow?{undos:[],redos:[]}:this._handlePositionChange(e,n,t,l,!1)};this._disposableMap.set(i,this._refRangeService.registerRefRange(r,o,e,n))}_watchPosition(e,n,t){const i=t.id,r={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._watchDisposableMap.set(i,this._refRangeService.watchRange(e,n,r,(o,u)=>{const{redos:l}=this._handlePositionChange(e,n,t,u,!0);d.sequenceExecuteAsync(l,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(e){const n=this._disposableMap.get(e);n==null||n.dispose(),this._disposableMap.delete(e)}_unwatchPosition(e){const n=this._watchDisposableMap.get(e);n==null||n.dispose(),this._watchDisposableMap.delete(e)}_registerRange(e,n,t,i=!1){var r,o,u;if(t.startsWith("#")){const l=new URLSearchParams(t.slice(1)),p={gid:(r=l.get("gid"))!=null?r:"",range:(o=l.get("range"))!=null?o:"",rangeid:(u=l.get("rangeid"))!=null?u:""};if(p.range&&p.gid){const h=p.gid,g=S.deserializeRangeWithSheet(p.range).range;if(d.isValidRange(g)&&p.range!==j){const f=R=>{const m=_.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(g,R,{selectionManagerService:this._selectionManagerService});return m&&S.serializeRange(m)===S.serializeRange(g)?{redos:[],undos:[]}:{redos:[{id:M.UpdateHyperLinkMutation.id,params:{unitId:e,subUnitId:h,id:n,payload:{payload:`#gid=${h}&range=${m?S.serializeRange(m):"err"}`}}}],undos:[{id:M.UpdateHyperLinkMutation.id,params:{unitId:e,subUnitId:h,id:n,payload:{payload:t}}}]}};this._rangeDisableMap.set(n,this._refRangeService.registerRefRange(g,f,e,h)),i||this._rangeWatcherMap.set(n,this._refRangeService.watchRange(e,h,g,(R,m)=>{this._hyperLinkModel.updateHyperLink(e,h,n,{payload:`#gid=${h}&range=${m?S.serializeRange(m):"err"}`},!0)},!0))}}}}_unregisterRange(e){const n=this._rangeDisableMap.get(e);n==null||n.dispose(),this._rangeDisableMap.delete(e)}_unwatchRange(e){const n=this._rangeWatcherMap.get(e);n==null||n.dispose(),this._rangeWatcherMap.delete(e)}_initData(){this._hyperLinkModel.getAll().forEach(n=>{n.forEach(t=>{const{unitId:i,subUnitId:r,links:o}=t;o.forEach(u=>{this._registerPosition(i,r,u),this._watchPosition(i,r,u),this._registerRange(i,u.id,u.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(e=>{switch(e.type){case"add":{this._registerPosition(e.unitId,e.subUnitId,e.payload),this._watchPosition(e.unitId,e.subUnitId,e.payload),this._registerRange(e.unitId,e.payload.id,e.payload.payload);break}case"remove":{this._unregisterPosition(e.payload.id),this._unwatchPosition(e.payload.id),this._unregisterRange(e.payload.id),this._unwatchRange(e.payload.id);break}case"updateRef":{const{unitId:n,subUnitId:t,id:i,silent:r}=e,o=this._hyperLinkModel.getHyperLink(n,t,i);if(!o)return;this._unregisterPosition(i),this._registerPosition(n,t,o),r||(this._unwatchPosition(i),this._watchPosition(n,t,o));break}case"unload":{const{unitLinks:n}=e;n.forEach(t=>{const{links:i}=t;i.forEach(r=>{this._unregisterPosition(r.id),this._unwatchPosition(r.id),this._unregisterRange(r.id),this._unwatchRange(r.id)})});break}case"update":{e.silent||this._unwatchRange(e.id),this._unregisterRange(e.id),this._registerRange(e.unitId,e.id,e.payload.payload,e.silent);break}}})),this.disposeWithMe(d.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}},c.SheetsHyperLinkRefRangeController=ee([d.OnLifecycle(d.LifecycleStages.Starting,c.SheetsHyperLinkRefRangeController),H(0,v.Inject(_.RefRangeService)),H(1,v.Inject(M.HyperLinkModel)),H(2,v.Inject(_.SelectionManagerService)),H(3,d.ICommandService)],c.SheetsHyperLinkRefRangeController);var te=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,ie=(a,s,e,n)=>{for(var t=n>1?void 0:n?ne(s,e):s,i=a.length-1,r;i>=0;i--)(r=a[i])&&(t=(n?r(s,e,t):r(t))||t);return n&&t&&te(s,e,t),t},re=(a,s)=>(e,n)=>s(e,n,a);c.UniverSheetsHyperLinkPlugin=(U=class extends d.Plugin{constructor(s,e){super(),this._injector=e}onStarting(s){[[C],[c.SheetsHyperLinkController],[c.SheetsHyperLinkRefRangeController],[c.HyperLinkModel]].forEach(e=>{s.add(e)})}},y(U,"pluginName",N),y(U,"type",d.UniverInstanceType.UNIVER_SHEET),U),c.UniverSheetsHyperLinkPlugin=ie([re(1,v.Inject(v.Injector))],c.UniverSheetsHyperLinkPlugin),c.AddHyperLinkCommand=I,c.AddHyperLinkMutation=L,c.CancelHyperLinkCommand=O,c.ERROR_RANGE=j,c.HyperLinkType=b,c.RemoveHyperLinkCommand=P,c.RemoveHyperLinkMutation=k,c.UpdateHyperLinkCommand=E,c.UpdateHyperLinkMutation=w,c.UpdateHyperLinkRefMutation=D,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(d,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("rxjs"),require("@univerjs/core"),require("@univerjs/sheets"),require("@wendellhu/redi"),require("@univerjs/sheets-hyper-link"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","rxjs","@univerjs/core","@univerjs/sheets","@wendellhu/redi","@univerjs/sheets-hyper-link","@univerjs/engine-formula"],_):(d=typeof globalThis<"u"?globalThis:d||self,_(d.UniverSheetsHyperLink={},d.rxjs,d.UniverCore,d.UniverSheets,d["@wendellhu/redi"],d.UniverSheetsHyperLink,d.UniverEngineFormula))})(this,function(d,_,c,M,S,R,L){"use strict";var se=Object.defineProperty;var ae=(d,_,c)=>_ in d?se(d,_,{enumerable:!0,configurable:!0,writable:!0,value:c}):d[_]=c;var y=(d,_,c)=>ae(d,typeof _!="symbol"?_+"":_,c);var P;var V=Object.defineProperty,W=Object.getOwnPropertyDescriptor,q=(a,s,e,n)=>{for(var t=n>1?void 0:n?W(s,e):s,i=a.length-1,r;i>=0;i--)(r=a[i])&&(t=(n?r(s,e,t):r(t))||t);return n&&t&&V(s,e,t),t},G=(a,s)=>(e,n)=>s(e,n,a);d.HyperLinkModel=class extends c.Disposable{constructor(e){super();y(this,"_linkUpdate$",new _.Subject);y(this,"linkUpdate$",this._linkUpdate$.asObservable());y(this,"_linkMap",new Map);y(this,"_linkPositionMap",new Map);this._univerInstanceService=e,this.disposeWithMe({dispose:()=>{this._linkUpdate$.complete()}})}_ensureMap(e,n){let t=this._linkMap.get(e);t||(t=new Map,this._linkMap.set(e,t));let i=t.get(n);i||(i=new c.ObjectMatrix,t.set(n,i));let r=this._linkPositionMap.get(e);r||(r=new Map,this._linkPositionMap.set(e,r));let o=r.get(n);return o||(o=new Map,r.set(n,o)),{matrix:i,positionMap:o}}addHyperLink(e,n,t){const{matrix:i,positionMap:r}=this._ensureMap(e,n);return i.setValue(t.row,t.column,t),r.set(t.id,{row:t.row,column:t.column,link:t}),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:t,type:"add"}),!0}updateHyperLink(e,n,t,i,r=!1){const{matrix:o,positionMap:u}=this._ensureMap(e,n),l=u.get(t);if(!l)return!0;const p=o.getValue(l.row,l.column);return p&&(Object.assign(p,i),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:{display:p.display,payload:p.payload},id:t,type:"update",silent:r})),!0}updateHyperLinkRef(e,n,t,i,r=!1){const{matrix:o,positionMap:u}=this._ensureMap(e,n),l=u.get(t);if(!l)return!0;let p=o.getValue(l.row,l.column);return!p||p.id!==t?p=l.link:o.realDeleteValue(l.row,l.column),Object.assign(p,i),u.set(t,{...i,link:p}),o.setValue(i.row,i.column,p),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:i,id:t,type:"updateRef",silent:r}),!0}removeHyperLink(e,n,t){const{matrix:i,positionMap:r}=this._ensureMap(e,n),o=r.get(t);if(!o)return!1;r.delete(t);const u=i.getValue(o.row,o.column);return u&&u.id===t&&i.realDeleteValue(o.row,o.column),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:o.link,type:"remove"}),!0}getHyperLink(e,n,t){const{matrix:i,positionMap:r}=this._ensureMap(e,n),o=r.get(t);if(o)return i.getValue(o.row,o.column)}getHyperLinkByLocation(e,n,t,i){const{matrix:r}=this._ensureMap(e,n);return r.getValue(t,i)}getHyperLinkByLocationSync(e,n,t,i){var h,g,f,v,m;const{matrix:r}=this._ensureMap(e,n),o=this._univerInstanceService.getUnit(e,c.UniverInstanceType.UNIVER_SHEET),u=(h=o==null?void 0:o.getSheetBySheetId(n))==null?void 0:h.getCellRaw(t,i),l=((m=(v=u==null?void 0:u.v)!=null?v:(f=(g=u==null?void 0:u.p)==null?void 0:g.body)==null?void 0:f.dataStream.slice(0,-2))!=null?m:"").toString(),p=r.getValue(t,i);if(p)return{...p,display:l}}getSubUnit(e,n){const{matrix:t}=this._ensureMap(e,n),i=[];return t.forValue((r,o,u)=>{u&&i.push(u)}),i}getUnit(e){const n=this._linkMap.get(e);return n?Array.from(n.keys()).map(t=>{const i=this.getSubUnit(e,t);return{unitId:e,subUnitId:t,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))}},d.HyperLinkModel=q([G(0,c.IUniverInstanceService)],d.HyperLinkModel);const k={type:c.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(a,s){if(!s)return!1;const e=a.get(d.HyperLinkModel),{unitId:n,subUnitId:t,link:i}=s;return e.addHyperLink(n,t,i)}},C={type:c.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(a,s){if(!s)return!1;const e=a.get(d.HyperLinkModel),{unitId:n,subUnitId:t,payload:i,id:r}=s;return e.updateHyperLink(n,t,r,i,!1)}},D={type:c.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(a,s){if(!s)return!1;const e=a.get(d.HyperLinkModel),{unitId:n,subUnitId:t,id:i,row:r,column:o,silent:u}=s;return e.updateHyperLinkRef(n,t,i,{row:r,column:o},u)}},w={type:c.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(a,s){if(!s)return!1;const e=a.get(d.HyperLinkModel),{unitId:n,subUnitId:t,id:i}=s;return e.removeHyperLink(n,t,i)}},I={type:c.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(a,s){if(!s)return!1;const e=a.get(M.SheetInterceptorService),n=a.get(c.ICommandService),t=a.get(c.IUndoRedoService),{unitId:i,subUnitId:r,link:o}=s,{redos:u,undos:l}=e.onCommandExecute({id:I.id,params:s}),p={id:k.id,params:s},h={id:w.id,params:{unitId:i,subUnitId:r,id:o.id}};return(await c.sequenceExecuteAsync([p,...u],n)).result?(t.pushUndoRedo({redoMutations:[p,...u],undoMutations:[h,...l],unitID:i}),!0):!1}};function J(a){const{row:s,column:e,id:n,...t}=a;return t}const E={type:c.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(a,s){if(!s)return!1;const e=a.get(M.SheetInterceptorService),n=a.get(c.ICommandService),t=a.get(c.IUndoRedoService),i=a.get(d.HyperLinkModel),{unitId:r,subUnitId:o,id:u}=s,l=i.getHyperLink(r,o,u);if(!l)return!1;const{redos:p,undos:h}=e.onCommandExecute({id:E.id,params:s}),g={id:C.id,params:s},f={id:C.id,params:{unitId:r,subUnitId:o,id:u,payload:J(l)}};return(await c.sequenceExecuteAsync([g,...p],n)).result?(t.pushUndoRedo({redoMutations:[g,...p],undoMutations:[f,...h],unitID:r}),!0):!1}},O={type:c.CommandType.COMMAND,id:"sheets.command.remove-hyper-link",async handler(a,s){if(!s)return!1;const e=a.get(M.SheetInterceptorService),n=a.get(c.ICommandService),t=a.get(c.IUndoRedoService),i=a.get(d.HyperLinkModel),{unitId:r,subUnitId:o,id:u}=s,l=i.getHyperLink(r,o,u),{redos:p,undos:h}=e.onCommandExecute({id:O.id,params:s}),g={id:w.id,params:s},f={id:k.id,params:{unitId:r,subUnitId:o,link:l}};return(await c.sequenceExecuteAsync([g,...p],n)).result?(t.pushUndoRedo({redoMutations:[g,...p],undoMutations:[f,...h],unitID:r}),!0):!1}},b={type:c.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",async handler(a,s){if(!s)return!1;const e=a.get(c.ICommandService),n=a.get(c.IUndoRedoService),t=a.get(d.HyperLinkModel),{unitId:i,subUnitId:r,id:o}=s,u=t.getHyperLink(i,r,o),l={id:w.id,params:s},p={id:k.id,params:{unitId:i,subUnitId:r,link:u}};return(await c.sequenceExecuteAsync([l],e)).result?(n.pushUndoRedo({redoMutations:[l],undoMutations:[p],unitID:i}),!0):!1}};var z=Object.defineProperty,K=Object.getOwnPropertyDescriptor,B=(a,s,e,n)=>{for(var t=n>1?void 0:n?K(s,e):s,i=a.length-1,r;i>=0;i--)(r=a[i])&&(t=(n?r(s,e,t):r(t))||t);return n&&t&&z(s,e,t),t},Y=(a,s)=>(e,n)=>s(e,n,a);d.SheetsHyperLinkController=class extends c.Disposable{constructor(s){super(),this._commandService=s,this._registerCommands()}_registerCommands(){[k,C,w,D,I,E,O,b].forEach(s=>{this._commandService.registerCommand(s)})}},d.SheetsHyperLinkController=B([c.OnLifecycle(c.LifecycleStages.Starting,d.SheetsHyperLinkController),Y(0,c.ICommandService)],d.SheetsHyperLinkController);var N=(a=>(a[a.range=0]="range",a[a.link=1]="link",a))(N||{});const j="SHEET_HYPER_LINK_PLUGIN",$="err";var T=(a=>(a[a.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",a[a.UNIVER_DOC=1]="UNIVER_DOC",a[a.UNIVER_SHEET=2]="UNIVER_SHEET",a[a.UNIVER_SLIDE=3]="UNIVER_SLIDE",a[a.UNRECOGNIZED=-1]="UNRECOGNIZED",a))(T||{}),Z=Object.defineProperty,Q=Object.getOwnPropertyDescriptor,X=(a,s,e,n)=>{for(var t=n>1?void 0:n?Q(s,e):s,i=a.length-1,r;i>=0;i--)(r=a[i])&&(t=(n?r(s,e,t):r(t))||t);return n&&t&&Z(s,e,t),t},A=(a,s)=>(e,n)=>s(e,n,a);let H=class extends c.Disposable{constructor(a,s){super(),this._resourceManagerService=a,this._hyperLinkModel=s,this._initSnapshot()}_initSnapshot(){const a=e=>{const n=this._hyperLinkModel.getUnit(e),t={};return n?(n.forEach(i=>{t[i.subUnitId]=i.links.map(({display:r,...o})=>o)}),JSON.stringify(t)):""},s=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:j,businesses:[T.UNIVER_SHEET],toJson:e=>a(e),parseJson:e=>s(e),onUnLoad:e=>{this._hyperLinkModel.deleteUnit(e)},onLoad:async(e,n)=>{Object.keys(n).forEach(t=>{n[t].forEach(r=>{this._hyperLinkModel.addHyperLink(e,t,r)})})}}))}};H=X([c.OnLifecycle(c.LifecycleStages.Starting,H),A(0,c.IResourceManagerService),A(1,S.Inject(d.HyperLinkModel))],H);var x=Object.defineProperty,F=Object.getOwnPropertyDescriptor,ee=(a,s,e,n)=>{for(var t=n>1?void 0:n?F(s,e):s,i=a.length-1,r;i>=0;i--)(r=a[i])&&(t=(n?r(s,e,t):r(t))||t);return n&&t&&x(s,e,t),t},U=(a,s)=>(e,n)=>s(e,n,a);d.SheetsHyperLinkRefRangeController=class extends c.Disposable{constructor(e,n,t,i){super();y(this,"_disposableMap",new Map);y(this,"_watchDisposableMap",new Map);y(this,"_rangeDisableMap",new Map);y(this,"_rangeWatcherMap",new Map);y(this,"_handlePositionChange",(e,n,t,i,r)=>{const o={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};return i?{redos:[{id:R.UpdateHyperLinkRefMutation.id,params:{unitId:e,subUnitId:n,id:t.id,row:i.startRow,column:i.startColumn,silent:r}}],undos:[{id:R.UpdateHyperLinkRefMutation.id,params:{unitId:e,subUnitId:n,id:t.id,row:o.startRow,column:o.startColumn,silent:r}}]}:{redos:[{id:R.RemoveHyperLinkMutation.id,params:{unitId:e,subUnitId:n,id:t.id}}],undos:[{id:R.AddHyperLinkMutation.id,params:{unitId:e,subUnitId:n,link:t}}]}});this._refRangeService=e,this._hyperLinkModel=n,this._selectionManagerService=t,this._commandService=i,this._initData(),this._initRefRange()}_registerPosition(e,n,t){const i=t.id,r={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row},o=u=>{const l=M.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(r,u,{selectionManagerService:this._selectionManagerService});return l&&l.startColumn===r.startColumn&&l.startRow===r.startRow?{undos:[],redos:[]}:this._handlePositionChange(e,n,t,l,!1)};this._disposableMap.set(i,this._refRangeService.registerRefRange(r,o,e,n))}_watchPosition(e,n,t){const i=t.id,r={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._watchDisposableMap.set(i,this._refRangeService.watchRange(e,n,r,(o,u)=>{const{redos:l}=this._handlePositionChange(e,n,t,u,!0);c.sequenceExecuteAsync(l,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(e){const n=this._disposableMap.get(e);n==null||n.dispose(),this._disposableMap.delete(e)}_unwatchPosition(e){const n=this._watchDisposableMap.get(e);n==null||n.dispose(),this._watchDisposableMap.delete(e)}_registerRange(e,n,t,i=!1){var r,o,u;if(t.startsWith("#")){const l=new URLSearchParams(t.slice(1)),p={gid:(r=l.get("gid"))!=null?r:"",range:(o=l.get("range"))!=null?o:"",rangeid:(u=l.get("rangeid"))!=null?u:""};if(p.range&&p.gid){const h=p.gid,g=L.deserializeRangeWithSheet(p.range).range;if(c.isValidRange(g)&&p.range!==$){const f=v=>{const m=M.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(g,v,{selectionManagerService:this._selectionManagerService});return m&&L.serializeRange(m)===L.serializeRange(g)?{redos:[],undos:[]}:{redos:[{id:R.UpdateHyperLinkMutation.id,params:{unitId:e,subUnitId:h,id:n,payload:{payload:`#gid=${h}&range=${m?L.serializeRange(m):"err"}`}}}],undos:[{id:R.UpdateHyperLinkMutation.id,params:{unitId:e,subUnitId:h,id:n,payload:{payload:t}}}]}};this._rangeDisableMap.set(n,this._refRangeService.registerRefRange(g,f,e,h)),i||this._rangeWatcherMap.set(n,this._refRangeService.watchRange(e,h,g,(v,m)=>{this._hyperLinkModel.updateHyperLink(e,h,n,{payload:`#gid=${h}&range=${m?L.serializeRange(m):"err"}`},!0)},!0))}}}}_unregisterRange(e){const n=this._rangeDisableMap.get(e);n==null||n.dispose(),this._rangeDisableMap.delete(e)}_unwatchRange(e){const n=this._rangeWatcherMap.get(e);n==null||n.dispose(),this._rangeWatcherMap.delete(e)}_initData(){this._hyperLinkModel.getAll().forEach(n=>{n.forEach(t=>{const{unitId:i,subUnitId:r,links:o}=t;o.forEach(u=>{this._registerPosition(i,r,u),this._watchPosition(i,r,u),this._registerRange(i,u.id,u.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(e=>{switch(e.type){case"add":{this._registerPosition(e.unitId,e.subUnitId,e.payload),this._watchPosition(e.unitId,e.subUnitId,e.payload),this._registerRange(e.unitId,e.payload.id,e.payload.payload);break}case"remove":{this._unregisterPosition(e.payload.id),this._unwatchPosition(e.payload.id),this._unregisterRange(e.payload.id),this._unwatchRange(e.payload.id);break}case"updateRef":{const{unitId:n,subUnitId:t,id:i,silent:r}=e,o=this._hyperLinkModel.getHyperLink(n,t,i);if(!o)return;this._unregisterPosition(i),this._registerPosition(n,t,o),r||(this._unwatchPosition(i),this._watchPosition(n,t,o));break}case"unload":{const{unitLinks:n}=e;n.forEach(t=>{const{links:i}=t;i.forEach(r=>{this._unregisterPosition(r.id),this._unwatchPosition(r.id),this._unregisterRange(r.id),this._unwatchRange(r.id)})});break}case"update":{e.silent||this._unwatchRange(e.id),this._unregisterRange(e.id),this._registerRange(e.unitId,e.id,e.payload.payload,e.silent);break}}})),this.disposeWithMe(c.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}},d.SheetsHyperLinkRefRangeController=ee([c.OnLifecycle(c.LifecycleStages.Starting,d.SheetsHyperLinkRefRangeController),U(0,S.Inject(M.RefRangeService)),U(1,S.Inject(R.HyperLinkModel)),U(2,S.Inject(M.SelectionManagerService)),U(3,c.ICommandService)],d.SheetsHyperLinkRefRangeController);var te=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,ie=(a,s,e,n)=>{for(var t=n>1?void 0:n?ne(s,e):s,i=a.length-1,r;i>=0;i--)(r=a[i])&&(t=(n?r(s,e,t):r(t))||t);return n&&t&&te(s,e,t),t},re=(a,s)=>(e,n)=>s(e,n,a);d.UniverSheetsHyperLinkPlugin=(P=class extends c.Plugin{constructor(s,e){super(),this._injector=e}onStarting(s){[[H],[d.SheetsHyperLinkController],[d.SheetsHyperLinkRefRangeController],[d.HyperLinkModel]].forEach(e=>{s.add(e)})}},y(P,"pluginName",j),y(P,"type",c.UniverInstanceType.UNIVER_SHEET),P),d.UniverSheetsHyperLinkPlugin=ie([re(1,S.Inject(S.Injector))],d.UniverSheetsHyperLinkPlugin),d.AddHyperLinkCommand=I,d.AddHyperLinkMutation=k,d.CancelHyperLinkCommand=b,d.ERROR_RANGE=$,d.HyperLinkType=N,d.RemoveHyperLinkCommand=O,d.RemoveHyperLinkMutation=w,d.UpdateHyperLinkCommand=E,d.UpdateHyperLinkMutation=C,d.UpdateHyperLinkRefMutation=D,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-hyper-link",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -44,24 +44,24 @@
|
|
|
44
44
|
"lib"
|
|
45
45
|
],
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@wendellhu/redi": "0.15.
|
|
47
|
+
"@wendellhu/redi": "0.15.5",
|
|
48
48
|
"rxjs": ">=7.0.0",
|
|
49
|
-
"@univerjs/
|
|
50
|
-
"@univerjs/
|
|
51
|
-
"@univerjs/sheets
|
|
52
|
-
"@univerjs/
|
|
49
|
+
"@univerjs/engine-formula": "0.2.0",
|
|
50
|
+
"@univerjs/core": "0.2.0",
|
|
51
|
+
"@univerjs/sheets": "0.2.0",
|
|
52
|
+
"@univerjs/sheets-hyper-link": "0.2.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@univerjs/protocol": "0.1.38-alpha.
|
|
56
|
-
"@wendellhu/redi": "
|
|
55
|
+
"@univerjs/protocol": "0.1.38-alpha.11",
|
|
56
|
+
"@wendellhu/redi": "0.15.5",
|
|
57
57
|
"rxjs": "^7.8.1",
|
|
58
|
-
"typescript": "^5.
|
|
59
|
-
"vite": "^5.3.
|
|
58
|
+
"typescript": "^5.5.3",
|
|
59
|
+
"vite": "^5.3.3",
|
|
60
60
|
"vitest": "^1.6.0",
|
|
61
|
-
"@univerjs/core": "0.
|
|
62
|
-
"@univerjs/engine-formula": "0.
|
|
63
|
-
"@univerjs/
|
|
64
|
-
"@univerjs/
|
|
61
|
+
"@univerjs/core": "0.2.0",
|
|
62
|
+
"@univerjs/engine-formula": "0.2.0",
|
|
63
|
+
"@univerjs/shared": "0.2.0",
|
|
64
|
+
"@univerjs/sheets": "0.2.0"
|
|
65
65
|
},
|
|
66
66
|
"univerSpace": {
|
|
67
67
|
".": {
|