@univerjs/sheets-hyper-link 0.2.2 → 0.2.4-alpha.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/README.md +17 -7
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +208 -206
- package/lib/types/controllers/ref-range.controller.d.ts +2 -2
- package/lib/types/plugin.d.ts +1 -2
- package/lib/umd/index.js +1 -1
- package/package.json +12 -14
package/README.md
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
# @univerjs/sheets-hyper-link
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://img.shields.io/npm/l/@univerjs/hyper-link)
|
|
3
|
+
## Package Overview
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
| Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
|
|
6
|
+
| --- | --- | --- | --- | --- | :---: | :---: |
|
|
7
|
+
| `@univerjs/sheets-hyper-link` | `UniverSheetsHyperLink` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ❌ | ❌ |
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
## Introduction
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
[`@univerjs/sheets-hyper-link-ui`](../sheets-hyper-link-ui//README-zh.md)。
|
|
11
|
+
A internal package for `@univerjs/sheets-hyper-link-ui`, for using hyper-link feature please refer to `@univerjs/sheets-hyper-link-ui`.
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
15
|
### Installation
|
|
16
16
|
|
|
17
17
|
```shell
|
|
18
|
-
|
|
18
|
+
# Using npm
|
|
19
|
+
npm install @univerjs/sheets-hyper-link
|
|
20
|
+
|
|
21
|
+
# Using pnpm
|
|
22
|
+
pnpm add @univerjs/sheets-hyper-link
|
|
19
23
|
```
|
|
24
|
+
|
|
25
|
+
<!-- Links -->
|
|
26
|
+
[npm-version-shield]: https://img.shields.io/npm/v/@univerjs/sheets-hyper-link?style=flat-square
|
|
27
|
+
[npm-version-link]: https://npmjs.com/package/@univerjs/sheets-hyper-link
|
|
28
|
+
[npm-license-shield]: https://img.shields.io/npm/l/@univerjs/sheets-hyper-link?style=flat-square
|
|
29
|
+
[npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/sheets-hyper-link?style=flat-square
|
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 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;
|
|
1
|
+
"use strict";var A=Object.defineProperty;var T=(s,r,e)=>r in s?A(s,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[r]=e;var _=(s,r,e)=>T(s,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("rxjs"),d=require("@univerjs/core"),m=require("@univerjs/sheets"),M=require("@univerjs/sheets-hyper-link"),R=require("@univerjs/engine-formula");var j=Object.defineProperty,W=Object.getOwnPropertyDescriptor,q=(s,r,e,n)=>{for(var t=n>1?void 0:n?W(r,e):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(t=(n?o(r,e,t):o(t))||t);return n&&t&&j(r,e,t),t},G=(s,r)=>(e,n)=>r(e,n,s);exports.HyperLinkModel=class extends d.Disposable{constructor(e){super();_(this,"_linkUpdate$",new V.Subject);_(this,"linkUpdate$",this._linkUpdate$.asObservable());_(this,"_linkMap",new Map);_(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 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:i,positionMap:a}}addHyperLink(e,n,t){const{matrix:i,positionMap:o}=this._ensureMap(e,n);return i.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,i,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,i),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,i,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,i),c.set(t,{...i,link:p}),a.setValue(i.row,i.column,p),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:i,id:t,type:"updateRef",silent:o}),!0}removeHyperLink(e,n,t){const{matrix:i,positionMap:o}=this._ensureMap(e,n),a=o.get(t);if(!a)return!1;o.delete(t);const c=i.getValue(a.row,a.column);return c&&c.id===t&&i.realDeleteValue(a.row,a.column),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:a.link,type:"remove"}),!0}getHyperLink(e,n,t){const{matrix:i,positionMap:o}=this._ensureMap(e,n),a=o.get(t);if(a)return i.getValue(a.row,a.column)}getHyperLinkByLocation(e,n,t,i){const{matrix:o}=this._ensureMap(e,n);return o.getValue(t,i)}getHyperLinkByLocationSync(e,n,t,i){var u,h,y,f,g;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,i),l=((g=(f=c==null?void 0:c.v)!=null?f:(y=(h=c==null?void 0:c.p)==null?void 0:h.body)==null?void 0:y.dataStream.slice(0,-2))!=null?g:"").toString(),p=o.getValue(t,i);if(p)return{...p,display:l}}getSubUnit(e,n){const{matrix:t}=this._ensureMap(e,n),i=[];return t.forValue((o,a,c)=>{c&&i.push(c)}),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))}};exports.HyperLinkModel=q([G(0,d.IUniverInstanceService)],exports.HyperLinkModel);const v={type:d.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(s,r){if(!r)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:t,link:i}=r;return e.addHyperLink(n,t,i)}},H={type:d.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(s,r){if(!r)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:t,payload:i,id:o}=r;return e.updateHyperLink(n,t,o,i,!1)}},I={type:d.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(s,r){if(!r)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:t,id:i,row:o,column:a,silent:c}=r;return e.updateHyperLinkRef(n,t,i,{row:o,column:a},c)}},S={type:d.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(s,r){if(!r)return!1;const e=s.get(exports.HyperLinkModel),{unitId:n,subUnitId:t,id:i}=r;return e.removeHyperLink(n,t,i)}},C={type:d.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(s,r){if(!r)return!1;const e=s.get(m.SheetInterceptorService),n=s.get(d.ICommandService),t=s.get(d.IUndoRedoService),{unitId:i,subUnitId:o,link:a}=r,{redos:c,undos:l}=e.onCommandExecute({id:C.id,params:r}),p={id:v.id,params:r},u={id:S.id,params:{unitId:i,subUnitId:o,id:a.id}};return(await d.sequenceExecuteAsync([p,...c],n)).result?(t.pushUndoRedo({redoMutations:[p,...c],undoMutations:[u,...l],unitID:i}),!0):!1}};function J(s){const{row:r,column:e,id:n,...t}=s;return t}const w={type:d.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(s,r){if(!r)return!1;const e=s.get(m.SheetInterceptorService),n=s.get(d.ICommandService),t=s.get(d.IUndoRedoService),i=s.get(exports.HyperLinkModel),{unitId:o,subUnitId:a,id:c}=r,l=i.getHyperLink(o,a,c);if(!l)return!1;const{redos:p,undos:u}=e.onCommandExecute({id:w.id,params:r}),h={id:H.id,params:r},y={id:H.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}},U={type:d.CommandType.COMMAND,id:"sheets.command.remove-hyper-link",async handler(s,r){if(!r)return!1;const e=s.get(m.SheetInterceptorService),n=s.get(d.ICommandService),t=s.get(d.IUndoRedoService),i=s.get(exports.HyperLinkModel),{unitId:o,subUnitId:a,id:c}=r,l=i.getHyperLink(o,a,c),{redos:p,undos:u}=e.onCommandExecute({id:U.id,params:r}),h={id:S.id,params:r},y={id:v.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,r){if(!r)return!1;const e=s.get(d.ICommandService),n=s.get(d.IUndoRedoService),t=s.get(exports.HyperLinkModel),{unitId:i,subUnitId:o,id:a}=r,c=t.getHyperLink(i,o,a),l={id:S.id,params:r},p={id:v.id,params:{unitId:i,subUnitId:o,link:c}};return(await d.sequenceExecuteAsync([l],e)).result?(n.pushUndoRedo({redoMutations:[l],undoMutations:[p],unitID:i}),!0):!1}};var z=Object.defineProperty,K=Object.getOwnPropertyDescriptor,B=(s,r,e,n)=>{for(var t=n>1?void 0:n?K(r,e):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(t=(n?o(r,e,t):o(t))||t);return n&&t&&z(r,e,t),t},F=(s,r)=>(e,n)=>r(e,n,s);exports.SheetsHyperLinkController=class extends d.Disposable{constructor(r){super(),this._commandService=r,this._registerCommands()}_registerCommands(){[v,H,S,I,C,w,U,b].forEach(r=>{this._commandService.registerCommand(r)})}};exports.SheetsHyperLinkController=B([d.OnLifecycle(d.LifecycleStages.Starting,exports.SheetsHyperLinkController),F(0,d.ICommandService)],exports.SheetsHyperLinkController);var O=(s=>(s[s.range=0]="range",s[s.link=1]="link",s))(O||{});const E="SHEET_HYPER_LINK_PLUGIN",D="err";var N=(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))(N||{}),Y=Object.defineProperty,Z=Object.getOwnPropertyDescriptor,Q=(s,r,e,n)=>{for(var t=n>1?void 0:n?Z(r,e):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(t=(n?o(r,e,t):o(t))||t);return n&&t&&Y(r,e,t),t},P=(s,r)=>(e,n)=>r(e,n,s);let k=class extends d.Disposable{constructor(s,r){super(),this._resourceManagerService=s,this._hyperLinkModel=r,this._initSnapshot()}_initSnapshot(){const s=e=>{const n=this._hyperLinkModel.getUnit(e),t={};return n?(n.forEach(i=>{t[i.subUnitId]=i.links.map(({display:o,...a})=>a)}),JSON.stringify(t)):""},r=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:E,businesses:[N.UNIVER_SHEET],toJson:e=>s(e),parseJson:e=>r(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)})})}}))}};k=Q([d.OnLifecycle(d.LifecycleStages.Starting,k),P(0,d.IResourceManagerService),P(1,d.Inject(exports.HyperLinkModel))],k);var X=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,te=(s,r,e,n)=>{for(var t=n>1?void 0:n?ee(r,e):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(t=(n?o(r,e,t):o(t))||t);return n&&t&&X(r,e,t),t},L=(s,r)=>(e,n)=>r(e,n,s);exports.SheetsHyperLinkRefRangeController=class extends d.Disposable{constructor(e,n,t,i){super();_(this,"_disposableMap",new Map);_(this,"_watchDisposableMap",new Map);_(this,"_rangeDisableMap",new Map);_(this,"_rangeWatcherMap",new Map);_(this,"_handlePositionChange",(e,n,t,i,o)=>{const a={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:o}}],undos:[{id:M.UpdateHyperLinkRefMutation.id,params:{unitId:e,subUnitId:n,id:t.id,row:a.startRow,column:a.startColumn,silent:o}}]}:{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,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(i,this._refRangeService.registerRefRange(o,a,e,n))}_watchPosition(e,n,t){const i=t.id,o={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._watchDisposableMap.set(i,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,i=!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=R.deserializeRangeWithSheet(p.range).range;if(d.isValidRange(h)&&p.range!==D){const y=f=>{const g=m.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(h,f,{selectionManagerService:this._selectionManagerService});return g&&R.serializeRange(g)===R.serializeRange(h)?{redos:[],undos:[]}:{redos:[{id:M.UpdateHyperLinkMutation.id,params:{unitId:e,subUnitId:u,id:n,payload:{payload:`#gid=${u}&range=${g?R.serializeRange(g):"err"}`}}}],undos:[{id:M.UpdateHyperLinkMutation.id,params:{unitId:e,subUnitId:u,id:n,payload:{payload:t}}}]}};this._rangeDisableMap.set(n,this._refRangeService.registerRefRange(h,y,e,u)),i||this._rangeWatcherMap.set(n,this._refRangeService.watchRange(e,u,h,(f,g)=>{this._hyperLinkModel.updateHyperLink(e,u,n,{payload:`#gid=${u}&range=${g?R.serializeRange(g):"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:o,links:a}=t;a.forEach(c=>{this._registerPosition(i,o,c),this._watchPosition(i,o,c),this._registerRange(i,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:i,silent:o}=e,a=this._hyperLinkModel.getHyperLink(n,t,i);if(!a)return;this._unregisterPosition(i),this._registerPosition(n,t,a),o||(this._unwatchPosition(i),this._watchPosition(n,t,a));break}case"unload":{const{unitLinks:n}=e;n.forEach(t=>{const{links:i}=t;i.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),L(0,d.Inject(m.RefRangeService)),L(1,d.Inject(M.HyperLinkModel)),L(2,d.Inject(m.SheetsSelectionsService)),L(3,d.ICommandService)],exports.SheetsHyperLinkRefRangeController);var $=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,re=(s,r,e)=>r in s?$(s,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[r]=e,ie=(s,r,e,n)=>{for(var t=n>1?void 0:n?ne(r,e):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(t=(n?o(r,e,t):o(t))||t);return n&&t&&$(r,e,t),t},se=(s,r)=>(e,n)=>r(e,n,s),x=(s,r,e)=>re(s,typeof r!="symbol"?r+"":r,e);exports.UniverSheetsHyperLinkPlugin=class extends d.Plugin{constructor(r,e){super(),this._injector=e}onStarting(r){[[k],[exports.SheetsHyperLinkController],[exports.SheetsHyperLinkRefRangeController],[exports.HyperLinkModel]].forEach(e=>{r.add(e)})}};x(exports.UniverSheetsHyperLinkPlugin,"pluginName",E);x(exports.UniverSheetsHyperLinkPlugin,"type",d.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsHyperLinkPlugin=ie([d.DependentOn(m.UniverSheetsPlugin),se(1,d.Inject(d.Injector))],exports.UniverSheetsHyperLinkPlugin);exports.AddHyperLinkCommand=C;exports.AddHyperLinkMutation=v;exports.CancelHyperLinkCommand=b;exports.ERROR_RANGE=D;exports.HyperLinkType=O;exports.RemoveHyperLinkCommand=U;exports.RemoveHyperLinkMutation=S;exports.UpdateHyperLinkCommand=w;exports.UpdateHyperLinkMutation=H;exports.UpdateHyperLinkRefMutation=I;
|
package/lib/es/index.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Subject as
|
|
5
|
-
import { Disposable as
|
|
6
|
-
import { SheetInterceptorService as N, RefRangeService as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let _ = class extends k {
|
|
1
|
+
var z = Object.defineProperty;
|
|
2
|
+
var Y = (i, e, t) => e in i ? z(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var _ = (i, e, t) => Y(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Subject as Z } from "rxjs";
|
|
5
|
+
import { Disposable as C, ObjectMatrix as q, UniverInstanceType as A, IUniverInstanceService as F, CommandType as m, ICommandService as M, IUndoRedoService as k, sequenceExecuteAsync as R, OnLifecycle as E, LifecycleStages as D, Inject as y, IResourceManagerService as Q, isValidRange as X, toDisposable as ee, DependentOn as te, Injector as ne, Plugin as re } from "@univerjs/core";
|
|
6
|
+
import { SheetInterceptorService as N, RefRangeService as ie, SheetsSelectionsService as se, handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests as I, UniverSheetsPlugin as ae } from "@univerjs/sheets";
|
|
7
|
+
import { HyperLinkModel as oe, RemoveHyperLinkMutation as de, AddHyperLinkMutation as ce, UpdateHyperLinkRefMutation as $, UpdateHyperLinkMutation as x } from "@univerjs/sheets-hyper-link";
|
|
8
|
+
import { deserializeRangeWithSheet as ue, serializeRange as v } from "@univerjs/engine-formula";
|
|
9
|
+
var le = Object.defineProperty, pe = Object.getOwnPropertyDescriptor, he = (i, e, t, n) => {
|
|
10
|
+
for (var r = n > 1 ? void 0 : n ? pe(e, t) : e, s = i.length - 1, a; s >= 0; s--)
|
|
11
|
+
(a = i[s]) && (r = (n ? a(e, t, r) : a(r)) || r);
|
|
12
|
+
return n && r && le(e, t, r), r;
|
|
13
|
+
}, ge = (i, e) => (t, n) => e(t, n, i);
|
|
14
|
+
let g = class extends C {
|
|
16
15
|
constructor(e) {
|
|
17
16
|
super();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
_(this, "_linkUpdate$", new Z());
|
|
18
|
+
_(this, "linkUpdate$", this._linkUpdate$.asObservable());
|
|
19
|
+
_(this, "_linkMap", /* @__PURE__ */ new Map());
|
|
20
|
+
_(this, "_linkPositionMap", /* @__PURE__ */ new Map());
|
|
22
21
|
this._univerInstanceService = e, this.disposeWithMe({
|
|
23
22
|
dispose: () => {
|
|
24
23
|
this._linkUpdate$.complete();
|
|
@@ -29,25 +28,25 @@ let _ = class extends k {
|
|
|
29
28
|
let n = this._linkMap.get(e);
|
|
30
29
|
n || (n = /* @__PURE__ */ new Map(), this._linkMap.set(e, n));
|
|
31
30
|
let r = n.get(t);
|
|
32
|
-
r || (r = new
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
let a =
|
|
36
|
-
return a || (a = /* @__PURE__ */ new Map(),
|
|
31
|
+
r || (r = new q(), n.set(t, r));
|
|
32
|
+
let s = this._linkPositionMap.get(e);
|
|
33
|
+
s || (s = /* @__PURE__ */ new Map(), this._linkPositionMap.set(e, s));
|
|
34
|
+
let a = s.get(t);
|
|
35
|
+
return a || (a = /* @__PURE__ */ new Map(), s.set(t, a)), {
|
|
37
36
|
matrix: r,
|
|
38
37
|
positionMap: a
|
|
39
38
|
};
|
|
40
39
|
}
|
|
41
40
|
addHyperLink(e, t, n) {
|
|
42
|
-
const { matrix: r, positionMap:
|
|
43
|
-
return r.setValue(n.row, n.column, n),
|
|
41
|
+
const { matrix: r, positionMap: s } = this._ensureMap(e, t);
|
|
42
|
+
return r.setValue(n.row, n.column, n), s.set(n.id, { row: n.row, column: n.column, link: n }), this._linkUpdate$.next({
|
|
44
43
|
unitId: e,
|
|
45
44
|
subUnitId: t,
|
|
46
45
|
payload: n,
|
|
47
46
|
type: "add"
|
|
48
47
|
}), !0;
|
|
49
48
|
}
|
|
50
|
-
updateHyperLink(e, t, n, r,
|
|
49
|
+
updateHyperLink(e, t, n, r, s = !1) {
|
|
51
50
|
const { matrix: a, positionMap: o } = this._ensureMap(e, t), d = o.get(n);
|
|
52
51
|
if (!d)
|
|
53
52
|
return !0;
|
|
@@ -61,10 +60,10 @@ let _ = class extends k {
|
|
|
61
60
|
},
|
|
62
61
|
id: n,
|
|
63
62
|
type: "update",
|
|
64
|
-
silent:
|
|
63
|
+
silent: s
|
|
65
64
|
})), !0;
|
|
66
65
|
}
|
|
67
|
-
updateHyperLinkRef(e, t, n, r,
|
|
66
|
+
updateHyperLinkRef(e, t, n, r, s = !1) {
|
|
68
67
|
const { matrix: a, positionMap: o } = this._ensureMap(e, t), d = o.get(n);
|
|
69
68
|
if (!d)
|
|
70
69
|
return !0;
|
|
@@ -75,14 +74,14 @@ let _ = class extends k {
|
|
|
75
74
|
payload: r,
|
|
76
75
|
id: n,
|
|
77
76
|
type: "updateRef",
|
|
78
|
-
silent:
|
|
77
|
+
silent: s
|
|
79
78
|
}), !0;
|
|
80
79
|
}
|
|
81
80
|
removeHyperLink(e, t, n) {
|
|
82
|
-
const { matrix: r, positionMap:
|
|
81
|
+
const { matrix: r, positionMap: s } = this._ensureMap(e, t), a = s.get(n);
|
|
83
82
|
if (!a)
|
|
84
83
|
return !1;
|
|
85
|
-
|
|
84
|
+
s.delete(n);
|
|
86
85
|
const o = r.getValue(a.row, a.column);
|
|
87
86
|
return o && o.id === n && r.realDeleteValue(a.row, a.column), this._linkUpdate$.next({
|
|
88
87
|
unitId: e,
|
|
@@ -92,17 +91,17 @@ let _ = class extends k {
|
|
|
92
91
|
}), !0;
|
|
93
92
|
}
|
|
94
93
|
getHyperLink(e, t, n) {
|
|
95
|
-
const { matrix: r, positionMap:
|
|
94
|
+
const { matrix: r, positionMap: s } = this._ensureMap(e, t), a = s.get(n);
|
|
96
95
|
if (a)
|
|
97
96
|
return r.getValue(a.row, a.column);
|
|
98
97
|
}
|
|
99
98
|
getHyperLinkByLocation(e, t, n, r) {
|
|
100
|
-
const { matrix:
|
|
101
|
-
return
|
|
99
|
+
const { matrix: s } = this._ensureMap(e, t);
|
|
100
|
+
return s.getValue(n, r);
|
|
102
101
|
}
|
|
103
102
|
getHyperLinkByLocationSync(e, t, n, r) {
|
|
104
|
-
var u,
|
|
105
|
-
const { matrix:
|
|
103
|
+
var u, l, h, f, p;
|
|
104
|
+
const { matrix: s } = this._ensureMap(e, t), a = this._univerInstanceService.getUnit(e, A.UNIVER_SHEET), o = (u = a == null ? void 0 : a.getSheetBySheetId(t)) == null ? void 0 : u.getCellRaw(n, r), d = ((p = (f = o == null ? void 0 : o.v) != null ? f : (h = (l = o == null ? void 0 : o.p) == null ? void 0 : l.body) == null ? void 0 : h.dataStream.slice(0, -2)) != null ? p : "").toString(), c = s.getValue(n, r);
|
|
106
105
|
if (c)
|
|
107
106
|
return {
|
|
108
107
|
...c,
|
|
@@ -111,7 +110,7 @@ let _ = class extends k {
|
|
|
111
110
|
}
|
|
112
111
|
getSubUnit(e, t) {
|
|
113
112
|
const { matrix: n } = this._ensureMap(e, t), r = [];
|
|
114
|
-
return n.forValue((
|
|
113
|
+
return n.forValue((s, a, o) => {
|
|
115
114
|
o && r.push(o);
|
|
116
115
|
}), r;
|
|
117
116
|
}
|
|
@@ -138,117 +137,117 @@ let _ = class extends k {
|
|
|
138
137
|
return Array.from(this._linkMap.keys()).map((t) => this.getUnit(t));
|
|
139
138
|
}
|
|
140
139
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
],
|
|
140
|
+
g = he([
|
|
141
|
+
ge(0, F)
|
|
142
|
+
], g);
|
|
144
143
|
const H = {
|
|
145
144
|
type: m.MUTATION,
|
|
146
145
|
id: "sheets.mutation.add-hyper-link",
|
|
147
|
-
handler(
|
|
146
|
+
handler(i, e) {
|
|
148
147
|
if (!e)
|
|
149
148
|
return !1;
|
|
150
|
-
const t =
|
|
151
|
-
return t.addHyperLink(n, r,
|
|
149
|
+
const t = i.get(g), { unitId: n, subUnitId: r, link: s } = e;
|
|
150
|
+
return t.addHyperLink(n, r, s);
|
|
152
151
|
}
|
|
153
|
-
},
|
|
152
|
+
}, O = {
|
|
154
153
|
type: m.MUTATION,
|
|
155
154
|
id: "sheets.mutation.update-hyper-link",
|
|
156
|
-
handler(
|
|
155
|
+
handler(i, e) {
|
|
157
156
|
if (!e)
|
|
158
157
|
return !1;
|
|
159
|
-
const t =
|
|
160
|
-
return t.updateHyperLink(n, r, a,
|
|
158
|
+
const t = i.get(g), { unitId: n, subUnitId: r, payload: s, id: a } = e;
|
|
159
|
+
return t.updateHyperLink(n, r, a, s, !1);
|
|
161
160
|
}
|
|
162
|
-
},
|
|
161
|
+
}, _e = {
|
|
163
162
|
type: m.MUTATION,
|
|
164
163
|
id: "sheets.mutation.update-hyper-link-ref",
|
|
165
|
-
handler(
|
|
164
|
+
handler(i, e) {
|
|
166
165
|
if (!e)
|
|
167
166
|
return !1;
|
|
168
|
-
const t =
|
|
169
|
-
return t.updateHyperLinkRef(n, r,
|
|
167
|
+
const t = i.get(g), { unitId: n, subUnitId: r, id: s, row: a, column: o, silent: d } = e;
|
|
168
|
+
return t.updateHyperLinkRef(n, r, s, { row: a, column: o }, d);
|
|
170
169
|
}
|
|
171
|
-
},
|
|
170
|
+
}, b = {
|
|
172
171
|
type: m.MUTATION,
|
|
173
172
|
id: "sheets.mutation.remove-hyper-link",
|
|
174
|
-
handler(
|
|
173
|
+
handler(i, e) {
|
|
175
174
|
if (!e)
|
|
176
175
|
return !1;
|
|
177
|
-
const t =
|
|
178
|
-
return t.removeHyperLink(n, r,
|
|
176
|
+
const t = i.get(g), { unitId: n, subUnitId: r, id: s } = e;
|
|
177
|
+
return t.removeHyperLink(n, r, s);
|
|
179
178
|
}
|
|
180
|
-
},
|
|
179
|
+
}, j = {
|
|
181
180
|
type: m.COMMAND,
|
|
182
181
|
id: "sheets.command.add-hyper-link",
|
|
183
|
-
async handler(
|
|
182
|
+
async handler(i, e) {
|
|
184
183
|
if (!e)
|
|
185
184
|
return !1;
|
|
186
|
-
const t =
|
|
187
|
-
id:
|
|
185
|
+
const t = i.get(N), n = i.get(M), r = i.get(k), { unitId: s, subUnitId: a, link: o } = e, { redos: d, undos: c } = t.onCommandExecute({
|
|
186
|
+
id: j.id,
|
|
188
187
|
params: e
|
|
189
188
|
}), u = {
|
|
190
189
|
id: H.id,
|
|
191
190
|
params: e
|
|
192
|
-
},
|
|
193
|
-
id:
|
|
191
|
+
}, l = {
|
|
192
|
+
id: b.id,
|
|
194
193
|
params: {
|
|
195
|
-
unitId:
|
|
194
|
+
unitId: s,
|
|
196
195
|
subUnitId: a,
|
|
197
196
|
id: o.id
|
|
198
197
|
}
|
|
199
198
|
};
|
|
200
199
|
return (await R([u, ...d], n)).result ? (r.pushUndoRedo({
|
|
201
200
|
redoMutations: [u, ...d],
|
|
202
|
-
undoMutations: [
|
|
203
|
-
unitID:
|
|
201
|
+
undoMutations: [l, ...c],
|
|
202
|
+
unitID: s
|
|
204
203
|
}), !0) : !1;
|
|
205
204
|
}
|
|
206
205
|
};
|
|
207
|
-
function
|
|
208
|
-
const { row: e, column: t, id: n, ...r } =
|
|
206
|
+
function fe(i) {
|
|
207
|
+
const { row: e, column: t, id: n, ...r } = i;
|
|
209
208
|
return r;
|
|
210
209
|
}
|
|
211
|
-
const
|
|
210
|
+
const T = {
|
|
212
211
|
type: m.COMMAND,
|
|
213
212
|
id: "sheets.command.update-hyper-link",
|
|
214
|
-
async handler(
|
|
213
|
+
async handler(i, e) {
|
|
215
214
|
if (!e)
|
|
216
215
|
return !1;
|
|
217
|
-
const t =
|
|
216
|
+
const t = i.get(N), n = i.get(M), r = i.get(k), s = i.get(g), { unitId: a, subUnitId: o, id: d } = e, c = s.getHyperLink(a, o, d);
|
|
218
217
|
if (!c)
|
|
219
218
|
return !1;
|
|
220
|
-
const { redos: u, undos:
|
|
221
|
-
id:
|
|
219
|
+
const { redos: u, undos: l } = t.onCommandExecute({
|
|
220
|
+
id: T.id,
|
|
222
221
|
params: e
|
|
223
|
-
}),
|
|
224
|
-
id:
|
|
222
|
+
}), h = {
|
|
223
|
+
id: O.id,
|
|
225
224
|
params: e
|
|
226
225
|
}, f = {
|
|
227
|
-
id:
|
|
226
|
+
id: O.id,
|
|
228
227
|
params: {
|
|
229
228
|
unitId: a,
|
|
230
229
|
subUnitId: o,
|
|
231
230
|
id: d,
|
|
232
|
-
payload:
|
|
231
|
+
payload: fe(c)
|
|
233
232
|
}
|
|
234
233
|
};
|
|
235
|
-
return (await R([
|
|
236
|
-
redoMutations: [
|
|
237
|
-
undoMutations: [f, ...
|
|
234
|
+
return (await R([h, ...u], n)).result ? (r.pushUndoRedo({
|
|
235
|
+
redoMutations: [h, ...u],
|
|
236
|
+
undoMutations: [f, ...l],
|
|
238
237
|
unitID: a
|
|
239
238
|
}), !0) : !1;
|
|
240
239
|
}
|
|
241
|
-
},
|
|
240
|
+
}, W = {
|
|
242
241
|
type: m.COMMAND,
|
|
243
242
|
id: "sheets.command.remove-hyper-link",
|
|
244
|
-
async handler(
|
|
243
|
+
async handler(i, e) {
|
|
245
244
|
if (!e)
|
|
246
245
|
return !1;
|
|
247
|
-
const t =
|
|
248
|
-
id:
|
|
246
|
+
const t = i.get(N), n = i.get(M), r = i.get(k), s = i.get(g), { unitId: a, subUnitId: o, id: d } = e, c = s.getHyperLink(a, o, d), { redos: u, undos: l } = t.onCommandExecute({
|
|
247
|
+
id: W.id,
|
|
249
248
|
params: e
|
|
250
|
-
}),
|
|
251
|
-
id:
|
|
249
|
+
}), h = {
|
|
250
|
+
id: b.id,
|
|
252
251
|
params: e
|
|
253
252
|
}, f = {
|
|
254
253
|
id: H.id,
|
|
@@ -258,25 +257,25 @@ const W = {
|
|
|
258
257
|
link: c
|
|
259
258
|
}
|
|
260
259
|
};
|
|
261
|
-
return (await R([
|
|
262
|
-
redoMutations: [
|
|
263
|
-
undoMutations: [f, ...
|
|
260
|
+
return (await R([h, ...u], n)).result ? (r.pushUndoRedo({
|
|
261
|
+
redoMutations: [h, ...u],
|
|
262
|
+
undoMutations: [f, ...l],
|
|
264
263
|
unitID: a
|
|
265
264
|
}), !0) : !1;
|
|
266
265
|
}
|
|
267
|
-
},
|
|
266
|
+
}, me = {
|
|
268
267
|
type: m.COMMAND,
|
|
269
268
|
id: "sheets.command.cancel-hyper-link",
|
|
270
|
-
async handler(
|
|
269
|
+
async handler(i, e) {
|
|
271
270
|
if (!e)
|
|
272
271
|
return !1;
|
|
273
|
-
const t =
|
|
274
|
-
id:
|
|
272
|
+
const t = i.get(M), n = i.get(k), r = i.get(g), { unitId: s, subUnitId: a, id: o } = e, d = r.getHyperLink(s, a, o), c = {
|
|
273
|
+
id: b.id,
|
|
275
274
|
params: e
|
|
276
275
|
}, u = {
|
|
277
276
|
id: H.id,
|
|
278
277
|
params: {
|
|
279
|
-
unitId:
|
|
278
|
+
unitId: s,
|
|
280
279
|
subUnitId: a,
|
|
281
280
|
link: d
|
|
282
281
|
}
|
|
@@ -284,54 +283,54 @@ const W = {
|
|
|
284
283
|
return (await R([c], t)).result ? (n.pushUndoRedo({
|
|
285
284
|
redoMutations: [c],
|
|
286
285
|
undoMutations: [u],
|
|
287
|
-
unitID:
|
|
286
|
+
unitID: s
|
|
288
287
|
}), !0) : !1;
|
|
289
288
|
}
|
|
290
289
|
};
|
|
291
|
-
var
|
|
292
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
293
|
-
(a = s
|
|
294
|
-
return n && r &&
|
|
295
|
-
},
|
|
296
|
-
let
|
|
297
|
-
constructor(
|
|
298
|
-
super(), this._commandService =
|
|
290
|
+
var Me = Object.defineProperty, ye = Object.getOwnPropertyDescriptor, Re = (i, e, t, n) => {
|
|
291
|
+
for (var r = n > 1 ? void 0 : n ? ye(e, t) : e, s = i.length - 1, a; s >= 0; s--)
|
|
292
|
+
(a = i[s]) && (r = (n ? a(e, t, r) : a(r)) || r);
|
|
293
|
+
return n && r && Me(e, t, r), r;
|
|
294
|
+
}, ve = (i, e) => (t, n) => e(t, n, i);
|
|
295
|
+
let S = class extends C {
|
|
296
|
+
constructor(i) {
|
|
297
|
+
super(), this._commandService = i, this._registerCommands();
|
|
299
298
|
}
|
|
300
299
|
_registerCommands() {
|
|
301
300
|
[
|
|
302
301
|
H,
|
|
303
|
-
b,
|
|
304
302
|
O,
|
|
305
|
-
|
|
303
|
+
b,
|
|
304
|
+
_e,
|
|
305
|
+
j,
|
|
306
306
|
T,
|
|
307
307
|
W,
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
this._commandService.registerCommand(s);
|
|
308
|
+
me
|
|
309
|
+
].forEach((i) => {
|
|
310
|
+
this._commandService.registerCommand(i);
|
|
312
311
|
});
|
|
313
312
|
}
|
|
314
313
|
};
|
|
315
|
-
|
|
316
|
-
E(D.Starting,
|
|
317
|
-
|
|
318
|
-
],
|
|
319
|
-
var
|
|
320
|
-
const
|
|
321
|
-
var
|
|
322
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
323
|
-
(a = s
|
|
324
|
-
return n && r &&
|
|
325
|
-
}, V = (
|
|
326
|
-
let
|
|
327
|
-
constructor(
|
|
328
|
-
super(), this._resourceManagerService =
|
|
314
|
+
S = Re([
|
|
315
|
+
E(D.Starting, S),
|
|
316
|
+
ve(0, M)
|
|
317
|
+
], S);
|
|
318
|
+
var we = /* @__PURE__ */ ((i) => (i[i.range = 0] = "range", i[i.link = 1] = "link", i))(we || {});
|
|
319
|
+
const J = "SHEET_HYPER_LINK_PLUGIN", Se = "err";
|
|
320
|
+
var G = /* @__PURE__ */ ((i) => (i[i.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", i[i.UNIVER_DOC = 1] = "UNIVER_DOC", i[i.UNIVER_SHEET = 2] = "UNIVER_SHEET", i[i.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", i[i.UNRECOGNIZED = -1] = "UNRECOGNIZED", i))(G || {}), Le = Object.defineProperty, Ue = Object.getOwnPropertyDescriptor, Pe = (i, e, t, n) => {
|
|
321
|
+
for (var r = n > 1 ? void 0 : n ? Ue(e, t) : e, s = i.length - 1, a; s >= 0; s--)
|
|
322
|
+
(a = i[s]) && (r = (n ? a(e, t, r) : a(r)) || r);
|
|
323
|
+
return n && r && Le(e, t, r), r;
|
|
324
|
+
}, V = (i, e) => (t, n) => e(t, n, i);
|
|
325
|
+
let L = class extends C {
|
|
326
|
+
constructor(i, e) {
|
|
327
|
+
super(), this._resourceManagerService = i, this._hyperLinkModel = e, this._initSnapshot();
|
|
329
328
|
}
|
|
330
329
|
_initSnapshot() {
|
|
331
|
-
const
|
|
330
|
+
const i = (t) => {
|
|
332
331
|
const n = this._hyperLinkModel.getUnit(t), r = {};
|
|
333
|
-
return n ? (n.forEach((
|
|
334
|
-
r[
|
|
332
|
+
return n ? (n.forEach((s) => {
|
|
333
|
+
r[s.subUnitId] = s.links.map(({ display: a, ...o }) => o);
|
|
335
334
|
}), JSON.stringify(r)) : "";
|
|
336
335
|
}, e = (t) => {
|
|
337
336
|
if (!t)
|
|
@@ -344,9 +343,9 @@ let U = class extends k {
|
|
|
344
343
|
};
|
|
345
344
|
this.disposeWithMe(
|
|
346
345
|
this._resourceManagerService.registerPluginResource({
|
|
347
|
-
pluginName:
|
|
348
|
-
businesses: [
|
|
349
|
-
toJson: (t) =>
|
|
346
|
+
pluginName: J,
|
|
347
|
+
businesses: [G.UNIVER_SHEET],
|
|
348
|
+
toJson: (t) => i(t),
|
|
350
349
|
parseJson: (t) => e(t),
|
|
351
350
|
onUnLoad: (t) => {
|
|
352
351
|
this._hyperLinkModel.deleteUnit(t);
|
|
@@ -362,24 +361,24 @@ let U = class extends k {
|
|
|
362
361
|
);
|
|
363
362
|
}
|
|
364
363
|
};
|
|
365
|
-
|
|
366
|
-
E(D.Starting,
|
|
367
|
-
V(0,
|
|
368
|
-
V(1, y(
|
|
369
|
-
],
|
|
370
|
-
var
|
|
371
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
372
|
-
(a = s
|
|
373
|
-
return n && r &&
|
|
374
|
-
}, w = (
|
|
375
|
-
let
|
|
364
|
+
L = Pe([
|
|
365
|
+
E(D.Starting, L),
|
|
366
|
+
V(0, Q),
|
|
367
|
+
V(1, y(g))
|
|
368
|
+
], L);
|
|
369
|
+
var Ce = Object.defineProperty, ke = Object.getOwnPropertyDescriptor, He = (i, e, t, n) => {
|
|
370
|
+
for (var r = n > 1 ? void 0 : n ? ke(e, t) : e, s = i.length - 1, a; s >= 0; s--)
|
|
371
|
+
(a = i[s]) && (r = (n ? a(e, t, r) : a(r)) || r);
|
|
372
|
+
return n && r && Ce(e, t, r), r;
|
|
373
|
+
}, w = (i, e) => (t, n) => e(t, n, i);
|
|
374
|
+
let U = class extends C {
|
|
376
375
|
constructor(e, t, n, r) {
|
|
377
376
|
super();
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
377
|
+
_(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
378
|
+
_(this, "_watchDisposableMap", /* @__PURE__ */ new Map());
|
|
379
|
+
_(this, "_rangeDisableMap", /* @__PURE__ */ new Map());
|
|
380
|
+
_(this, "_rangeWatcherMap", /* @__PURE__ */ new Map());
|
|
381
|
+
_(this, "_handlePositionChange", (e, t, n, r, s) => {
|
|
383
382
|
const a = {
|
|
384
383
|
startColumn: n.column,
|
|
385
384
|
endColumn: n.column,
|
|
@@ -395,7 +394,7 @@ let P = class extends k {
|
|
|
395
394
|
id: n.id,
|
|
396
395
|
row: r.startRow,
|
|
397
396
|
column: r.startColumn,
|
|
398
|
-
silent:
|
|
397
|
+
silent: s
|
|
399
398
|
}
|
|
400
399
|
}],
|
|
401
400
|
undos: [{
|
|
@@ -406,12 +405,12 @@ let P = class extends k {
|
|
|
406
405
|
id: n.id,
|
|
407
406
|
row: a.startRow,
|
|
408
407
|
column: a.startColumn,
|
|
409
|
-
silent:
|
|
408
|
+
silent: s
|
|
410
409
|
}
|
|
411
410
|
}]
|
|
412
411
|
} : {
|
|
413
412
|
redos: [{
|
|
414
|
-
id:
|
|
413
|
+
id: de.id,
|
|
415
414
|
params: {
|
|
416
415
|
unitId: e,
|
|
417
416
|
subUnitId: t,
|
|
@@ -419,7 +418,7 @@ let P = class extends k {
|
|
|
419
418
|
}
|
|
420
419
|
}],
|
|
421
420
|
undos: [{
|
|
422
|
-
id:
|
|
421
|
+
id: ce.id,
|
|
423
422
|
params: {
|
|
424
423
|
unitId: e,
|
|
425
424
|
subUnitId: t,
|
|
@@ -431,22 +430,22 @@ let P = class extends k {
|
|
|
431
430
|
this._refRangeService = e, this._hyperLinkModel = t, this._selectionManagerService = n, this._commandService = r, this._initData(), this._initRefRange();
|
|
432
431
|
}
|
|
433
432
|
_registerPosition(e, t, n) {
|
|
434
|
-
const r = n.id,
|
|
433
|
+
const r = n.id, s = {
|
|
435
434
|
startColumn: n.column,
|
|
436
435
|
endColumn: n.column,
|
|
437
436
|
startRow: n.row,
|
|
438
437
|
endRow: n.row
|
|
439
438
|
}, a = (o) => {
|
|
440
|
-
const d = I(
|
|
441
|
-
return d && d.startColumn ===
|
|
439
|
+
const d = I(s, o, { selectionManagerService: this._selectionManagerService });
|
|
440
|
+
return d && d.startColumn === s.startColumn && d.startRow === s.startRow ? {
|
|
442
441
|
undos: [],
|
|
443
442
|
redos: []
|
|
444
443
|
} : this._handlePositionChange(e, t, n, d, !1);
|
|
445
444
|
};
|
|
446
|
-
this._disposableMap.set(r, this._refRangeService.registerRefRange(
|
|
445
|
+
this._disposableMap.set(r, this._refRangeService.registerRefRange(s, a, e, t));
|
|
447
446
|
}
|
|
448
447
|
_watchPosition(e, t, n) {
|
|
449
|
-
const r = n.id,
|
|
448
|
+
const r = n.id, s = {
|
|
450
449
|
startColumn: n.column,
|
|
451
450
|
endColumn: n.column,
|
|
452
451
|
startRow: n.row,
|
|
@@ -454,7 +453,7 @@ let P = class extends k {
|
|
|
454
453
|
};
|
|
455
454
|
this._watchDisposableMap.set(
|
|
456
455
|
r,
|
|
457
|
-
this._refRangeService.watchRange(e, t,
|
|
456
|
+
this._refRangeService.watchRange(e, t, s, (a, o) => {
|
|
458
457
|
const { redos: d } = this._handlePositionChange(e, t, n, o, !0);
|
|
459
458
|
R(d, this._commandService, { onlyLocal: !0 });
|
|
460
459
|
}, !0)
|
|
@@ -469,19 +468,19 @@ let P = class extends k {
|
|
|
469
468
|
t == null || t.dispose(), this._watchDisposableMap.delete(e);
|
|
470
469
|
}
|
|
471
470
|
_registerRange(e, t, n, r = !1) {
|
|
472
|
-
var
|
|
471
|
+
var s, a, o;
|
|
473
472
|
if (n.startsWith("#")) {
|
|
474
473
|
const d = new URLSearchParams(n.slice(1)), c = {
|
|
475
|
-
gid: (
|
|
474
|
+
gid: (s = d.get("gid")) != null ? s : "",
|
|
476
475
|
range: (a = d.get("range")) != null ? a : "",
|
|
477
476
|
rangeid: (o = d.get("rangeid")) != null ? o : ""
|
|
478
477
|
};
|
|
479
478
|
if (c.range && c.gid) {
|
|
480
|
-
const u = c.gid,
|
|
481
|
-
if (
|
|
482
|
-
const
|
|
483
|
-
const
|
|
484
|
-
return
|
|
479
|
+
const u = c.gid, l = ue(c.range).range;
|
|
480
|
+
if (X(l) && c.range !== Se) {
|
|
481
|
+
const h = (f) => {
|
|
482
|
+
const p = I(l, f, { selectionManagerService: this._selectionManagerService });
|
|
483
|
+
return p && v(p) === v(l) ? {
|
|
485
484
|
redos: [],
|
|
486
485
|
undos: []
|
|
487
486
|
} : {
|
|
@@ -492,7 +491,7 @@ let P = class extends k {
|
|
|
492
491
|
subUnitId: u,
|
|
493
492
|
id: t,
|
|
494
493
|
payload: {
|
|
495
|
-
payload: `#gid=${u}&range=${
|
|
494
|
+
payload: `#gid=${u}&range=${p ? v(p) : "err"}`
|
|
496
495
|
}
|
|
497
496
|
}
|
|
498
497
|
}],
|
|
@@ -509,9 +508,9 @@ let P = class extends k {
|
|
|
509
508
|
}]
|
|
510
509
|
};
|
|
511
510
|
};
|
|
512
|
-
this._rangeDisableMap.set(t, this._refRangeService.registerRefRange(
|
|
511
|
+
this._rangeDisableMap.set(t, this._refRangeService.registerRefRange(l, h, e, u)), r || this._rangeWatcherMap.set(t, this._refRangeService.watchRange(e, u, l, (f, p) => {
|
|
513
512
|
this._hyperLinkModel.updateHyperLink(e, u, t, {
|
|
514
|
-
payload: `#gid=${u}&range=${
|
|
513
|
+
payload: `#gid=${u}&range=${p ? v(p) : "err"}`
|
|
515
514
|
}, !0);
|
|
516
515
|
}, !0));
|
|
517
516
|
}
|
|
@@ -529,9 +528,9 @@ let P = class extends k {
|
|
|
529
528
|
_initData() {
|
|
530
529
|
this._hyperLinkModel.getAll().forEach((t) => {
|
|
531
530
|
t.forEach((n) => {
|
|
532
|
-
const { unitId: r, subUnitId:
|
|
531
|
+
const { unitId: r, subUnitId: s, links: a } = n;
|
|
533
532
|
a.forEach((o) => {
|
|
534
|
-
this._registerPosition(r,
|
|
533
|
+
this._registerPosition(r, s, o), this._watchPosition(r, s, o), this._registerRange(r, o.id, o.payload);
|
|
535
534
|
});
|
|
536
535
|
});
|
|
537
536
|
});
|
|
@@ -549,18 +548,18 @@ let P = class extends k {
|
|
|
549
548
|
break;
|
|
550
549
|
}
|
|
551
550
|
case "updateRef": {
|
|
552
|
-
const { unitId: t, subUnitId: n, id: r, silent:
|
|
551
|
+
const { unitId: t, subUnitId: n, id: r, silent: s } = e, a = this._hyperLinkModel.getHyperLink(t, n, r);
|
|
553
552
|
if (!a)
|
|
554
553
|
return;
|
|
555
|
-
this._unregisterPosition(r), this._registerPosition(t, n, a),
|
|
554
|
+
this._unregisterPosition(r), this._registerPosition(t, n, a), s || (this._unwatchPosition(r), this._watchPosition(t, n, a));
|
|
556
555
|
break;
|
|
557
556
|
}
|
|
558
557
|
case "unload": {
|
|
559
558
|
const { unitLinks: t } = e;
|
|
560
559
|
t.forEach((n) => {
|
|
561
560
|
const { links: r } = n;
|
|
562
|
-
r.forEach((
|
|
563
|
-
this._unregisterPosition(
|
|
561
|
+
r.forEach((s) => {
|
|
562
|
+
this._unregisterPosition(s.id), this._unwatchPosition(s.id), this._unregisterRange(s.id), this._unwatchRange(s.id);
|
|
564
563
|
});
|
|
565
564
|
});
|
|
566
565
|
break;
|
|
@@ -571,56 +570,59 @@ let P = class extends k {
|
|
|
571
570
|
}
|
|
572
571
|
}
|
|
573
572
|
})
|
|
574
|
-
), this.disposeWithMe(
|
|
573
|
+
), this.disposeWithMe(ee(() => {
|
|
575
574
|
this._disposableMap.forEach((e) => {
|
|
576
575
|
e.dispose();
|
|
577
576
|
}), this._disposableMap.clear();
|
|
578
577
|
}));
|
|
579
578
|
}
|
|
580
579
|
};
|
|
581
|
-
|
|
582
|
-
E(D.Starting,
|
|
583
|
-
w(0, y(
|
|
584
|
-
w(1, y(
|
|
585
|
-
w(2, y(
|
|
580
|
+
U = He([
|
|
581
|
+
E(D.Starting, U),
|
|
582
|
+
w(0, y(ie)),
|
|
583
|
+
w(1, y(oe)),
|
|
584
|
+
w(2, y(se)),
|
|
586
585
|
w(3, M)
|
|
587
|
-
],
|
|
588
|
-
var
|
|
589
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
590
|
-
(a = s
|
|
591
|
-
return n && r &&
|
|
592
|
-
},
|
|
593
|
-
let
|
|
594
|
-
constructor(
|
|
586
|
+
], U);
|
|
587
|
+
var K = Object.defineProperty, be = Object.getOwnPropertyDescriptor, Oe = (i, e, t) => e in i ? K(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, Ee = (i, e, t, n) => {
|
|
588
|
+
for (var r = n > 1 ? void 0 : n ? be(e, t) : e, s = i.length - 1, a; s >= 0; s--)
|
|
589
|
+
(a = i[s]) && (r = (n ? a(e, t, r) : a(r)) || r);
|
|
590
|
+
return n && r && K(e, t, r), r;
|
|
591
|
+
}, De = (i, e) => (t, n) => e(t, n, i), B = (i, e, t) => Oe(i, typeof e != "symbol" ? e + "" : e, t);
|
|
592
|
+
let P = class extends re {
|
|
593
|
+
constructor(i, e) {
|
|
595
594
|
super(), this._injector = e;
|
|
596
595
|
}
|
|
597
|
-
onStarting(
|
|
596
|
+
onStarting(i) {
|
|
598
597
|
[
|
|
599
|
-
[U],
|
|
600
598
|
[L],
|
|
601
|
-
[
|
|
602
|
-
[
|
|
599
|
+
[S],
|
|
600
|
+
[U],
|
|
601
|
+
[g]
|
|
603
602
|
].forEach((e) => {
|
|
604
|
-
|
|
603
|
+
i.add(e);
|
|
605
604
|
});
|
|
606
605
|
}
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
606
|
+
};
|
|
607
|
+
B(P, "pluginName", J);
|
|
608
|
+
B(P, "type", A.UNIVER_SHEET);
|
|
609
|
+
P = Ee([
|
|
610
|
+
te(ae),
|
|
611
|
+
De(1, y(ne))
|
|
612
|
+
], P);
|
|
611
613
|
export {
|
|
612
|
-
|
|
614
|
+
j as AddHyperLinkCommand,
|
|
613
615
|
H as AddHyperLinkMutation,
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
616
|
+
me as CancelHyperLinkCommand,
|
|
617
|
+
Se as ERROR_RANGE,
|
|
618
|
+
g as HyperLinkModel,
|
|
619
|
+
we as HyperLinkType,
|
|
620
|
+
W as RemoveHyperLinkCommand,
|
|
621
|
+
b as RemoveHyperLinkMutation,
|
|
622
|
+
S as SheetsHyperLinkController,
|
|
623
|
+
U as SheetsHyperLinkRefRangeController,
|
|
624
|
+
P as UniverSheetsHyperLinkPlugin,
|
|
625
|
+
T as UpdateHyperLinkCommand,
|
|
626
|
+
O as UpdateHyperLinkMutation,
|
|
627
|
+
_e as UpdateHyperLinkRefMutation
|
|
626
628
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Disposable, ICommandService } from '@univerjs/core';
|
|
2
|
-
import { RefRangeService,
|
|
2
|
+
import { RefRangeService, SheetsSelectionsService } from '@univerjs/sheets';
|
|
3
3
|
import { HyperLinkModel } from '@univerjs/sheets-hyper-link';
|
|
4
4
|
|
|
5
5
|
export declare class SheetsHyperLinkRefRangeController extends Disposable {
|
|
@@ -11,7 +11,7 @@ export declare class SheetsHyperLinkRefRangeController extends Disposable {
|
|
|
11
11
|
private _watchDisposableMap;
|
|
12
12
|
private _rangeDisableMap;
|
|
13
13
|
private _rangeWatcherMap;
|
|
14
|
-
constructor(_refRangeService: RefRangeService, _hyperLinkModel: HyperLinkModel, _selectionManagerService:
|
|
14
|
+
constructor(_refRangeService: RefRangeService, _hyperLinkModel: HyperLinkModel, _selectionManagerService: SheetsSelectionsService, _commandService: ICommandService);
|
|
15
15
|
private _handlePositionChange;
|
|
16
16
|
private _registerPosition;
|
|
17
17
|
private _watchPosition;
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Plugin, UniverInstanceType } from '@univerjs/core';
|
|
2
|
-
import { Injector } from '@wendellhu/redi';
|
|
1
|
+
import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
3
2
|
|
|
4
3
|
export declare class UniverSheetsHyperLinkPlugin extends Plugin {
|
|
5
4
|
protected _injector: Injector;
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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"})});
|
|
1
|
+
(function(d,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("rxjs"),require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-hyper-link"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","rxjs","@univerjs/core","@univerjs/sheets","@univerjs/sheets-hyper-link","@univerjs/engine-formula"],_):(d=typeof globalThis<"u"?globalThis:d||self,_(d.UniverSheetsHyperLink={},d.rxjs,d.UniverCore,d.UniverSheets,d.UniverSheetsHyperLink,d.UniverEngineFormula))})(this,function(d,_,u,f,v,S){"use strict";var se=Object.defineProperty;var ae=(d,_,u)=>_ in d?se(d,_,{enumerable:!0,configurable:!0,writable:!0,value:u}):d[_]=u;var m=(d,_,u)=>ae(d,typeof _!="symbol"?_+"":_,u);var V=Object.defineProperty,W=Object.getOwnPropertyDescriptor,q=(s,r,e,n)=>{for(var t=n>1?void 0:n?W(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(t=(n?a(r,e,t):a(t))||t);return n&&t&&V(r,e,t),t},G=(s,r)=>(e,n)=>r(e,n,s);d.HyperLinkModel=class extends u.Disposable{constructor(e){super();m(this,"_linkUpdate$",new _.Subject);m(this,"linkUpdate$",this._linkUpdate$.asObservable());m(this,"_linkMap",new Map);m(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 u.ObjectMatrix,t.set(n,i));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let o=a.get(n);return o||(o=new Map,a.set(n,o)),{matrix:i,positionMap:o}}addHyperLink(e,n,t){const{matrix:i,positionMap:a}=this._ensureMap(e,n);return i.setValue(t.row,t.column,t),a.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,a=!1){const{matrix:o,positionMap:c}=this._ensureMap(e,n),l=c.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:a})),!0}updateHyperLinkRef(e,n,t,i,a=!1){const{matrix:o,positionMap:c}=this._ensureMap(e,n),l=c.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),c.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:a}),!0}removeHyperLink(e,n,t){const{matrix:i,positionMap:a}=this._ensureMap(e,n),o=a.get(t);if(!o)return!1;a.delete(t);const c=i.getValue(o.row,o.column);return c&&c.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:a}=this._ensureMap(e,n),o=a.get(t);if(o)return i.getValue(o.row,o.column)}getHyperLinkByLocation(e,n,t,i){const{matrix:a}=this._ensureMap(e,n);return a.getValue(t,i)}getHyperLinkByLocationSync(e,n,t,i){var h,g,M,R,y;const{matrix:a}=this._ensureMap(e,n),o=this._univerInstanceService.getUnit(e,u.UniverInstanceType.UNIVER_SHEET),c=(h=o==null?void 0:o.getSheetBySheetId(n))==null?void 0:h.getCellRaw(t,i),l=((y=(R=c==null?void 0:c.v)!=null?R:(M=(g=c==null?void 0:c.p)==null?void 0:g.body)==null?void 0:M.dataStream.slice(0,-2))!=null?y:"").toString(),p=a.getValue(t,i);if(p)return{...p,display:l}}getSubUnit(e,n){const{matrix:t}=this._ensureMap(e,n),i=[];return t.forValue((a,o,c)=>{c&&i.push(c)}),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,u.IUniverInstanceService)],d.HyperLinkModel);const L={type:u.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(s,r){if(!r)return!1;const e=s.get(d.HyperLinkModel),{unitId:n,subUnitId:t,link:i}=r;return e.addHyperLink(n,t,i)}},C={type:u.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(s,r){if(!r)return!1;const e=s.get(d.HyperLinkModel),{unitId:n,subUnitId:t,payload:i,id:a}=r;return e.updateHyperLink(n,t,a,i,!1)}},E={type:u.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(s,r){if(!r)return!1;const e=s.get(d.HyperLinkModel),{unitId:n,subUnitId:t,id:i,row:a,column:o,silent:c}=r;return e.updateHyperLinkRef(n,t,i,{row:a,column:o},c)}},k={type:u.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(s,r){if(!r)return!1;const e=s.get(d.HyperLinkModel),{unitId:n,subUnitId:t,id:i}=r;return e.removeHyperLink(n,t,i)}},H={type:u.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(s,r){if(!r)return!1;const e=s.get(f.SheetInterceptorService),n=s.get(u.ICommandService),t=s.get(u.IUndoRedoService),{unitId:i,subUnitId:a,link:o}=r,{redos:c,undos:l}=e.onCommandExecute({id:H.id,params:r}),p={id:L.id,params:r},h={id:k.id,params:{unitId:i,subUnitId:a,id:o.id}};return(await u.sequenceExecuteAsync([p,...c],n)).result?(t.pushUndoRedo({redoMutations:[p,...c],undoMutations:[h,...l],unitID:i}),!0):!1}};function J(s){const{row:r,column:e,id:n,...t}=s;return t}const P={type:u.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(s,r){if(!r)return!1;const e=s.get(f.SheetInterceptorService),n=s.get(u.ICommandService),t=s.get(u.IUndoRedoService),i=s.get(d.HyperLinkModel),{unitId:a,subUnitId:o,id:c}=r,l=i.getHyperLink(a,o,c);if(!l)return!1;const{redos:p,undos:h}=e.onCommandExecute({id:P.id,params:r}),g={id:C.id,params:r},M={id:C.id,params:{unitId:a,subUnitId:o,id:c,payload:J(l)}};return(await u.sequenceExecuteAsync([g,...p],n)).result?(t.pushUndoRedo({redoMutations:[g,...p],undoMutations:[M,...h],unitID:a}),!0):!1}},I={type:u.CommandType.COMMAND,id:"sheets.command.remove-hyper-link",async handler(s,r){if(!r)return!1;const e=s.get(f.SheetInterceptorService),n=s.get(u.ICommandService),t=s.get(u.IUndoRedoService),i=s.get(d.HyperLinkModel),{unitId:a,subUnitId:o,id:c}=r,l=i.getHyperLink(a,o,c),{redos:p,undos:h}=e.onCommandExecute({id:I.id,params:r}),g={id:k.id,params:r},M={id:L.id,params:{unitId:a,subUnitId:o,link:l}};return(await u.sequenceExecuteAsync([g,...p],n)).result?(t.pushUndoRedo({redoMutations:[g,...p],undoMutations:[M,...h],unitID:a}),!0):!1}},O={type:u.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",async handler(s,r){if(!r)return!1;const e=s.get(u.ICommandService),n=s.get(u.IUndoRedoService),t=s.get(d.HyperLinkModel),{unitId:i,subUnitId:a,id:o}=r,c=t.getHyperLink(i,a,o),l={id:k.id,params:r},p={id:L.id,params:{unitId:i,subUnitId:a,link:c}};return(await u.sequenceExecuteAsync([l],e)).result?(n.pushUndoRedo({redoMutations:[l],undoMutations:[p],unitID:i}),!0):!1}};var z=Object.defineProperty,K=Object.getOwnPropertyDescriptor,B=(s,r,e,n)=>{for(var t=n>1?void 0:n?K(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(t=(n?a(r,e,t):a(t))||t);return n&&t&&z(r,e,t),t},Y=(s,r)=>(e,n)=>r(e,n,s);d.SheetsHyperLinkController=class extends u.Disposable{constructor(r){super(),this._commandService=r,this._registerCommands()}_registerCommands(){[L,C,k,E,H,P,I,O].forEach(r=>{this._commandService.registerCommand(r)})}},d.SheetsHyperLinkController=B([u.OnLifecycle(u.LifecycleStages.Starting,d.SheetsHyperLinkController),Y(0,u.ICommandService)],d.SheetsHyperLinkController);var b=(s=>(s[s.range=0]="range",s[s.link=1]="link",s))(b||{});const D="SHEET_HYPER_LINK_PLUGIN",N="err";var j=(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))(j||{}),Z=Object.defineProperty,Q=Object.getOwnPropertyDescriptor,X=(s,r,e,n)=>{for(var t=n>1?void 0:n?Q(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(t=(n?a(r,e,t):a(t))||t);return n&&t&&Z(r,e,t),t},$=(s,r)=>(e,n)=>r(e,n,s);let U=class extends u.Disposable{constructor(s,r){super(),this._resourceManagerService=s,this._hyperLinkModel=r,this._initSnapshot()}_initSnapshot(){const s=e=>{const n=this._hyperLinkModel.getUnit(e),t={};return n?(n.forEach(i=>{t[i.subUnitId]=i.links.map(({display:a,...o})=>o)}),JSON.stringify(t)):""},r=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:D,businesses:[j.UNIVER_SHEET],toJson:e=>s(e),parseJson:e=>r(e),onUnLoad:e=>{this._hyperLinkModel.deleteUnit(e)},onLoad:async(e,n)=>{Object.keys(n).forEach(t=>{n[t].forEach(a=>{this._hyperLinkModel.addHyperLink(e,t,a)})})}}))}};U=X([u.OnLifecycle(u.LifecycleStages.Starting,U),$(0,u.IResourceManagerService),$(1,u.Inject(d.HyperLinkModel))],U);var F=Object.defineProperty,x=Object.getOwnPropertyDescriptor,ee=(s,r,e,n)=>{for(var t=n>1?void 0:n?x(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(t=(n?a(r,e,t):a(t))||t);return n&&t&&F(r,e,t),t},w=(s,r)=>(e,n)=>r(e,n,s);d.SheetsHyperLinkRefRangeController=class extends u.Disposable{constructor(e,n,t,i){super();m(this,"_disposableMap",new Map);m(this,"_watchDisposableMap",new Map);m(this,"_rangeDisableMap",new Map);m(this,"_rangeWatcherMap",new Map);m(this,"_handlePositionChange",(e,n,t,i,a)=>{const o={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};return i?{redos:[{id:v.UpdateHyperLinkRefMutation.id,params:{unitId:e,subUnitId:n,id:t.id,row:i.startRow,column:i.startColumn,silent:a}}],undos:[{id:v.UpdateHyperLinkRefMutation.id,params:{unitId:e,subUnitId:n,id:t.id,row:o.startRow,column:o.startColumn,silent:a}}]}:{redos:[{id:v.RemoveHyperLinkMutation.id,params:{unitId:e,subUnitId:n,id:t.id}}],undos:[{id:v.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,a={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row},o=c=>{const l=f.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(a,c,{selectionManagerService:this._selectionManagerService});return l&&l.startColumn===a.startColumn&&l.startRow===a.startRow?{undos:[],redos:[]}:this._handlePositionChange(e,n,t,l,!1)};this._disposableMap.set(i,this._refRangeService.registerRefRange(a,o,e,n))}_watchPosition(e,n,t){const i=t.id,a={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._watchDisposableMap.set(i,this._refRangeService.watchRange(e,n,a,(o,c)=>{const{redos:l}=this._handlePositionChange(e,n,t,c,!0);u.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 a,o,c;if(t.startsWith("#")){const l=new URLSearchParams(t.slice(1)),p={gid:(a=l.get("gid"))!=null?a:"",range:(o=l.get("range"))!=null?o:"",rangeid:(c=l.get("rangeid"))!=null?c:""};if(p.range&&p.gid){const h=p.gid,g=S.deserializeRangeWithSheet(p.range).range;if(u.isValidRange(g)&&p.range!==N){const M=R=>{const y=f.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(g,R,{selectionManagerService:this._selectionManagerService});return y&&S.serializeRange(y)===S.serializeRange(g)?{redos:[],undos:[]}:{redos:[{id:v.UpdateHyperLinkMutation.id,params:{unitId:e,subUnitId:h,id:n,payload:{payload:`#gid=${h}&range=${y?S.serializeRange(y):"err"}`}}}],undos:[{id:v.UpdateHyperLinkMutation.id,params:{unitId:e,subUnitId:h,id:n,payload:{payload:t}}}]}};this._rangeDisableMap.set(n,this._refRangeService.registerRefRange(g,M,e,h)),i||this._rangeWatcherMap.set(n,this._refRangeService.watchRange(e,h,g,(R,y)=>{this._hyperLinkModel.updateHyperLink(e,h,n,{payload:`#gid=${h}&range=${y?S.serializeRange(y):"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:a,links:o}=t;o.forEach(c=>{this._registerPosition(i,a,c),this._watchPosition(i,a,c),this._registerRange(i,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:i,silent:a}=e,o=this._hyperLinkModel.getHyperLink(n,t,i);if(!o)return;this._unregisterPosition(i),this._registerPosition(n,t,o),a||(this._unwatchPosition(i),this._watchPosition(n,t,o));break}case"unload":{const{unitLinks:n}=e;n.forEach(t=>{const{links:i}=t;i.forEach(a=>{this._unregisterPosition(a.id),this._unwatchPosition(a.id),this._unregisterRange(a.id),this._unwatchRange(a.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(u.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}},d.SheetsHyperLinkRefRangeController=ee([u.OnLifecycle(u.LifecycleStages.Starting,d.SheetsHyperLinkRefRangeController),w(0,u.Inject(f.RefRangeService)),w(1,u.Inject(v.HyperLinkModel)),w(2,u.Inject(f.SheetsSelectionsService)),w(3,u.ICommandService)],d.SheetsHyperLinkRefRangeController);var T=Object.defineProperty,te=Object.getOwnPropertyDescriptor,ne=(s,r,e)=>r in s?T(s,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[r]=e,ie=(s,r,e,n)=>{for(var t=n>1?void 0:n?te(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(t=(n?a(r,e,t):a(t))||t);return n&&t&&T(r,e,t),t},re=(s,r)=>(e,n)=>r(e,n,s),A=(s,r,e)=>ne(s,typeof r!="symbol"?r+"":r,e);d.UniverSheetsHyperLinkPlugin=class extends u.Plugin{constructor(r,e){super(),this._injector=e}onStarting(r){[[U],[d.SheetsHyperLinkController],[d.SheetsHyperLinkRefRangeController],[d.HyperLinkModel]].forEach(e=>{r.add(e)})}},A(d.UniverSheetsHyperLinkPlugin,"pluginName",D),A(d.UniverSheetsHyperLinkPlugin,"type",u.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsHyperLinkPlugin=ie([u.DependentOn(f.UniverSheetsPlugin),re(1,u.Inject(u.Injector))],d.UniverSheetsHyperLinkPlugin),d.AddHyperLinkCommand=H,d.AddHyperLinkMutation=L,d.CancelHyperLinkCommand=O,d.ERROR_RANGE=N,d.HyperLinkType=b,d.RemoveHyperLinkCommand=I,d.RemoveHyperLinkMutation=k,d.UpdateHyperLinkCommand=P,d.UpdateHyperLinkMutation=C,d.UpdateHyperLinkRefMutation=E,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.2.
|
|
3
|
+
"version": "0.2.4-alpha.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -44,24 +44,22 @@
|
|
|
44
44
|
"lib"
|
|
45
45
|
],
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@wendellhu/redi": "0.15.5",
|
|
48
47
|
"rxjs": ">=7.0.0",
|
|
49
|
-
"@univerjs/engine-formula": "0.2.
|
|
50
|
-
"@univerjs/
|
|
51
|
-
"@univerjs/
|
|
52
|
-
"@univerjs/sheets-hyper-link": "0.2.
|
|
48
|
+
"@univerjs/engine-formula": "0.2.4-alpha.0",
|
|
49
|
+
"@univerjs/core": "0.2.4-alpha.0",
|
|
50
|
+
"@univerjs/sheets": "0.2.4-alpha.0",
|
|
51
|
+
"@univerjs/sheets-hyper-link": "0.2.4-alpha.0"
|
|
53
52
|
},
|
|
54
53
|
"devDependencies": {
|
|
55
|
-
"@univerjs/protocol": "0.1.38-alpha.
|
|
56
|
-
"@wendellhu/redi": "0.15.5",
|
|
54
|
+
"@univerjs/protocol": "0.1.38-alpha.23",
|
|
57
55
|
"rxjs": "^7.8.1",
|
|
58
56
|
"typescript": "^5.5.3",
|
|
59
|
-
"vite": "^5.3.
|
|
60
|
-
"vitest": "^
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/
|
|
64
|
-
"@univerjs/
|
|
57
|
+
"vite": "^5.3.4",
|
|
58
|
+
"vitest": "^2.0.3",
|
|
59
|
+
"@univerjs/engine-formula": "0.2.4-alpha.0",
|
|
60
|
+
"@univerjs/sheets": "0.2.4-alpha.0",
|
|
61
|
+
"@univerjs/core": "0.2.4-alpha.0",
|
|
62
|
+
"@univerjs/shared": "0.2.4-alpha.0"
|
|
65
63
|
},
|
|
66
64
|
"univerSpace": {
|
|
67
65
|
".": {
|