@univerjs/sheets-hyper-link 0.4.2 → 0.5.0-beta.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/facade.js +1 -0
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +101 -0
- package/lib/es/index.js +1056 -354
- package/lib/types/commands/commands/add-hyper-link.command.d.ts +19 -0
- package/lib/types/commands/commands/remove-hyper-link.command.d.ts +19 -0
- package/lib/types/commands/commands/update-hyper-link.command.d.ts +17 -0
- package/lib/types/controllers/remove-sheet.controller.d.ts +10 -0
- package/lib/types/controllers/rich-text-ref-range.controller.d.ts +15 -0
- package/lib/types/controllers/set-range.controller.d.ts +14 -0
- package/lib/types/facade/f-range.d.ts +50 -0
- package/lib/types/facade/f-workbook.d.ts +32 -0
- package/lib/types/facade/index.d.ts +18 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/services/parser.service.d.ts +24 -0
- package/lib/umd/facade.js +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +24 -13
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ICommand } from '@univerjs/core';
|
|
2
|
+
import { ICellHyperLink } from '../../types/interfaces/i-hyper-link';
|
|
3
|
+
export interface IAddHyperLinkCommandParams {
|
|
4
|
+
unitId: string;
|
|
5
|
+
subUnitId: string;
|
|
6
|
+
link: ICellHyperLink;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Command for add hyperlink
|
|
10
|
+
*/
|
|
11
|
+
export declare const AddHyperLinkCommand: ICommand<IAddHyperLinkCommandParams>;
|
|
12
|
+
export interface IAddRichHyperLinkCommandParams {
|
|
13
|
+
/**
|
|
14
|
+
* url of link
|
|
15
|
+
*/
|
|
16
|
+
documentId: string;
|
|
17
|
+
link: ICellHyperLink;
|
|
18
|
+
}
|
|
19
|
+
export declare const AddRichHyperLinkCommand: ICommand<IAddRichHyperLinkCommandParams>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ICommand } from '@univerjs/core';
|
|
2
|
+
export interface ICancelHyperLinkCommandParams {
|
|
3
|
+
unitId: string;
|
|
4
|
+
subUnitId: string;
|
|
5
|
+
/**
|
|
6
|
+
* id of link
|
|
7
|
+
*/
|
|
8
|
+
id: string;
|
|
9
|
+
row: number;
|
|
10
|
+
column: number;
|
|
11
|
+
}
|
|
12
|
+
export declare const CancelHyperLinkCommand: ICommand<ICancelHyperLinkCommandParams>;
|
|
13
|
+
export interface ICancelRichHyperLinkCommandParams extends ICancelHyperLinkCommandParams {
|
|
14
|
+
/**
|
|
15
|
+
* document id
|
|
16
|
+
*/
|
|
17
|
+
documentId: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const CancelRichHyperLinkCommand: ICommand<ICancelRichHyperLinkCommandParams>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ICommand } from '@univerjs/core';
|
|
2
|
+
import { ICellLinkContent } from '../../types/interfaces/i-hyper-link';
|
|
3
|
+
export interface IUpdateHyperLinkCommandParams {
|
|
4
|
+
unitId: string;
|
|
5
|
+
subUnitId: string;
|
|
6
|
+
id: string;
|
|
7
|
+
payload: ICellLinkContent;
|
|
8
|
+
row: number;
|
|
9
|
+
column: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const UpdateHyperLinkCommand: ICommand<IUpdateHyperLinkCommandParams>;
|
|
12
|
+
export interface IUpdateRichHyperLinkCommandParams {
|
|
13
|
+
documentId: string;
|
|
14
|
+
id: string;
|
|
15
|
+
payload: ICellLinkContent;
|
|
16
|
+
}
|
|
17
|
+
export declare const UpdateRichHyperLinkCommand: ICommand<IUpdateRichHyperLinkCommandParams>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
+
import { SheetInterceptorService } from '@univerjs/sheets';
|
|
3
|
+
import { HyperLinkModel } from '../models/hyper-link.model';
|
|
4
|
+
export declare class SheetsHyperLinkRemoveSheetController extends Disposable {
|
|
5
|
+
private _sheetInterceptorService;
|
|
6
|
+
private _univerInstanceService;
|
|
7
|
+
private _hyperLinkModel;
|
|
8
|
+
constructor(_sheetInterceptorService: SheetInterceptorService, _univerInstanceService: IUniverInstanceService, _hyperLinkModel: HyperLinkModel);
|
|
9
|
+
private _initSheetChange;
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
+
import { RefRangeService } from '@univerjs/sheets';
|
|
3
|
+
export declare class SheetsHyperLinkRichTextRefRangeController extends Disposable {
|
|
4
|
+
private readonly _commandService;
|
|
5
|
+
private readonly _univerInstanceService;
|
|
6
|
+
private readonly _refRangeService;
|
|
7
|
+
private _refRangeMap;
|
|
8
|
+
constructor(_commandService: ICommandService, _univerInstanceService: IUniverInstanceService, _refRangeService: RefRangeService);
|
|
9
|
+
private _enusreMap;
|
|
10
|
+
private _isLegalRangeUrl;
|
|
11
|
+
private _registerRange;
|
|
12
|
+
private _initWorkbookLoad;
|
|
13
|
+
private _initWorkbookUnload;
|
|
14
|
+
private _initSetRangesListener;
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
+
import { SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';
|
|
3
|
+
import { HyperLinkModel } from '../models/hyper-link.model';
|
|
4
|
+
export declare class SheetHyperLinkSetRangeController extends Disposable {
|
|
5
|
+
private readonly _sheetInterceptorService;
|
|
6
|
+
private readonly _hyperLinkModel;
|
|
7
|
+
private readonly _selectionManagerService;
|
|
8
|
+
private readonly _univerInstanceService;
|
|
9
|
+
constructor(_sheetInterceptorService: SheetInterceptorService, _hyperLinkModel: HyperLinkModel, _selectionManagerService: SheetsSelectionsService, _univerInstanceService: IUniverInstanceService);
|
|
10
|
+
private _initCommandInterceptor;
|
|
11
|
+
private _initSetRangeValuesCommandInterceptor;
|
|
12
|
+
private _initClearSelectionCommandInterceptor;
|
|
13
|
+
private _initAfterEditor;
|
|
14
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export interface ICellHyperLink {
|
|
17
|
+
id: string;
|
|
18
|
+
startIndex: number;
|
|
19
|
+
endIndex: number;
|
|
20
|
+
url: string;
|
|
21
|
+
label: string;
|
|
22
|
+
}
|
|
23
|
+
interface IFRangeHyperlinkMixin {
|
|
24
|
+
/**
|
|
25
|
+
* Get all hyperlinks in the cell in the range.
|
|
26
|
+
* @returns hyperlinks
|
|
27
|
+
*/
|
|
28
|
+
getHyperLinks(): ICellHyperLink[];
|
|
29
|
+
/**
|
|
30
|
+
* Update hyperlink in the cell in the range.
|
|
31
|
+
* [!important] This method is async.
|
|
32
|
+
* @param id id of the hyperlink
|
|
33
|
+
* @param url url
|
|
34
|
+
* @param label optional, label of the url
|
|
35
|
+
* @returns success or not
|
|
36
|
+
*/
|
|
37
|
+
updateHyperLink(id: string, url: string, label?: string): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Cancel hyperlink in the cell in the range.
|
|
40
|
+
* [!important] This method is async.
|
|
41
|
+
* @param id id of the hyperlink
|
|
42
|
+
* @returns success or not
|
|
43
|
+
*/
|
|
44
|
+
cancelHyperLink(id: string): Promise<boolean>;
|
|
45
|
+
}
|
|
46
|
+
declare module '@univerjs/sheets/facade' {
|
|
47
|
+
interface FRange extends IFRangeHyperlinkMixin {
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IRange } from '@univerjs/core';
|
|
2
|
+
import { ISheetHyperLinkInfo } from '@univerjs/sheets-hyper-link';
|
|
3
|
+
import { FWorkbook } from '@univerjs/sheets/facade';
|
|
4
|
+
interface IFWorkbookHyperlinkMixin {
|
|
5
|
+
/**
|
|
6
|
+
* create a hyperlink for the sheet
|
|
7
|
+
* @param sheetId the sheet id to link
|
|
8
|
+
* @param range the range to link, or define-name id
|
|
9
|
+
* @returns the hyperlink string
|
|
10
|
+
*/
|
|
11
|
+
createSheetHyperlink(this: FWorkbook, sheetId: string, range?: string | IRange): string;
|
|
12
|
+
/**
|
|
13
|
+
* parse the hyperlink string to get the hyperlink info
|
|
14
|
+
* @param hyperlink the hyperlink string
|
|
15
|
+
* @returns the hyperlink info
|
|
16
|
+
*/
|
|
17
|
+
parseSheetHyperlink(this: FWorkbook, hyperlink: string): ISheetHyperLinkInfo;
|
|
18
|
+
}
|
|
19
|
+
export declare class FWorkbookHyperLinkMixin extends FWorkbook implements IFWorkbookHyperlinkMixin {
|
|
20
|
+
createSheetHyperlink(sheetId: string, range?: string | IRange): string;
|
|
21
|
+
/**
|
|
22
|
+
* parse the hyperlink string to get the hyperlink info
|
|
23
|
+
* @param hyperlink the hyperlink string
|
|
24
|
+
* @returns the hyperlink info
|
|
25
|
+
*/
|
|
26
|
+
parseSheetHyperlink(hyperlink: string): ISheetHyperLinkInfo;
|
|
27
|
+
}
|
|
28
|
+
declare module '@univerjs/sheets/facade' {
|
|
29
|
+
interface FWorkbook extends IFWorkbookHyperlinkMixin {
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import './f-workbook';
|
|
17
|
+
import './f-range';
|
|
18
|
+
export { FWorkbookHyperLinkMixin } from './f-workbook';
|
package/lib/types/index.d.ts
CHANGED
|
@@ -17,7 +17,11 @@ export { HyperLinkModel } from './models/hyper-link.model';
|
|
|
17
17
|
export { SheetHyperLinkType } from './types/enums/hyper-link-type';
|
|
18
18
|
export { UniverSheetsHyperLinkPlugin } from './plugin';
|
|
19
19
|
export type { ICellHyperLink, ICellLinkContent } from './types/interfaces/i-hyper-link';
|
|
20
|
+
export { type ISheetHyperLinkInfo, type ISheetUrlParams, SheetsHyperLinkParserService } from './services/parser.service';
|
|
20
21
|
export { ERROR_RANGE } from './types/const';
|
|
22
|
+
export { AddHyperLinkCommand, AddRichHyperLinkCommand, type IAddHyperLinkCommandParams, type IAddRichHyperLinkCommandParams } from './commands/commands/add-hyper-link.command';
|
|
23
|
+
export { CancelHyperLinkCommand, CancelRichHyperLinkCommand, type ICancelHyperLinkCommandParams, type ICancelRichHyperLinkCommandParams } from './commands/commands/remove-hyper-link.command';
|
|
24
|
+
export { type IUpdateHyperLinkCommandParams, type IUpdateRichHyperLinkCommandParams, UpdateHyperLinkCommand, UpdateRichHyperLinkCommand } from './commands/commands/update-hyper-link.command';
|
|
21
25
|
export { AddHyperLinkMutation, type IAddHyperLinkMutationParams } from './commands/mutations/add-hyper-link.mutation';
|
|
22
26
|
export { type IRemoveHyperLinkMutationParams, RemoveHyperLinkMutation } from './commands/mutations/remove-hyper-link.mutation';
|
|
23
27
|
export { type IUpdateHyperLinkMutationParams, type IUpdateHyperLinkRefMutationParams, UpdateHyperLinkMutation, UpdateHyperLinkRefMutation, } from './commands/mutations/update-hyper-link.mutation';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IRange, Nullable, IUniverInstanceService, LocaleService } from '@univerjs/core';
|
|
2
|
+
import { IDefinedNamesService } from '@univerjs/engine-formula';
|
|
3
|
+
import { SheetHyperLinkType } from '../types/enums/hyper-link-type';
|
|
4
|
+
export interface ISheetUrlParams {
|
|
5
|
+
gid?: string;
|
|
6
|
+
range?: string;
|
|
7
|
+
rangeid?: string;
|
|
8
|
+
unitid?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ISheetHyperLinkInfo {
|
|
11
|
+
type: SheetHyperLinkType;
|
|
12
|
+
name: string;
|
|
13
|
+
url: string;
|
|
14
|
+
searchObj: Nullable<ISheetUrlParams>;
|
|
15
|
+
}
|
|
16
|
+
export declare class SheetsHyperLinkParserService {
|
|
17
|
+
private _univerInstanceService;
|
|
18
|
+
private _localeService;
|
|
19
|
+
private _definedNamesService;
|
|
20
|
+
constructor(_univerInstanceService: IUniverInstanceService, _localeService: LocaleService, _definedNamesService: IDefinedNamesService);
|
|
21
|
+
buildHyperLink(unitId: string, sheetId: string, range?: string | IRange): string;
|
|
22
|
+
parseHyperLink(urlStr: string): ISheetHyperLinkInfo;
|
|
23
|
+
private _getURLName;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/sheets/facade"),require("@univerjs/sheets-hyper-link"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets/facade","@univerjs/sheets-hyper-link","@univerjs/core"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.UniverSheetsHyperLinkFacade={},n.UniverSheetsFacade,n.UniverSheetsHyperLink,n.UniverCore))})(this,function(n,i,a,d){"use strict";class p extends i.FWorkbook{createSheetHyperlink(e,t){return this._injector.get(a.SheetsHyperLinkParserService).buildHyperLink(this.getId(),e,t)}parseSheetHyperlink(e){return this._injector.get(a.SheetsHyperLinkParserService).parseHyperLink(e)}}i.FWorkbook.extend(p);class k extends i.FRange{setHyperLink(e,t){const s={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),link:{row:this._range.startRow,column:this._range.startColumn,payload:e,display:t,id:d.generateRandomId()}};return this._commandService.executeCommand(a.AddHyperLinkCommand.id,s)}getHyperLinks(){var t,s,o;const e=this._worksheet.getCellRaw(this._range.startRow,this._range.startColumn);return e!=null&&e.p?(o=(s=(t=e.p.body)==null?void 0:t.customRanges)==null?void 0:s.filter(r=>r.rangeType===d.CustomRangeType.HYPERLINK).map(r=>{var u,h,c,m,l;return{id:`${r.rangeId}_${r.startIndex}_${r.endIndex}`,startIndex:r.startIndex,endIndex:r.endIndex,url:(h=(u=r.properties)==null?void 0:u.url)!=null?h:"",label:(l=(m=(c=e.p)==null?void 0:c.body)==null?void 0:m.dataStream.slice(r.startIndex,r.endIndex+1).replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(d.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))!=null?l:""}}))!=null?o:[]:[]}updateHyperLink(e,t,s){const o={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e,payload:{payload:t,display:s}};return this._commandService.executeCommand(a.UpdateHyperLinkCommand.id,o)}cancelHyperLink(e){const t={unitId:this.getUnitId(),subUnitId:this._worksheet.getSheetId(),row:this._range.startRow,column:this._range.startColumn,id:e};return this._commandService.executeCommand(a.CancelHyperLinkCommand.id,t)}}i.FRange.extend(k),n.FWorkbookHyperLinkMixin=p,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("rxjs"),require("@univerjs/sheets"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs","@univerjs/sheets","@univerjs/engine-formula"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsHyperLink={},global.UniverCore,global.rxjs,global.UniverSheets,global.UniverEngineFormula))})(this,function(exports2,core,rxjs,sheets,engineFormula){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c,_d,_e;var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4");exports2.HyperLinkModel=(_a=class extends core.Disposable{constructor(_univerInstanceService){super();__publicField(this,"_linkUpdate$",new rxjs.Subject);__publicField(this,"linkUpdate$",this._linkUpdate$.asObservable());__publicField(this,"_linkMap",new Map);__publicField(this,"_linkPositionMap",new Map);this._univerInstanceService=_univerInstanceService,this.disposeWithMe({dispose:__name(()=>{this._linkUpdate$.complete()},"dispose")})}_ensureMap(unitId,subUnitId){let unitMap=this._linkMap.get(unitId);unitMap||(unitMap=new Map,this._linkMap.set(unitId,unitMap));let matrix=unitMap.get(subUnitId);matrix||(matrix=new core.ObjectMatrix,unitMap.set(subUnitId,matrix));let positionUnitMap=this._linkPositionMap.get(unitId);positionUnitMap||(positionUnitMap=new Map,this._linkPositionMap.set(unitId,positionUnitMap));let positionSubUnitMap=positionUnitMap.get(subUnitId);return positionSubUnitMap||(positionSubUnitMap=new Map,positionUnitMap.set(subUnitId,positionSubUnitMap)),{matrix,positionMap:positionSubUnitMap}}addHyperLink(unitId,subUnitId,link){const{matrix,positionMap}=this._ensureMap(unitId,subUnitId);return matrix.setValue(link.row,link.column,link),positionMap.set(link.id,{row:link.row,column:link.column,link}),this._linkUpdate$.next({unitId,subUnitId,payload:link,type:"add"}),!0}updateHyperLink(unitId,subUnitId,id,payload,silent=!1){const{matrix,positionMap}=this._ensureMap(unitId,subUnitId),position=positionMap.get(id);if(!position)return!0;const link=matrix.getValue(position.row,position.column);return link&&(Object.assign(link,payload),this._linkUpdate$.next({unitId,subUnitId,payload:{display:link.display,payload:link.payload},id,type:"update",silent})),!0}updateHyperLinkRef(unitId,subUnitId,id,payload,silent=!1){const{matrix,positionMap}=this._ensureMap(unitId,subUnitId),position=positionMap.get(id);if(!position)return!0;let link=matrix.getValue(position.row,position.column);return!link||link.id!==id?link=position.link:matrix.realDeleteValue(position.row,position.column),Object.assign(link,payload),positionMap.set(id,{...payload,link}),matrix.setValue(payload.row,payload.column,link),this._linkUpdate$.next({unitId,subUnitId,payload,id,type:"updateRef",silent}),!0}removeHyperLink(unitId,subUnitId,id){const{matrix,positionMap}=this._ensureMap(unitId,subUnitId),position=positionMap.get(id);if(!position)return!1;positionMap.delete(id);const link=matrix.getValue(position.row,position.column);return link&&link.id===id&&matrix.realDeleteValue(position.row,position.column),this._linkUpdate$.next({unitId,subUnitId,payload:position.link,type:"remove"}),!0}getHyperLink(unitId,subUnitId,id){const{matrix,positionMap}=this._ensureMap(unitId,subUnitId),position=positionMap.get(id);if(position)return matrix.getValue(position.row,position.column)}getHyperLinkByLocation(unitId,subUnitId,row,column){const{matrix}=this._ensureMap(unitId,subUnitId);return matrix.getValue(row,column)}getHyperLinkByLocationSync(unitId,subUnitId,row,column){var _a2,_b2,_c2,_d2,_e2;const{matrix}=this._ensureMap(unitId,subUnitId),workbook=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET),cell=(_a2=workbook==null?void 0:workbook.getSheetBySheetId(subUnitId))==null?void 0:_a2.getCellRaw(row,column),cellValueStr=((_e2=(_d2=cell==null?void 0:cell.v)!=null?_d2:(_c2=(_b2=cell==null?void 0:cell.p)==null?void 0:_b2.body)==null?void 0:_c2.dataStream.slice(0,-2))!=null?_e2:"").toString(),link=matrix.getValue(row,column);if(link)return{...link,display:cellValueStr}}getSubUnit(unitId,subUnitId){const{matrix}=this._ensureMap(unitId,subUnitId),links=[];return matrix.forValue((row,col,value)=>{value&&links.push(value)}),links}getUnit(unitId){const unitMap=this._linkMap.get(unitId);return unitMap?Array.from(unitMap.keys()).map(subUnitId=>{const links=this.getSubUnit(unitId,subUnitId);return{unitId,subUnitId,links}}):[]}deleteUnit(unitId){const links=this.getUnit(unitId);this._linkMap.delete(unitId),this._linkPositionMap.delete(unitId),this._linkUpdate$.next({type:"unload",unitId,unitLinks:links})}getAll(){return Array.from(this._linkMap.keys()).map(unitId=>this.getUnit(unitId))}},__name(_a,"HyperLinkModel"),_a),exports2.HyperLinkModel=__decorateClass$4([__decorateParam$4(0,core.IUniverInstanceService)],exports2.HyperLinkModel);var SheetHyperLinkType=(SheetHyperLinkType2=>(SheetHyperLinkType2.SHEET="gid",SheetHyperLinkType2.RANGE="range",SheetHyperLinkType2.DEFINE_NAME="rangeid",SheetHyperLinkType2.INVALID="invalid",SheetHyperLinkType2.URL="url",SheetHyperLinkType2))(SheetHyperLinkType||{});const PLUGIN_CONFIG_KEY="sheets-hyper-link.config",defaultPluginConfig={},AddHyperLinkMutation={type:core.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(accessor,params){if(!params)return!1;const model=accessor.get(exports2.HyperLinkModel),{unitId,subUnitId,link}=params;return model.addHyperLink(unitId,subUnitId,link)}},RemoveHyperLinkMutation={type:core.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(accessor,params){if(!params)return!1;const model=accessor.get(exports2.HyperLinkModel),{unitId,subUnitId,id}=params;return model.removeHyperLink(unitId,subUnitId,id)}},UpdateHyperLinkMutation={type:core.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(accessor,params){if(!params)return!1;const model=accessor.get(exports2.HyperLinkModel),{unitId,subUnitId,payload,id}=params;return model.updateHyperLink(unitId,subUnitId,id,payload,!1)}},UpdateHyperLinkRefMutation={type:core.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(accessor,params){if(!params)return!1;const model=accessor.get(exports2.HyperLinkModel),{unitId,subUnitId,id,row,column,silent}=params;return model.updateHyperLinkRef(unitId,subUnitId,id,{row,column},silent)}},SHEET_HYPER_LINK_PLUGIN="SHEET_HYPER_LINK_PLUGIN",ERROR_RANGE="err";var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3");let SheetsHyperLinkRefRangeController=(_b=class extends core.Disposable{constructor(_refRangeService,_hyperLinkModel,_selectionManagerService,_commandService){super();__publicField(this,"_disposableMap",new Map);__publicField(this,"_watchDisposableMap",new Map);__publicField(this,"_rangeDisableMap",new Map);__publicField(this,"_rangeWatcherMap",new Map);__publicField(this,"_handlePositionChange",__name((unitId,subUnitId,link,resultRange,silent)=>{const oldRange={startColumn:link.column,endColumn:link.column,startRow:link.row,endRow:link.row};return resultRange?{redos:[{id:UpdateHyperLinkRefMutation.id,params:{unitId,subUnitId,id:link.id,row:resultRange.startRow,column:resultRange.startColumn,silent}}],undos:[{id:UpdateHyperLinkRefMutation.id,params:{unitId,subUnitId,id:link.id,row:oldRange.startRow,column:oldRange.startColumn,silent}}]}:{redos:[{id:RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:link.id}}],undos:[{id:AddHyperLinkMutation.id,params:{unitId,subUnitId,link}}]}},"_handlePositionChange"));this._refRangeService=_refRangeService,this._hyperLinkModel=_hyperLinkModel,this._selectionManagerService=_selectionManagerService,this._commandService=_commandService,this._initData(),this._initRefRange()}_registerPosition(unitId,subUnitId,link){const id=link.id,oldRange={startColumn:link.column,endColumn:link.column,startRow:link.row,endRow:link.row},handleRefRangeChange=__name(commandInfo=>{const resultRanges=sheets.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(oldRange,commandInfo,{selectionManagerService:this._selectionManagerService}),resultRange=Array.isArray(resultRanges)?resultRanges[0]:resultRanges;return resultRange&&resultRange.startColumn===oldRange.startColumn&&resultRange.startRow===oldRange.startRow?{undos:[],redos:[]}:this._handlePositionChange(unitId,subUnitId,link,resultRange,!1)},"handleRefRangeChange");this._disposableMap.set(id,this._refRangeService.registerRefRange(oldRange,handleRefRangeChange,unitId,subUnitId))}_watchPosition(unitId,subUnitId,link){const id=link.id,oldRange={startColumn:link.column,endColumn:link.column,startRow:link.row,endRow:link.row};this._watchDisposableMap.set(id,this._refRangeService.watchRange(unitId,subUnitId,oldRange,(before,after)=>{const{redos}=this._handlePositionChange(unitId,subUnitId,link,after,!0);core.sequenceExecuteAsync(redos,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(id){const disposable=this._disposableMap.get(id);disposable==null||disposable.dispose(),this._disposableMap.delete(id)}_unwatchPosition(id){const disposable=this._watchDisposableMap.get(id);disposable==null||disposable.dispose(),this._watchDisposableMap.delete(id)}_registerRange(unitId,id,payload,silent=!1){var _a2,_b2,_c2;if(payload.startsWith("#")){const search=new URLSearchParams(payload.slice(1)),searchObj={gid:(_a2=search.get("gid"))!=null?_a2:"",range:(_b2=search.get("range"))!=null?_b2:"",rangeid:(_c2=search.get("rangeid"))!=null?_c2:""};if(searchObj.range&&searchObj.gid){const subUnitId=searchObj.gid,range=engineFormula.deserializeRangeWithSheet(searchObj.range).range;if(core.isValidRange(range)&&searchObj.range!==ERROR_RANGE){const handleRangeChange=__name(commandInfo=>{const resultRange=sheets.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(range,commandInfo,{selectionManagerService:this._selectionManagerService});return resultRange&&engineFormula.serializeRange(resultRange)===engineFormula.serializeRange(range)?{redos:[],undos:[]}:{redos:[{id:UpdateHyperLinkMutation.id,params:{unitId,subUnitId,id,payload:{payload:`#gid=${subUnitId}&range=${resultRange?engineFormula.serializeRange(resultRange):"err"}`}}}],undos:[{id:UpdateHyperLinkMutation.id,params:{unitId,subUnitId,id,payload:{payload}}}]}},"handleRangeChange");this._rangeDisableMap.set(id,this._refRangeService.registerRefRange(range,handleRangeChange,unitId,subUnitId)),silent||this._rangeWatcherMap.set(id,this._refRangeService.watchRange(unitId,subUnitId,range,(before,after)=>{this._hyperLinkModel.updateHyperLink(unitId,subUnitId,id,{payload:`#gid=${subUnitId}&range=${after?engineFormula.serializeRange(after):"err"}`},!0)},!0))}}}}_unregisterRange(id){const disposable=this._rangeDisableMap.get(id);disposable==null||disposable.dispose(),this._rangeDisableMap.delete(id)}_unwatchRange(id){const disposable=this._rangeWatcherMap.get(id);disposable==null||disposable.dispose(),this._rangeWatcherMap.delete(id)}_initData(){this._hyperLinkModel.getAll().forEach(unitData=>{unitData.forEach(subUnitData=>{const{unitId,subUnitId,links}=subUnitData;links.forEach(link=>{this._registerPosition(unitId,subUnitId,link),this._watchPosition(unitId,subUnitId,link),this._registerRange(unitId,link.id,link.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(option=>{switch(option.type){case"add":{this._registerPosition(option.unitId,option.subUnitId,option.payload),this._watchPosition(option.unitId,option.subUnitId,option.payload),this._registerRange(option.unitId,option.payload.id,option.payload.payload);break}case"remove":{this._unregisterPosition(option.payload.id),this._unwatchPosition(option.payload.id),this._unregisterRange(option.payload.id),this._unwatchRange(option.payload.id);break}case"updateRef":{const{unitId,subUnitId,id,silent}=option,link=this._hyperLinkModel.getHyperLink(unitId,subUnitId,id);if(!link)return;this._unregisterPosition(id),this._registerPosition(unitId,subUnitId,link),silent||(this._unwatchPosition(id),this._watchPosition(unitId,subUnitId,link));break}case"unload":{const{unitLinks}=option;unitLinks.forEach(subUnitData=>{const{links}=subUnitData;links.forEach(link=>{this._unregisterPosition(link.id),this._unwatchPosition(link.id),this._unregisterRange(link.id),this._unwatchRange(link.id)})});break}case"update":{option.silent||this._unwatchRange(option.id),this._unregisterRange(option.id),this._registerRange(option.unitId,option.id,option.payload.payload,option.silent);break}}})),this.disposeWithMe(core.toDisposable(()=>{this._disposableMap.forEach(item=>{item.dispose()}),this._disposableMap.clear()}))}},__name(_b,"SheetsHyperLinkRefRangeController"),_b);SheetsHyperLinkRefRangeController=__decorateClass$3([__decorateParam$3(0,core.Inject(sheets.RefRangeService)),__decorateParam$3(1,core.Inject(exports2.HyperLinkModel)),__decorateParam$3(2,core.Inject(sheets.SheetsSelectionsService)),__decorateParam$3(3,core.ICommandService)],SheetsHyperLinkRefRangeController);var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");let SheetsHyperLinkController=(_c=class extends core.Disposable{constructor(_commandService){super(),this._commandService=_commandService,this._registerCommands()}_registerCommands(){[AddHyperLinkMutation,UpdateHyperLinkMutation,RemoveHyperLinkMutation,UpdateHyperLinkRefMutation].forEach(command=>{this._commandService.registerCommand(command)})}},__name(_c,"SheetsHyperLinkController"),_c);SheetsHyperLinkController=__decorateClass$2([__decorateParam$2(0,core.ICommandService)],SheetsHyperLinkController);var _=(E=>(E[E.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",E[E.UNIVER_DOC=1]="UNIVER_DOC",E[E.UNIVER_SHEET=2]="UNIVER_SHEET",E[E.UNIVER_SLIDE=3]="UNIVER_SLIDE",E[E.UNIVER_PROJECT=4]="UNIVER_PROJECT",E[E.UNRECOGNIZED=-1]="UNRECOGNIZED",E))(_||{}),__defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");let SheetsHyperLinkResourceController=(_d=class extends core.Disposable{constructor(_resourceManagerService,_hyperLinkModel){super(),this._resourceManagerService=_resourceManagerService,this._hyperLinkModel=_hyperLinkModel,this._initSnapshot()}_initSnapshot(){const toJson=__name(unitID=>{const map=this._hyperLinkModel.getUnit(unitID),resultMap={};return map?(map.forEach(info=>{resultMap[info.subUnitId]=info.links.map(({display,...link})=>link)}),JSON.stringify(resultMap)):""},"toJson"),parseJson=__name(json=>{if(!json)return{};try{return JSON.parse(json)}catch{return{}}},"parseJson");this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:SHEET_HYPER_LINK_PLUGIN,businesses:[_.UNIVER_SHEET],toJson:__name(unitID=>toJson(unitID),"toJson"),parseJson:__name(json=>parseJson(json),"parseJson"),onUnLoad:__name(unitID=>{this._hyperLinkModel.deleteUnit(unitID)},"onUnLoad"),onLoad:__name(async(unitID,value)=>{Object.keys(value).forEach(subunitId=>{value[subunitId].forEach(link=>{this._hyperLinkModel.addHyperLink(unitID,subunitId,link)})})},"onLoad")}))}},__name(_d,"SheetsHyperLinkResourceController"),_d);SheetsHyperLinkResourceController=__decorateClass$1([__decorateParam$1(0,core.IResourceManagerService),__decorateParam$1(1,core.Inject(exports2.HyperLinkModel))],SheetsHyperLinkResourceController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField");exports2.UniverSheetsHyperLinkPlugin=(_e=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[SheetsHyperLinkResourceController],[SheetsHyperLinkController],[SheetsHyperLinkRefRangeController],[exports2.HyperLinkModel]].forEach(dep=>{this._injector.add(dep)}),this._injector.get(SheetsHyperLinkRefRangeController),this._injector.get(SheetsHyperLinkResourceController),this._injector.get(SheetsHyperLinkController)}},__name(_e,"UniverSheetsHyperLinkPlugin"),_e),__publicField2(exports2.UniverSheetsHyperLinkPlugin,"pluginName",SHEET_HYPER_LINK_PLUGIN),__publicField2(exports2.UniverSheetsHyperLinkPlugin,"type",core.UniverInstanceType.UNIVER_SHEET),exports2.UniverSheetsHyperLinkPlugin=__decorateClass([core.DependentOn(sheets.UniverSheetsPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService)],exports2.UniverSheetsHyperLinkPlugin),exports2.AddHyperLinkMutation=AddHyperLinkMutation,exports2.ERROR_RANGE=ERROR_RANGE,exports2.RemoveHyperLinkMutation=RemoveHyperLinkMutation,exports2.SheetHyperLinkType=SheetHyperLinkType,exports2.UpdateHyperLinkMutation=UpdateHyperLinkMutation,exports2.UpdateHyperLinkRefMutation=UpdateHyperLinkRefMutation,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(p,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("rxjs"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs","@univerjs/sheets","@univerjs/engine-formula","@univerjs/docs"],o):(p=typeof globalThis<"u"?globalThis:p||self,o(p.UniverSheetsHyperLink={},p.UniverCore,p.rxjs,p.UniverSheets,p.UniverEngineFormula,p.UniverDocs))})(this,function(p,o,H,m,M,x){"use strict";var Ze=Object.defineProperty;var Qe=(p,o,H)=>o in p?Ze(p,o,{enumerable:!0,configurable:!0,writable:!0,value:H}):p[o]=H;var U=(p,o,H)=>Qe(p,typeof o!="symbol"?o+"":o,H);var Se=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Re=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ie(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Se(t,e,i),i},Me=(r,t)=>(e,n)=>t(e,n,r);p.HyperLinkModel=class extends o.Disposable{constructor(e){super();U(this,"_linkUpdate$",new H.Subject);U(this,"linkUpdate$",this._linkUpdate$.asObservable());U(this,"_linkMap",new Map);U(this,"_linkPositionMap",new Map);this._univerInstanceService=e,this.disposeWithMe({dispose:()=>{this._linkUpdate$.complete()}})}_ensureMap(e,n){let i=this._linkMap.get(e);i||(i=new Map,this._linkMap.set(e,i));let s=i.get(n);s||(s=new o.ObjectMatrix,i.set(n,s));let a=this._linkPositionMap.get(e);a||(a=new Map,this._linkPositionMap.set(e,a));let d=a.get(n);return d||(d=new Map,a.set(n,d)),{matrix:s,positionMap:d}}addHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n);return s.setValue(i.row,i.column,i),a.set(i.id,{row:i.row,column:i.column,link:i}),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:i,type:"add"}),!0}updateHyperLink(e,n,i,s,a=!1){const{matrix:d,positionMap:c}=this._ensureMap(e,n),l=c.get(i);if(!l)return!0;const u=d.getValue(l.row,l.column);return u&&(Object.assign(u,s),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:{display:u.display,payload:u.payload},id:i,type:"update",silent:a})),!0}updateHyperLinkRef(e,n,i,s,a=!1){const{matrix:d,positionMap:c}=this._ensureMap(e,n),l=c.get(i);if(!l)return!0;let u=d.getValue(l.row,l.column);return!u||u.id!==i?u=l.link:d.realDeleteValue(l.row,l.column),Object.assign(u,s),c.set(i,{...s,link:u}),d.setValue(s.row,s.column,u),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:s,id:i,type:"updateRef",silent:a}),!0}removeHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(i);if(!d)return!1;a.delete(i);const c=s.getValue(d.row,d.column);return c&&c.id===i&&s.realDeleteValue(d.row,d.column),this._linkUpdate$.next({unitId:e,subUnitId:n,payload:d.link,type:"remove"}),!0}getHyperLink(e,n,i){const{matrix:s,positionMap:a}=this._ensureMap(e,n),d=a.get(i);if(d)return s.getValue(d.row,d.column)}getHyperLinkByLocation(e,n,i,s){const{matrix:a}=this._ensureMap(e,n);return a.getValue(i,s)}getHyperLinkByLocationSync(e,n,i,s){var g,f,_,h,y;const{matrix:a}=this._ensureMap(e,n),d=this._univerInstanceService.getUnit(e,o.UniverInstanceType.UNIVER_SHEET),c=(g=d==null?void 0:d.getSheetBySheetId(n))==null?void 0:g.getCellRaw(i,s),l=((y=(h=c==null?void 0:c.v)!=null?h:(_=(f=c==null?void 0:c.p)==null?void 0:f.body)==null?void 0:_.dataStream.slice(0,-2))!=null?y:"").toString(),u=a.getValue(i,s);if(u)return{...u,display:l}}getSubUnit(e,n){const{matrix:i}=this._ensureMap(e,n),s=[];return i.forValue((a,d,c)=>{c&&s.push(c)}),s}getUnit(e){const n=this._linkMap.get(e);return n?Array.from(n.keys()).map(i=>{const s=this.getSubUnit(e,i);return{unitId:e,subUnitId:i,links:s}}):[]}deleteUnit(e){const n=this.getUnit(e);this._linkMap.delete(e),this._linkPositionMap.delete(e),this._linkUpdate$.next({type:"unload",unitId:e,unitLinks:n})}getAll(){return Array.from(this._linkMap.keys()).map(n=>this.getUnit(n))}},p.HyperLinkModel=Re([Me(0,o.IUniverInstanceService)],p.HyperLinkModel);var L=(r=>(r.SHEET="gid",r.RANGE="range",r.DEFINE_NAME="rangeid",r.INVALID="invalid",r.URL="url",r))(L||{});const Ce="sheets-hyper-link.config",Ue={},E={type:o.CommandType.MUTATION,id:"sheets.mutation.add-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,link:s}=t;return e.addHyperLink(n,i,s)}},k={type:o.CommandType.MUTATION,id:"sheets.mutation.remove-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s}=t;return e.removeHyperLink(n,i,s)}},B={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,payload:s,id:a}=t;return e.updateHyperLink(n,i,a,s,!1)}},W={type:o.CommandType.MUTATION,id:"sheets.mutation.update-hyper-link-ref",handler(r,t){if(!t)return!1;const e=r.get(p.HyperLinkModel),{unitId:n,subUnitId:i,id:s,row:a,column:d,silent:c}=t;return e.updateHyperLinkRef(n,i,s,{row:a,column:d},c)}},se="SHEET_HYPER_LINK_PLUGIN",$="err";var Le=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ee=(r,t,e,n)=>{for(var i=n>1?void 0:n?we(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Le(t,e,i),i},z=(r,t)=>(e,n)=>t(e,n,r);let G=class extends o.Disposable{constructor(t,e,n,i){super();U(this,"_disposableMap",new Map);U(this,"_watchDisposableMap",new Map);U(this,"_rangeDisableMap",new Map);U(this,"_rangeWatcherMap",new Map);U(this,"_handlePositionChange",(t,e,n,i,s)=>{const a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};return i?{redos:[{id:W.id,params:{unitId:t,subUnitId:e,id:n.id,row:i.startRow,column:i.startColumn,silent:s}}],undos:[{id:W.id,params:{unitId:t,subUnitId:e,id:n.id,row:a.startRow,column:a.startColumn,silent:s}}]}:{redos:[{id:k.id,params:{unitId:t,subUnitId:e,id:n.id}}],undos:[{id:E.id,params:{unitId:t,subUnitId:e,link:n}}]}});this._refRangeService=t,this._hyperLinkModel=e,this._selectionManagerService=n,this._commandService=i,this._initData(),this._initRefRange()}_registerPosition(t,e,n){const i=n.id,s={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row},a=d=>{const c=m.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,d,{selectionManagerService:this._selectionManagerService}),l=Array.isArray(c)?c[0]:c;return l&&l.startColumn===s.startColumn&&l.startRow===s.startRow?{undos:[],redos:[]}:this._handlePositionChange(t,e,n,l,!1)};this._disposableMap.set(i,this._refRangeService.registerRefRange(s,a,t,e))}_watchPosition(t,e,n){const i=n.id,s={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._watchDisposableMap.set(i,this._refRangeService.watchRange(t,e,s,(a,d)=>{const{redos:c}=this._handlePositionChange(t,e,n,d,!0);o.sequenceExecuteAsync(c,this._commandService,{onlyLocal:!0})},!0))}_unregisterPosition(t){const e=this._disposableMap.get(t);e==null||e.dispose(),this._disposableMap.delete(t)}_unwatchPosition(t){const e=this._watchDisposableMap.get(t);e==null||e.dispose(),this._watchDisposableMap.delete(t)}_registerRange(t,e,n,i=!1){var s,a,d;if(n.startsWith("#")){const c=new URLSearchParams(n.slice(1)),l={gid:(s=c.get("gid"))!=null?s:"",range:(a=c.get("range"))!=null?a:"",rangeid:(d=c.get("rangeid"))!=null?d:""};if(l.range&&l.gid){const u=l.gid,g=M.deserializeRangeWithSheet(l.range).range;if(o.isValidRange(g)&&l.range!==$){const f=_=>{const h=m.handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests(g,_,{selectionManagerService:this._selectionManagerService});return h&&M.serializeRange(h)===M.serializeRange(g)?{redos:[],undos:[]}:{redos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:`#gid=${u}&range=${h?M.serializeRange(h):"err"}`}}}],undos:[{id:B.id,params:{unitId:t,subUnitId:u,id:e,payload:{payload:n}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(g,f,t,u)),i||this._rangeWatcherMap.set(e,this._refRangeService.watchRange(t,u,g,(_,h)=>{this._hyperLinkModel.updateHyperLink(t,u,e,{payload:`#gid=${u}&range=${h?M.serializeRange(h):"err"}`},!0)},!0))}}}}_unregisterRange(t){const e=this._rangeDisableMap.get(t);e==null||e.dispose(),this._rangeDisableMap.delete(t)}_unwatchRange(t){const e=this._rangeWatcherMap.get(t);e==null||e.dispose(),this._rangeWatcherMap.delete(t)}_initData(){this._hyperLinkModel.getAll().forEach(e=>{e.forEach(n=>{const{unitId:i,subUnitId:s,links:a}=n;a.forEach(d=>{this._registerPosition(i,s,d),this._watchPosition(i,s,d),this._registerRange(i,d.id,d.payload)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(t=>{switch(t.type){case"add":{this._registerPosition(t.unitId,t.subUnitId,t.payload),this._watchPosition(t.unitId,t.subUnitId,t.payload),this._registerRange(t.unitId,t.payload.id,t.payload.payload);break}case"remove":{this._unregisterPosition(t.payload.id),this._unwatchPosition(t.payload.id),this._unregisterRange(t.payload.id),this._unwatchRange(t.payload.id);break}case"updateRef":{const{unitId:e,subUnitId:n,id:i,silent:s}=t,a=this._hyperLinkModel.getHyperLink(e,n,i);if(!a)return;this._unregisterPosition(i),this._registerPosition(e,n,a),s||(this._unwatchPosition(i),this._watchPosition(e,n,a));break}case"unload":{const{unitLinks:e}=t;e.forEach(n=>{const{links:i}=n;i.forEach(s=>{this._unregisterPosition(s.id),this._unwatchPosition(s.id),this._unregisterRange(s.id),this._unwatchRange(s.id)})});break}case"update":{t.silent||this._unwatchRange(t.id),this._unregisterRange(t.id),this._registerRange(t.unitId,t.id,t.payload.payload,t.silent);break}}})),this.disposeWithMe(o.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};G=Ee([z(0,o.Inject(m.RefRangeService)),z(1,o.Inject(p.HyperLinkModel)),z(2,o.Inject(m.SheetsSelectionsService)),z(3,o.ICommandService)],G);var ke=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Pe=(r,t,e,n)=>{for(var i=n>1?void 0:n?be(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&ke(t,e,i),i},ee=(r,t)=>(e,n)=>t(e,n,r);let K=class extends o.Disposable{constructor(r,t,e){super(),this._sheetInterceptorService=r,this._univerInstanceService=t,this._hyperLinkModel=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var t;if(r.id===m.RemoveSheetCommand.id){const e=r.params,n=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!n)return{redos:[],undos:[]};const i=n.getUnitId(),s=e.subUnitId||((t=n.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const a=this._hyperLinkModel.getSubUnit(i,s),d=a.map(l=>({id:k.id,params:{unitId:i,subUnitId:s,id:l.id}})),c=a.map(l=>({id:E.id,params:{unitId:i,subUnitId:s,link:l}}));return{redos:d,undos:c}}return{redos:[],undos:[]}}}))}};K=Pe([ee(0,o.Inject(m.SheetInterceptorService)),ee(1,o.IUniverInstanceService),ee(2,o.Inject(p.HyperLinkModel))],K);var He=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Ne=(r,t,e,n)=>{for(var i=n>1?void 0:n?Te(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&He(t,e,i),i},te=(r,t)=>(e,n)=>t(e,n,r);let Y=class extends o.Disposable{constructor(t,e,n){super();U(this,"_refRangeMap",new Map);this._commandService=t,this._univerInstanceService=e,this._refRangeService=n,this._initWorkbookLoad(),this._initWorkbookUnload(),this._initSetRangesListener()}_enusreMap(t,e){let n=this._refRangeMap.get(t);n||(n=new Map,this._refRangeMap.set(t,n));let i=n.get(e);return i||(i=new o.ObjectMatrix,n.set(e,i)),i}_isLegalRangeUrl(t,e){var i,s,a;const n=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!n)return null;if(e&&e.startsWith("#")){const d=new URLSearchParams(e.slice(1)),c={gid:(i=d.get("gid"))!=null?i:"",range:(s=d.get("range"))!=null?s:"",rangeid:(a=d.get("rangeid"))!=null?a:""};if(c.range&&c.gid){const l=c.gid,u=n.getSheetBySheetId(l);if(!u)return null;const g=M.deserializeRangeWithSheet(c.range).range;if(o.isValidRange(g,u)&&c.range!==$)return g}}return null}_registerRange(t,e,n,i,s){var d,c,l,u;const a=this._enusreMap(t,e);if((c=(d=s.body)==null?void 0:d.customRanges)!=null&&c.some(g=>{var f;return g.rangeType===o.CustomRangeType.HYPERLINK&&this._isLegalRangeUrl(t,(f=g.properties)==null?void 0:f.url)})){const g=new o.DisposableCollection;let f=!1;(u=(l=s.body)==null?void 0:l.customRanges)==null||u.forEach(_=>{var h;if(_.rangeType===o.CustomRangeType.HYPERLINK){const y=(h=_.properties)==null?void 0:h.url,R=this._isLegalRangeUrl(t,y);R&&(f=!0,g.add(this._refRangeService.watchRange(t,e,R,(v,C)=>{_.properties.url=`#gid=${e}&range=${C?M.serializeRange(C):$}`})))}}),f&&a.setValue(n,i,g)}}_initWorkbookLoad(){const t=e=>{const n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId(),a=this._enusreMap(n,s);i.getCellMatrix().forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,s,d,c,l.p)})})};this._univerInstanceService.getAllUnitsForType(o.UniverInstanceType.UNIVER_SHEET).forEach(e=>{t(e)}),this.disposeWithMe(this._univerInstanceService.unitAdded$.subscribe(e=>{e.type===o.UniverInstanceType.UNIVER_SHEET&&t(e)}))}_initWorkbookUnload(){this._univerInstanceService.unitDisposed$.subscribe(t=>{if(t.type===o.UniverInstanceType.UNIVER_SHEET){const e=t,n=e.getUnitId();e.getSheets().forEach(i=>{const s=i.getSheetId();this._enusreMap(n,s).forValue((d,c,l)=>{l&&l.dispose()})}),this._refRangeMap.delete(n)}})}_initSetRangesListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===m.SetRangeValuesMutation.id){const e=t.params,{unitId:n,subUnitId:i,cellValue:s}=e,a=this._enusreMap(n,i);s&&new o.ObjectMatrix(s).forValue((d,c,l)=>{const u=a.getValue(d,c);u&&u.dispose(),l&&l.p&&this._registerRange(n,i,d,c,l.p)})}}))}};Y=Ne([te(0,o.ICommandService),te(1,o.IUniverInstanceService),te(2,o.Inject(m.RefRangeService))],Y);var Oe=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Ve=(r,t,e,n)=>{for(var i=n>1?void 0:n?De(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Oe(t,e,i),i},F=(r,t)=>(e,n)=>t(e,n,r);let q=class extends o.Disposable{constructor(r,t,e,n){super(),this._sheetInterceptorService=r,this._hyperLinkModel=t,this._selectionManagerService=e,this._univerInstanceService=n,this._initCommandInterceptor(),this._initAfterEditor()}_initCommandInterceptor(){this._initSetRangeValuesCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{if(r.id===m.SetRangeValuesCommand.id){const t=r.params,{unitId:e,subUnitId:n}=t,i=[],s=[];return t.cellValue&&new o.ObjectMatrix(t.cellValue).forValue((a,d)=>{const c=this._hyperLinkModel.getHyperLinkByLocation(e,n,a,d);c&&(i.push({id:k.id,params:{unitId:e,subUnitId:n,id:c.id}}),s.push({id:E.id,params:{unitId:e,subUnitId:n,link:c}}))}),{undos:s,redos:i}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{if(r.id===m.ClearSelectionContentCommand.id||r.id===m.ClearSelectionAllCommand.id||r.id===m.ClearSelectionFormatCommand.id){const t=[],e=[],n=this._selectionManagerService.getCurrentLastSelection(),i=m.getSheetCommandTarget(this._univerInstanceService);if(n&&i){const{unitId:s,subUnitId:a}=i;o.Range.foreach(n.range,(d,c)=>{const l=this._hyperLinkModel.getHyperLinkByLocation(s,a,d,c);l&&(t.push({id:k.id,params:{unitId:s,subUnitId:a,id:l.id}}),e.push({id:E.id,params:{unitId:s,subUnitId:a,link:l}}))})}return{redos:t,undos:e}}return{redos:[],undos:[]}}}))}_initAfterEditor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(m.AFTER_CELL_EDIT,{handler:(r,t,e)=>{if(!r||r.p)return e(r);if(typeof r.v=="string"&&o.Tools.isLegalUrl(r.v)&&r.v[r.v.length-1]!==" "){const{unitId:n,subUnitId:i}=t,s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),a=s==null?void 0:s.getSheetBySheetId(i);if(!a)return e(r);const d=a.getBlankCellDocumentModel(r);if(!d.documentModel)return e(r);const c=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:r.v.length,collapsed:!1},body:{dataStream:`${r.v}`,customRanges:[{startIndex:0,endIndex:r.v.length-1,rangeId:o.generateRandomId(),rangeType:o.CustomRangeType.HYPERLINK,properties:{url:r.v}}]},doc:d.documentModel});if(!c)return e(r);const l=d.documentModel.getBody();return o.TextX.apply(l,c.serialize()),e({...r,p:{id:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:l,documentStyle:{pageSize:{width:1/0,height:1/0}}}})}return e(r)}}))}};q=Ve([F(0,o.Inject(m.SheetInterceptorService)),F(1,o.Inject(p.HyperLinkModel)),F(2,o.Inject(m.SheetsSelectionsService)),F(3,o.IUniverInstanceService)],q);const ae={type:o.CommandType.COMMAND,id:"sheets.command.add-hyper-link",async handler(r,t){if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,t);if(!d)return!1;const{unitId:c,subUnitId:l,workbook:u,worksheet:g}=d,{link:f}=t,{payload:_,display:h,row:y,column:R,id:v}=f,C=g.getCell(y,R),S=g.getBlankCellDocumentModel(C),w=S.documentModel.getSnapshot(),I=o.Tools.deepClone(w.body);if(!I)return!1;let b;if(h?b=o.BuildTextUtils.selection.replace({selection:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!0},body:{dataStream:`${h}`,customRanges:[{startIndex:0,endIndex:h.length-1,rangeType:o.CustomRangeType.HYPERLINK,rangeId:v,properties:{url:_}}]},doc:S.documentModel}):b=o.BuildTextUtils.customRange.add({body:I,range:{startOffset:0,endOffset:I.dataStream.length-2,collapsed:!1},rangeId:v,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:_,refId:v}}),!b)return!1;const j=o.TextX.apply(I,b.serialize()),P={p:{...w,body:j},t:o.CellValueType.STRING},N=await a.onWriteCell(u,g,y,R,P),O={unitId:c,subUnitId:l,cellValue:{[f.row]:{[f.column]:N}}},ie={id:m.SetRangeValuesMutation.id,params:O},Z=m.SetRangeValuesUndoMutationFactory(r,O),re={id:m.SetRangeValuesMutation.id,params:Z},A=[ie],D=[re],V=s.getHyperLinkByLocation(c,l,y,R);return V&&(A.push({id:k.id,params:{unitId:c,subUnitId:l,id:V.id}}),D.push({id:E.id,params:{unitId:c,subUnitId:l,link:V}})),await o.sequenceExecuteAsync(A,e)?(n.pushUndoRedo({redoMutations:A,undoMutations:D,unitID:c}),!0):!1}},oe={id:"sheets.command.add-rich-hyper-link",type:o.CommandType.COMMAND,handler:async(r,t)=>{if(!t)return!1;const{documentId:e,link:n}=t,i=r.get(o.ICommandService),s=o.generateRandomId(),{payload:a}=n,d=x.addCustomRangeBySelectionFactory(r,{unitId:e,rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:a,refId:s}});return d?i.syncExecuteCommand(d.id,d.params):!1}},de={type:o.CommandType.COMMAND,id:"sheets.command.cancel-hyper-link",handler(r,t){var P,N;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=m.getSheetCommandTarget(i,t);if(!a)return!1;const{row:d,column:c,id:l}=t,{unitId:u,subUnitId:g,worksheet:f}=a,_=f.getCell(d,c);if(!_)return!1;const h=f.getCellDocumentModelWithFormula(_);if(!(h!=null&&h.documentModel))return!1;const y=o.Tools.deepClone(h.documentModel.getSnapshot());if(!((N=(P=y.body)==null?void 0:P.customRanges)==null?void 0:N.find(O=>O.rangeId===l)))return!1;const v=o.BuildTextUtils.customRange.delete(r,{documentDataModel:h.documentModel,rangeId:l});if(!v)return!1;const C=o.TextX.apply(y.body,v.serialize()),S=[],w=[],I={unitId:u,subUnitId:g,cellValue:{[d]:{[c]:{p:{...y,body:C},t:o.CellValueType.STRING}}}};S.push({id:m.SetRangeValuesMutation.id,params:I});const b=m.SetRangeValuesUndoMutationFactory(r,I);w.push({id:m.SetRangeValuesMutation.id,params:b});const j=s.getHyperLinkByLocation(u,g,d,c);return j&&(S.push({id:k.id,params:{unitId:u,subUnitId:g,id:l}}),w.push({id:E.id,params:{unitId:u,subUnitId:g,link:{...j}}})),o.sequenceExecute(S,e).result?(n.pushUndoRedo({redoMutations:S,undoMutations:w,unitID:u}),!0):!1}},ce={type:o.CommandType.COMMAND,id:"sheets.command.cancel-rich-hyper-link",handler(r,t){var u,g;if(!t)return!1;const{id:e,documentId:n}=t,i=r.get(o.ICommandService),a=r.get(o.IUniverInstanceService).getUnit(n,o.UniverInstanceType.UNIVER_DOC),d=(g=(u=a==null?void 0:a.getBody())==null?void 0:u.customRanges)==null?void 0:g.find(f=>f.rangeId===e);let c=null;d&&d.endIndex===a.getBody().dataStream.length-3&&(c={dataStream:" "});const l=x.deleteCustomRangeFactory(r,{unitId:n,rangeId:e,insert:c});return l?i.syncExecuteCommand(l.id,l.params):!1}},le={type:o.CommandType.COMMAND,id:"sheets.command.update-hyper-link",async handler(r,t){var _e,ye,ve;if(!t)return!1;const e=r.get(o.ICommandService),n=r.get(o.IUndoRedoService),i=r.get(o.IUniverInstanceService),s=r.get(p.HyperLinkModel),a=r.get(m.SheetInterceptorService),d=m.getSheetCommandTarget(i,{unitId:t.unitId,subUnitId:t.subUnitId});if(!d)return!1;const{payload:c,row:l,column:u,id:g}=t,{workbook:f,worksheet:_,unitId:h,subUnitId:y}=d,{payload:R,display:v=""}=c,C=_.getCell(l,u);if(!C)return!1;const S=_.getCellDocumentModelWithFormula(C);if(!(S!=null&&S.documentModel))return!1;const w=S.documentModel.getSnapshot(),I=(ye=(_e=w.body)==null?void 0:_e.customRanges)==null?void 0:ye.find(Xe=>Xe.rangeId===g);if(!I)return!1;const b=o.generateRandomId(),T=(ve=o.getBodySlice(S.documentModel.getBody(),I.startIndex,I.endIndex+1).textRuns)==null?void 0:ve[0];T&&(T.ed=v.length+1);const P=x.replaceSelectionFactory(r,{unitId:h,body:{dataStream:`${v}`,customRanges:[{rangeId:b,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:v.length-1,properties:{url:R}}],textRuns:T?[T]:void 0},selection:{startOffset:I.startIndex,endOffset:I.endIndex+1,collapsed:!1},doc:S.documentModel});if(!P)return!1;const N=o.TextX.apply(o.Tools.deepClone(w.body),P.textX.serialize()),O={p:{...w,body:N},t:o.CellValueType.STRING},ie=await a.onWriteCell(f,_,l,u,O),Z={id:m.SetRangeValuesMutation.id,params:{unitId:h,subUnitId:y,cellValue:{[l]:{[u]:ie}}}},re=m.SetRangeValuesUndoMutationFactory(r,Z.params),A={id:m.SetRangeValuesMutation.id,params:re},D=[Z],V=[A],Q=s.getHyperLinkByLocation(h,y,l,u);return Q&&(D.push({id:k.id,params:{unitId:h,subUnitId:y,id:Q.id}}),V.push({id:E.id,params:{unitId:h,subUnitId:y,link:Q}})),await o.sequenceExecuteAsync(D,e)?(n.pushUndoRedo({redoMutations:D,undoMutations:V,unitID:h}),!0):!1}},ue={type:o.CommandType.COMMAND,id:"sheets.command.update-rich-hyper-link",handler:(r,t)=>{var h,y,R,v;if(!t)return!1;const{documentId:e,payload:n,id:i}=t,s=r.get(o.IUniverInstanceService),a=r.get(o.ICommandService),d=s.getUnit(e,o.UniverInstanceType.UNIVER_DOC);if(!d)return!1;const c=(y=(h=d.getBody())==null?void 0:h.customRanges)==null?void 0:y.find(C=>C.rangeId===i);if(!c)return!1;const l=(R=t.payload.display)!=null?R:"",u=o.generateRandomId(),f=(v=o.getBodySlice(d.getBody(),c.startIndex,c.endIndex+1).textRuns)==null?void 0:v[0];f&&(f.ed=l.length+1);const _=x.replaceSelectionFactory(r,{unitId:e,body:{dataStream:`${l}`,customRanges:[{rangeId:u,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:l.length-1,properties:{url:n.payload}}],textRuns:f?[f]:void 0},selection:{startOffset:c.startIndex,endOffset:c.endIndex+1,collapsed:!1},doc:d});return _?a.syncExecuteCommand(_.id,_.params):!1}};var $e=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Ae=(r,t,e,n)=>{for(var i=n>1?void 0:n?je(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&$e(t,e,i),i},xe=(r,t)=>(e,n)=>t(e,n,r);let J=class extends o.Disposable{constructor(r){super(),this._commandService=r,this._registerCommands()}_registerCommands(){[ae,le,de,ue,ce,oe,E,B,k,W].forEach(r=>{this._commandService.registerCommand(r)})}};J=Ae([xe(0,o.ICommandService)],J);var pe=(r=>(r[r.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",r[r.UNIVER_DOC=1]="UNIVER_DOC",r[r.UNIVER_SHEET=2]="UNIVER_SHEET",r[r.UNIVER_SLIDE=3]="UNIVER_SLIDE",r[r.UNIVER_PROJECT=4]="UNIVER_PROJECT",r[r.UNRECOGNIZED=-1]="UNRECOGNIZED",r))(pe||{}),Be=Object.defineProperty,We=Object.getOwnPropertyDescriptor,ze=(r,t,e,n)=>{for(var i=n>1?void 0:n?We(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Be(t,e,i),i},ge=(r,t)=>(e,n)=>t(e,n,r);let X=class extends o.Disposable{constructor(r,t){super(),this._resourceManagerService=r,this._hyperLinkModel=t,this._initSnapshot()}_initSnapshot(){const r=e=>{const n=this._hyperLinkModel.getUnit(e),i={};return n?(n.forEach(s=>{i[s.subUnitId]=s.links.map(({display:a,...d})=>d)}),JSON.stringify(i)):""},t=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:se,businesses:[pe.UNIVER_SHEET],toJson:e=>r(e),parseJson:e=>t(e),onUnLoad:e=>{this._hyperLinkModel.deleteUnit(e)},onLoad:async(e,n)=>{Object.keys(n).forEach(i=>{n[i].forEach(a=>{this._hyperLinkModel.addHyperLink(e,i,a)})})}}))}};X=ze([ge(0,o.IResourceManagerService),ge(1,o.Inject(p.HyperLinkModel))],X);var Ge=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ye=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ke(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Ge(t,e,i),i},ne=(r,t)=>(e,n)=>t(e,n,r);p.SheetsHyperLinkParserService=class{constructor(t,e,n){this._univerInstanceService=t,this._localeService=e,this._definedNamesService=n}buildHyperLink(t,e,n){return`#${L.SHEET}=${e}${n?`&${typeof n=="string"?L.DEFINE_NAME:L.RANGE}=${typeof n=="string"?n:M.serializeRange(n)}`:""}`}parseHyperLink(t){var e,n,i,s;if(t.startsWith("#")){const a=new URLSearchParams(t.slice(1)),d={gid:(e=a.get("gid"))!=null?e:"",range:(n=a.get("range"))!=null?n:"",rangeid:(i=a.get("rangeid"))!=null?i:"",unitid:(s=a.get("unitid"))!=null?s:""},c=this._getURLName(d);return{type:c.type,name:c.name,url:t,searchObj:d}}else return{type:L.URL,name:t,url:t,searchObj:null}}_getURLName(t){var u;const{gid:e,range:n,rangeid:i,unitid:s}=t,a=s?this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),d={type:L.INVALID,name:this._localeService.t("hyperLink.message.refError")};if(!a)return d;const c=e?a.getSheetBySheetId(e):a.getActiveSheet(),l=(u=c==null?void 0:c.getName())!=null?u:"";if(n){if(!c)return d;const g=M.deserializeRangeWithSheet(n).range;return o.isValidRange(g,c)&&n!==$?{type:L.RANGE,name:M.serializeRangeWithSheet(l,g)}:d}if(i){const g=this._definedNamesService.getValueById(a.getUnitId(),i);return g?{type:L.DEFINE_NAME,name:g.formulaOrRefString}:d}if(e){const g=a.getSheetBySheetId(e);return g?{type:L.SHEET,name:g.getName()}:d}return d}},p.SheetsHyperLinkParserService=Ye([ne(0,o.IUniverInstanceService),ne(1,o.Inject(o.LocaleService)),ne(2,M.IDefinedNamesService)],p.SheetsHyperLinkParserService);var he=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,qe=(r,t,e)=>t in r?he(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Je=(r,t,e,n)=>{for(var i=n>1?void 0:n?Fe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&he(t,e,i),i},me=(r,t)=>(e,n)=>t(e,n,r),fe=(r,t,e)=>qe(r,typeof t!="symbol"?t+"":t,e);p.UniverSheetsHyperLinkPlugin=class extends o.Plugin{constructor(t=Ue,e,n){super(),this._config=t,this._injector=e,this._configService=n;const{...i}=this._config;this._configService.setConfig(Ce,i)}onStarting(){o.registerDependencies(this._injector,[[p.HyperLinkModel],[p.SheetsHyperLinkParserService],[X],[J],[G],[q],[K],[Y]]),o.touchDependencies(this._injector,[[G],[X],[J],[q],[K],[Y]])}},fe(p.UniverSheetsHyperLinkPlugin,"pluginName",se),fe(p.UniverSheetsHyperLinkPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),p.UniverSheetsHyperLinkPlugin=Je([o.DependentOn(m.UniverSheetsPlugin),me(1,o.Inject(o.Injector)),me(2,o.IConfigService)],p.UniverSheetsHyperLinkPlugin),p.AddHyperLinkCommand=ae,p.AddHyperLinkMutation=E,p.AddRichHyperLinkCommand=oe,p.CancelHyperLinkCommand=de,p.CancelRichHyperLinkCommand=ce,p.ERROR_RANGE=$,p.RemoveHyperLinkMutation=k,p.SheetHyperLinkType=L,p.UpdateHyperLinkCommand=le,p.UpdateHyperLinkMutation=B,p.UpdateHyperLinkRefMutation=W,p.UpdateRichHyperLinkCommand=ue,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-hyper-link",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -29,10 +29,14 @@
|
|
|
29
29
|
"require": "./lib/cjs/*",
|
|
30
30
|
"types": "./lib/types/index.d.ts"
|
|
31
31
|
},
|
|
32
|
+
"./facade": {
|
|
33
|
+
"import": "./lib/es/facade.js",
|
|
34
|
+
"require": "./lib/cjs/facade.js",
|
|
35
|
+
"types": "./lib/types/facade/index.d.ts"
|
|
36
|
+
},
|
|
32
37
|
"./lib/*": "./lib/*"
|
|
33
38
|
},
|
|
34
|
-
"main": "./lib/
|
|
35
|
-
"module": "./lib/es/index.js",
|
|
39
|
+
"main": "./lib/es/index.js",
|
|
36
40
|
"types": "./lib/types/index.d.ts",
|
|
37
41
|
"publishConfig": {
|
|
38
42
|
"access": "public"
|
|
@@ -47,19 +51,20 @@
|
|
|
47
51
|
"rxjs": ">=7.0.0"
|
|
48
52
|
},
|
|
49
53
|
"dependencies": {
|
|
50
|
-
"@univerjs/protocol": "0.1.39-alpha.
|
|
51
|
-
"@univerjs/
|
|
52
|
-
"@univerjs/
|
|
53
|
-
"@univerjs/
|
|
54
|
+
"@univerjs/protocol": "0.1.39-alpha.45",
|
|
55
|
+
"@univerjs/docs": "0.5.0-beta.0",
|
|
56
|
+
"@univerjs/core": "0.5.0-beta.0",
|
|
57
|
+
"@univerjs/sheets": "0.5.0-beta.0",
|
|
58
|
+
"@univerjs/engine-formula": "0.5.0-beta.0"
|
|
54
59
|
},
|
|
55
60
|
"devDependencies": {
|
|
56
61
|
"rxjs": "^7.8.1",
|
|
57
62
|
"typescript": "^5.6.3",
|
|
58
|
-
"vite": "^5.4.
|
|
59
|
-
"vitest": "^2.1.
|
|
60
|
-
"@univerjs-infra/shared": "0.
|
|
63
|
+
"vite": "^5.4.11",
|
|
64
|
+
"vitest": "^2.1.5",
|
|
65
|
+
"@univerjs-infra/shared": "0.5.0-beta.0"
|
|
61
66
|
},
|
|
62
|
-
"
|
|
67
|
+
"space": {
|
|
63
68
|
".": {
|
|
64
69
|
"import": "./lib/es/index.js",
|
|
65
70
|
"require": "./lib/cjs/index.js",
|
|
@@ -70,6 +75,11 @@
|
|
|
70
75
|
"require": "./lib/cjs/*",
|
|
71
76
|
"types": "./lib/types/index.d.ts"
|
|
72
77
|
},
|
|
78
|
+
"./facade": {
|
|
79
|
+
"import": "./lib/es/facade.js",
|
|
80
|
+
"require": "./lib/cjs/facade.js",
|
|
81
|
+
"types": "./lib/types/facade/index.d.ts"
|
|
82
|
+
},
|
|
73
83
|
"./lib/*": "./lib/*"
|
|
74
84
|
},
|
|
75
85
|
"scripts": {
|
|
@@ -77,6 +87,7 @@
|
|
|
77
87
|
"test:watch": "vitest",
|
|
78
88
|
"coverage": "vitest run --coverage",
|
|
79
89
|
"lint:types": "tsc --noEmit",
|
|
80
|
-
"build": "
|
|
81
|
-
}
|
|
90
|
+
"build": "univer-cli build"
|
|
91
|
+
},
|
|
92
|
+
"module": "./lib/es/index.js"
|
|
82
93
|
}
|